public abstract class AbstractFileQueueCommitter extends AbstractCommitter
prepareCommitAddition(IAddOperation)
and
prepareCommitDeletion(IDeleteOperation)
to manipulate the
data supplied with the operations before committing takes place.
AbstractBatchCommitter
.
Subclasses implementing IXMLConfigurable
should allow this inner
configuration:
<queueDir>(optional path where to queue files)</queueDir> <queueSize>(max queue size before committing)</queueSize>
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_QUEUE_DIR
Default directory where to queue files.
|
protected ConcurrentHashMap<File,Thread> |
filesCommitting
Files currently being committed
|
DEFAULT_QUEUE_SIZE, queueSize
Constructor and Description |
---|
AbstractFileQueueCommitter()
Constructor.
|
AbstractFileQueueCommitter(int queueSize)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
commit()
Commits documents.
|
protected abstract void |
commitAddition(IAddOperation operation)
Allow subclasses to commit a file to be added.
|
protected abstract void |
commitComplete()
Allow subclasses to operate upon the end of the commit operation.
|
protected abstract void |
commitDeletion(IDeleteOperation operation)
Allow subclasses to commit a file to be deleted.
|
boolean |
equals(Object obj) |
protected long |
getInitialQueueDocCount()
Gets the initial document count, in case there are already documents
in the queue the first time the committer is used.
|
String |
getQueueDir()
Gets the directory where queued files are stored.
|
int |
hashCode() |
protected void |
prepareCommitAddition(IAddOperation operation)
Optionally performs actions on a document to be added before
actually committing it.
|
protected void |
prepareCommitDeletion(IDeleteOperation operation)
Optionally performs operations on a document to be deleted before
actually committing it.
|
protected void |
queueAddition(String reference,
InputStream content,
com.norconex.commons.lang.map.Properties metadata)
Queues a document to be added.
|
protected void |
queueRemoval(String ref,
com.norconex.commons.lang.map.Properties metadata)
Queues a document to be deleted.
|
void |
setQueueDir(String queueDir)
Sets the directory where queued files are stored.
|
String |
toString() |
add, getQueueSize, remove, setQueueSize
public static final String DEFAULT_QUEUE_DIR
protected final ConcurrentHashMap<File,Thread> filesCommitting
public AbstractFileQueueCommitter()
public AbstractFileQueueCommitter(int queueSize)
queueSize
- max queue sizepublic String getQueueDir()
public void setQueueDir(String queueDir)
queueDir
- directoryprotected long getInitialQueueDocCount()
AbstractCommitter
getInitialQueueDocCount
in class AbstractCommitter
protected void queueAddition(String reference, InputStream content, com.norconex.commons.lang.map.Properties metadata)
AbstractCommitter
queueAddition
in class AbstractCommitter
reference
- document referencecontent
- document contentmetadata
- document metadataprotected void queueRemoval(String ref, com.norconex.commons.lang.map.Properties metadata)
AbstractCommitter
queueRemoval
in class AbstractCommitter
ref
- document referencemetadata
- document metadatapublic void commit()
ICommitter
protected abstract void commitAddition(IAddOperation operation) throws IOException
Allow subclasses to commit a file to be added.
The subclass has the responsibility of deleting the file once the content is permanently stored. The subclass may decide to further batch those documents before storing them if more efficient this way.
operation
- the document operation to performIOException
- problem to commit additionprotected abstract void commitDeletion(IDeleteOperation operation) throws IOException
Allow subclasses to commit a file to be deleted.
The subclass has the responsibility of deleting the file once the content is permanently stored. The subclass may decide to further batch those deletions before storing them if more efficient that way.
operation
- the document operation to performIOException
- problem committing deletionprotected abstract void commitComplete()
protected void prepareCommitAddition(IAddOperation operation) throws IOException
operation
- addition to be performedIOException
- problem preparing commit additionprotected void prepareCommitDeletion(IDeleteOperation operation) throws IOException
operation
- deletion to be performedIOException
- problem preparing commit deletionpublic boolean equals(Object obj)
equals
in class AbstractCommitter
public int hashCode()
hashCode
in class AbstractCommitter
public String toString()
toString
in class AbstractCommitter
Copyright © 2009–2020 Norconex Inc.. All rights reserved.