Skip to content
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

Change path of REST APIs for 'Sample Extension Plugin' and naming convension in filename and comments #25

Merged
merged 6 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@
*
* Users need to provide "id", "index", "job_name", and "interval" parameter to schedule
* a job. e.g.
* {@code POST /_opendistro/scheduler_sample/watch?id=kibana-job-id&job_name=watch kibana index&index=.kibana_1&interval=1"}
* {@code
* POST /_plugins/scheduler_sample/watch?id=dashboards-job-id&job_name=watch dashboards index&index=.opensearch_dashboards_1&interval=1
* }
*
* creates a job with id "1" and job name "watch kibana index", which logs ".kibana_1" index's shards info
* every 1 minute
* creates a job with id "dashboards-job-id" and job name "watch dashboards index",
* which logs ".opensearch_dashboards_1" index's shards info every 1 minute
*
* Users can remove that job by calling
* {@code DELETE /_opendistro/scheduler_sample/watch?id=kibana-job-id}
* {@code DELETE /_plugins/scheduler_sample/watch?id=dashboards-job-id}
*/
public class SampleExtensionRestHandler extends BaseRestHandler {
public static final String WATCH_INDEX_URI = "/_opendistro/scheduler_sample/watch";
public static final String WATCH_INDEX_URI = "/_plugins/scheduler_sample/watch";

@Override
public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
/**
* A sample job runner class.
*
* The job runner should be a singleton class if it uses Elasticsearch client or other objects passed
* from Elasticsearch. Because when registering the job runner to JobScheduler plugin, Elasticsearch has
* The job runner should be a singleton class if it uses OpenSearch client or other objects passed
* from OpenSearch. Because when registering the job runner to JobScheduler plugin, OpenSearch has
* not invoke plugins' createComponents() method. That is saying the plugin is not completely initalized,
* and the Elasticsearch {@link org.opensearch.client.Client}, {@link ClusterService} and other objects
* and the OpenSearch {@link org.opensearch.client.Client}, {@link ClusterService} and other objects
* are not available to plugin and this job runner.
*
* So we have to move this job runner intialization to {@link Plugin} createComponents() method, and using
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public LockService(final Client client, final ClusterService clusterService) {

private String lockMapping() {
try {
InputStream in = LockService.class.getResourceAsStream("opendistro_job_scheduler_lock.json");
InputStream in = LockService.class.getResourceAsStream("opensearch_job_scheduler_lock.json");
StringBuilder stringBuilder = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
for (String line; (line = bufferedReader.readLine()) != null; ) {
Expand Down