com.ibm.jtopenlite.ddm
Class DDMThreadedReader
- java.lang.Object
-
- com.ibm.jtopenlite.ddm.DDMThreadedReader
-
- All Implemented Interfaces:
- DDMReadCallback
public abstract class DDMThreadedReader extends java.lang.Object implements DDMReadCallback
A special kind ofDDMReadCallback
you can use when you want multiple threads to simultaneously process data being read out of the same file and connection. The data is read by the main thread, but the conversion is done by one or more processing threads. Subclass this class and implement theprocess()
method to read record data off-thread from the main I/O thread. This gives the performance advantage of streaming data from the server in parallel with processing said data. It is important to note that using more than one thread will likely cause the records to be processed out-of-order.
-
-
Constructor Summary
Constructors Constructor and Description DDMThreadedReader(DDMRecordFormat format, DDMFile file, int numThreads)
Constructs a multi-threaded reader to process data being read from the specified file using the specified record format.
-
Method Summary
Methods Modifier and Type Method and Description void
endOfFile(DDMCallbackEvent event)
Do not call this method directly; it is implemented for DDMConnection to call.boolean
isDone()
Indicates if end-of-file has been reached and our threads have been shutdown.void
newRecord(DDMCallbackEvent event, DDMDataBuffer buffer)
Do not call this method directly; it is implemented for DDMConnection to call.abstract void
process(DDMRecordFormat format, DDMDataBuffer dataBuffer)
Override this method with your own record processing logic.void
recordNotFound(DDMCallbackEvent event)
Do not call this method directly; it is implemented for DDMConnection to call.
-
-
-
Constructor Detail
-
DDMThreadedReader
public DDMThreadedReader(DDMRecordFormat format, DDMFile file, int numThreads)
Constructs a multi-threaded reader to process data being read from the specified file using the specified record format.- Parameters:
format
- The record format to copy and give to each thread for it to pass toprocess()
.file
- The file being read.numThreads
- The number of threads to use. This number is capped by the number of buffers in the file object, so that each thread always has at least one buffer to process, to avoid contention. Having more than one buffer per thread is fine.
-
-
Method Detail
-
newRecord
public final void newRecord(DDMCallbackEvent event, DDMDataBuffer buffer)
Do not call this method directly; it is implemented for DDMConnection to call.- Specified by:
newRecord
in interfaceDDMReadCallback
-
recordNotFound
public final void recordNotFound(DDMCallbackEvent event)
Do not call this method directly; it is implemented for DDMConnection to call.- Specified by:
recordNotFound
in interfaceDDMReadCallback
-
endOfFile
public final void endOfFile(DDMCallbackEvent event)
Do not call this method directly; it is implemented for DDMConnection to call.- Specified by:
endOfFile
in interfaceDDMReadCallback
-
isDone
public final boolean isDone()
Indicates if end-of-file has been reached and our threads have been shutdown.
-
process
public abstract void process(DDMRecordFormat format, DDMDataBuffer dataBuffer)
Override this method with your own record processing logic.
-
-