diff --git a/CHANGELOG.md b/CHANGELOG.md index c60d79679a9b0..3f948e0f3d8d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,6 +119,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Remove LegacyESVersion.V_7_4_ and V_7_5_ Constants ([#4704](https://github.com/opensearch-project/OpenSearch/pull/4704)) - Remove Legacy Version support from Snapshot/Restore Service ([#4728](https://github.com/opensearch-project/OpenSearch/pull/4728)) - Remove deprecated serialization logic from pipeline aggs ([#4847](https://github.com/opensearch-project/OpenSearch/pull/4847)) +- Remove unused private methods ([#4926](https://github.com/opensearch-project/OpenSearch/pull/4926)) ### Fixed - `opensearch-service.bat start` and `opensearch-service.bat manager` failing to run ([#4289](https://github.com/opensearch-project/OpenSearch/pull/4289)) diff --git a/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java index 166d8e3269d70..62e743d513193 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java @@ -51,7 +51,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -220,14 +219,6 @@ private List getAvailableJavaVersions(JavaVersion minimumCompilerVersi return javaVersions; } - private static boolean isCurrentJavaHome(File javaHome) { - try { - return Files.isSameFile(javaHome.toPath(), Jvm.current().getJavaHome().toPath()); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - private static String getTestSeed() { String testSeedProperty = System.getProperty("tests.seed"); final String testSeed; diff --git a/buildSrc/src/test/java/org/opensearch/gradle/precommit/ForbiddenPatternsTaskTests.java b/buildSrc/src/test/java/org/opensearch/gradle/precommit/ForbiddenPatternsTaskTests.java index ea4db8954bca4..6ce2e70f68381 100644 --- a/buildSrc/src/test/java/org/opensearch/gradle/precommit/ForbiddenPatternsTaskTests.java +++ b/buildSrc/src/test/java/org/opensearch/gradle/precommit/ForbiddenPatternsTaskTests.java @@ -104,10 +104,6 @@ private ForbiddenPatternsTask createTask(Project project) { return project.getTasks().create("forbiddenPatterns", ForbiddenPatternsTask.class); } - private ForbiddenPatternsTask createTask(Project project, String taskName) { - return project.getTasks().create(taskName, ForbiddenPatternsTask.class); - } - private void writeSourceFile(Project project, String name, String... lines) throws IOException { File file = new File(project.getProjectDir(), name); file.getParentFile().mkdirs(); diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/antlr/Walker.java b/modules/lang-painless/src/main/java/org/opensearch/painless/antlr/Walker.java index 719a69a9977e7..c03b4199ce8d9 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/antlr/Walker.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/antlr/Walker.java @@ -248,10 +248,6 @@ private Location location(ParserRuleContext ctx) { return new Location(sourceName, ctx.getStart().getStartIndex()); } - private Location location(TerminalNode tn) { - return new Location(sourceName, tn.getSymbol().getStartIndex()); - } - @Override public ANode visitSource(SourceContext ctx) { List functions = new ArrayList<>(); diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java index 6239946852cf8..edd301603250a 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java @@ -152,25 +152,6 @@ private void randomRequest(AbstractBulkIndexByScrollRequest request) { request.setScript(random().nextBoolean() ? null : randomScript()); } - private void assertRequestEquals(Version version, ReindexRequest request, ReindexRequest tripped) { - assertRequestEquals((AbstractBulkIndexByScrollRequest) request, (AbstractBulkIndexByScrollRequest) tripped); - assertEquals(request.getDestination().version(), tripped.getDestination().version()); - assertEquals(request.getDestination().index(), tripped.getDestination().index()); - if (request.getRemoteInfo() == null) { - assertNull(tripped.getRemoteInfo()); - } else { - assertNotNull(tripped.getRemoteInfo()); - assertEquals(request.getRemoteInfo().getScheme(), tripped.getRemoteInfo().getScheme()); - assertEquals(request.getRemoteInfo().getHost(), tripped.getRemoteInfo().getHost()); - assertEquals(request.getRemoteInfo().getQuery(), tripped.getRemoteInfo().getQuery()); - assertEquals(request.getRemoteInfo().getUsername(), tripped.getRemoteInfo().getUsername()); - assertEquals(request.getRemoteInfo().getPassword(), tripped.getRemoteInfo().getPassword()); - assertEquals(request.getRemoteInfo().getHeaders(), tripped.getRemoteInfo().getHeaders()); - assertEquals(request.getRemoteInfo().getSocketTimeout(), tripped.getRemoteInfo().getSocketTimeout()); - assertEquals(request.getRemoteInfo().getConnectTimeout(), tripped.getRemoteInfo().getConnectTimeout()); - } - } - private void assertRequestEquals(AbstractBulkIndexByScrollRequest request, AbstractBulkIndexByScrollRequest tripped) { assertRequestEquals((AbstractBulkByScrollRequest) request, (AbstractBulkByScrollRequest) tripped); assertEquals(request.getScript(), tripped.getScript()); diff --git a/plugins/repository-azure/src/test/java/org/opensearch/repositories/azure/AzureBlobContainerRetriesTests.java b/plugins/repository-azure/src/test/java/org/opensearch/repositories/azure/AzureBlobContainerRetriesTests.java index 1478f48f16650..9ebebc5b25a3e 100644 --- a/plugins/repository-azure/src/test/java/org/opensearch/repositories/azure/AzureBlobContainerRetriesTests.java +++ b/plugins/repository-azure/src/test/java/org/opensearch/repositories/azure/AzureBlobContainerRetriesTests.java @@ -61,7 +61,6 @@ import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; -import org.apache.hc.core5.http.HttpStatus; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -484,28 +483,4 @@ private static Optional getRangeEnd(HttpExchange exchange) { return Optional.of(Math.toIntExact(rangeEnd)); } - private static void sendIncompleteContent(HttpExchange exchange, byte[] bytes) throws IOException { - final int rangeStart = getRangeStart(exchange); - assertThat(rangeStart, lessThan(bytes.length)); - final Optional rangeEnd = getRangeEnd(exchange); - final int length; - if (rangeEnd.isPresent()) { - // adapt range end to be compliant to https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35 - final int effectiveRangeEnd = Math.min(rangeEnd.get(), bytes.length - 1); - length = effectiveRangeEnd - rangeStart; - } else { - length = bytes.length - rangeStart - 1; - } - exchange.getResponseHeaders().add("Content-Type", "application/octet-stream"); - exchange.getResponseHeaders().add("x-ms-blob-content-length", String.valueOf(length)); - exchange.getResponseHeaders().add("x-ms-blob-type", "blockblob"); - exchange.sendResponseHeaders(HttpStatus.SC_OK, length); - final int bytesToSend = randomIntBetween(0, length - 1); - if (bytesToSend > 0) { - exchange.getResponseBody().write(bytes, rangeStart, bytesToSend); - } - if (randomBoolean()) { - exchange.getResponseBody().flush(); - } - } } diff --git a/qa/die-with-dignity/src/javaRestTest/java/org/opensearch/qa/die_with_dignity/DieWithDignityIT.java b/qa/die-with-dignity/src/javaRestTest/java/org/opensearch/qa/die_with_dignity/DieWithDignityIT.java index ec891ef8d44ef..aedb05e8dcbd5 100644 --- a/qa/die-with-dignity/src/javaRestTest/java/org/opensearch/qa/die_with_dignity/DieWithDignityIT.java +++ b/qa/die-with-dignity/src/javaRestTest/java/org/opensearch/qa/die_with_dignity/DieWithDignityIT.java @@ -98,15 +98,6 @@ public void testDieWithDignity() throws Exception { } } - private boolean containsAll(String line, String... subStrings) { - for (String subString : subStrings) { - if (line.matches(subString) == false) { - return false; - } - } - return true; - } - private void debugLogs(Path path) throws IOException { try (BufferedReader reader = Files.newBufferedReader(path)) { reader.lines().forEach(line -> logger.info(line)); diff --git a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java index 4fd82af9603a9..870398ddf6fec 100644 --- a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java @@ -195,25 +195,6 @@ public void testRecoveryWithConcurrentIndexing() throws Exception { } } - private void assertDocCountOnAllCopies(String index, int expectedCount) throws Exception { - assertBusy(() -> { - Map state = entityAsMap(client().performRequest(new Request("GET", "/_cluster/state"))); - String xpath = "routing_table.indices." + index + ".shards.0.node"; - @SuppressWarnings("unchecked") List assignedNodes = (List) XContentMapValues.extractValue(xpath, state); - assertNotNull(state.toString(), assignedNodes); - for (String assignedNode : assignedNodes) { - try { - assertCount(index, "_only_nodes:" + assignedNode, expectedCount); - } catch (ResponseException e) { - if (e.getMessage().contains("no data nodes with criteria [" + assignedNode + "found for shard: [" + index + "][0]")) { - throw new AssertionError(e); // shard is relocating - ask assert busy to retry - } - throw e; - } - } - }); - } - private void assertCount(final String index, final String preference, final int expectedCount) throws IOException { final int actualDocs; try { @@ -530,17 +511,6 @@ public void testClosedIndexNoopRecovery() throws Exception { break; } } - /** - * Returns the version in which the given index has been created - */ - private static Version indexVersionCreated(final String indexName) throws IOException { - final Request request = new Request("GET", "/" + indexName + "/_settings"); - final String versionCreatedSetting = indexName + ".settings.index.version.created"; - request.addParameter("filter_path", versionCreatedSetting); - - final Response response = client().performRequest(request); - return Version.fromId(Integer.parseInt(ObjectPath.createFromResponse(response).evaluate(versionCreatedSetting))); - } /** * Asserts that an index is closed in the cluster state. If `checkRoutingTable` is true, it also asserts @@ -587,20 +557,6 @@ private void assertClosedIndex(final String index, final boolean checkRoutingTab } } - @SuppressWarnings("unchecked") - private void assertPeerRecoveredFiles(String reason, String index, String targetNode, Matcher sizeMatcher) throws IOException { - Map recoveryStats = entityAsMap(client().performRequest(new Request("GET", index + "/_recovery"))); - List> shards = (List>) XContentMapValues.extractValue(index + "." + "shards", recoveryStats); - for (Map shard : shards) { - if (Objects.equals(XContentMapValues.extractValue("type", shard), "PEER")) { - if (Objects.equals(XContentMapValues.extractValue("target.name", shard), targetNode)) { - Integer recoveredFileSize = (Integer) XContentMapValues.extractValue("index.files.recovered", shard); - assertThat(reason + " target node [" + targetNode + "] stats [" + recoveryStats + "]", recoveredFileSize, sizeMatcher); - } - } - } - } - @SuppressWarnings("unchecked") private void ensureGlobalCheckpointSynced(String index) throws Exception { assertBusy(() -> { diff --git a/sandbox/plugins/concurrent-search/src/test/java/org/opensearch/search/query/QueryPhaseTests.java b/sandbox/plugins/concurrent-search/src/test/java/org/opensearch/search/query/QueryPhaseTests.java index 74cd4754efe44..2768a38cf673d 100644 --- a/sandbox/plugins/concurrent-search/src/test/java/org/opensearch/search/query/QueryPhaseTests.java +++ b/sandbox/plugins/concurrent-search/src/test/java/org/opensearch/search/query/QueryPhaseTests.java @@ -53,11 +53,9 @@ import org.apache.lucene.index.Term; import org.apache.lucene.queries.spans.SpanNearQuery; import org.apache.lucene.queries.spans.SpanTermQuery; -import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Collector; -import org.apache.lucene.search.CollectorManager; import org.apache.lucene.search.ConstantScoreQuery; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.FieldComparator; @@ -76,7 +74,6 @@ import org.apache.lucene.search.SortField; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; -import org.apache.lucene.search.TopFieldDocs; import org.apache.lucene.search.TotalHitCountCollector; import org.apache.lucene.search.TotalHits; import org.apache.lucene.search.Weight; @@ -1178,75 +1175,6 @@ public void search(List leaves, Weight weight, Collector coll }; } - // used to check that numeric long or date sort optimization was run - private static ContextIndexSearcher newOptimizedContextSearcher(IndexReader reader, int queryType, ExecutorService executor) - throws IOException { - return new ContextIndexSearcher( - reader, - IndexSearcher.getDefaultSimilarity(), - IndexSearcher.getDefaultQueryCache(), - IndexSearcher.getDefaultQueryCachingPolicy(), - true, - executor - ) { - - @Override - public void search( - Query query, - CollectorManager manager, - QuerySearchResult result, - DocValueFormat[] formats, - TotalHits totalHits - ) throws IOException { - assertTrue(query instanceof BooleanQuery); - List clauses = ((BooleanQuery) query).clauses(); - assertTrue(clauses.size() == 2); - assertTrue(clauses.get(0).getOccur() == Occur.FILTER); - assertTrue(clauses.get(1).getOccur() == Occur.SHOULD); - if (queryType == 0) { - assertTrue( - clauses.get(1).getQuery().getClass() == LongPoint.newDistanceFeatureQuery("random_field", 1, 1, 1).getClass() - ); - } - if (queryType == 1) assertTrue(clauses.get(1).getQuery() instanceof DocValuesFieldExistsQuery); - super.search(query, manager, result, formats, totalHits); - } - - @Override - public void search( - List leaves, - Weight weight, - @SuppressWarnings("rawtypes") CollectorManager manager, - QuerySearchResult result, - DocValueFormat[] formats, - TotalHits totalHits - ) throws IOException { - final Query query = weight.getQuery(); - assertTrue(query instanceof BooleanQuery); - List clauses = ((BooleanQuery) query).clauses(); - assertTrue(clauses.size() == 2); - assertTrue(clauses.get(0).getOccur() == Occur.FILTER); - assertTrue(clauses.get(1).getOccur() == Occur.SHOULD); - if (queryType == 0) { - assertTrue( - clauses.get(1).getQuery().getClass() == LongPoint.newDistanceFeatureQuery("random_field", 1, 1, 1).getClass() - ); - } - if (queryType == 1) assertTrue(clauses.get(1).getQuery() instanceof DocValuesFieldExistsQuery); - super.search(leaves, weight, manager, result, formats, totalHits); - } - - @Override - public void search(List leaves, Weight weight, Collector collector) throws IOException { - if (getExecutor() == null) { - assert (false); // should not be there, expected to search with CollectorManager - } else { - super.search(leaves, weight, collector); - } - } - }; - } - private static class TestTotalHitCountCollectorManager extends TotalHitCountCollectorManager { private int totalHits; private final TotalHitCountCollector collector; diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java index 955f0f0465d88..4664648c03ccc 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java @@ -56,7 +56,6 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.ByteSizeUnit; import org.opensearch.common.unit.ByteSizeValue; -import org.opensearch.core.internal.io.IOUtils; import org.opensearch.env.Environment; import org.opensearch.env.NodeEnvironment; import org.opensearch.index.IndexSettings; @@ -486,12 +485,5 @@ TestFileStore getTestFileStore(Path path) { assertThat(path + " not contained in a unique tracked path", containingPaths, hasSize(1)); return trackedPaths.get(containingPaths.iterator().next()); } - - void clearTrackedPaths() throws IOException { - for (Path path : trackedPaths.keySet()) { - IOUtils.rm(path); - } - trackedPaths.clear(); - } } } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MultiTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MultiTermsIT.java index 7d7f80c8ac758..d4273aee925f7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MultiTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MultiTermsIT.java @@ -161,7 +161,4 @@ public void testMultiValuedFieldWithValueScript() throws Exception { assertThat(bucket.getDocCount(), equalTo(2L)); } - private MultiTermsValuesSourceConfig field(String name) { - return new MultiTermsValuesSourceConfig.Builder().setFieldName(name).build(); - } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/segments/IndicesSegmentResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/segments/IndicesSegmentResponse.java index c3992f8d42967..e21616657502a 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/segments/IndicesSegmentResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/segments/IndicesSegmentResponse.java @@ -36,18 +36,15 @@ import org.apache.lucene.search.SortField; import org.apache.lucene.search.SortedNumericSortField; import org.apache.lucene.search.SortedSetSortField; -import org.apache.lucene.util.Accountable; import org.opensearch.action.support.DefaultShardOperationFailedException; import org.opensearch.action.support.broadcast.BroadcastResponse; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; -import org.opensearch.common.unit.ByteSizeValue; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.index.engine.Segment; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -197,21 +194,6 @@ private static void toXContent(XContentBuilder builder, Sort sort) throws IOExce builder.endArray(); } - private static void toXContent(XContentBuilder builder, Accountable tree) throws IOException { - builder.startObject(); - builder.field(Fields.DESCRIPTION, tree.toString()); - builder.humanReadableField(Fields.SIZE_IN_BYTES, Fields.SIZE, new ByteSizeValue(tree.ramBytesUsed())); - Collection children = tree.getChildResources(); - if (children.isEmpty() == false) { - builder.startArray(Fields.CHILDREN); - for (Accountable child : children) { - toXContent(builder, child); - } - builder.endArray(); - } - builder.endObject(); - } - /** * Fields for parsing and toXContent * diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java index ec72ea8b49829..e6c943331f323 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java @@ -605,25 +605,4 @@ public static Set getPossibleRoleNames() { return roleMap.keySet(); } - /** - * Enum that holds all the possible roles that a node can fulfill in a cluster. - * Each role has its name and a corresponding abbreviation used by cat apis. - */ - private enum LegacyRole { - MASTER("master"), - DATA("data"), - INGEST("ingest"); - - private final String roleName; - - LegacyRole(final String roleName) { - this.roleName = roleName; - } - - public String roleName() { - return roleName; - } - - } - } diff --git a/server/src/main/java/org/opensearch/index/engine/Segment.java b/server/src/main/java/org/opensearch/index/engine/Segment.java index a341e73364356..a80256cb685c1 100644 --- a/server/src/main/java/org/opensearch/index/engine/Segment.java +++ b/server/src/main/java/org/opensearch/index/engine/Segment.java @@ -38,7 +38,6 @@ import org.apache.lucene.search.SortedNumericSortField; import org.apache.lucene.search.SortedSetSelector; import org.apache.lucene.search.SortedNumericSelector; -import org.apache.lucene.util.Accountable; import org.opensearch.Version; import org.opensearch.common.Nullable; import org.opensearch.common.io.stream.StreamInput; @@ -48,7 +47,6 @@ import org.opensearch.common.unit.ByteSizeValue; import java.io.IOException; -import java.util.Collection; import java.util.Map; import java.util.Objects; @@ -317,17 +315,6 @@ private static void readRamTree(StreamInput in) throws IOException { } } - // the ram tree is written recursively since the depth is fairly low (5 or 6) - private void writeRamTree(StreamOutput out, Accountable tree) throws IOException { - out.writeString(tree.toString()); - out.writeVLong(tree.ramBytesUsed()); - Collection children = tree.getChildResources(); - out.writeVInt(children.size()); - for (Accountable child : children) { - writeRamTree(out, child); - } - } - @Override public String toString() { return "Segment{" diff --git a/server/src/main/java/org/opensearch/index/mapper/DocumentMapperParser.java b/server/src/main/java/org/opensearch/index/mapper/DocumentMapperParser.java index 237d69e3ad244..0d332942644f4 100644 --- a/server/src/main/java/org/opensearch/index/mapper/DocumentMapperParser.java +++ b/server/src/main/java/org/opensearch/index/mapper/DocumentMapperParser.java @@ -37,10 +37,8 @@ import org.opensearch.common.collect.Tuple; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.time.DateFormatter; -import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.IndexSettings; import org.opensearch.index.query.QueryShardContext; @@ -197,18 +195,6 @@ private static String getRemainingFields(Map map) { return remainingFields.toString(); } - private Tuple> extractMapping(String type, String source) throws MapperParsingException { - Map root; - try ( - XContentParser parser = XContentType.JSON.xContent().createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, source) - ) { - root = parser.mapOrdered(); - } catch (Exception e) { - throw new MapperParsingException("failed to parse mapping definition", e); - } - return extractMapping(type, root); - } - /** * Given an optional type name and mapping definition, returns the type and a normalized form of the mappings. * diff --git a/server/src/main/java/org/opensearch/index/query/ExistsQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/ExistsQueryBuilder.java index 135a9788ab039..6b90a338ee606 100644 --- a/server/src/main/java/org/opensearch/index/query/ExistsQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/ExistsQueryBuilder.java @@ -32,14 +32,12 @@ package org.opensearch.index.query; -import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.ConstantScoreQuery; import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; -import org.apache.lucene.search.TermQuery; import org.opensearch.common.ParseField; import org.opensearch.common.ParsingException; import org.opensearch.common.Strings; @@ -185,12 +183,6 @@ public static Query newFilter(QueryShardContext context, String fieldPattern, bo return new ConstantScoreQuery(boolFilterBuilder.build()); } - private static Query newLegacyExistsQuery(QueryShardContext context, String field) { - MappedFieldType fieldType = context.fieldMapper(field); - String fieldName = fieldType != null ? fieldType.name() : field; - return new TermQuery(new Term(FieldNamesFieldMapper.NAME, fieldName)); - } - private static Query newFieldExistsQuery(QueryShardContext context, String field) { MappedFieldType fieldType = context.getMapperService().fieldType(field); if (fieldType == null) { diff --git a/server/src/main/java/org/opensearch/ingest/IngestMetadata.java b/server/src/main/java/org/opensearch/ingest/IngestMetadata.java index f55ba28e9c304..bf605833db6cf 100644 --- a/server/src/main/java/org/opensearch/ingest/IngestMetadata.java +++ b/server/src/main/java/org/opensearch/ingest/IngestMetadata.java @@ -74,10 +74,6 @@ public final class IngestMetadata implements Metadata.Custom { // IngestMetadata is registered as custom metadata. private final Map pipelines; - private IngestMetadata() { - this.pipelines = Collections.emptyMap(); - } - public IngestMetadata(Map pipelines) { this.pipelines = Collections.unmodifiableMap(pipelines); } diff --git a/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java b/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java index 0123c839e4ad9..a4cd2fbe97bd5 100644 --- a/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java @@ -935,21 +935,6 @@ public void applyClusterState(ClusterChangedEvent event) { assert assertNoDanglingSnapshots(event.state()); } - /** - * Cleanup all snapshots found in the given cluster state that have no more work left: - * 1. Completed snapshots - * 2. Snapshots in state INIT that a previous cluster-manager of an older version failed to start - * 3. Snapshots in any other state that have all their shard tasks completed - */ - private void endCompletedSnapshots(ClusterState state) { - SnapshotsInProgress snapshotsInProgress = state.custom(SnapshotsInProgress.TYPE); - assert snapshotsInProgress != null; - snapshotsInProgress.entries() - .stream() - .filter(entry -> entry.state().completed() || entry.state() == State.INIT || completed(entry.shards().values())) - .forEach(entry -> endSnapshot(entry, state.metadata(), null)); - } - private boolean assertConsistentWithClusterState(ClusterState state) { final SnapshotsInProgress snapshotsInProgress = state.custom(SnapshotsInProgress.TYPE, SnapshotsInProgress.EMPTY); if (snapshotsInProgress.entries().isEmpty() == false) { @@ -1295,31 +1280,6 @@ private static boolean removedNodesCleanupNeeded(SnapshotsInProgress snapshotsIn }); } - /** - * Returns list of indices with missing shards, and list of indices that are closed - * - * @param shards list of shard statuses - * @return list of failed and closed indices - */ - private static Tuple, Set> indicesWithMissingShards( - ImmutableOpenMap shards, - Metadata metadata - ) { - Set missing = new HashSet<>(); - Set closed = new HashSet<>(); - for (ObjectObjectCursor entry : shards) { - if (entry.value.state() == ShardState.MISSING) { - if (metadata.hasIndex(entry.key.getIndex().getName()) - && metadata.getIndexSafe(entry.key.getIndex()).getState() == IndexMetadata.State.CLOSE) { - closed.add(entry.key.getIndex().getName()); - } else { - missing.add(entry.key.getIndex().getName()); - } - } - } - return new Tuple<>(missing, closed); - } - /** * Finalizes the shard in repository and then removes it from cluster state *

diff --git a/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java index 079e5d388bbf4..f2ea34a9f187d 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java @@ -48,7 +48,6 @@ import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentParseException; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.index.RandomCreateIndexGenerator; import org.opensearch.index.mapper.MapperService; import org.opensearch.indices.IndicesModule; import org.opensearch.test.OpenSearchTestCase; @@ -215,22 +214,4 @@ public void testValidation() { conditionsGenerator.add((request) -> request.addMaxIndexAgeCondition(new TimeValue(randomNonNegativeLong()))); } - private static RolloverRequest createTestItem() throws IOException { - RolloverRequest rolloverRequest = new RolloverRequest(); - if (randomBoolean()) { - rolloverRequest.getCreateIndexRequest().mapping(RandomCreateIndexGenerator.randomMapping()); - } - if (randomBoolean()) { - RandomCreateIndexGenerator.randomAliases(rolloverRequest.getCreateIndexRequest()); - } - if (randomBoolean()) { - rolloverRequest.getCreateIndexRequest().settings(RandomCreateIndexGenerator.randomIndexSettings()); - } - int numConditions = randomIntBetween(0, 3); - List> conditions = randomSubsetOf(numConditions, conditionsGenerator); - for (Consumer consumer : conditions) { - consumer.accept(rolloverRequest); - } - return rolloverRequest; - } } diff --git a/server/src/test/java/org/opensearch/cluster/coordination/NoClusterManagerBlockServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/NoClusterManagerBlockServiceTests.java index d9ff21204387d..7bd2fefe50c42 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/NoClusterManagerBlockServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/NoClusterManagerBlockServiceTests.java @@ -52,13 +52,6 @@ private void createService(Settings settings) { noClusterManagerBlockService = new NoClusterManagerBlockService(settings, clusterSettings); } - private void assertDeprecatedWarningEmitted() { - assertWarnings( - "[discovery.zen.no_master_block] setting was deprecated in OpenSearch and will be removed in a future release! " - + "See the breaking changes documentation for the next major version." - ); - } - public void testBlocksWritesByDefault() { createService(Settings.EMPTY); assertThat(noClusterManagerBlockService.getNoClusterManagerBlock(), sameInstance(NO_CLUSTER_MANAGER_BLOCK_METADATA_WRITES)); diff --git a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java index 3f39d67dee765..7fe58d75932a1 100644 --- a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java @@ -456,10 +456,4 @@ private static DiscoveryNode newClusterManagerNode(String nodeId, Map DATA_ROLE = Collections.unmodifiableSet( new HashSet<>(Collections.singletonList(DiscoveryNodeRole.DATA_ROLE)) ); - - private ClusterState removeNodes(ClusterState clusterState, String... nodeIds) { - DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.getNodes()); - org.opensearch.common.collect.List.of(nodeIds).forEach(nodeBuilder::remove); - return allocationService.disassociateDeadNodes(ClusterState.builder(clusterState).nodes(nodeBuilder).build(), false, "test"); - } } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java index 5348fd0a778f7..389cd19e4953e 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java @@ -32,7 +32,6 @@ package org.opensearch.cluster.metadata; -import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import org.hamcrest.Matchers; import org.junit.Before; import org.opensearch.ExceptionsHelper; @@ -94,7 +93,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -1302,14 +1300,6 @@ private CompressedXContent createMapping(String fieldName, String fieldType) { } } - private static Map convertMappings(ImmutableOpenMap mappings) { - Map converted = new HashMap<>(mappings.size()); - for (ObjectObjectCursor cursor : mappings) { - converted.put(cursor.key, cursor.value); - } - return converted; - } - private ShardLimitValidator randomShardLimitService() { return createTestShardLimitService(randomIntBetween(10, 10000), false); } diff --git a/server/src/test/java/org/opensearch/common/joda/JavaJodaTimeDuellingTests.java b/server/src/test/java/org/opensearch/common/joda/JavaJodaTimeDuellingTests.java index 94ddfd7e7f100..02bc6c58ad233 100644 --- a/server/src/test/java/org/opensearch/common/joda/JavaJodaTimeDuellingTests.java +++ b/server/src/test/java/org/opensearch/common/joda/JavaJodaTimeDuellingTests.java @@ -874,13 +874,6 @@ private void assertSamePrinterOutput(String format, ZonedDateTime javaDate, Date assertSamePrinterOutput(format, javaDate, jodaDate, dateFormatter, jodaDateFormatter); } - private void assertSamePrinterOutput(String format, ZonedDateTime javaDate, DateTime jodaDate, Locale locale) { - DateFormatter dateFormatter = DateFormatter.forPattern(format).withLocale(locale); - DateFormatter jodaDateFormatter = Joda.forPattern(format).withLocale(locale); - - assertSamePrinterOutput(format, javaDate, jodaDate, dateFormatter, jodaDateFormatter); - } - private void assertSamePrinterOutput( String format, ZonedDateTime javaDate, @@ -908,12 +901,6 @@ private void assertSameDate(String input, String format) { assertSameDate(input, format, jodaFormatter, javaFormatter); } - private void assertSameDate(String input, String format, Locale locale) { - DateFormatter jodaFormatter = Joda.forPattern(format).withLocale(locale); - DateFormatter javaFormatter = DateFormatter.forPattern(format).withLocale(locale); - assertSameDate(input, format, jodaFormatter, javaFormatter); - } - private void assertSameDate(String input, String format, DateFormatter jodaFormatter, DateFormatter javaFormatter) { DateTime jodaDateTime = jodaFormatter.parseJoda(input); diff --git a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java index 28a420403bcc1..e4b2bbcacbdcd 100644 --- a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java @@ -3525,17 +3525,6 @@ public void testSkipTranslogReplay() throws IOException { } } - private Path[] filterExtraFSFiles(Path[] files) { - List paths = new ArrayList<>(); - for (Path p : files) { - if (p.getFileName().toString().startsWith("extra")) { - continue; - } - paths.add(p); - } - return paths.toArray(new Path[0]); - } - public void testTranslogReplay() throws IOException { final LongSupplier inSyncGlobalCheckpointSupplier = () -> this.engine.getProcessedLocalCheckpoint(); final int numDocs = randomIntBetween(1, 10); diff --git a/server/src/test/java/org/opensearch/index/mapper/DateFieldTypeTests.java b/server/src/test/java/org/opensearch/index/mapper/DateFieldTypeTests.java index 085343f4ff2f7..490966c5c48e5 100644 --- a/server/src/test/java/org/opensearch/index/mapper/DateFieldTypeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/DateFieldTypeTests.java @@ -67,7 +67,6 @@ import org.joda.time.DateTimeZone; import java.io.IOException; -import java.time.Instant; import java.time.ZoneOffset; import java.util.Collections; @@ -365,10 +364,6 @@ public void testDateNanoDocValues() throws IOException { dir.close(); } - private Instant instant(String str) { - return DateFormatters.from(DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.parse(str)).toInstant(); - } - private static DateFieldType fieldType(Resolution resolution, String format, String nullValue) { DateFormatter formatter = DateFormatter.forPattern(format); return new DateFieldType("field", true, false, true, formatter, resolution, nullValue, Collections.emptyMap()); diff --git a/server/src/test/java/org/opensearch/index/translog/TranslogTests.java b/server/src/test/java/org/opensearch/index/translog/TranslogTests.java index 153677e00c22b..964fc8f21c388 100644 --- a/server/src/test/java/org/opensearch/index/translog/TranslogTests.java +++ b/server/src/test/java/org/opensearch/index/translog/TranslogTests.java @@ -1018,10 +1018,6 @@ private Term newUid(ParsedDocument doc) { return new Term("_id", Uid.encodeId(doc.id())); } - private Term newUid(String id) { - return new Term("_id", Uid.encodeId(id)); - } - public void testVerifyTranslogIsNotDeleted() throws IOException { assertFileIsPresent(translog, 1); translog.add(new Translog.Index("1", 0, primaryTerm.get(), new byte[] { 1 })); diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java index b20154fff9256..fe8a7cb2b786b 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java @@ -80,15 +80,10 @@ import org.opensearch.client.RestClientBuilder; import org.opensearch.cluster.ClusterModule; import org.opensearch.cluster.ClusterState; -import org.opensearch.cluster.RestoreInProgress; -import org.opensearch.cluster.SnapshotDeletionsInProgress; -import org.opensearch.cluster.SnapshotsInProgress; import org.opensearch.cluster.coordination.OpenSearchNodeCommand; import org.opensearch.cluster.health.ClusterHealthStatus; -import org.opensearch.cluster.metadata.IndexGraveyard; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.metadata.Metadata; -import org.opensearch.cluster.metadata.RepositoriesMetadata; import org.opensearch.cluster.routing.IndexRoutingTable; import org.opensearch.cluster.routing.IndexShardRoutingTable; import org.opensearch.cluster.routing.ShardRouting; @@ -141,7 +136,6 @@ import org.opensearch.indices.IndicesQueryCache; import org.opensearch.indices.IndicesRequestCache; import org.opensearch.indices.store.IndicesStore; -import org.opensearch.ingest.IngestMetadata; import org.opensearch.monitor.os.OsInfo; import org.opensearch.node.NodeMocksPlugin; import org.opensearch.plugins.NetworkPlugin; @@ -149,7 +143,6 @@ import org.opensearch.rest.RestStatus; import org.opensearch.rest.action.RestCancellableNodeClient; import org.opensearch.script.MockScriptService; -import org.opensearch.script.ScriptMetadata; import org.opensearch.search.MockSearchService; import org.opensearch.search.SearchHit; import org.opensearch.search.SearchService; @@ -1248,37 +1241,6 @@ protected void ensureClusterStateCanBeReadByNodeTool() throws IOException { } } - private static final Set SAFE_METADATA_CUSTOMS = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(IndexGraveyard.TYPE, IngestMetadata.TYPE, RepositoriesMetadata.TYPE, ScriptMetadata.TYPE)) - ); - - private static final Set SAFE_CUSTOMS = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(RestoreInProgress.TYPE, SnapshotDeletionsInProgress.TYPE, SnapshotsInProgress.TYPE)) - ); - - /** - * Remove any customs except for customs that we know all clients understand. - * - * @param clusterState the cluster state to remove possibly-unknown customs from - * @return the cluster state with possibly-unknown customs removed - */ - private ClusterState removePluginCustoms(final ClusterState clusterState) { - final ClusterState.Builder builder = ClusterState.builder(clusterState); - clusterState.customs().keysIt().forEachRemaining(key -> { - if (SAFE_CUSTOMS.contains(key) == false) { - builder.removeCustom(key); - } - }); - final Metadata.Builder mdBuilder = Metadata.builder(clusterState.metadata()); - clusterState.metadata().customs().keysIt().forEachRemaining(key -> { - if (SAFE_METADATA_CUSTOMS.contains(key) == false) { - mdBuilder.removeCustom(key); - } - }); - builder.metadata(mdBuilder); - return builder.build(); - } - /** * Ensures the cluster is in a searchable state for the given indices. This means a searchable copy of each * shard is available on the cluster.