-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'es/6.x' into ccr-6.x
* es/6.x: (21 commits) Rename methods in PersistentTasksService (#30837) [DOCS] Fix watcher file location Minor clean-up in InternalRange. (#30886) [DOCS] Remove reference to platinum Docker image (#30916) Use dedicated ML APIs in tests (#30941) [test] packaging: use shell when running commands (#30852) [DOCS] Adds missing TLS settings for auditing (#30822) QA: Preserve templates and snapshot on upgrades Upgrade to Lucene-7.4-snapshot-1cbadda4d3 (#30928) Upgrade to Lucene-7.4.0-snapshot-cc2ee23050 (#30778) Fix IndexTemplateMetaData parsing from xContent (#30917) [DOCS] Fixes 6.4 breaking change page [DOCS] Reset edit links (#30909) Moved keyword tokenizer to analysis-common module (#30642) added migration note about legacy stored script formats being deprecated Deprecate accepting malformed requests in stored script API (#28939) Remove log traces in AzureStorageServiceImpl and fix test Move list tasks under Tasks namespace (#30906) Improve allocation-disabling instructions (#30248) Remove AllocatedPersistentTask.getState() (#30858) ...
- Loading branch information
Showing
132 changed files
with
1,289 additions
and
752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
client/rest-high-level/src/main/java/org/elasticsearch/client/TasksClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.apache.http.Header; | ||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest; | ||
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; | ||
|
||
import java.io.IOException; | ||
|
||
import static java.util.Collections.emptySet; | ||
|
||
/** | ||
* A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Tasks API. | ||
* <p> | ||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html">Task Management API on elastic.co</a> | ||
*/ | ||
public class TasksClient { | ||
private final RestHighLevelClient restHighLevelClient; | ||
|
||
TasksClient(RestHighLevelClient restHighLevelClient) { | ||
this.restHighLevelClient = restHighLevelClient; | ||
} | ||
|
||
/** | ||
* Get current tasks using the Task Management API | ||
* <p> | ||
* See | ||
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html"> Task Management API on elastic.co</a> | ||
*/ | ||
public ListTasksResponse list(ListTasksRequest request, Header... headers) throws IOException { | ||
return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::listTasks, ListTasksResponse::fromXContent, | ||
emptySet(), headers); | ||
} | ||
|
||
/** | ||
* Asynchronously get current tasks using the Task Management API | ||
* <p> | ||
* See | ||
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html"> Task Management API on elastic.co</a> | ||
*/ | ||
public void listAsync(ListTasksRequest request, ActionListener<ListTasksResponse> listener, Header... headers) { | ||
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::listTasks, ListTasksResponse::fromXContent, | ||
listener, emptySet(), headers); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest; | ||
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; | ||
import org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup; | ||
import org.elasticsearch.tasks.TaskInfo; | ||
|
||
import java.io.IOException; | ||
|
||
import static java.util.Collections.emptyList; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.greaterThanOrEqualTo; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
public class TasksIT extends ESRestHighLevelClientTestCase { | ||
|
||
public void testListTasks() throws IOException { | ||
ListTasksRequest request = new ListTasksRequest(); | ||
ListTasksResponse response = execute(request, highLevelClient().tasks()::list, highLevelClient().tasks()::listAsync); | ||
|
||
assertThat(response, notNullValue()); | ||
assertThat(response.getNodeFailures(), equalTo(emptyList())); | ||
assertThat(response.getTaskFailures(), equalTo(emptyList())); | ||
// It's possible that there are other tasks except 'cluster:monitor/tasks/lists[n]' and 'action":"cluster:monitor/tasks/lists' | ||
assertThat(response.getTasks().size(), greaterThanOrEqualTo(2)); | ||
boolean listTasksFound = false; | ||
for (TaskGroup taskGroup : response.getTaskGroups()) { | ||
TaskInfo parent = taskGroup.getTaskInfo(); | ||
if ("cluster:monitor/tasks/lists".equals(parent.getAction())) { | ||
assertThat(taskGroup.getChildTasks().size(), equalTo(1)); | ||
TaskGroup childGroup = taskGroup.getChildTasks().iterator().next(); | ||
assertThat(childGroup.getChildTasks().isEmpty(), equalTo(true)); | ||
TaskInfo child = childGroup.getTaskInfo(); | ||
assertThat(child.getAction(), equalTo("cluster:monitor/tasks/lists[n]")); | ||
assertThat(child.getParentTaskId(), equalTo(parent.getTaskId())); | ||
listTasksFound = true; | ||
} | ||
} | ||
assertTrue("List tasks were not found", listTasksFound); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.