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 BinaryIO
io
Protected Variable for BinaryIOstatic int
PDL_PROTOCOL_BUFFER
buffer for PDL protocol.protected java.lang.String
protocolVersion
Protected Variable for a string of protocolVersionprotected SocketProductReceiver
receiver
Protected Variable for SocketProductReceiverprotected java.net.Socket
socket
Protected 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 void
acquireWriteLock(ProductId id)
Acquire write lock in receiver storage.java.lang.String
readProtocolVersion(java.io.InputStream in)
Read PDL protocol version.void
releaseWriteLock(ProductId id)
Release write lock in receiver storeage.void
run()
Process incoming socket connection.void
sendException(java.io.OutputStream out, java.lang.Exception e)
Send an exception to the user.void
sendString(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.IOException
Read 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:
run
in 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.IOException
Send 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
-
-