Skip to content

Commit

Permalink
Change path of REST APIs for 'Sample Extension Plugin' and naming con…
Browse files Browse the repository at this point in the history
…vension in filename and comments (opensearch-project#25)

* Rename mapping definition file for job scheduler lock index

* Rename Elasticsearch to OpenSearch in comments for Sample-extension-plugin

* Rename Rest API and 'kibana' in the comments for sample-extension-plugin

Signed-off-by: Tianli Feng <ftianli@amazon.com>
  • Loading branch information
Tianli Feng committed May 20, 2021
1 parent 0a8f201 commit 69b52c4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
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

0 comments on commit 69b52c4

Please sign in to comment.