Package com.marklogic.client.ext.batch
Class RestBatchWriter
- java.lang.Object
-
- com.marklogic.client.ext.helper.LoggingObject
-
- com.marklogic.client.ext.batch.BatchWriterSupport
-
- com.marklogic.client.ext.batch.RestBatchWriter
-
- All Implemented Interfaces:
BatchWriter
public class RestBatchWriter extends BatchWriterSupport
REST API-based implementation, using the Java Client API. By default, this will call release() on each of the DatabaseClient objects that are passed in. Be sure to disable this if you want to keep using those DatabaseClient objects.To customize what this does with every batch, you can set a new instance of BatchHandler. This class defaults to using DefaultBatchHandler; it'll pass its instances of Format and ServerTransform to that class.
-
-
Field Summary
-
Fields inherited from class com.marklogic.client.ext.helper.LoggingObject
logger
-
-
Constructor Summary
Constructors Constructor Description RestBatchWriter(com.marklogic.client.DatabaseClient databaseClient)RestBatchWriter(com.marklogic.client.DatabaseClient databaseClient, boolean releaseDatabaseClients)RestBatchWriter(java.util.List<com.marklogic.client.DatabaseClient> databaseClients)RestBatchWriter(java.util.List<com.marklogic.client.DatabaseClient> databaseClients, boolean releaseDatabaseClients, BatchHandler batchHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.RunnablebuildRunnable(com.marklogic.client.DatabaseClient client, java.util.List<? extends com.marklogic.client.document.DocumentWriteOperation> items)protected com.marklogic.client.DatabaseClientdetermineDatabaseClientToUse()protected intgetClientIndex()protected java.util.List<com.marklogic.client.DatabaseClient>getDatabaseClients()protected com.marklogic.client.document.ServerTransformgetServerTransform()voidinitialize()Give the writer a chance to perform any initialization it requires before it starts writing documents.protected booleanisReleaseDatabaseClients()voidsetBatchHandler(BatchHandler batchHandler)voidsetContentFormat(com.marklogic.client.io.Format contentFormat)voidsetReleaseDatabaseClients(boolean releaseDatabaseClients)voidsetServerTransform(com.marklogic.client.document.ServerTransform serverTransform)voidwaitForCompletion()Assuming that the writer is using a multi-threaded approach, call this to wait for the writer to finish performing all of its writes.voidwrite(java.util.List<? extends com.marklogic.client.document.DocumentWriteOperation> items)Write the given list of documents, as defined by the Java Client DocumentWriteOperation interface.-
Methods inherited from class com.marklogic.client.ext.batch.BatchWriterSupport
executeRunnable, getTaskExecutor, getThreadCount, getWriteListener, initializeDefaultTaskExecutor, setTaskExecutor, setThreadCount, setWriteListener
-
Methods inherited from class com.marklogic.client.ext.helper.LoggingObject
format
-
-
-
-
Constructor Detail
-
RestBatchWriter
public RestBatchWriter(com.marklogic.client.DatabaseClient databaseClient)
-
RestBatchWriter
public RestBatchWriter(com.marklogic.client.DatabaseClient databaseClient, boolean releaseDatabaseClients)
-
RestBatchWriter
public RestBatchWriter(java.util.List<com.marklogic.client.DatabaseClient> databaseClients)
-
RestBatchWriter
public RestBatchWriter(java.util.List<com.marklogic.client.DatabaseClient> databaseClients, boolean releaseDatabaseClients, BatchHandler batchHandler)
-
-
Method Detail
-
write
public void write(java.util.List<? extends com.marklogic.client.document.DocumentWriteOperation> items)
Description copied from interface:BatchWriterWrite the given list of documents, as defined by the Java Client DocumentWriteOperation interface.
-
initialize
public void initialize()
Description copied from interface:BatchWriterGive the writer a chance to perform any initialization it requires before it starts writing documents.- Specified by:
initializein interfaceBatchWriter- Overrides:
initializein classBatchWriterSupport
-
determineDatabaseClientToUse
protected com.marklogic.client.DatabaseClient determineDatabaseClientToUse()
-
buildRunnable
protected java.lang.Runnable buildRunnable(com.marklogic.client.DatabaseClient client, java.util.List<? extends com.marklogic.client.document.DocumentWriteOperation> items)
-
waitForCompletion
public void waitForCompletion()
Description copied from interface:BatchWriterAssuming that the writer is using a multi-threaded approach, call this to wait for the writer to finish performing all of its writes.- Specified by:
waitForCompletionin interfaceBatchWriter- Overrides:
waitForCompletionin classBatchWriterSupport
-
setReleaseDatabaseClients
public void setReleaseDatabaseClients(boolean releaseDatabaseClients)
-
setServerTransform
public void setServerTransform(com.marklogic.client.document.ServerTransform serverTransform)
-
getDatabaseClients
protected java.util.List<com.marklogic.client.DatabaseClient> getDatabaseClients()
-
getClientIndex
protected int getClientIndex()
-
isReleaseDatabaseClients
protected boolean isReleaseDatabaseClients()
-
getServerTransform
protected com.marklogic.client.document.ServerTransform getServerTransform()
-
setContentFormat
public void setContentFormat(com.marklogic.client.io.Format contentFormat)
-
setBatchHandler
public void setBatchHandler(BatchHandler batchHandler)
-
-