-
Notifications
You must be signed in to change notification settings - Fork 24.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #3368
- Loading branch information
Showing
14 changed files
with
664 additions
and
0 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
45 changes: 45 additions & 0 deletions
45
src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksAction.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,45 @@ | ||
/* | ||
* Licensed to ElasticSearch and Shay Banon 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.action.admin.cluster.tasks; | ||
|
||
import org.elasticsearch.action.admin.cluster.ClusterAction; | ||
import org.elasticsearch.client.ClusterAdminClient; | ||
|
||
/** | ||
*/ | ||
public class PendingClusterTasksAction extends ClusterAction<PendingClusterTasksRequest, PendingClusterTasksResponse, PendingClusterTasksRequestBuilder> { | ||
|
||
public static final PendingClusterTasksAction INSTANCE = new PendingClusterTasksAction(); | ||
public static final String NAME = "cluster/task"; | ||
|
||
private PendingClusterTasksAction() { | ||
super(NAME); | ||
} | ||
|
||
@Override | ||
public PendingClusterTasksResponse newResponse() { | ||
return new PendingClusterTasksResponse(); | ||
} | ||
|
||
@Override | ||
public PendingClusterTasksRequestBuilder newRequestBuilder(ClusterAdminClient client) { | ||
return new PendingClusterTasksRequestBuilder(client); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksRequest.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,33 @@ | ||
/* | ||
* Licensed to ElasticSearch and Shay Banon 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.action.admin.cluster.tasks; | ||
|
||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.support.master.MasterNodeOperationRequest; | ||
|
||
/** | ||
*/ | ||
public class PendingClusterTasksRequest extends MasterNodeOperationRequest<PendingClusterTasksRequest> { | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
.../java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksRequestBuilder.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,39 @@ | ||
/* | ||
* Licensed to ElasticSearch and Shay Banon 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.action.admin.cluster.tasks; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder; | ||
import org.elasticsearch.client.ClusterAdminClient; | ||
import org.elasticsearch.client.internal.InternalClusterAdminClient; | ||
|
||
/** | ||
*/ | ||
public class PendingClusterTasksRequestBuilder extends MasterNodeOperationRequestBuilder<PendingClusterTasksRequest, PendingClusterTasksResponse, PendingClusterTasksRequestBuilder> { | ||
|
||
public PendingClusterTasksRequestBuilder(ClusterAdminClient client) { | ||
super((InternalClusterAdminClient) client, new PendingClusterTasksRequest()); | ||
} | ||
|
||
@Override | ||
protected void doExecute(ActionListener<PendingClusterTasksResponse> listener) { | ||
((InternalClusterAdminClient) client).pendingClusterTasks(request, listener); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksResponse.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,82 @@ | ||
/* | ||
* Licensed to ElasticSearch and Shay Banon 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.action.admin.cluster.tasks; | ||
|
||
import org.elasticsearch.action.ActionResponse; | ||
import org.elasticsearch.cluster.service.PendingClusterTask; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
/** | ||
*/ | ||
public class PendingClusterTasksResponse extends ActionResponse implements Iterable<PendingClusterTask> { | ||
|
||
private List<PendingClusterTask> pendingTasks; | ||
|
||
PendingClusterTasksResponse() { | ||
} | ||
|
||
PendingClusterTasksResponse(List<PendingClusterTask> pendingTasks) { | ||
this.pendingTasks = pendingTasks; | ||
} | ||
|
||
public List<PendingClusterTask> pendingTasks() { | ||
return pendingTasks; | ||
} | ||
|
||
/** | ||
* The pending cluster tasks | ||
*/ | ||
public List<PendingClusterTask> getPendingTasks() { | ||
return pendingTasks(); | ||
} | ||
|
||
@Override | ||
public Iterator<PendingClusterTask> iterator() { | ||
return pendingTasks.iterator(); | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
int size = in.readVInt(); | ||
pendingTasks = new ArrayList<PendingClusterTask>(size); | ||
for (int i = 0; i < size; i++) { | ||
PendingClusterTask task = new PendingClusterTask(); | ||
task.readFrom(in); | ||
pendingTasks.add(task); | ||
} | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeVInt(pendingTasks.size()); | ||
for (PendingClusterTask task : pendingTasks) { | ||
task.writeTo(out); | ||
} | ||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
...java/org/elasticsearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.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,69 @@ | ||
/* | ||
* Licensed to ElasticSearch and Shay Banon 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.action.admin.cluster.tasks; | ||
|
||
import org.elasticsearch.ElasticSearchException; | ||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction; | ||
import org.elasticsearch.cluster.ClusterService; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.TransportService; | ||
|
||
/** | ||
*/ | ||
public class TransportPendingClusterTasksAction extends TransportMasterNodeOperationAction<PendingClusterTasksRequest, PendingClusterTasksResponse> { | ||
|
||
private final ClusterService clusterService; | ||
|
||
@Inject | ||
public TransportPendingClusterTasksAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool) { | ||
super(settings, transportService, clusterService, threadPool); | ||
this.clusterService = clusterService; | ||
} | ||
|
||
@Override | ||
protected String transportAction() { | ||
return PendingClusterTasksAction.NAME; | ||
} | ||
|
||
@Override | ||
protected String executor() { | ||
// very lightweight operation in memory, no need to fork to a thread | ||
return ThreadPool.Names.SAME; | ||
} | ||
|
||
@Override | ||
protected PendingClusterTasksRequest newRequest() { | ||
return new PendingClusterTasksRequest(); | ||
} | ||
|
||
@Override | ||
protected PendingClusterTasksResponse newResponse() { | ||
return new PendingClusterTasksResponse(); | ||
} | ||
|
||
@Override | ||
protected void masterOperation(PendingClusterTasksRequest request, ClusterState state, ActionListener<PendingClusterTasksResponse> listener) throws ElasticSearchException { | ||
listener.onResponse(new PendingClusterTasksResponse(clusterService.pendingTasks())); | ||
} | ||
} |
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
Oops, something went wrong.