Background:
- Working on this issue - a new feature in ism to “stop following” indices from a leader cluster.
- This requires invoking the CCR action TransportStopIndexReplicationAction from ism code.
- As per the suggestion (to solve classloader issues), the request and response objects need to be treated as ActionRequest and ActionResponse respectively and converted to the actual required types later. For this, the method doExecute() in TransportStopIndexReplicationAction class needs to be overridden with a change, like previously done for other “Actions” in plugins like Notifications.
- TransportStopIndexReplicationAction extends the opensearch action TransportClusterManagerNodeAction
Describe the issue:
Unable to override the doExecute method when the type of request needs to be changed to ActionRequest instead of StopIndexReplicationRequest →
Original method in TransportClusterManagerNodeAction.java
@Override
protected void doExecute(Task task, final Request request, ActionListener<Response> listener) {
if (task != null) {
request.setParentTask(clusterService.localNode().getId(), task.getId());
}
new AsyncSingleAction(task, request, listener).run();
}
Intended change I’m trying to make in CCR (TransportStopIndexReplicationAction)
override fun doExecute(
task: Task?,
request: ActionRequest,
listener: ActionListener<AcknowledgedResponse>?
) {
super.doExecute(task, request, listener)
}
Error:
doExecute' overrides nothing.
Analysis:
- It allows to override the doExecute method only if the request parameter remains of type StopIndexReplicationRequest. But with the change in the type to ActionRequest, it fails to override the method.
- TransportStopIndexReplicationAction extends TransportClusterManagerNodeAction which is defined as follows:
public abstract class TransportClusterManagerNodeAction <Request extends ClusterManagerNodeRequest<Request>, Response extends ActionResponse> extends HandledTransportAction<Request, Response>
That means only a class X that meets this condition can be used for request :
**X extends ClusterManagerNodeRequest <X> **
So, as the classes like ActionRequest, ClusterManagerNodeRequest etc do not meet the generics constraint defined for TransportClusterManagerNodeAction, the overriding fails.
Ask:
Current design of TransportClusterManagerNodeAction is a major limitation for this feature as we want to be able to cast the request to type ActionRequest.
Request help on this issue from opensearch experts.