Class WorkClientImpl
java.lang.Object
co.yellowdog.platform.clients.scheduler.WorkClientImpl
-
Method Summary
Modifier and TypeMethodDescriptionaddTasksToTaskGroup
(@NonNull TaskGroup taskGroup, @NonNull List<Task> tasks) Submits NEW tasks to the YellowDog Scheduler service to be added to the specified task group.addTasksToTaskGroup
(@NonNull String namespace, @NonNull String workRequirementName, @NonNull String taskGroupName, @NonNull List<Task> tasks) Submits NEW tasks to the YellowDog Scheduler service to be added to the specified task group.addTasksToTaskGroup
(@NonNull String taskGroupId, @NonNull List<Task> tasks) Submits NEW tasks to the YellowDog Scheduler service to be added to the specified task group.addWorkRequirement
(@NonNull WorkRequirement workRequirement) Submits a NEW work requirement to the YellowDog Scheduler service to be initialised and started.void
addWorkRequirementListener
(@NonNull WorkRequirement workRequirement, @NonNull SubscriptionEventListener<WorkRequirement> listener) Adds an event listener to receive notifications of changes for the specified work requirement.void
addWorkRequirementListener
(@NonNull String workRequirementId, @NonNull SubscriptionEventListener<WorkRequirement> listener) Adds an event listener to receive notifications of changes for the specified work requirement.cancelTask
(@NonNull Task task, boolean abort) Instructs the Scheduler to cancel the specified task.cancelTask
(@NonNull String taskId, boolean abort) Instructs the Scheduler to cancel the specified task.cancelWorkRequirement
(@NonNull WorkRequirement workRequirement) Instructs the Scheduler to cancel the supplied work requirement, no further tasks will be executed and all workers shall be released.cancelWorkRequirement
(@NonNull WorkRequirement workRequirement, boolean abort) Instructs the Scheduler to cancel the supplied work requirement, no further tasks will be executed and all workers shall be released.cancelWorkRequirement
(@NonNull String workRequirementId) Instructs the Scheduler to cancel the supplied work requirement, no further tasks will be executed and all workers shall be released.cancelWorkRequirement
(@NonNull String workRequirementId, boolean abort) Instructs the Scheduler to cancel the supplied work requirement, no further tasks will be executed and all workers shall be released.void
close()
Cancels any active Server-Sent Event subscriptions.static WorkClientImpl
create
(@NonNull ServicesSchema servicesSchema, @NonNull RetryFactory retryFactory, @NonNull AuthenticationHeadersProvider authenticationHeadersProvider, @NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper, @NonNull UserAgent userAgent) Returns summaries of all existing work requirements within the system for the requesting user.findTasks
(@NonNull TaskSearch search) Returns tasks within the system that match the specified search.findTasks
(@NonNull TaskSearch search, @NonNull SliceReference sliceReference) Returns a slice of tasks that match the specified search and slice reference.Gets the latest state of the supplied task.Gets the latest state of the supplied task.getTasks
(TaskSearch search) Returns aSearchClient
that offers the ability to search tasks.getWorkRequirement
(@NonNull WorkRequirement workRequirement) Gets the latest state of the supplied work requirement.getWorkRequirement
(@NonNull String workRequirementId) Gets the latest state of the supplied work requirement.getWorkRequirement
(@NonNull String namespace, @NonNull String workRequirementName) Gets the latest state of the supplied work requirement.getWorkRequirementHelper
(@NonNull WorkRequirement workRequirement) Constructs a new work requirement helper for the specified requirement.getWorkRequirementHelper
(@NonNull String workRequirementId) Constructs a new work requirement helper for the specified requirement.Returns aSearchClient
that offers the ability to search work requirements.holdWorkRequirement
(@NonNull WorkRequirement workRequirement) Instructs the Scheduler to hold the supplied work requirement, no further tasks will be executed until the work requirement is started again.holdWorkRequirement
(@NonNull String workRequirementId) Instructs the Scheduler to hold the supplied work requirement, no further tasks will be executed until the work requirement is started again.void
removeWorkRequirementListener
(@NonNull SubscriptionEventListener<WorkRequirement> listener) Removes the specified event listener.startWorkRequirement
(@NonNull WorkRequirement workRequirement) Instructs the Scheduler to start the supplied work requirement after it was held.startWorkRequirement
(@NonNull String workRequirementId) Instructs the Scheduler to start the supplied work requirement after it was held.streamTasks
(@NonNull TaskSearch search) Streams tasks within the system that match the specified search.updateWorkRequirement
(@NonNull WorkRequirement workRequirement) Submits an existing work requirement to the YellowDog Scheduler service to be updated.
-
Method Details
-
create
public static WorkClientImpl create(@NonNull @NonNull ServicesSchema servicesSchema, @NonNull @NonNull RetryFactory retryFactory, @NonNull @NonNull AuthenticationHeadersProvider authenticationHeadersProvider, @NonNull @NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper, @NonNull @NonNull UserAgent userAgent) -
addWorkRequirement
Description copied from interface:WorkClient
Submits a NEW work requirement to the YellowDog Scheduler service to be initialised and started.- Specified by:
addWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirement
- the work requirement to submit- Returns:
- the latest state of the work requirement after it has been submitted
-
updateWorkRequirement
Description copied from interface:WorkClient
Submits an existing work requirement to the YellowDog Scheduler service to be updated.- Specified by:
updateWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirement
- the work requirement to submit- Returns:
- the latest state of the work requirement after it has been submitted
-
getWorkRequirement
Description copied from interface:WorkClient
Gets the latest state of the supplied work requirement.- Specified by:
getWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirement
- the work requirement for which to get the latest state- Returns:
- the latest state of the work requirement
-
getWorkRequirement
Description copied from interface:WorkClient
Gets the latest state of the supplied work requirement.- Specified by:
getWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirementId
- the ID of the work requirement- Returns:
- the latest state of the work requirement
-
getWorkRequirement
public WorkRequirement getWorkRequirement(@NonNull @NonNull String namespace, @NonNull @NonNull String workRequirementName) Description copied from interface:WorkClient
Gets the latest state of the supplied work requirement.- Specified by:
getWorkRequirement
in interfaceWorkClient
- Parameters:
namespace
- the namespace containing the requirementworkRequirementName
- the name of the requirement- Returns:
- the latest state of the work requirement
-
holdWorkRequirement
Description copied from interface:WorkClient
Instructs the Scheduler to hold the supplied work requirement, no further tasks will be executed until the work requirement is started again.- Specified by:
holdWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirement
- the work requirement to hold- Returns:
- the latest state of the work requirement after the hold instruction was submitted
-
holdWorkRequirement
Description copied from interface:WorkClient
Instructs the Scheduler to hold the supplied work requirement, no further tasks will be executed until the work requirement is started again.- Specified by:
holdWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirementId
- the ID of the work requirement to hold- Returns:
- the latest state of the work requirement after the hold instruction was submitted
-
startWorkRequirement
Description copied from interface:WorkClient
Instructs the Scheduler to start the supplied work requirement after it was held.- Specified by:
startWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirement
- the work requirement to start after being held- Returns:
- the latest state of the work requirement after the start instruction was submitted
-
startWorkRequirement
Description copied from interface:WorkClient
Instructs the Scheduler to start the supplied work requirement after it was held.- Specified by:
startWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirementId
- the ID of the work requirement to start after being held- Returns:
- the latest state of the work requirement after the start instruction was submitted
-
cancelWorkRequirement
Description copied from interface:WorkClient
Instructs the Scheduler to cancel the supplied work requirement, no further tasks will be executed and all workers shall be released.- Specified by:
cancelWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirement
- the work requirement to cancel- Returns:
- the latest state of the work requirement after the cancel instruction was submitted
-
cancelWorkRequirement
public WorkRequirement cancelWorkRequirement(@NonNull @NonNull WorkRequirement workRequirement, boolean abort) Description copied from interface:WorkClient
Instructs the Scheduler to cancel the supplied work requirement, no further tasks will be executed and all workers shall be released.- Specified by:
cancelWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirement
- the work requirement to cancelabort
- if tasks should be aborted if they have been allocated to a worker- Returns:
- the latest state of the work requirement after the cancel instruction was submitted
-
cancelWorkRequirement
Description copied from interface:WorkClient
Instructs the Scheduler to cancel the supplied work requirement, no further tasks will be executed and all workers shall be released.- Specified by:
cancelWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirementId
- the ID of the work requirement to cancel- Returns:
- the latest state of the work requirement after the cancel instruction was submitted
-
cancelWorkRequirement
public WorkRequirement cancelWorkRequirement(@NonNull @NonNull String workRequirementId, boolean abort) Description copied from interface:WorkClient
Instructs the Scheduler to cancel the supplied work requirement, no further tasks will be executed and all workers shall be released.- Specified by:
cancelWorkRequirement
in interfaceWorkClient
- Parameters:
workRequirementId
- the ID of the work requirement to cancelabort
- if tasks should be aborted if they have been allocated to a worker- Returns:
- the latest state of the work requirement after the cancel instruction was submitted
-
addWorkRequirementListener
public void addWorkRequirementListener(@NonNull @NonNull WorkRequirement workRequirement, @NonNull @NonNull SubscriptionEventListener<WorkRequirement> listener) Description copied from interface:WorkClient
Adds an event listener to receive notifications of changes for the specified work requirement. The client manages subscriptions to YellowDog Scheduler such that the first listener created for a requirement will cause a Server-Sent Events subscription to be initiated; additional listeners for the same requirement share that subscription.- Specified by:
addWorkRequirementListener
in interfaceWorkClient
- Parameters:
workRequirement
- the work requirement for which to receive notificationslistener
- the event listener that will be invoked for notifications
-
addWorkRequirementListener
public void addWorkRequirementListener(@NonNull @NonNull String workRequirementId, @NonNull @NonNull SubscriptionEventListener<WorkRequirement> listener) Description copied from interface:WorkClient
Adds an event listener to receive notifications of changes for the specified work requirement. The client manages subscriptions to YellowDog Scheduler such that the first listener created for a requirement will cause a Server-Sent Events subscription to be initiated; additional listeners for the same requirement share that subscription.- Specified by:
addWorkRequirementListener
in interfaceWorkClient
- Parameters:
workRequirementId
- the ID of the work requirement for which to receive notificationslistener
- the event listener that will be invoked for notifications
-
removeWorkRequirementListener
public void removeWorkRequirementListener(@NonNull @NonNull SubscriptionEventListener<WorkRequirement> listener) Description copied from interface:WorkClient
Removes the specified event listener. The client manages subscriptions to YellowDog Scheduler such that when the last listener for a requirement is removed, the associated Server-Sent Events subscription is cancelled.- Specified by:
removeWorkRequirementListener
in interfaceWorkClient
- Parameters:
listener
- the event listener that will no longer be invoked for notifications
-
getWorkRequirementHelper
public WorkRequirementHelper getWorkRequirementHelper(@NonNull @NonNull WorkRequirement workRequirement) Description copied from interface:WorkClient
Constructs a new work requirement helper for the specified requirement.- Specified by:
getWorkRequirementHelper
in interfaceWorkClient
- Parameters:
workRequirement
- the work requirement for which the helper will be constructed- Returns:
- a new work requirement helper
-
getWorkRequirementHelper
Description copied from interface:WorkClient
Constructs a new work requirement helper for the specified requirement.- Specified by:
getWorkRequirementHelper
in interfaceWorkClient
- Parameters:
workRequirementId
- the ID of the work requirement for which the helper will be constructed- Returns:
- a new work requirement helper
-
findAllWorkRequirements
Description copied from interface:WorkClient
Returns summaries of all existing work requirements within the system for the requesting user.- Specified by:
findAllWorkRequirements
in interfaceWorkClient
- Returns:
- a list of work requirement summaries
-
getWorkRequirements
Description copied from interface:WorkClient
Returns aSearchClient
that offers the ability to search work requirements.- Specified by:
getWorkRequirements
in interfaceWorkClient
- Parameters:
search
- the search- Returns:
- the search client
-
addTasksToTaskGroup
public List<Task> addTasksToTaskGroup(@NonNull @NonNull TaskGroup taskGroup, @NonNull @NonNull List<Task> tasks) Description copied from interface:WorkClient
Submits NEW tasks to the YellowDog Scheduler service to be added to the specified task group.- Specified by:
addTasksToTaskGroup
in interfaceWorkClient
- Parameters:
taskGroup
- the task group to add the tasks totasks
- the submitted tasks- Returns:
- the latest state of the tasks after they have been submitted
-
addTasksToTaskGroup
public List<Task> addTasksToTaskGroup(@NonNull @NonNull String taskGroupId, @NonNull @NonNull List<Task> tasks) Description copied from interface:WorkClient
Submits NEW tasks to the YellowDog Scheduler service to be added to the specified task group.- Specified by:
addTasksToTaskGroup
in interfaceWorkClient
- Parameters:
taskGroupId
- the ID of the task group to add the tasks totasks
- the submitted tasks- Returns:
- the latest state of the tasks after they have been submitted
-
addTasksToTaskGroup
public List<Task> addTasksToTaskGroup(@NonNull @NonNull String namespace, @NonNull @NonNull String workRequirementName, @NonNull @NonNull String taskGroupName, @NonNull @NonNull List<Task> tasks) Description copied from interface:WorkClient
Submits NEW tasks to the YellowDog Scheduler service to be added to the specified task group.- Specified by:
addTasksToTaskGroup
in interfaceWorkClient
- Parameters:
namespace
- the namespaceworkRequirementName
- the work requirement nametaskGroupName
- the task group nametasks
- the submitted tasks- Returns:
- the latest state of the tasks after they have been submitted
-
getTask
Description copied from interface:WorkClient
Gets the latest state of the supplied task.- Specified by:
getTask
in interfaceWorkClient
- Parameters:
task
- the task for which to get the latest state- Returns:
- the latest state of the task
-
getTask
Description copied from interface:WorkClient
Gets the latest state of the supplied task.- Specified by:
getTask
in interfaceWorkClient
- Parameters:
taskId
- the ID of the task- Returns:
- the latest state of the task
-
cancelTask
Description copied from interface:WorkClient
Instructs the Scheduler to cancel the specified task.- Specified by:
cancelTask
in interfaceWorkClient
- Parameters:
task
- the task to cancelabort
- if the task should be aborted if it has been allocated to a worker- Returns:
- the latest state of the task after the cancel instruction was submitted
-
cancelTask
Description copied from interface:WorkClient
Instructs the Scheduler to cancel the specified task.- Specified by:
cancelTask
in interfaceWorkClient
- Parameters:
taskId
- the ID of the task to cancelabort
- if the task should be aborted if it has been allocated to a worker- Returns:
- the latest state of the task after the cancel instruction was submitted
-
findTasks
Description copied from interface:WorkClient
Returns tasks within the system that match the specified search. WARNING: If your search matches too many tasks to fit into your application's memory limits, consider usingWorkClient.streamTasks(TaskSearch)
orWorkClient.findTasks(TaskSearch, SliceReference)
.- Specified by:
findTasks
in interfaceWorkClient
- Parameters:
search
- the search- Returns:
- a list of tasks
-
streamTasks
Description copied from interface:WorkClient
Streams tasks within the system that match the specified search.- Specified by:
streamTasks
in interfaceWorkClient
- Parameters:
search
- the search- Returns:
- a stream of tasks
-
findTasks
public Slice<Task> findTasks(@NonNull @NonNull TaskSearch search, @NonNull @NonNull SliceReference sliceReference) Description copied from interface:WorkClient
Returns a slice of tasks that match the specified search and slice reference.- Specified by:
findTasks
in interfaceWorkClient
- Parameters:
search
- the searchsliceReference
- the slice reference- Returns:
- a slice of tasks
-
getTasks
Description copied from interface:WorkClient
Returns aSearchClient
that offers the ability to search tasks.- Specified by:
getTasks
in interfaceWorkClient
- Parameters:
search
- the search- Returns:
- the search client
-
close
public void close()Cancels any active Server-Sent Event subscriptions.- Specified by:
close
in interfaceAutoCloseable
-