Package org.nuxeo.ecm.core.bulk
Class BulkServiceImpl
java.lang.Object
org.nuxeo.ecm.core.bulk.BulkServiceImpl
- All Implemented Interfaces:
jakarta.transaction.Synchronization,AsyncService<String,,BulkStatus, Map<String, Serializable>> BulkService
public class BulkServiceImpl
extends Object
implements BulkService, jakarta.transaction.Synchronization
Basic implementation of
BulkService.- Since:
- 10.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Namestatic final longstatic final longstatic final Stringstatic final Namestatic final Stringprotected static final longprotected final Map<String, BulkCommand> protected final AtomicLongprotected static final ThreadLocal<Boolean> static final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Nameprotected static final ThreadLocal<List<BulkCommand>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAborts an asynchronous task.voidafterCompletion(int status) voidappendExternalBucket(BulkBucket bucket) Sends aBulkBucketto the right bulk action.booleanWaits for completion of given bulk command.booleanWaits for completion of all bulk commands.voidprotected voidcheckIfScrollerExists(BulkCommand command) voidcompleteExternalScroll(String commandId, long count) Completes a running bulk computation having an external scroller.getCommand(String commandId) Returns the command or null if the command is not found or aborted.Retrieves the command execution result.Returns the status of a task.getStatuses(String username) Gets the list of action statuses triggered by the given user.protected booleanregisterSynchronization(jakarta.transaction.Synchronization sync) byte[]setCommand(BulkCommand command) Stores the command in the kv store, returns the encoded command.protected voidsetExclusive(BulkCommand command) byte[]setStatus(BulkStatus status) Stores the status in the kv store returns the encoded statusprotected Stringsubmit(BulkCommand command) Submits aBulkCommandthat will be processed asynchronously, even if the current transaction rolls back (the method is not transactional).submitTransactional(BulkCommand command) Submits aBulkCommandthat will be processed asynchronously only if the transaction commits successfully (nothing will be submitted in case of transaction rollback).
-
Field Details
-
BULK_LOG_MANAGER_NAME
Deprecated.- See Also:
-
BULK_KV_STORE_NAME
- See Also:
-
COMMAND_STREAM
- See Also:
-
COMMAND_STREAM_NAME
-
STATUS_STREAM
- See Also:
-
STATUS_STREAM_NAME
-
DONE_STREAM
- See Also:
-
DONE_STREAM_NAME
-
COMMAND_PREFIX
- See Also:
-
RECORD_CODEC
Deprecated.- See Also:
-
STATUS_PREFIX
- See Also:
-
EXCLUSIVE_PREFIX
- See Also:
-
PRODUCE_IMMEDIATE_OPTION
- See Also:
-
COMPLETED_TTL_SECONDS
public static final long COMPLETED_TTL_SECONDS -
ABORTED_TTL_SECONDS
public static final long ABORTED_TTL_SECONDS -
COMPLETED_IN_ERROR_TTL_SECONDS
public static final long COMPLETED_IN_ERROR_TTL_SECONDS -
EXCLUSIVE_TTL_SECONDS
protected static final long EXCLUSIVE_TTL_SECONDS -
externalScrollerCounter
-
externalCommands
-
isEnlisted
-
transactionCommands
-
-
Constructor Details
-
BulkServiceImpl
public BulkServiceImpl()
-
-
Method Details
-
submit
Description copied from interface:BulkServiceSubmits aBulkCommandthat will be processed asynchronously, even if the current transaction rolls back (the method is not transactional).- Specified by:
submitin interfaceBulkService- Parameters:
command- the command to submit- Returns:
- a unique bulk command identifier
-
checkIfScrollerExists
-
submit
-
getStatus
Description copied from interface:AsyncServiceReturns the status of a task.- Specified by:
getStatusin interfaceAsyncService<String,BulkStatus, Map<String, Serializable>>
-
setExclusive
-
setStatus
Stores the status in the kv store returns the encoded status -
getCommand
Description copied from interface:BulkServiceReturns the command or null if the command is not found or aborted.- Specified by:
getCommandin interfaceBulkService
-
abort
Description copied from interface:AsyncServiceAborts an asynchronous task. Service should try to cancel the task, if not possible it must try to stop it.- Specified by:
abortin interfaceAsyncService<String,BulkStatus, Map<String, Serializable>>
-
getResult
Description copied from interface:AsyncServiceRetrieves the command execution result.- Specified by:
getResultin interfaceAsyncService<String,BulkStatus, Map<String, Serializable>>
-
setCommand
Stores the command in the kv store, returns the encoded command. -
await
Description copied from interface:BulkServiceWaits for completion of given bulk command.- Specified by:
awaitin interfaceBulkService- Parameters:
commandId- the command to waitduration- the duration to wait- Returns:
trueif bulk command completed orfalseif computation has not finished after the timeout- Throws:
InterruptedException
-
getKvStore
-
await
Description copied from interface:BulkServiceWaits for completion of all bulk commands.- Specified by:
awaitin interfaceBulkService- Parameters:
duration- the duration to wait- Returns:
trueif all bulk commands completed orfalseif one or more has not finished after the timeout- Throws:
InterruptedException
-
getStatuses
Description copied from interface:BulkServiceGets the list of action statuses triggered by the given user.- Specified by:
getStatusesin interfaceBulkService- Parameters:
username- the user name- Returns:
- the list of statuses
-
appendExternalBucket
Description copied from interface:BulkServiceSends aBulkBucketto the right bulk action.This method is useful to produce bucket externally when using an external scroller.
- Specified by:
appendExternalBucketin interfaceBulkService- Parameters:
bucket- the bucket to send to a bulk action
-
completeExternalScroll
Description copied from interface:BulkServiceCompletes a running bulk computation having an external scroller.- Specified by:
completeExternalScrollin interfaceBulkService- Parameters:
commandId- the command idcount- the total number of elements produced by the external scroller
-
submitTransactional
Description copied from interface:BulkServiceSubmits aBulkCommandthat will be processed asynchronously only if the transaction commits successfully (nothing will be submitted in case of transaction rollback). Note that theAsyncService.getStatus(Serializable)will return an unknown state until transaction is committed.- Specified by:
submitTransactionalin interfaceBulkService- Parameters:
command- the command to submit- Returns:
- a unique bulk command identifier
-
registerSynchronization
protected boolean registerSynchronization(jakarta.transaction.Synchronization sync) throws jakarta.transaction.RollbackException - Throws:
jakarta.transaction.RollbackException
-
beforeCompletion
public void beforeCompletion()- Specified by:
beforeCompletionin interfacejakarta.transaction.Synchronization
-
afterCompletion
public void afterCompletion(int status) - Specified by:
afterCompletionin interfacejakarta.transaction.Synchronization
-