com.ibm.websphere.batch.devframework.datastreams.bdsadapter
Class AbstractBatchDataOutputStreamRecordMetrics
- java.lang.Object
-
- com.ibm.websphere.batch.devframework.datastreams.bdsadapter.AbstractBatchDataStream
-
- com.ibm.websphere.batch.devframework.datastreams.bdsadapter.AbstractBatchDataOutputStreamRecordMetrics
-
- All Implemented Interfaces:
- com.ibm.batch.api.BatchDataStream, AbstractBatchDataOutputStream, AbstractBatchDataStreamRecordMetrics, RecordMetrics, java.io.Externalizable, java.io.Serializable
public abstract class AbstractBatchDataOutputStreamRecordMetrics extends AbstractBatchDataStream implements AbstractBatchDataOutputStream, AbstractBatchDataStreamRecordMetrics, RecordMetrics, java.io.Externalizable
Common class that all AbstractBatchDataOutputStreams inherit from. Allows us to insert common code into all the write paths.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.ibm.websphere.batch.RecordMetrics
RecordMetrics.MetricName
-
-
Field Summary
-
Fields inherited from class com.ibm.websphere.batch.devframework.datastreams.bdsadapter.AbstractBatchDataStream
jobStepKey
-
-
Constructor Summary
Constructors Constructor and Description AbstractBatchDataOutputStreamRecordMetrics()
-
Method Summary
Methods Modifier and Type Method and Description abstract java.lang.String
_externalizeCheckpointInformation()
Abstract method implemented by sub class.abstract void
_internalizeCheckpointInformation(java.lang.String token)
Abstract method implemented by sub class.abstract void
_positionAtCurrentCheckpoint()
Abstract method implemented by sub class.protected abstract void
_write(java.lang.Object record)
Abstract method implemented by sub class.void
addSkipListener(SkipListener skipListener)
Add a SkipListener callback to the BDS.protected void
endRPSMetric()
java.lang.String
externalizeCheckpointInformation()
Encode record metric data at the beginning of the token, then call _externalizeCheckpointInformation, implemented by the sub class, and append whatever it returns to the end of the token.abstract void
flush()
Flushes the output streamlong
getCumulativeTime()
long
getMetric(RecordMetrics.MetricName metricName)
Returns the value of the batch data stream metric specifiedlong
getRecordCount()
protected com.ibm.ws.gridcontainer.batch.impl.SkipHandler
getSkipHandler()
void
initialize(java.lang.String name, java.lang.String jobstepId)
Called during stream initialization.void
internalizeCheckpointInformation(java.lang.String token)
Parse record metric data from the beginning of the token, then call _internalizeCheckpointInformation, implemented by the sub class, passing the rest of the token.void
positionAtCurrentCheckpoint()
This metohd calls the sub class (via _positionAtCurrentCheckpoint) to allow the sub class to position the BDS properly, then it sets its own checkpoint-related record metric values.void
readExternal(java.io.ObjectInput in)
protected void
setExceptionRecord(java.lang.Object record)
void
setMetric(RecordMetrics.MetricName metricName, long value)
protected void
setSkipMetric()
protected void
startRPSMetric()
void
write(java.lang.Object record)
Writes the given record to the output stream.void
writeExternal(java.io.ObjectOutput out)
abstract void
writeHeader(java.lang.Object record)
Writes header data-
Methods inherited from class com.ibm.websphere.batch.devframework.datastreams.bdsadapter.AbstractBatchDataStream
close, getJobstepId, getName, getProperties, getProperty, getRequiredProperty, getRequiredProperty, initialize, intermediateCheckpoint, isRestart, loadClass, open, positionAtInitialCheckpoint, setProperties, setRestart
-
-
-
-
Constructor Detail
-
AbstractBatchDataOutputStreamRecordMetrics
public AbstractBatchDataOutputStreamRecordMetrics()
-
-
Method Detail
-
initialize
public void initialize(java.lang.String name, java.lang.String jobstepId) throws BatchContainerDataStreamException
Description copied from class:AbstractBatchDataStream
Called during stream initialization.- Specified by:
initialize
in interfacecom.ibm.batch.api.BatchDataStream
- Overrides:
initialize
in classAbstractBatchDataStream
- Parameters:
name
- the logical name of the BDS, this name is used to locate the resource in the job's xJCL.jobstepId
- an identifier that represents the step within the batch job that is being run. This id is used to locate the resource in the job's xJCL.- Throws:
BatchContainerDataStreamException
-
_write
protected abstract void _write(java.lang.Object record) throws java.lang.Exception
Abstract method implemented by sub class. This method is called by write(Object).- Throws:
java.lang.Exception
-
write
public void write(java.lang.Object record) throws java.lang.Exception
Writes the given record to the output stream. Delegates to _write(Object), implemented by the sub class. Handle skip records, if applicable.- Specified by:
write
in interfaceAbstractBatchDataOutputStream
- Parameters:
record
-- Throws:
java.lang.Exception
-
flush
public abstract void flush() throws java.lang.Exception
Flushes the output stream- Specified by:
flush
in interfaceAbstractBatchDataOutputStream
- Throws:
java.lang.Exception
-
writeHeader
public abstract void writeHeader(java.lang.Object record) throws java.lang.Exception
Writes header data- Specified by:
writeHeader
in interfaceAbstractBatchDataOutputStream
- Parameters:
record
-- Throws:
java.lang.Exception
-
_internalizeCheckpointInformation
public abstract void _internalizeCheckpointInformation(java.lang.String token)
Abstract method implemented by sub class. This method is called by internalizeCheckpointInformation.- Parameters:
token
- the checkpoint token
-
internalizeCheckpointInformation
public final void internalizeCheckpointInformation(java.lang.String token)
Parse record metric data from the beginning of the token, then call _internalizeCheckpointInformation, implemented by the sub class, passing the rest of the token.- Specified by:
internalizeCheckpointInformation
in interfacecom.ibm.batch.api.BatchDataStream
- Specified by:
internalizeCheckpointInformation
in classAbstractBatchDataStream
- Parameters:
token
- the checkpoint token
-
_externalizeCheckpointInformation
public abstract java.lang.String _externalizeCheckpointInformation()
Abstract method implemented by sub class. This method is called by externalizeCheckpointInformation.
-
externalizeCheckpointInformation
public final java.lang.String externalizeCheckpointInformation()
Encode record metric data at the beginning of the token, then call _externalizeCheckpointInformation, implemented by the sub class, and append whatever it returns to the end of the token.- Specified by:
externalizeCheckpointInformation
in interfacecom.ibm.batch.api.BatchDataStream
- Specified by:
externalizeCheckpointInformation
in classAbstractBatchDataStream
- Returns:
- - This is a string that is created to record the BDS's position in the stream being processed. This String is opaque to anyone but the BDS, so only the BDS can interpret its content.
-
_positionAtCurrentCheckpoint
public abstract void _positionAtCurrentCheckpoint() throws BatchContainerDataStreamException
Abstract method implemented by sub class. This method is called by positionAtCurrentCheckpoint.
-
positionAtCurrentCheckpoint
public void positionAtCurrentCheckpoint() throws BatchContainerDataStreamException
This metohd calls the sub class (via _positionAtCurrentCheckpoint) to allow the sub class to position the BDS properly, then it sets its own checkpoint-related record metric values.- Specified by:
positionAtCurrentCheckpoint
in interfacecom.ibm.batch.api.BatchDataStream
- Throws:
BatchContainerDataStreamException
-
addSkipListener
public void addSkipListener(SkipListener skipListener)
Add a SkipListener callback to the BDS. The SkipListener is called by the BDS whenever the BDS fails to read or write a record and is configured to skip the failed record.
- Specified by:
addSkipListener
in interfaceAbstractBatchDataStreamRecordMetrics
- Parameters:
skipListener
- The user-implemented SkipListener callback.
-
getMetric
public long getMetric(RecordMetrics.MetricName metricName)
Description copied from interface:RecordMetrics
Returns the value of the batch data stream metric specified- Specified by:
getMetric
in interfaceRecordMetrics
- Parameters:
metricName
- - skip or rps- Returns:
- metricValue
-
getRecordCount
public long getRecordCount()
-
getCumulativeTime
public long getCumulativeTime()
-
setMetric
public void setMetric(RecordMetrics.MetricName metricName, long value)
-
startRPSMetric
protected void startRPSMetric()
-
endRPSMetric
protected void endRPSMetric()
-
setExceptionRecord
protected void setExceptionRecord(java.lang.Object record)
-
setSkipMetric
protected void setSkipMetric()
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
getSkipHandler
protected com.ibm.ws.gridcontainer.batch.impl.SkipHandler getSkipHandler()
-
-