Package com.nt.udc.oi.node.jdbc
Class JDBCOITransport
java.lang.Object
com.nt.udc.ndk.node.OITransport
com.nt.udc.oi.node.jdbc.JDBCOITransport
- All Implemented Interfaces:
DataReceiverIfc
,DCTransport
,FileDataReceiverIfc
,StateBufferSaveable
,Runnable
This transport is responsible for retrieving JDBCOIRecord objects from
its DataProvider and writing the data contained within those records
to the configured database as described by the 'tblInfo' mapping
provided to the constructor.
-
Field Summary
Fields inherited from class com.nt.udc.ndk.node.OITransport
dataProvider, filedataProvider, node, pollingInterval
-
Constructor Summary
ConstructorsConstructorDescriptionJDBCOITransport
(OINode oinode, JDBCConnectionFactoryIfc cFactory, com.nt.udc.admin.FieldDescriptor[] tblInfo, com.nt.udc.admin.FieldDescriptor[] lobInfo, String catalog, String schema, List<List<String>> reservedNameList, boolean badRecordFormat, int batchTimeOut, int retrybatchTimeoutCount) Construct a new JDBCOITransport. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
close
(boolean commit) Close the connection to the database.protected void
connect()
Attempt to establish the connection with the database.void
This method allows the transport's DataProvider to tell the transport that data is waiting to be 'picked up'.void
handleLostConnection
(String mesg) boolean
boolean
Indicates whether this JDBCOITransport is connected to the databaseboolean
Indicates whether data is available from the transport's DataProviderboolean
Indicates whether the transport is fully functionalboolean
Indicates whether this JDBCOITransport is currently processing databoolean
Indicates whether this JDBCOITransport is runningvoid
processData
(DCFieldContainer record) Accept anOIRecord
to be written to the database.void
processData
(DCFieldContainer[] records) Accept someOIRecord
objects to be written to the database.protected void
Attempt to re-establish the database 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.void
setBadRecordFormat
(boolean badRecordFormat) void
Set the object used to provide this transport with a connection to the database.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 runningvoid
shutdown()
Stop the transport.void
stopNode()
Methods inherited from class com.nt.udc.ndk.node.OITransport
fileDataIsAvailable, getDataProvider, getFileDataProvider, getNode, getPollingInterval, getRealNarsOut, incrementOut, processEndOfFileData, processFileData, processFileData, processRejectFile, processStartOfFileData, setDataProvider, setFileDataProvider, setNode, setPollingInterval, setTransactionID
-
Constructor Details
-
JDBCOITransport
public JDBCOITransport(OINode oinode, JDBCConnectionFactoryIfc cFactory, com.nt.udc.admin.FieldDescriptor[] tblInfo, com.nt.udc.admin.FieldDescriptor[] lobInfo, String catalog, String schema, List<List<String>> reservedNameList, boolean badRecordFormat, int batchTimeOut, int retrybatchTimeoutCount) throws NodeStartException Construct a new JDBCOITransport. The transport will connect to the database as appropriate according to the connection factory and insert the data contained within the incoming OI records to the database.- Parameters:
oinode
- Reference to the OINode containing the transportcFactory
- A connection factory used to provide the transport with a java.sql.Connection objecttblInfo
- An array of FieldDescriptor objects that define the relationship between record attributes and DB tables/columns. The 'tag' member of the FieldDescriptor object is expected to be in the format of 'DB_table.DB_column'lobInfo
- An array of FieldDescriptor objects that contains information regarding which of the record attributes are LOB type.catalog
- The DB catalog name, for columns validationschema
- The DB schema pattern, for columns validationreservedNameList
-- Throws:
NodeStartException
-
-
Method Details
-
dataIsAvailable
public void dataIsAvailable()This method allows the transport's DataProvider to tell the transport that data is waiting to be 'picked up'. It is then the responsibility of the transport to retrieve the data via the provider'sgetData()
method and process it via the receiver'sprocessData()
method.- Specified by:
dataIsAvailable
in interfaceDataReceiverIfc
- Specified by:
dataIsAvailable
in classOITransport
-
processData
Accept anOIRecord
to be written to the database. This method will block until the data can be successfully written.- Specified by:
processData
in interfaceDataReceiverIfc
- Specified by:
processData
in classOITransport
- Parameters:
record
-OIRecord
containing the data.
-
processData
Accept someOIRecord
objects to be written to the database. This method will block until the data can be successfully written.- Specified by:
processData
in interfaceDataReceiverIfc
- Parameters:
records
- An array ofOIRecord
objects.- Throws:
NodeProcessingException
-
run
public void run()This method is used when the OITransport runs within its own thread. The method will retrieve the data from the transport's DataProvider pass the DCFieldContainer() objects on to the processData() method.- Specified by:
run
in interfaceRunnable
- Specified by:
run
in classOITransport
-
stopNode
public void stopNode() -
shutdown
public void shutdown()Stop the transport. To ensure no loss of data, this method will wait for the transport to obtain and process all pending data from its DataProvider, unless it is shutting down due to a processing error.- Specified by:
shutdown
in interfaceDCTransport
- Specified by:
shutdown
in classOITransport
-
saveState
Save the Object's state to the given buffer.- Specified by:
saveState
in interfaceStateBufferSaveable
- Parameters:
buffer
- Buffer for writing- Throws:
StateException
-
restoreState
Restore the Object's state from the given buffer.- Specified by:
restoreState
in interfaceStateBufferSaveable
- Parameters:
buffer
- Buffer for reading- Throws:
StateException
-
setConnectionFactory
Set the object used to provide this transport with a connection to the database.- Parameters:
factory
- AJDBCConnectionFactoryIfc
object that knows how to connect to the desired database and can provide this transport with ajava.sql.Connection
object for communicating with that database.
-
isConnected
public boolean isConnected()Indicates whether this JDBCOITransport is connected to the database -
isDataAvailable
public boolean isDataAvailable()Indicates whether data is available from the transport's DataProvider -
isRunning
public boolean isRunning()Indicates whether this JDBCOITransport is running -
setRunning
protected void setRunning(boolean run) Sets the boolean which indicates whether the transport is running -
isProcessingData
public boolean isProcessingData()Indicates whether this JDBCOITransport is currently processing data -
setProcessingData
protected void setProcessingData(boolean value) Sets the boolean indicating whether the transport is currently processing data. -
isHealthy
public boolean isHealthy()Indicates whether the transport is fully functional- Specified by:
isHealthy
in interfaceDCTransport
- Overrides:
isHealthy
in classOITransport
- Returns:
- true if the transport is healthy, false otherwise
-
connect
Attempt to establish the connection with the database.- Throws:
SQLException
-
close
protected void close(boolean commit) Close the connection to the database.- Parameters:
commit
-true
, if any pending transactions should be commited prior to closing the database connection.
-
reconnect
protected void reconnect()Attempt to re-establish the database connection. -
handleLostConnection
-
isBadRecordFormat
public boolean isBadRecordFormat() -
setBadRecordFormat
public void setBadRecordFormat(boolean badRecordFormat)
-