com.ibm.websphere.batch.devframework.datastreams.bdsadapter
Class AbstractBatchDataStream
- java.lang.Object
-
- com.ibm.websphere.batch.devframework.datastreams.bdsadapter.AbstractBatchDataStream
-
- All Implemented Interfaces:
- com.ibm.batch.api.BatchDataStream
- Direct Known Subclasses:
- AbstractBatchDataInputStreamRecordMetrics, AbstractBatchDataOutputStreamRecordMetrics
public abstract class AbstractBatchDataStream extends java.lang.Object implements BatchDataStream
Base implementation ofBatchDataStream.
-
-
Field Summary
Fields Modifier and Type Field and Description protected java.lang.StringjobStepKey
-
Constructor Summary
Constructors Constructor and Description AbstractBatchDataStream()
-
Method Summary
Methods Modifier and Type Method and Description abstract voidclose()Close underlying implementation stream.abstract java.lang.StringexternalizeCheckpointInformation()This method is called just before a checkpoint is to be taken by the batch container.java.lang.StringgetJobstepId()java.lang.StringgetName()The getName method returns the logical name of the BDS that was received in the initialize method.java.util.PropertiesgetProperties()The getProperties method returns the bds properties specified in the xJCL and received in the setProperties method.protected java.lang.StringgetProperty(java.lang.String key)Convenience method to return a property value.protected java.lang.StringgetRequiredProperty(java.util.Properties props, java.lang.String key)protected java.lang.StringgetRequiredProperty(java.lang.String key)Convenience method to return a property value.protected abstract voidinitialize(java.util.Properties props)This method is invoked during stream initialization.voidinitialize(java.lang.String name, java.lang.String jobstepId)Called during stream initialization.voidintermediateCheckpoint()LREE calls this method after a checkpoint is taken
This implementation does nothing; subclasses may override.abstract voidinternalizeCheckpointInformation(java.lang.String token)Parse restart token supplied by LREE.java.lang.BooleanisRestart()protected java.lang.ObjectloadClass(java.lang.String className)abstract voidopen()Opens delegate stream.abstract voidpositionAtInitialCheckpoint()Positions the stream to the initial checkpoint (i.e., the beginning of the stream).voidsetProperties(java.util.Properties props)LREE calls this method to tell us our properties as specified in the xJCL.protected voidsetRestart(boolean restart)Sets the 'restarting' flag on this BDS.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ibm.websphere.batch.BatchDataStream
positionAtCurrentCheckpoint
-
-
-
-
Method Detail
-
close
public abstract void close() throws BatchContainerDataStreamExceptionClose underlying implementation stream.- Specified by:
closein interfacecom.ibm.batch.api.BatchDataStream- Throws:
BatchContainerDataStreamException- Underlying implementation stream threw an exception in itsclose()method.
-
internalizeCheckpointInformation
public abstract void internalizeCheckpointInformation(java.lang.String token) throws java.lang.RuntimeExceptionParse restart token supplied by LREE.
This implementation assumes the restart token is a record cound, parseable as an integer.- Specified by:
internalizeCheckpointInformationin interfacecom.ibm.batch.api.BatchDataStream- Parameters:
token- - This is a string that was created by the BDS that was returned to the Batch Execution Environment on the externalizeCheckpointInformation method. This String is opaque to anyone but the BDS, so only the BDS can interpret its content.- Throws:
java.lang.RuntimeException- Restart token could not be parsed as an integer.
-
open
public abstract void open() throws BatchContainerDataStreamExceptionOpens delegate stream.- Specified by:
openin interfacecom.ibm.batch.api.BatchDataStream- Throws:
BatchContainerDataStreamException- Error opening delegate stream.
-
positionAtInitialCheckpoint
public abstract void positionAtInitialCheckpoint() throws BatchContainerDataStreamExceptionPositions the stream to the initial checkpoint (i.e., the beginning of the stream).
This implementation simply sets the record counter to zero. Overriding subclasses should call the parent implementation.- Specified by:
positionAtInitialCheckpointin interfacecom.ibm.batch.api.BatchDataStream- Throws:
BatchContainerDataStreamException- Error positioning the stream.
-
initialize
protected abstract void initialize(java.util.Properties props)
This method is invoked during stream initialization. Properties specified in the xJCL are passed as input- Parameters:
props-
-
externalizeCheckpointInformation
public abstract java.lang.String externalizeCheckpointInformation()
This method is called just before a checkpoint is to be taken by the batch container. This allows the stream to save any information that can be used by the container in case of a restart.- Specified by:
externalizeCheckpointInformationin interfacecom.ibm.batch.api.BatchDataStream- 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.
-
getJobstepId
public java.lang.String getJobstepId()
- Returns:
- Our job/step id.
-
getName
public java.lang.String getName()
Description copied from interface:BatchDataStreamThe getName method returns the logical name of the BDS that was received in the initialize method.- Specified by:
getNamein interfacecom.ibm.batch.api.BatchDataStream- Returns:
- Our logical name as specified in the xJCL.
-
getProperties
public java.util.Properties getProperties()
Description copied from interface:BatchDataStreamThe getProperties method returns the bds properties specified in the xJCL and received in the setProperties method.
- Specified by:
getPropertiesin interfacecom.ibm.batch.api.BatchDataStream- Returns:
- Our properties as specified in the xJCL.
-
getProperty
protected java.lang.String getProperty(java.lang.String key)
Convenience method to return a property value.- Parameters:
key- Property key.- Returns:
- Property value.
-
getRequiredProperty
protected java.lang.String getRequiredProperty(java.lang.String key)
Convenience method to return a property value. Throws an exception if the property was not set, or was set to an empty value.- Parameters:
key- Property key.- Returns:
- Property value.
- Throws:
java.lang.RuntimeException- No value was specified for the given key.
-
getRequiredProperty
protected java.lang.String getRequiredProperty(java.util.Properties props, java.lang.String key)
-
initialize
public void initialize(java.lang.String name, java.lang.String jobstepId) throws BatchContainerDataStreamExceptionCalled during stream initialization.- Specified by:
initializein interfacecom.ibm.batch.api.BatchDataStream- 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
-
intermediateCheckpoint
public void intermediateCheckpoint()
LREE calls this method after a checkpoint is taken
This implementation does nothing; subclasses may override.- Specified by:
intermediateCheckpointin interfacecom.ibm.batch.api.BatchDataStream
-
setProperties
public void setProperties(java.util.Properties props)
LREE calls this method to tell us our properties as specified in the xJCL.- Specified by:
setPropertiesin interfacecom.ibm.batch.api.BatchDataStream- Parameters:
props- Stream properties from xJCL.
-
isRestart
public java.lang.Boolean isRestart()
- Returns:
Boolean.FALSEif we are not restartingBoolean.TRUEif we are restartingnullif not yet known
-
setRestart
protected void setRestart(boolean restart)
Sets the 'restarting' flag on this BDS. Should be called by subclasses, in theirBatchDataStream.positionAtCurrentCheckpoint()(set totrue) orBatchDataStream.positionAtInitialCheckpoint()(set tofalse) methods, respectively.- Parameters:
restart-
-
loadClass
protected java.lang.Object loadClass(java.lang.String className)
-
-