public class IndexWriter
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Field and Description |
---|---|
private boolean |
incremental |
private static int |
INDEX_V1 |
private WritableResourceHandler |
local |
private java.util.Properties |
localIndexProperties |
private java.lang.String |
nextChunkCounter |
private java.lang.String |
nextChunkName |
Constructor and Description |
---|
IndexWriter(WritableResourceHandler local,
java.lang.String indexId,
boolean incrementalSupported) |
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
calculateNextChunkCounter()
Calculates the chunk names that needs to be fetched.
|
void |
close()
Closes the underlying
ResourceHandler and synchronizes published index properties, so remote clients
becomes able to consume newly published index. |
java.lang.String |
getChainId()
Returns the chain id of published index.
|
java.lang.String |
getIndexId()
Returns the index context ID that published index has set.
|
java.lang.String |
getNextChunkName()
Returns the next chunk name about to be published.
|
java.util.Date |
getPublishedTimestamp()
Returns the
Date when index was last published or null if this is first publishing. |
boolean |
isIncremental()
Returns
true if incremental publish is about to happen. |
int |
writeChunk(java.util.Iterator<java.util.Map<java.lang.String,java.lang.String>> iterator)
Writes out the record iterator and returns the written record count.
|
private static final int INDEX_V1
private final WritableResourceHandler local
private final java.util.Properties localIndexProperties
private final boolean incremental
private final java.lang.String nextChunkCounter
private final java.lang.String nextChunkName
public IndexWriter(WritableResourceHandler local, java.lang.String indexId, boolean incrementalSupported) throws java.io.IOException
java.io.IOException
public java.lang.String getIndexId()
public java.util.Date getPublishedTimestamp()
Date
when index was last published or null
if this is first publishing. In other
words,returns null
when isIncremental()
returns false
. After this writer is closed, the
return value is updated to "now" (in method
.public boolean isIncremental()
true
if incremental publish is about to happen.public java.lang.String getChainId()
isIncremental()
is false
, this is the newly
generated chain ID.public java.lang.String getNextChunkName()
public int writeChunk(java.util.Iterator<java.util.Map<java.lang.String,java.lang.String>> iterator) throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
ResourceHandler
and synchronizes published index properties, so remote clients
becomes able to consume newly published index. If sync is not desired (ie. due to aborted publish), then this
method should NOT be invoked, but rather the ResourceHandler
that caller provided in constructor of
this class should be closed manually.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
private java.lang.String calculateNextChunkCounter()