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.String
jobStepKey
-
Constructor Summary
Constructors Constructor and Description AbstractBatchDataStream()
-
Method Summary
Methods Modifier and Type Method and Description abstract void
close()
Close underlying implementation stream.abstract java.lang.String
externalizeCheckpointInformation()
This method is called just before a checkpoint is to be taken by the batch container.java.lang.String
getJobstepId()
java.lang.String
getName()
The getName method returns the logical name of the BDS that was received in the initialize method.java.util.Properties
getProperties()
The getProperties method returns the bds properties specified in the xJCL and received in the setProperties method.protected java.lang.String
getProperty(java.lang.String key)
Convenience method to return a property value.protected java.lang.String
getRequiredProperty(java.util.Properties props, java.lang.String key)
protected java.lang.String
getRequiredProperty(java.lang.String key)
Convenience method to return a property value.protected abstract void
initialize(java.util.Properties props)
This method is invoked during stream initialization.void
initialize(java.lang.String name, java.lang.String jobstepId)
Called during stream initialization.void
intermediateCheckpoint()
LREE calls this method after a checkpoint is taken
This implementation does nothing; subclasses may override.abstract void
internalizeCheckpointInformation(java.lang.String token)
Parse restart token supplied by LREE.java.lang.Boolean
isRestart()
protected java.lang.Object
loadClass(java.lang.String className)
abstract void
open()
Opens delegate stream.abstract void
positionAtInitialCheckpoint()
Positions the stream to the initial checkpoint (i.e., the beginning of the stream).void
setProperties(java.util.Properties props)
LREE calls this method to tell us our properties as specified in the xJCL.protected void
setRestart(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 BatchContainerDataStreamException
Close underlying implementation stream.- Specified by:
close
in 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.RuntimeException
Parse restart token supplied by LREE.
This implementation assumes the restart token is a record cound, parseable as an integer.- Specified by:
internalizeCheckpointInformation
in 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 BatchContainerDataStreamException
Opens delegate stream.- Specified by:
open
in interfacecom.ibm.batch.api.BatchDataStream
- Throws:
BatchContainerDataStreamException
- Error opening delegate stream.
-
positionAtInitialCheckpoint
public abstract void positionAtInitialCheckpoint() throws BatchContainerDataStreamException
Positions 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:
positionAtInitialCheckpoint
in 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:
externalizeCheckpointInformation
in 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:BatchDataStream
The getName method returns the logical name of the BDS that was received in the initialize method.- Specified by:
getName
in interfacecom.ibm.batch.api.BatchDataStream
- Returns:
- Our logical name as specified in the xJCL.
-
getProperties
public java.util.Properties getProperties()
Description copied from interface:BatchDataStream
The getProperties method returns the bds properties specified in the xJCL and received in the setProperties method.
- Specified by:
getProperties
in 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 BatchContainerDataStreamException
Called during stream initialization.- Specified by:
initialize
in 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:
intermediateCheckpoint
in 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:
setProperties
in interfacecom.ibm.batch.api.BatchDataStream
- Parameters:
props
- Stream properties from xJCL.
-
isRestart
public java.lang.Boolean isRestart()
- Returns:
Boolean.FALSE
if we are not restartingBoolean.TRUE
if we are restartingnull
if 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)
-
-