public abstract class GenericWorker extends Object implements WorkerBase
| Modifier and Type | Field and Description |
|---|---|
protected String |
domain |
protected long |
domainRetentionPeriodInDays |
protected static int |
MAX_IDENTITY_LENGTH |
protected boolean |
registerDomain |
protected AmazonSimpleWorkflow |
service |
protected AtomicReference<CountDownLatch> |
suspendLatch |
protected Thread.UncaughtExceptionHandler |
uncaughtExceptionHandler |
| Constructor and Description |
|---|
GenericWorker() |
GenericWorker(AmazonSimpleWorkflow service,
String domain,
String taskListToPoll) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
protected void |
checkRequiredProperty(Object value,
String name) |
protected abstract void |
checkRequredProperties() |
protected void |
checkStarted() |
protected abstract TaskPoller |
createPoller() |
String |
getDomain() |
long |
getDomainRetentionPeriodInDays() |
String |
getIdentity() |
int |
getMaximumPollRateIntervalMilliseconds() |
double |
getMaximumPollRatePerSecond() |
double |
getPollBackoffCoefficient() |
long |
getPollBackoffInitialInterval() |
long |
getPollBackoffMaximumInterval() |
int |
getPollThreadCount() |
protected abstract String |
getPollThreadNamePrefix() |
AmazonSimpleWorkflow |
getService() |
String |
getTaskListToPoll()
Task list name that given worker polls for tasks.
|
Thread.UncaughtExceptionHandler |
getUncaughtExceptionHandler() |
boolean |
isDisableServiceShutdownOnStop() |
boolean |
isDisableTypeRegistrationOnStart() |
boolean |
isRegisterDomain() |
boolean |
isRunning() |
void |
resumePolling()
Allow new poll requests.
|
void |
setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop)
By default when @{link
shutdown() or @{link
shutdownNow() is called the worker calls
AmazonSimpleWorkflow.shutdown() on the service instance it is
configured with before shutting down internal thread pools. |
void |
setDisableTypeRegistrationOnStart(boolean disableTypeRegistrationOnStart)
When set to true disables types registration on start even if
SkipTypeRegistration is not specified. |
void |
setDomain(String domain) |
void |
setDomainRetentionPeriodInDays(long domainRetentionPeriodInDays)
Value of DomainRetentionPeriodInDays parameter passed to
AmazonSimpleWorkflow.registerDomain(com.amazonaws.services.simpleworkflow.model.RegisterDomainRequest) call. |
void |
setIdentity(String identity)
Set the identity that worker specifies in the poll requests.
|
void |
setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds)
The sliding window interval used to measure the poll rate.
|
void |
setMaximumPollRatePerSecond(double maximumPollRatePerSecond)
Maximum number of poll request to the task list per second allowed.
|
void |
setPollBackoffCoefficient(double backoffCoefficient) |
void |
setPollBackoffInitialInterval(long backoffInitialInterval)
Failed poll requests are retried after an interval defined by an
exponential backoff algorithm.
|
void |
setPollBackoffMaximumInterval(long backoffMaximumInterval) |
void |
setPollThreadCount(int threadCount)
Defines how many concurrent threads are used by the given worker to poll
the specified task list.
|
void |
setRegisterDomain(boolean registerDomain)
Should domain be registered on startup.
|
void |
setService(AmazonSimpleWorkflow service) |
void |
setTaskListToPoll(String taskListToPoll) |
void |
setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
Handler notified about poll request and other unexpected failures.
|
void |
shutdown() |
boolean |
shutdownAndAwaitTermination(long timeout,
TimeUnit unit) |
void |
shutdownNow() |
void |
start() |
void |
suspendPolling()
Do not make new poll requests.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitregisterTypesToPollprotected static final int MAX_IDENTITY_LENGTH
protected AmazonSimpleWorkflow service
protected String domain
protected boolean registerDomain
protected long domainRetentionPeriodInDays
protected final AtomicReference<CountDownLatch> suspendLatch
protected Thread.UncaughtExceptionHandler uncaughtExceptionHandler
public GenericWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll)
public GenericWorker()
public AmazonSimpleWorkflow getService()
getService in interface WorkerBasepublic void setService(AmazonSimpleWorkflow service)
public String getDomain()
getDomain in interface WorkerBasepublic void setDomain(String domain)
public boolean isRegisterDomain()
isRegisterDomain in interface WorkerBasepublic void setRegisterDomain(boolean registerDomain)
false.
When enabled #setDomainRetentionPeriodInDays(Long) property is
required.setRegisterDomain in interface WorkerBasepublic long getDomainRetentionPeriodInDays()
getDomainRetentionPeriodInDays in interface WorkerBasepublic void setDomainRetentionPeriodInDays(long domainRetentionPeriodInDays)
WorkerBaseAmazonSimpleWorkflow.registerDomain(com.amazonaws.services.simpleworkflow.model.RegisterDomainRequest) call. Required when
WorkerBase.isRegisterDomain() is true.setDomainRetentionPeriodInDays in interface WorkerBasepublic String getTaskListToPoll()
WorkerBasegetTaskListToPoll in interface WorkerBasepublic void setTaskListToPoll(String taskListToPoll)
public double getMaximumPollRatePerSecond()
getMaximumPollRatePerSecond in interface WorkerBasepublic void setMaximumPollRatePerSecond(double maximumPollRatePerSecond)
WorkerBasesetMaximumPollRatePerSecond in interface WorkerBaseWorkerBase.setMaximumPollRateIntervalMilliseconds(int)public int getMaximumPollRateIntervalMilliseconds()
getMaximumPollRateIntervalMilliseconds in interface WorkerBasepublic void setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds)
WorkerBasesetMaximumPollRateIntervalMilliseconds in interface WorkerBaseWorkerBase.setMaximumPollRatePerSecond(double)public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
getUncaughtExceptionHandler in interface WorkerBasepublic void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
WorkerBasesetUncaughtExceptionHandler in interface WorkerBasepublic String getIdentity()
getIdentity in interface WorkerBasepublic void setIdentity(String identity)
WorkerBasesetIdentity in interface WorkerBaseidentity - maximum size is 256 characters.public long getPollBackoffInitialInterval()
getPollBackoffInitialInterval in interface WorkerBasepublic void setPollBackoffInitialInterval(long backoffInitialInterval)
WorkerBasesetPollBackoffInitialInterval in interface WorkerBasebackoffInitialInterval - the interval between failure and the first retry. Default is
100.public long getPollBackoffMaximumInterval()
getPollBackoffMaximumInterval in interface WorkerBasepublic void setPollBackoffMaximumInterval(long backoffMaximumInterval)
setPollBackoffMaximumInterval in interface WorkerBasebackoffMaximumInterval - maximum interval between poll request retries. Default is
60000 (one minute).WorkerBase.setPollBackoffInitialInterval(long)public boolean isDisableServiceShutdownOnStop()
isDisableServiceShutdownOnStop in interface WorkerBasesetDisableServiceShutdownOnStop(boolean)public void setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop)
shutdown() or @{link
shutdownNow() is called the worker calls
AmazonSimpleWorkflow.shutdown() on the service instance it is
configured with before shutting down internal thread pools. Otherwise
threads that are waiting on a poll request might block shutdown for the
duration of a poll. This flag allows disabling this behavior.setDisableServiceShutdownOnStop in interface WorkerBasedisableServiceShutdownOnStop - true means do not call
AmazonSimpleWorkflow.shutdown()public double getPollBackoffCoefficient()
getPollBackoffCoefficient in interface WorkerBasepublic void setPollBackoffCoefficient(double backoffCoefficient)
setPollBackoffCoefficient in interface WorkerBasebackoffCoefficient - coefficient that defines how fast retry interval grows in case
of poll request failures. Default is 2.0.WorkerBase.setPollBackoffInitialInterval(long)public int getPollThreadCount()
getPollThreadCount in interface WorkerBasepublic void setPollThreadCount(int threadCount)
WorkerBaseActivityWorker two separate threads pools are used. One for
polling and another one for executing activities. The size of the
activity execution thread pool is defined through
ActivityWorker.setTaskExecutorThreadPoolSize(int).setPollThreadCount in interface WorkerBasepublic void setDisableTypeRegistrationOnStart(boolean disableTypeRegistrationOnStart)
WorkerBaseSkipTypeRegistration is not specified. Types still can be
registered by calling WorkerBase.registerTypesToPoll().setDisableTypeRegistrationOnStart in interface WorkerBasepublic boolean isDisableTypeRegistrationOnStart()
isDisableTypeRegistrationOnStart in interface WorkerBasepublic void start()
start in interface WorkerLifecycleprotected abstract String getPollThreadNamePrefix()
protected abstract TaskPoller createPoller()
protected abstract void checkRequredProperties()
protected void checkStarted()
public void shutdown()
shutdown in interface WorkerLifecyclepublic void shutdownNow()
shutdownNow in interface WorkerLifecyclepublic boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface WorkerLifecycleInterruptedExceptionpublic boolean shutdownAndAwaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
shutdownAndAwaitTermination in interface WorkerLifecycleInterruptedExceptionpublic boolean isRunning()
isRunning in interface WorkerBasepublic void suspendPolling()
SuspendablesuspendPolling in interface Suspendablepublic void resumePolling()
SuspendableresumePolling in interface SuspendableCopyright © 2016. All rights reserved.