Skip to content

Commit 457a66e

Browse files
committed
Rename request variables in shrink/split handlers (#30207)
This is a code-tidying PR, a little side adventure while working on another change. Previously only shrink request existed but when the ability to split indices was added, shrink and split were done together under a single request object: the resize request object. However, the code inherited the legacy name in the naming of some variables. This commit cleans this up.
1 parent 68d86f7 commit 457a66e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestShrinkIndexAction.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public String getName() {
4545

4646
@Override
4747
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
48-
ResizeRequest shrinkIndexRequest = new ResizeRequest(request.param("target"), request.param("index"));
49-
shrinkIndexRequest.setResizeType(ResizeType.SHRINK);
50-
request.applyContentParser(shrinkIndexRequest::fromXContent);
51-
shrinkIndexRequest.timeout(request.paramAsTime("timeout", shrinkIndexRequest.timeout()));
52-
shrinkIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", shrinkIndexRequest.masterNodeTimeout()));
53-
shrinkIndexRequest.setWaitForActiveShards(ActiveShardCount.parseString(request.param("wait_for_active_shards")));
54-
return channel -> client.admin().indices().resizeIndex(shrinkIndexRequest, new RestToXContentListener<>(channel));
48+
final ResizeRequest resizeRequest = new ResizeRequest(request.param("target"), request.param("index"));
49+
resizeRequest.setResizeType(ResizeType.SHRINK);
50+
request.applyContentParser(resizeRequest::fromXContent);
51+
resizeRequest.timeout(request.paramAsTime("timeout", resizeRequest.timeout()));
52+
resizeRequest.masterNodeTimeout(request.paramAsTime("master_timeout", resizeRequest.masterNodeTimeout()));
53+
resizeRequest.setWaitForActiveShards(ActiveShardCount.parseString(request.param("wait_for_active_shards")));
54+
return channel -> client.admin().indices().resizeIndex(resizeRequest, new RestToXContentListener<>(channel));
5555
}
5656
}

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestSplitIndexAction.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public String getName() {
4545

4646
@Override
4747
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
48-
ResizeRequest shrinkIndexRequest = new ResizeRequest(request.param("target"), request.param("index"));
49-
shrinkIndexRequest.setResizeType(ResizeType.SPLIT);
50-
request.applyContentParser(shrinkIndexRequest::fromXContent);
51-
shrinkIndexRequest.timeout(request.paramAsTime("timeout", shrinkIndexRequest.timeout()));
52-
shrinkIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", shrinkIndexRequest.masterNodeTimeout()));
53-
shrinkIndexRequest.setWaitForActiveShards(ActiveShardCount.parseString(request.param("wait_for_active_shards")));
54-
return channel -> client.admin().indices().resizeIndex(shrinkIndexRequest, new RestToXContentListener<>(channel));
48+
final ResizeRequest resizeRequest = new ResizeRequest(request.param("target"), request.param("index"));
49+
resizeRequest.setResizeType(ResizeType.SPLIT);
50+
request.applyContentParser(resizeRequest::fromXContent);
51+
resizeRequest.timeout(request.paramAsTime("timeout", resizeRequest.timeout()));
52+
resizeRequest.masterNodeTimeout(request.paramAsTime("master_timeout", resizeRequest.masterNodeTimeout()));
53+
resizeRequest.setWaitForActiveShards(ActiveShardCount.parseString(request.param("wait_for_active_shards")));
54+
return channel -> client.admin().indices().resizeIndex(resizeRequest, new RestToXContentListener<>(channel));
5555
}
5656
}

0 commit comments

Comments
 (0)