Package com.marklogic.client.ext.batch
Class BatchWriterSupport
- java.lang.Object
-
- com.marklogic.client.ext.helper.LoggingObject
-
- com.marklogic.client.ext.batch.BatchWriterSupport
-
- All Implemented Interfaces:
BatchWriter
- Direct Known Subclasses:
RestBatchWriter,XccBatchWriter
public abstract class BatchWriterSupport extends LoggingObject implements BatchWriter
Support class for BatchWriter implementations that uses Spring's TaskExecutor interface for parallelizing writes to MarkLogic. Allows for setting a TaskExecutor instance, and if one is not set, a default one will be created based on the threadCount attribute. That attribute is ignored if a TaskExecutor is set.
-
-
Field Summary
-
Fields inherited from class com.marklogic.client.ext.helper.LoggingObject
logger
-
-
Constructor Summary
Constructors Constructor Description BatchWriterSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidexecuteRunnable(java.lang.Runnable runnable, java.util.List<? extends com.marklogic.client.document.DocumentWriteOperation> items)Will use the WriteListener if the TaskExecutor is an instance of AsyncListenableTaskExecutor.protected org.springframework.core.task.TaskExecutorgetTaskExecutor()intgetThreadCount()protected WriteListenergetWriteListener()voidinitialize()Give the writer a chance to perform any initialization it requires before it starts writing documents.protected voidinitializeDefaultTaskExecutor()voidsetTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)voidsetThreadCount(int threadCount)voidsetWriteListener(WriteListener writeListener)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.-
Methods inherited from class com.marklogic.client.ext.helper.LoggingObject
format
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.marklogic.client.ext.batch.BatchWriter
write
-
-
-
-
Method Detail
-
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
-
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
-
initializeDefaultTaskExecutor
protected void initializeDefaultTaskExecutor()
-
executeRunnable
protected void executeRunnable(java.lang.Runnable runnable, java.util.List<? extends com.marklogic.client.document.DocumentWriteOperation> items)Will use the WriteListener if the TaskExecutor is an instance of AsyncListenableTaskExecutor. The WriteListener will then be used to listen for failures.- Parameters:
runnable-items-
-
getTaskExecutor
protected org.springframework.core.task.TaskExecutor getTaskExecutor()
-
setTaskExecutor
public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
-
setThreadCount
public void setThreadCount(int threadCount)
-
getWriteListener
protected WriteListener getWriteListener()
-
setWriteListener
public void setWriteListener(WriteListener writeListener)
-
getThreadCount
public int getThreadCount()
-
-