Skip to content
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

[Backport 2.10] Remove _primary preference from get/mget requests #393

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void deleteDatasource(final Datasource datasource) {
* @throws IOException exception
*/
public Datasource getDatasource(final String name) throws IOException {
GetRequest request = new GetRequest(DatasourceExtension.JOB_INDEX_NAME, name).preference(Preference.PRIMARY.type());
GetRequest request = new GetRequest(DatasourceExtension.JOB_INDEX_NAME, name);
GetResponse response;
try {
response = StashedThreadContext.run(client, () -> client.get(request).actionGet(clusterSettings.get(Ip2GeoSettings.TIMEOUT)));
Expand All @@ -244,7 +244,7 @@ public Datasource getDatasource(final String name) throws IOException {
* @param actionListener the action listener
*/
public void getDatasource(final String name, final ActionListener<Datasource> actionListener) {
GetRequest request = new GetRequest(DatasourceExtension.JOB_INDEX_NAME, name).preference(Preference.PRIMARY.type());
GetRequest request = new GetRequest(DatasourceExtension.JOB_INDEX_NAME, name);
StashedThreadContext.run(client, () -> client.get(request, new ActionListener<>() {
@Override
public void onResponse(final GetResponse response) {
Expand Down Expand Up @@ -282,7 +282,6 @@ public void getDatasources(final String[] names, final ActionListener<List<Datas
client,
() -> client.prepareMultiGet()
.add(DatasourceExtension.JOB_INDEX_NAME, names)
.setPreference(Preference.PRIMARY.type())
.execute(createGetDataSourceQueryActionLister(MultiGetResponse.class, actionListener))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ private Datasource setupClientForGetRequest(final boolean isExist, final Runtime
GetRequest request = (GetRequest) actionRequest;
assertEquals(datasource.getName(), request.id());
assertEquals(DatasourceExtension.JOB_INDEX_NAME, request.index());
assertEquals(Preference.PRIMARY.type(), request.preference());
GetResponse response = getMockedGetResponse(isExist ? datasource : null);
if (exception != null) {
throw exception;
Expand Down Expand Up @@ -264,7 +263,6 @@ public void testGetDatasources_whenValidInput_thenSucceed() {
assertTrue(actionRequest instanceof MultiGetRequest);
MultiGetRequest request = (MultiGetRequest) actionRequest;
assertEquals(2, request.getItems().size());
assertEquals(Preference.PRIMARY.type(), request.preference());
for (MultiGetRequest.Item item : request.getItems()) {
assertEquals(DatasourceExtension.JOB_INDEX_NAME, item.index());
assertTrue(datasources.stream().filter(datasource -> datasource.getName().equals(item.id())).findAny().isPresent());
Expand Down