Class Worker<T>
- java.lang.Object
-
- com.snowflake.connectors.taskreactor.worker.Worker<T>
-
- Type Parameters:
T- param defining type of response during running worker jobs.
- Direct Known Subclasses:
IngestionWorker,SimpleIngestionWorker,SimpleTaskWorker
public abstract class Worker<T> extends Object
A set of methods performed by the Worker implementation.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedWorker(WorkerId workerId, Identifier instanceName, WorkerStatusRepository workerStatusRepository, ObjectName workerTask, WorkerQueue workerQueue, TaskRepository taskRepository)Creates a newWorker.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TperformWork(WorkItem workItem)Trun()Generic body of the worker execution job.protected booleanshouldCancel()Returns whether the worker should cancel its execution.
-
-
-
Constructor Detail
-
Worker
protected Worker(WorkerId workerId, Identifier instanceName, WorkerStatusRepository workerStatusRepository, ObjectName workerTask, WorkerQueue workerQueue, TaskRepository taskRepository)
Creates a newWorker.- Parameters:
workerId- worker idinstanceName- Task Reactor instance nameworkerStatusRepository- worker status repositoryworkerTask- name of the worker task objectworkerQueue- worker queuetaskRepository- task repository
-
-
Method Detail
-
run
public T run() throws WorkerException, WorkerJobCancelledException
Generic body of the worker execution job.- Returns:
- result of the
performWork(com.snowflake.connectors.taskreactor.worker.queue.WorkItem)method implementation. - Throws:
WorkerException- when generic worker fail occurs.WorkerJobCancelledException- if running task is performed by worker scheduled for cancellation.
-
performWork
protected abstract T performWork(WorkItem workItem)
- Parameters:
workItem- work item provided by the dispatcher- Returns:
- custom object defined by the user.
-
shouldCancel
protected boolean shouldCancel()
Returns whether the worker should cancel its execution.- Returns:
- whether the worker should cancel its execution
-
-