Package org.nuxeo.ecm.core.bulk
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 Summary
Modifier and TypeFieldDescriptionstatic final long
static final String
static final String
Deprecated.static final String
static final String
static final Name
static final long
static final long
static final String
static final Name
static final String
protected static final long
protected final Map<String,
BulkCommand> protected final AtomicLong
protected static final ThreadLocal<Boolean>
static final String
static final String
Deprecated.static final String
static final String
static final Name
protected static final ThreadLocal<List<BulkCommand>>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAborts an asynchronous task.void
afterCompletion
(int status) void
appendExternalBucket
(BulkBucket bucket) Sends aBulkBucket
to the right bulk action.boolean
Waits for completion of given bulk command.boolean
Waits for completion of all bulk commands.void
protected void
checkIfScrollerExists
(BulkCommand command) void
completeExternalScroll
(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 boolean
registerSynchronization
(javax.transaction.Synchronization sync) byte[]
setCommand
(BulkCommand command) Stores the command in the kv store, returns the encoded command.protected void
setExclusive
(BulkCommand command) byte[]
setStatus
(BulkStatus status) Stores the status in the kv store returns the encoded statusprotected String
submit
(BulkCommand command) Submits aBulkCommand
that will be processed asynchronously, even if the current transaction rolls back (the method is not transactional).submitTransactional
(BulkCommand command) Submits aBulkCommand
that 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- See Also:
-
ABORTED_TTL_SECONDS
public static final long ABORTED_TTL_SECONDS- See Also:
-
COMPLETED_IN_ERROR_TTL_SECONDS
public static final long COMPLETED_IN_ERROR_TTL_SECONDS- See Also:
-
EXCLUSIVE_TTL_SECONDS
protected static final long EXCLUSIVE_TTL_SECONDS- See Also:
-
externalScrollerCounter
-
externalCommands
-
isEnlisted
-
transactionCommands
-
-
Constructor Details
-
BulkServiceImpl
public BulkServiceImpl()
-
-
Method Details
-
submit
Description copied from interface:BulkService
Submits aBulkCommand
that will be processed asynchronously, even if the current transaction rolls back (the method is not transactional).- Specified by:
submit
in interfaceBulkService
- Parameters:
command
- the command to submit- Returns:
- a unique bulk command identifier
-
checkIfScrollerExists
-
submit
-
getStatus
Description copied from interface:AsyncService
Returns the status of a task.- Specified by:
getStatus
in interfaceAsyncService<String,
BulkStatus, Map<String, Serializable>>
-
setExclusive
-
setStatus
Stores the status in the kv store returns the encoded status -
getCommand
Description copied from interface:BulkService
Returns the command or null if the command is not found or aborted.- Specified by:
getCommand
in interfaceBulkService
-
abort
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 interfaceAsyncService<String,
BulkStatus, Map<String, Serializable>>
-
getResult
Description copied from interface:AsyncService
Retrieves the command execution result.- Specified by:
getResult
in interfaceAsyncService<String,
BulkStatus, Map<String, Serializable>>
-
setCommand
Stores the command in the kv store, returns the encoded command. -
await
Description copied from interface:BulkService
Waits for completion of given bulk command.- Specified by:
await
in interfaceBulkService
- Parameters:
commandId
- the command to waitduration
- the duration to wait- Returns:
true
if bulk command completed orfalse
if computation has not finished after the timeout- Throws:
InterruptedException
-
getKvStore
-
await
Description copied from interface:BulkService
Waits for completion of all bulk commands.- Specified by:
await
in interfaceBulkService
- Parameters:
duration
- the duration to wait- Returns:
true
if all bulk commands completed orfalse
if one or more has not finished after the timeout- Throws:
InterruptedException
-
getStatuses
Description copied from interface:BulkService
Gets the list of action statuses triggered by the given user.- Specified by:
getStatuses
in interfaceBulkService
- Parameters:
username
- the user name- Returns:
- the list of statuses
-
appendExternalBucket
Description copied from interface:BulkService
Sends aBulkBucket
to the right bulk action.This method is useful to produce bucket externally when using an external scroller.
- Specified by:
appendExternalBucket
in interfaceBulkService
- Parameters:
bucket
- the bucket to send to a bulk action
-
completeExternalScroll
Description copied from interface:BulkService
Completes a running bulk computation having an external scroller.- Specified by:
completeExternalScroll
in interfaceBulkService
- Parameters:
commandId
- the command idcount
- the total number of elements produced by the external scroller
-
submitTransactional
Description copied from interface:BulkService
Submits aBulkCommand
that 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:
submitTransactional
in interfaceBulkService
- 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 interfacejavax.transaction.Synchronization
-
afterCompletion
public void afterCompletion(int status) - Specified by:
afterCompletion
in interfacejavax.transaction.Synchronization
-