Class BulkServiceImpl

java.lang.Object
org.nuxeo.ecm.core.bulk.BulkServiceImpl
All Implemented Interfaces:
javax.transaction.Synchronization, AsyncService<String,BulkStatus,Map<String,Serializable>>, BulkService

public class BulkServiceImpl extends Object implements BulkService, javax.transaction.Synchronization
Basic implementation of BulkService.
Since:
10.2
  • Field Details

  • Constructor Details

    • BulkServiceImpl

      public BulkServiceImpl()
  • Method Details

    • submit

      public String submit(BulkCommand command)
      Description copied from interface: BulkService
      Submits a BulkCommand that will be processed asynchronously, even if the current transaction rolls back (the method is not transactional).
      Specified by:
      submit in interface BulkService
      Parameters:
      command - the command to submit
      Returns:
      a unique bulk command identifier
    • checkIfScrollerExists

      protected void checkIfScrollerExists(BulkCommand command)
    • submit

      protected String submit(String shardKey, String key, byte[] bytes)
    • getStatus

      public BulkStatus getStatus(String commandId)
      Description copied from interface: AsyncService
      Returns the status of a task.
      Specified by:
      getStatus in interface AsyncService<String,BulkStatus,Map<String,Serializable>>
    • setExclusive

      protected void setExclusive(BulkCommand command)
    • setStatus

      public byte[] setStatus(BulkStatus status)
      Stores the status in the kv store returns the encoded status
    • getCommand

      public BulkCommand getCommand(String commandId)
      Description copied from interface: BulkService
      Returns the command or null if the command is not found or aborted.
      Specified by:
      getCommand in interface BulkService
    • abort

      public BulkStatus abort(String commandId)
      Description copied from interface: AsyncService
      Aborts an asynchronous task. Service should try to cancel the task, if not possible it must try to stop it.
      Specified by:
      abort in interface AsyncService<String,BulkStatus,Map<String,Serializable>>
    • getResult

      public Map<String,Serializable> getResult(String commandId)
      Description copied from interface: AsyncService
      Retrieves the command execution result.
      Specified by:
      getResult in interface AsyncService<String,BulkStatus,Map<String,Serializable>>
    • setCommand

      public byte[] setCommand(BulkCommand command)
      Stores the command in the kv store, returns the encoded command.
    • await

      public boolean await(String commandId, Duration duration) throws InterruptedException
      Description copied from interface: BulkService
      Waits for completion of given bulk command.
      Specified by:
      await in interface BulkService
      Parameters:
      commandId - the command to wait
      duration - the duration to wait
      Returns:
      true if bulk command completed or false if computation has not finished after the timeout
      Throws:
      InterruptedException
    • getKvStore

      public KeyValueStore getKvStore()
    • await

      public boolean await(Duration duration) throws InterruptedException
      Description copied from interface: BulkService
      Waits for completion of all bulk commands.
      Specified by:
      await in interface BulkService
      Parameters:
      duration - the duration to wait
      Returns:
      true if all bulk commands completed or false if one or more has not finished after the timeout
      Throws:
      InterruptedException
    • getStatuses

      public List<BulkStatus> getStatuses(String username)
      Description copied from interface: BulkService
      Gets the list of action statuses triggered by the given user.
      Specified by:
      getStatuses in interface BulkService
      Parameters:
      username - the user name
      Returns:
      the list of statuses
    • appendExternalBucket

      public void appendExternalBucket(BulkBucket bucket)
      Description copied from interface: BulkService
      Sends a BulkBucket to the right bulk action.

      This method is useful to produce bucket externally when using an external scroller.

      Specified by:
      appendExternalBucket in interface BulkService
      Parameters:
      bucket - the bucket to send to a bulk action
    • completeExternalScroll

      public void completeExternalScroll(String commandId, long count)
      Description copied from interface: BulkService
      Completes a running bulk computation having an external scroller.
      Specified by:
      completeExternalScroll in interface BulkService
      Parameters:
      commandId - the command id
      count - the total number of elements produced by the external scroller
    • submitTransactional

      public String submitTransactional(BulkCommand command)
      Description copied from interface: BulkService
      Submits a BulkCommand that will be processed asynchronously only if the transaction commits successfully (nothing will be submitted in case of transaction rollback). Note that the AsyncService.getStatus(Serializable) will return an unknown state until transaction is committed.
      Specified by:
      submitTransactional in interface BulkService
      Parameters:
      command - the command to submit
      Returns:
      a unique bulk command identifier
    • registerSynchronization

      protected boolean registerSynchronization(javax.transaction.Synchronization sync) throws javax.transaction.RollbackException
      Throws:
      javax.transaction.RollbackException
    • beforeCompletion

      public void beforeCompletion()
      Specified by:
      beforeCompletion in interface javax.transaction.Synchronization
    • afterCompletion

      public void afterCompletion(int status)
      Specified by:
      afterCompletion in interface javax.transaction.Synchronization