Package com.nt.udc.ei.transport
Class TcpEITransport
java.lang.Object
com.nt.udc.ndk.node.EITransport
com.nt.udc.ei.transport.TcpEITransport
- All Implemented Interfaces:
DataProviderIfc
,DCTransport
,FileDataProviderIfc
,Runnable
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.-
Field Summary
Fields inherited from class com.nt.udc.ndk.node.EITransport
dataReceiver, fdChecked, filedataReceiver, fileduplicateCheck, fileToProcess, inputCount, lockFile, movedFile, node, pollingInterval, processing, processingData, running
-
Constructor Summary
ConstructorsConstructorDescriptionTcpEITransport
(EINode einode, DCRecordFactoryIfc factory, String host, int prt) Construct a new TcpEITransport to be used within the specified EINode.TcpEITransport
(EINode einode, DCRecordFactoryIfc factory, String host, int prt, int pktSize, int qSize) Construct a new TcpEITransport to be used within the specified EINode. -
Method Summary
Modifier and TypeMethodDescriptionThis method is used by the DataReceiver to fetch a set of DCFieldContainers.getData()
This method is used by the DataReceiver to fetch a single DCFieldContainer.boolean
This method is used by the DataReceiver to ask this provider if data is available.boolean
This method is used to check if the transport is fully functional.boolean
Indicates whether transport should shutdown upon processing errorvoid
run()
This method is used when the EITransport runs within its own thread.void
setShutdownOnError
(boolean flag) Indicates whether transport should shutdown upon processing errorvoid
shutdown()
Stop the transport.Methods inherited from class com.nt.udc.ndk.node.EITransport
getCurrArchFile, getData, getDataReceiver, getDubCheckObj, getDupCheckFlag, getFileBulkData, getFileData, getFileDataReceiver, getFileList, getMovedFileStatus, getNode, getPollingInterval, getProcessedArchFile, handleRejectOfFile, incrementIn, incrementIn, isEndOfFile, isFileDataAvailable, isProcessing, isProcessingData, isStartOfFile, moveCurrentFileToBackUp, openInputFile, rejectFile, removeProcessedFile, setCountsSuspect, setDataReceiver, setFileDataReceiver, setFileToProcess, setMovedFileStatus, setNode, setPollingInterval, setProcessedArchFile, setProcessing, signalBatchCompletion, validOIMinorType
-
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 transportfactory
- DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.host
- The host name / IP address to listen toport
- 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 transportfactory
- DCRecordFactoryIfc() object used to generate the desired EIRecord() objects.host
- The host name / IP address to listen topktSize
- The number of bytes in an incoming data 'packet'qSize
- The maximum number of 'packets' allowed in the queueport
- 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 interfaceDataProviderIfc
- Specified by:
isDataAvailable
in classEITransport
- Returns:
true
, if data is available
-
getData
This method is used by the DataReceiver to fetch a single DCFieldContainer.- Specified by:
getData
in interfaceDataProviderIfc
- Specified by:
getData
in classEITransport
- Returns:
- DCFieldContainer.
-
getBulkData
This method is used by the DataReceiver to fetch a set of DCFieldContainers.- Specified by:
getBulkData
in interfaceDataProviderIfc
- Specified by:
getBulkData
in classEITransport
- 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 aQueuedTcpPacket
object and stored in a queue until the data is requested by the transport's DataReceiver.- Specified by:
run
in interfaceRunnable
- Specified by:
run
in classEITransport
-
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 interfaceDCTransport
- Specified by:
shutdown
in classEITransport
-
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 isfalse
.
-
isHealthy
public boolean isHealthy()This method is used to check if the transport is fully functional.- Specified by:
isHealthy
in interfaceDCTransport
- Overrides:
isHealthy
in classEITransport
- Returns:
- true if the transport is healthy, false otherwise
-