public class StreamWorkManager extends WorkManagerImpl
Modifier and Type | Class and Description |
---|---|
class |
StreamWorkManager.WorkScheduling |
WorkManagerImpl.WorkCompletionSynchronizer, WorkManagerImpl.WorkThreadPoolExecutor
WorkManager.Scheduling
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CONCURRENCY |
static String |
DEFAULT_WORK_CODEC |
static String |
DEFAULT_WORK_LOG_CONFIG |
static String |
DEFAULT_WORK_OVER_PROVISIONING |
protected static org.apache.commons.logging.Log |
log |
protected LogManager |
logManager |
protected Settings |
settings |
protected long |
stateTTL |
static String |
STATETTL_DEFAULT_VALUE |
static String |
STATETTL_KEY |
protected boolean |
storeState |
static String |
STORESTATE_KEY |
protected Set<String> |
streamIds |
protected StreamProcessor |
streamProcessor |
protected Topology |
topology |
static String |
WORK_CODEC_PROP |
static String |
WORK_LOG_CONFIG_PROP |
static String |
WORK_OVER_PROVISIONING_PROP |
completionSynchronizer, DEFAULT_CATEGORY, DEFAULT_QUEUE_ID, executors, IMPL_EP, NAME, QUEUES_EP, queuing, registry, SHUTDOWN_DELAY_MS_KEY, shutdownInProgress, started, THREAD_PREFIX, workQueueConfig, workQueuingConfig
lastModified
Constructor and Description |
---|
StreamWorkManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
activateQueueMetrics(String queueId) |
boolean |
awaitCompletion(String queueId,
long duration,
TimeUnit unit)
Waits for completion of work in a given queue.
|
protected boolean |
awaitCompletionOnQueue(String queueId,
long duration,
TimeUnit unit) |
boolean |
awaitCompletionWithWaterMark(String queueId,
long duration,
TimeUnit unit)
Deprecated.
since 10.2 because unused
|
protected void |
deactivateQueueMetrics(String queueId) |
Work |
find(String s,
Work.State state)
Finds a work instance.
|
int |
getApplicationStartedOrder()
The component notification order for
Component.applicationStarted(org.nuxeo.runtime.model.ComponentContext) . |
protected Codec<Record> |
getCodec() |
protected String |
getCodecName() |
protected String |
getLogConfig() |
protected LogManager |
getLogManager() |
protected long |
getLowWaterMark(String queueId) |
WorkQueueMetrics |
getMetrics(String queueId)
Gets the metrics for the
queueId |
protected WorkQueueMetrics |
getMetricsWithNuxeoClassLoader(String queueId) |
protected int |
getOverProvisioningFactor() |
protected int |
getPartitions(int maxThreads) |
int |
getQueueSize(String queueId,
Work.State state)
Gets the number of work instances in a given queue in a defined state.
|
protected String |
getStreamForCategory(String category) |
Work.State |
getWorkState(String workId)
Gets the state in which a work instance is.
|
void |
init()
Starts up this
WorkManager and attempts to resume work previously suspended and saved at
WorkManager.shutdown(long, java.util.concurrent.TimeUnit) time. |
protected void |
initTopology() |
boolean |
isProcessingEnabled(String queueId)
Is processing enabled for a given queue id.
|
List<Work> |
listWork(String s,
Work.State state)
Lists the work instances in a given queue in a defined state.
|
List<String> |
listWorkIds(String s,
Work.State state)
Lists the work ids in a given queue in a defined state.
|
void |
schedule(Work work,
WorkManager.Scheduling scheduling,
boolean afterCommit)
Schedules work for execution at a later time, with a specific scheduling policy.
|
protected boolean |
scheduleAfterCommit(Work work,
WorkManager.Scheduling scheduling)
Schedule after commit.
|
boolean |
shutdown(long timeout,
TimeUnit timeUnit)
Shuts down this
WorkManager and attempts to suspend and save the running and scheduled work instances. |
boolean |
shutdownQueue(String queueId,
long timeout,
TimeUnit unit)
Shuts down a work queue and attempts to suspend and save the running and scheduled work instances.
|
void |
start(ComponentContext context)
Start the component.
|
protected void |
supplantWorkManagerImpl()
Hack to steal the WorkManagerImpl queue contributions.
|
awaitCompletion, enableProcessing, enableProcessing, getCategoryQueueId, getExecutor, getTimestampAfter, getWorkQueueDescriptor, getWorkQueueIds, hasWorkInState, isProcessingEnabled, isQueuingEnabled, isStarted, newWorkQueuing, noScheduledOrRunningWork, registerContribution, remainingMillis, removeExecutor, schedule, schedule, schedule, shutdownExecutors, stop, unregisterContribution
activate, deactivate, getAdapter, getLastModified, registerExtension, setLastModified, setModifiedNow, unregisterExtension
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applicationStarted
protected static final org.apache.commons.logging.Log log
public static final String WORK_LOG_CONFIG_PROP
public static final String DEFAULT_WORK_LOG_CONFIG
public static final String WORK_CODEC_PROP
public static final String DEFAULT_WORK_CODEC
public static final String WORK_OVER_PROVISIONING_PROP
public static final String DEFAULT_WORK_OVER_PROVISIONING
public static final int DEFAULT_CONCURRENCY
public static final String STATETTL_KEY
public static final String STORESTATE_KEY
public static final String STATETTL_DEFAULT_VALUE
protected StreamProcessor streamProcessor
protected LogManager logManager
protected boolean storeState
protected long stateTTL
public StreamWorkManager()
protected int getOverProvisioningFactor()
protected String getCodecName()
public void schedule(Work work, WorkManager.Scheduling scheduling, boolean afterCommit)
WorkManager
schedule
in interface WorkManager
schedule
in class WorkManagerImpl
work
- the work to executescheduling
- the scheduling policyafterCommit
- if true
and the work is scheduled, it will only be run after the current transaction
(if any) has committedWorkManager.schedule(Work)
protected String getStreamForCategory(String category)
public int getApplicationStartedOrder()
Component
Component.applicationStarted(org.nuxeo.runtime.model.ComponentContext)
.
Components are notified in increasing order. Order 1000 is the default order for components that don't care. Order 100 is the repository initialization.
getApplicationStartedOrder
in interface Component
getApplicationStartedOrder
in class WorkManagerImpl
public void start(ComponentContext context)
Component
start
in interface Component
start
in class WorkManagerImpl
public void init()
WorkManager
WorkManager
and attempts to resume work previously suspended and saved at
WorkManager.shutdown(long, java.util.concurrent.TimeUnit)
time.init
in interface WorkManager
init
in class WorkManagerImpl
protected LogManager getLogManager()
protected String getLogConfig()
public boolean isProcessingEnabled(String queueId)
WorkManager
isProcessingEnabled
in interface WorkManager
isProcessingEnabled
in class WorkManagerImpl
protected void supplantWorkManagerImpl()
protected void initTopology()
protected int getPartitions(int maxThreads)
protected void activateQueueMetrics(String queueId)
protected void deactivateQueueMetrics(String queueId)
public boolean shutdownQueue(String queueId, long timeout, TimeUnit unit)
WorkManager
shutdownQueue
in interface WorkManager
shutdownQueue
in class WorkManagerImpl
queueId
- the queue idtimeout
- the time to waitunit
- the timeout unittrue
if shutdown is done, false
if there are still some threads executing after the
timeoutpublic boolean shutdown(long timeout, TimeUnit timeUnit)
WorkManager
WorkManager
and attempts to suspend and save the running and scheduled work instances.shutdown
in interface WorkManager
shutdown
in class WorkManagerImpl
timeout
- the time to waittimeUnit
- the timeout unittrue
if shutdown is done, false
if there are still some threads executing after the
timeoutpublic int getQueueSize(String queueId, Work.State state)
WorkManager
getQueueSize
in interface WorkManager
getQueueSize
in class WorkManagerImpl
queueId
- the queue idstate
- the state defining the state to look into, SCHEDULED
, RUNNING
, COMPLETED
, or null
for non-completed (
SCHEDULED
or RUNNING
)protected WorkQueueMetrics getMetricsWithNuxeoClassLoader(String queueId)
public WorkQueueMetrics getMetrics(String queueId)
WorkManager
queueId
getMetrics
in interface WorkManager
getMetrics
in class WorkManagerImpl
public boolean awaitCompletion(String queueId, long duration, TimeUnit unit) throws InterruptedException
WorkManager
awaitCompletion
in interface WorkManager
awaitCompletion
in class WorkManagerImpl
queueId
- the queue idduration
- the time to waitunit
- the timeout unittrue
if all work completed in the queue, or false
if there is still some non-completed
work after the timeoutInterruptedException
protected boolean awaitCompletionOnQueue(String queueId, long duration, TimeUnit unit) throws InterruptedException
InterruptedException
@Deprecated public boolean awaitCompletionWithWaterMark(String queueId, long duration, TimeUnit unit) throws InterruptedException
InterruptedException
protected long getLowWaterMark(String queueId)
public Work.State getWorkState(String workId)
WorkManager
getWorkState
in interface WorkManager
getWorkState
in class WorkManagerImpl
workId
- the id of the work to findnull
if not foundpublic Work find(String s, Work.State state)
WorkManager
find
in interface WorkManager
find
in class WorkManagerImpl
s
- the id of the work to findstate
- the state defining the state to look into, SCHEDULED
, RUNNING
, or null
for non-completednull
if not foundpublic List<Work> listWork(String s, Work.State state)
WorkManager
listWork
in interface WorkManager
listWork
in class WorkManagerImpl
s
- the queue idstate
- the state defining the state to look into, SCHEDULED
, RUNNING
, or null
for non-completedpublic List<String> listWorkIds(String s, Work.State state)
WorkManager
listWorkIds
in interface WorkManager
listWorkIds
in class WorkManagerImpl
s
- the queue idstate
- the state defining the state to look into, SCHEDULED
, RUNNING
, or null
for non-completedprotected boolean scheduleAfterCommit(Work work, WorkManager.Scheduling scheduling)
WorkManagerImpl
false
if impossible (no transaction or transaction manager).scheduleAfterCommit
in class WorkManagerImpl
Copyright © 2018 Nuxeo. All rights reserved.