forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recommission api level support (opensearch-project#4604)
* Add changes for Recommission API Signed-off-by: pranikum <109206473+pranikum@users.noreply.github.com>
- Loading branch information
Showing
19 changed files
with
459 additions
and
11 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
19 changes: 19 additions & 0 deletions
19
...-api-spec/src/main/resources/rest-api-spec/api/cluster.delete_decommission_awareness.json
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,19 @@ | ||
{ | ||
"cluster.delete_decommission_awareness": { | ||
"documentation": { | ||
"url": "https://opensearch.org/docs/latest/opensearch/rest-api/decommission/", | ||
"description": "Delete any existing decommission." | ||
}, | ||
"stability": "experimental", | ||
"url": { | ||
"paths": [ | ||
{ | ||
"path": "/_cluster/decommission/awareness/", | ||
"methods": [ | ||
"DELETE" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
...rch/action/admin/cluster/decommission/awareness/delete/DeleteDecommissionStateAction.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,25 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.cluster.decommission.awareness.delete; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
/** | ||
* Delete decommission state action. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class DeleteDecommissionStateAction extends ActionType<DeleteDecommissionStateResponse> { | ||
public static final DeleteDecommissionStateAction INSTANCE = new DeleteDecommissionStateAction(); | ||
public static final String NAME = "cluster:admin/decommission/awareness/delete"; | ||
|
||
private DeleteDecommissionStateAction() { | ||
super(NAME, DeleteDecommissionStateResponse::new); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ch/action/admin/cluster/decommission/awareness/delete/DeleteDecommissionStateRequest.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,40 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.cluster.decommission.awareness.delete; | ||
|
||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Request for deleting decommission request. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class DeleteDecommissionStateRequest extends ClusterManagerNodeRequest<DeleteDecommissionStateRequest> { | ||
|
||
public DeleteDecommissionStateRequest() {} | ||
|
||
public DeleteDecommissionStateRequest(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...on/admin/cluster/decommission/awareness/delete/DeleteDecommissionStateRequestBuilder.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,27 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.cluster.decommission.awareness.delete; | ||
|
||
import org.opensearch.action.support.clustermanager.ClusterManagerNodeOperationRequestBuilder; | ||
import org.opensearch.client.OpenSearchClient; | ||
|
||
/** | ||
* Builder for Delete decommission request. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class DeleteDecommissionStateRequestBuilder extends ClusterManagerNodeOperationRequestBuilder< | ||
DeleteDecommissionStateRequest, | ||
DeleteDecommissionStateResponse, | ||
DeleteDecommissionStateRequestBuilder> { | ||
|
||
public DeleteDecommissionStateRequestBuilder(OpenSearchClient client, DeleteDecommissionStateAction action) { | ||
super(client, action, new DeleteDecommissionStateRequest()); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...h/action/admin/cluster/decommission/awareness/delete/DeleteDecommissionStateResponse.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,36 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.cluster.decommission.awareness.delete; | ||
|
||
import org.opensearch.action.support.master.AcknowledgedResponse; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Response returned after deletion of decommission request. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class DeleteDecommissionStateResponse extends AcknowledgedResponse { | ||
|
||
public DeleteDecommissionStateResponse(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
public DeleteDecommissionStateResponse(boolean acknowledged) { | ||
super(acknowledged); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...n/admin/cluster/decommission/awareness/delete/TransportDeleteDecommissionStateAction.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,86 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.cluster.decommission.awareness.delete; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.action.ActionListener; | ||
import org.opensearch.action.support.ActionFilters; | ||
import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; | ||
import org.opensearch.cluster.ClusterState; | ||
import org.opensearch.cluster.block.ClusterBlockException; | ||
import org.opensearch.cluster.block.ClusterBlockLevel; | ||
import org.opensearch.cluster.decommission.DecommissionService; | ||
import org.opensearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.opensearch.cluster.service.ClusterService; | ||
import org.opensearch.common.inject.Inject; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.threadpool.ThreadPool; | ||
import org.opensearch.transport.TransportService; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Transport action for delete decommission. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class TransportDeleteDecommissionStateAction extends TransportClusterManagerNodeAction< | ||
DeleteDecommissionStateRequest, | ||
DeleteDecommissionStateResponse> { | ||
|
||
private static final Logger logger = LogManager.getLogger(TransportDeleteDecommissionStateAction.class); | ||
private final DecommissionService decommissionService; | ||
|
||
@Inject | ||
public TransportDeleteDecommissionStateAction( | ||
TransportService transportService, | ||
ClusterService clusterService, | ||
ThreadPool threadPool, | ||
ActionFilters actionFilters, | ||
IndexNameExpressionResolver indexNameExpressionResolver, | ||
DecommissionService decommissionService | ||
) { | ||
super( | ||
DeleteDecommissionStateAction.NAME, | ||
transportService, | ||
clusterService, | ||
threadPool, | ||
actionFilters, | ||
DeleteDecommissionStateRequest::new, | ||
indexNameExpressionResolver | ||
); | ||
this.decommissionService = decommissionService; | ||
} | ||
|
||
@Override | ||
protected String executor() { | ||
return ThreadPool.Names.SAME; | ||
} | ||
|
||
@Override | ||
protected DeleteDecommissionStateResponse read(StreamInput in) throws IOException { | ||
return new DeleteDecommissionStateResponse(in); | ||
} | ||
|
||
@Override | ||
protected ClusterBlockException checkBlock(DeleteDecommissionStateRequest request, ClusterState state) { | ||
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); | ||
} | ||
|
||
@Override | ||
protected void clusterManagerOperation( | ||
DeleteDecommissionStateRequest request, | ||
ClusterState state, | ||
ActionListener<DeleteDecommissionStateResponse> listener | ||
) { | ||
logger.info("Received delete decommission Request [{}]", request); | ||
this.decommissionService.startRecommissionAction(listener); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.../java/org/opensearch/action/admin/cluster/decommission/awareness/delete/package-info.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,10 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
/** Delete decommission transport handlers. */ | ||
package org.opensearch.action.admin.cluster.decommission.awareness.delete; |
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.