|
13 | 13 | import org.apache.logging.log4j.Logger; |
14 | 14 | import org.elasticsearch.action.ActionListener; |
15 | 15 | import org.elasticsearch.action.ActionListenerResponseHandler; |
| 16 | +import org.elasticsearch.action.IndicesRequest; |
16 | 17 | import org.elasticsearch.action.OriginalIndices; |
17 | 18 | import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; |
18 | 19 | import org.elasticsearch.action.admin.cluster.node.tasks.get.TransportGetTaskAction; |
19 | 20 | import org.elasticsearch.action.support.ChannelActionListener; |
| 21 | +import org.elasticsearch.action.support.IndicesOptions; |
20 | 22 | import org.elasticsearch.client.internal.OriginSettingClient; |
21 | 23 | import org.elasticsearch.client.internal.node.NodeClient; |
22 | 24 | import org.elasticsearch.cluster.node.DiscoveryNode; |
@@ -350,6 +352,38 @@ private static class ClearScrollContextsRequest extends TransportRequest { |
350 | 352 | } |
351 | 353 | } |
352 | 354 |
|
| 355 | + static class SearchFreeContextRequest extends ScrollFreeContextRequest implements IndicesRequest { |
| 356 | + private final OriginalIndices originalIndices; |
| 357 | + |
| 358 | + SearchFreeContextRequest(StreamInput in) throws IOException { |
| 359 | + super(in); |
| 360 | + originalIndices = OriginalIndices.readOriginalIndices(in); |
| 361 | + } |
| 362 | + |
| 363 | + @Override |
| 364 | + public void writeTo(StreamOutput out) throws IOException { |
| 365 | + super.writeTo(out); |
| 366 | + OriginalIndices.writeOriginalIndices(originalIndices, out); |
| 367 | + } |
| 368 | + |
| 369 | + @Override |
| 370 | + public String[] indices() { |
| 371 | + if (originalIndices == null) { |
| 372 | + return null; |
| 373 | + } |
| 374 | + return originalIndices.indices(); |
| 375 | + } |
| 376 | + |
| 377 | + @Override |
| 378 | + public IndicesOptions indicesOptions() { |
| 379 | + if (originalIndices == null) { |
| 380 | + return null; |
| 381 | + } |
| 382 | + return originalIndices.indicesOptions(); |
| 383 | + } |
| 384 | + |
| 385 | + } |
| 386 | + |
353 | 387 | public static class SearchFreeContextResponse extends TransportResponse { |
354 | 388 |
|
355 | 389 | private static final SearchFreeContextResponse FREED = new SearchFreeContextResponse(true); |
@@ -400,12 +434,13 @@ public static void registerRequestHandler(TransportService transportService, Sea |
400 | 434 | ); |
401 | 435 |
|
402 | 436 | // TODO: remove this handler once the lowest compatible version stops using it |
403 | | - transportService.registerRequestHandler(FREE_CONTEXT_ACTION_NAME, freeContextExecutor, in -> { |
404 | | - var res = new ScrollFreeContextRequest(in); |
405 | | - // this handler exists for BwC purposes only, we don't need the original indices to free the context |
406 | | - OriginalIndices.readOriginalIndices(in); |
407 | | - return res; |
408 | | - }, freeContextHandler); |
| 437 | + // this handler exists for BwC purposes only, we don't need the original indices to free the context |
| 438 | + transportService.registerRequestHandler( |
| 439 | + FREE_CONTEXT_ACTION_NAME, |
| 440 | + freeContextExecutor, |
| 441 | + SearchFreeContextRequest::new, |
| 442 | + freeContextHandler |
| 443 | + ); |
409 | 444 | TransportActionProxy.registerProxyAction(transportService, FREE_CONTEXT_ACTION_NAME, false, SearchFreeContextResponse::readFrom); |
410 | 445 |
|
411 | 446 | transportService.registerRequestHandler( |
|
0 commit comments