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 voidclose(boolean commit) Close the connection to the database.protected voidconnect()Attempt to establish the connection with the database.voidThis method allows the transport's DataProvider to tell the transport that data is waiting to be 'picked up'.voidhandleLostConnection(String mesg) booleanbooleanIndicates whether this JDBCOITransport is connected to the databasebooleanIndicates whether data is available from the transport's DataProviderbooleanIndicates whether the transport is fully functionalbooleanIndicates whether this JDBCOITransport is currently processing databooleanIndicates whether this JDBCOITransport is runningvoidprocessData(DCFieldContainer record) Accept anOIRecordto be written to the database.voidprocessData(DCFieldContainer[] records) Accept someOIRecordobjects to be written to the database.protected voidAttempt to re-establish the database connection.voidrestoreState(StateBuffer buffer) Restore the Object's state from the given buffer.voidrun()This method is used when the OITransport runs within its own thread.voidsaveState(StateBuffer buffer) Save the Object's state to the given buffer.voidsetBadRecordFormat(boolean badRecordFormat) voidSet the object used to provide this transport with a connection to the database.protected voidsetProcessingData(boolean value) Sets the boolean indicating whether the transport is currently processing data.protected voidsetRunning(boolean run) Sets the boolean which indicates whether the transport is runningvoidshutdown()Stop the transport.voidstopNode()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:
dataIsAvailablein interfaceDataReceiverIfc- Specified by:
dataIsAvailablein classOITransport
-
processData
Accept anOIRecordto be written to the database. This method will block until the data can be successfully written.- Specified by:
processDatain interfaceDataReceiverIfc- Specified by:
processDatain classOITransport- Parameters:
record-OIRecordcontaining the data.
-
processData
Accept someOIRecordobjects to be written to the database. This method will block until the data can be successfully written.- Specified by:
processDatain interfaceDataReceiverIfc- Parameters:
records- An array ofOIRecordobjects.- 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:
runin interfaceRunnable- Specified by:
runin 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:
shutdownin interfaceDCTransport- Specified by:
shutdownin classOITransport
-
saveState
Save the Object's state to the given buffer.- Specified by:
saveStatein interfaceStateBufferSaveable- Parameters:
buffer- Buffer for writing- Throws:
StateException
-
restoreState
Restore the Object's state from the given buffer.- Specified by:
restoreStatein 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- AJDBCConnectionFactoryIfcobject that knows how to connect to the desired database and can provide this transport with ajava.sql.Connectionobject 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:
isHealthyin interfaceDCTransport- Overrides:
isHealthyin 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)
-