Package io.temporal.internal.worker
Class SyncWorkflowWorker
- java.lang.Object
-
- io.temporal.internal.worker.SyncWorkflowWorker
-
- All Implemented Interfaces:
Shutdownable
,Startable
,Suspendable
,SuspendableWorker
,WorkerWithLifecycle
public class SyncWorkflowWorker extends java.lang.Object implements SuspendableWorker
Facade that supports a lifecycle and maintains an assembly ofWorkflowWorker
that performing execution of workflow taskLocalActivityWorker
that performs execution of local activities scheduled by the workflow tasks
-
-
Constructor Summary
Constructors Constructor Description SyncWorkflowWorker(io.temporal.serviceclient.WorkflowServiceStubs service, java.lang.String namespace, java.lang.String taskQueue, SingleWorkerOptions singleWorkerOptions, SingleWorkerOptions localActivityOptions, WorkflowRunLockManager runLocks, WorkflowExecutorCache cache, java.lang.String stickyTaskQueueName, WorkflowThreadExecutor workflowThreadExecutor, EagerActivityDispatcher eagerActivityDispatcher)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
WorkerLifecycleState
getLifecycleState()
boolean
isShutdown()
boolean
isSuspended()
boolean
isTerminated()
<R> R
queryWorkflowExecution(WorkflowExecutionHistory history, java.lang.String queryType, java.lang.Class<R> resultClass, java.lang.reflect.Type resultType, java.lang.Object[] args)
void
registerLocalActivityImplementations(java.lang.Object... activitiesImplementation)
<R> void
registerWorkflowImplementationFactory(WorkflowImplementationOptions options, java.lang.Class<R> clazz, Functions.Func<R> factory)
void
registerWorkflowImplementationTypes(WorkflowImplementationOptions options, java.lang.Class<?>[] workflowImplementationTypes)
WorkflowTaskDispatchHandle
reserveWorkflowExecutor()
void
resumePolling()
Allow new poll requests.java.util.concurrent.CompletableFuture<java.lang.Void>
shutdown(ShutdownManager shutdownManager, boolean interruptTasks)
boolean
start()
This method is not required to be idempotent.void
suspendPolling()
Do not make new poll requests.java.lang.String
toString()
-
-
-
Constructor Detail
-
SyncWorkflowWorker
public SyncWorkflowWorker(@Nonnull io.temporal.serviceclient.WorkflowServiceStubs service, @Nonnull java.lang.String namespace, @Nonnull java.lang.String taskQueue, @Nonnull SingleWorkerOptions singleWorkerOptions, @Nonnull SingleWorkerOptions localActivityOptions, @Nonnull WorkflowRunLockManager runLocks, @Nonnull WorkflowExecutorCache cache, java.lang.String stickyTaskQueueName, @Nonnull WorkflowThreadExecutor workflowThreadExecutor, @Nonnull EagerActivityDispatcher eagerActivityDispatcher)
-
-
Method Detail
-
registerWorkflowImplementationTypes
public void registerWorkflowImplementationTypes(WorkflowImplementationOptions options, java.lang.Class<?>[] workflowImplementationTypes)
-
registerWorkflowImplementationFactory
public <R> void registerWorkflowImplementationFactory(WorkflowImplementationOptions options, java.lang.Class<R> clazz, Functions.Func<R> factory)
-
registerLocalActivityImplementations
public void registerLocalActivityImplementations(java.lang.Object... activitiesImplementation)
-
start
public boolean start()
Description copied from interface:Startable
This method is not required to be idempotent. It is expected to be called only once.
-
shutdown
public java.util.concurrent.CompletableFuture<java.lang.Void> shutdown(ShutdownManager shutdownManager, boolean interruptTasks)
- Specified by:
shutdown
in interfaceShutdownable
- Parameters:
shutdownManager
- provides toolset to get a Future for a shutdown of instances that have both non-blocking and not returning a Future on a completion shutdown methods (likeExecutorService.shutdown()
)interruptTasks
- if the threads processing user code (like workflows, workflow tasks or activities) should be interrupted, or we want to wait for their full graceful completion- Returns:
- CompletableFuture which should be completed when awaiting downstream dependencies can
proceed with their own shutdown. Should never be completed exceptionally
CompletableFuture.exceptionally(Function)
as downstream dependencies have no use of this information (they need to perform a shutdown anyway), and it complicates the shutdown flow.
-
awaitTermination
public void awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
- Specified by:
awaitTermination
in interfaceShutdownable
-
suspendPolling
public void suspendPolling()
Description copied from interface:Suspendable
Do not make new poll requests. Outstanding long polls still can return tasks after this method was called.- Specified by:
suspendPolling
in interfaceSuspendable
-
resumePolling
public void resumePolling()
Description copied from interface:Suspendable
Allow new poll requests.- Specified by:
resumePolling
in interfaceSuspendable
-
queryWorkflowExecution
public <R> R queryWorkflowExecution(WorkflowExecutionHistory history, java.lang.String queryType, java.lang.Class<R> resultClass, java.lang.reflect.Type resultType, java.lang.Object[] args) throws java.lang.Exception
- Throws:
java.lang.Exception
-
isSuspended
public boolean isSuspended()
- Specified by:
isSuspended
in interfaceSuspendable
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfaceShutdownable
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfaceShutdownable
-
getLifecycleState
public WorkerLifecycleState getLifecycleState()
- Specified by:
getLifecycleState
in interfaceWorkerWithLifecycle
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
reserveWorkflowExecutor
@Nullable public WorkflowTaskDispatchHandle reserveWorkflowExecutor()
-
-