public class DeleteListener extends java.lang.Object implements QueryBatchListener
Sends a Java API bulk
delete
request for all the documents from each
batch. Because it deletes documents, it should only be used
when:
QueryBatcher.withConsistentSnapshot()
is called,
ornewQueryBatcher(Iterator<String>)
is used to
traverse a static data set
QueryBatcher deleteBatcher = moveMgr.newQueryBatcher(query)
.onUrisReady(new DeleteListener())
.withConsistentSnapshot();
JobTicket ticket = moveMgr.startJob(deleteBatcher);
deleteBatcher.awaitCompletion();
moveMgr.stopJob(ticket);
With Iterator<String>, pass a DeleteListener instance to
QueryBatcher onUrisReady like so:
QueryBatcher deleteBatcher = moveMgr.newQueryBatcher(query)
.onUrisReady(new DeleteListener());
JobTicket ticket = moveMgr.startJob(deleteBatcher);
deleteBatcher.awaitCompletion();
moveMgr.stopJob(ticket);
As with all the provided listeners, this listener will not meet the needs of all applications but the source code for it should serve as helpful sample code so you can write your own custom listeners.
Constructor and Description |
---|
DeleteListener() |
Modifier and Type | Method and Description |
---|---|
void |
initializeListener(QueryBatcher queryBatcher)
This implementation of initializeListener adds
this instance of DeleteListener to the two RetryListener's in this
QueryBatcher so they will retry any batches that fail during the
delete request.
|
DeleteListener |
onFailure(BatchFailureListener<QueryBatch> listener)
When a batch fails or a callback throws an
Exception, run this listener code.
|
void |
processEvent(QueryBatch batch)
The standard BatchListener action called by
QueryBatcher.
|
public void initializeListener(QueryBatcher queryBatcher)
initializeListener
in interface QueryBatchListener
queryBatcher
- the QueryBatcher which will call
this Listenerpublic void processEvent(QueryBatch batch)
processEvent
in interface BatchListener<QueryBatch>
processEvent
in interface QueryBatchListener
batch
- the batch of uris and some metadata about
the current status of the jobpublic DeleteListener onFailure(BatchFailureListener<QueryBatch> listener)
listener
- the code to run when a failure
occursCopyright © 2024 MarkLogic Corporation. All Rights Reserved.