Package gov.usgs.earthquake.distribution
Class SocketProductReceiverHandler
java.lang.Object
gov.usgs.earthquake.distribution.SocketProductReceiverHandler
- All Implemented Interfaces:
Runnable
Handles incoming socket including lock/unlock on storage
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BinaryIOProtected Variable for BinaryIOstatic final intbuffer for PDL protocol.protected StringProtected Variable for a string of protocolVersionprotected final SocketProductReceiverProtected Variable for SocketProductReceiverprotected final SocketProtected Variable for Socket -
Constructor Summary
ConstructorsConstructorDescriptionSocketProductReceiverHandler(SocketProductReceiver receiver, Socket socket) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidAcquire write lock in receiver storage.Read PDL protocol version.voidRelease write lock in receiver storeage.voidrun()Process incoming socket connection.voidsendException(OutputStream out, Exception e) Send an exception to the user.voidsendString(OutputStream out, String str) Send a string to the user.
-
Field Details
-
PDL_PROTOCOL_BUFFER
public static final int PDL_PROTOCOL_BUFFERbuffer for PDL protocol. Set to 1024- See Also:
-
io
Protected Variable for BinaryIO -
receiver
Protected Variable for SocketProductReceiver -
socket
Protected Variable for Socket -
protocolVersion
Protected Variable for a string of protocolVersion
-
-
Constructor Details
-
SocketProductReceiverHandler
Constructor- Parameters:
receiver- SocketProductReceiversocket- Socket
-
-
Method Details
-
acquireWriteLock
Acquire write lock in receiver storage.- Parameters:
id- product to lock.
-
releaseWriteLock
Release write lock in receiver storeage.- Parameters:
id- product to unlock.
-
readProtocolVersion
Read PDL protocol version.- Parameters:
in- input stream to read- Returns:
- version, or null if not the PDL protocol.
- Throws:
IOException- if IO error occurs
-
run
public void run()Process incoming socket connection. -
sendException
Send an exception to the user.- Parameters:
out- output stream where exception message is writtene- exception to write
-
sendString
Send a string to the user.- Parameters:
out- output stream where exception message is writtenstr- string to write- Throws:
IOException- if IO error occurs
-