diff --git a/build.gradle b/build.gradle index 20a40c27f73de..d175d2d7b9ce7 100644 --- a/build.gradle +++ b/build.gradle @@ -48,26 +48,26 @@ import java.nio.charset.StandardCharsets import static org.opensearch.gradle.util.GradleUtils.maybeConfigure plugins { + id "test-report-aggregation" + id 'jacoco-report-aggregation' id 'lifecycle-base' id 'opensearch.docker-support' id 'opensearch.global-build-info' - id "com.diffplug.spotless" version "6.25.0" apply false - id "org.openrewrite.rewrite" version "7.11.0" apply false + id "com.diffplug.spotless" version "7.1.0" apply false id "org.gradle.test-retry" version "1.6.2" apply false - id "test-report-aggregation" - id 'jacoco-report-aggregation' + id "org.openrewrite.rewrite" version "7.11.0" apply false } apply from: 'gradle/build-complete.gradle' -apply from: 'gradle/runtime-jdk-provision.gradle' -apply from: 'gradle/ide.gradle' +apply from: 'gradle/code-convention.gradle' +apply from: 'gradle/code-coverage.gradle' apply from: 'gradle/forbidden-dependencies.gradle' apply from: 'gradle/formatting.gradle' -apply from: 'gradle/rewrite.gradle' +apply from: 'gradle/ide.gradle' apply from: 'gradle/local-distribution.gradle' -apply from: 'gradle/run.gradle' apply from: 'gradle/missing-javadoc.gradle' -apply from: 'gradle/code-coverage.gradle' +apply from: 'gradle/run.gradle' +apply from: 'gradle/runtime-jdk-provision.gradle' // common maven publishing configuration allprojects { diff --git a/client/sniffer/licenses/jackson-core-2.17.3.jar.sha1 b/client/sniffer/licenses/jackson-core-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..13c532bb8cfc9 --- /dev/null +++ b/client/sniffer/licenses/jackson-core-2.17.3.jar.sha1 @@ -0,0 +1 @@ +1d6eb3e959c737692b720d3492b2f1f34c4c8579 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index de0c203360487..88a2c7770161d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ org.gradle.caching=true org.gradle.warning.mode=none org.gradle.parallel=true # https://github.com/openrewrite/rewrite-gradle-plugin/issues/212 -#org.gradle.workers.max=3 +org.gradle.workers.max=3 org.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Xss2m \ --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \ diff --git a/gradle/code-convention.gradle b/gradle/code-convention.gradle new file mode 100644 index 0000000000000..d5cd60c1191e2 --- /dev/null +++ b/gradle/code-convention.gradle @@ -0,0 +1,69 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + * + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.opensearch.gradle.BuildPlugin + +import static java.lang.System.getenv + +allprojects { + plugins.withType(BuildPlugin).whenPluginAdded { + project.apply plugin: "org.openrewrite.rewrite" + rewrite { + activeRecipe("org.opensearch.openrewrite.recipe.CodeCleanup") + configFile = file("$rootDir/gradle/code-convention.yml") + exclusions.add("**OpenSearchTestCaseTests.java") + exclusions.add("**/simple-bulk11.json") + exclusions.add("**/simple-msearch5.json") + exclusions.add("**AbstractBenchmark.java") + exclusions.add("**ScriptClassPathResolutionContext.java") + exclusions.add("**StarTreeMapper.java") + failOnDryRunResults = true + } + repositories { + mavenCentral() + } + dependencies { + rewrite("org.openrewrite.recipe:rewrite-rewrite:0.9.0") + rewrite("org.openrewrite.recipe:rewrite-static-analysis:2.12.0") + } + tasks { + if (getenv("dogFoodDev")) { + assemble { + dependsOn(rewriteRun) + } + } + if (!getenv("skipDogFood")) { + check { + dependsOn(rewriteDryRun) + } + } + } + } +} diff --git a/gradle/code-convention.yml b/gradle/code-convention.yml new file mode 100644 index 0000000000000..329968a5d00e9 --- /dev/null +++ b/gradle/code-convention.yml @@ -0,0 +1,15 @@ +type: specs.openrewrite.org/v1beta/recipe +name: org.opensearch.openrewrite.recipe.CodeCleanup +displayName: CodeCleanup +description: Automatically cleanup code, e.g. remove unnecessary parentheses, simplify expressions. +recipeList: + - org.openrewrite.java.RemoveUnusedImports + - org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods +# - org.openrewrite.text.EndOfLineAtEndOfFile +# - org.openrewrite.java.OrderImports +# - org.openrewrite.java.format.RemoveTrailingWhitespace +# - org.openrewrite.staticanalysis.EmptyBlock +# - org.openrewrite.staticanalysis.RemoveCallsToSystemGc +# - org.openrewrite.staticanalysis.RemoveUnusedLocalVariables +# - org.openrewrite.staticanalysis.RemoveUnusedPrivateFields +# - org.openrewrite.staticanalysis.UnnecessaryThrows diff --git a/gradle/formatting.gradle b/gradle/formatting.gradle index ad8b1725244e0..af14ee4971d0f 100644 --- a/gradle/formatting.gradle +++ b/gradle/formatting.gradle @@ -30,81 +30,56 @@ import org.opensearch.gradle.BuildPlugin -/* - * This script plugin configures formatting for Java source using Spotless - * for Gradle. Since the act of formatting existing source can interfere - * with developers' workflows, we don't automatically format all code - * (yet). Instead, we maintain a list of projects that are excluded from - * formatting, until we reach a point where we can comfortably format them - * in one go without too much disruption. - * - * Any new sub-projects must not be added to the exclusions list! - * - * To perform a reformat, run: - * - * ./gradlew spotlessApply - * - * To check the current format, run: - * - * ./gradlew spotlessJavaCheck - * - * This is also carried out by the `precommit` task. - * - * For more about Spotless, see: - * - * https://github.com/diffplug/spotless/tree/master/plugin-gradle - */ +import static java.lang.System.getenv allprojects { plugins.withType(BuildPlugin).whenPluginAdded { - project.apply plugin: "com.diffplug.spotless" - - spotless { - java { - // Normally this isn't necessary, but we have Java sources in - // non-standard places - target '**/*.java' - - importOrder( - 'de.thetaphi', - 'com.carrotsearch', - 'com.fasterxml', - 'com.avast', - 'com.sun', - 'com.maxmind|com.github|com.networknt|groovy|nebula', - 'org.antlr', - 'software.amazon', - 'com.azure|com.microsoft|com.ibm|com.google|joptsimple|org.apache|org.bouncycastle|org.codehaus|org.opensearch|org.objectweb|org.joda|org.hamcrest|org.openjdk|org.gradle|org.junit', - 'javax', - 'java', - '', - '\\#java|\\#org.opensearch|\\#org.hamcrest|\\#' - ) - - eclipse().withP2Mirrors(Map.of("https://download.eclipse.org/", "https://mirror.umd.edu/eclipse/")).configFile rootProject.file('buildSrc/formatterConfig.xml') - endWithNewline() - - custom 'Refuse wildcard imports', { - // Wildcard imports can't be resolved; fail the build - if (it =~ /\s+import .*\*;/) { - throw new AssertionError("Do not use wildcard imports. 'spotlessApply' cannot resolve this issue.") - } - } - - // See DEVELOPER_GUIDE.md for details of when to enable this. - if (System.getProperty('spotless.paddedcell') != null) { - paddedCell() - } + project.apply plugin: "com.diffplug.spotless" + spotless { + java { + // Normally this isn't necessary, but we have Java sources in + // non-standard places + target '**/*.java' + importOrder( + 'de.thetaphi', + 'com.carrotsearch', + 'com.fasterxml', + 'com.avast', + 'com.sun', + 'com.maxmind|com.github|com.networknt|groovy|nebula', + 'org.antlr', + 'software.amazon', + 'com.azure|com.microsoft|com.ibm|com.google|joptsimple|org.apache|org.bouncycastle|org.codehaus|org.opensearch|org.objectweb|org.joda|org.hamcrest|org.openjdk|org.gradle|org.junit', + 'javax', + 'java', + '', + '\\#java|\\#org.opensearch|\\#org.hamcrest|\\#' + ) + eclipse().withP2Mirrors(Map.of("https://download.eclipse.org/", "https://mirror.umd.edu/eclipse/")).configFile rootProject.file('buildSrc/formatterConfig.xml') + endWithNewline() + removeWildcardImports() + // See DEVELOPER_GUIDE.md for details of when to enable this. + if (System.getProperty('spotless.paddedcell') != null) { + paddedCell() } - format 'misc', { - target '*.md', '*.gradle', '**/*.json', '**/*.yaml', '**/*.yml', '**/*.svg' - - targetExclude '**/simple-bulk11.json', '**/simple-msearch5.json' - - endWithNewline() + } + format 'misc', { + target '*.md', '*.gradle', '**/*.json', '**/*.yaml', '**/*.yml', '**/*.svg' + targetExclude '**/simple-bulk11.json', '**/simple-msearch5.json' + endWithNewline() + } + } + tasks { + if (getenv("dogFoodDev")) { + assemble { + dependsOn(spotlessJavaApply) } } - - precommit.dependsOn 'spotlessJavaCheck' + if (!getenv("skipDogFood")) { + check { + dependsOn(spotlessJavaCheck) + } + } + } } } diff --git a/libs/core/licenses/jackson-core-2.17.3.jar.sha1 b/libs/core/licenses/jackson-core-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..13c532bb8cfc9 --- /dev/null +++ b/libs/core/licenses/jackson-core-2.17.3.jar.sha1 @@ -0,0 +1 @@ +1d6eb3e959c737692b720d3492b2f1f34c4c8579 \ No newline at end of file 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/libs/x-content/licenses/jackson-core-2.17.3.jar.sha1 b/libs/x-content/licenses/jackson-core-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..13c532bb8cfc9 --- /dev/null +++ b/libs/x-content/licenses/jackson-core-2.17.3.jar.sha1 @@ -0,0 +1 @@ +1d6eb3e959c737692b720d3492b2f1f34c4c8579 \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-dataformat-cbor-2.17.3.jar.sha1 b/libs/x-content/licenses/jackson-dataformat-cbor-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..6ff493a7256c9 --- /dev/null +++ b/libs/x-content/licenses/jackson-dataformat-cbor-2.17.3.jar.sha1 @@ -0,0 +1 @@ +5286b5df35824b8c2a8ceae9a54e99dca9220e15 \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-dataformat-smile-2.17.3.jar.sha1 b/libs/x-content/licenses/jackson-dataformat-smile-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..7d71c29876246 --- /dev/null +++ b/libs/x-content/licenses/jackson-dataformat-smile-2.17.3.jar.sha1 @@ -0,0 +1 @@ +cd19020c7bace93ce269e85ac6fee782a6bf4e16 \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-dataformat-yaml-2.17.3.jar.sha1 b/libs/x-content/licenses/jackson-dataformat-yaml-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..332ff6d34fdc1 --- /dev/null +++ b/libs/x-content/licenses/jackson-dataformat-yaml-2.17.3.jar.sha1 @@ -0,0 +1 @@ +536e9d9ee966cf40a8b5d2f9ba505551364d0ad5 \ No newline at end of file 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 2dc115b73c378..eb7f46e648516 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 @@ -2600,17 +2600,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/modules/ingest-geoip/licenses/jackson-annotations-2.17.3.jar.sha1 b/modules/ingest-geoip/licenses/jackson-annotations-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c96fec30e5fc5 --- /dev/null +++ b/modules/ingest-geoip/licenses/jackson-annotations-2.17.3.jar.sha1 @@ -0,0 +1 @@ +4f30a05d2eee0ab700cdc27aa5967e934d3042b2 \ No newline at end of file diff --git a/modules/ingest-geoip/licenses/jackson-databind-2.17.3.jar.sha1 b/modules/ingest-geoip/licenses/jackson-databind-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c310f4f68ca92 --- /dev/null +++ b/modules/ingest-geoip/licenses/jackson-databind-2.17.3.jar.sha1 @@ -0,0 +1 @@ +42c617beb411ee813bdc39a287424bfb19d99185 \ No newline at end of file diff --git a/modules/ingest-geoip/licenses/jackson-datatype-jsr310-2.17.3.jar.sha1 b/modules/ingest-geoip/licenses/jackson-datatype-jsr310-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..6d0a55ebdd7a4 --- /dev/null +++ b/modules/ingest-geoip/licenses/jackson-datatype-jsr310-2.17.3.jar.sha1 @@ -0,0 +1 @@ +a25fe2f5607fea9e00ed00cf81b7aa2eaacbbd6e \ No newline at end of file diff --git a/modules/lang-expression/licenses/asm-9.8.jar.sha1 b/modules/lang-expression/licenses/asm-9.8.jar.sha1 new file mode 100644 index 0000000000000..24005efca428d --- /dev/null +++ b/modules/lang-expression/licenses/asm-9.8.jar.sha1 @@ -0,0 +1 @@ +dc19ecb3f7889b7860697215cae99c0f9b6f6b4b \ No newline at end of file diff --git a/modules/lang-painless/licenses/asm-9.8.jar.sha1 b/modules/lang-painless/licenses/asm-9.8.jar.sha1 new file mode 100644 index 0000000000000..24005efca428d --- /dev/null +++ b/modules/lang-painless/licenses/asm-9.8.jar.sha1 @@ -0,0 +1 @@ +dc19ecb3f7889b7860697215cae99c0f9b6f6b4b \ No newline at end of file diff --git a/modules/lang-painless/licenses/asm-util-9.8.jar.sha1 b/modules/lang-painless/licenses/asm-util-9.8.jar.sha1 new file mode 100644 index 0000000000000..bd60871d16324 --- /dev/null +++ b/modules/lang-painless/licenses/asm-util-9.8.jar.sha1 @@ -0,0 +1 @@ +395f1c1f035258511f27bc9b2583d76e4b143f59 \ No newline at end of file diff --git a/plugins/arrow-flight-rpc/licenses/error_prone_annotations-2.36.0.jar.sha1 b/plugins/arrow-flight-rpc/licenses/error_prone_annotations-2.36.0.jar.sha1 new file mode 100644 index 0000000000000..2770835697e79 --- /dev/null +++ b/plugins/arrow-flight-rpc/licenses/error_prone_annotations-2.36.0.jar.sha1 @@ -0,0 +1 @@ +227d4d4957ccc3dc5761bd897e3a0ee587e750a7 \ No newline at end of file diff --git a/plugins/arrow-flight-rpc/licenses/jackson-annotations-2.17.3.jar.sha1 b/plugins/arrow-flight-rpc/licenses/jackson-annotations-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c96fec30e5fc5 --- /dev/null +++ b/plugins/arrow-flight-rpc/licenses/jackson-annotations-2.17.3.jar.sha1 @@ -0,0 +1 @@ +4f30a05d2eee0ab700cdc27aa5967e934d3042b2 \ No newline at end of file diff --git a/plugins/arrow-flight-rpc/licenses/jackson-databind-2.17.3.jar.sha1 b/plugins/arrow-flight-rpc/licenses/jackson-databind-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c310f4f68ca92 --- /dev/null +++ b/plugins/arrow-flight-rpc/licenses/jackson-databind-2.17.3.jar.sha1 @@ -0,0 +1 @@ +42c617beb411ee813bdc39a287424bfb19d99185 \ No newline at end of file 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/arrow-flight-rpc/src/test/java/org/opensearch/arrow/flight/impl/BaseFlightProducerTests.java b/plugins/arrow-flight-rpc/src/test/java/org/opensearch/arrow/flight/impl/BaseFlightProducerTests.java index 65caae55e9e40..5b0ccccb0c5d3 100644 --- a/plugins/arrow-flight-rpc/src/test/java/org/opensearch/arrow/flight/impl/BaseFlightProducerTests.java +++ b/plugins/arrow-flight-rpc/src/test/java/org/opensearch/arrow/flight/impl/BaseFlightProducerTests.java @@ -566,8 +566,9 @@ public void testGetFlightInfo_LocationNotFound() { } public void testGetFlightInfo_SchemaError() { - when(streamManager.getStreamProducer(any(FlightStreamTicket.class))) - .thenReturn(Optional.of(FlightStreamManager.StreamProducerHolder.create(streamProducer, allocator))); + when(streamManager.getStreamProducer(any(FlightStreamTicket.class))).thenReturn( + Optional.of(FlightStreamManager.StreamProducerHolder.create(streamProducer, allocator)) + ); Location location = Location.forGrpcInsecure("localhost", 8815); when(flightClientManager.getFlightClientLocation(LOCAL_NODE_ID)).thenReturn(Optional.of(location)); when(streamProducer.createRoot(allocator)).thenReturn(mock(VectorSchemaRoot.class)); diff --git a/plugins/arrow-flight-rpc/src/test/java/org/opensearch/arrow/flight/impl/FlightStreamReaderTests.java b/plugins/arrow-flight-rpc/src/test/java/org/opensearch/arrow/flight/impl/FlightStreamReaderTests.java index f8bb592662a85..2a879635e186d 100644 --- a/plugins/arrow-flight-rpc/src/test/java/org/opensearch/arrow/flight/impl/FlightStreamReaderTests.java +++ b/plugins/arrow-flight-rpc/src/test/java/org/opensearch/arrow/flight/impl/FlightStreamReaderTests.java @@ -58,7 +58,7 @@ public void tearDown() throws Exception { public void testNext_ReturnsTrue_WhenFlightStreamHasNext() throws Exception { when(mockFlightStream.next()).thenReturn(true); assertTrue(iterator.next()); - assert(mockFlightStream).next(); + assert (mockFlightStream).next(); } public void testNext_ReturnsFalse_WhenFlightStreamHasNoNext() throws Exception { 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/plugins/crypto-kms/licenses/jackson-annotations-2.17.3.jar.sha1 b/plugins/crypto-kms/licenses/jackson-annotations-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c96fec30e5fc5 --- /dev/null +++ b/plugins/crypto-kms/licenses/jackson-annotations-2.17.3.jar.sha1 @@ -0,0 +1 @@ +4f30a05d2eee0ab700cdc27aa5967e934d3042b2 \ No newline at end of file diff --git a/plugins/crypto-kms/licenses/jackson-databind-2.17.3.jar.sha1 b/plugins/crypto-kms/licenses/jackson-databind-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c310f4f68ca92 --- /dev/null +++ b/plugins/crypto-kms/licenses/jackson-databind-2.17.3.jar.sha1 @@ -0,0 +1 @@ +42c617beb411ee813bdc39a287424bfb19d99185 \ No newline at end of file diff --git a/plugins/discovery-ec2/licenses/jackson-annotations-2.17.3.jar.sha1 b/plugins/discovery-ec2/licenses/jackson-annotations-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c96fec30e5fc5 --- /dev/null +++ b/plugins/discovery-ec2/licenses/jackson-annotations-2.17.3.jar.sha1 @@ -0,0 +1 @@ +4f30a05d2eee0ab700cdc27aa5967e934d3042b2 \ No newline at end of file diff --git a/plugins/discovery-ec2/licenses/jackson-databind-2.17.3.jar.sha1 b/plugins/discovery-ec2/licenses/jackson-databind-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c310f4f68ca92 --- /dev/null +++ b/plugins/discovery-ec2/licenses/jackson-databind-2.17.3.jar.sha1 @@ -0,0 +1 @@ +42c617beb411ee813bdc39a287424bfb19d99185 \ No newline at end of file diff --git a/plugins/ingestion-kinesis/licenses/jackson-annotations-2.17.3.jar.sha1 b/plugins/ingestion-kinesis/licenses/jackson-annotations-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c96fec30e5fc5 --- /dev/null +++ b/plugins/ingestion-kinesis/licenses/jackson-annotations-2.17.3.jar.sha1 @@ -0,0 +1 @@ +4f30a05d2eee0ab700cdc27aa5967e934d3042b2 \ No newline at end of file diff --git a/plugins/ingestion-kinesis/licenses/jackson-databind-2.17.3.jar.sha1 b/plugins/ingestion-kinesis/licenses/jackson-databind-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c310f4f68ca92 --- /dev/null +++ b/plugins/ingestion-kinesis/licenses/jackson-databind-2.17.3.jar.sha1 @@ -0,0 +1 @@ +42c617beb411ee813bdc39a287424bfb19d99185 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/asm-9.8.jar.sha1 b/plugins/repository-azure/licenses/asm-9.8.jar.sha1 new file mode 100644 index 0000000000000..24005efca428d --- /dev/null +++ b/plugins/repository-azure/licenses/asm-9.8.jar.sha1 @@ -0,0 +1 @@ +dc19ecb3f7889b7860697215cae99c0f9b6f6b4b \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-annotations-2.17.3.jar.sha1 b/plugins/repository-azure/licenses/jackson-annotations-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c96fec30e5fc5 --- /dev/null +++ b/plugins/repository-azure/licenses/jackson-annotations-2.17.3.jar.sha1 @@ -0,0 +1 @@ +4f30a05d2eee0ab700cdc27aa5967e934d3042b2 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-databind-2.17.3.jar.sha1 b/plugins/repository-azure/licenses/jackson-databind-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c310f4f68ca92 --- /dev/null +++ b/plugins/repository-azure/licenses/jackson-databind-2.17.3.jar.sha1 @@ -0,0 +1 @@ +42c617beb411ee813bdc39a287424bfb19d99185 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-dataformat-xml-2.17.3.jar.sha1 b/plugins/repository-azure/licenses/jackson-dataformat-xml-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..9b2965f3efca0 --- /dev/null +++ b/plugins/repository-azure/licenses/jackson-dataformat-xml-2.17.3.jar.sha1 @@ -0,0 +1 @@ +cae13eba442238be7f265dd7c5681a63fb22bf71 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-datatype-jsr310-2.17.3.jar.sha1 b/plugins/repository-azure/licenses/jackson-datatype-jsr310-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..6d0a55ebdd7a4 --- /dev/null +++ b/plugins/repository-azure/licenses/jackson-datatype-jsr310-2.17.3.jar.sha1 @@ -0,0 +1 @@ +a25fe2f5607fea9e00ed00cf81b7aa2eaacbbd6e \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.17.3.jar.sha1 b/plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c8766eb9dcbdd --- /dev/null +++ b/plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.17.3.jar.sha1 @@ -0,0 +1 @@ +0ba7b7b68e0c564dd69ba757bdfc93b04e884478 \ No newline at end of file diff --git a/plugins/repository-s3/licenses/jackson-annotations-2.17.3.jar.sha1 b/plugins/repository-s3/licenses/jackson-annotations-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c96fec30e5fc5 --- /dev/null +++ b/plugins/repository-s3/licenses/jackson-annotations-2.17.3.jar.sha1 @@ -0,0 +1 @@ +4f30a05d2eee0ab700cdc27aa5967e934d3042b2 \ No newline at end of file diff --git a/plugins/repository-s3/licenses/jackson-databind-2.17.3.jar.sha1 b/plugins/repository-s3/licenses/jackson-databind-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..c310f4f68ca92 --- /dev/null +++ b/plugins/repository-s3/licenses/jackson-databind-2.17.3.jar.sha1 @@ -0,0 +1 @@ +42c617beb411ee813bdc39a287424bfb19d99185 \ No newline at end of file diff --git a/plugins/transport-grpc/licenses/error_prone_annotations-2.36.0.jar.sha1 b/plugins/transport-grpc/licenses/error_prone_annotations-2.36.0.jar.sha1 new file mode 100644 index 0000000000000..2770835697e79 --- /dev/null +++ b/plugins/transport-grpc/licenses/error_prone_annotations-2.36.0.jar.sha1 @@ -0,0 +1 @@ +227d4d4957ccc3dc5761bd897e3a0ee587e750a7 \ No newline at end of file diff --git a/server/licenses/jackson-core-2.17.3.jar.sha1 b/server/licenses/jackson-core-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..13c532bb8cfc9 --- /dev/null +++ b/server/licenses/jackson-core-2.17.3.jar.sha1 @@ -0,0 +1 @@ +1d6eb3e959c737692b720d3492b2f1f34c4c8579 \ No newline at end of file diff --git a/server/licenses/jackson-dataformat-cbor-2.17.3.jar.sha1 b/server/licenses/jackson-dataformat-cbor-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..6ff493a7256c9 --- /dev/null +++ b/server/licenses/jackson-dataformat-cbor-2.17.3.jar.sha1 @@ -0,0 +1 @@ +5286b5df35824b8c2a8ceae9a54e99dca9220e15 \ No newline at end of file diff --git a/server/licenses/jackson-dataformat-smile-2.17.3.jar.sha1 b/server/licenses/jackson-dataformat-smile-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..7d71c29876246 --- /dev/null +++ b/server/licenses/jackson-dataformat-smile-2.17.3.jar.sha1 @@ -0,0 +1 @@ +cd19020c7bace93ce269e85ac6fee782a6bf4e16 \ No newline at end of file diff --git a/server/licenses/jackson-dataformat-yaml-2.17.3.jar.sha1 b/server/licenses/jackson-dataformat-yaml-2.17.3.jar.sha1 new file mode 100644 index 0000000000000..332ff6d34fdc1 --- /dev/null +++ b/server/licenses/jackson-dataformat-yaml-2.17.3.jar.sha1 @@ -0,0 +1 @@ +536e9d9ee966cf40a8b5d2f9ba505551364d0ad5 \ No newline at end of file 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 912c48d7bbdfe..f428eeace7410 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/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java index 89c73d2e59485..3f8e14d116a73 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java @@ -398,28 +398,4 @@ private void createIndexMappingsFromObjectType(String indexName, List ty indexRequestBuilder.setMapping(mappings.toArray(new String[0])).get(); ensureGreen(); } - - // Convert Integer, Short, Byte and Boolean to Int in order to match the conversion done - // by the internal hits when populating the sort values. - private List convertSortValues(List sortValues) { - List converted = new ArrayList<>(); - for (int i = 0; i < sortValues.size(); i++) { - Object from = sortValues.get(i); - if (from instanceof Short) { - converted.add(((Short) from).intValue()); - } else if (from instanceof Byte) { - converted.add(((Byte) from).intValue()); - } else if (from instanceof Boolean) { - boolean b = (boolean) from; - if (b) { - converted.add(1); - } else { - converted.add(0); - } - } else { - converted.add(from); - } - } - return converted; - } } 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 4e284f1fe5c3e..a6e6679b9e272 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/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/action/admin/indices/create/TransportCreateIndexActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/create/TransportCreateIndexActionTests.java index 5b5c8e5954157..708245f952105 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/create/TransportCreateIndexActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/create/TransportCreateIndexActionTests.java @@ -83,11 +83,7 @@ public void testClusterManagerOperation_usesTransformedMapping() { // Capture ActionListener passed to applyTransformers final ArgumentCaptor> listenerCaptor = ArgumentCaptor.forClass(ActionListener.class); - doNothing().when(mappingTransformerRegistry).applyTransformers( - anyString(), - any(), - listenerCaptor.capture() - ); + doNothing().when(mappingTransformerRegistry).applyTransformers(anyString(), any(), listenerCaptor.capture()); // Act: Call the method action.clusterManagerOperation(request, clusterState, responseListener); @@ -96,8 +92,9 @@ public void testClusterManagerOperation_usesTransformedMapping() { listenerCaptor.getValue().onResponse(transformedMapping); // Assert: Capture request sent to createIndexService - ArgumentCaptor updateRequestCaptor = - ArgumentCaptor.forClass(CreateIndexClusterStateUpdateRequest.class); + ArgumentCaptor updateRequestCaptor = ArgumentCaptor.forClass( + CreateIndexClusterStateUpdateRequest.class + ); verify(createIndexService, times(1)).createIndex(updateRequestCaptor.capture(), any()); // Ensure transformed mapping is passed correctly 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..023d9b983afc4 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); @@ -800,9 +791,7 @@ public void testDeleteStaleIndexRoutingPathsThrowsIOException() throws IOExcepti doThrow(new IOException("test exception")).when(blobContainer).deleteBlobsIgnoringIfNotExists(Mockito.anyList()); remoteRoutingTableService.doStart(); - IOException thrown = assertThrows(IOException.class, () -> { - remoteRoutingTableService.deleteStaleIndexRoutingPaths(stalePaths); - }); + IOException thrown = assertThrows(IOException.class, () -> { remoteRoutingTableService.deleteStaleIndexRoutingPaths(stalePaths); }); assertEquals("test exception", thrown.getMessage()); verify(blobContainer).deleteBlobsIgnoringIfNotExists(stalePaths); } @@ -823,9 +812,10 @@ public void testDeleteStaleIndexRoutingDiffPathsThrowsIOException() throws IOExc doThrow(new IOException("test exception")).when(blobContainer).deleteBlobsIgnoringIfNotExists(Mockito.anyList()); remoteRoutingTableService.doStart(); - IOException thrown = assertThrows(IOException.class, () -> { - remoteRoutingTableService.deleteStaleIndexRoutingDiffPaths(stalePaths); - }); + IOException thrown = assertThrows( + IOException.class, + () -> { remoteRoutingTableService.deleteStaleIndexRoutingDiffPaths(stalePaths); } + ); assertEquals("test exception", thrown.getMessage()); verify(blobContainer).deleteBlobsIgnoringIfNotExists(stalePaths); } 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/autoforcemerge/AutoForceMergeManagerTests.java b/server/src/test/java/org/opensearch/index/autoforcemerge/AutoForceMergeManagerTests.java index 8f33c3534423a..d8044846d73cf 100644 --- a/server/src/test/java/org/opensearch/index/autoforcemerge/AutoForceMergeManagerTests.java +++ b/server/src/test/java/org/opensearch/index/autoforcemerge/AutoForceMergeManagerTests.java @@ -179,13 +179,14 @@ public void testNodeValidatorWithHealthyResources() { when(cpu.getPercent()).thenReturn((short) 50); when(jvm.getHeapUsedPercent()).thenReturn((short) 60); ThreadPoolStats stats = new ThreadPoolStats( - Arrays.asList(new ThreadPoolStats.Stats( - ThreadPool.Names.FORCE_MERGE, 1, 0, 0, 0, 1, 0, 0 - )) + Arrays.asList(new ThreadPoolStats.Stats(ThreadPool.Names.FORCE_MERGE, 1, 0, 0, 0, 1, 0, 0)) ); when(threadPool.stats()).thenReturn(stats); - AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(getConfiguredClusterSettings(true, true, Collections.emptyMap()), getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE))); + AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode( + getConfiguredClusterSettings(true, true, Collections.emptyMap()), + getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE)) + ); autoForceMergeManager.start(); assertTrue(autoForceMergeManager.getNodeValidator().validate().isAllowed()); autoForceMergeManager.close(); @@ -195,13 +196,14 @@ public void testNodeValidatorWithFeatureSwitch() { when(cpu.getPercent()).thenReturn((short) 50); when(jvm.getHeapUsedPercent()).thenReturn((short) 60); ThreadPoolStats stats = new ThreadPoolStats( - Arrays.asList(new ThreadPoolStats.Stats( - ThreadPool.Names.FORCE_MERGE, 1, 0, 0, 0, 1, 0, 0 - )) + Arrays.asList(new ThreadPoolStats.Stats(ThreadPool.Names.FORCE_MERGE, 1, 0, 0, 0, 1, 0, 0)) ); when(threadPool.stats()).thenReturn(stats); Settings settings = getConfiguredClusterSettings(false, false, Collections.emptyMap()); - AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(settings, getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE))); + AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode( + settings, + getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE)) + ); autoForceMergeManager.start(); assertFalse(autoForceMergeManager.getConfigurationValidator().validate().isAllowed()); assertNotEquals(Lifecycle.State.STARTED, ResourceTrackerProvider.resourceTrackers.cpuFiveMinute.lifecycleState()); @@ -249,7 +251,10 @@ public void testNodeValidatorWithHighCPU() { public void testNodeValidatorWithHighDiskUsage() { when(cpu.getPercent()).thenReturn((short) 50); when(disk.getAvailable()).thenReturn(new ByteSizeValue(5)); - AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(getConfiguredClusterSettings(true, true, Collections.emptyMap()), getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE))); + AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode( + getConfiguredClusterSettings(true, true, Collections.emptyMap()), + getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE)) + ); autoForceMergeManager.start(); assertFalse(autoForceMergeManager.getNodeValidator().validate().isAllowed()); autoForceMergeManager.close(); @@ -257,14 +262,17 @@ public void testNodeValidatorWithHighDiskUsage() { public void testNodeValidatorWithHighJVMUsage() { when(cpu.getPercent()).thenReturn((short) 50); - AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(getConfiguredClusterSettings(true, true, Collections.emptyMap()), getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE))); + AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode( + getConfiguredClusterSettings(true, true, Collections.emptyMap()), + getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE)) + ); autoForceMergeManager.start(); when(jvm.getHeapUsedPercent()).thenReturn((short) 90); assertFalse(autoForceMergeManager.getNodeValidator().validate().isAllowed()); - for(int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) ResourceTrackerProvider.resourceTrackers.jvmOneMinute.recordUsage(90); assertFalse(autoForceMergeManager.getNodeValidator().validate().isAllowed()); - for(int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) ResourceTrackerProvider.resourceTrackers.jvmFiveMinute.recordUsage(90); assertFalse(autoForceMergeManager.getNodeValidator().validate().isAllowed()); autoForceMergeManager.close(); @@ -274,12 +282,13 @@ public void testNodeValidatorWithInsufficientForceMergeThreads() { when(cpu.getPercent()).thenReturn((short) 50); when(jvm.getHeapUsedPercent()).thenReturn((short) 50); ThreadPoolStats stats = new ThreadPoolStats( - Arrays.asList(new ThreadPoolStats.Stats( - ThreadPool.Names.FORCE_MERGE, 1, 1, 1, 0, 1, 0, -1 - )) + Arrays.asList(new ThreadPoolStats.Stats(ThreadPool.Names.FORCE_MERGE, 1, 1, 1, 0, 1, 0, -1)) ); when(threadPool.stats()).thenReturn(stats); - AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode(getConfiguredClusterSettings(true, true, Collections.emptyMap()), getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE))); + AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode( + getConfiguredClusterSettings(true, true, Collections.emptyMap()), + getNodeWithRoles(DATA_NODE_1, Set.of(DiscoveryNodeRole.DATA_ROLE)) + ); autoForceMergeManager.start(); assertFalse(autoForceMergeManager.getNodeValidator().validate().isAllowed()); ThreadPoolStats emptyStats = new ThreadPoolStats(Collections.emptyList()); @@ -553,12 +562,7 @@ private AutoForceMergeManager clusterSetupWithNode(Settings settings, DiscoveryN when(clusterService.getSettings()).thenReturn(settings); when(clusterService.localNode()).thenReturn(node); - return new AutoForceMergeManager( - threadPool, - monitorService, - indicesService, - clusterService - ); + return new AutoForceMergeManager(threadPool, monitorService, indicesService, clusterService); } private IndexShard getShard(String indexName, TranslogStats translogStats, Integer segmentCount) { 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/compositeindex/datacube/startree/builder/StarTreesBuilderTests.java b/server/src/test/java/org/opensearch/index/compositeindex/datacube/startree/builder/StarTreesBuilderTests.java index 6c75e89959348..43578c54d4709 100644 --- a/server/src/test/java/org/opensearch/index/compositeindex/datacube/startree/builder/StarTreesBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/compositeindex/datacube/startree/builder/StarTreesBuilderTests.java @@ -104,16 +104,32 @@ public void test_buildWithNoStarTreeFields() throws IOException { public void test_getStarTreeBuilder() throws IOException { when(mapperService.getCompositeFieldTypes()).thenReturn(Set.of(starTreeFieldType)); StarTreesBuilder starTreesBuilder = new StarTreesBuilder(segmentWriteState, mapperService, new AtomicInteger()); - StarTreeBuilder starTreeBuilder = starTreesBuilder.getStarTreeBuilder(metaOut, dataOut, starTreeField, segmentWriteState, mapperService); + StarTreeBuilder starTreeBuilder = starTreesBuilder.getStarTreeBuilder( + metaOut, + dataOut, + starTreeField, + segmentWriteState, + mapperService + ); assertTrue(starTreeBuilder instanceof OnHeapStarTreeBuilder); } public void test_getStarTreeBuilder_illegalArgument() throws IOException { when(mapperService.getCompositeFieldTypes()).thenReturn(Set.of(starTreeFieldType)); - StarTreeFieldConfiguration starTreeFieldConfiguration = new StarTreeFieldConfiguration(1, new HashSet<>(), StarTreeFieldConfiguration.StarTreeBuildMode.OFF_HEAP); + StarTreeFieldConfiguration starTreeFieldConfiguration = new StarTreeFieldConfiguration( + 1, + new HashSet<>(), + StarTreeFieldConfiguration.StarTreeBuildMode.OFF_HEAP + ); StarTreeField starTreeField = new StarTreeField("star_tree", new ArrayList<>(), new ArrayList<>(), starTreeFieldConfiguration); StarTreesBuilder starTreesBuilder = new StarTreesBuilder(segmentWriteState, mapperService, new AtomicInteger()); - StarTreeBuilder starTreeBuilder = starTreesBuilder.getStarTreeBuilder(metaOut, dataOut, starTreeField, segmentWriteState, mapperService); + StarTreeBuilder starTreeBuilder = starTreesBuilder.getStarTreeBuilder( + metaOut, + dataOut, + starTreeField, + segmentWriteState, + mapperService + ); assertTrue(starTreeBuilder instanceof OffHeapStarTreeBuilder); starTreeBuilder.close(); } diff --git a/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java b/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java index d673eb49be581..3f8882c8416e0 100644 --- a/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java +++ b/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java @@ -135,9 +135,12 @@ public void testGetPrimaryTermGenerationUuid() { } public void testInitException() throws IOException { - when(remoteMetadataDirectory.listFilesByPrefixInLexicographicOrder(RemoteSegmentStoreDirectory.MetadataFilenameUtils.METADATA_PREFIX, METADATA_FILES_TO_FETCH)).thenThrow( - new IOException("Error") - ); + when( + remoteMetadataDirectory.listFilesByPrefixInLexicographicOrder( + RemoteSegmentStoreDirectory.MetadataFilenameUtils.METADATA_PREFIX, + METADATA_FILES_TO_FETCH + ) + ).thenThrow(new IOException("Error")); assertThrows(IOException.class, () -> remoteSegmentStoreDirectory.init()); } @@ -155,9 +158,12 @@ public void testInitNoMetadataFile() throws IOException { } public void testInitMultipleMetadataFile() throws IOException { - when(remoteMetadataDirectory.listFilesByPrefixInLexicographicOrder(RemoteSegmentStoreDirectory.MetadataFilenameUtils.METADATA_PREFIX, METADATA_FILES_TO_FETCH)).thenReturn( - List.of(metadataFilename, metadataFilenameDup) - ); + when( + remoteMetadataDirectory.listFilesByPrefixInLexicographicOrder( + RemoteSegmentStoreDirectory.MetadataFilenameUtils.METADATA_PREFIX, + METADATA_FILES_TO_FETCH + ) + ).thenReturn(List.of(metadataFilename, metadataFilenameDup)); assertThrows(IllegalStateException.class, () -> remoteSegmentStoreDirectory.init()); } diff --git a/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryWithPinnedTimestampTests.java b/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryWithPinnedTimestampTests.java index e71023125d4cd..2531462d21d40 100644 --- a/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryWithPinnedTimestampTests.java +++ b/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryWithPinnedTimestampTests.java @@ -187,7 +187,8 @@ public void testDeleteStaleCommitsPinnedTimestampMdFile() throws Exception { ) ).thenReturn(List.of(metadataFilename, metadataFilename2, metadataFilename3)); - long pinnedTimestampMatchingMetadataFilename2 = RemoteSegmentStoreDirectory.MetadataFilenameUtils.getTimestamp(metadataFilename2) + 10; + long pinnedTimestampMatchingMetadataFilename2 = RemoteSegmentStoreDirectory.MetadataFilenameUtils.getTimestamp(metadataFilename2) + + 10; String blobName = "snapshot1__" + pinnedTimestampMatchingMetadataFilename2; when(blobContainer.listBlobs()).thenReturn(Map.of(blobName, new PlainBlobMetadata(blobName, 100))); diff --git a/server/src/test/java/org/opensearch/indices/replication/RemoteStoreReplicationSourceTests.java b/server/src/test/java/org/opensearch/indices/replication/RemoteStoreReplicationSourceTests.java index 88c0046796ce6..45d6dadf008b3 100644 --- a/server/src/test/java/org/opensearch/indices/replication/RemoteStoreReplicationSourceTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/RemoteStoreReplicationSourceTests.java @@ -181,8 +181,12 @@ private void buildIndexShardBehavior(IndexShard mockShard, IndexShard indexShard when(mockShard.getSegmentInfosSnapshot()).thenReturn(indexShard.getSegmentInfosSnapshot()); Store remoteStore = mock(Store.class); when(mockShard.remoteStore()).thenReturn(remoteStore); - RemoteSegmentStoreDirectory remoteSegmentStoreDirectory = (RemoteSegmentStoreDirectory) ((FilterDirectory) ((FilterDirectory) indexShard.remoteStore().directory()).getDelegate()).getDelegate(); - FilterDirectory remoteStoreFilterDirectory = new RemoteStoreRefreshListenerTests.TestFilterDirectory(new RemoteStoreRefreshListenerTests.TestFilterDirectory(remoteSegmentStoreDirectory)); + RemoteSegmentStoreDirectory remoteSegmentStoreDirectory = + (RemoteSegmentStoreDirectory) ((FilterDirectory) ((FilterDirectory) indexShard.remoteStore().directory()).getDelegate()) + .getDelegate(); + FilterDirectory remoteStoreFilterDirectory = new RemoteStoreRefreshListenerTests.TestFilterDirectory( + new RemoteStoreRefreshListenerTests.TestFilterDirectory(remoteSegmentStoreDirectory) + ); when(remoteStore.directory()).thenReturn(remoteStoreFilterDirectory); } } 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 f106aaa13dc48..cb610a6139afc 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.