Skip to content

Commit

Permalink
add documentation & TaskWorker interface
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Bansal <bansvaru@amazon.com>
  • Loading branch information
linuxpi committed May 7, 2024
1 parent bf65b92 commit 1742088
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
package org.opensearch.offline_tasks;

import org.opensearch.common.annotation.ExperimentalApi;
import org.opensearch.offline_tasks.task.Task;
import org.opensearch.offline_tasks.task.TaskId;

import java.util.List;

Expand All @@ -21,37 +23,37 @@
public interface TaskClient {

/**
* Submit a new task to Task Store/Queue
* Submit a new task to TaskStore/Queue
*
* @param task
*/
void submitTask(Task task);

/**
* Claim task from Task Store/Queue. This ensure no 2 nodes work on the same task.
* Claim task from TaskStore/Queue. This ensures no 2 Offline Nodes work on the same task.
*
* @param taskId
*/
void claimTask(TaskId taskId);

/**
* Get task from Task Store/Queue
* Get task from TaskStore/Queue
*
* @param taskId
* @return
* @return Task corresponding to TaskId
*/
Task getTask(TaskId taskId);

/**
* Update task in Task Store/Queue
* Update task in TaskStore/Queue
*
* @param task
* @return
*/
Task updateTask(Task task);
void updateTask(Task task);

/**
* Mark task as cancelled
* Mark task as cancelled.
* Ongoing Tasks can be cancelled as well if the corresponding worker supports cancellation
*
* @param taskId
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
* compatible open source license.
*/

package org.opensearch.offline_tasks;
package org.opensearch.offline_tasks.task;

import org.opensearch.common.annotation.ExperimentalApi;

/**
* A Background Task to be run on Offline Node.
*/
@ExperimentalApi
public class Task {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@
* compatible open source license.
*/

package org.opensearch.offline_tasks;
package org.opensearch.offline_tasks.task;

import org.opensearch.common.annotation.ExperimentalApi;

/**
* Class encapsulating Task id
* Class encapsulating Task identifier
*/
@ExperimentalApi
public class TaskId {

/**
* Id of the Task
* Identified of the Task
*/
String id;

/**
* Constructor to initialize TaskId
* @param id
*/
public TaskId(String id) {
this.id = id;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.offline_tasks.task;

import org.opensearch.common.annotation.ExperimentalApi;

/**
* Base class for all TaskParams implementation of various TaskTypes
*/
@ExperimentalApi
public abstract class TaskParams {

/**
* Default constructor
*/
public TaskParams() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.offline_tasks;
package org.opensearch.offline_tasks.task;

/**
* Enum for task type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
*/

/**
* Contains telemetry related classes
* Contains tasks related classes
*/
package org.opensearch.offline_tasks;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.offline_tasks.worker;

import org.opensearch.common.annotation.ExperimentalApi;
import org.opensearch.offline_tasks.task.Task;
import org.opensearch.offline_tasks.task.TaskParams;

/**
* Task Worker that executes the Task
*
* @opensearch.experimental
*/
@ExperimentalApi
public interface TaskWorker {

/**
* Execute the Task
*
* @param task Task to be execute
* @param taskParams TaskParams to be used while executing the task
*/
void executeTask(Task task, TaskParams taskParams);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/**
* Contains task worker related classes
*/
package org.opensearch.offline_tasks.worker;
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

package org.opensearch.offline_tasks;

/**
* Base class for all TaskParams implementation of various TaskTypes
*/
public abstract class TaskParams {
public class TaskClientTest {
public TaskClientTest() {}
}

0 comments on commit 1742088

Please sign in to comment.