Class TcpEITransport

java.lang.Object
com.nt.udc.ndk.node.EITransport
com.nt.udc.ei.transport.TcpEITransport
All Implemented Interfaces:
DataProviderIfc, DCTransport, FileDataProviderIfc, Runnable

public class TcpEITransport extends EITransport
This class will create a socket on the given host/port and listen for incoming data via TCP. The bytes read from the socket will be placed within a QueuedTcpPacket object and stored in a queue until the transport's DataReceiver requests data via the getData() or getBulkData() method. At that time, a QueuedTcpPacket is popped off the queue and given to the transport's DCRecordFactoryIfc object via the factory's getRecords() method. The DCFieldContainer objects returned from the factory will then be supplied to the DataReceiver.
  • Constructor Details

    • TcpEITransport

      public TcpEITransport(EINode einode, DCRecordFactoryIfc factory, String host, int prt) throws NodeStartException
      Construct a new TcpEITransport to be used within the specified EINode. The transport will create a socket on the given host/port and generate TcpEIRecord() objects of the specified type.
      Parameters:
      einode - Reference to the EINode containing the transport
      factory - DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.
      host - The host name / IP address to listen to
      port - The port number to listen on
      Throws:
      NodeStartException
    • TcpEITransport

      public TcpEITransport(EINode einode, DCRecordFactoryIfc factory, String host, int prt, int pktSize, int qSize) throws NodeStartException
      Construct a new TcpEITransport to be used within the specified EINode. The transport will create a socket on the given host/port and generate TcpEIRecord() objects of the specified type.
      Parameters:
      einode - Reference to the EINode containing the transport
      factory - DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.
      host - The host name / IP address to listen to
      pktSize - The number of bytes in an incoming data 'packet'
      qSize - The maximum number of 'packets' allowed in the queue
      port - The port number to listen on
      Throws:
      NodeStartException
  • Method Details

    • isDataAvailable

      public boolean isDataAvailable()
      This method is used by the DataReceiver to ask this provider if data is available.
      Specified by:
      isDataAvailable in interface DataProviderIfc
      Specified by:
      isDataAvailable in class EITransport
      Returns:
      true, if data is available
    • getData

      public DCFieldContainer getData()
      This method is used by the DataReceiver to fetch a single DCFieldContainer.
      Specified by:
      getData in interface DataProviderIfc
      Specified by:
      getData in class EITransport
      Returns:
      DCFieldContainer.
    • getBulkData

      public DCFieldContainer[] getBulkData()
      This method is used by the DataReceiver to fetch a set of DCFieldContainers.
      Specified by:
      getBulkData in interface DataProviderIfc
      Specified by:
      getBulkData in class EITransport
      Returns:
      DCFieldContainer object array, containing the data that is for processing
    • run

      public void run()
      This method is used when the EITransport runs within its own thread. Each 'packet' of bytes that is read from the socket will be placed in a QueuedTcpPacket object and stored in a queue until the data is requested by the transport's DataReceiver.
      Specified by:
      run in interface Runnable
      Specified by:
      run in class EITransport
    • shutdown

      public void shutdown()
      Stop the transport. To ensure no loss of data, the transport should continue to supply any queued data to its DataReceiver.
      Specified by:
      shutdown in interface DCTransport
      Specified by:
      shutdown in class EITransport
    • isShutdownOnError

      public boolean isShutdownOnError()
      Indicates whether transport should shutdown upon processing error
    • setShutdownOnError

      public void setShutdownOnError(boolean flag)
      Indicates whether transport should shutdown upon processing error
      Parameters:
      flag - true, if error should cause a shutdown. Default is false.
    • isHealthy

      public boolean isHealthy()
      This method is used to check if the transport is fully functional.
      Specified by:
      isHealthy in interface DCTransport
      Overrides:
      isHealthy in class EITransport
      Returns:
      true if the transport is healthy, false otherwise