Spring for Apache Hadoop

org.springframework.yarn.batch.item
Class DataStoreItemReader<T>

java.lang.Object
  extended by org.springframework.yarn.batch.item.DataStoreItemReader<T>
Type Parameters:
T - the type of object returned as item read
All Implemented Interfaces:
org.springframework.batch.item.ItemReader<T>, org.springframework.batch.item.ItemStream, org.springframework.batch.item.ItemStreamReader<T>

public class DataStoreItemReader<T>
extends java.lang.Object
implements org.springframework.batch.item.ItemStreamReader<T>

Implementation of ItemReader able to read items from HDFS file splits.

Author:
Janne Valkealahti

Field Summary
static java.lang.String READ_POSITION
           
 
Constructor Summary
DataStoreItemReader()
          Instantiates a new data store item reader.
DataStoreItemReader(DataStoreReader<T> dataStoreReader)
          Instantiates a new data store item reader.
 
Method Summary
 void close()
           
 boolean isSaveState()
          The flag that determines whether to save internal state for restarts.
 void open(org.springframework.batch.item.ExecutionContext executionContext)
           
 T read()
           
 void setDataStoreReader(DataStoreReader<T> dataStoreReader)
          Sets the data store reader.
 void setLineDataMapper(LineDataMapper<T> lineDataMapper)
          Sets the line data mapper.
 void setSaveState(boolean saveState)
          Set the flag that determines whether to save internal data for ExecutionContext.
 void update(org.springframework.batch.item.ExecutionContext executionContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_POSITION

public static final java.lang.String READ_POSITION
See Also:
Constant Field Values
Constructor Detail

DataStoreItemReader

public DataStoreItemReader()
Instantiates a new data store item reader.


DataStoreItemReader

public DataStoreItemReader(DataStoreReader<T> dataStoreReader)
Instantiates a new data store item reader.

Parameters:
dataStoreReader - the data store reader
Method Detail

open

public void open(org.springframework.batch.item.ExecutionContext executionContext)
          throws org.springframework.batch.item.ItemStreamException
Specified by:
open in interface org.springframework.batch.item.ItemStream
Throws:
org.springframework.batch.item.ItemStreamException

update

public void update(org.springframework.batch.item.ExecutionContext executionContext)
            throws org.springframework.batch.item.ItemStreamException
Specified by:
update in interface org.springframework.batch.item.ItemStream
Throws:
org.springframework.batch.item.ItemStreamException

close

public void close()
           throws org.springframework.batch.item.ItemStreamException
Specified by:
close in interface org.springframework.batch.item.ItemStream
Throws:
org.springframework.batch.item.ItemStreamException

read

public T read()
       throws java.lang.Exception,
              org.springframework.batch.item.UnexpectedInputException,
              org.springframework.batch.item.ParseException,
              org.springframework.batch.item.NonTransientResourceException
Specified by:
read in interface org.springframework.batch.item.ItemReader<T>
Throws:
java.lang.Exception
org.springframework.batch.item.UnexpectedInputException
org.springframework.batch.item.ParseException
org.springframework.batch.item.NonTransientResourceException

setLineDataMapper

public void setLineDataMapper(LineDataMapper<T> lineDataMapper)
Sets the line data mapper.

Parameters:
lineDataMapper - the new line data mapper

setDataStoreReader

public void setDataStoreReader(DataStoreReader<T> dataStoreReader)
Sets the data store reader.

Parameters:
dataStoreReader - the new data store reader

setSaveState

public void setSaveState(boolean saveState)
Set the flag that determines whether to save internal data for ExecutionContext. Only switch this to false if you don't want to save any state from this stream, and you don't need it to be restartable. Always set it to false if the reader is being used in a concurrent environment.

Parameters:
saveState - flag value (default true).

isSaveState

public boolean isSaveState()
The flag that determines whether to save internal state for restarts.

Returns:
true if the flag was set

Spring for Apache Hadoop