Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Walter Knize <[email protected]>
  • Loading branch information
nknize committed Oct 6, 2022
1 parent f351e49 commit 96a4f43
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.opensearch.common.util.concurrent.AbstractRunnable;
import org.opensearch.common.xcontent.support.XContentMapValues;
import org.opensearch.index.IndexSettings;
import org.opensearch.index.mapper.MapperService;
import org.opensearch.rest.RestStatus;
import org.opensearch.test.rest.yaml.ObjectPath;
import org.hamcrest.Matcher;
Expand Down Expand Up @@ -235,11 +236,15 @@ private void assertCount(final String index, final String preference, final int
assertThat("preference [" + preference + "]", actualDocs, equalTo(expectedCount));
}

private String getNodeId() throws IOException {
private String getNodeId(Predicate<Version> versionPredicate) throws IOException {
Response response = client().performRequest(new Request("GET", "_nodes"));
ObjectPath objectPath = ObjectPath.createFromResponse(response);
Map<String, Object> nodesAsMap = objectPath.evaluate("nodes");
for (String id : nodesAsMap.keySet()) {
Version version = Version.fromString(objectPath.evaluate("nodes." + id + ".version"));
if (versionPredicate.test(version)) {
return id;
}
return id;
}
return null;
Expand Down Expand Up @@ -268,8 +273,8 @@ public void testRelocationWithConcurrentIndexing() throws Exception {
break;
case MIXED:
// todo: verify this test can be removed in 3.0.0
final String newNode = getNodeId();
final String oldNode = getNodeId();
final String newNode = getNodeId(v -> v.equals(Version.CURRENT));
final String oldNode = getNodeId(v -> v.before(Version.CURRENT));
// remove the replica and guaranteed the primary is placed on the old node
updateIndexSettings(index, Settings.builder()
.put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0)
Expand Down Expand Up @@ -346,11 +351,7 @@ public void testRecovery() throws Exception {
if (randomBoolean()) {
indexDocs(index, i, 1); // update
} else if (randomBoolean()) {
if (getNodeId() == null) {
client().performRequest(new Request("DELETE", index + "/test/" + i));
} else {
client().performRequest(new Request("DELETE", index + "/_doc/" + i));
}
client().performRequest(new Request("DELETE", index + "/" + MapperService.SINGLE_MAPPING_NAME + "/" + i));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public void testSystemIndicesUpgrades() throws Exception {
// make sure .tasks index exists
Request getTasksIndex = new Request("GET", "/.tasks");
getTasksIndex.addParameter("allow_no_indices", "false");
getTasksIndex.addParameter("include_type_name", "false");
getTasksIndex.setOptions(expectVersionSpecificWarnings(v -> {
v.current(systemIndexWarning);
v.compatible(systemIndexWarning);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import org.opensearch.index.mapper.Mapper;
import org.opensearch.index.mapper.MetadataFieldMapper;
import org.opensearch.index.mapper.NestedPathFieldMapper;
import org.opensearch.plugins.MapperPlugin;

import java.util.Collections;
Expand All @@ -52,7 +51,6 @@ public final class MapperRegistry {

private final Map<String, Mapper.TypeParser> mapperParsers;
private final Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers;
private final Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsersPre20;
private final Function<String, Predicate<String>> fieldFilter;

public MapperRegistry(
Expand All @@ -62,9 +60,6 @@ public MapperRegistry(
) {
this.mapperParsers = Collections.unmodifiableMap(new LinkedHashMap<>(mapperParsers));
this.metadataMapperParsers = Collections.unmodifiableMap(new LinkedHashMap<>(metadataMapperParsers));
Map<String, MetadataFieldMapper.TypeParser> tempPre20 = new LinkedHashMap<>(metadataMapperParsers);
tempPre20.remove(NestedPathFieldMapper.NAME);
this.metadataMapperParsersPre20 = Collections.unmodifiableMap(tempPre20);
this.fieldFilter = fieldFilter;
}

Expand Down

0 comments on commit 96a4f43

Please sign in to comment.