KEY
- key typeVALUE
- value typepublic abstract class ChunkedCollectionWriter<KEY,VALUE> extends Object implements Closeable
This is the base class for chunked collection writers. Chunked collection writers organize a stream of key-value
entries into chunks and write them out to the distributed in-memory data grid so that they can be retrieved in the same order by
a ChunkedCollectionReader
. It uses a thread pool to concurrently write key-value entries to the grid.
When an object is added to the chunk collection by put(Object, Object)
, it is written to the byte buffer
of the current active assembling chunk by putObject(java.io.DataOutputStream, java.nio.ByteBuffer, int, Object, Object)
.
When the chunk is full, it is added to the write queue and the output is redirected to the next assembling chunk.
Chunks are written out asynchronously by calling writeChunkOut(java.nio.ByteBuffer, int, int)
.
The writer should be (close()
)d to finalize output when there are no more objects to write.
Constructor and Description |
---|
ChunkedCollectionWriter(com.scaleoutsoftware.soss.client.map.impl.ChunkBufferPool chunkBufferPool)
Creates the chunk writer.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Releases all chunk buffers back into the thread pool.
|
void |
close()
Closes the chunk writer.
|
int |
getNumberOfChunks()
Gets the number of written chunks.
|
void |
put(KEY key,
VALUE value)
Puts the key and value into the collection.
|
public ChunkedCollectionWriter(com.scaleoutsoftware.soss.client.map.impl.ChunkBufferPool chunkBufferPool) throws IOException
chunkBufferPool
- the pool of chunks to write toIOException
- If a write error occurspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- if an error occurred while writing chunks outpublic void cleanup()
public int getNumberOfChunks()
close()
is called.public void put(KEY key, VALUE value) throws IOException
key
- key objectvalue
- value objectIOException
- if write error occurredCopyright (C) 2007-2014 ScaleOut Software, Inc.