Class NPLFieldProcessor

java.lang.Object
com.nt.udc.ndk.node.DCFieldProcessor
com.nt.udc.ndk.node.NPLFieldProcessor
All Implemented Interfaces:
DataProviderIfc, DataReceiverIfc, FileDataProviderIfc, FileDataReceiverIfc, StateFreezable, Runnable
Direct Known Subclasses:
FlexibleAggregatorFieldProcessor, HCDeDupFieldProcessor, JDBCOIFieldProcessor, MXNPLFieldProcessor, Sol42FieldProcessor

public class NPLFieldProcessor extends DCFieldProcessor implements StateFreezable
  • Field Details

    • logger

      protected LoggerIfc logger
      Object to use to log messages
    • waitForInputLock

      protected Object waitForInputLock
      Used to pause the processing when waiting for more input
    • nplProgram

      protected NPLProgramIfc nplProgram
    • currentState

      protected RuntimeState currentState
      State-related members
    • freezeHelper

      protected StateFreezeHelper freezeHelper
    • fileLevelTransaction

      protected boolean fileLevelTransaction
    • currentTransactionId

      protected String currentTransactionId
  • Constructor Details

    • NPLFieldProcessor

      public NPLFieldProcessor(Class outputDataType, LoggerIfc inLogger, String scratchDir, String fileName) throws NodeProcessingException
      Calls parent's constructor.
      Parameters:
      outputDataType - Class of Objects that this NPLFieldProcessor will produce
      inLogger - Object that will be used for logging messages from this NPLFieldProcessor.
      scratchDir - Directory to write out records containing
      fileName - Either the name of the NPL text file or the precompiled NPLProgram class file to use
      Throws:
      NodeProcessingException
    • NPLFieldProcessor

      public NPLFieldProcessor(Class outputDataType, LoggerIfc inLogger, String scratchDir, String fileName, IDCMethodHandler methodHandler) throws NodeProcessingException
      Calls other constructor with 4 parameters, and then sets the methodHandler that will be used by the NPLProgram.
      Parameters:
      outputDataType - Class of Objects that this NPLFieldProcessor will produce
      inLogger - Object that will be used for logging messages from this NPLFieldProcessor.
      scratchDir - Directory to write out records containing errors
      fileName - Either the name of the NPL text file or the precompiled NPLProgram class file to us
      methodHandler - An instance of the IDCMethodHandler interface to give to the NPL Program.
      Throws:
      NodeProcessingException
    • NPLFieldProcessor

      public NPLFieldProcessor(Class outputDataType, LoggerIfc inLogger, String scratchDir, String fileName, IDCMethodHandler methodHandler, boolean isFileLevelTransaction) throws NodeProcessingException
      Calls other constructor with 4 parameters, and then sets the methodHandler that will be used by the NPLProgram.
      Parameters:
      outputDataType - Class of Objects that this NPLFieldProcessor will produce
      inLogger - Object that will be used for logging messages from this NPLFieldProcessor.
      scratchDir - Directory to write out records containing errors
      fileName - Either the name of the NPL text file or the precompiled NPLProgram class file to us
      methodHandler - An instance of the IDCMethodHandler interface to give to the NPL Program.
      isFileLevelTransaction - Specifies if this field processor can be used in File level transaction
      Throws:
      NodeProcessingException
    • NPLFieldProcessor

      public NPLFieldProcessor(Class outputDataType, LoggerIfc inLogger, String scratchDir, String fileName, boolean isFileLeveTranasction) throws NodeProcessingException
      Calls parent's constructor.
      Parameters:
      outputDataType - Class of Objects that this NPLFieldProcessor will produce
      inLogger - Object that will be used for logging messages from this NPLFieldProcessor.
      scratchDir - Directory to write out records containing
      fileName - Either the name of the NPL text file or the precompiled NPLProgram class file to use
      isFileLevelTransaction - Specifies if this field processor can be used in File level transaction
      Throws:
      NodeProcessingException
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
      Specified by:
      run in class DCFieldProcessor
    • shutdown

      public void shutdown()
      Performs all steps necessary to gracefully stop this FieldProcessor.
      Specified by:
      shutdown in class DCFieldProcessor
    • isDataAvailable

      public boolean isDataAvailable()
      Description copied from interface: DataProviderIfc
      Allows a DataReceiver to determine whether some data is available for processing
      Specified by:
      isDataAvailable in interface DataProviderIfc
      Specified by:
      isDataAvailable in class DCFieldProcessor
      Returns:
      true, if data is available
    • getData

      public DCFieldContainer getData()
      Description copied from interface: DataProviderIfc
      Allows a DataReceiver to obtain the available data in a known format.
      Specified by:
      getData in interface DataProviderIfc
      Specified by:
      getData in class DCFieldProcessor
      Returns:
      DCFieldContainer object containing the data that is available for processing
    • getBulkData

      public DCFieldContainer[] getBulkData()
      Description copied from interface: DataProviderIfc
      Allows a DataReceiver to obtain the available data in a known format.
      Specified by:
      getBulkData in interface DataProviderIfc
      Returns:
      DCFieldContainer object array, containing the data that is for processing
    • setDataReceiver

      public void setDataReceiver(DataReceiverIfc rec)
      Description copied from interface: DataProviderIfc
      Sets the object to which this DataProvider will send its data.
      Specified by:
      setDataReceiver in interface DataProviderIfc
      Overrides:
      setDataReceiver in class DCFieldProcessor
      Parameters:
      rec - Object which will obtain data from this DataProvider
    • dataIsAvailable

      public void dataIsAvailable()
      Description copied from interface: DataReceiverIfc
      Allows a DataProvider to indicate that some data is available for processing
      Specified by:
      dataIsAvailable in interface DataReceiverIfc
      Specified by:
      dataIsAvailable in class DCFieldProcessor
    • processData

      public void processData(DCFieldContainer inputData) throws NodeProcessingException
      Description copied from interface: DataReceiverIfc
      Manipulates the data provided by its DataProvider
      Specified by:
      processData in interface DataReceiverIfc
      Specified by:
      processData in class DCFieldProcessor
      Throws:
      NodeProcessingException
    • processData

      public void processData(DCFieldContainer inputData, String eof) throws NodeProcessingException
      Throws:
      NodeProcessingException
    • processFileData

      public boolean processFileData(DCFieldContainer inputData) throws NodeProcessingException, FileRejectException
      Description copied from class: DCFieldProcessor
      This is just a dummy implementation, any field processor needing the file level transaction behavior should override this method and implement correct behavior.
      Specified by:
      processFileData in interface FileDataReceiverIfc
      Overrides:
      processFileData in class DCFieldProcessor
      Returns:
      true, if data is processed successfully
      Throws:
      NodeProcessingException
      FileRejectException
    • processData

      public void processData(DCFieldContainer[] inputData) throws NodeProcessingException
      Description copied from interface: DataReceiverIfc
      Manipulates the set of data provided by its DataProvider
      Specified by:
      processData in interface DataReceiverIfc
      Throws:
      NodeProcessingException
    • processFileData

      public boolean processFileData(DCFieldContainer[] inputData) throws NodeProcessingException
      Description copied from class: DCFieldProcessor
      This is just a dummy implementation, any field processor needing the file level transaction behavior should override this method and implement correct behavior.
      Specified by:
      processFileData in interface FileDataReceiverIfc
      Overrides:
      processFileData in class DCFieldProcessor
      Returns:
      true, if data is processed successfully
      Throws:
      NodeProcessingException
    • getLogger

      protected LoggerIfc getLogger()
      Returns the LoggerIfc object used by this class to record log messages
      Returns:
      The LoggerIfc object used by this field processor
    • getNPLProgram

      protected NPLProgramIfc getNPLProgram()
      Returns the NPLProgramIfc object used by this field processor
      Returns:
      The NPLProgramIfc object used by this field processor
    • setRunning

      protected void setRunning(boolean run)
      Sets the boolean which indicates whether the field processor is running
    • isRunning

      protected boolean isRunning()
      Indicates whether this NPLFieldProcessor is running
    • setShutdown

      protected void setShutdown(boolean stop)
      Sets the boolean which indicates whether the field processor has been shutdown
    • isShutdown

      protected boolean isShutdown()
      Indicates whether this NPLFieldProcessor has been shutdown
    • getSleepTime

      public long getSleepTime()
      Returns the amount of time, in milliseconds, that will elapse before this NPLFieldProcessor will check for data to process, if it is running.
      Returns:
      sleep timer value, default is 1 minute (100000).
    • setSleepTime

      public void setSleepTime(long timerValue)
      Sets the amount of time, in milliseconds, that will elapse before this NPLFieldProcessor will check for data to process, if it is running.
      Parameters:
      timerValue - value for the sleep timer, default is 1 minute (100000).
    • isShutdownOnError

      public boolean isShutdownOnError()
      Indicates whether this NPLFieldProcessor should shutdown upon encountering an error during processing
    • setShutdownOnError

      public void setShutdownOnError(boolean value)
      Indicates whether this NPLFieldProcessor should shutdown upon encountering an error during processing default value is false
    • setBulkProcessing

      public void setBulkProcessing(boolean bulk)
      Sets the boolean which indicates whether the field processor will the retrieve and process the DCFieldContainers individually or in bulk.
      Overrides:
      setBulkProcessing in class DCFieldProcessor
      Parameters:
      bulk - True, if bulk processing is desired
    • isBulkProcessing

      public boolean isBulkProcessing()
      Indicates whether this NPLFieldProcessor is retrieving and processing the DCFieldContainers individually or in bulk.
    • setMultiThreadConfig

      public void setMultiThreadConfig(boolean mtChecked, boolean mtOrderChecked, int totalThreads)
      Overrides:
      setMultiThreadConfig in class DCFieldProcessor
    • setbulkIOConfig

      public void setbulkIOConfig(boolean bulkio)
      Overrides:
      setbulkIOConfig in class DCFieldProcessor
    • setPollForData

      public void setPollForData()
      Overrides:
      setPollForData in class DCFieldProcessor
    • getPollForData

      public boolean getPollForData()
      Overrides:
      getPollForData in class DCFieldProcessor
    • handleProcessingException

      protected void handleProcessingException(DCFieldContainer dcfc, Exception ex)
    • handleProcessingException

      protected void handleProcessingException(DCFieldContainer dcfc)
      Writes the given data to an error file and, if configured to shutdown on a processing error, logs a message and shuts down the FieldProcessor.
    • handleProcessingException

      protected void handleProcessingException(DCFieldContainer[] dcfcs)
      Writes the given data to an error file and, if configured to shutdown on a processing error, logs a message and shuts down the FieldProcessor.
    • writeToError

      protected boolean writeToError(DCFieldContainer data)
      Appends records containing errors to an output file
    • writeToError

      protected boolean writeToError(DCFieldContainer[] data)
      Appends records containing errors to an output file
    • setProcessingData

      public void setProcessingData(boolean value)
      Sets the boolean indicating whether the field processor is currently processing data.
    • getNPLFileName

      public String getNPLFileName()
    • setNPLFileName

      public void setNPLFileName(String fileName) throws NodeProcessingException
      Throws:
      NodeProcessingException
    • getInputFields

      public ArrayList getInputFields()
      Gets a list of the input fields defined in the input records.
      Returns:
      List of input fields. The elements in this ArrayList are actually other ArrayLists, one for each input record. The elements of these ArrayLists are FieldDescriptor objects, one for each field in the input record.
    • getOutputFields

      public ArrayList getOutputFields()
      Gets a list of the output fields defined in the output records.
      Returns:
      List of output fields. The elements in this ArrayList are actually other ArrayList s, one for each output record. The elements of these ArrayLists are FieldDescriptor objects, one for each field in the output record.
    • getExposedFields

      public ArrayList getExposedFields(String reason)
      Gets a list of the fields defined in the expose clause for the reason provided.
      Parameters:
      reason - Reason the fields are being exposed.
      Returns:
      List of exposed fields. The elements in the ArrayList are FieldDescriptor objects, one for each field in the expose clause matching the reason provided.
    • getConfigValue

      public String getConfigValue(String key)
      Gets the value of a configuration attribute.
      Parameters:
      key - Configuration attribute to get the value of.
      Returns:
      Value of the attribute. Returns null if the attribute does not exist.
    • getIntConfigValue

      public int getIntConfigValue(String key)
      Gets the value of a configuration attribute.
      Parameters:
      key - Configuration attribute to get the value of.
      Returns:
      Value of the attribute. Returns -1 if the attribute does not exist.
    • getMethodHandler

      public IDCMethodHandler getMethodHandler(String name)
      Returns the method handler with the specified name that is being used by this field processor's NPL program. Use the name "Java" to retrieve the method handler imported by NPL. For method handlers declared using the JavaHook declaration, use the name given to identify the method handler in the JavaHook declaration.
      Parameters:
      name - name of method handler to get
      Returns:
      method handler with given name or null if no method handler with given name
    • freezeState

      public void freezeState(Callback freezeCallback)
      Used by the StateManager thread to halt the processing while the state of the node is saved.
      Specified by:
      freezeState in interface StateFreezable
      Parameters:
      freezeCallback - Object to notify when the processing has been frozen.
    • unfreezeState

      public void unfreezeState()
      Used by the StateManager thread to resume the processing previously halted.
      Specified by:
      unfreezeState in interface StateFreezable
    • isFileLevelTransaction

      public boolean isFileLevelTransaction()
    • handleRejectOfFile

      public void handleRejectOfFile()
      Description copied from interface: FileDataProviderIfc
      To handle the remaining input files when there is reject of a file
      Specified by:
      handleRejectOfFile in interface FileDataProviderIfc
      Overrides:
      handleRejectOfFile in class DCFieldProcessor
    • isRejected

      public boolean isRejected()
    • setTransactionID

      public void setTransactionID(String tID)
      Specified by:
      setTransactionID in interface FileDataReceiverIfc
      Overrides:
      setTransactionID in class DCFieldProcessor