org.springframework.data.hadoop.fs
Class HdfsItemWriter<T>

java.lang.Object
  extended by org.springframework.data.hadoop.fs.HdfsItemWriter<T>
All Implemented Interfaces:
ItemStream, ItemStreamWriter<T>, ItemWriter<T>

public class HdfsItemWriter<T>
extends Object
implements ItemStreamWriter<T>

An ItemWriter implementation used to write the incoming items to HDFS. Due to the HDFS limitation that files cannot be deleted or modified, the ability to roll back a file to a previously known state is not possible. This prevents the ability to restart using this ItemWriter.
This ItemWriter is not thread-safe.

Author:
Michael Minella

Constructor Summary
HdfsItemWriter(FileSystem fileSystem, Serializer<T> itemSerializer, String fileName)
          Constructor
 
Method Summary
 void close()
           
protected  void doWrite(List<? extends T> items)
          Performs the actual write to the store via the template.
 void open(ExecutionContext executionContext)
           
 void update(ExecutionContext executionContext)
           
 void write(List<? extends T> items)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HdfsItemWriter

public HdfsItemWriter(FileSystem fileSystem,
                      Serializer<T> itemSerializer,
                      String fileName)
Constructor

Parameters:
fileSystem - - HDFS FileSystem reference
itemSerializer - - Strategy for serializing items
fileName - - Name of the file to be written to
Method Detail

doWrite

protected void doWrite(List<? extends T> items)
Performs the actual write to the store via the template. This can be overridden by a subclass if necessary.

Parameters:
items - the list of items to be persisted.

open

public void open(ExecutionContext executionContext)
          throws ItemStreamException
Specified by:
open in interface ItemStream
Throws:
ItemStreamException

update

public void update(ExecutionContext executionContext)
            throws ItemStreamException
Specified by:
update in interface ItemStream
Throws:
ItemStreamException

write

public void write(List<? extends T> items)
           throws Exception
Specified by:
write in interface ItemWriter<T>
Throws:
Exception

close

public void close()
Specified by:
close in interface ItemStream