Class 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      protected org.springframework.core.task.TaskExecutor getTaskExecutor()  
      int getThreadCount()  
      protected WriteListener getWriteListener()  
      void initialize()
      Give the writer a chance to perform any initialization it requires before it starts writing documents.
      protected void initializeDefaultTaskExecutor()  
      void setTaskExecutor​(org.springframework.core.task.TaskExecutor taskExecutor)  
      void setThreadCount​(int threadCount)  
      void setWriteListener​(WriteListener writeListener)  
      void waitForCompletion()
      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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BatchWriterSupport

        public BatchWriterSupport()
    • Method Detail

      • initialize

        public void initialize()
        Description copied from interface: BatchWriter
        Give the writer a chance to perform any initialization it requires before it starts writing documents.
        Specified by:
        initialize in interface BatchWriter
      • waitForCompletion

        public void waitForCompletion()
        Description copied from interface: BatchWriter
        Assuming 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:
        waitForCompletion in interface BatchWriter
      • 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)
      • setWriteListener

        public void setWriteListener​(WriteListener writeListener)
      • getThreadCount

        public int getThreadCount()