public class TcpOITransport extends OITransport implements StateBufferSaveable
dataProvider, filedataProvider, node, pollingInterval| Constructor and Description |
|---|
TcpOITransport(OINode oinode,
java.lang.String host,
int prt)
Construct a new TcpOITransport to be used within the specified OINode.
|
TcpOITransport(OINode oinode,
java.lang.String host,
int prt,
boolean wait)
Construct a new TcpOITransport to be used within the specified OINode.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
close()
Close the socket and its output stream.
|
protected void |
connect()
Create the socket and attempt to establish a connection.
|
void |
dataIsAvailable()
This method allows the transport's DataProvider to tell the transport
that data is waiting to be 'picked up'.
|
boolean |
isConnected()
Indicates whether this TcpOITransport is connected to the TCP socket
|
boolean |
isDataAvailable()
Indicates whether data is available from the transport's DataProvider
|
boolean |
isHealthy()
Indicates whether the transport is fully functional
|
boolean |
isProcessingData()
Indicates whether this TcpOITransport is currently processing data
|
boolean |
isRunning()
Indicates whether this TcpOITransport is running
|
boolean |
isWaitForReconnect()
Indicates whether this TcpOITransport is configured to, in the event
of a lost connection, wait for the connection to be re-established
before sending the data.
|
void |
processData(DCFieldContainer record)
Accept an
OIRecord to be transmitted via TCP. |
void |
processData(DCFieldContainer[] records)
Accept some
OIRecord objects to be transmitted via TCP. |
protected void |
reconnect()
Attempt to re-establish the connection.
|
void |
restoreState(StateBuffer buffer)
Restore the Object's state from the given buffer.
|
void |
run()
This method is used when the OITransport runs within its own thread.
|
void |
saveState(StateBuffer buffer)
Save the Object's state to the given buffer.
|
protected void |
setProcessingData(boolean value)
Sets the boolean indicating whether the transport is currently
processing data.
|
protected void |
setRunning(boolean run)
Sets the boolean which indicates whether the transport is running
|
void |
setWaitForReconnect(boolean value)
Sets the boolean indicating whether the transport should, in the
event of a lost connection, wait for the connection to be
re-established before sending the current record or drop the current
record and move on to processing the next record.
|
void |
shutdown()
Stop the transport.
|
protected void |
write(byte[] bytes)
Write the given bytes to the socket's output stream.
|
fileDataIsAvailable, getDataProvider, getFileDataProvider, getNode, getPollingInterval, getRealNarsOut, incrementOut, processEndOfFileData, processFileData, processFileData, processRejectFile, processStartOfFileData, setDataProvider, setFileDataProvider, setNode, setPollingInterval, setTransactionIDpublic TcpOITransport(OINode oinode, java.lang.String host, int prt) throws NodeStartException
oinode - Reference to the OINode containing the transporthost - The host name / IP address to which to connectport - The port number to which to connectNodeStartExceptionpublic TcpOITransport(OINode oinode, java.lang.String host, int prt, boolean wait) throws NodeStartException
oinode - Reference to the OINode containing the transporthost - The host name / IP address to which to connectport - The port number to which to connectwait - true, if transport should hold the
current record until the connection has been
re-established. Otherwise, the current record will
be dropped and processing will continue with the
next record.NodeStartExceptionpublic void dataIsAvailable()
getData() method and process it via the receiver's
processData() method.dataIsAvailable in interface DataReceiverIfcdataIsAvailable in class OITransportpublic void processData(DCFieldContainer record) throws NodeProcessingException
OIRecord to be transmitted via TCP. This
method will block until the data can be successfully transmitted,
unless the transport is configured to drop records while the
connection is lost.processData in interface DataReceiverIfcprocessData in class OITransportrecord - OIRecord containing the data.NodeProcessingExceptionpublic void processData(DCFieldContainer[] records) throws NodeProcessingException
OIRecord objects to be transmitted via TCP.
This method will block until the data can be successfully transmitted,
unless the transport is configured to drop records while the
connection is lost.processData in interface DataReceiverIfcrecords - An array of OIRecord objects.NodeProcessingExceptionpublic void saveState(StateBuffer buffer) throws StateException
saveState in interface StateBufferSaveablebuffer - Buffer for writingStateExceptionpublic void restoreState(StateBuffer buffer) throws StateException
restoreState in interface StateBufferSaveablebuffer - Buffer for readingStateExceptionpublic void run()
run in interface java.lang.Runnablerun in class OITransportpublic void shutdown()
If the TCP connection has been lost and processing has been stoppped until the connection has been re-established, an indicator will be written to the node's scratch directory, marking the position in the current NAR file. When the transport is restarted, this marker will be read and processing will resume at that point in the NAR file.
shutdown in interface DCTransportshutdown in class OITransportpublic boolean isHealthy()
isHealthy in interface DCTransportisHealthy in class OITransportpublic boolean isConnected()
public boolean isDataAvailable()
public boolean isRunning()
protected void setRunning(boolean run)
public boolean isProcessingData()
protected void setProcessingData(boolean value)
public boolean isWaitForReconnect()
true, if transport will hold the current record
until the connection has been re-established. Otherwise,
the current record will be dropped and processing will
continue with the next record.public void setWaitForReconnect(boolean value)
protected void connect()
throws java.io.IOException
java.io.IOExceptionprotected void write(byte[] bytes)
throws java.io.IOException
bytes - Bytes to be written to the socket's output stream.java.io.IOExceptionprotected void close()
protected void reconnect()