public class HdfsItemWriter<T>
extends java.lang.Object
implements org.springframework.batch.item.ItemStreamWriter<T>
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
.
ItemWriter
is not thread-safe.Constructor and Description |
---|
HdfsItemWriter(org.apache.hadoop.fs.FileSystem fileSystem,
org.springframework.core.serializer.Serializer<T> itemSerializer,
java.lang.String fileName)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
doWrite(java.util.List<? extends T> items)
Performs the actual write to the store via the template.
|
void |
open(org.springframework.batch.item.ExecutionContext executionContext) |
void |
update(org.springframework.batch.item.ExecutionContext executionContext) |
void |
write(java.util.List<? extends T> items) |
public HdfsItemWriter(org.apache.hadoop.fs.FileSystem fileSystem, org.springframework.core.serializer.Serializer<T> itemSerializer, java.lang.String fileName)
fileSystem
- - HDFS FileSystem
referenceitemSerializer
- - Strategy for serializing itemsfileName
- - Name of the file to be written toprotected void doWrite(java.util.List<? extends T> items)
items
- the list of items to be persisted.public void open(org.springframework.batch.item.ExecutionContext executionContext) throws org.springframework.batch.item.ItemStreamException
open
in interface org.springframework.batch.item.ItemStream
org.springframework.batch.item.ItemStreamException
public void update(org.springframework.batch.item.ExecutionContext executionContext) throws org.springframework.batch.item.ItemStreamException
update
in interface org.springframework.batch.item.ItemStream
org.springframework.batch.item.ItemStreamException
public void write(java.util.List<? extends T> items) throws java.lang.Exception
write
in interface org.springframework.batch.item.ItemWriter<T>
java.lang.Exception
public void close()
close
in interface org.springframework.batch.item.ItemStream