Class UdpEITransport

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

public class UdpEITransport extends EITransport
This class will create a socket on the given port and listen for incoming DatagramPacket objects. Each packet will be placed within a QueuedUdpPacket object and stored in a queue until the transport's DataReceiver requests data via the getData() or getBulkData() method. At that time, a QueuedUdpPacket 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

    • UdpEITransport

      public UdpEITransport(EINode einode, DCRecordFactoryIfc factory, int prt) throws NodeStartException
      Construct a new UdpEITransport to be used within the specified EINode. The transport will create a socket on the given port on the local host and use the given factory to generate EIRecord() objects.
      Parameters:
      einode - Reference to the EINode containing the transport
      factory - DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.
      prt - The port number to listen on
      Throws:
      NodeStartException
    • UdpEITransport

      public UdpEITransport(EINode einode, DCRecordFactoryIfc factory, String host, int prt) throws NodeStartException
      Construct a new UdpEITransport to be used within the specified EINode. The transport will create a socket on the given remote host/port and use the given factory to generate EIRecord() objects.
      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
      prt - The port number to listen on
      Throws:
      NodeStartException
    • UdpEITransport

      public UdpEITransport(EINode einode, DCRecordFactoryIfc factory, int prt, int pktSize) throws NodeStartException
      Construct a new UdpEITransport to be used within the specified EINode. The transport will create a socket on the given port on the local host and use the given factory to generate EIRecord() objects.
      Parameters:
      einode - Reference to the EINode containing the transport
      factory - DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.
      prt - The port number to listen on
      pktSize - Number of bytes in a data 'packet' (default 4096)
      Throws:
      NodeStartException
    • UdpEITransport

      public UdpEITransport(EINode einode, DCRecordFactoryIfc factory, int prt, int pktSize, int socketBufSize) throws NodeStartException
      Construct a new UdpEITransport to be used within the specified EINode. The transport will create a socket on the given port on the local host and use the given factory to generate EIRecord() objects.
      Parameters:
      einode - Reference to the EINode containing the transport
      factory - DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.
      prt - The port number to listen on
      pktSize - Number of bytes in a data 'packet' (default 4096)
      socketBufSize - Socket buffer size (default 65536)
      Throws:
      NodeStartException
    • UdpEITransport

      public UdpEITransport(EINode einode, DCRecordFactoryIfc factory, ResponseDatagramFactory responseFactory, int prt, int pktSize) throws NodeStartException
      Construct a new UdpEITransport to be used within the specified EINode. The transport will create a socket on the given port on the local host and use the given factory to generate EIRecord() objects.
      Parameters:
      einode - Reference to the EINode containing the transport
      factory - DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.
      prt - The port number to listen on
      pktSize - Number of bytes in a data 'packet' (default 4096)
      Throws:
      NodeStartException
    • UdpEITransport

      public UdpEITransport(EINode einode, DCRecordFactoryIfc factory, String host, int prt, int pktSize) throws NodeStartException
      Construct a new UdpEITransport to be used within the specified EINode. The transport will create a socket on the given remote host/port and use the given factory to generate EIRecord() objects.
      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
      prt - The port number to listen on
      pktSize - Number of bytes in a data 'packet' (default 4096)
      Throws:
      NodeStartException
    • UdpEITransport

      public UdpEITransport(EINode einode, DCRecordFactoryIfc factory, ResponseDatagramFactory responseFactory, String host, int prt, int pktSize) throws NodeStartException
      Construct a new UdpEITransport to be used within the specified EINode. The transport will create a socket on the given remote host/port and use the given factory to generate EIRecord() objects.
      Parameters:
      einode - Reference to the EINode containing the transport
      factory - DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.
      responseFactory - Factory object to construct the response datagram
      host - The host name / IP address to listen to
      prt - The port number to listen on
      pktSize - Number of bytes in a data 'packet' (default 4096)
      Throws:
      NodeStartException
    • UdpEITransport

      public UdpEITransport(EINode einode, DCRecordFactoryIfc factory, ResponseDatagramFactory responseFactory, String host, int prt, int pktSize, int idleRecWriteTime) throws NodeStartException
      Construct a new UdpEITransport to be used within the specified EINode. The transport will create a socket on the given remote host/port and use the given factory to generate EIRecord() objects.
      Parameters:
      einode - Reference to the EINode containing the transport
      factory - DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.
      responseFactory - Factory object to construct the response datagram
      host - The host name / IP address to listen to
      prt - The port number to listen on
      pktSize - Number of bytes in a data 'packet' (default 4096)
      idleRecWriteTime - Idle record write time is made configurable (default 10 seconds)
      Throws:
      NodeStartException
    • UdpEITransport

      public UdpEITransport(EINode einode, DCRecordFactoryIfc factory, ResponseDatagramFactory responseFactory, String host, int prt, int pktSize, int idleRecWriteTime, int socketBufSize) throws NodeStartException
      Construct a new UdpEITransport to be used within the specified EINode. The transport will create a socket on the given remote host/port and use the given factory to generate EIRecord() objects.
      Parameters:
      einode - Reference to the EINode containing the transport
      factory - DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.
      responseFactory - Factory object to construct the response datagram
      host - The host name / IP address to listen to
      prt - The port number to listen on
      pktSize - Number of bytes in a data 'packet' (default 4096)
      idleRecWriteTime - Idle record write time is made configurable (default 10 seconds)
      socketBufSize - Socket buffer size (default 65536)
      Throws:
      NodeStartException
  • Method Details

    • initMesManager

      protected void initMesManager(int idleRecWriteTime)
    • 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()
      Description copied from class: EITransport
      This method is used by the DataReceiver to fetch a single
      Specified by:
      getData in interface DataProviderIfc
      Specified by:
      getData in class EITransport
      Returns:
      DCFieldContainer.
    • getBulkData

      public DCFieldContainer[] getBulkData()
      Description copied from class: EITransport
      This method is used by the DataReceiver to fetch a set of DCFieldContainer objects.
      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 DatagramPacket object that is received will be placed in a QueuedUdpPacket 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.
    • send

      public void send(DatagramPacket response)
      This method is used to send the given datagram packet back to the originator of the incoming data.
      Parameters:
      response - The datagram packet to be sent
    • beginReconfigure

      public void beginReconfigure()
      Sets this transport into a reconfiguration state. While in the reconfiguration state, data is not accessible (even if available). Specifically, isDataAvailable() will always return false and getData() and getBulkData() will always return null while this transport is being reconfigured. Packets will still be read off the line while the transport is reconfigured.
    • endReconfigure

      public void endReconfigure()
      Ends reconfiguration state, allowing data to be accessed again.
    • isReconfiguring

      public boolean isReconfiguring()
      Returns value of reconfiguring flag.
    • reconfigure

      public void reconfigure(DCRecordFactoryIfc factory, ResponseDatagramFactory responseFactory, int radius_port)
      Reconfigures the record factory and queue size of this UDP transport.
      Parameters:
      factory - DCRecordFactoryIfc object used to generate the desired EI record objects
      responseFactory -
      radius_port - The Radius port number
    • reconfigure

      public void reconfigure(DCRecordFactoryIfc factory, ResponseDatagramFactory responseFactory, int port, int idleRecWrTime)
    • 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
    • resetLoggingState

      public void resetLoggingState()
      Resets state for conditionally logged messages. This method should be called from the node's clearStatus() method.