-
Notifications
You must be signed in to change notification settings - Fork 25.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REST high-level client: add support for split and shrink index API #28425
Changes from all commits
a000fa1
48108e0
4eba77a
bc2b010
2e3ba2f
0a1fb6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ | |
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; | ||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; | ||
import org.elasticsearch.action.admin.indices.open.OpenIndexRequest; | ||
import org.elasticsearch.action.admin.indices.shrink.ResizeRequest; | ||
import org.elasticsearch.action.admin.indices.shrink.ResizeType; | ||
import org.elasticsearch.action.bulk.BulkRequest; | ||
import org.elasticsearch.action.delete.DeleteRequest; | ||
import org.elasticsearch.action.get.GetRequest; | ||
|
@@ -182,12 +184,12 @@ static Request createIndex(CreateIndexRequest createIndexRequest) throws IOExcep | |
HttpEntity entity = createEntity(createIndexRequest, REQUEST_BODY_CONTENT_TYPE); | ||
return new Request(HttpPut.METHOD_NAME, endpoint, parameters.getParams(), entity); | ||
} | ||
|
||
static Request updateAliases(IndicesAliasesRequest indicesAliasesRequest) throws IOException { | ||
Params parameters = Params.builder(); | ||
parameters.withTimeout(indicesAliasesRequest.timeout()); | ||
parameters.withMasterTimeout(indicesAliasesRequest.masterNodeTimeout()); | ||
|
||
HttpEntity entity = createEntity(indicesAliasesRequest, REQUEST_BODY_CONTENT_TYPE); | ||
return new Request(HttpPost.METHOD_NAME, "/_aliases", parameters.getParams(), entity); | ||
} | ||
|
@@ -496,7 +498,31 @@ static Request rankEval(RankEvalRequest rankEvalRequest) throws IOException { | |
HttpEntity entity = null; | ||
entity = createEntity(rankEvalRequest.getRankEvalSpec(), REQUEST_BODY_CONTENT_TYPE); | ||
return new Request(HttpGet.METHOD_NAME, endpoint, Collections.emptyMap(), entity); | ||
} | ||
|
||
static Request split(ResizeRequest resizeRequest) throws IOException { | ||
if (resizeRequest.getResizeType() != ResizeType.SPLIT) { | ||
throw new IllegalArgumentException("Wrong resize type [" + resizeRequest.getResizeType() + "] for indices split request"); | ||
} | ||
return resize(resizeRequest); | ||
} | ||
|
||
static Request shrink(ResizeRequest resizeRequest) throws IOException { | ||
if (resizeRequest.getResizeType() != ResizeType.SHRINK) { | ||
throw new IllegalArgumentException("Wrong resize type [" + resizeRequest.getResizeType() + "] for indices shrink request"); | ||
} | ||
return resize(resizeRequest); | ||
} | ||
|
||
private static Request resize(ResizeRequest resizeRequest) throws IOException { | ||
Params params = Params.builder(); | ||
params.withTimeout(resizeRequest.timeout()); | ||
params.withMasterTimeout(resizeRequest.masterNodeTimeout()); | ||
params.withWaitForActiveShards(resizeRequest.getTargetIndexRequest().waitForActiveShards()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we check that the target index is not null at this stage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we already check this in the validate method, which the high level client calls internally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I know but I was thinking we could be more defensive. On the other side there's no reason this method would be reused somewhere else so let's keep it like this. |
||
String endpoint = buildEndpoint(resizeRequest.getSourceIndex(), "_" + resizeRequest.getResizeType().name().toLowerCase(Locale.ROOT), | ||
resizeRequest.getTargetIndexRequest().index()); | ||
HttpEntity entity = createEntity(resizeRequest, REQUEST_BODY_CONTENT_TYPE); | ||
return new Request(HttpPut.METHOD_NAME, endpoint, params.getParams(), entity); | ||
} | ||
|
||
private static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType) throws IOException { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR but we might want to rename
restHighLevelClient
toclient
here