Skip to content

Commit 10c653a

Browse files
committed
Change CCR API request classes to use Writeable serialization instead of Streamable (elastic#34911)
Only the follow stats request couldn't be changed to use Writeable serialization, because that requires changes in `TransportTasksAction` and `BaseTasksRequest` base classes.
1 parent b3de1b3 commit 10c653a

29 files changed

+128
-79
lines changed

server/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public abstract class AcknowledgedRequest<Request extends MasterNodeRequest<Requ
4141
protected AcknowledgedRequest() {
4242
}
4343

44+
protected AcknowledgedRequest(StreamInput in) throws IOException {
45+
super(in);
46+
timeout = in.readTimeValue();
47+
}
48+
4449
/**
4550
* Allows to set the timeout
4651
* @param timeout timeout as a string (e.g. 1s)

server/src/main/java/org/elasticsearch/action/support/master/MasterNodeReadRequest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ public abstract class MasterNodeReadRequest<Request extends MasterNodeReadReques
3131

3232
protected boolean local = false;
3333

34+
protected MasterNodeReadRequest() {
35+
}
36+
37+
protected MasterNodeReadRequest(StreamInput in) throws IOException {
38+
super(in);
39+
local = in.readBoolean();
40+
}
41+
3442
@SuppressWarnings("unchecked")
3543
public final Request local(boolean local) {
3644
this.local = local;

server/src/main/java/org/elasticsearch/action/support/master/MasterNodeRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public abstract class MasterNodeRequest<Request extends MasterNodeRequest<Reques
3838
protected MasterNodeRequest() {
3939
}
4040

41+
protected MasterNodeRequest(StreamInput in) throws IOException {
42+
super(in);
43+
masterNodeTimeout = in.readTimeValue();
44+
}
45+
4146
/**
4247
* A timeout value in case the master has not been discovered yet or disconnected.
4348
*/

server/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeAction.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.elasticsearch.cluster.node.DiscoveryNode;
3636
import org.elasticsearch.cluster.node.DiscoveryNodes;
3737
import org.elasticsearch.cluster.service.ClusterService;
38+
import org.elasticsearch.common.io.stream.Writeable;
3839
import org.elasticsearch.common.settings.Settings;
3940
import org.elasticsearch.common.unit.TimeValue;
4041
import org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException;
@@ -66,6 +67,12 @@ protected TransportMasterNodeAction(Settings settings, String actionName, Transp
6667
this(settings, actionName, true, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, request);
6768
}
6869

70+
protected TransportMasterNodeAction(Settings settings, String actionName, TransportService transportService,
71+
ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
72+
Writeable.Reader<Request> request, IndexNameExpressionResolver indexNameExpressionResolver) {
73+
this(settings, actionName, true, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver);
74+
}
75+
6976
protected TransportMasterNodeAction(Settings settings, String actionName, boolean canTripCircuitBreaker,
7077
TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
7178
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
@@ -77,6 +84,17 @@ protected TransportMasterNodeAction(Settings settings, String actionName, boolea
7784
this.executor = executor();
7885
}
7986

87+
protected TransportMasterNodeAction(Settings settings, String actionName, boolean canTripCircuitBreaker,
88+
TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
89+
ActionFilters actionFilters, Writeable.Reader<Request> request,
90+
IndexNameExpressionResolver indexNameExpressionResolver) {
91+
super(settings, actionName, canTripCircuitBreaker, threadPool, transportService, actionFilters, request,
92+
indexNameExpressionResolver);
93+
this.transportService = transportService;
94+
this.clusterService = clusterService;
95+
this.executor = executor();
96+
}
97+
8098
protected abstract String executor();
8199

82100
protected abstract Response newResponse();

server/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeReadAction.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.action.support.ActionFilters;
2424
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
2525
import org.elasticsearch.cluster.service.ClusterService;
26+
import org.elasticsearch.common.io.stream.Writeable;
2627
import org.elasticsearch.common.settings.Setting;
2728
import org.elasticsearch.common.settings.Setting.Property;
2829
import org.elasticsearch.common.settings.Settings;
@@ -49,6 +50,13 @@ protected TransportMasterNodeReadAction(Settings settings, String actionName, Tr
4950
this(settings, actionName, true, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver,request);
5051
}
5152

53+
protected TransportMasterNodeReadAction(Settings settings, String actionName, TransportService transportService,
54+
ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
55+
Writeable.Reader<Request> request, IndexNameExpressionResolver indexNameExpressionResolver) {
56+
this(settings, actionName, true, transportService, clusterService, threadPool, actionFilters, request,
57+
indexNameExpressionResolver);
58+
}
59+
5260
protected TransportMasterNodeReadAction(Settings settings, String actionName, boolean checkSizeLimit, TransportService transportService,
5361
ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
5462
IndexNameExpressionResolver indexNameExpressionResolver, Supplier<Request> request) {
@@ -57,6 +65,14 @@ protected TransportMasterNodeReadAction(Settings settings, String actionName, bo
5765
this.forceLocal = FORCE_LOCAL_SETTING.get(settings);
5866
}
5967

68+
protected TransportMasterNodeReadAction(Settings settings, String actionName, boolean checkSizeLimit, TransportService transportService,
69+
ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
70+
Writeable.Reader<Request> request, IndexNameExpressionResolver indexNameExpressionResolver) {
71+
super(settings, actionName, checkSizeLimit, transportService, clusterService, threadPool, actionFilters, request,
72+
indexNameExpressionResolver);
73+
this.forceLocal = FORCE_LOCAL_SETTING.get(settings);
74+
}
75+
6076
@Override
6177
protected final boolean localExecute(Request request) {
6278
return forceLocal || request.local();

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportCcrStatsAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public TransportCcrStatsAction(
5555
clusterService,
5656
threadPool,
5757
actionFilters,
58-
indexNameExpressionResolver,
59-
CcrStatsAction.Request::new
58+
CcrStatsAction.Request::new,
59+
indexNameExpressionResolver
6060
);
6161
this.client = client;
6262
this.ccrLicenseChecker = Objects.requireNonNull(ccrLicenseChecker);

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportDeleteAutoFollowPatternAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public TransportDeleteAutoFollowPatternAction(Settings settings, TransportServic
3737
ThreadPool threadPool, ActionFilters actionFilters,
3838
IndexNameExpressionResolver indexNameExpressionResolver) {
3939
super(settings, DeleteAutoFollowPatternAction.NAME, transportService, clusterService, threadPool, actionFilters,
40-
indexNameExpressionResolver, DeleteAutoFollowPatternAction.Request::new);
40+
DeleteAutoFollowPatternAction.Request::new, indexNameExpressionResolver);
4141
}
4242

4343
@Override

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportGetAutoFollowPatternAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public TransportGetAutoFollowPatternAction(Settings settings,
3838
ActionFilters actionFilters,
3939
IndexNameExpressionResolver indexNameExpressionResolver) {
4040
super(settings, GetAutoFollowPatternAction.NAME, transportService, clusterService, threadPool, actionFilters,
41-
indexNameExpressionResolver, GetAutoFollowPatternAction.Request::new);
41+
GetAutoFollowPatternAction.Request::new, indexNameExpressionResolver);
4242
}
4343

4444
@Override

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPauseFollowAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public TransportPauseFollowAction(
4040
final ClusterService clusterService,
4141
final PersistentTasksService persistentTasksService) {
4242
super(settings, PauseFollowAction.NAME, transportService, clusterService, threadPool, actionFilters,
43-
indexNameExpressionResolver, PauseFollowAction.Request::new);
43+
PauseFollowAction.Request::new, indexNameExpressionResolver);
4444
this.persistentTasksService = persistentTasksService;
4545
}
4646

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutAutoFollowPatternAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public TransportPutAutoFollowPatternAction(
5353
final IndexNameExpressionResolver indexNameExpressionResolver,
5454
final CcrLicenseChecker ccrLicenseChecker) {
5555
super(settings, PutAutoFollowPatternAction.NAME, transportService, clusterService, threadPool, actionFilters,
56-
indexNameExpressionResolver, PutAutoFollowPatternAction.Request::new);
56+
PutAutoFollowPatternAction.Request::new, indexNameExpressionResolver);
5757
this.client = client;
5858
this.ccrLicenseChecker = Objects.requireNonNull(ccrLicenseChecker, "ccrLicenseChecker");
5959
}

0 commit comments

Comments
 (0)