Class SocketProductReceiverHandler

java.lang.Object
gov.usgs.earthquake.distribution.SocketProductReceiverHandler
All Implemented Interfaces:
Runnable

public class SocketProductReceiverHandler extends Object implements Runnable
Handles incoming socket including lock/unlock on storage
See Also:
  • Field Details

    • PDL_PROTOCOL_BUFFER

      public static final int PDL_PROTOCOL_BUFFER
      buffer for PDL protocol. Set to 1024
      See Also:
    • io

      protected final BinaryIO io
      Protected Variable for BinaryIO
    • receiver

      protected final SocketProductReceiver receiver
      Protected Variable for SocketProductReceiver
    • socket

      protected final Socket socket
      Protected Variable for Socket
    • protocolVersion

      protected String protocolVersion
      Protected Variable for a string of protocolVersion
  • Constructor Details

    • SocketProductReceiverHandler

      public SocketProductReceiverHandler(SocketProductReceiver receiver, Socket socket)
      Constructor
      Parameters:
      receiver - SocketProductReceiver
      socket - Socket
  • Method Details

    • 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 String readProtocolVersion(InputStream in) throws IOException
      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.
      Specified by:
      run in interface Runnable
    • sendException

      public void sendException(OutputStream out, Exception e)
      Send an exception to the user.
      Parameters:
      out - output stream where exception message is written
      e - exception to write
    • sendString

      public void sendString(OutputStream out, String str) throws IOException
      Send a string to the user.
      Parameters:
      out - output stream where exception message is written
      str - string to write
      Throws:
      IOException - if IO error occurs