Spring for Apache Hadoop

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

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

public class HdfsFileSplitItemReader<T>
extends java.lang.Object
implements org.springframework.batch.item.file.ResourceAwareItemReaderItemStream<T>

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

Author:
Janne Valkealahti

Constructor Summary
HdfsFileSplitItemReader()
          Instantiates a new hdfs file split 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 setLineDataMapper(LineDataMapper<T> lineDataMapper)
          Sets the line data mapper.
 void setResource(org.springframework.core.io.Resource resource)
           
 void setSaveState(boolean saveState)
          Set the flag that determines whether to save internal data for ExecutionContext.
 void setSplitLength(long splitLength)
          Sets the split length.
 void setSplitStart(long splitStart)
          Sets the split start.
 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
 

Constructor Detail

HdfsFileSplitItemReader

public HdfsFileSplitItemReader()
Instantiates a new hdfs file split item 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

setResource

public void setResource(org.springframework.core.io.Resource resource)
Specified by:
setResource in interface org.springframework.batch.item.file.ResourceAwareItemReaderItemStream<T>

setLineDataMapper

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

Parameters:
lineDataMapper - the new line data mapper

setSplitStart

public void setSplitStart(long splitStart)
Sets the split start.

Parameters:
splitStart - the new split start

setSplitLength

public void setSplitLength(long splitLength)
Sets the split length.

Parameters:
splitLength - the new split length

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