diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cc2e517d844c..4b2de6dcc9dfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Grant access to testclusters dir for tests ([#19085](https://github.com/opensearch-project/OpenSearch/issues/19085)) - Fix assertion error when collapsing search results with concurrent segment search enabled ([#19053](https://github.com/opensearch-project/OpenSearch/pull/19053)) - Fix skip_unavailable setting changing to default during node drop issue ([#18766](https://github.com/opensearch-project/OpenSearch/pull/18766)) +- S1144: Unused "private" methods should be removed ([#18918](https://github.com/opensearch-project/OpenSearch/pull/18918)) ### Dependencies - Bump `com.netflix.nebula.ospackage-base` from 12.0.0 to 12.1.0 ([#19019](https://github.com/opensearch-project/OpenSearch/pull/19019)) diff --git a/libs/task-commons/src/main/java/org/opensearch/task/commons/clients/TaskListRequest.java b/libs/task-commons/src/main/java/org/opensearch/task/commons/clients/TaskListRequest.java index 625e15dfb3b6d..64c414a20867c 100644 --- a/libs/task-commons/src/main/java/org/opensearch/task/commons/clients/TaskListRequest.java +++ b/libs/task-commons/src/main/java/org/opensearch/task/commons/clients/TaskListRequest.java @@ -71,16 +71,6 @@ public TaskListRequest taskType(TaskStatus... taskStatus) { return this; } - /** - * Update worker node to filter with in the request - * @param workerNode WorkerNode - * @return ListTaskRequest - */ - private TaskListRequest workerNode(WorkerNode workerNode) { - this.workerNodes = workerNode; - return this; - } - /** * Update page number to start with when fetching the list of tasks * @param startPageNumber startPageNumber diff --git a/modules/cache-common/src/test/java/org/opensearch/cache/common/tier/TieredSpilloverCacheTests.java b/modules/cache-common/src/test/java/org/opensearch/cache/common/tier/TieredSpilloverCacheTests.java index ffaaf86abb031..864a29b74eab4 100644 --- a/modules/cache-common/src/test/java/org/opensearch/cache/common/tier/TieredSpilloverCacheTests.java +++ b/modules/cache-common/src/test/java/org/opensearch/cache/common/tier/TieredSpilloverCacheTests.java @@ -2665,17 +2665,6 @@ private TieredSpilloverCache getTieredSpilloverCache( return builder.build(); } - private TieredSpilloverCache initializeTieredSpilloverCache( - int keyValueSize, - int diskCacheSize, - RemovalListener, String> removalListener, - Settings settings, - long diskDeliberateDelay - - ) { - return initializeTieredSpilloverCache(keyValueSize, diskCacheSize, removalListener, settings, diskDeliberateDelay, null, 256); - } - private TieredSpilloverCache initializeTieredSpilloverCache( int keyValueSize, int diskCacheSize, diff --git a/plugins/arrow-flight-rpc/src/internalClusterTest/java/org/opensearch/arrow/flight/chaos/ChaosAgent.java b/plugins/arrow-flight-rpc/src/internalClusterTest/java/org/opensearch/arrow/flight/chaos/ChaosAgent.java index 08340245cc7e0..d40e6aa10a8e9 100644 --- a/plugins/arrow-flight-rpc/src/internalClusterTest/java/org/opensearch/arrow/flight/chaos/ChaosAgent.java +++ b/plugins/arrow-flight-rpc/src/internalClusterTest/java/org/opensearch/arrow/flight/chaos/ChaosAgent.java @@ -14,7 +14,6 @@ import javassist.ClassPool; import javassist.CtClass; import javassist.CtConstructor; -import javassist.CtMethod; /** * Java agent for bytecode injection of chaos testing @@ -75,27 +74,6 @@ private boolean shouldTransform(String className) { return className.startsWith("org/opensearch/arrow/flight/transport/Flight"); } - private void transformFlightTransport(CtClass ctClass) throws Exception { - CtMethod method = ctClass.getDeclaredMethod("openConnection"); - method.insertBefore("org.opensearch.arrow.flight.chaos.ChaosScenario.injectChaos();"); - } - - private void transformFlightTransportChannel(CtClass ctClass) throws Exception { - CtMethod sendBatch = ctClass.getDeclaredMethod("sendResponseBatch"); - sendBatch.insertBefore("org.opensearch.arrow.flight.chaos.ChaosScenario.injectChaos();"); - - CtMethod complete = ctClass.getDeclaredMethod("completeStream"); - complete.insertBefore("org.opensearch.arrow.flight.chaos.ChaosScenario.injectChaos();"); - } - - private void transformFlightTransportResponse(CtClass ctClass) throws Exception { - CtMethod nextResponse = ctClass.getDeclaredMethod("nextResponse"); - nextResponse.insertBefore("org.opensearch.arrow.flight.chaos.ChaosScenario.injectChaos();"); - - // CtMethod close = ctClass.getDeclaredMethod("close"); - // close.insertBefore("org.opensearch.arrow.flight.chaos.ChaosInterceptor.beforeResponseClose();"); - } - private void transformFlightServerChannelWithDelay(CtClass ctClass) throws Exception { CtConstructor[] ctr = ctClass.getConstructors(); ctr[0].insertBefore("org.opensearch.arrow.flight.chaos.ChaosScenario.injectChaos();"); diff --git a/plugins/arrow-flight-rpc/src/internalClusterTest/java/org/opensearch/arrow/flight/chaos/ChaosScenario.java b/plugins/arrow-flight-rpc/src/internalClusterTest/java/org/opensearch/arrow/flight/chaos/ChaosScenario.java index d1939b69f656a..57e2c41e4a80c 100644 --- a/plugins/arrow-flight-rpc/src/internalClusterTest/java/org/opensearch/arrow/flight/chaos/ChaosScenario.java +++ b/plugins/arrow-flight-rpc/src/internalClusterTest/java/org/opensearch/arrow/flight/chaos/ChaosScenario.java @@ -8,7 +8,6 @@ package org.opensearch.arrow.flight.chaos; -import org.opensearch.transport.stream.StreamErrorCode; import org.opensearch.transport.stream.StreamException; import java.util.concurrent.atomic.AtomicBoolean; @@ -67,20 +66,6 @@ public static void injectChaos() throws StreamException { } } - private static void simulateUnresponsiveness() throws StreamException { - try { - Thread.sleep(timeoutDelayMs); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - throw new StreamException(StreamErrorCode.TIMED_OUT, "Client unresponsive"); - } - - private static void simulateClientNodeDeath() throws StreamException { - // Simulate node death followed by recovery - throw new StreamException(StreamErrorCode.UNAVAILABLE, "Client node death - connection lost"); - } - private static void simulateLongRunningOperation() throws StreamException { try { Thread.sleep(timeoutDelayMs); diff --git a/plugins/arrow-flight-rpc/src/main/java/org/opensearch/arrow/flight/bootstrap/FlightClientManager.java b/plugins/arrow-flight-rpc/src/main/java/org/opensearch/arrow/flight/bootstrap/FlightClientManager.java index c81f4d3c270e7..6fb320aba0334 100644 --- a/plugins/arrow-flight-rpc/src/main/java/org/opensearch/arrow/flight/bootstrap/FlightClientManager.java +++ b/plugins/arrow-flight-rpc/src/main/java/org/opensearch/arrow/flight/bootstrap/FlightClientManager.java @@ -35,7 +35,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; @@ -247,10 +246,6 @@ private static boolean isValidNode(DiscoveryNode node) { return node != null && !node.getVersion().before(MIN_SUPPORTED_VERSION) && FeatureFlags.isEnabled(ARROW_STREAMS_SETTING); } - private Set getCurrentClusterNodes() { - return Objects.requireNonNull(clientConfig.clusterService).state().nodes().getNodes().keySet(); - } - @VisibleForTesting Map getFlightClients() { return flightClients; diff --git a/plugins/cache-ehcache/src/test/java/org/opensearch/cache/store/disk/EhCacheDiskCacheTests.java b/plugins/cache-ehcache/src/test/java/org/opensearch/cache/store/disk/EhCacheDiskCacheTests.java index 3b3c5fd82f87f..b7428a69704aa 100644 --- a/plugins/cache-ehcache/src/test/java/org/opensearch/cache/store/disk/EhCacheDiskCacheTests.java +++ b/plugins/cache-ehcache/src/test/java/org/opensearch/cache/store/disk/EhCacheDiskCacheTests.java @@ -1264,35 +1264,6 @@ PersistentCacheManager buildCacheManager() { } } - private EhcacheDiskCache.Builder createDummyBuilder(String storagePath) throws IOException { - Settings settings = Settings.builder().build(); - MockRemovalListener removalListener = new MockRemovalListener<>(); - ToLongBiFunction, String> weigher = getWeigher(); - try (NodeEnvironment env = newNodeEnvironment(settings)) { - if (storagePath == null || storagePath.isBlank()) { - storagePath = env.nodePaths()[0].path.toString() + "/request_cache"; - } - return (EhcacheDiskCache.Builder) new EhcacheDiskCache.Builder().setThreadPoolAlias( - "ehcacheTest" - ) - .setIsEventListenerModeSync(true) - .setStoragePath(storagePath) - .setKeyType(String.class) - .setValueType(String.class) - .setKeySerializer(new StringSerializer()) - .setDiskCacheAlias("test1") - .setValueSerializer(new StringSerializer()) - .setDimensionNames(List.of(dimensionName)) - .setCacheType(CacheType.INDICES_REQUEST_CACHE) - .setSettings(settings) - .setExpireAfterAccess(TimeValue.MAX_VALUE) - .setMaximumWeightInBytes(CACHE_SIZE_IN_BYTES) - .setRemovalListener(removalListener) - .setWeigher(weigher) - .setStatsTrackingEnabled(false); - } - } - private List getRandomDimensions(List dimensionNames) { Random rand = Randomness.get(); int bound = 3; 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 57ded47fd64c6..d7028aded4e11 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 @@ -503,12 +503,6 @@ public void testDiskMonitorResetLastRuntimeMilliSecOnlyInFirstCall() throws Exce }, 30L, TimeUnit.SECONDS); } - private String populateNode(final String dataNodeName) throws Exception { - final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); - createAndPopulateIndex(indexName, dataNodeName); - return indexName; - } - private void createIndex(String indexName, String nodeName, boolean isWarmIndex) throws Exception { final Settings.Builder indexSettingBuilder = Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java index e2fada2e3496c..69e45e41bd843 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java @@ -83,10 +83,6 @@ protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put(REMOTE_CLUSTER_STATE_ENABLED_SETTING.getKey(), true).build(); } - private void addNewNodes(int dataNodeCount, int clusterManagerNodeCount) { - internalCluster().startNodes(dataNodeCount + clusterManagerNodeCount); - } - private Map initialTestSetup(int shardCount, int replicaCount, int dataNodeCount, int clusterManagerNodeCount) { prepareCluster(clusterManagerNodeCount, dataNodeCount, INDEX_NAME, replicaCount, shardCount); Map indexStats = indexData(1, false, INDEX_NAME); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java index 17b633c533218..b95ad18471d0e 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java @@ -146,19 +146,6 @@ public NodesInfoRequest removeMetric(String metric) { return this; } - /** - * Helper method for adding and removing metrics. Used when deserializing - * a NodesInfoRequest from an ordered list of booleans. - * - * @param addMetric Whether or not to include a metric. - * @param metricName Name of the metric to include or remove. - */ - private void optionallyAddMetric(boolean addMetric, String metricName) { - if (addMetric) { - requestedMetrics.add(metricName); - } - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java index db45d19dcdcb0..2392f28e6bbcb 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java @@ -172,17 +172,6 @@ public NodesStatsRequest removeMetric(String metric) { return this; } - /** - * Helper method for adding metrics during deserialization. - * @param includeMetric Whether or not to include a metric. - * @param metricName Name of the metric to add. - */ - private void optionallyAddMetric(boolean includeMetric, String metricName) { - if (includeMetric) { - requestedMetrics.add(metricName); - } - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java b/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java index 2caea2a8431a4..438597030c5ca 100644 --- a/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java +++ b/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java @@ -32,7 +32,6 @@ package org.opensearch.cluster.action.index; -import org.opensearch.OpenSearchException; import org.opensearch.action.admin.indices.mapping.put.AutoPutMappingAction; import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest; @@ -44,7 +43,6 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.RunOnce; -import org.opensearch.common.util.concurrent.UncategorizedExecutionException; import org.opensearch.core.action.ActionListener; import org.opensearch.core.index.Index; import org.opensearch.core.xcontent.MediaTypeRegistry; @@ -150,19 +148,6 @@ protected void sendUpdateMapping(Index index, Mapping mappingUpdate, ActionListe ); } - // todo: this explicit unwrap should not be necessary, but is until guessRootCause is fixed to allow wrapped non-es exception. - private static Exception unwrapException(Exception cause) { - return cause instanceof OpenSearchException ? unwrapEsException((OpenSearchException) cause) : cause; - } - - private static RuntimeException unwrapEsException(OpenSearchException esEx) { - Throwable root = esEx.unwrapCause(); - if (root instanceof RuntimeException) { - return (RuntimeException) root; - } - return new UncategorizedExecutionException("Failed execution", root); - } - /** * An adjustable semaphore * diff --git a/server/src/main/java/org/opensearch/common/io/VersionedCodecStreamWrapper.java b/server/src/main/java/org/opensearch/common/io/VersionedCodecStreamWrapper.java index b62ae1f1d3956..c2efb897f8749 100644 --- a/server/src/main/java/org/opensearch/common/io/VersionedCodecStreamWrapper.java +++ b/server/src/main/java/org/opensearch/common/io/VersionedCodecStreamWrapper.java @@ -13,7 +13,6 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.index.CorruptIndexException; -import org.apache.lucene.store.ChecksumIndexInput; import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; @@ -97,15 +96,6 @@ private int checkHeader(IndexInput indexInput) throws IOException { return CodecUtil.checkHeader(indexInput, this.codec, minVersion, this.currentVersion); } - /** - * Reads footer from file input stream containing checksum. - * The {@link IndexInput#getFilePointer()} should be at the footer start position. - * @param indexInput file input stream - */ - private void checkFooter(ChecksumIndexInput indexInput) throws IOException { - CodecUtil.checkFooter(indexInput); - } - /** * Writes header with {@code this.codec} and {@code this.currentVersion} to the file output stream * @param indexOutput file output stream diff --git a/server/src/main/java/org/opensearch/env/NodeEnvironment.java b/server/src/main/java/org/opensearch/env/NodeEnvironment.java index 0b47ec03a3e69..8b5c6d4497007 100644 --- a/server/src/main/java/org/opensearch/env/NodeEnvironment.java +++ b/server/src/main/java/org/opensearch/env/NodeEnvironment.java @@ -677,18 +677,6 @@ public void deleteIndexDirectoryUnderLock(Index index, IndexSettings indexSettin } } - private void deleteIndexFileCacheDirectory(Index index) { - final Path indexCachePath = fileCacheNodePath().fileCachePath.resolve(index.getUUID()); - logger.trace("deleting index {} file cache directory, path: [{}]", index, indexCachePath); - if (Files.exists(indexCachePath)) { - try { - IOUtils.rm(indexCachePath); - } catch (IOException e) { - logger.error(() -> new ParameterizedMessage("Failed to delete cache path for index {}", index), e); - } - } - } - /** * Tries to lock all local shards for the given index. If any of the shard locks can't be acquired * a {@link ShardLockObtainFailedException} is thrown and all previously acquired locks are released. diff --git a/server/src/main/java/org/opensearch/gateway/ShardsBatchGatewayAllocator.java b/server/src/main/java/org/opensearch/gateway/ShardsBatchGatewayAllocator.java index ce14cb3442f75..d72716a461389 100644 --- a/server/src/main/java/org/opensearch/gateway/ShardsBatchGatewayAllocator.java +++ b/server/src/main/java/org/opensearch/gateway/ShardsBatchGatewayAllocator.java @@ -43,7 +43,6 @@ import org.opensearch.indices.store.ShardAttributes; import org.opensearch.indices.store.TransportNodesListShardStoreMetadataBatch; import org.opensearch.indices.store.TransportNodesListShardStoreMetadataBatch.NodeStoreFilesMetadata; -import org.opensearch.indices.store.TransportNodesListShardStoreMetadataHelper; import org.opensearch.indices.store.TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata; import org.opensearch.telemetry.metrics.noop.NoopMetricsRegistry; @@ -838,17 +837,6 @@ protected void removeShard(ShardId shardId) { this.batchInfo.remove(shardId); } - private TransportNodesListShardStoreMetadataBatch.NodeStoreFilesMetadata buildEmptyReplicaShardResponse() { - return new TransportNodesListShardStoreMetadataBatch.NodeStoreFilesMetadata( - new TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata( - null, - Store.MetadataSnapshot.EMPTY, - Collections.emptyList() - ), - null - ); - } - private void removeFromBatch(ShardRouting shard) { removeShard(shard.shardId()); clearShardFromCache(shard.shardId()); diff --git a/server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateService.java b/server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateService.java index c68cce4034716..943f5becc528a 100644 --- a/server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateService.java +++ b/server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateService.java @@ -1948,13 +1948,6 @@ public void setRemoteStateReadTimeout(TimeValue remoteStateReadTimeout) { this.remoteStateReadTimeout = remoteStateReadTimeout; } - private BlobStoreTransferService getBlobStoreTransferService() { - if (blobStoreTransferService == null) { - blobStoreTransferService = new BlobStoreTransferService(getBlobStore(), threadpool); - } - return blobStoreTransferService; - } - Set getAllClusterUUIDs(String clusterName) throws IOException { Map clusterUUIDMetadata = clusterUUIDContainer(blobStoreRepository, clusterName).children(); if (clusterUUIDMetadata == null) { @@ -1963,22 +1956,6 @@ Set getAllClusterUUIDs(String clusterName) throws IOException { return Collections.unmodifiableSet(clusterUUIDMetadata.keySet()); } - private Map getLatestManifestForAllClusterUUIDs(String clusterName, Set clusterUUIDs) { - Map manifestsByClusterUUID = new HashMap<>(); - for (String clusterUUID : clusterUUIDs) { - try { - Optional manifest = getLatestClusterMetadataManifest(clusterName, clusterUUID); - manifest.ifPresent(clusterMetadataManifest -> manifestsByClusterUUID.put(clusterUUID, clusterMetadataManifest)); - } catch (Exception e) { - throw new IllegalStateException( - String.format(Locale.ROOT, "Exception in fetching manifest for clusterUUID: %s", clusterUUID), - e - ); - } - } - return manifestsByClusterUUID; - } - /** * This method creates a valid cluster UUID chain. * diff --git a/server/src/main/java/org/opensearch/index/compositeindex/datacube/startree/builder/BaseStarTreeBuilder.java b/server/src/main/java/org/opensearch/index/compositeindex/datacube/startree/builder/BaseStarTreeBuilder.java index 3db3cbe9652fc..c39e83cb29687 100644 --- a/server/src/main/java/org/opensearch/index/compositeindex/datacube/startree/builder/BaseStarTreeBuilder.java +++ b/server/src/main/java/org/opensearch/index/compositeindex/datacube/startree/builder/BaseStarTreeBuilder.java @@ -1102,18 +1102,6 @@ private StarTreeDocument createAggregatedDocs(InMemoryTreeNode node) throws IOEx return aggregatedStarTreeDocument; } - /** - * Handles the dimension of date time field type - * - * @param fieldName name of the field - * @param val value of the field - * @return returns the converted dimension of the field to a particular granularity - */ - private long handleDateDimension(final String fieldName, final long val) { - // TODO: handle timestamp granularity - return val; - } - public void close() throws IOException { } diff --git a/server/src/main/java/org/opensearch/index/query/BoolQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/BoolQueryBuilder.java index a2f71a7064903..f2e7565c885c1 100644 --- a/server/src/main/java/org/opensearch/index/query/BoolQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/BoolQueryBuilder.java @@ -32,13 +32,9 @@ package org.opensearch.index.query; -import org.apache.lucene.index.LeafReader; -import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.PointValues; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; import org.opensearch.common.lucene.search.Queries; @@ -52,13 +48,10 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.function.Consumer; import java.util.stream.Stream; @@ -468,90 +461,4 @@ public void visit(QueryBuilderVisitor visitor) { } } - - private boolean rewriteMustNotRangeClausesToShould(BoolQueryBuilder newBuilder, QueryRewriteContext queryRewriteContext) { - // If there is a range query on a given field in a must_not clause, it's more performant to execute it as - // multiple should clauses representing everything outside the target range. - - // First check if we can get the individual LeafContexts. If we can't, we can't proceed with the rewrite, since we can't confirm - // every doc has exactly 1 value for this field. - List leafReaderContexts = getLeafReaderContexts(queryRewriteContext); - if (leafReaderContexts == null || leafReaderContexts.isEmpty()) { - return false; - } - - QueryShardContext shardContext = getQueryShardContext(queryRewriteContext); - - boolean changed = false; - // For now, only handle the case where there's exactly 1 complement-aware query for this field. - Map fieldCounts = new HashMap<>(); - Set complementAwareQueries = new HashSet<>(); - for (QueryBuilder clause : mustNotClauses) { - if (clause instanceof ComplementAwareQueryBuilder && clause instanceof WithFieldName wfn) { - fieldCounts.merge(wfn.fieldName(), 1, Integer::sum); - complementAwareQueries.add((ComplementAwareQueryBuilder) wfn); - } - } - - for (ComplementAwareQueryBuilder caq : complementAwareQueries) { - String fieldName = ((WithFieldName) caq).fieldName(); - if (fieldCounts.getOrDefault(fieldName, 0) == 1) { - // Check that all docs on this field have exactly 1 value, otherwise we can't perform this rewrite - if (checkAllDocsHaveOneValue(leafReaderContexts, fieldName)) { - List complement = caq.getComplement(shardContext); - if (complement != null) { - BoolQueryBuilder nestedBoolQuery = new BoolQueryBuilder(); - nestedBoolQuery.minimumShouldMatch(1); - for (QueryBuilder complementComponent : complement) { - nestedBoolQuery.should(complementComponent); - } - newBuilder.must(nestedBoolQuery); - newBuilder.mustNotClauses.remove(caq); - changed = true; - } - } - } - } - - if (minimumShouldMatch == null && changed) { - if ((!shouldClauses.isEmpty()) && mustClauses.isEmpty() && filterClauses.isEmpty()) { - // If there were originally should clauses and no must/filter clauses, null minimumShouldMatch is set to a default of 1 - // within Lucene. - // But if there was originally a must or filter clause, the default is 0. - // If we added a must clause due to this rewrite, we should respect what the original default would have been. - newBuilder.minimumShouldMatch(1); - } - } - return changed; - } - - private List getLeafReaderContexts(QueryRewriteContext queryRewriteContext) { - if (queryRewriteContext == null) return null; - QueryShardContext shardContext = queryRewriteContext.convertToShardContext(); - if (shardContext == null) return null; - IndexSearcher indexSearcher = shardContext.searcher(); - if (indexSearcher == null) return null; - return indexSearcher.getIndexReader().leaves(); - } - - private QueryShardContext getQueryShardContext(QueryRewriteContext queryRewriteContext) { - return queryRewriteContext == null ? null : queryRewriteContext.convertToShardContext(); // Note this can still be null - } - - private boolean checkAllDocsHaveOneValue(List contexts, String fieldName) { - for (LeafReaderContext lrc : contexts) { - PointValues values; - try { - LeafReader reader = lrc.reader(); - values = reader.getPointValues(fieldName); - if (values == null || !(values.getDocCount() == reader.maxDoc() && values.getDocCount() == values.size())) { - return false; - } - } catch (IOException e) { - // If we can't get PointValues to check on the number of values per doc, assume the query is ineligible - return false; - } - } - return true; - } } diff --git a/server/src/main/java/org/opensearch/index/remote/RemoteStorePressureSettings.java b/server/src/main/java/org/opensearch/index/remote/RemoteStorePressureSettings.java index e66aa3444c214..504903b737e7c 100644 --- a/server/src/main/java/org/opensearch/index/remote/RemoteStorePressureSettings.java +++ b/server/src/main/java/org/opensearch/index/remote/RemoteStorePressureSettings.java @@ -101,10 +101,6 @@ long getMinRefreshSeqNoLagLimit() { return minRefreshSeqNoLagLimit; } - private void setMinRefreshSeqNoLagLimit(long minRefreshSeqNoLagLimit) { - this.minRefreshSeqNoLagLimit = minRefreshSeqNoLagLimit; - } - double getBytesLagVarianceFactor() { return bytesLagVarianceFactor; } diff --git a/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java b/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java index 1e2264593310d..06a555790ddb0 100644 --- a/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java +++ b/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java @@ -322,17 +322,6 @@ public void onFailure(Exception e) { }); } - private boolean isRemoteSnapshot(ShardId shardId) { - final IndexService indexService = indicesService.indexService(shardId.getIndex()); - if (indexService != null) { - final IndexShard shard = indexService.getShardOrNull(shardId.id()); - if (shard != null) { - return shard.isRemoteSnapshot(); - } - } - return false; - } - // package private for testing static String summarizeFailure(Throwable t) { if (t.getCause() == null) { diff --git a/server/src/main/java/org/opensearch/transport/TransportLogger.java b/server/src/main/java/org/opensearch/transport/TransportLogger.java index 997b3bb5ba18e..ead31c49b2092 100644 --- a/server/src/main/java/org/opensearch/transport/TransportLogger.java +++ b/server/src/main/java/org/opensearch/transport/TransportLogger.java @@ -37,9 +37,7 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.core.common.io.stream.InputStreamStreamInput; import org.opensearch.core.common.io.stream.StreamInput; -import org.opensearch.core.compress.CompressorRegistry; import java.io.IOException; @@ -175,16 +173,4 @@ private static String format(TcpChannel channel, InboundMessage message, String } return sb.toString(); } - - private static StreamInput decompressingStream(byte status, StreamInput streamInput) throws IOException { - if (TransportStatus.isCompress(status) && streamInput.available() > 0) { - try { - return new InputStreamStreamInput(CompressorRegistry.defaultCompressor().threadLocalInputStream(streamInput)); - } catch (IllegalArgumentException e) { - throw new IllegalStateException("stream marked as compressed, but is missing deflate header"); - } - } else { - return streamInput; - } - } } diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java index ceb0c6f1c675b..919c909578076 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java @@ -521,18 +521,4 @@ public void testMaxMinNodeVersion() { assertEquals(Version.fromString("1.1.0"), build.getMaxNodeVersion()); assertEquals(Version.fromString("5.1.0"), build.getMinNodeVersion()); } - - private DiscoveryNode buildDiscoveryNodeFromExisting(DiscoveryNode existing, Version newVersion) { - return new DiscoveryNode( - existing.getName(), - existing.getId(), - existing.getEphemeralId(), - existing.getHostName(), - existing.getHostAddress(), - existing.getAddress(), - existing.getAttributes(), - existing.getRoles(), - newVersion - ); - } } diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/BalanceConfigurationTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/BalanceConfigurationTests.java index 11cbe89645657..77b924550821f 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/BalanceConfigurationTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/BalanceConfigurationTests.java @@ -619,29 +619,6 @@ private void verifyPerIndexPrimaryBalance(ClusterState currentState) { } } - private void verifySkewedPrimaryBalance(ClusterState clusterState, int delta) throws Exception { - assertBusy(() -> { - RoutingNodes nodes = clusterState.getRoutingNodes(); - int totalPrimaryShards = 0; - for (final IndexRoutingTable index : clusterState.getRoutingTable().indicesRouting().values()) { - totalPrimaryShards += index.primaryShardsActive(); - } - final int avgPrimaryShardsPerNode = (int) Math.ceil(totalPrimaryShards * 1f / clusterState.getRoutingNodes().size()); - int maxPrimaryShardOnNode = Integer.MIN_VALUE; - int minPrimaryShardOnNode = Integer.MAX_VALUE; - for (RoutingNode node : nodes) { - final int primaryCount = node.shardsWithState(STARTED) - .stream() - .filter(ShardRouting::primary) - .collect(Collectors.toList()) - .size(); - maxPrimaryShardOnNode = Math.max(maxPrimaryShardOnNode, primaryCount); - minPrimaryShardOnNode = Math.min(minPrimaryShardOnNode, primaryCount); - } - assertTrue(maxPrimaryShardOnNode - minPrimaryShardOnNode < delta); - }, 60, TimeUnit.SECONDS); - } - private void verifyPrimaryBalance(ClusterState clusterState, float buffer) throws Exception { assertBusy(() -> { RoutingNodes nodes = clusterState.getRoutingNodes(); diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteShardsBalancerBaseTestCase.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteShardsBalancerBaseTestCase.java index cfdaaab4e117d..2b07d711e2e9b 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteShardsBalancerBaseTestCase.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteShardsBalancerBaseTestCase.java @@ -194,14 +194,6 @@ protected ClusterState createRemoteIndex(ClusterState state, String indexName) { return ClusterState.builder(state).metadata(metadata).routingTable(routingTable).build(); } - private AllocationDeciders remoteAllocationDeciders(Settings settings, ClusterSettings clusterSettings) { - List deciders = new ArrayList<>( - ClusterModule.createAllocationDeciders(settings, clusterSettings, Collections.emptyList()) - ); - Collections.shuffle(deciders, random()); - return new AllocationDeciders(deciders); - } - public AllocationService createRemoteCapableAllocationService() { Settings settings = Settings.Builder.EMPTY_SETTINGS; return new OpenSearchAllocationTestCase.MockAllocationService( diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteShardsRebalanceShardsTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteShardsRebalanceShardsTests.java index e55a9de160114..824d15030f052 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteShardsRebalanceShardsTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteShardsRebalanceShardsTests.java @@ -95,16 +95,4 @@ private int getTotalShardCountAcrossNodes(final Map nodePrimari } return totalShardCount; } - - /** - * Asserts that the expected value is within the variance range. - *

- * Being used to assert the average number of shards per node. - * Variance is required in case of non-absolute mean values; - * for example, total number of remote capable nodes in a cluster. - */ - private void assertInRange(int actual, int expectedMean, int variance) { - assertTrue(actual >= expectedMean - variance); - assertTrue(actual <= expectedMean + variance); - } } diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteStoreMigrationAllocationDeciderTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteStoreMigrationAllocationDeciderTests.java index e6e81c94e7f32..131beda510beb 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteStoreMigrationAllocationDeciderTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/RemoteStoreMigrationAllocationDeciderTests.java @@ -583,10 +583,6 @@ private Settings getCustomSettings(String direction, String compatibilityMode, I return builder.build(); } - private String getRandomCompatibilityMode() { - return randomFrom(RemoteStoreNodeService.CompatibilityMode.STRICT.mode, RemoteStoreNodeService.CompatibilityMode.MIXED.mode); - } - private ClusterSettings getClusterSettings(Settings settings) { return new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); } diff --git a/server/src/test/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableServiceTests.java b/server/src/test/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableServiceTests.java index 63501f878d55d..a8f5a87c53970 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableServiceTests.java @@ -35,7 +35,6 @@ import org.opensearch.core.index.Index; import org.opensearch.gateway.remote.ClusterMetadataManifest; import org.opensearch.gateway.remote.RemoteClusterStateUtils; -import org.opensearch.index.remote.RemoteStoreEnums; import org.opensearch.index.remote.RemoteStorePathStrategy; import org.opensearch.index.remote.RemoteStoreUtils; import org.opensearch.index.translog.transfer.BlobStoreTransferService; @@ -776,14 +775,6 @@ private ClusterState createClusterState(String indexName) { .build(); } - private BlobPath getPath() { - BlobPath indexRoutingPath = basePath.add(INDEX_ROUTING_TABLE); - return RemoteStoreEnums.PathType.HASHED_PREFIX.path( - RemoteStorePathStrategy.PathInput.builder().basePath(indexRoutingPath).indexUUID("uuid").build(), - RemoteStoreEnums.PathHashAlgorithm.FNV_1A_BASE64 - ); - } - public void testDeleteStaleIndexRoutingPaths() throws IOException { doNothing().when(blobContainer).deleteBlobsIgnoringIfNotExists(any()); when(blobStore.blobContainer(any())).thenReturn(blobContainer); diff --git a/server/src/test/java/org/opensearch/gateway/PrimaryShardBatchAllocatorTests.java b/server/src/test/java/org/opensearch/gateway/PrimaryShardBatchAllocatorTests.java index 2edde8281b11a..9b91e51fab2f5 100644 --- a/server/src/test/java/org/opensearch/gateway/PrimaryShardBatchAllocatorTests.java +++ b/server/src/test/java/org/opensearch/gateway/PrimaryShardBatchAllocatorTests.java @@ -75,13 +75,6 @@ public void buildTestAllocator() { this.batchAllocator = new TestBatchAllocator(); } - private void allocateAllUnassigned(final RoutingAllocation allocation) { - final RoutingNodes.UnassignedShards.UnassignedIterator iterator = allocation.routingNodes().unassigned().iterator(); - while (iterator.hasNext()) { - batchAllocator.allocateUnassigned(iterator.next(), allocation, iterator); - } - } - private void allocateAllUnassignedBatch(final RoutingAllocation allocation) { final RoutingNodes.UnassignedShards.UnassignedIterator iterator = allocation.routingNodes().unassigned().iterator(); List shardsToBatch = new ArrayList<>(); diff --git a/server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateServiceTests.java b/server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateServiceTests.java index d9de899bed529..930cb32ba668d 100644 --- a/server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateServiceTests.java +++ b/server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateServiceTests.java @@ -3919,30 +3919,6 @@ private void mockObjectsForGettingPreviousClusterUUID( when(blobStoreRepository.getCompressor()).thenReturn(compressor); } - private ClusterMetadataManifest generateV1ClusterMetadataManifest( - String clusterUUID, - String previousClusterUUID, - String stateUUID, - List uploadedIndexMetadata, - String globalMetadataFileName, - Boolean isUUIDCommitted - ) { - return ClusterMetadataManifest.builder() - .indices(uploadedIndexMetadata) - .clusterTerm(1L) - .stateVersion(1L) - .stateUUID(stateUUID) - .clusterUUID(clusterUUID) - .nodeId("nodeA") - .opensearchVersion(VersionUtils.randomOpenSearchVersion(random())) - .previousClusterUUID(previousClusterUUID) - .committed(true) - .clusterUUIDCommitted(isUUIDCommitted) - .globalMetadataFileName(globalMetadataFileName) - .codecVersion(CODEC_V1) - .build(); - } - private ClusterMetadataManifest generateClusterMetadataManifest( String clusterUUID, String previousClusterUUID, diff --git a/server/src/test/java/org/opensearch/index/compositeindex/datacube/startree/builder/StarTreeBuilderMergeFlowTests.java b/server/src/test/java/org/opensearch/index/compositeindex/datacube/startree/builder/StarTreeBuilderMergeFlowTests.java index d6def0b075128..2dd6189194abb 100644 --- a/server/src/test/java/org/opensearch/index/compositeindex/datacube/startree/builder/StarTreeBuilderMergeFlowTests.java +++ b/server/src/test/java/org/opensearch/index/compositeindex/datacube/startree/builder/StarTreeBuilderMergeFlowTests.java @@ -2306,47 +2306,6 @@ private StarTreeValues getStarTreeValuesWithKeywords( return starTreeValues; } - private StarTreeValues getStarTreeValuesWithKeywords( - SortedSetDocValues dimList, - SortedSetDocValues dimList2, - SortedSetDocValues dimList4, - SortedSetDocValues dimList3, - SortedNumericDocValues metricsList, - SortedNumericDocValues metricsList1, - StarTreeField sf, - String number - ) { - Map> dimDocIdSetIterators = Map.of( - "field1_minute", - () -> new SortedSetStarTreeValuesIterator(dimList), - "field1_half-hour", - () -> new SortedSetStarTreeValuesIterator(dimList4), - "field1_hour", - () -> new SortedSetStarTreeValuesIterator(dimList2), - "field3", - () -> new SortedSetStarTreeValuesIterator(dimList3) - ); - Map> metricDocIdSetIterators = new LinkedHashMap<>(); - - metricDocIdSetIterators.put( - fullyQualifiedFieldNameForStarTreeMetricsDocValues( - sf.getName(), - "field2", - sf.getMetrics().get(0).getMetrics().get(0).getTypeName() - ), - () -> new SortedNumericStarTreeValuesIterator(metricsList) - ); - metricDocIdSetIterators.put( - fullyQualifiedFieldNameForStarTreeMetricsDocValues( - sf.getName(), - "field2", - sf.getMetrics().get(0).getMetrics().get(1).getTypeName() - ), - () -> new SortedNumericStarTreeValuesIterator(metricsList1) - ); - return new StarTreeValues(sf, null, dimDocIdSetIterators, metricDocIdSetIterators, Map.of(SEGMENT_DOCS_COUNT, number), null); - } - private StarTreeValues getStarTreeValues( List dimList1, List docsWithField1, diff --git a/server/src/test/java/org/opensearch/index/engine/LeafSorterOptimizationTests.java b/server/src/test/java/org/opensearch/index/engine/LeafSorterOptimizationTests.java index af0d74ae06e98..db561200d3088 100644 --- a/server/src/test/java/org/opensearch/index/engine/LeafSorterOptimizationTests.java +++ b/server/src/test/java/org/opensearch/index/engine/LeafSorterOptimizationTests.java @@ -11,10 +11,6 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.LeafReader; import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.Sort; -import org.apache.lucene.search.SortField; -import org.apache.lucene.search.TopDocs; import org.opensearch.Version; import org.opensearch.common.lucene.uid.Versions; import org.opensearch.common.unit.TimeValue; @@ -34,7 +30,6 @@ import java.util.Comparator; import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; @@ -307,23 +302,4 @@ public void testTimestampSortOptimizationWorksOnAllEngineTypes() throws IOExcept } } } - - private void testSortPerformance(Engine engine, String engineType) throws IOException { - try (Engine.Searcher searcher = engine.acquireSearcher("test", Engine.SearcherScope.EXTERNAL)) { - DirectoryReader reader = searcher.getDirectoryReader(); - IndexSearcher indexSearcher = new IndexSearcher(reader); - - // Create a sort by timestamp (descending) - Sort timestampSort = new Sort(new SortField("@timestamp", SortField.Type.LONG, true)); - - // Perform a sorted search - TopDocs topDocs = indexSearcher.search(new MatchAllDocsQuery(), 10, timestampSort); - - // Verify that the search completed successfully - assertThat("Search should complete successfully on " + engineType, topDocs.totalHits.value(), greaterThan(0L)); - - // Verify that the engine has leafSorter configured - assertThat("Engine " + engineType + " should have leafSorter configured", engine.config().getLeafSorter(), notNullValue()); - } - } } diff --git a/server/src/test/java/org/opensearch/index/query/TermQueryWithDocIdAndQueryTests.java b/server/src/test/java/org/opensearch/index/query/TermQueryWithDocIdAndQueryTests.java index a1edb1f0958ec..0e745232a6780 100644 --- a/server/src/test/java/org/opensearch/index/query/TermQueryWithDocIdAndQueryTests.java +++ b/server/src/test/java/org/opensearch/index/query/TermQueryWithDocIdAndQueryTests.java @@ -249,22 +249,6 @@ public void testFetchIsCoveredWithTermsLookupId() throws Exception { verify(mockClient, atLeastOnce()).get(any(GetRequest.class), any()); } - private QueryBuilder mockQueryBuilder() { - return mock(QueryBuilder.class); - } - - private QueryRewriteContext mockRewriteContextForFetch(Client client) { - QueryRewriteContext rewriteContext = mock(QueryRewriteContext.class); - doAnswer(invocation -> { - Object asyncAction = invocation.getArgument(0); - @SuppressWarnings("unchecked") - BiConsumer>> lambda = (BiConsumer>>) asyncAction; - lambda.accept(client, ActionListener.wrap(resp -> {}, ex -> fail("Should not throw"))); - return null; - }).when(rewriteContext).registerAsyncAction(any()); - return rewriteContext; - } - public void testFetchIsCoveredWithTermsLookupQuery() throws Exception { QueryBuilder subQuery = mock(QueryBuilder.class); TermsLookup termsLookup = new TermsLookup("classes", null, "enrolled", subQuery); diff --git a/server/src/test/java/org/opensearch/rest/action/cat/RestCatSegmentReplicationActionTests.java b/server/src/test/java/org/opensearch/rest/action/cat/RestCatSegmentReplicationActionTests.java index 41ad9e8bcbb44..b3e3ad6a7ec76 100644 --- a/server/src/test/java/org/opensearch/rest/action/cat/RestCatSegmentReplicationActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/cat/RestCatSegmentReplicationActionTests.java @@ -31,7 +31,6 @@ import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -183,8 +182,4 @@ private void addTestFileMetadata(ReplicationLuceneIndex index, int startIndex, i } } } - - private static String percent(float percent) { - return String.format(Locale.ROOT, "%1.1f%%", percent); - } } diff --git a/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/DerivedFieldFetchAndHighlightTests.java b/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/DerivedFieldFetchAndHighlightTests.java index 409f123d6e108..63199b2b1e8b7 100644 --- a/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/DerivedFieldFetchAndHighlightTests.java +++ b/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/DerivedFieldFetchAndHighlightTests.java @@ -26,13 +26,9 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.IndexService; import org.opensearch.index.IndexSettings; -import org.opensearch.index.mapper.ContentPath; import org.opensearch.index.mapper.DefaultDerivedFieldResolver; import org.opensearch.index.mapper.DerivedField; import org.opensearch.index.mapper.DerivedFieldResolverFactory; -import org.opensearch.index.mapper.DerivedFieldSupportedTypes; -import org.opensearch.index.mapper.DerivedFieldType; -import org.opensearch.index.mapper.Mapper; import org.opensearch.index.mapper.MapperService; import org.opensearch.index.mapper.SourceToParse; import org.opensearch.index.query.QueryShardContext; @@ -474,15 +470,4 @@ private static ScriptService getScriptService() { ScriptService scriptService = new ScriptService(Settings.EMPTY, engines, ScriptModule.CORE_CONTEXTS); return scriptService; } - - private DerivedFieldType createDerivedFieldType(String name, String type, String script) { - Mapper.BuilderContext context = mock(Mapper.BuilderContext.class); - when(context.path()).thenReturn(new ContentPath()); - return new DerivedFieldType( - new DerivedField(name, type, new Script(ScriptType.INLINE, "mockscript", script, emptyMap())), - DerivedFieldSupportedTypes.getFieldMapperFromType(type, name, context, null), - DerivedFieldSupportedTypes.getIndexableFieldGeneratorType(type, name), - null - ); - } } diff --git a/test/framework/src/main/java/org/opensearch/repositories/blobstore/BlobStoreTestUtil.java b/test/framework/src/main/java/org/opensearch/repositories/blobstore/BlobStoreTestUtil.java index 027b1bef84e7f..69d7b9f511bfd 100644 --- a/test/framework/src/main/java/org/opensearch/repositories/blobstore/BlobStoreTestUtil.java +++ b/test/framework/src/main/java/org/opensearch/repositories/blobstore/BlobStoreTestUtil.java @@ -59,14 +59,12 @@ import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.index.IndexModule; import org.opensearch.repositories.IndexId; import org.opensearch.repositories.RepositoriesService; import org.opensearch.repositories.RepositoryData; import org.opensearch.repositories.ShardGenerations; import org.opensearch.snapshots.SnapshotId; import org.opensearch.snapshots.SnapshotInfo; -import org.opensearch.snapshots.SnapshotMissingException; import org.opensearch.test.InternalTestCluster; import org.opensearch.threadpool.ThreadPool; @@ -470,24 +468,4 @@ private static ClusterService mockClusterService(ClusterState initialState) { when(clusterService.getClusterSettings()).thenReturn(clusterSettings); return clusterService; } - - private static boolean isRemoteSnapshot(BlobStoreRepository repository, RepositoryData repositoryData, IndexId indexId) - throws IOException { - final Collection snapshotIds = repositoryData.getSnapshotIds(); - for (SnapshotId snapshotId : snapshotIds) { - try { - if (isRemoteSnapshot(repository.getSnapshotIndexMetaData(repositoryData, snapshotId, indexId))) { - return true; - } - } catch (SnapshotMissingException e) { - // Index does not exist in this snapshot so continue looping - } - } - return false; - } - - private static boolean isRemoteSnapshot(IndexMetadata metadata) { - final String storeType = metadata.getSettings().get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey()); - return storeType != null && storeType.equals(IndexModule.Type.REMOTE_SNAPSHOT.getSettingsKey()); - } } diff --git a/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java b/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java index 8c612d258f183..f03678ca4ca58 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java @@ -722,30 +722,6 @@ protected void refreshAllIndices() throws IOException { client().performRequest(refreshRequest); } - private static void deleteAllSLMPolicies() throws IOException { - Map policies; - - try { - Response response = adminClient().performRequest(new Request("GET", "/_slm/policy")); - policies = entityAsMap(response); - } catch (ResponseException e) { - if (RestStatus.METHOD_NOT_ALLOWED.getStatus() == e.getResponse().getStatusLine().getStatusCode() - || RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { - // If bad request returned, SLM is not enabled. - return; - } - throw e; - } - - if (policies == null || policies.isEmpty()) { - return; - } - - for (String policyName : policies.keySet()) { - adminClient().performRequest(new Request("DELETE", "/_slm/policy/" + policyName)); - } - } - /** * Logs a message if there are still running tasks. The reasoning is that any tasks still running are state the is trying to bleed into * other tests.