-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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 synced flush API #29189
Changes from 4 commits
5922216
76bf15b
1a77355
b301ace
723300b
3d7f978
0bf9dcf
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 |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; | ||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; | ||
import org.elasticsearch.action.admin.indices.flush.FlushRequest; | ||
import org.elasticsearch.action.admin.indices.flush.SyncedFlushRequest; | ||
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest; | ||
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; | ||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; | ||
|
@@ -234,6 +235,15 @@ static Request flush(FlushRequest flushRequest) { | |
return new Request(HttpPost.METHOD_NAME, endpoint, parameters.getParams(), null); | ||
} | ||
|
||
static Request syncedFlush(SyncedFlushRequest syncedFlushRequest) { | ||
String[] indices = syncedFlushRequest.indices() == null ? Strings.EMPTY_ARRAY : syncedFlushRequest.indices(); | ||
String endpoint = endpoint(indices, "_flush", "synced"); | ||
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.
|
||
Params syncedFlushparameters = Params.builder(); | ||
// This request takes no other parameters other than the indices. | ||
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. I would remove this comment |
||
syncedFlushparameters.withIndicesOptions(syncedFlushRequest.indicesOptions()); | ||
return new Request(HttpPost.METHOD_NAME, endpoint, syncedFlushparameters.getParams(), null); | ||
} | ||
|
||
static Request forceMerge(ForceMergeRequest forceMergeRequest) { | ||
String[] indices = forceMergeRequest.indices() == null ? Strings.EMPTY_ARRAY : forceMergeRequest.indices(); | ||
String endpoint = endpoint(indices, "_forcemerge"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; | ||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; | ||
import org.elasticsearch.action.admin.indices.flush.FlushRequest; | ||
import org.elasticsearch.action.admin.indices.flush.SyncedFlushRequest; | ||
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest; | ||
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; | ||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; | ||
|
@@ -622,6 +623,31 @@ public void testFlush() { | |
assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME)); | ||
} | ||
|
||
public void testSyncedFlush() { | ||
String[] indices = randomBoolean() ? null : randomIndicesNames(0, 5); | ||
SyncedFlushRequest syncedFlushRequest; | ||
if (randomBoolean()) { | ||
syncedFlushRequest = new SyncedFlushRequest(indices); | ||
} else { | ||
syncedFlushRequest = new SyncedFlushRequest(); | ||
syncedFlushRequest.indices(indices); | ||
} | ||
Map<String, String> expectedParams = new HashMap<>(); | ||
setRandomIndicesOptions(syncedFlushRequest::indicesOptions, syncedFlushRequest::indicesOptions, expectedParams); | ||
|
||
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. can you remove one of these empty lines please? |
||
Request request = Request.syncedFlush(syncedFlushRequest); | ||
StringJoiner endpoint = new StringJoiner("/", "/", ""); | ||
if (indices != null && indices.length > 0) { | ||
endpoint.add(String.join(",", indices)); | ||
} | ||
endpoint.add("_flush"); | ||
endpoint.add("synced"); | ||
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. endpoint.add("_flush/synced") ? |
||
assertThat(request.getEndpoint(), equalTo(endpoint.toString())); | ||
assertThat(request.getParameters(), equalTo(expectedParams)); | ||
assertThat(request.getEntity(), nullValue()); | ||
assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME)); | ||
} | ||
|
||
public void testForceMerge() { | ||
String[] indices = randomBoolean() ? null : randomIndicesNames(0, 5); | ||
ForceMergeRequest forceMergeRequest; | ||
|
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.
as odd as this sounds, could you rename the methods to flushSynced as that's how this API is referred to in our SPEC ? request and response can and should stay the same.