Skip to content

Commit f1bdf01

Browse files
authored
Replace TransportResponse.Empty with ActionResponse.Empty (elastic#126432)
No need to distinguish these things any more, we can just use `ActionResponse.Empty` everywhere. Backport of elastic#126400 to `8.x`
1 parent 52b07ab commit f1bdf01

File tree

31 files changed

+143
-157
lines changed

31 files changed

+143
-157
lines changed

server/src/internalClusterTest/java/org/elasticsearch/common/network/ThreadWatchdogIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.apache.logging.log4j.Level;
1313
import org.elasticsearch.action.ActionListenerResponseHandler;
14+
import org.elasticsearch.action.ActionResponse;
1415
import org.elasticsearch.action.support.SubscribableListener;
1516
import org.elasticsearch.client.Request;
1617
import org.elasticsearch.client.internal.node.NodeClient;
@@ -137,7 +138,7 @@ public void testThreadWatchdogTransportLogging() {
137138
EmptyRequest::new,
138139
(request, channel, task) -> {
139140
blockAndWaitForWatchdogLogs();
140-
channel.sendResponse(TransportResponse.Empty.INSTANCE);
141+
channel.sendResponse(ActionResponse.Empty.INSTANCE);
141142
}
142143
);
143144

@@ -149,7 +150,7 @@ public void testThreadWatchdogTransportLogging() {
149150
new EmptyRequest(),
150151
new ActionListenerResponseHandler<TransportResponse>(
151152
l,
152-
in -> TransportResponse.Empty.INSTANCE,
153+
in -> ActionResponse.Empty.INSTANCE,
153154
EsExecutors.DIRECT_EXECUTOR_SERVICE
154155
)
155156
)

server/src/main/java/org/elasticsearch/action/search/SearchTransportService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.apache.logging.log4j.Logger;
1414
import org.elasticsearch.action.ActionListener;
1515
import org.elasticsearch.action.ActionListenerResponseHandler;
16+
import org.elasticsearch.action.ActionResponse;
1617
import org.elasticsearch.action.IndicesRequest;
1718
import org.elasticsearch.action.OriginalIndices;
1819
import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest;
@@ -159,7 +160,7 @@ public void sendClearAllScrollContexts(Transport.Connection connection, final Ac
159160
CLEAR_SCROLL_CONTEXTS_ACTION_NAME,
160161
new ClearScrollContextsRequest(),
161162
TransportRequestOptions.EMPTY,
162-
new ActionListenerResponseHandler<>(listener, in -> TransportResponse.Empty.INSTANCE, TransportResponseHandler.TRANSPORT_WORKER)
163+
new ActionListenerResponseHandler<>(listener, in -> ActionResponse.Empty.INSTANCE, TransportResponseHandler.TRANSPORT_WORKER)
163164
);
164165
}
165166

@@ -449,14 +450,14 @@ public static void registerRequestHandler(TransportService transportService, Sea
449450
ClearScrollContextsRequest::new,
450451
(request, channel, task) -> {
451452
searchService.freeAllScrollContexts();
452-
channel.sendResponse(TransportResponse.Empty.INSTANCE);
453+
channel.sendResponse(ActionResponse.Empty.INSTANCE);
453454
}
454455
);
455456
TransportActionProxy.registerProxyAction(
456457
transportService,
457458
CLEAR_SCROLL_CONTEXTS_ACTION_NAME,
458459
false,
459-
(in) -> TransportResponse.Empty.INSTANCE
460+
(in) -> ActionResponse.Empty.INSTANCE
460461
);
461462

