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, setTransactionID
public 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 connectNodeStartException
public 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.NodeStartException
public void dataIsAvailable()
getData()
method and process it via the receiver's
processData()
method.dataIsAvailable
in interface DataReceiverIfc
dataIsAvailable
in class OITransport
public 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 DataReceiverIfc
processData
in class OITransport
record
- OIRecord
containing the data.NodeProcessingException
public 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 DataReceiverIfc
records
- An array of OIRecord
objects.NodeProcessingException
public void saveState(StateBuffer buffer) throws StateException
saveState
in interface StateBufferSaveable
buffer
- Buffer for writingStateException
public void restoreState(StateBuffer buffer) throws StateException
restoreState
in interface StateBufferSaveable
buffer
- Buffer for readingStateException
public void run()
run
in interface java.lang.Runnable
run
in class OITransport
public 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 DCTransport
shutdown
in class OITransport
public boolean isHealthy()
isHealthy
in interface DCTransport
isHealthy
in class OITransport
public 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.IOException
protected void write(byte[] bytes) throws java.io.IOException
bytes
- Bytes to be written to the socket's output stream.java.io.IOException
protected void close()
protected void reconnect()