Package gov.usgs.earthquake.distribution
Class SocketProductReceiverHandler
- java.lang.Object
-
- gov.usgs.earthquake.distribution.SocketProductReceiverHandler
-
- All Implemented Interfaces:
java.lang.Runnable
public class SocketProductReceiverHandler extends java.lang.Object implements java.lang.Runnable
-
-
Field Summary
Fields Modifier and Type Field Description protected BinaryIOioProtected Variable for BinaryIOstatic intPDL_PROTOCOL_BUFFERbuffer for PDL protocol.protected java.lang.StringprotocolVersionProtected Variable for a string of protocolVersionprotected SocketProductReceiverreceiverProtected Variable for SocketProductReceiverprotected java.net.SocketsocketProtected Variable for Socket
-
Constructor Summary
Constructors Constructor Description SocketProductReceiverHandler(SocketProductReceiver receiver, java.net.Socket socket)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquireWriteLock(ProductId id)Acquire write lock in receiver storage.java.lang.StringreadProtocolVersion(java.io.InputStream in)Read PDL protocol version.voidreleaseWriteLock(ProductId id)Release write lock in receiver storeage.voidrun()Process incoming socket connection.voidsendException(java.io.OutputStream out, java.lang.Exception e)Send an exception to the user.voidsendString(java.io.OutputStream out, java.lang.String str)Send a string to the user.
-
-
-
Field Detail
-
PDL_PROTOCOL_BUFFER
public static final int PDL_PROTOCOL_BUFFER
buffer for PDL protocol. Set to 1024- See Also:
- Constant Field Values
-
io
protected final BinaryIO io
Protected Variable for BinaryIO
-
receiver
protected final SocketProductReceiver receiver
Protected Variable for SocketProductReceiver
-
socket
protected final java.net.Socket socket
Protected Variable for Socket
-
protocolVersion
protected java.lang.String protocolVersion
Protected Variable for a string of protocolVersion
-
-
Constructor Detail
-
SocketProductReceiverHandler
public SocketProductReceiverHandler(SocketProductReceiver receiver, java.net.Socket socket)
Constructor- Parameters:
receiver- SocketProductReceiversocket- Socket
-
-
Method Detail
-
acquireWriteLock
public void acquireWriteLock(ProductId id)
Acquire write lock in receiver storage.- Parameters:
id- product to lock.
-
releaseWriteLock
public void releaseWriteLock(ProductId id)
Release write lock in receiver storeage.- Parameters:
id- product to unlock.
-
readProtocolVersion
public java.lang.String readProtocolVersion(java.io.InputStream in) throws java.io.IOExceptionRead PDL protocol version.- Parameters:
in- input stream to read- Returns:
- version, or null if not the PDL protocol.
- Throws:
java.io.IOException- if IO error occurs
-
run
public void run()
Process incoming socket connection.- Specified by:
runin interfacejava.lang.Runnable
-
sendException
public void sendException(java.io.OutputStream out, java.lang.Exception e)Send an exception to the user.- Parameters:
out- output stream where exception message is writtene- exception to write
-
sendString
public void sendString(java.io.OutputStream out, java.lang.String str) throws java.io.IOExceptionSend a string to the user.- Parameters:
out- output stream where exception message is writtenstr- string to write- Throws:
java.io.IOException- if IO error occurs
-
-