From 3da926394f9cb90d26d0b8e118fdface3fb5026b Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 18 May 2021 16:59:37 -0700 Subject: [PATCH 1/5] Rename mapping definition file for job scheduler lock index Signed-off-by: Tianli Feng --- .../jobscheduler/spi/utils/LockService.java | 2 +- ...b_scheduler_lock.json => opensearch_job_scheduler_lock.json} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename spi/src/main/resources/com/amazon/opendistroforelasticsearch/jobscheduler/spi/utils/{opendistro_job_scheduler_lock.json => opensearch_job_scheduler_lock.json} (100%) diff --git a/spi/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/spi/utils/LockService.java b/spi/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/spi/utils/LockService.java index 084fc756..27987240 100644 --- a/spi/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/spi/utils/LockService.java +++ b/spi/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/spi/utils/LockService.java @@ -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; ) { diff --git a/spi/src/main/resources/com/amazon/opendistroforelasticsearch/jobscheduler/spi/utils/opendistro_job_scheduler_lock.json b/spi/src/main/resources/com/amazon/opendistroforelasticsearch/jobscheduler/spi/utils/opensearch_job_scheduler_lock.json similarity index 100% rename from spi/src/main/resources/com/amazon/opendistroforelasticsearch/jobscheduler/spi/utils/opendistro_job_scheduler_lock.json rename to spi/src/main/resources/com/amazon/opendistroforelasticsearch/jobscheduler/spi/utils/opensearch_job_scheduler_lock.json From 198cb304a1c023fc3555e82e610e167f4ccba9d8 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 18 May 2021 17:00:56 -0700 Subject: [PATCH 2/5] Rename Elasticsearch to OpenSearch in comments for Sample-extension-plugin Signed-off-by: Tianli Feng --- .../jobscheduler/sampleextension/SampleJobRunner.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleJobRunner.java b/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleJobRunner.java index 2eb1635a..4a34d8cb 100644 --- a/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleJobRunner.java +++ b/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleJobRunner.java @@ -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 From 5a764d8b148be85b4c4b252d5b4243e6ff6cee89 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 18 May 2021 17:08:29 -0700 Subject: [PATCH 3/5] Rename Rest API and 'kibana' in the comments for sample-extension-plugin Signed-off-by: Tianli Feng --- .../sampleextension/SampleExtensionRestHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java b/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java index 7657b2a0..e4a7d2d6 100644 --- a/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java +++ b/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java @@ -52,16 +52,16 @@ * * 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=opensearch-dashboards-job-id&job_name=watch opensearch-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 + * creates a job with id "opensearch-dashboards-job-id" and job name "watch opensearch-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() { From 547518a03546517beffe20283af69dfb5ac4279c Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 18 May 2021 18:06:39 -0700 Subject: [PATCH 4/5] Break 2 long lines of the comments Signed-off-by: Tianli Feng --- .../sampleextension/SampleExtensionRestHandler.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java b/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java index e4a7d2d6..11e48fdb 100644 --- a/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java +++ b/sample-extension-plugin/src/main/java/com/amazon/opendistroforelasticsearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java @@ -50,12 +50,13 @@ /** * A sample rest handler that supports schedule and deschedule job operation * - * Users need to provide "id", "index", "job_name", and "interval" parameter to schedule - * a job. e.g. - * {@code POST /_plugins/scheduler_sample/watch?id=opensearch-dashboards-job-id&job_name=watch opensearch-dashboards index&index=.opensearch_dashboards_1&interval=1"} + * Users need to provide "id", "index", "job_name", and "interval" parameter to schedule a job. e.g. + * {@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 "opensearch-dashboards-job-id" and job name "watch opensearch-dashboards index", which logs ".opensearch_dashboards_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 /_plugins/scheduler_sample/watch?id=dashboards-job-id} From d0543d6c79b120a6669823f56a2f86d7617ef29e Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Wed, 19 May 2021 09:41:40 -0700 Subject: [PATCH 5/5] Restore a line break of the comment Signed-off-by: Tianli Feng --- .../sampleextension/SampleExtensionRestHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sample-extension-plugin/src/main/java/org/opensearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java b/sample-extension-plugin/src/main/java/org/opensearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java index 7d4a232a..a1ca1d1f 100644 --- a/sample-extension-plugin/src/main/java/org/opensearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java +++ b/sample-extension-plugin/src/main/java/org/opensearch/jobscheduler/sampleextension/SampleExtensionRestHandler.java @@ -50,7 +50,8 @@ /** * A sample rest handler that supports schedule and deschedule job operation * - * Users need to provide "id", "index", "job_name", and "interval" parameter to schedule a job. e.g. + * Users need to provide "id", "index", "job_name", and "interval" parameter to schedule + * a job. e.g. * {@code * POST /_plugins/scheduler_sample/watch?id=dashboards-job-id&job_name=watch dashboards index&index=.opensearch_dashboards_1&interval=1 * }