-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
introduce BackgroundTaskService #4
Conversation
/** | ||
* Service to manage execution of tasks on Offline Node | ||
*/ | ||
public class BackgroundTaskService implements LifecycleComponent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add @opensearch.internal
.
Also, should we extend AbstractLifecycleComponent
instead like the other services do, unless we plan to extend any other classes?
/** | |
* Service to manage execution of tasks on Offline Node | |
*/ | |
public class BackgroundTaskService implements LifecycleComponent { | |
/** | |
* Service to manage execution of tasks on Offline Node | |
* | |
* @opensearch.internal | |
*/ | |
public class BackgroundTaskService extends AbstractLifecycleComponent { |
private AsyncBackgroundTaskFetch backgroundTaskFetch; | ||
/** | ||
* TaskClient used to interact with TaskStore/Queue for Task Management and Coordination | ||
*/ | ||
private final TaskClient taskClient; | ||
/** | ||
* Provides Corresponding TaskWorker to execute for each Task | ||
*/ | ||
private final Map<TaskType, TaskWorker> taskWorkerMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private AsyncBackgroundTaskFetch backgroundTaskFetch; | |
/** | |
* TaskClient used to interact with TaskStore/Queue for Task Management and Coordination | |
*/ | |
private final TaskClient taskClient; | |
/** | |
* Provides Corresponding TaskWorker to execute for each Task | |
*/ | |
private final Map<TaskType, TaskWorker> taskWorkerMap; | |
private AsyncBackgroundTaskFetch backgroundTaskFetch; | |
/** | |
* TaskClient used to interact with TaskStore/Queue for Task Management and Coordination | |
*/ | |
private final TaskClient taskClient; | |
/** | |
* Provides Corresponding TaskWorker to execute for each Task | |
*/ | |
private final Map<TaskType, TaskWorker> taskWorkerMap; |
@Override | ||
public void stop() { | ||
backgroundTaskFetch.close(); | ||
backgroundTaskFetch.cancel(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close()
is calling cancel()
internally. Do we need the explicit cancel?
@Override | |
public void stop() { | |
backgroundTaskFetch.close(); | |
backgroundTaskFetch.cancel(); | |
} | |
@Override | |
public void stop() { | |
backgroundTaskFetch.close(); | |
} |
@Override | ||
public Lifecycle.State lifecycleState() { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we returning null?
@Override | ||
public void addLifecycleListener(LifecycleListener listener) { | ||
|
||
} | ||
|
||
@Override | ||
public void removeLifecycleListener(LifecycleListener listener) { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these intentional?
|
||
} | ||
|
||
public void maybeExecuteTasks() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
public void maybeExecuteTasks() { | |
public void maybeExecuteUnassignedTasks() { |
} | ||
} | ||
|
||
private class AsyncBackgroundTaskFetch extends AbstractAsyncTask { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing javadoc
} | ||
} | ||
|
||
private class AsyncBackgroundTaskFetch extends AbstractAsyncTask { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we name this BackgroundTaskFetch
or AsyncTaskFetch
, unless the current name is intentional?
if (taskClient.claimTask(task.getTaskId())) { | ||
taskWorkerMap.get(task.getTaskType()).executeTask(task); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be synchronized?
Description
[Describe what this change achieves]
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.