462463
transportService.registerRequestHandler(

server/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.TransportVersion;
1717
import org.elasticsearch.TransportVersions;
1818
import org.elasticsearch.action.ActionListener;
19+
import org.elasticsearch.action.ActionResponse;
1920
import org.elasticsearch.action.ResultDeduplicator;
2021
import org.elasticsearch.action.support.ChannelActionListener;
2122
import org.elasticsearch.cluster.ClusterState;
@@ -55,7 +56,6 @@
5556
import org.elasticsearch.transport.TransportChannel;
5657
import org.elasticsearch.transport.TransportRequest;
5758
import org.elasticsearch.transport.TransportRequestHandler;
58-
import org.elasticsearch.transport.TransportResponse;
5959
import org.elasticsearch.transport.TransportResponseHandler;
6060
import org.elasticsearch.transport.TransportService;
6161

@@ -290,7 +290,7 @@ public void messageReceived(FailedShardEntry request, TransportChannel channel,
290290
logger.debug(() -> format("%s received shard failed for [%s]", request.getShardId(), request), request.failure);
291291
taskQueue.submitTask(
292292
TASK_SOURCE,
293-
new FailedShardUpdateTask(request, new ChannelActionListener<>(channel).map(ignored -> TransportResponse.Empty.INSTANCE)),
293+
new FailedShardUpdateTask(request, new ChannelActionListener<>(channel).map(ignored -> ActionResponse.Empty.INSTANCE)),
294294
null
295295
);
296296
}
@@ -591,7 +591,7 @@ public void messageReceived(StartedShardEntry request, TransportChannel channel,
591591
logger.debug("{} received shard started for [{}]", request.shardId, request);
592592
taskQueue.submitTask(
593593
"shard-started " + request,
594-
new StartedShardUpdateTask(request, new ChannelActionListener<>(channel).map(ignored -> TransportResponse.Empty.INSTANCE)),
594+
new StartedShardUpdateTask(request, new ChannelActionListener<>(channel).map(ignored -> ActionResponse.Empty.INSTANCE)),
595595
null
596596
);
597597
}

server/src/main/java/org/elasticsearch/cluster/coordination/Coordinator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.apache.logging.log4j.Logger;
1414
import org.apache.lucene.util.SetOnce;
1515
import org.elasticsearch.action.ActionListener;
16+
import org.elasticsearch.action.ActionResponse.Empty;
1617
import org.elasticsearch.action.support.ChannelActionListener;
1718
import org.elasticsearch.action.support.RefCountingListener;
1819
import org.elasticsearch.action.support.SubscribableListener;
@@ -75,7 +76,6 @@
7576
import org.elasticsearch.threadpool.ThreadPool.Names;
7677
import org.elasticsearch.transport.NodeDisconnectedException;
7778
import org.elasticsearch.transport.TransportRequestOptions;
78-
import org.elasticsearch.transport.TransportResponse.Empty;
7979
import org.elasticsearch.transport.TransportResponseHandler;
8080
import org.elasticsearch.transport.TransportService;
8181
import org.elasticsearch.transport.Transports;

server/src/main/java/org/elasticsearch/cluster/coordination/FollowersChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.apache.logging.log4j.LogManager;
1313
import org.apache.logging.log4j.Logger;
1414
import org.elasticsearch.action.ActionListener;
15+
import org.elasticsearch.action.ActionResponse.Empty;
1516
import org.elasticsearch.action.ActionRunnable;
1617
import org.elasticsearch.action.support.ChannelActionListener;
1718
import org.elasticsearch.cluster.coordination.Coordinator.Mode;
@@ -37,7 +38,6 @@
3738
import org.elasticsearch.transport.TransportRequest;
3839
import org.elasticsearch.transport.TransportRequestOptions;
3940
import org.elasticsearch.transport.TransportRequestOptions.Type;
40-
import org.elasticsearch.transport.TransportResponse.Empty;
4141
import org.elasticsearch.transport.TransportResponseHandler;
4242
import org.elasticsearch.transport.TransportService;
4343

server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.apache.logging.log4j.Logger;
1414
import org.elasticsearch.ElasticsearchException;
1515
import org.elasticsearch.action.ActionListener;
16+
import org.elasticsearch.action.ActionResponse.Empty;
1617
import org.elasticsearch.action.support.ChannelActionListener;
1718
import org.elasticsearch.cluster.ClusterState;
1819
import org.elasticsearch.cluster.coordination.Coordinator.Mode;
@@ -45,7 +46,6 @@
4546
import org.elasticsearch.transport.TransportException;
4647
import org.elasticsearch.transport.TransportRequest;
4748
import org.elasticsearch.transport.TransportRequestOptions;
48-
import org.elasticsearch.transport.TransportResponse.Empty;
4949
import org.elasticsearch.transport.TransportResponseHandler;
5050
import org.elasticsearch.transport.TransportService;
5151

server/src/main/java/org/elasticsearch/cluster/coordination/JoinValidationService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.TransportVersion;
1616
import org.elasticsearch.TransportVersions;
1717
import org.elasticsearch.action.ActionListener;
18+
import org.elasticsearch.action.ActionResponse;
1819
import org.elasticsearch.action.ActionRunnable;
1920
import org.elasticsearch.cluster.ClusterState;
2021
import org.elasticsearch.cluster.metadata.Metadata;
@@ -38,7 +39,6 @@
3839
import org.elasticsearch.transport.NodeNotConnectedException;
3940
import org.elasticsearch.transport.Transport;
4041
import org.elasticsearch.transport.TransportRequestOptions;
41-
import org.elasticsearch.transport.TransportResponse;
4242
import org.elasticsearch.transport.TransportResponseHandler;
4343
import org.elasticsearch.transport.TransportService;
4444

@@ -142,7 +142,7 @@ public JoinValidationService(
142142
);
143143
}
144144
joinValidators.forEach(joinValidator -> joinValidator.accept(transportService.getLocalNode(), remoteState));
145-
channel.sendResponse(TransportResponse.Empty.INSTANCE);
145+
channel.sendResponse(ActionResponse.Empty.INSTANCE);
146146
}
147147
);
148148
}
@@ -369,7 +369,7 @@ protected void doRun() {
369369
REQUEST_OPTIONS,
370370
new CleanableResponseHandler<>(
371371
listener.map(ignored -> null),
372-
in -> TransportResponse.Empty.INSTANCE,
372+
in -> ActionResponse.Empty.INSTANCE,
373373
responseExecutor,
374374
bytes::decRef
375375
)

server/src/main/java/org/elasticsearch/cluster/coordination/LeaderChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.apache.logging.log4j.LogManager;
1313
import org.apache.logging.log4j.Logger;
1414
import org.elasticsearch.ExceptionsHelper;
15+
import org.elasticsearch.action.ActionResponse.Empty;
1516
import org.elasticsearch.cluster.node.DiscoveryNode;
1617
import org.elasticsearch.cluster.node.DiscoveryNodes;
1718
import org.elasticsearch.common.io.stream.StreamInput;
@@ -36,7 +37,6 @@
3637
import org.elasticsearch.transport.TransportRequest;
3738
import org.elasticsearch.transport.TransportRequestOptions;
3839
import org.elasticsearch.transport.TransportRequestOptions.Type;
39-
import org.elasticsearch.transport.TransportResponse.Empty;
4040
import org.elasticsearch.transport.TransportResponseHandler;
4141
import org.elasticsearch.transport.TransportService;
4242

server/src/main/java/org/elasticsearch/indices/recovery/PeerRecoveryTargetService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ public void messageReceived(final RecoveryHandoffPrimaryContextRequest request,
573573
.handoffPrimaryContext(
574574
request.primaryContext(),
575575
ActionListener.runBefore(
576-
new ChannelActionListener<>(channel).map(v -> TransportResponse.Empty.INSTANCE),
576+
new ChannelActionListener<>(channel).map(v -> ActionResponse.Empty.INSTANCE),
577577
recoveryRef::close
578578
)
579579
);
@@ -694,7 +694,7 @@ public final void messageReceived(final T request, TransportChannel channel, Tas
694694
}
695695

696696
protected CheckedFunction<Void, TransportResponse, Exception> responseMapping(RecoveryTarget recoveryTarget) {
697-
return v -> TransportResponse.Empty.INSTANCE;
697+
return v -> ActionResponse.Empty.INSTANCE;
698698
}
699699

700700
protected abstract void handleRequest(T request, RecoveryTarget target, ActionListener<Void> listener) throws IOException;

server/src/main/java/org/elasticsearch/indices/recovery/RemoteRecoveryTargetHandler.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.ExceptionsHelper;
1818
import org.elasticsearch.action.ActionListener;
1919
import org.elasticsearch.action.ActionListenerResponseHandler;
20+
import org.elasticsearch.action.ActionResponse;
2021
import org.elasticsearch.action.ActionRunnable;
2122
import org.elasticsearch.action.support.RetryableAction;
2223
import org.elasticsearch.cluster.node.DiscoveryNode;
@@ -116,7 +117,7 @@ public void prepareForTranslogOperations(int totalTranslogOps, ActionListener<Vo
116117
shardId,
117118
totalTranslogOps
118119
);
119-
final Writeable.Reader<TransportResponse.Empty> reader = in -> TransportResponse.Empty.INSTANCE;
120+
final Writeable.Reader<ActionResponse.Empty> reader = in -> ActionResponse.Empty.INSTANCE;
120121
executeRetryableAction(action, request, standardTimeoutRequestOptions, listener.map(r -> null), reader);
121122
}
122123

@@ -131,7 +132,7 @@ public void finalizeRecovery(final long globalCheckpoint, final long trimAboveSe
131132
globalCheckpoint,
132133
trimAboveSeqNo
133134
);
134-
final Writeable.Reader<TransportResponse.Empty> reader = in -> TransportResponse.Empty.INSTANCE;
135+
final Writeable.Reader<ActionResponse.Empty> reader = in -> ActionResponse.Empty.INSTANCE;
135136
executeRetryableAction(
136137
action,
137138
request,
@@ -148,7 +149,7 @@ public void handoffPrimaryContext(final ReplicationTracker.PrimaryContext primar
148149
PeerRecoveryTargetService.Actions.HANDOFF_PRIMARY_CONTEXT,
149150
new RecoveryHandoffPrimaryContextRequest(recoveryId, shardId, primaryContext),
150151
standardTimeoutRequestOptions,
151-
new ActionListenerResponseHandler<>(listener.map(r -> null), in -> TransportResponse.Empty.INSTANCE, threadPool.generic())
152+
new ActionListenerResponseHandler<>(listener.map(r -> null), in -> ActionResponse.Empty.INSTANCE, threadPool.generic())
152153
);
153154
}
154155

@@ -200,7 +201,7 @@ public void receiveFileInfo(
200201
phase1ExistingFileSizes,
201202
totalTranslogOps
202203
);
203-
final Writeable.Reader<TransportResponse.Empty> reader = in -> TransportResponse.Empty.INSTANCE;
204+
final Writeable.Reader<ActionResponse.Empty> reader = in -> ActionResponse.Empty.INSTANCE;
204205
executeRetryableAction(action, request, standardTimeoutRequestOptions, listener.map(r -> null), reader);
205206
}
206207

