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 BinaryIO
Protected Variable for BinaryIOstatic final int
buffer for PDL protocol.protected String
Protected Variable for a string of protocolVersionprotected final SocketProductReceiver
Protected Variable for SocketProductReceiverprotected final Socket
Protected Variable for Socket -
Constructor Summary
ConstructorsConstructorDescriptionSocketProductReceiverHandler
(SocketProductReceiver receiver, Socket socket) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
Acquire write lock in receiver storage.Read PDL protocol version.void
Release write lock in receiver storeage.void
run()
Process incoming socket connection.void
sendException
(OutputStream out, Exception e) Send an exception to the user.void
sendString
(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
-