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

public class JDBCOITransport extends OITransport implements StateBufferSaveable
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.
  • 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 transport
      cFactory - A connection factory used to provide the transport with a java.sql.Connection object
      tblInfo - 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 validation
      schema - The DB schema pattern, for columns validation
      reservedNameList -
      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's getData() method and process it via the receiver's processData() method.
      Specified by:
      dataIsAvailable in interface DataReceiverIfc
      Specified by:
      dataIsAvailable in class OITransport
    • processData

      public void processData(DCFieldContainer record)
      Accept an OIRecord to be written to the database. This method will block until the data can be successfully written.
      Specified by:
      processData in interface DataReceiverIfc
      Specified by:
      processData in class OITransport
      Parameters:
      record - OIRecord containing the data.
    • processData

      public void processData(DCFieldContainer[] records) throws NodeProcessingException
      Accept some OIRecord objects to be written to the database. This method will block until the data can be successfully written.
      Specified by:
      processData in interface DataReceiverIfc
      Parameters:
      records - An array of OIRecord 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 interface Runnable
      Specified by:
      run in class OITransport
    • 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 interface DCTransport
      Specified by:
      shutdown in class OITransport
    • saveState

      public void saveState(StateBuffer buffer) throws StateException
      Save the Object's state to the given buffer.
      Specified by:
      saveState in interface StateBufferSaveable
      Parameters:
      buffer - Buffer for writing
      Throws:
      StateException
    • restoreState

      public void restoreState(StateBuffer buffer) throws StateException
      Restore the Object's state from the given buffer.
      Specified by:
      restoreState in interface StateBufferSaveable
      Parameters:
      buffer - Buffer for reading
      Throws:
      StateException
    • setConnectionFactory

      public void setConnectionFactory(JDBCConnectionFactoryIfc factory)
      Set the object used to provide this transport with a connection to the database.
      Parameters:
      factory - A JDBCConnectionFactoryIfc object that knows how to connect to the desired database and can provide this transport with a java.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 interface DCTransport
      Overrides:
      isHealthy in class OITransport
      Returns:
      true if the transport is healthy, false otherwise
    • connect

      protected void connect() throws SQLException
      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

      public void handleLostConnection(String mesg)
    • isBadRecordFormat

      public boolean isBadRecordFormat()
    • setBadRecordFormat

      public void setBadRecordFormat(boolean badRecordFormat)