@@ -221,8 +222,8 @@ public void cleanFiles(
221222
totalTranslogOps,
222223
globalCheckpoint
223224
);
224-
final Writeable.Reader<TransportResponse.Empty> reader = in -> TransportResponse.Empty.INSTANCE;
225-
final ActionListener<TransportResponse.Empty> responseListener = listener.map(r -> null);
225+
final Writeable.Reader<ActionResponse.Empty> reader = in -> ActionResponse.Empty.INSTANCE;
226+
final ActionListener<ActionResponse.Empty> responseListener = listener.map(r -> null);
226227
executeRetryableAction(action, request, TransportRequestOptions.EMPTY, responseListener, reader);
227228
}
228229

@@ -243,8 +244,8 @@ public void restoreFileFromSnapshot(
243244
indexId,
244245
snapshotFile
245246
);
246-
final Writeable.Reader<TransportResponse.Empty> reader = in -> TransportResponse.Empty.INSTANCE;
247-
final ActionListener<TransportResponse.Empty> responseListener = listener.map(r -> null);
247+
final Writeable.Reader<ActionResponse.Empty> reader = in -> ActionResponse.Empty.INSTANCE;
248+
final ActionListener<ActionResponse.Empty> responseListener = listener.map(r -> null);
248249
executeRetryableAction(action, request, TransportRequestOptions.EMPTY, responseListener, reader);
249250
}
250251

@@ -303,8 +304,8 @@ public void writeFileChunk(
303304
threadPool.generic()
304305
.execute(
305306
ActionRunnable.wrap(
306-
ActionListener.<TransportResponse.Empty>runBefore(listener.map(r -> null), request::decRef),
307-
l -> executeRetryableAction(action, request, fileChunkRequestOptions, l, in -> TransportResponse.Empty.INSTANCE)
307+
ActionListener.<ActionResponse.Empty>runBefore(listener.map(r -> null), request::decRef),
308+
l -> executeRetryableAction(action, request, fileChunkRequestOptions, l, in -> ActionResponse.Empty.INSTANCE)
308309
)
309310
);
310311
}

0 commit comments

Comments
 (0)