-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete API for weighted round robin search routing
Signed-off-by: Anshu Agarwal <[email protected]>
- Loading branch information
Anshu Agarwal
committed
Sep 3, 2022
1 parent
97b2931
commit 8ce5255
Showing
12 changed files
with
368 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
25 changes: 25 additions & 0 deletions
25
...nsearch/action/admin/cluster/shards/routing/wrr/delete/ClusterDeleteWRRWeightsAction.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.shards.routing.wrr.delete; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
/** | ||
* Action to delete weights for weighted round-robin shard routing policy. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ClusterDeleteWRRWeightsAction extends ActionType<ClusterDeleteWRRWeightsResponse> { | ||
public static final ClusterDeleteWRRWeightsAction INSTANCE = new ClusterDeleteWRRWeightsAction(); | ||
public static final String NAME = "cluster:admin/routing/awareness/weights/delete"; | ||
|
||
private ClusterDeleteWRRWeightsAction() { | ||
super(NAME, ClusterDeleteWRRWeightsResponse::new); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...search/action/admin/cluster/shards/routing/wrr/delete/ClusterDeleteWRRWeightsRequest.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 @@ | ||
/* | ||
* 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.shards.routing.wrr.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 to delete weights for weighted round-robin shard routing policy. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ClusterDeleteWRRWeightsRequest extends ClusterManagerNodeRequest<ClusterDeleteWRRWeightsRequest> { | ||
public ClusterDeleteWRRWeightsRequest() { | ||
} | ||
|
||
public ClusterDeleteWRRWeightsRequest(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ClusterDeleteWRRWeightsRequest"; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...action/admin/cluster/shards/routing/wrr/delete/ClusterDeleteWRRWeightsRequestBuilder.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.shards.routing.wrr.delete; | ||
|
||
import org.opensearch.action.support.clustermanager.ClusterManagerNodeOperationRequestBuilder; | ||
import org.opensearch.client.OpenSearchClient; | ||
|
||
/** | ||
* Request builder to delete weights for weighted round-robin shard routing policy. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ClusterDeleteWRRWeightsRequestBuilder extends ClusterManagerNodeOperationRequestBuilder< | ||
ClusterDeleteWRRWeightsRequest, | ||
ClusterDeleteWRRWeightsResponse, | ||
ClusterDeleteWRRWeightsRequestBuilder> { | ||
|
||
public ClusterDeleteWRRWeightsRequestBuilder(OpenSearchClient client, ClusterDeleteWRRWeightsAction action) { | ||
super(client, action, new ClusterDeleteWRRWeightsRequest()); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...earch/action/admin/cluster/shards/routing/wrr/delete/ClusterDeleteWRRWeightsResponse.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,37 @@ | ||
/* | ||
* 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.shards.routing.wrr.delete; | ||
|
||
import org.opensearch.action.support.master.AcknowledgedResponse; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.common.xcontent.ToXContentObject; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Response from deleting weights for weighted round-robin search routing policy. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ClusterDeleteWRRWeightsResponse extends AcknowledgedResponse implements ToXContentObject { | ||
ClusterDeleteWRRWeightsResponse(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
ClusterDeleteWRRWeightsResponse(boolean acknowledged) { | ||
super(acknowledged); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
|
||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
...earch/action/admin/cluster/shards/routing/wrr/delete/TransportDeleteWRRWeightsAction.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,93 @@ | ||
/* | ||
* 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.shards.routing.wrr.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.metadata.IndexNameExpressionResolver; | ||
import org.opensearch.cluster.routing.WRRShardRoutingService; | ||
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 deleting weights for weighted round-robin search routing policy | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class TransportDeleteWRRWeightsAction extends TransportClusterManagerNodeAction< | ||
ClusterDeleteWRRWeightsRequest, | ||
ClusterDeleteWRRWeightsResponse> { | ||
|
||
private static final Logger logger = LogManager.getLogger(TransportDeleteWRRWeightsAction.class); | ||
|
||
private final WRRShardRoutingService wrrShardRoutingService; | ||
|
||
@Inject | ||
public TransportDeleteWRRWeightsAction( | ||
TransportService transportService, | ||
ClusterService clusterService, | ||
WRRShardRoutingService wrrShardRoutingService, | ||
ThreadPool threadPool, | ||
ActionFilters actionFilters, | ||
IndexNameExpressionResolver indexNameExpressionResolver | ||
) { | ||
super( | ||
ClusterDeleteWRRWeightsAction.NAME, | ||
transportService, | ||
clusterService, | ||
threadPool, | ||
actionFilters, | ||
ClusterDeleteWRRWeightsRequest::new, | ||
indexNameExpressionResolver | ||
); | ||
this.wrrShardRoutingService = wrrShardRoutingService; | ||
} | ||
|
||
@Override | ||
protected String executor() { | ||
return ThreadPool.Names.SAME; | ||
} | ||
|
||
@Override | ||
protected ClusterDeleteWRRWeightsResponse read(StreamInput in) throws IOException { | ||
return new ClusterDeleteWRRWeightsResponse(in); | ||
} | ||
|
||
@Override | ||
protected ClusterBlockException checkBlock(ClusterDeleteWRRWeightsRequest request, ClusterState state) { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected void clusterManagerOperation( | ||
ClusterDeleteWRRWeightsRequest request, | ||
ClusterState state, | ||
ActionListener<ClusterDeleteWRRWeightsResponse> listener | ||
) throws Exception { | ||
wrrShardRoutingService.deleteWRRWeightsMetadata( | ||
request, | ||
ActionListener.delegateFailure( | ||
listener, | ||
(delegatedListener, response) -> { | ||
delegatedListener.onResponse(new ClusterDeleteWRRWeightsResponse(response.isAcknowledged())); | ||
} | ||
) | ||
); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...main/java/org/opensearch/action/admin/cluster/shards/routing/wrr/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 weighted-round robin shard routing weights. */ | ||
package org.opensearch.action.admin.cluster.shards.routing.wrr.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.