From d4f102bf7525d4c7ae0c42e073d35ef622298e09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 10:25:02 -0700 Subject: [PATCH 01/26] Bump org.apache.zookeeper:zookeeper from 3.8.2 to 3.9.0 in /test/fixtures/hdfs-fixture (#9146) * Bump org.apache.zookeeper:zookeeper in /test/fixtures/hdfs-fixture Bumps org.apache.zookeeper:zookeeper from 3.8.2 to 3.9.0. --- updated-dependencies: - dependency-name: org.apache.zookeeper:zookeeper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- test/fixtures/hdfs-fixture/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abf991d537b26..ff2e5c03e0338 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -92,7 +92,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Bump `io.grpc:grpc-context` from 1.46.0 to 1.56.1 ([#8726](https://github.com/opensearch-project/OpenSearch/pull/8726)) - Bump `com.netflix.nebula:gradle-info-plugin` from 12.1.5 to 12.1.6 ([#8724](https://github.com/opensearch-project/OpenSearch/pull/8724)) - Bump `commons-codec:commons-codec` from 1.15 to 1.16.0 ([#8725](https://github.com/opensearch-project/OpenSearch/pull/8725)) -- Bump `org.apache.zookeeper:zookeeper` from 3.8.1 to 3.8.2 ([#8844](https://github.com/opensearch-project/OpenSearch/pull/8844)) +- Bump `org.apache.zookeeper:zookeeper` from 3.8.1 to 3.9.0 ([#8844](https://github.com/opensearch-project/OpenSearch/pull/8844), [#9146](https://github.com/opensearch-project/OpenSearch/pull/9146)) - Bump `org.gradle.test-retry` from 1.5.3 to 1.5.4 ([#8842](https://github.com/opensearch-project/OpenSearch/pull/8842)) - Bump `com.netflix.nebula.ospackage-base` from 11.3.0 to 11.4.0 ([#8838](https://github.com/opensearch-project/OpenSearch/pull/8838)) - Bump `com.google.http-client:google-http-client-gson` from 1.43.2 to 1.43.3 ([#8840](https://github.com/opensearch-project/OpenSearch/pull/8840)) diff --git a/test/fixtures/hdfs-fixture/build.gradle b/test/fixtures/hdfs-fixture/build.gradle index b052988f88a2b..ff25e1b0852e1 100644 --- a/test/fixtures/hdfs-fixture/build.gradle +++ b/test/fixtures/hdfs-fixture/build.gradle @@ -61,7 +61,7 @@ dependencies { api "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}" api "org.eclipse.jetty:jetty-server:${versions.jetty}" api "org.eclipse.jetty.websocket:javax-websocket-server-impl:${versions.jetty}" - api 'org.apache.zookeeper:zookeeper:3.8.2' + api 'org.apache.zookeeper:zookeeper:3.9.0' api "org.apache.commons:commons-text:1.10.0" api "commons-net:commons-net:3.9.0" runtimeOnly "com.google.guava:guava:${versions.guava}" From 7655c32a441facaf627c2d703f6b39489987e542 Mon Sep 17 00:00:00 2001 From: Gagan Juneja Date: Wed, 9 Aug 2023 00:18:19 +0530 Subject: [PATCH 02/26] Adds support for tracing runnable scenarios (#8831) * Add support for tracer to create new TracerContextStorage Signed-off-by: Gagan Juneja * Updated CHANGELOG Signed-off-by: Gagan Juneja * Refactoring Signed-off-by: Gagan Juneja * Adds feature to expose current span and start span with parent Signed-off-by: Gagan Juneja * Updating the CHANGELOG Signed-off-by: Gagan Juneja * Adds feature to expose current span and start span with parent Signed-off-by: Gagan Juneja * Adds feature to expose current span and start span with parent Signed-off-by: Gagan Juneja * Update Changelog Signed-off-by: Gagan Juneja * Empty-Commit Signed-off-by: Gagan Juneja * Empty-Commit Signed-off-by: Gagan Juneja * Remove empty lines Signed-off-by: Gagan Juneja * Empty-Commit Signed-off-by: Gagan Juneja --------- Signed-off-by: Gagan Juneja Signed-off-by: Gagan Juneja Co-authored-by: Gagan Juneja --- CHANGELOG.md | 2 + .../telemetry/tracing/DefaultTracer.java | 20 ++++++- .../telemetry/tracing/SpanContext.java | 29 +++++++++ .../opensearch/telemetry/tracing/Tracer.java | 13 ++++ .../telemetry/tracing/noop/NoopTracer.java | 11 ++++ .../tracing/runnable/TraceableRunnable.java | 44 ++++++++++++++ .../tracing/runnable/package-info.java | 12 ++++ .../telemetry/tracing/DefaultTracerTests.java | 35 ++++++++++- .../tracing/TraceableRunnableTests.java | 60 +++++++++++++++++++ .../telemetry/tracing/WrappedTracer.java | 13 +++- .../telemetry/tracing/WrappedTracerTests.java | 2 +- 11 files changed, 235 insertions(+), 6 deletions(-) create mode 100644 libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java create mode 100644 libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/TraceableRunnable.java create mode 100644 libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/package-info.java create mode 100644 libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/TraceableRunnableTests.java diff --git a/CHANGELOG.md b/CHANGELOG.md index ff2e5c03e0338..e5ab51e9b162e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,11 +112,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Make Span exporter configurable ([#8620](https://github.com/opensearch-project/OpenSearch/issues/8620)) - Change InternalSignificantTerms to sum shard-level superset counts only in final reduce ([#8735](https://github.com/opensearch-project/OpenSearch/pull/8735)) - Exclude 'benchmarks' from codecov report ([#8805](https://github.com/opensearch-project/OpenSearch/pull/8805)) +- Adds support for tracing runnable scenarios ([#8831](https://github.com/opensearch-project/OpenSearch/pull/8831)) - [Refactor] MediaTypeParser to MediaTypeParserRegistry ([#8636](https://github.com/opensearch-project/OpenSearch/pull/8636)) - Create separate SourceLookup instance per segment slice in SignificantTextAggregatorFactory ([#8807](https://github.com/opensearch-project/OpenSearch/pull/8807)) - Add support for aggregation profiler with concurrent aggregation ([#8801](https://github.com/opensearch-project/OpenSearch/pull/8801)) - [Remove] Deprecated Fractional ByteSizeValue support #9005 ([#9005](https://github.com/opensearch-project/OpenSearch/pull/9005)) - Make MultiBucketConsumerService thread safe to use across slices during search ([#9047](https://github.com/opensearch-project/OpenSearch/pull/9047)) + ### Deprecated ### Removed diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java index ea59eec645420..f46c3e57b6c4b 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java @@ -37,7 +37,17 @@ public DefaultTracer(TracingTelemetry tracingTelemetry, TracerContextStorage endSpan(scopeSpan)); @@ -48,11 +58,15 @@ public void close() throws IOException { ((Closeable) tracingTelemetry).close(); } - // Visible for testing - Span getCurrentSpan() { + private Span getCurrentSpanInternal() { return tracerContextStorage.get(TracerContextStorage.CURRENT_SPAN); } + public SpanContext getCurrentSpan() { + final Span currentSpan = tracerContextStorage.get(TracerContextStorage.CURRENT_SPAN); + return (currentSpan == null) ? null : new SpanContext(currentSpan); + } + private void endSpan(Span span) { if (span != null) { span.endSpan(); diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java new file mode 100644 index 0000000000000..b849869afdc03 --- /dev/null +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/SpanContext.java @@ -0,0 +1,29 @@ +/* + * 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. + */ + +package org.opensearch.telemetry.tracing; + +/** + * Wrapped Span will be exposed to the code outside of tracing package for sharing the {@link Span} without having access to + * its properties. + */ +public final class SpanContext { + private final Span span; + + /** + * Constructor. + * @param span span to be wrapped. + */ + public SpanContext(Span span) { + this.span = span; + } + + Span getSpan() { + return span; + } +} diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Tracer.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Tracer.java index d422b58aa0a9f..96a14eaeb85dc 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Tracer.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/Tracer.java @@ -26,4 +26,17 @@ public interface Tracer extends Closeable { */ SpanScope startSpan(String spanName); + /** + * Started the {@link Span} with the given name and parent. + * @param spanName span name. + * @param parentSpan parent span. + * @return scope of the span, must be closed with explicit close or with try-with-resource + */ + SpanScope startSpan(String spanName, SpanContext parentSpan); + + /** + * Returns the current span. + * @return current wrapped span. + */ + SpanContext getCurrentSpan(); } diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java index a1768d7d59116..74480844f5a3c 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java @@ -10,6 +10,7 @@ import org.opensearch.telemetry.tracing.SpanScope; import org.opensearch.telemetry.tracing.Tracer; +import org.opensearch.telemetry.tracing.SpanContext; /** * No-op implementation of Tracer @@ -30,6 +31,16 @@ public SpanScope startSpan(String spanName) { return SpanScope.NO_OP; } + @Override + public SpanContext getCurrentSpan() { + return null; + } + + @Override + public SpanScope startSpan(String spanName, SpanContext parentSpan) { + return SpanScope.NO_OP; + } + @Override public void close() { diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/TraceableRunnable.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/TraceableRunnable.java new file mode 100644 index 0000000000000..5f179467d5426 --- /dev/null +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/TraceableRunnable.java @@ -0,0 +1,44 @@ +/* + * 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. + */ + +package org.opensearch.telemetry.tracing.runnable; + +import org.opensearch.telemetry.tracing.SpanContext; +import org.opensearch.telemetry.tracing.SpanScope; +import org.opensearch.telemetry.tracing.Tracer; + +/** + * Wraps the runnable and add instrumentation to trace the {@link Runnable} + */ +public class TraceableRunnable implements Runnable { + private final Runnable runnable; + private final SpanContext parent; + private final Tracer tracer; + private final String spanName; + + /** + * Constructor. + * @param tracer tracer + * @param spanName spanName + * @param parent parent Span. + * @param runnable runnable. + */ + public TraceableRunnable(Tracer tracer, String spanName, SpanContext parent, Runnable runnable) { + this.tracer = tracer; + this.spanName = spanName; + this.parent = parent; + this.runnable = runnable; + } + + @Override + public void run() { + try (SpanScope spanScope = tracer.startSpan(spanName, parent)) { + runnable.run(); + } + } +} diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/package-info.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/package-info.java new file mode 100644 index 0000000000000..9f696a4ac573e --- /dev/null +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/package-info.java @@ -0,0 +1,12 @@ +/* + * 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. + */ + +/** + * Contains tracing related classes + */ +package org.opensearch.telemetry.tracing.runnable; diff --git a/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java b/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java index 2b7a379b0051a..6c39b81783f65 100644 --- a/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java +++ b/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java @@ -9,9 +9,12 @@ package org.opensearch.telemetry.tracing; import org.junit.Assert; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; +import org.opensearch.test.telemetry.tracing.MockTracingTelemetry; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -40,7 +43,37 @@ public void testCreateSpan() { defaultTracer.startSpan("span_name"); - Assert.assertEquals("span_name", defaultTracer.getCurrentSpan().getSpanName()); + Assert.assertEquals("span_name", defaultTracer.getCurrentSpan().getSpan().getSpanName()); + } + + public void testCreateSpanWithParent() { + TracingTelemetry tracingTelemetry = new MockTracingTelemetry(); + DefaultTracer defaultTracer = new DefaultTracer( + tracingTelemetry, + new ThreadContextBasedTracerContextStorage(new ThreadContext(Settings.EMPTY), tracingTelemetry) + ); + + defaultTracer.startSpan("span_name", null); + + SpanContext parentSpan = defaultTracer.getCurrentSpan(); + + defaultTracer.startSpan("span_name_1", parentSpan); + + Assert.assertEquals("span_name_1", defaultTracer.getCurrentSpan().getSpan().getSpanName()); + Assert.assertEquals(parentSpan.getSpan(), defaultTracer.getCurrentSpan().getSpan().getParentSpan()); + } + + public void testCreateSpanWithNullParent() { + TracingTelemetry tracingTelemetry = new MockTracingTelemetry(); + DefaultTracer defaultTracer = new DefaultTracer( + tracingTelemetry, + new ThreadContextBasedTracerContextStorage(new ThreadContext(Settings.EMPTY), tracingTelemetry) + ); + + defaultTracer.startSpan("span_name", null); + + Assert.assertEquals("span_name", defaultTracer.getCurrentSpan().getSpan().getSpanName()); + Assert.assertEquals(null, defaultTracer.getCurrentSpan().getSpan().getParentSpan()); } public void testEndSpanByClosingScope() { diff --git a/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/TraceableRunnableTests.java b/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/TraceableRunnableTests.java new file mode 100644 index 0000000000000..28cd036d44e5e --- /dev/null +++ b/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/TraceableRunnableTests.java @@ -0,0 +1,60 @@ +/* + * 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. + */ + +package org.opensearch.telemetry.tracing; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.telemetry.tracing.runnable.TraceableRunnable; +import org.opensearch.test.OpenSearchTestCase; +import org.opensearch.test.telemetry.tracing.MockTracingTelemetry; + +public class TraceableRunnableTests extends OpenSearchTestCase { + + private final ThreadContextBasedTracerContextStorage contextStorage = new ThreadContextBasedTracerContextStorage( + new ThreadContext(Settings.EMPTY), + new MockTracingTelemetry() + ); + + public void testRunnableWithNullParent() throws Exception { + String spanName = "testRunnable"; + DefaultTracer defaultTracer = new DefaultTracer(new MockTracingTelemetry(), contextStorage); + final AtomicBoolean isRunnableCompleted = new AtomicBoolean(false); + TraceableRunnable traceableRunnable = new TraceableRunnable( + defaultTracer, + spanName, + null, + () -> { isRunnableCompleted.set(true); } + ); + traceableRunnable.run(); + assertTrue(isRunnableCompleted.get()); + assertEquals(spanName, defaultTracer.getCurrentSpan().getSpan().getSpanName()); + assertEquals(null, defaultTracer.getCurrentSpan().getSpan().getParentSpan()); + } + + public void testRunnableWithParent() throws Exception { + String spanName = "testRunnable"; + String parentSpanName = "parentSpan"; + DefaultTracer defaultTracer = new DefaultTracer(new MockTracingTelemetry(), contextStorage); + defaultTracer.startSpan(parentSpanName); + SpanContext parentSpan = defaultTracer.getCurrentSpan(); + AtomicReference currrntSpan = new AtomicReference<>(new SpanContext(null)); + final AtomicBoolean isRunnableCompleted = new AtomicBoolean(false); + TraceableRunnable traceableRunnable = new TraceableRunnable(defaultTracer, spanName, parentSpan, () -> { + isRunnableCompleted.set(true); + currrntSpan.set(defaultTracer.getCurrentSpan()); + }); + traceableRunnable.run(); + assertTrue(isRunnableCompleted.get()); + assertEquals(spanName, currrntSpan.get().getSpan().getSpanName()); + assertEquals(parentSpan.getSpan(), currrntSpan.get().getSpan().getParentSpan()); + assertEquals(parentSpan.getSpan(), defaultTracer.getCurrentSpan().getSpan()); + } +} diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java b/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java index 0ba9a8ea5fd88..f633d3ebebe86 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java @@ -36,8 +36,19 @@ public WrappedTracer(TelemetrySettings telemetrySettings, Tracer defaultTracer) @Override public SpanScope startSpan(String spanName) { + return startSpan(spanName, null); + } + + @Override + public SpanContext getCurrentSpan() { + Tracer delegateTracer = getDelegateTracer(); + return delegateTracer.getCurrentSpan(); + } + + @Override + public SpanScope startSpan(String spanName, SpanContext parentSpan) { Tracer delegateTracer = getDelegateTracer(); - return delegateTracer.startSpan(spanName); + return delegateTracer.startSpan(spanName, parentSpan); } @Override diff --git a/server/src/test/java/org/opensearch/telemetry/tracing/WrappedTracerTests.java b/server/src/test/java/org/opensearch/telemetry/tracing/WrappedTracerTests.java index d1abc5a4d98aa..50c720e1c8555 100644 --- a/server/src/test/java/org/opensearch/telemetry/tracing/WrappedTracerTests.java +++ b/server/src/test/java/org/opensearch/telemetry/tracing/WrappedTracerTests.java @@ -48,7 +48,7 @@ public void testStartSpanWithTracingEnabledInvokesDefaultTracer() throws Excepti wrappedTracer.startSpan("foo"); assertTrue(wrappedTracer.getDelegateTracer() instanceof DefaultTracer); - verify(mockDefaultTracer).startSpan("foo"); + verify(mockDefaultTracer).startSpan("foo", null); } } From 6eb87b5373ece77a9fc83dc669ec61d959c93617 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Tue, 8 Aug 2023 14:28:18 -0500 Subject: [PATCH 03/26] Reinstate maintainers from emeritus to active (#9173) This commit reinstates Rabi Panda, and Abbas Hussain as maintainers of the opensearch repository. The removing maintainers process specifies maintainer status is retained until the maintainer explicitly requests to be moved to emeritus status. This can be done by way of a PR, public issue, or email thread to the maintainers on the subproject. Signed-off-by: Nicholas Walter Knize --- MAINTAINERS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 95e87f4be43bf..cac17903b1925 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -6,6 +6,7 @@ This document contains a list of maintainers in this repo. See [opensearch-proje | Maintainer | GitHub ID | Affiliation | |--------------------------| ------------------------------------------------------- | ----------- | +| Abbas Hussain | [abbashus](https://github.com/abbashus) | Meta | | Anas Alkouz | [anasalkouz](https://github.com/anasalkouz) | Amazon | | Andrew Ross | [andrross](https://github.com/andrross) | Amazon | | Andriy Redko | [reta](https://github.com/reta) | Aiven | @@ -20,6 +21,7 @@ This document contains a list of maintainers in this repo. See [opensearch-proje | Marc Handalian | [mch2](https://github.com/mch2) | Amazon | | Nick Knize | [nknize](https://github.com/nknize) | Amazon | | Owais Kazi | [owaiskazi19](https://github.com/owaiskazi19) | Amazon | +| Rabi Panda | [adnapibar](https://github.com/adnapibar) | Independent | | Rishikesh Pasham | [Rishikesh1159](https://github.com/Rishikesh1159) | Amazon | | Ryan Bogan | [ryanbogan](https://github.com/ryanbogan) | Amazon | | Sachin Kale | [sachinpkale](https://github.com/sachinpkale) | Amazon | @@ -33,8 +35,6 @@ This document contains a list of maintainers in this repo. See [opensearch-proje ## Emeritus | Maintainer | GitHub ID | Affiliation | -|-------------------------|---------------------------------------------| ----------- | -| Abbas Hussain | [abbashus](https://github.com/abbashus) | Amazon | +|-------------------------|---------------------------------------------|-------------| | Megha Sai Kavikondala | [meghasaik](https://github.com/meghasaik) | Amazon | -| Rabi Panda | [adnapibar](https://github.com/adnapibar) | Amazon | | Xue Zhou | [xuezhou25](https://github.com/xuezhou25) | Amazon | From d252de15f510322a2aeb55b4c1995a4434074dd2 Mon Sep 17 00:00:00 2001 From: INDRAJIT BANERJEE Date: Wed, 9 Aug 2023 17:24:22 +0530 Subject: [PATCH 04/26] Fixing SnapshotResiliencyTests.testTransportGetSnapshotsAction (#9189) * Fixing flaky test testTransportGetSnapshotsAction Signed-off-by: INDRAJIT BANERJEE Signed-off-by: Indrajit Banerjee --- CHANGELOG.md | 2 +- .../snapshots/SnapshotResiliencyTests.java | 52 +++++++++---------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ab51e9b162e..dcaee5b3fc57b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -129,4 +129,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Security [Unreleased 3.0]: https://github.com/opensearch-project/OpenSearch/compare/2.x...HEAD -[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.10...2.x \ No newline at end of file +[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.10...2.x diff --git a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java index c04e2821d7931..ce918ba40d8be 100644 --- a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java @@ -798,43 +798,41 @@ public void testTransportGetSnapshotsAction() { setupTestCluster(randomFrom(1, 3, 5), randomIntBetween(2, 10)); String repoName = "repo"; - final String[] snapshotsList = { "snapshot-1", "snapshot-2" }; - final String[] indexList = { "index-1", "index-2" }; + final String[] snapshotsList = { "snapshot-1" }; + final String index = "index-1"; final int shards = randomIntBetween(1, 10); TestClusterNodes.TestClusterNode clusterManagerNode = testClusterNodes.currentClusterManager( testClusterNodes.nodes.values().iterator().next().clusterService.state() ); - for (int i = 0; i < snapshotsList.length; i++) { - final StepListener createSnapshotResponseStepListener = new StepListener<>(); - final String snapshot = snapshotsList[i]; - final String index = indexList[i]; - continueOrDie( - createRepoAndIndex(repoName, index, shards), - createSnapshotResponse -> client().admin() - .cluster() - .prepareCreateSnapshot(repoName, snapshot) - .setWaitForCompletion(true) - .execute(createSnapshotResponseStepListener) - ); - } - deterministicTaskQueue.runAllRunnableTasks(); + final StepListener createSnapshotResponseStepListener = new StepListener<>(); + final String snapshot = snapshotsList[0]; + continueOrDie( + createRepoAndIndex(repoName, index, shards), + createSnapshotResponse -> client().admin() + .cluster() + .prepareCreateSnapshot(repoName, snapshot) + .setWaitForCompletion(true) + .execute(createSnapshotResponseStepListener) + ); + + continueOrDie(createSnapshotResponseStepListener, createSnapshotResponse -> { - TransportAction getSnapshotsAction = clusterManagerNode.actions.get(GetSnapshotsAction.INSTANCE); - TransportGetSnapshotsAction transportGetSnapshotsAction = (TransportGetSnapshotsAction) getSnapshotsAction; - GetSnapshotsRequest repoSnapshotRequest = new GetSnapshotsRequest().repository(repoName).snapshots(snapshotsList); + TransportAction getSnapshotsAction = clusterManagerNode.actions.get(GetSnapshotsAction.INSTANCE); + TransportGetSnapshotsAction transportGetSnapshotsAction = (TransportGetSnapshotsAction) getSnapshotsAction; + GetSnapshotsRequest repoSnapshotRequest = new GetSnapshotsRequest().repository(repoName).snapshots(snapshotsList); - transportGetSnapshotsAction.execute(null, repoSnapshotRequest, ActionListener.wrap(repoSnapshotResponse -> { - assertNotNull("Snapshot list should not be null", repoSnapshotResponse.getSnapshots()); - assertThat(repoSnapshotResponse.getSnapshots(), hasSize(2)); - List snapshotInfos = repoSnapshotResponse.getSnapshots(); - for (SnapshotInfo snapshotInfo : snapshotInfos) { + transportGetSnapshotsAction.execute(null, repoSnapshotRequest, ActionListener.wrap(repoSnapshotResponse -> { + assertNotNull("Snapshot list should not be null", repoSnapshotResponse.getSnapshots()); + assertThat(repoSnapshotResponse.getSnapshots(), hasSize(1)); + List snapshotInfos = repoSnapshotResponse.getSnapshots(); + SnapshotInfo snapshotInfo = snapshotInfos.get(0); assertEquals(SnapshotState.SUCCESS, snapshotInfo.state()); assertEquals(0, snapshotInfo.failedShards()); - assertTrue(Arrays.stream(snapshotsList).anyMatch(snapshotInfo.snapshotId().getName()::equals)); - } - }, exception -> { throw new AssertionError(exception); })); + assertEquals(snapshotInfo.snapshotId().getName(), snapshotsList[0]); + }, exception -> { throw new AssertionError(exception); })); + }); } public void testTransportGetCurrentSnapshotsAction() { From b2af655047920774bb9db062b47a908b37740726 Mon Sep 17 00:00:00 2001 From: Poojita Raj Date: Wed, 9 Aug 2023 05:17:33 -0700 Subject: [PATCH 05/26] Mute flaky test SearchWeightedRoutingIT.testStrictWeightedRoutingWithCustomString (#9175) Signed-off-by: Poojita Raj --- .../java/org/opensearch/search/SearchWeightedRoutingIT.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/SearchWeightedRoutingIT.java b/server/src/internalClusterTest/java/org/opensearch/search/SearchWeightedRoutingIT.java index 28a4db5ecaf9d..15628500f60de 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/SearchWeightedRoutingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/SearchWeightedRoutingIT.java @@ -1090,6 +1090,7 @@ public void testMultiGetWithNetworkDisruption_FailOpenDisabled() throws Exceptio /** * Assert that preference search with custom string doesn't hit a node in weighed away az */ + @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/8030") public void testStrictWeightedRoutingWithCustomString() { Settings commonSettings = Settings.builder() .put("cluster.routing.allocation.awareness.attributes", "zone") From 7560afb4e48e3ac247c18225cdf257e1899a5641 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Aug 2023 09:31:39 -0400 Subject: [PATCH 06/26] Bump io.grpc:grpc-context from 1.56.1 to 1.57.1 in /plugins/repository-gcs (#9145) * Bump io.grpc:grpc-context in /plugins/repository-gcs Bumps [io.grpc:grpc-context](https://github.com/grpc/grpc-java) from 1.56.1 to 1.57.1. - [Release notes](https://github.com/grpc/grpc-java/releases) - [Commits](https://github.com/grpc/grpc-java/compare/v1.56.1...v1.57.1) --- updated-dependencies: - dependency-name: io.grpc:grpc-context dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Updating SHAs Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] Signed-off-by: Andriy Redko --------- Signed-off-by: dependabot[bot] Signed-off-by: Andriy Redko Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 4 ++-- plugins/repository-gcs/build.gradle | 4 ++-- plugins/repository-gcs/licenses/grpc-api-1.57.1.jar.sha1 | 1 + .../{grpc-context-LICENSE.txt => grpc-api-LICENSE.txt} | 0 .../licenses/{grpc-context-NOTICE.txt => grpc-api-NOTICE.txt} | 0 plugins/repository-gcs/licenses/grpc-context-1.56.1.jar.sha1 | 1 - 6 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 plugins/repository-gcs/licenses/grpc-api-1.57.1.jar.sha1 rename plugins/repository-gcs/licenses/{grpc-context-LICENSE.txt => grpc-api-LICENSE.txt} (100%) rename plugins/repository-gcs/licenses/{grpc-context-NOTICE.txt => grpc-api-NOTICE.txt} (100%) delete mode 100644 plugins/repository-gcs/licenses/grpc-context-1.56.1.jar.sha1 diff --git a/CHANGELOG.md b/CHANGELOG.md index dcaee5b3fc57b..63b962a8357ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,7 +89,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Dependencies - Bump `org.apache.logging.log4j:log4j-core` from 2.17.1 to 2.20.0 ([#8307](https://github.com/opensearch-project/OpenSearch/pull/8307)) -- Bump `io.grpc:grpc-context` from 1.46.0 to 1.56.1 ([#8726](https://github.com/opensearch-project/OpenSearch/pull/8726)) +- Bump `io.grpc:grpc-context` from 1.46.0 to 1.57.1 ([#8726](https://github.com/opensearch-project/OpenSearch/pull/8726), [#9145](https://github.com/opensearch-project/OpenSearch/pull/9145)) - Bump `com.netflix.nebula:gradle-info-plugin` from 12.1.5 to 12.1.6 ([#8724](https://github.com/opensearch-project/OpenSearch/pull/8724)) - Bump `commons-codec:commons-codec` from 1.15 to 1.16.0 ([#8725](https://github.com/opensearch-project/OpenSearch/pull/8725)) - Bump `org.apache.zookeeper:zookeeper` from 3.8.1 to 3.9.0 ([#8844](https://github.com/opensearch-project/OpenSearch/pull/8844), [#9146](https://github.com/opensearch-project/OpenSearch/pull/9146)) @@ -129,4 +129,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Security [Unreleased 3.0]: https://github.com/opensearch-project/OpenSearch/compare/2.x...HEAD -[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.10...2.x +[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.10...2.x \ No newline at end of file diff --git a/plugins/repository-gcs/build.gradle b/plugins/repository-gcs/build.gradle index 0fb98c8b9abff..3719637a4b33e 100644 --- a/plugins/repository-gcs/build.gradle +++ b/plugins/repository-gcs/build.gradle @@ -86,7 +86,7 @@ dependencies { api "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}" api "commons-codec:commons-codec:${versions.commonscodec}" api 'org.threeten:threetenbp:1.4.4' - api 'io.grpc:grpc-context:1.56.1' + api 'io.grpc:grpc-api:1.57.1' api 'io.opencensus:opencensus-api:0.31.1' api 'io.opencensus:opencensus-contrib-http-util:0.31.1' @@ -205,7 +205,7 @@ thirdPartyAudit { // commons-logging provided dependencies 'javax.jms.Message', 'javax.servlet.ServletContextEvent', - 'javax.servlet.ServletContextListener', + 'javax.servlet.ServletContextListener' ) } diff --git a/plugins/repository-gcs/licenses/grpc-api-1.57.1.jar.sha1 b/plugins/repository-gcs/licenses/grpc-api-1.57.1.jar.sha1 new file mode 100644 index 0000000000000..c52d208334070 --- /dev/null +++ b/plugins/repository-gcs/licenses/grpc-api-1.57.1.jar.sha1 @@ -0,0 +1 @@ +2a7f06d11b65839cf222159b4e947a22eddc59e6 \ No newline at end of file diff --git a/plugins/repository-gcs/licenses/grpc-context-LICENSE.txt b/plugins/repository-gcs/licenses/grpc-api-LICENSE.txt similarity index 100% rename from plugins/repository-gcs/licenses/grpc-context-LICENSE.txt rename to plugins/repository-gcs/licenses/grpc-api-LICENSE.txt diff --git a/plugins/repository-gcs/licenses/grpc-context-NOTICE.txt b/plugins/repository-gcs/licenses/grpc-api-NOTICE.txt similarity index 100% rename from plugins/repository-gcs/licenses/grpc-context-NOTICE.txt rename to plugins/repository-gcs/licenses/grpc-api-NOTICE.txt diff --git a/plugins/repository-gcs/licenses/grpc-context-1.56.1.jar.sha1 b/plugins/repository-gcs/licenses/grpc-context-1.56.1.jar.sha1 deleted file mode 100644 index dbc1ea470dadd..0000000000000 --- a/plugins/repository-gcs/licenses/grpc-context-1.56.1.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3681b1caf41af1da0c4a3ffec47ab4a3d907c190 \ No newline at end of file From ccf0b9a5036b8779514d4bfd9034e147e4617da8 Mon Sep 17 00:00:00 2001 From: Poojita Raj Date: Wed, 9 Aug 2023 09:04:20 -0700 Subject: [PATCH 07/26] Mute flaky test ShardMovementStrategyTests.testClusterGreenAfterPartialRelocationNoPreferenceShardMovementPrimaryFirstEnabled (#9181) Signed-off-by: Poojita Raj --- .../opensearch/cluster/routing/ShardMovementStrategyTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/test/java/org/opensearch/cluster/routing/ShardMovementStrategyTests.java b/server/src/test/java/org/opensearch/cluster/routing/ShardMovementStrategyTests.java index 12994bdfcf6d5..84c615a6459bd 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/ShardMovementStrategyTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/ShardMovementStrategyTests.java @@ -70,6 +70,7 @@ public void testClusterGreenAfterPartialRelocationReplicaFirstShardMovementPrima testClusterGreenAfterPartialRelocation(ShardMovementStrategy.REPLICA_FIRST, false); } + @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/9178") public void testClusterGreenAfterPartialRelocationNoPreferenceShardMovementPrimaryFirstEnabled() throws InterruptedException { testClusterGreenAfterPartialRelocation(ShardMovementStrategy.NO_PREFERENCE, true); } From 15b7de00f2ff75587560ac6e38ffb20da030178e Mon Sep 17 00:00:00 2001 From: Jay Deng Date: Wed, 9 Aug 2023 12:21:04 -0700 Subject: [PATCH 08/26] Do not evaluate shard_size and shard_min_doc_count at segment slice level (#9085) * Use BucketCountThresholds in InternalTerms and InternalAggregations and do not apply shard level thresholds at slice level for Concurrent Segment Search Signed-off-by: Jay Deng * Addressing comments Signed-off-by: Jay Deng * Re-introduce shardSize member to InternalMultiTerms and InternalMappedTerms Signed-off-by: Jay Deng * Introduce LocalBucketCountThresholds for local size and min_doc_count values Signed-off-by: Jay Deng --------- Signed-off-by: Jay Deng --- CHANGELOG.md | 3 +- .../aggregations/TermsReduceBenchmark.java | 6 +-- .../StringTermsSerializationBenchmark.java | 6 +-- .../AggregationCollectorManager.java | 19 +++---- .../GlobalAggCollectorManager.java | 10 ++++ .../aggregations/InternalAggregation.java | 14 ++++++ .../NonGlobalAggCollectorManager.java | 10 ++++ .../bucket/LocalBucketCountThresholds.java | 36 ++++++++++++++ .../terms/AbstractStringTermsAggregator.java | 10 ++-- .../bucket/terms/DoubleTerms.java | 20 +++----- .../GlobalOrdinalsStringTermsAggregator.java | 20 ++++---- .../terms/InternalMappedSignificantTerms.java | 7 ++- .../bucket/terms/InternalMappedTerms.java | 7 ++- .../bucket/terms/InternalMultiTerms.java | 17 +++---- .../terms/InternalSignificantTerms.java | 29 +++++++++-- .../bucket/terms/InternalTerms.java | 32 ++++++++---- .../aggregations/bucket/terms/LongTerms.java | 25 ++++------ .../terms/MapStringTermsAggregator.java | 16 +++--- .../bucket/terms/MultiTermsAggregator.java | 16 +++--- .../bucket/terms/NumericTermsAggregator.java | 49 +++++++++---------- .../bucket/terms/SignificantLongTerms.java | 17 +++---- .../bucket/terms/SignificantStringTerms.java | 17 +++---- .../SignificantTermsAggregatorFactory.java | 7 +-- .../bucket/terms/StringTerms.java | 20 +++----- .../bucket/terms/TermsAggregator.java | 25 ++++++++++ .../bucket/terms/TermsAggregatorFactory.java | 8 +-- .../terms/UnmappedSignificantTerms.java | 12 +++-- .../bucket/terms/UnmappedTerms.java | 13 +++-- .../bucket/terms/UnsignedLongTerms.java | 25 ++++------ .../search/internal/SearchContext.java | 14 ++++++ .../InternalAggregationsTests.java | 11 ++--- .../InternalMultiBucketAggregationTests.java | 12 ++--- .../bucket/terms/DoubleTermsTests.java | 18 ++++--- .../bucket/terms/InternalMultiTermsTests.java | 11 +++-- .../InternalSignificantTermsTestCase.java | 2 +- .../bucket/terms/InternalTermsTestCase.java | 2 +- .../bucket/terms/LongTermsTests.java | 18 ++++--- .../terms/SignificanceHeuristicTests.java | 32 +++++++++--- .../terms/SignificantLongTermsTests.java | 19 +++++-- .../terms/SignificantStringTermsTests.java | 12 ++--- .../bucket/terms/StringTermsTests.java | 18 ++++--- .../bucket/terms/UnsignedLongTermsTests.java | 18 ++++--- .../aggregations/AggregatorTestCase.java | 1 + 43 files changed, 411 insertions(+), 273 deletions(-) create mode 100644 server/src/main/java/org/opensearch/search/aggregations/bucket/LocalBucketCountThresholds.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 63b962a8357ec..3799b8a2db9bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,6 +118,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Add support for aggregation profiler with concurrent aggregation ([#8801](https://github.com/opensearch-project/OpenSearch/pull/8801)) - [Remove] Deprecated Fractional ByteSizeValue support #9005 ([#9005](https://github.com/opensearch-project/OpenSearch/pull/9005)) - Make MultiBucketConsumerService thread safe to use across slices during search ([#9047](https://github.com/opensearch-project/OpenSearch/pull/9047)) +- Change shard_size and shard_min_doc_count evaluation to happen in shard level reduce phase ([#9085](https://github.com/opensearch-project/OpenSearch/pull/9085)) ### Deprecated @@ -129,4 +130,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Security [Unreleased 3.0]: https://github.com/opensearch-project/OpenSearch/compare/2.x...HEAD -[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.10...2.x \ No newline at end of file +[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.10...2.x diff --git a/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/TermsReduceBenchmark.java b/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/TermsReduceBenchmark.java index b18ea4327cbc2..180676e7b2ed2 100644 --- a/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/TermsReduceBenchmark.java +++ b/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/TermsReduceBenchmark.java @@ -57,6 +57,7 @@ import org.opensearch.search.aggregations.InternalAggregations; import org.opensearch.search.aggregations.MultiBucketConsumerService; import org.opensearch.search.aggregations.bucket.terms.StringTerms; +import org.opensearch.search.aggregations.bucket.terms.TermsAggregator; import org.opensearch.search.aggregations.pipeline.PipelineAggregator; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.search.query.QuerySearchResult; @@ -170,15 +171,14 @@ private StringTerms newTerms(Random rand, BytesRef[] dict, boolean withNested) { "terms", BucketOrder.key(true), BucketOrder.count(false), - topNSize, - 1, Collections.emptyMap(), DocValueFormat.RAW, numShards, true, 0, buckets, - 0 + 0, + new TermsAggregator.BucketCountThresholds(1, 0, topNSize, numShards) ); } diff --git a/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/bucket/terms/StringTermsSerializationBenchmark.java b/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/bucket/terms/StringTermsSerializationBenchmark.java index 8f86a0f3afbc6..8d528d94e463e 100644 --- a/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/bucket/terms/StringTermsSerializationBenchmark.java +++ b/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/bucket/terms/StringTermsSerializationBenchmark.java @@ -51,6 +51,7 @@ import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; +import org.opensearch.search.aggregations.bucket.terms.TermsAggregator; import java.util.ArrayList; import java.util.List; @@ -86,15 +87,14 @@ private StringTerms newTerms(boolean withNested) { "test", BucketOrder.key(true), BucketOrder.key(true), - buckets, - 1, null, DocValueFormat.RAW, buckets, false, 100000, resultBuckets, - 0 + 0, + new TermsAggregator.BucketCountThresholds(1, 0, buckets, buckets) ); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/AggregationCollectorManager.java b/server/src/main/java/org/opensearch/search/aggregations/AggregationCollectorManager.java index 1f60ff6503ca8..ae06f80516e3e 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/AggregationCollectorManager.java +++ b/server/src/main/java/org/opensearch/search/aggregations/AggregationCollectorManager.java @@ -26,7 +26,7 @@ * aggregation operators */ class AggregationCollectorManager implements CollectorManager { - private final SearchContext context; + protected final SearchContext context; private final CheckedFunction, IOException> aggProvider; private final String collectorReason; @@ -63,18 +63,11 @@ public ReduceableSearchResult reduce(Collection collectors) throws IO } final InternalAggregations internalAggregations = InternalAggregations.from(internals); - // Reduce the aggregations across slices before sending to the coordinator. We will perform shard level reduce iff multiple slices - // were created to execute this request and it used concurrent segment search path - // TODO: Add the check for flag that the request was executed using concurrent search - if (collectors.size() > 1) { - // using reduce is fine here instead of topLevelReduce as pipeline aggregation is evaluated on the coordinator after all - // documents are collected across shards for an aggregation - return new AggregationReduceableSearchResult( - InternalAggregations.reduce(Collections.singletonList(internalAggregations), context.partialOnShard()) - ); - } else { - return new AggregationReduceableSearchResult(internalAggregations); - } + return buildAggregationResult(internalAggregations); + } + + protected AggregationReduceableSearchResult buildAggregationResult(InternalAggregations internalAggregations) { + return new AggregationReduceableSearchResult(internalAggregations); } static Collector createCollector(SearchContext context, List collectors, String reason) throws IOException { diff --git a/server/src/main/java/org/opensearch/search/aggregations/GlobalAggCollectorManager.java b/server/src/main/java/org/opensearch/search/aggregations/GlobalAggCollectorManager.java index 56f53a57a8573..41e8aba895480 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/GlobalAggCollectorManager.java +++ b/server/src/main/java/org/opensearch/search/aggregations/GlobalAggCollectorManager.java @@ -14,6 +14,7 @@ import org.opensearch.search.profile.query.CollectorResult; import java.io.IOException; +import java.util.Collections; import java.util.Objects; /** @@ -38,4 +39,13 @@ public Collector newCollector() throws IOException { return super.newCollector(); } } + + @Override + protected AggregationReduceableSearchResult buildAggregationResult(InternalAggregations internalAggregations) { + // Reduce the aggregations across slices before sending to the coordinator. We will perform shard level reduce as long as any slices + // were created so that we can apply shard level bucket count thresholds in the reduce phase. + return new AggregationReduceableSearchResult( + InternalAggregations.reduce(Collections.singletonList(internalAggregations), context.partialOnShard()) + ); + } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/InternalAggregation.java b/server/src/main/java/org/opensearch/search/aggregations/InternalAggregation.java index 999ed458f2388..d1de09cffd674 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/InternalAggregation.java +++ b/server/src/main/java/org/opensearch/search/aggregations/InternalAggregation.java @@ -40,6 +40,8 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.rest.action.search.RestSearchAction; import org.opensearch.script.ScriptService; +import org.opensearch.search.aggregations.bucket.LocalBucketCountThresholds; +import org.opensearch.search.aggregations.bucket.terms.TermsAggregator; import org.opensearch.search.aggregations.pipeline.PipelineAggregator; import org.opensearch.search.aggregations.pipeline.PipelineAggregator.PipelineTree; import org.opensearch.search.aggregations.support.AggregationPath; @@ -160,6 +162,18 @@ public boolean isSliceLevel() { return this.isSliceLevel; } + /** + * For slice level partial reduce we will apply shard level `shard_size` and `shard_min_doc_count` limits + * whereas for coordinator level partial reduce it will use top level `size` and `min_doc_count` + */ + public LocalBucketCountThresholds asLocalBucketCountThresholds(TermsAggregator.BucketCountThresholds bucketCountThresholds) { + if (isSliceLevel()) { + return new LocalBucketCountThresholds(bucketCountThresholds.getShardMinDocCount(), bucketCountThresholds.getShardSize()); + } else { + return new LocalBucketCountThresholds(bucketCountThresholds.getMinDocCount(), bucketCountThresholds.getRequiredSize()); + } + } + public BigArrays bigArrays() { return bigArrays; } diff --git a/server/src/main/java/org/opensearch/search/aggregations/NonGlobalAggCollectorManager.java b/server/src/main/java/org/opensearch/search/aggregations/NonGlobalAggCollectorManager.java index 3729734c48ed7..984eefb9b52a4 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/NonGlobalAggCollectorManager.java +++ b/server/src/main/java/org/opensearch/search/aggregations/NonGlobalAggCollectorManager.java @@ -14,6 +14,7 @@ import org.opensearch.search.profile.query.CollectorResult; import java.io.IOException; +import java.util.Collections; import java.util.Objects; /** @@ -38,4 +39,13 @@ public Collector newCollector() throws IOException { return super.newCollector(); } } + + @Override + protected AggregationReduceableSearchResult buildAggregationResult(InternalAggregations internalAggregations) { + // Reduce the aggregations across slices before sending to the coordinator. We will perform shard level reduce as long as any slices + // were created so that we can apply shard level bucket count thresholds in the reduce phase. + return new AggregationReduceableSearchResult( + InternalAggregations.reduce(Collections.singletonList(internalAggregations), context.partialOnShard()) + ); + } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/LocalBucketCountThresholds.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/LocalBucketCountThresholds.java new file mode 100644 index 0000000000000..98dc07cec49ab --- /dev/null +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/LocalBucketCountThresholds.java @@ -0,0 +1,36 @@ +/* + * 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. + */ + +package org.opensearch.search.aggregations.bucket; + +import org.opensearch.search.aggregations.bucket.terms.TermsAggregator; + +/** + * BucketCountThresholds type that holds the local (either shard level or request level) bucket count thresholds in minDocCount and requireSize fields. + * Similar to {@link TermsAggregator.BucketCountThresholds} however only provides getters for the local members and no setters. + * + * @opensearch.internal + */ +public class LocalBucketCountThresholds { + + private final long minDocCount; + private final int requiredSize; + + public LocalBucketCountThresholds(long localminDocCount, int localRequiredSize) { + this.minDocCount = localminDocCount; + this.requiredSize = localRequiredSize; + } + + public int getRequiredSize() { + return requiredSize; + } + + public long getMinDocCount() { + return minDocCount; + } +} diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/AbstractStringTermsAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/AbstractStringTermsAggregator.java index 9551be10e52b8..d06a0ed9976fc 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/AbstractStringTermsAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/AbstractStringTermsAggregator.java @@ -76,15 +76,14 @@ protected StringTerms buildEmptyTermsAggregation() { name, order, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, bucketCountThresholds.getShardSize(), showTermDocCountError, 0, emptyList(), - 0 + 0, + bucketCountThresholds ); } @@ -95,14 +94,13 @@ protected SignificantStringTerms buildEmptySignificantTermsAggregation(long subs int supersetSize = topReader.numDocs(); return new SignificantStringTerms( name, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, subsetSize, supersetSize, significanceHeuristic, - emptyList() + emptyList(), + bucketCountThresholds ); } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/DoubleTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/DoubleTerms.java index 0b76c302801af..de02d5a938644 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/DoubleTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/DoubleTerms.java @@ -130,29 +130,27 @@ public DoubleTerms( String name, BucketOrder reduceOrder, BucketOrder order, - int requiredSize, - long minDocCount, Map metadata, DocValueFormat format, int shardSize, boolean showTermDocCountError, long otherDocCount, List buckets, - long docCountError + long docCountError, + TermsAggregator.BucketCountThresholds bucketCountThresholds ) { super( name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -174,15 +172,14 @@ public DoubleTerms create(List buckets) { name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -204,15 +201,14 @@ protected DoubleTerms create(String name, List buckets, BucketOrder redu name, reduceOrder, order, - requiredSize, - minDocCount, getMetadata(), format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java index e0a22435b8f48..53e5bce91ead2 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java @@ -57,6 +57,7 @@ import org.opensearch.search.aggregations.InternalOrder; import org.opensearch.search.aggregations.LeafBucketCollector; import org.opensearch.search.aggregations.LeafBucketCollectorBase; +import org.opensearch.search.aggregations.bucket.LocalBucketCountThresholds; import org.opensearch.search.aggregations.bucket.terms.SignificanceLookup.BackgroundFrequencyForBytes; import org.opensearch.search.aggregations.bucket.terms.heuristic.SignificanceHeuristic; import org.opensearch.search.aggregations.support.ValuesSource; @@ -603,6 +604,7 @@ abstract class ResultStrategy< TB extends InternalMultiBucketAggregation.InternalBucket> implements Releasable { private InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws IOException { + LocalBucketCountThresholds localBucketCountThresholds = context.asLocalBucketCountThresholds(bucketCountThresholds); if (valueCount == 0) { // no context in this reader InternalAggregation[] results = new InternalAggregation[owningBucketOrds.length]; for (int ordIdx = 0; ordIdx < owningBucketOrds.length; ordIdx++) { @@ -615,11 +617,11 @@ private InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws long[] otherDocCount = new long[owningBucketOrds.length]; for (int ordIdx = 0; ordIdx < owningBucketOrds.length; ordIdx++) { final int size; - if (bucketCountThresholds.getMinDocCount() == 0) { + if (localBucketCountThresholds.getMinDocCount() == 0) { // if minDocCount == 0 then we can end up with more buckets then maxBucketOrd() returns - size = (int) Math.min(valueCount, bucketCountThresholds.getShardSize()); + size = (int) Math.min(valueCount, localBucketCountThresholds.getRequiredSize()); } else { - size = (int) Math.min(maxBucketOrd(), bucketCountThresholds.getShardSize()); + size = (int) Math.min(maxBucketOrd(), localBucketCountThresholds.getRequiredSize()); } PriorityQueue ordered = buildPriorityQueue(size); final int finalOrdIdx = ordIdx; @@ -630,7 +632,7 @@ private InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws @Override public void accept(long globalOrd, long bucketOrd, long docCount) throws IOException { otherDocCount[finalOrdIdx] += docCount; - if (docCount >= bucketCountThresholds.getShardMinDocCount()) { + if (docCount >= localBucketCountThresholds.getMinDocCount()) { if (spare == null) { spare = buildEmptyTemporaryBucket(); } @@ -799,15 +801,14 @@ StringTerms buildResult(long owningBucketOrd, long otherDocCount, StringTerms.Bu name, reduceOrder, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, bucketCountThresholds.getShardSize(), showTermDocCountError, otherDocCount, Arrays.asList(topBuckets), - 0 + 0, + bucketCountThresholds ); } @@ -924,14 +925,13 @@ void buildSubAggs(SignificantStringTerms.Bucket[][] topBucketsPreOrd) throws IOE SignificantStringTerms buildResult(long owningBucketOrd, long otherDocCount, SignificantStringTerms.Bucket[] topBuckets) { return new SignificantStringTerms( name, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, subsetSize(owningBucketOrd), supersetSize, significanceHeuristic, - Arrays.asList(topBuckets) + Arrays.asList(topBuckets), + bucketCountThresholds ); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMappedSignificantTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMappedSignificantTerms.java index 97a95b8df840b..a7c5427fa38cc 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMappedSignificantTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMappedSignificantTerms.java @@ -64,16 +64,15 @@ public abstract class InternalMappedSignificantTerms< protected InternalMappedSignificantTerms( String name, - int requiredSize, - long minDocCount, Map metadata, DocValueFormat format, long subsetSize, long supersetSize, SignificanceHeuristic significanceHeuristic, - List buckets + List buckets, + TermsAggregator.BucketCountThresholds bucketCountThresholds ) { - super(name, requiredSize, minDocCount, metadata); + super(name, bucketCountThresholds, metadata); this.format = format; this.buckets = buckets; this.subsetSize = subsetSize; diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMappedTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMappedTerms.java index f5e92fec8195d..d542064df24d7 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMappedTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMappedTerms.java @@ -64,17 +64,16 @@ protected InternalMappedTerms( String name, BucketOrder reduceOrder, BucketOrder order, - int requiredSize, - long minDocCount, Map metadata, DocValueFormat format, int shardSize, boolean showTermDocCountError, long otherDocCount, List buckets, - long docCountError + long docCountError, + TermsAggregator.BucketCountThresholds bucketCountThresholds ) { - super(name, reduceOrder, order, requiredSize, minDocCount, metadata); + super(name, reduceOrder, order, bucketCountThresholds, metadata); this.format = format; this.shardSize = shardSize; this.showTermDocCountError = showTermDocCountError; diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMultiTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMultiTerms.java index fc84f35385d5c..4d1cbd4ce72f1 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMultiTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalMultiTerms.java @@ -233,17 +233,16 @@ public InternalMultiTerms( String name, BucketOrder reduceOrder, BucketOrder order, - int requiredSize, - long minDocCount, Map metadata, int shardSize, boolean showTermDocCountError, long otherDocCount, long docCountError, List formats, - List buckets + List buckets, + TermsAggregator.BucketCountThresholds bucketCountThresholds ) { - super(name, reduceOrder, order, requiredSize, minDocCount, metadata); + super(name, reduceOrder, order, bucketCountThresholds, metadata); this.shardSize = shardSize; this.showTermDocCountError = showTermDocCountError; this.otherDocCount = otherDocCount; @@ -278,15 +277,14 @@ public InternalMultiTerms create(List buckets) { name, reduceOrder, order, - requiredSize, - minDocCount, metadata, shardSize, showTermDocCountError, otherDocCount, docCountError, termFormats, - buckets + buckets, + bucketCountThresholds ); } @@ -357,15 +355,14 @@ protected InternalMultiTerms create( name, reduceOrder, order, - requiredSize, - minDocCount, metadata, shardSize, showTermDocCountError, otherDocCount, docCountError, termFormats, - buckets + buckets, + bucketCountThresholds ); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalSignificantTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalSignificantTerms.java index 84d148199a7f9..03bb519ed9961 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalSignificantTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalSignificantTerms.java @@ -39,6 +39,7 @@ import org.opensearch.search.aggregations.InternalAggregation; import org.opensearch.search.aggregations.InternalAggregations; import org.opensearch.search.aggregations.InternalMultiBucketAggregation; +import org.opensearch.search.aggregations.bucket.LocalBucketCountThresholds; import org.opensearch.search.aggregations.bucket.terms.heuristic.SignificanceHeuristic; import java.io.IOException; @@ -195,11 +196,17 @@ public final XContentBuilder toXContent(XContentBuilder builder, Params params) protected final int requiredSize; protected final long minDocCount; + protected final TermsAggregator.BucketCountThresholds bucketCountThresholds; - protected InternalSignificantTerms(String name, int requiredSize, long minDocCount, Map metadata) { + protected InternalSignificantTerms( + String name, + TermsAggregator.BucketCountThresholds bucketCountThresholds, + Map metadata + ) { super(name, metadata); - this.requiredSize = requiredSize; - this.minDocCount = minDocCount; + this.requiredSize = bucketCountThresholds.getRequiredSize(); + this.minDocCount = bucketCountThresholds.getMinDocCount(); + this.bucketCountThresholds = bucketCountThresholds; } /** @@ -209,6 +216,9 @@ protected InternalSignificantTerms(StreamInput in) throws IOException { super(in); requiredSize = readSize(in); minDocCount = in.readVLong(); + // shardMinDocCount and shardSize are not used on the coordinator, so they are not deserialized. We use + // CoordinatorBucketCountThresholds which will throw an exception if they are accessed. + bucketCountThresholds = new TermsAggregator.CoordinatorBucketCountThresholds(minDocCount, -1, requiredSize, -1); } protected final void doWriteTo(StreamOutput out) throws IOException { @@ -224,6 +234,7 @@ protected final void doWriteTo(StreamOutput out) throws IOException { @Override public InternalAggregation reduce(List aggregations, ReduceContext reduceContext) { + LocalBucketCountThresholds localBucketCountThresholds = reduceContext.asLocalBucketCountThresholds(bucketCountThresholds); long globalSubsetSize = 0; long globalSupersetSize = 0; // Compute the overall result set size and the corpus size using the @@ -265,13 +276,21 @@ public InternalAggregation reduce(List aggregations, Reduce } } SignificanceHeuristic heuristic = getSignificanceHeuristic().rewrite(reduceContext); - final int size = reduceContext.isFinalReduce() == false ? buckets.size() : Math.min(requiredSize, buckets.size()); + boolean isCoordinatorPartialReduce = reduceContext.isFinalReduce() == false && reduceContext.isSliceLevel() == false; + // Do not apply size threshold on coordinator partial reduce + final int size = !isCoordinatorPartialReduce + ? Math.min(localBucketCountThresholds.getRequiredSize(), buckets.size()) + : buckets.size(); BucketSignificancePriorityQueue ordered = new BucketSignificancePriorityQueue<>(size); for (Map.Entry> entry : buckets.entrySet()) { List sameTermBuckets = entry.getValue(); final B b = reduceBucket(sameTermBuckets, reduceContext); b.updateScore(heuristic); - if (((b.score > 0) && (b.subsetDf >= minDocCount)) || reduceContext.isFinalReduce() == false) { + // For concurrent search case we do not apply bucket count thresholds in buildAggregation and instead is done here during + // reduce. However, the bucket score is only evaluated at the final coordinator reduce. + boolean meetsThresholds = (b.subsetDf >= localBucketCountThresholds.getMinDocCount()) + && (((b.score > 0) || reduceContext.isSliceLevel())); + if (isCoordinatorPartialReduce || meetsThresholds) { B removed = ordered.insertWithOverflow(b); if (removed == null) { reduceContext.consumeBucketsAndMaybeBreak(1); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalTerms.java index 9a80155eea51c..0be7de5ded32f 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/InternalTerms.java @@ -46,6 +46,7 @@ import org.opensearch.search.aggregations.InternalOrder; import org.opensearch.search.aggregations.KeyComparable; import org.opensearch.search.aggregations.bucket.IteratorAndCurrent; +import org.opensearch.search.aggregations.bucket.LocalBucketCountThresholds; import org.opensearch.search.aggregations.bucket.MultiBucketsAggregation; import java.io.IOException; @@ -223,29 +224,29 @@ public int hashCode() { protected final BucketOrder order; protected final int requiredSize; protected final long minDocCount; + protected final TermsAggregator.BucketCountThresholds bucketCountThresholds; /** * Creates a new {@link InternalTerms} * @param name The name of the aggregation * @param reduceOrder The {@link BucketOrder} that should be used to merge shard results. * @param order The {@link BucketOrder} that should be used to sort the final reduce. - * @param requiredSize The number of top buckets. - * @param minDocCount The minimum number of documents allowed per bucket. + * @param bucketCountThresholds Object containing values for minDocCount, shardMinDocCount, size, shardSize. * @param metadata The metadata associated with the aggregation. */ protected InternalTerms( String name, BucketOrder reduceOrder, BucketOrder order, - int requiredSize, - long minDocCount, + TermsAggregator.BucketCountThresholds bucketCountThresholds, Map metadata ) { super(name, metadata); this.reduceOrder = reduceOrder; this.order = order; - this.requiredSize = requiredSize; - this.minDocCount = minDocCount; + this.bucketCountThresholds = bucketCountThresholds; + this.requiredSize = bucketCountThresholds.getRequiredSize(); + this.minDocCount = bucketCountThresholds.getMinDocCount(); } /** @@ -257,6 +258,9 @@ protected InternalTerms(StreamInput in) throws IOException { order = InternalOrder.Streams.readOrder(in); requiredSize = readSize(in); minDocCount = in.readVLong(); + // shardMinDocCount and shardSize are not used on the coordinator, so they are not deserialized. We use + // CoordinatorBucketCountThresholds which will throw an exception if they are accessed. + bucketCountThresholds = new TermsAggregator.CoordinatorBucketCountThresholds(minDocCount, -1, requiredSize, getShardSize()); } @Override @@ -385,6 +389,7 @@ private List reduceLegacy(List aggregations, ReduceConte } public InternalAggregation reduce(List aggregations, ReduceContext reduceContext) { + LocalBucketCountThresholds localBucketCountThresholds = reduceContext.asLocalBucketCountThresholds(bucketCountThresholds); long sumDocCountError = 0; long otherDocCount = 0; InternalTerms referenceTerms = null; @@ -444,8 +449,8 @@ public InternalAggregation reduce(List aggregations, Reduce reducedBuckets = reduceLegacy(aggregations, reduceContext); } final B[] list; - if (reduceContext.isFinalReduce()) { - final int size = Math.min(requiredSize, reducedBuckets.size()); + if (reduceContext.isFinalReduce() || reduceContext.isSliceLevel()) { + final int size = Math.min(localBucketCountThresholds.getRequiredSize(), reducedBuckets.size()); // final comparator final BucketPriorityQueue ordered = new BucketPriorityQueue<>(size, order.comparator()); for (B bucket : reducedBuckets) { @@ -455,7 +460,7 @@ public InternalAggregation reduce(List aggregations, Reduce final long finalSumDocCountError = sumDocCountError; bucket.setDocCountError(docCountError -> docCountError + finalSumDocCountError); } - if (bucket.getDocCount() >= minDocCount) { + if (bucket.getDocCount() >= localBucketCountThresholds.getMinDocCount()) { B removed = ordered.insertWithOverflow(bucket); if (removed != null) { otherDocCount += removed.getDocCount(); @@ -474,7 +479,9 @@ public InternalAggregation reduce(List aggregations, Reduce } else { // we can prune the list on partial reduce if the aggregation is ordered by key // and not filtered (minDocCount == 0) - int size = isKeyOrder(order) && minDocCount == 0 ? Math.min(requiredSize, reducedBuckets.size()) : reducedBuckets.size(); + int size = isKeyOrder(order) && localBucketCountThresholds.getMinDocCount() == 0 + ? Math.min(localBucketCountThresholds.getRequiredSize(), reducedBuckets.size()) + : reducedBuckets.size(); list = createBucketsArray(size); for (int i = 0; i < size; i++) { reduceContext.consumeBucketsAndMaybeBreak(1); @@ -493,6 +500,11 @@ public InternalAggregation reduce(List aggregations, Reduce } else { docCountError = aggregations.size() == 1 ? 0 : sumDocCountError; } + + // Shards must return buckets sorted by key, so we apply the sort here in shard level reduce + if (reduceContext.isSliceLevel()) { + Arrays.sort(list, thisReduceOrder.comparator()); + } return create(name, Arrays.asList(list), reduceContext.isFinalReduce() ? order : thisReduceOrder, docCountError, otherDocCount); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/LongTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/LongTerms.java index 67aa80d0a9879..fe78145dce3e7 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/LongTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/LongTerms.java @@ -142,29 +142,27 @@ public LongTerms( String name, BucketOrder reduceOrder, BucketOrder order, - int requiredSize, - long minDocCount, Map metadata, DocValueFormat format, int shardSize, boolean showTermDocCountError, long otherDocCount, List buckets, - long docCountError + long docCountError, + TermsAggregator.BucketCountThresholds bucketCountThresholds ) { super( name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -186,15 +184,14 @@ public LongTerms create(List buckets) { name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -216,15 +213,14 @@ protected LongTerms create(String name, List buckets, BucketOrder reduce name, reduceOrder, order, - requiredSize, - minDocCount, getMetadata(), format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -293,15 +289,14 @@ static DoubleTerms convertLongTermsToDouble(LongTerms longTerms, DocValueFormat longTerms.getName(), longTerms.reduceOrder, longTerms.order, - longTerms.requiredSize, - longTerms.minDocCount, longTerms.metadata, longTerms.format, longTerms.shardSize, longTerms.showTermDocCountError, longTerms.otherDocCount, newBuckets, - longTerms.docCountError + longTerms.docCountError, + longTerms.bucketCountThresholds ); } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MapStringTermsAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MapStringTermsAggregator.java index bcdf1f4480a31..b0d2194cccc84 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MapStringTermsAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MapStringTermsAggregator.java @@ -50,6 +50,7 @@ import org.opensearch.search.aggregations.InternalOrder; import org.opensearch.search.aggregations.LeafBucketCollector; import org.opensearch.search.aggregations.LeafBucketCollectorBase; +import org.opensearch.search.aggregations.bucket.LocalBucketCountThresholds; import org.opensearch.search.aggregations.bucket.terms.SignificanceLookup.BackgroundFrequencyForBytes; import org.opensearch.search.aggregations.bucket.terms.heuristic.SignificanceHeuristic; import org.opensearch.search.aggregations.support.ValuesSource; @@ -244,11 +245,12 @@ abstract class ResultStrategy ordered = buildPriorityQueue(size); B spare = null; @@ -257,7 +259,7 @@ private InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws while (ordsEnum.next()) { long docCount = bucketDocCount(ordsEnum.ord()); otherDocCounts[ordIdx] += docCount; - if (docCount < bucketCountThresholds.getShardMinDocCount()) { + if (docCount < localBucketCountThresholds.getMinDocCount()) { continue; } if (spare == null) { @@ -454,15 +456,14 @@ StringTerms buildResult(long owningBucketOrd, long otherDocCount, StringTerms.Bu name, reduceOrder, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, bucketCountThresholds.getShardSize(), showTermDocCountError, otherDocCount, Arrays.asList(topBuckets), - 0 + 0, + bucketCountThresholds ); } @@ -572,14 +573,13 @@ void buildSubAggs(SignificantStringTerms.Bucket[][] topBucketsPerOrd) throws IOE SignificantStringTerms buildResult(long owningBucketOrd, long otherDocCount, SignificantStringTerms.Bucket[] topBuckets) { return new SignificantStringTerms( name, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, subsetSizes.get(owningBucketOrd), supersetSize, significanceHeuristic, - Arrays.asList(topBuckets) + Arrays.asList(topBuckets), + bucketCountThresholds ); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregator.java index 9d99c0b90a075..c86302844b730 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregator.java @@ -33,6 +33,7 @@ import org.opensearch.search.aggregations.InternalOrder; import org.opensearch.search.aggregations.LeafBucketCollector; import org.opensearch.search.aggregations.bucket.DeferableBucketAggregator; +import org.opensearch.search.aggregations.bucket.LocalBucketCountThresholds; import org.opensearch.search.aggregations.support.AggregationPath; import org.opensearch.search.aggregations.support.ValuesSource; import org.opensearch.search.internal.SearchContext; @@ -118,13 +119,14 @@ public MultiTermsAggregator( @Override public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws IOException { + LocalBucketCountThresholds localBucketCountThresholds = context.asLocalBucketCountThresholds(bucketCountThresholds); InternalMultiTerms.Bucket[][] topBucketsPerOrd = new InternalMultiTerms.Bucket[owningBucketOrds.length][]; long[] otherDocCounts = new long[owningBucketOrds.length]; for (int ordIdx = 0; ordIdx < owningBucketOrds.length; ordIdx++) { collectZeroDocEntriesIfNeeded(owningBucketOrds[ordIdx]); long bucketsInOrd = bucketOrds.bucketsInOrd(owningBucketOrds[ordIdx]); - int size = (int) Math.min(bucketsInOrd, bucketCountThresholds.getShardSize()); + int size = (int) Math.min(bucketsInOrd, localBucketCountThresholds.getRequiredSize()); PriorityQueue ordered = new BucketPriorityQueue<>(size, partiallyBuiltBucketComparator); InternalMultiTerms.Bucket spare = null; BytesRef dest = null; @@ -136,7 +138,7 @@ public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws I while (ordsEnum.next()) { long docCount = bucketDocCount(ordsEnum.ord()); otherDocCounts[ordIdx] += docCount; - if (docCount < bucketCountThresholds.getShardMinDocCount()) { + if (docCount < localBucketCountThresholds.getMinDocCount()) { continue; } if (spare == null) { @@ -182,15 +184,14 @@ InternalMultiTerms buildResult(long owningBucketOrd, long otherDocCount, Interna name, reduceOrder, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), bucketCountThresholds.getShardSize(), showTermDocCountError, otherDocCount, 0, formats, - List.of(topBuckets) + List.of(topBuckets), + bucketCountThresholds ); } @@ -200,15 +201,14 @@ public InternalAggregation buildEmptyAggregation() { name, order, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), bucketCountThresholds.getShardSize(), showTermDocCountError, 0, 0, formats, - Collections.emptyList() + Collections.emptyList(), + bucketCountThresholds ); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregator.java index a0265135fe9d3..8bab7ffbbb90f 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregator.java @@ -52,6 +52,7 @@ import org.opensearch.search.aggregations.InternalOrder; import org.opensearch.search.aggregations.LeafBucketCollector; import org.opensearch.search.aggregations.LeafBucketCollectorBase; +import org.opensearch.search.aggregations.bucket.LocalBucketCountThresholds; import org.opensearch.search.aggregations.bucket.terms.IncludeExclude.LongFilter; import org.opensearch.search.aggregations.bucket.terms.LongKeyedBucketOrds.BucketOrdsEnum; import org.opensearch.search.aggregations.bucket.terms.SignificanceLookup.BackgroundFrequencyForLong; @@ -173,13 +174,14 @@ abstract class ResultStrategy ordered = buildPriorityQueue(size); B spare = null; BucketOrdsEnum ordsEnum = bucketOrds.ordsEnum(owningBucketOrds[ordIdx]); @@ -187,7 +189,7 @@ private InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws while (ordsEnum.next()) { long docCount = bucketDocCount(ordsEnum.ord()); otherDocCounts[ordIdx] += docCount; - if (docCount < bucketCountThresholds.getShardMinDocCount()) { + if (docCount < localBucketCountThresholds.getMinDocCount()) { continue; } if (spare == null) { @@ -395,15 +397,14 @@ LongTerms buildResult(long owningBucketOrd, long otherDocCount, LongTerms.Bucket name, reduceOrder, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, bucketCountThresholds.getShardSize(), showTermDocCountError, otherDocCount, List.of(topBuckets), - 0 + 0, + bucketCountThresholds ); } @@ -413,15 +414,14 @@ LongTerms buildEmptyResult() { name, order, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, bucketCountThresholds.getShardSize(), showTermDocCountError, 0, emptyList(), - 0 + 0, + bucketCountThresholds ); } } @@ -477,15 +477,14 @@ DoubleTerms buildResult(long owningBucketOrd, long otherDocCount, DoubleTerms.Bu name, reduceOrder, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, bucketCountThresholds.getShardSize(), showTermDocCountError, otherDocCount, List.of(topBuckets), - 0 + 0, + bucketCountThresholds ); } @@ -495,15 +494,14 @@ DoubleTerms buildEmptyResult() { name, order, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, bucketCountThresholds.getShardSize(), showTermDocCountError, 0, emptyList(), - 0 + 0, + bucketCountThresholds ); } } @@ -558,15 +556,14 @@ UnsignedLongTerms buildResult(long owningBucketOrd, long otherDocCount, Unsigned name, reduceOrder, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, bucketCountThresholds.getShardSize(), showTermDocCountError, otherDocCount, List.of(topBuckets), - 0 + 0, + bucketCountThresholds ); } @@ -576,15 +573,14 @@ UnsignedLongTerms buildEmptyResult() { name, order, order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, bucketCountThresholds.getShardSize(), showTermDocCountError, 0, emptyList(), - 0 + 0, + bucketCountThresholds ); } } @@ -670,17 +666,17 @@ void collectZeroDocEntriesIfNeeded(long owningBucketOrd) throws IOException {} @Override SignificantLongTerms buildResult(long owningBucketOrd, long otherDocCoun, SignificantLongTerms.Bucket[] topBuckets) { - return new SignificantLongTerms( + SignificantLongTerms significantLongTerms = new SignificantLongTerms( name, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, subsetSizes.get(owningBucketOrd), supersetSize, significanceHeuristic, - List.of(topBuckets) + List.of(topBuckets), + bucketCountThresholds ); + return significantLongTerms; } @Override @@ -691,14 +687,13 @@ SignificantLongTerms buildEmptyResult() { int supersetSize = topReader.numDocs(); return new SignificantLongTerms( name, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), metadata(), format, 0, supersetSize, significanceHeuristic, - emptyList() + emptyList(), + bucketCountThresholds ); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantLongTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantLongTerms.java index 46e8cea7abc36..3da5a766fc37b 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantLongTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantLongTerms.java @@ -130,16 +130,15 @@ public int hashCode() { public SignificantLongTerms( String name, - int requiredSize, - long minDocCount, Map metadata, DocValueFormat format, long subsetSize, long supersetSize, SignificanceHeuristic significanceHeuristic, - List buckets + List buckets, + TermsAggregator.BucketCountThresholds bucketCountThresholds ) { - super(name, requiredSize, minDocCount, metadata, format, subsetSize, supersetSize, significanceHeuristic, buckets); + super(name, metadata, format, subsetSize, supersetSize, significanceHeuristic, buckets, bucketCountThresholds); } /** @@ -158,14 +157,13 @@ public String getWriteableName() { public SignificantLongTerms create(List buckets) { return new SignificantLongTerms( name, - requiredSize, - minDocCount, metadata, format, subsetSize, supersetSize, significanceHeuristic, - buckets + buckets, + bucketCountThresholds ); } @@ -187,14 +185,13 @@ public Bucket createBucket(InternalAggregations aggregations, SignificantLongTer protected SignificantLongTerms create(long subsetSize, long supersetSize, List buckets) { return new SignificantLongTerms( getName(), - requiredSize, - minDocCount, getMetadata(), format, subsetSize, supersetSize, significanceHeuristic, - buckets + buckets, + bucketCountThresholds ); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantStringTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantStringTerms.java index d8d93ad7ae159..c70db6005d7cd 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantStringTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantStringTerms.java @@ -135,16 +135,15 @@ public int hashCode() { public SignificantStringTerms( String name, - int requiredSize, - long minDocCount, Map metadata, DocValueFormat format, long subsetSize, long supersetSize, SignificanceHeuristic significanceHeuristic, - List buckets + List buckets, + TermsAggregator.BucketCountThresholds bucketCountThresholds ) { - super(name, requiredSize, minDocCount, metadata, format, subsetSize, supersetSize, significanceHeuristic, buckets); + super(name, metadata, format, subsetSize, supersetSize, significanceHeuristic, buckets, bucketCountThresholds); } /** @@ -163,14 +162,13 @@ public String getWriteableName() { public SignificantStringTerms create(List buckets) { return new SignificantStringTerms( name, - requiredSize, - minDocCount, metadata, format, subsetSize, supersetSize, significanceHeuristic, - buckets + buckets, + bucketCountThresholds ); } @@ -192,14 +190,13 @@ public Bucket createBucket(InternalAggregations aggregations, SignificantStringT protected SignificantStringTerms create(long subsetSize, long supersetSize, List buckets) { return new SignificantStringTerms( getName(), - requiredSize, - minDocCount, getMetadata(), format, subsetSize, supersetSize, significanceHeuristic, - buckets + buckets, + bucketCountThresholds ); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java index 1dacd4c7de4e8..9f5136dc1df53 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java @@ -246,12 +246,7 @@ public Aggregator build( @Override protected Aggregator createUnmapped(SearchContext searchContext, Aggregator parent, Map metadata) throws IOException { - final InternalAggregation aggregation = new UnmappedSignificantTerms( - name, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), - metadata - ); + final InternalAggregation aggregation = new UnmappedSignificantTerms(name, bucketCountThresholds, metadata); return new NonCollectingAggregator(name, searchContext, parent, factories, metadata) { @Override public InternalAggregation buildEmptyAggregation() { diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/StringTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/StringTerms.java index c985bf770d4a7..6dedc65ff14e3 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/StringTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/StringTerms.java @@ -134,29 +134,27 @@ public StringTerms( String name, BucketOrder reduceOrder, BucketOrder order, - int requiredSize, - long minDocCount, Map metadata, DocValueFormat format, int shardSize, boolean showTermDocCountError, long otherDocCount, List buckets, - long docCountError + long docCountError, + TermsAggregator.BucketCountThresholds bucketCountThresholds ) { super( name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -178,15 +176,14 @@ public StringTerms create(List buckets) { name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -213,15 +210,14 @@ protected StringTerms create(String name, List buckets, BucketOrder redu name, reduceOrder, order, - requiredSize, - minDocCount, getMetadata(), format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregator.java index 9e2aa85bb1dd8..7cacf1e918380 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregator.java @@ -39,6 +39,7 @@ import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.search.DocValueFormat; +import org.opensearch.search.aggregations.AggregationExecutionException; import org.opensearch.search.aggregations.Aggregator; import org.opensearch.search.aggregations.AggregatorFactories; import org.opensearch.search.aggregations.BucketOrder; @@ -195,6 +196,30 @@ public boolean equals(Object obj) { } } + /** + * BucketCountThresholds type that throws an exception when shardMinDocCount or shardSize are accessed. This is used for + * deserialization on the coordinator during reduce as shardMinDocCount and shardSize should not be accessed this way on the + * coordinator. + * + * @opensearch.internal + */ + public static class CoordinatorBucketCountThresholds extends BucketCountThresholds { + + public CoordinatorBucketCountThresholds(long minDocCount, long shardMinDocCount, int requiredSize, int shardSize) { + super(minDocCount, shardMinDocCount, requiredSize, shardSize); + } + + @Override + public long getShardMinDocCount() { + throw new AggregationExecutionException("shard_min_doc_count should not be accessed via CoordinatorBucketCountThresholds"); + } + + @Override + public int getShardSize() { + throw new AggregationExecutionException("shard_size should not be accessed via CoordinatorBucketCountThresholds"); + } + } + protected final DocValueFormat format; protected final BucketCountThresholds bucketCountThresholds; protected final BucketOrder order; diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java index 11be3da5c8991..62844b4499dba 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java @@ -265,13 +265,7 @@ public Aggregator build( @Override protected Aggregator createUnmapped(SearchContext searchContext, Aggregator parent, Map metadata) throws IOException { - final InternalAggregation aggregation = new UnmappedTerms( - name, - order, - bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), - metadata - ); + final InternalAggregation aggregation = new UnmappedTerms(name, order, bucketCountThresholds, metadata); Aggregator agg = new NonCollectingAggregator(name, searchContext, parent, factories, metadata) { @Override public InternalAggregation buildEmptyAggregation() { diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnmappedSignificantTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnmappedSignificantTerms.java index 9384f9e793d81..2c8aa8f0a0c37 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnmappedSignificantTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnmappedSignificantTerms.java @@ -77,8 +77,12 @@ private Bucket( } } - public UnmappedSignificantTerms(String name, int requiredSize, long minDocCount, Map metadata) { - super(name, requiredSize, minDocCount, metadata); + public UnmappedSignificantTerms( + String name, + TermsAggregator.BucketCountThresholds bucketCountThresholds, + Map metadata + ) { + super(name, bucketCountThresholds, metadata); } /** @@ -105,7 +109,7 @@ public String getType() { @Override public UnmappedSignificantTerms create(List buckets) { - return new UnmappedSignificantTerms(name, requiredSize, minDocCount, metadata); + return new UnmappedSignificantTerms(name, bucketCountThresholds, metadata); } @Override @@ -132,7 +136,7 @@ Bucket createBucket( @Override public InternalAggregation reduce(List aggregations, ReduceContext reduceContext) { - return new UnmappedSignificantTerms(name, requiredSize, minDocCount, metadata); + return new UnmappedSignificantTerms(name, bucketCountThresholds, metadata); } @Override diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnmappedTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnmappedTerms.java index 01902f9449bae..3d2bbb93c889a 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnmappedTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnmappedTerms.java @@ -72,8 +72,13 @@ private Bucket( } } - public UnmappedTerms(String name, BucketOrder order, int requiredSize, long minDocCount, Map metadata) { - super(name, order, order, requiredSize, minDocCount, metadata); + public UnmappedTerms( + String name, + BucketOrder order, + TermsAggregator.BucketCountThresholds bucketCountThresholds, + Map metadata + ) { + super(name, order, order, bucketCountThresholds, metadata); } /** @@ -100,7 +105,7 @@ public String getType() { @Override public UnmappedTerms create(List buckets) { - return new UnmappedTerms(name, order, requiredSize, minDocCount, metadata); + return new UnmappedTerms(name, order, bucketCountThresholds, metadata); } @Override @@ -120,7 +125,7 @@ protected UnmappedTerms create(String name, List buckets, BucketOrder re @Override public InternalAggregation reduce(List aggregations, ReduceContext reduceContext) { - return new UnmappedTerms(name, order, requiredSize, minDocCount, metadata); + return new UnmappedTerms(name, order, bucketCountThresholds, metadata); } @Override diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnsignedLongTerms.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnsignedLongTerms.java index db05ac84b4aec..edeec00d366fd 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnsignedLongTerms.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/UnsignedLongTerms.java @@ -121,29 +121,27 @@ public UnsignedLongTerms( String name, BucketOrder reduceOrder, BucketOrder order, - int requiredSize, - long minDocCount, Map metadata, DocValueFormat format, int shardSize, boolean showTermDocCountError, long otherDocCount, List buckets, - long docCountError + long docCountError, + TermsAggregator.BucketCountThresholds bucketCountThresholds ) { super( name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -165,15 +163,14 @@ public UnsignedLongTerms create(List buckets) { name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -195,15 +192,14 @@ protected UnsignedLongTerms create(String name, List buckets, BucketOrde name, reduceOrder, order, - requiredSize, - minDocCount, getMetadata(), format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -272,15 +268,14 @@ static DoubleTerms convertUnsignedLongTermsToDouble(UnsignedLongTerms unsignedLo unsignedLongTerms.getName(), unsignedLongTerms.reduceOrder, unsignedLongTerms.order, - unsignedLongTerms.requiredSize, - unsignedLongTerms.minDocCount, unsignedLongTerms.metadata, unsignedLongTerms.format, unsignedLongTerms.shardSize, unsignedLongTerms.showTermDocCountError, unsignedLongTerms.otherDocCount, newBuckets, - unsignedLongTerms.docCountError + unsignedLongTerms.docCountError, + unsignedLongTerms.bucketCountThresholds ); } } diff --git a/server/src/main/java/org/opensearch/search/internal/SearchContext.java b/server/src/main/java/org/opensearch/search/internal/SearchContext.java index bc2a0658e5a6d..704683a59c473 100644 --- a/server/src/main/java/org/opensearch/search/internal/SearchContext.java +++ b/server/src/main/java/org/opensearch/search/internal/SearchContext.java @@ -35,6 +35,7 @@ import org.apache.lucene.search.CollectorManager; import org.apache.lucene.search.FieldDoc; import org.apache.lucene.search.Query; +import org.apache.lucene.util.ArrayUtil; import org.opensearch.action.search.SearchShardTask; import org.opensearch.action.search.SearchType; import org.opensearch.common.Nullable; @@ -57,6 +58,8 @@ import org.opensearch.search.aggregations.BucketCollectorProcessor; import org.opensearch.search.aggregations.InternalAggregation; import org.opensearch.search.aggregations.SearchContextAggregations; +import org.opensearch.search.aggregations.bucket.LocalBucketCountThresholds; +import org.opensearch.search.aggregations.bucket.terms.TermsAggregator; import org.opensearch.search.collapse.CollapseContext; import org.opensearch.search.dfs.DfsSearchResult; import org.opensearch.search.fetch.FetchPhase; @@ -400,6 +403,17 @@ public boolean isConcurrentSegmentSearchEnabled() { return false; } + /** + * Returns local bucket count thresholds based on concurrent segment search status + */ + public LocalBucketCountThresholds asLocalBucketCountThresholds(TermsAggregator.BucketCountThresholds bucketCountThresholds) { + if (isConcurrentSegmentSearchEnabled()) { + return new LocalBucketCountThresholds(0, ArrayUtil.MAX_ARRAY_LENGTH - 1); + } else { + return new LocalBucketCountThresholds(bucketCountThresholds.getShardMinDocCount(), bucketCountThresholds.getShardSize()); + } + } + /** * Adds a releasable that will be freed when this context is closed. */ diff --git a/server/src/test/java/org/opensearch/search/aggregations/InternalAggregationsTests.java b/server/src/test/java/org/opensearch/search/aggregations/InternalAggregationsTests.java index 354c635e06fab..59bc90788a1e7 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/InternalAggregationsTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/InternalAggregationsTests.java @@ -43,6 +43,7 @@ import org.opensearch.search.aggregations.bucket.histogram.InternalDateHistogramTests; import org.opensearch.search.aggregations.bucket.terms.StringTerms; import org.opensearch.search.aggregations.bucket.terms.StringTermsTests; +import org.opensearch.search.aggregations.bucket.terms.TermsAggregator; import org.opensearch.search.aggregations.pipeline.InternalSimpleValueTests; import org.opensearch.search.aggregations.pipeline.MaxBucketPipelineAggregationBuilder; import org.opensearch.search.aggregations.pipeline.PipelineAggregator; @@ -76,15 +77,14 @@ public void testNonFinalReduceTopLevelPipelineAggs() { "name", BucketOrder.key(true), BucketOrder.key(true), - 10, - 1, Collections.emptyMap(), DocValueFormat.RAW, 25, false, 10, Collections.emptyList(), - 0 + 0, + new TermsAggregator.BucketCountThresholds(1, 0, 10, 25) ); List aggs = singletonList(InternalAggregations.from(Collections.singletonList(terms))); InternalAggregations reducedAggs = InternalAggregations.topLevelReduce(aggs, maxBucketReduceContext().forPartialReduction()); @@ -96,15 +96,14 @@ public void testFinalReduceTopLevelPipelineAggs() { "name", BucketOrder.key(true), BucketOrder.key(true), - 10, - 1, Collections.emptyMap(), DocValueFormat.RAW, 25, false, 10, Collections.emptyList(), - 0 + 0, + new TermsAggregator.BucketCountThresholds(1, 0, 10, 25) ); InternalAggregations aggs = InternalAggregations.from(Collections.singletonList(terms)); diff --git a/server/src/test/java/org/opensearch/search/aggregations/InternalMultiBucketAggregationTests.java b/server/src/test/java/org/opensearch/search/aggregations/InternalMultiBucketAggregationTests.java index bc48b546e6d28..b7f4094da9990 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/InternalMultiBucketAggregationTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/InternalMultiBucketAggregationTests.java @@ -37,6 +37,7 @@ import org.opensearch.search.aggregations.bucket.terms.InternalTerms; import org.opensearch.search.aggregations.bucket.terms.LongTerms; import org.opensearch.search.aggregations.bucket.terms.StringTerms; +import org.opensearch.search.aggregations.bucket.terms.TermsAggregator; import org.opensearch.search.aggregations.metrics.InternalAvg; import org.opensearch.search.aggregations.support.AggregationPath; import org.opensearch.test.OpenSearchTestCase; @@ -164,20 +165,18 @@ public void testResolveToSpecificBucket() { DocValueFormat.RAW ) ); - InternalTerms termsAgg = new StringTerms( "string_terms", BucketOrder.count(false), BucketOrder.count(false), - 1, - 0, Collections.emptyMap(), DocValueFormat.RAW, 1, false, 0, stringBuckets, - 0 + 0, + new TermsAggregator.BucketCountThresholds(0, 0, 1, 1) ); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(termsAgg)); LongTerms.Bucket bucket = new LongTerms.Bucket(19, 1, internalAggregations, false, 0, DocValueFormat.RAW); @@ -208,15 +207,14 @@ public void testResolveToMissingSpecificBucket() { "string_terms", BucketOrder.count(false), BucketOrder.count(false), - 1, - 0, Collections.emptyMap(), DocValueFormat.RAW, 1, false, 0, stringBuckets, - 0 + 0, + new TermsAggregator.BucketCountThresholds(0, 0, 1, 1) ); InternalAggregations internalAggregations = InternalAggregations.from(Collections.singletonList(termsAgg)); LongTerms.Bucket bucket = new LongTerms.Bucket(19, 1, internalAggregations, false, 0, DocValueFormat.RAW); diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/DoubleTermsTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/DoubleTermsTests.java index 853d56202c360..5fe9c1dee358d 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/DoubleTermsTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/DoubleTermsTests.java @@ -59,6 +59,12 @@ public class DoubleTermsTests extends InternalTermsTestCase { long minDocCount = 1; int requiredSize = 3; int shardSize = requiredSize + 2; + TermsAggregator.BucketCountThresholds bucketCountThresholds = new TermsAggregator.BucketCountThresholds( + minDocCount, + 0, + requiredSize, + shardSize + ); DocValueFormat format = randomNumericDocValueFormat(); long otherDocCount = 0; List buckets = new ArrayList<>(); @@ -75,15 +81,14 @@ public class DoubleTermsTests extends InternalTermsTestCase { name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -158,15 +163,14 @@ protected Class implementationClass() { name, doubleTerms.reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, shardSize) ); } else { String name = instance.getName(); @@ -195,7 +199,7 @@ protected Class implementationClass() { default: throw new AssertionError("Illegal randomisation branch"); } - return new UnmappedTerms(name, order, requiredSize, minDocCount, metadata); + return new UnmappedTerms(name, order, new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, 0), metadata); } } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalMultiTermsTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalMultiTermsTests.java index 2657f2bdd5138..9f8bab1179ad6 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalMultiTermsTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalMultiTermsTests.java @@ -45,6 +45,12 @@ public class InternalMultiTermsTests extends InternalTermsTestCase { int requiredSize = 3; int shardSize = requiredSize + 2; long otherDocCount = 0; + TermsAggregator.BucketCountThresholds bucketCountThresholds = new TermsAggregator.BucketCountThresholds( + minDocCount, + 0, + requiredSize, + shardSize + ); final int numBuckets = randomNumberOfBuckets(); @@ -70,15 +76,14 @@ public class InternalMultiTermsTests extends InternalTermsTestCase { name, reduceOrder, order, - requiredSize, - minDocCount, metadata, shardSize, showTermDocCountError, otherDocCount, docCountError, formats, - buckets + buckets, + bucketCountThresholds ); } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalSignificantTermsTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalSignificantTermsTestCase.java index aab9e91576b18..e640aa92ac782 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalSignificantTermsTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalSignificantTermsTestCase.java @@ -114,7 +114,7 @@ protected abstract InternalSignificantTerms createTestInstance( @Override protected InternalSignificantTerms createUnmappedInstance(String name, Map metadata) { InternalSignificantTerms testInstance = createTestInstance(name, metadata); - return new UnmappedSignificantTerms(name, testInstance.requiredSize, testInstance.minDocCount, metadata); + return new UnmappedSignificantTerms(name, testInstance.bucketCountThresholds, metadata); } @Override diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalTermsTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalTermsTestCase.java index d3f7c62021243..2e00248a70771 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalTermsTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/InternalTermsTestCase.java @@ -73,7 +73,7 @@ public void init() { @Override protected InternalTerms createUnmappedInstance(String name, Map metadata) { InternalTerms testInstance = createTestInstance(name, metadata); - return new UnmappedTerms(name, testInstance.order, testInstance.requiredSize, testInstance.minDocCount, metadata); + return new UnmappedTerms(name, testInstance.order, testInstance.bucketCountThresholds, metadata); } @Override diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/LongTermsTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/LongTermsTests.java index becf89c4603f3..44fa9f5e79593 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/LongTermsTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/LongTermsTests.java @@ -59,6 +59,12 @@ public class LongTermsTests extends InternalTermsTestCase { long minDocCount = 1; int requiredSize = 3; int shardSize = requiredSize + 2; + TermsAggregator.BucketCountThresholds bucketCountThresholds = new TermsAggregator.BucketCountThresholds( + minDocCount, + 0, + requiredSize, + shardSize + ); DocValueFormat format = randomNumericDocValueFormat(); long otherDocCount = 0; List buckets = new ArrayList<>(); @@ -75,15 +81,14 @@ public class LongTermsTests extends InternalTermsTestCase { name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -158,15 +163,14 @@ protected Class implementationClass() { name, longTerms.reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, shardSize) ); } else { String name = instance.getName(); @@ -195,7 +199,7 @@ protected Class implementationClass() { default: throw new AssertionError("Illegal randomisation branch"); } - return new UnmappedTerms(name, order, requiredSize, minDocCount, metadata); + return new UnmappedTerms(name, order, new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, 0), metadata); } } } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificanceHeuristicTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificanceHeuristicTests.java index b400f5bccca01..24aeed1aeb635 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificanceHeuristicTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificanceHeuristicTests.java @@ -125,7 +125,16 @@ public void testStreamResponse() throws Exception { DocValueFormat.RAW, randomDoubleBetween(0, 100, true) ); - return new SignificantLongTerms("some_name", 1, 1, null, DocValueFormat.RAW, 10, 20, heuristic, singletonList(bucket)); + return new SignificantLongTerms( + "some_name", + null, + DocValueFormat.RAW, + 10, + 20, + heuristic, + singletonList(bucket), + new TermsAggregator.BucketCountThresholds(1, 0, 1, 0) + ); } else { SignificantStringTerms.Bucket bucket = new SignificantStringTerms.Bucket( new BytesRef("someterm"), @@ -137,7 +146,16 @@ public void testStreamResponse() throws Exception { DocValueFormat.RAW, randomDoubleBetween(0, 100, true) ); - return new SignificantStringTerms("some_name", 1, 1, null, DocValueFormat.RAW, 10, 20, heuristic, singletonList(bucket)); + return new SignificantStringTerms( + "some_name", + null, + DocValueFormat.RAW, + 10, + 20, + heuristic, + singletonList(bucket), + new TermsAggregator.BucketCountThresholds(1, 0, 1, 0) + ); } } @@ -204,14 +222,13 @@ SignificantStringTerms createAggregation( ) { return new SignificantStringTerms( "sig_terms", - 2, - -1, emptyMap(), DocValueFormat.RAW, subsetSize, supersetSize, significanceHeuristic, - buckets + buckets, + new TermsAggregator.BucketCountThresholds(-1, 0, 2, 0) ); } @@ -240,14 +257,13 @@ SignificantLongTerms createAggregation( ) { return new SignificantLongTerms( "sig_terms", - 2, - -1, emptyMap(), DocValueFormat.RAW, subsetSize, supersetSize, significanceHeuristic, - buckets + buckets, + new TermsAggregator.BucketCountThresholds(-1, 0, 2, 0) ); } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantLongTermsTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantLongTermsTests.java index 886e4d8267578..38b478efd004b 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantLongTermsTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantLongTermsTests.java @@ -85,7 +85,17 @@ protected InternalSignificantTerms createTestInstance( bucket.updateScore(significanceHeuristic); buckets.add(bucket); } - return new SignificantLongTerms(name, requiredSize, 1L, metadata, format, subsetSize, supersetSize, significanceHeuristic, buckets); + + return new SignificantLongTerms( + name, + metadata, + format, + subsetSize, + supersetSize, + significanceHeuristic, + buckets, + new TermsAggregator.BucketCountThresholds(1L, 0, requiredSize, 0) + ); } @Override @@ -150,14 +160,13 @@ protected Class implementationClass() { } return new SignificantLongTerms( name, - requiredSize, - minDocCount, metadata, format, subsetSize, supersetSize, significanceHeuristic, - buckets + buckets, + new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, 0) ); } else { String name = instance.getName(); @@ -185,7 +194,7 @@ protected Class implementationClass() { default: throw new AssertionError("Illegal randomisation branch"); } - return new UnmappedSignificantTerms(name, requiredSize, minDocCount, metadata); + return new UnmappedSignificantTerms(name, new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, 0), metadata); } } } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantStringTermsTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantStringTermsTests.java index 63a08a7aa1683..3ac30248ef353 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantStringTermsTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantStringTermsTests.java @@ -80,14 +80,13 @@ protected InternalSignificantTerms createTestInstance( } return new SignificantStringTerms( name, - requiredSize, - 1L, metadata, format, subsetSize, supersetSize, significanceHeuristic, - buckets + buckets, + new TermsAggregator.BucketCountThresholds(1L, 0, requiredSize, 0) ); } @@ -153,14 +152,13 @@ protected Class implementationClass() { } return new SignificantStringTerms( name, - requiredSize, - minDocCount, metadata, format, subsetSize, supersetSize, significanceHeuristic, - buckets + buckets, + new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, 0) ); } else { String name = instance.getName(); @@ -188,7 +186,7 @@ protected Class implementationClass() { default: throw new AssertionError("Illegal randomisation branch"); } - return new UnmappedSignificantTerms(name, requiredSize, minDocCount, metadata); + return new UnmappedSignificantTerms(name, new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, 0), metadata); } } } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/StringTermsTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/StringTermsTests.java index 6757c8e00f83d..deba96fd3ae19 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/StringTermsTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/StringTermsTests.java @@ -140,15 +140,14 @@ protected Class implementationClass() { name, stringTerms.reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, shardSize) ); } else { String name = instance.getName(); @@ -177,7 +176,7 @@ protected Class implementationClass() { default: throw new AssertionError("Illegal randomisation branch"); } - return new UnmappedTerms(name, order, requiredSize, minDocCount, metadata); + return new UnmappedTerms(name, order, new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, 0), metadata); } } @@ -206,6 +205,12 @@ private BytesRef[] generateRandomDict() { long minDocCount = 1; int requiredSize = 3; int shardSize = requiredSize + 2; + TermsAggregator.BucketCountThresholds bucketCountThresholds = new TermsAggregator.BucketCountThresholds( + minDocCount, + 0, + requiredSize, + shardSize + ); DocValueFormat format = DocValueFormat.RAW; long otherDocCount = 0; List buckets = new ArrayList<>(); @@ -226,15 +231,14 @@ private BytesRef[] generateRandomDict() { name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/UnsignedLongTermsTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/UnsignedLongTermsTests.java index b961039e50501..478961c2a404c 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/UnsignedLongTermsTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/UnsignedLongTermsTests.java @@ -36,6 +36,12 @@ public class UnsignedLongTermsTests extends InternalTermsTestCase { long minDocCount = 1; int requiredSize = 3; int shardSize = requiredSize + 2; + TermsAggregator.BucketCountThresholds bucketCountThresholds = new TermsAggregator.BucketCountThresholds( + minDocCount, + 0, + requiredSize, + shardSize + ); DocValueFormat format = randomNumericDocValueFormat(); long otherDocCount = 0; List buckets = new ArrayList<>(); @@ -52,15 +58,14 @@ public class UnsignedLongTermsTests extends InternalTermsTestCase { name, reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + bucketCountThresholds ); } @@ -135,15 +140,14 @@ protected Class implementationClass() { name, longTerms.reduceOrder, order, - requiredSize, - minDocCount, metadata, format, shardSize, showTermDocCountError, otherDocCount, buckets, - docCountError + docCountError, + new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, shardSize) ); } else { String name = instance.getName(); @@ -172,7 +176,7 @@ protected Class implementationClass() { default: throw new AssertionError("Illegal randomisation branch"); } - return new UnmappedTerms(name, order, requiredSize, minDocCount, metadata); + return new UnmappedTerms(name, order, new TermsAggregator.BucketCountThresholds(minDocCount, 0, requiredSize, 0), metadata); } } } diff --git a/test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java b/test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java index 874d60a4097f2..27c406b019c77 100644 --- a/test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java +++ b/test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java @@ -350,6 +350,7 @@ public boolean shouldCache(Query query) { when(searchContext.aggregations()).thenReturn(new SearchContextAggregations(AggregatorFactories.EMPTY, bucketConsumer)); when(searchContext.query()).thenReturn(query); when(searchContext.bucketCollectorProcessor()).thenReturn(new BucketCollectorProcessor()); + when(searchContext.asLocalBucketCountThresholds(any())).thenCallRealMethod(); /* * Always use the circuit breaking big arrays instance so that the CircuitBreakerService * we're passed gets a chance to break. From 7278f434cd83f095623e34c2105f1b79d247af18 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Wed, 9 Aug 2023 15:10:55 -0500 Subject: [PATCH 09/26] [Refactor] From XContentType.JSON to MediaTypeRegistry.JSON (#9156) This commit rote refactors nearly all instances and usages of the XContentType.JSON singleton instance defined in the :libs:opensearch-x-content library to the MediaTypeRegistry.JSON singleton instance defined in :libs:opensearch-core. This decouples the server and test implementations from the x-content library such that foundation classes can be further refactored from the :server module to the :opensearch-core library without requiring a strict dependency on the x-content library. This keeps opensearch-core library loosely coupled with the remaining :libs:opensearch-* libraries such that serverless and cloud-native implementations can selective import only the libraries needed for implementation. Signed-off-by: Nicholas Walter Knize --- .../opensearch/client/RequestConverters.java | 22 +++-- .../indices/GetFieldMappingsResponse.java | 4 +- .../indices/PutIndexTemplateRequest.java | 8 +- .../client/slm/SnapshotLifecyclePolicy.java | 4 +- .../slm/SnapshotLifecyclePolicyMetadata.java | 4 +- .../client/slm/SnapshotLifecycleStats.java | 4 +- .../slm/SnapshotRetentionConfiguration.java | 4 +- .../forbidden/rest-high-level-signatures.txt | 2 +- .../opensearch/client/BulkProcessorIT.java | 16 ++-- .../client/BulkProcessorRetryIT.java | 4 +- .../BulkRequestWithGlobalParametersIT.java | 30 +++---- .../opensearch/client/ClusterClientIT.java | 4 +- .../java/org/opensearch/client/CrudIT.java | 57 ++++++------ .../CustomRestHighLevelClientTests.java | 6 +- .../opensearch/client/IndicesClientIT.java | 10 +-- .../client/IndicesRequestConvertersTests.java | 4 +- .../client/IngestRequestConvertersTests.java | 6 +- ...OpenSearchRestHighLevelClientTestCase.java | 3 +- .../java/org/opensearch/client/ReindexIT.java | 26 +++--- .../client/RequestConvertersTests.java | 87 +++++++++--------- .../client/RestHighLevelClientTests.java | 2 +- .../java/org/opensearch/client/SearchIT.java | 4 +- .../org/opensearch/client/SnapshotIT.java | 4 +- .../opensearch/client/StoredScriptsIT.java | 32 +++++-- .../java/org/opensearch/client/TasksIT.java | 6 +- .../opensearch/client/UpdateByQueryIT.java | 16 ++-- .../documentation/CRUDDocumentationIT.java | 24 ++--- .../ClusterClientDocumentationIT.java | 4 +- .../IndicesClientDocumentationIT.java | 27 +++--- .../IngestClientDocumentationIT.java | 10 +-- .../documentation/SearchDocumentationIT.java | 50 ++++++----- .../SnapshotClientDocumentationIT.java | 6 +- .../StoredScriptsDocumentationIT.java | 20 +++-- .../GetIndexTemplatesResponseTests.java | 4 +- .../opensearch/test/rest/NodeRestUsageIT.java | 9 +- .../core/xcontent/MapXContentParser.java | 8 +- .../core/xcontent/XContentHelper.java | 53 +++++++++++ .../core/xcontent/XContentParser.java | 4 +- ...ultShardOperationFailedExceptionTests.java | 9 +- .../common/xcontent/ObjectParserTests.java | 9 +- .../ingest/common/IngestRestartIT.java | 14 +-- .../ingest/common/ScriptProcessor.java | 4 +- .../ingest/common/JsonProcessorTests.java | 4 +- .../geoip/GeoIpProcessorNonIngestNodeIT.java | 4 +- .../script/expression/StoredExpressionIT.java | 6 +- .../script/mustache/SearchTemplateIT.java | 52 ++++++----- .../mustache/CustomMustacheFactory.java | 4 +- .../mustache/MultiSearchTemplateResponse.java | 4 +- .../mustache/SearchTemplateResponse.java | 5 +- .../TransportSearchTemplateAction.java | 5 +- .../MultiSearchTemplateRequestTests.java | 18 ++-- .../mustache/SearchTemplateResponseTests.java | 2 +- .../action/PainlessExecuteApiTests.java | 10 +-- .../index/mapper/BWCTemplateTests.java | 8 +- .../RankFeatureMetaFieldMapperTests.java | 3 +- .../mapper/ScaledFloatFieldMapperTests.java | 20 ++--- .../SearchAsYouTypeFieldMapperTests.java | 6 +- .../mapper/ParentJoinFieldMapperTests.java | 38 +++++--- .../percolator/PercolatorQuerySearchIT.java | 83 +++++++++-------- .../percolator/PercolateQueryBuilder.java | 10 +-- .../PercolateQueryBuilderTests.java | 10 +-- .../PercolateWithNestedQueryBuilderTests.java | 10 ++- .../PercolatorFieldMapperTests.java | 36 ++++---- .../PercolatorQuerySearchTests.java | 14 +-- .../index/rankeval/RankEvalResponse.java | 4 +- .../index/rankeval/RankEvalSpec.java | 4 +- .../index/rankeval/RatedDocument.java | 4 +- .../index/rankeval/RatedRequest.java | 4 +- .../rankeval/TransportRankEvalAction.java | 4 +- .../DiscountedCumulativeGainTests.java | 4 +- .../index/rankeval/EvalQueryQualityTests.java | 2 +- .../index/rankeval/RankEvalResponseTests.java | 4 +- .../reindex/AsyncBulkByScrollActionTests.java | 4 +- .../opensearch/index/reindex/CancelTests.java | 6 +- .../index/reindex/RestReindexActionTests.java | 6 +- .../common/SearchPipelineCommonIT.java | 4 +- .../common/FilterQueryRequestProcessor.java | 4 +- .../common/ScriptRequestProcessor.java | 4 +- .../ICUCollationKeywordFieldMapperIT.java | 70 ++++++++++----- .../plugin/correlation/utils/IndexUtils.java | 6 +- .../query/CorrelationQueryBuilderTests.java | 4 +- .../index/mapper/size/SizeMappingIT.java | 4 +- .../index/mapper/size/SizeMappingTests.java | 8 +- .../repositories/gcs/TestUtils.java | 4 +- .../upgrades/FullClusterRestartIT.java | 5 +- .../java/org/opensearch/search/CCSDuelIT.java | 14 +-- .../org/opensearch/upgrades/RecoveryIT.java | 3 +- .../http/SearchRestCancellationIT.java | 15 ++-- .../cluster/node/tasks/AbstractTasksIT.java | 4 +- .../admin/cluster/node/tasks/TasksIT.java | 8 +- .../admin/indices/create/CloneIndexIT.java | 6 +- .../admin/indices/create/ShrinkIndexIT.java | 24 ++--- .../admin/indices/create/SplitIndexIT.java | 12 +-- .../datastream/DataStreamTestCase.java | 4 +- .../indices/datastream/DataStreamUsageIT.java | 11 ++- .../action/bulk/BulkIntegrationIT.java | 12 +-- .../bulk/BulkProcessorClusterSettingsIT.java | 8 +- .../action/bulk/BulkWithUpdatesIT.java | 26 +++--- .../action/ingest/AsyncIngestProcessorIT.java | 6 +- .../support/WaitActiveShardCountIT.java | 12 +-- .../opensearch/aliases/IndexAliasesIT.java | 89 ++++++++++--------- .../opensearch/cluster/SimpleDataNodesIT.java | 9 +- .../cluster/routing/PrimaryAllocationIT.java | 4 +- .../ClusterDisruptionCleanSettingsIT.java | 4 +- .../discovery/ClusterDisruptionIT.java | 12 ++- .../discovery/ClusterManagerDisruptionIT.java | 8 +- .../document/DocumentActionsIT.java | 4 +- .../org/opensearch/document/ShardInfoIT.java | 12 +-- .../java/org/opensearch/get/GetActionIT.java | 16 ++-- .../org/opensearch/index/FinalPipelineIT.java | 46 +++++++--- .../index/IndexRequestBuilderIT.java | 10 +-- .../index/engine/MaxDocsLimitIT.java | 4 +- .../index/seqno/GlobalCheckpointSyncIT.java | 10 +-- .../shard/GlobalCheckpointListenersIT.java | 4 +- .../opensearch/index/shard/IndexShardIT.java | 46 +++++----- .../opensearch/index/shard/SearchIdleIT.java | 12 +-- ...DateMathIndexExpressionsIntegrationIT.java | 14 +-- .../mapping/UpdateMappingIntegrationIT.java | 16 ++-- .../indices/recovery/IndexRecoveryIT.java | 23 ++--- .../indices/stats/IndexStatsIT.java | 9 +- .../template/SimpleIndexTemplateIT.java | 18 ++-- .../org/opensearch/ingest/IngestClientIT.java | 36 ++++---- ...gestProcessorNotInstalledOnAllNodesIT.java | 8 +- .../org/opensearch/mget/SimpleMgetIT.java | 4 +- .../org/opensearch/recovery/RelocationIT.java | 8 +- .../opensearch/recovery/SimpleRecoveryIT.java | 6 +- .../remotestore/PrimaryTermValidationIT.java | 4 +- .../RemoteStoreBackpressureIT.java | 4 +- .../opensearch/script/StoredScriptsIT.java | 13 ++- .../search/SearchCancellationIT.java | 6 +- .../search/aggregations/bucket/NestedIT.java | 6 +- .../SignificantTermsSignificanceScoreIT.java | 4 +- .../bucket/TermsShardMinDocCountIT.java | 8 +- .../metrics/ScriptedMetricIT.java | 10 +-- .../aggregations/pipeline/BucketScriptIT.java | 4 +- .../pipeline/BucketSelectorIT.java | 4 +- .../aggregations/pipeline/MaxBucketIT.java | 6 +- .../fetch/subphase/MatchedQueriesIT.java | 8 +- .../search/fields/SearchFieldsIT.java | 16 ++-- .../opensearch/search/geo/GeoFilterIT.java | 10 +-- .../search/geo/GeoShapeIntegrationIT.java | 10 +-- .../geo/LegacyGeoShapeIntegrationIT.java | 4 +- .../search/msearch/MultiSearchIT.java | 4 +- .../search/nested/SimpleNestedIT.java | 10 +-- .../search/preference/SearchPreferenceIT.java | 4 +- .../search/query/QueryStringIT.java | 8 +- .../search/query/SearchQueryIT.java | 6 +- .../search/query/SimpleQueryStringIT.java | 22 ++--- .../search/simple/SimpleSearchIT.java | 28 +++--- .../opensearch/search/sort/FieldSortIT.java | 12 +-- .../SnapshotCustomPluginStateIT.java | 6 +- .../cluster/health/ClusterHealthResponse.java | 4 +- .../tasks/cancel/CancelTasksResponse.java | 4 +- .../node/tasks/get/GetTaskResponse.java | 4 +- .../node/tasks/list/ListTasksResponse.java | 4 +- .../restore/RestoreRemoteStoreRequest.java | 4 +- .../stats/RemoteStoreStatsResponse.java | 4 +- .../put/PutRepositoryRequest.java | 8 +- .../verify/VerifyRepositoryResponse.java | 4 +- .../settings/ClusterGetSettingsResponse.java | 4 +- .../ClusterUpdateSettingsRequest.java | 10 +-- .../snapshots/clone/CloneSnapshotRequest.java | 4 +- .../create/CreateSnapshotRequest.java | 3 +- .../snapshots/get/GetSnapshotsResponse.java | 4 +- .../restore/RestoreSnapshotRequest.java | 3 +- .../snapshots/status/SnapshotStats.java | 4 +- .../snapshots/status/SnapshotStatus.java | 4 +- .../admin/cluster/stats/AnalysisStats.java | 4 +- .../admin/cluster/stats/MappingStats.java | 4 +- .../storedscripts/PutStoredScriptRequest.java | 6 +- .../PutStoredScriptRequestBuilder.java | 6 +- .../indices/alias/IndicesAliasesRequest.java | 5 +- .../admin/indices/analyze/AnalyzeAction.java | 4 +- .../indices/close/CloseIndexResponse.java | 10 +-- .../indices/create/CreateIndexRequest.java | 2 +- .../create/CreateIndexRequestBuilder.java | 12 +-- .../admin/indices/get/GetIndexResponse.java | 4 +- .../mapping/get/GetFieldMappingsResponse.java | 6 +- .../mapping/get/GetMappingsResponse.java | 4 +- .../TransportGetFieldMappingsIndexAction.java | 6 +- .../mapping/put/PutMappingRequest.java | 9 +- .../mapping/put/PutMappingRequestBuilder.java | 6 +- .../readonly/AddIndexBlockResponse.java | 10 +-- .../indices/recovery/RecoveryResponse.java | 4 +- .../SegmentReplicationStatsResponse.java | 4 +- .../admin/indices/rollover/RolloverInfo.java | 4 +- .../settings/put/UpdateSettingsRequest.java | 9 +- .../indices/stats/IndicesStatsResponse.java | 4 +- .../template/put/PutIndexTemplateRequest.java | 12 +-- .../put/PutIndexTemplateRequestBuilder.java | 19 ++-- .../action/bulk/BulkItemRequest.java | 4 +- .../action/bulk/BulkItemResponse.java | 4 +- .../opensearch/action/bulk/BulkProcessor.java | 11 +-- .../action/bulk/BulkRequestParser.java | 3 +- .../action/fieldcaps/FieldCapabilities.java | 4 +- .../fieldcaps/FieldCapabilitiesResponse.java | 4 +- .../opensearch/action/get/GetResponse.java | 4 +- .../action/get/MultiGetRequest.java | 4 +- .../action/index/IndexRequestBuilder.java | 28 +++--- .../action/index/IndexResponse.java | 4 +- .../action/ingest/GetPipelineResponse.java | 4 +- .../ingest/PutPipelineRequestBuilder.java | 6 +- .../SimulatePipelineRequestBuilder.java | 6 +- .../search/GetSearchPipelineResponse.java | 4 +- .../action/search/MultiSearchResponse.java | 4 +- .../action/search/SearchResponse.java | 4 +- .../support/replication/ReplicationTask.java | 4 +- .../action/update/UpdateHelper.java | 9 +- .../action/update/UpdateRequest.java | 41 +++++---- .../action/update/UpdateRequestBuilder.java | 40 ++++----- .../opensearch/client/ClusterAdminClient.java | 6 +- .../java/org/opensearch/client/Requests.java | 4 +- .../client/support/AbstractClient.java | 10 +-- .../cluster/RepositoryCleanupInProgress.java | 4 +- .../cluster/SnapshotsInProgress.java | 4 +- .../action/index/MappingUpdatedAction.java | 4 +- .../ClusterAwarenessAttributeValueHealth.java | 4 +- .../ClusterAwarenessAttributesHealth.java | 4 +- .../cluster/coordination/Coordinator.java | 14 +-- .../DecommissionAttributeMetadata.java | 4 +- .../cluster/health/ClusterShardHealth.java | 4 +- .../cluster/metadata/AliasMetadata.java | 3 +- .../cluster/metadata/ComponentTemplate.java | 4 +- .../metadata/ComponentTemplateMetadata.java | 4 +- .../metadata/ComposableIndexTemplate.java | 4 +- .../ComposableIndexTemplateMetadata.java | 4 +- .../cluster/metadata/DataStreamMetadata.java | 4 +- .../MetadataIndexTemplateService.java | 4 +- .../metadata/RepositoriesMetadata.java | 4 +- .../metadata/TemplateUpgradeService.java | 11 ++- .../metadata/WeightedRoutingMetadata.java | 4 +- .../command/AllocationCommands.java | 4 +- .../common/geo/builders/ShapeBuilder.java | 4 +- .../opensearch/common/settings/Setting.java | 8 +- .../opensearch/common/settings/Settings.java | 16 ++-- .../common/settings/SettingsModule.java | 4 +- .../xcontent/JsonToStringXContentParser.java | 8 +- .../common/xcontent/XContentHelper.java | 61 +++++-------- .../org/opensearch/index/get/GetResult.java | 4 +- .../mapper/AbstractGeometryFieldMapper.java | 4 +- .../index/mapper/DocumentMapper.java | 6 +- .../index/mapper/DocumentMapperParser.java | 4 +- .../index/mapper/GeoShapeParser.java | 4 +- .../index/mapper/MapperService.java | 8 +- .../index/mapper/RootObjectMapper.java | 4 +- .../index/query/AbstractQueryBuilder.java | 4 +- .../index/query/InnerHitBuilder.java | 4 +- .../index/query/MoreLikeThisQueryBuilder.java | 3 +- .../index/query/SpanNearQueryBuilder.java | 4 +- .../index/reindex/BulkByScrollTask.java | 6 +- .../index/reindex/ScrollableHitSource.java | 4 +- .../index/search/stats/SearchStats.java | 4 +- .../index/shard/PrimaryReplicaSyncer.java | 4 +- .../RemoveCorruptedShardDataCommand.java | 4 +- .../index/translog/TranslogStats.java | 4 +- .../opensearch/indices/IndicesService.java | 3 +- .../opensearch/ingest/ConfigurationUtils.java | 4 +- .../ingest/PipelineConfiguration.java | 3 +- .../PersistentTasksCustomMetadata.java | 6 +- .../PersistentTasksNodeService.java | 4 +- .../repositories/RepositoryCleanupResult.java | 4 +- .../repositories/RepositoryInfo.java | 4 +- .../repositories/RepositoryStatsSnapshot.java | 4 +- .../blobstore/BlobStoreRepository.java | 6 +- .../org/opensearch/rest/RestController.java | 3 +- .../java/org/opensearch/rest/RestRequest.java | 8 +- .../opensearch/rest/action/cat/RestTable.java | 4 +- .../java/org/opensearch/script/Script.java | 3 +- .../opensearch/script/StoredScriptSource.java | 4 +- .../java/org/opensearch/search/SearchHit.java | 6 +- .../aggregations/AggregationBuilder.java | 4 +- .../aggregations/AggregatorFactories.java | 4 +- .../search/aggregations/BucketOrder.java | 4 +- .../aggregations/InternalAggregation.java | 4 +- .../PipelineAggregationBuilder.java | 4 +- .../BaseMultiValuesSourceFieldConfig.java | 4 +- .../search/builder/SearchSourceBuilder.java | 6 +- .../highlight/AbstractHighlighterBuilder.java | 4 +- .../pipeline/PipelineConfiguration.java | 3 +- .../search/rescore/RescorerBuilder.java | 4 +- .../opensearch/search/slice/SliceBuilder.java | 4 +- .../opensearch/search/sort/SortBuilder.java | 4 +- .../opensearch/search/suggest/Suggest.java | 4 +- .../search/suggest/SuggestBuilder.java | 4 +- .../CompletionSuggestionBuilder.java | 10 +-- .../org/opensearch/snapshots/RestoreInfo.java | 4 +- .../org/opensearch/tasks/RawTaskStatus.java | 3 +- .../java/org/opensearch/tasks/TaskInfo.java | 4 +- .../opensearch/tasks/TaskResourceStats.java | 4 +- .../opensearch/tasks/TaskResourceUsage.java | 4 +- .../java/org/opensearch/tasks/TaskResult.java | 5 +- .../opensearch/tasks/TaskResultsService.java | 3 +- .../org/opensearch/tasks/TaskThreadUsage.java | 4 +- .../ExceptionSerializationTests.java | 6 +- .../opensearch/OpenSearchExceptionTests.java | 3 +- .../RenamedTimeoutRequestParameterTests.java | 4 +- .../node/tasks/TransportTasksActionTests.java | 5 +- .../RestoreRemoteStoreRequestTests.java | 4 +- .../ClusterUpdateSettingsRequestTests.java | 13 +-- ...ClusterPutWeightedRoutingRequestTests.java | 14 +-- .../create/CreateSnapshotRequestTests.java | 4 +- .../restore/RestoreSnapshotRequestTests.java | 4 +- .../cluster/stats/ClusterStatsNodesTests.java | 18 ++-- .../GetStoredScriptResponseTests.java | 4 +- .../PutStoredScriptRequestTests.java | 7 +- .../indices/alias/AliasActionsTests.java | 2 +- .../close/CloseIndexResponseTests.java | 5 +- .../CreateIndexRequestBuilderTests.java | 10 +-- .../create/CreateIndexRequestTests.java | 2 +- .../create/CreateIndexResponseTests.java | 6 +- .../forcemerge/RestForceMergeActionTests.java | 4 +- .../get/GetFieldMappingsResponseTests.java | 4 +- .../mapping/put/PutMappingRequestTests.java | 13 +-- .../rollover/RolloverRequestTests.java | 2 +- .../indices/shrink/ResizeRequestTests.java | 5 +- .../indices/shrink/ResizeResponseTests.java | 4 +- .../indices/stats/IndicesStatsTests.java | 4 +- .../put/PutIndexTemplateRequestTests.java | 4 +- .../query/ValidateQueryResponseTests.java | 4 +- .../action/bulk/BulkProcessorTests.java | 6 +- .../action/bulk/BulkRequestModifierTests.java | 4 +- .../action/bulk/BulkRequestParserTests.java | 40 ++++++--- .../action/bulk/BulkRequestTests.java | 38 ++++---- .../action/bulk/BulkResponseTests.java | 2 +- .../bulk/TransportBulkActionTookTests.java | 4 +- .../action/delete/DeleteResponseTests.java | 5 +- .../action/explain/ExplainResponseTests.java | 3 +- .../MergedFieldCapabilitiesResponseTests.java | 3 +- .../action/get/GetResponseTests.java | 9 +- .../get/TransportMultiGetActionTests.java | 6 +- .../index/IndexRequestBuilderTests.java | 6 +- .../action/index/IndexRequestTests.java | 20 ++--- .../action/index/IndexResponseTests.java | 5 +- .../ingest/PutPipelineRequestTests.java | 11 ++- .../ingest/SimulatePipelineRequestTests.java | 10 +-- .../search/MultiSearchRequestTests.java | 32 +++---- .../SearchPhaseExecutionExceptionTests.java | 3 +- .../action/search/SearchResponseTests.java | 9 +- .../search/ShardSearchFailureTests.java | 7 +- .../replication/ReplicationResponseTests.java | 7 +- .../termvectors/TermVectorsUnitTests.java | 10 +-- .../TransportMultiTermVectorsActionTests.java | 6 +- .../action/update/UpdateRequestTests.java | 11 +-- .../action/update/UpdateResponseTests.java | 31 +++---- .../client/AbstractClientHeadersTestCase.java | 4 +- .../cluster/metadata/IndexGraveyardTests.java | 4 +- .../cluster/metadata/IndexMetadataTests.java | 6 +- .../metadata/IndexTemplateMetadataTests.java | 14 +-- .../MetadataIndexTemplateServiceTests.java | 6 +- .../ClusterStateToStringTests.java | 4 +- .../common/geo/GeoJsonSerializationTests.java | 4 +- .../common/settings/SettingsTests.java | 13 +-- .../common/xcontent/XContentFactoryTests.java | 15 ++-- .../xcontent/XContentParserUtilsTests.java | 5 +- .../common/xcontent/XContentTypeTests.java | 19 ++-- .../builder/XContentBuilderTests.java | 50 +++++------ .../common/xcontent/cbor/JsonVsCborTests.java | 3 +- .../xcontent/smile/JsonVsSmileTests.java | 3 +- .../xcontent/support/XContentHelperTests.java | 5 +- .../support/XContentMapValuesTests.java | 2 +- .../rest/ExtensionRestRequestTests.java | 7 +- .../rest/ExtensionRestResponseTests.java | 4 +- .../RestInitializeExtensionActionTests.java | 10 +-- .../opensearch/index/IndexServiceTests.java | 20 +++-- .../index/IndexingSlowLogTests.java | 8 +- .../index/engine/InternalEngineTests.java | 4 +- .../fielddata/BinaryDVFieldDataTests.java | 10 +-- .../index/get/DocumentFieldTests.java | 18 ++-- .../opensearch/index/get/GetResultTests.java | 38 ++++---- .../mapper/CompletionFieldMapperTests.java | 4 +- .../mapper/DataStreamFieldMapperTests.java | 12 +-- .../index/mapper/DocumentParserTests.java | 10 +-- .../index/mapper/DynamicMappingTests.java | 20 ++--- .../mapper/FieldFilterMapperPluginTests.java | 4 +- .../mapper/FieldNamesFieldMapperTests.java | 8 +- .../mapper/FlatObjectFieldDataTests.java | 4 +- .../GenericStoreDynamicTemplateTests.java | 8 +- .../mapper/GeoShapeFieldMapperTests.java | 4 +- .../index/mapper/IdFieldMapperTests.java | 6 +- .../index/mapper/IndexFieldMapperTests.java | 4 +- .../index/mapper/IpRangeFieldMapperTests.java | 4 +- .../mapper/JavaMultiFieldMergeTests.java | 10 +-- .../LegacyGeoShapeFieldMapperTests.java | 14 +-- .../index/mapper/MultiFieldTests.java | 6 +- .../index/mapper/NestedObjectMapperTests.java | 36 ++++---- .../mapper/NestedPathFieldMapperTests.java | 4 +- .../mapper/NullValueObjectMappingTests.java | 8 +- .../index/mapper/NumberFieldMapperTests.java | 4 +- .../index/mapper/NumberFieldTypeTests.java | 4 +- .../index/mapper/ObjectMapperTests.java | 4 +- .../mapper/PathMatchDynamicTemplateTests.java | 8 +- .../index/mapper/RoutingFieldMapperTests.java | 6 +- .../index/mapper/SourceFieldMapperTests.java | 12 +-- .../mapper/StoredNumericValuesTests.java | 4 +- .../index/query/WrapperQueryBuilderTests.java | 5 +- .../IndexLevelReplicationTests.java | 36 ++++---- .../RecoveryDuringReplicationTests.java | 35 ++++---- .../index/shard/IndexShardTests.java | 22 ++--- .../shard/PrimaryReplicaSyncerTests.java | 6 +- .../index/shard/RefreshListenersTests.java | 13 ++- .../SegmentReplicationIndexShardTests.java | 10 +-- ...licationWithNodeToNodeIndexShardTests.java | 10 +-- .../index/shard/ShardGetServiceTests.java | 10 +-- .../snapshots/blobstore/FileInfoTests.java | 5 +- ...oteStoreShardShallowCopySnapshotTests.java | 5 +- .../index/translog/LocalTranslogTests.java | 4 +- .../translog/TranslogManagerTestCase.java | 4 +- .../IndexingMemoryControllerTests.java | 4 +- .../indices/IndicesRequestCacheTests.java | 16 ++-- ...alStorePeerRecoverySourceHandlerTests.java | 4 +- .../PeerRecoveryTargetServiceTests.java | 4 +- .../indices/recovery/RecoveryTests.java | 14 +-- .../OngoingSegmentReplicationsTests.java | 6 +- .../SegmentReplicationSourceHandlerTests.java | 4 +- .../ingest/IngestMetadataTests.java | 36 ++++---- .../opensearch/ingest/IngestServiceTests.java | 75 ++++++++-------- .../ingest/PipelineConfigurationTests.java | 11 +-- .../persistent/TestPersistentTasksPlugin.java | 4 +- .../repositories/RepositoryDataTests.java | 3 +- .../opensearch/rest/BaseRestHandlerTests.java | 6 +- .../opensearch/rest/RestControllerTests.java | 18 ++-- ...tClusterAddWeightedRoutingActionTests.java | 4 +- ...usterDeleteWeightedRoutingActionTests.java | 6 +- .../RestReloadSecureSettingsActionTests.java | 6 +- .../admin/indices/RestAnalyzeActionTests.java | 4 +- .../indices/RestGetAliasesActionTests.java | 15 ++-- .../indices/RestValidateQueryActionTests.java | 4 +- .../rest/action/cat/RestTableTests.java | 3 +- .../action/document/RestBulkActionTests.java | 4 +- .../action/document/RestIndexActionTests.java | 4 +- .../document/RestUpdateActionTests.java | 4 +- .../script/ScriptContextInfoTests.java | 8 +- .../script/ScriptMetadataTests.java | 48 ++++++---- .../opensearch/script/ScriptServiceTests.java | 12 ++- .../org/opensearch/script/ScriptTests.java | 8 +- .../script/StoredScriptSourceTests.java | 12 +-- .../opensearch/script/StoredScriptTests.java | 49 +++++----- .../org/opensearch/search/SearchHitTests.java | 32 +++---- .../opensearch/search/SearchHitsTests.java | 17 ++-- .../search/SearchSortValuesTests.java | 15 ++-- .../opensearch/search/geo/GeoQueryTests.java | 4 +- .../search/geo/GeoShapeQueryTests.java | 10 +-- .../pipeline/SearchPipelineServiceTests.java | 46 +++++----- .../pipeline/SearchPipelineStatsTests.java | 6 +- .../search/pit/RestDeletePitActionTests.java | 8 +- .../search/profile/ProfileResultTests.java | 2 +- .../SearchProfileShardResultsTests.java | 2 +- .../AggregationProfileShardResultTests.java | 7 +- .../profile/query/CollectorResultTests.java | 2 +- .../query/QueryProfileShardResultTests.java | 2 +- .../scroll/RestClearScrollActionTests.java | 6 +- .../scroll/RestSearchScrollActionTests.java | 6 +- .../searchafter/SearchAfterBuilderTests.java | 2 +- .../search/sort/SortValueTests.java | 4 +- .../CompletionSuggestionOptionTests.java | 5 +- .../search/suggest/SuggestTests.java | 5 +- .../search/suggest/SuggestionEntryTests.java | 9 +- .../search/suggest/SuggestionOptionTests.java | 5 +- .../search/suggest/SuggestionTests.java | 11 +-- .../suggest/TermSuggestionOptionTests.java | 5 +- .../CategoryContextMappingTests.java | 20 ++--- .../completion/GeoContextMappingTests.java | 10 +-- .../SharedSignificantTermsTestMethods.java | 6 +- .../threadpool/ThreadPoolStatsTests.java | 4 +- .../index/engine/EngineTestCase.java | 19 ++-- .../index/mapper/MapperServiceTestCase.java | 6 +- ...enSearchIndexLevelReplicationTestCase.java | 6 +- .../index/shard/IndexShardTestCase.java | 9 +- .../blobstore/BlobStoreTestUtil.java | 4 +- .../search/RandomSearchRequestGenerator.java | 4 +- .../aggregations/BaseAggregationTestCase.java | 4 +- ...ternalSingleBucketAggregationTestCase.java | 2 +- .../AbstractBroadcastResponseTestCase.java | 3 +- .../test/AbstractQueryTestCase.java | 17 ++-- .../test/AbstractSerializingTestCase.java | 3 +- .../test/AbstractXContentTestCase.java | 21 ++--- .../test/InternalAggregationTestCase.java | 2 +- .../test/OpenSearchIntegTestCase.java | 5 +- .../opensearch/test/OpenSearchTestCase.java | 6 +- .../org/opensearch/test/RandomObjects.java | 10 +-- .../test/hamcrest/OpenSearchAssertions.java | 7 +- .../test/rest/OpenSearchRestTestCase.java | 12 +-- .../yaml/ClientYamlTestExecutionContext.java | 6 +- .../rest/yaml/ClientYamlTestResponse.java | 3 +- .../OpenSearchClientYamlSuiteTestCase.java | 4 +- .../test/AbstractXContentTestCaseTests.java | 6 +- .../test/XContentTestUtilsTests.java | 16 ++-- 487 files changed, 2523 insertions(+), 2210 deletions(-) create mode 100644 libs/core/src/main/java/org/opensearch/core/xcontent/XContentHelper.java diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java index c48acfc5b6ece..6bc691a74a2c4 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java @@ -78,9 +78,9 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.core.common.util.CollectionUtils; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContent; @@ -119,7 +119,7 @@ * @opensearch.api */ final class RequestConverters { - static final XContentType REQUEST_BODY_CONTENT_TYPE = XContentType.JSON; + static final MediaType REQUEST_BODY_CONTENT_TYPE = MediaTypeRegistry.JSON; private RequestConverters() { // Contains only status utility methods @@ -177,7 +177,7 @@ static Request bulk(BulkRequest bulkRequest) throws IOException { } if (bulkContentType == null) { - bulkContentType = XContentType.JSON; + bulkContentType = MediaTypeRegistry.JSON; } final byte separator = bulkContentType.xContent().streamSeparator(); @@ -266,7 +266,12 @@ static Request bulk(BulkRequest bulkRequest) throws IOException { } } } else if (opType == DocWriteRequest.OpType.UPDATE) { - source = XContentHelper.toXContent((UpdateRequest) action, bulkContentType, ToXContent.EMPTY_PARAMS, false).toBytesRef(); + source = org.opensearch.core.xcontent.XContentHelper.toXContent( + (UpdateRequest) action, + bulkContentType, + ToXContent.EMPTY_PARAMS, + false + ).toBytesRef(); } if (source != null) { @@ -821,7 +826,8 @@ static HttpEntity createEntity(ToXContent toXContent, MediaType mediaType) throw } static HttpEntity createEntity(ToXContent toXContent, MediaType mediaType, ToXContent.Params toXContentParams) throws IOException { - BytesRef source = XContentHelper.toXContent(toXContent, mediaType, toXContentParams, false).toBytesRef(); + BytesRef source = org.opensearch.core.xcontent.XContentHelper.toXContent(toXContent, mediaType, toXContentParams, false) + .toBytesRef(); return new ByteArrayEntity(source.bytes, source.offset, source.length, createContentType(mediaType)); } @@ -868,12 +874,12 @@ static String endpoint(String[] indices, String endpoint, String type) { } /** - * Returns a {@link ContentType} from a given {@link XContentType}. + * Returns a {@link ContentType} from a given {@link MediaType}. * * @param mediaType the {@link MediaType} * @return the {@link ContentType} */ - @SuppressForbidden(reason = "Only allowed place to convert a XContentType to a ContentType") + @SuppressForbidden(reason = "Only allowed place to convert a MediaType to a ContentType") public static ContentType createContentType(final MediaType mediaType) { return ContentType.create(mediaType.mediaTypeWithoutParameters(), (Charset) null); } @@ -1252,7 +1258,7 @@ Params withWaitForEvents(Priority waitForEvents) { */ static MediaType enforceSameContentType(IndexRequest indexRequest, @Nullable MediaType mediaType) { MediaType requestContentType = indexRequest.getContentType(); - if (requestContentType != XContentType.JSON && requestContentType != XContentType.SMILE) { + if (requestContentType != MediaTypeRegistry.JSON && requestContentType != MediaTypeRegistry.fromFormat("smile")) { throw new IllegalArgumentException( "Unsupported content-type found for request with content-type [" + requestContentType diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetFieldMappingsResponse.java b/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetFieldMappingsResponse.java index 1359c68fc1311..4a298ac55999f 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetFieldMappingsResponse.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetFieldMappingsResponse.java @@ -35,11 +35,11 @@ import org.opensearch.core.ParseField; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.Mapper; import java.io.IOException; @@ -150,7 +150,7 @@ public String fullName() { * Returns the mappings as a map. Note that the returned map has a single key which is always the field's {@link Mapper#name}. */ public Map sourceAsMap() { - return XContentHelper.convertToMap(source, true, XContentType.JSON).v2(); + return XContentHelper.convertToMap(source, true, MediaTypeRegistry.JSON).v2(); } // pkg-private for testing diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/indices/PutIndexTemplateRequest.java b/client/rest-high-level/src/main/java/org/opensearch/client/indices/PutIndexTemplateRequest.java index 09dbbd63b9479..ed5db741ea6f1 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/indices/PutIndexTemplateRequest.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/indices/PutIndexTemplateRequest.java @@ -217,10 +217,10 @@ public Settings settings() { * Adds mapping that will be added when the index gets created. * * @param source The mapping source - * @param xContentType The type of content contained within the source + * @param mediaType The type of content contained within the source */ - public PutIndexTemplateRequest mapping(String source, XContentType xContentType) { - internalMapping(XContentHelper.convertToMap(new BytesArray(source), true, xContentType).v2()); + public PutIndexTemplateRequest mapping(String source, MediaType mediaType) { + internalMapping(XContentHelper.convertToMap(new BytesArray(source), true, mediaType).v2()); return this; } @@ -268,7 +268,7 @@ public PutIndexTemplateRequest mapping(Map source) { private PutIndexTemplateRequest internalMapping(Map source) { try { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder(); builder.map(source); MediaType mediaType = builder.contentType(); Objects.requireNonNull(mediaType); diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecyclePolicy.java b/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecyclePolicy.java index a6f8bfdee4d68..fd101c575b97a 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecyclePolicy.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecyclePolicy.java @@ -33,10 +33,10 @@ package org.opensearch.client.slm; import org.opensearch.common.Nullable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -169,6 +169,6 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecyclePolicyMetadata.java b/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecyclePolicyMetadata.java index 0fcb6f7c6a29e..dd44d16f0d65e 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecyclePolicyMetadata.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecyclePolicyMetadata.java @@ -33,10 +33,10 @@ package org.opensearch.client.slm; import org.opensearch.common.Nullable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -289,7 +289,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } } diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecycleStats.java b/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecycleStats.java index a2e43325ccd6f..476533d9c91ca 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecycleStats.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotLifecycleStats.java @@ -33,10 +33,10 @@ package org.opensearch.client.slm; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -188,7 +188,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } public static class SnapshotPolicyStats implements ToXContentFragment { diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotRetentionConfiguration.java b/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotRetentionConfiguration.java index 9982c0f2cef7d..3165b6bede19d 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotRetentionConfiguration.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/slm/SnapshotRetentionConfiguration.java @@ -34,10 +34,10 @@ import org.opensearch.common.Nullable; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -151,6 +151,6 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/client/rest-high-level/src/main/resources/forbidden/rest-high-level-signatures.txt b/client/rest-high-level/src/main/resources/forbidden/rest-high-level-signatures.txt index e9e793aa9a783..42dde784147c7 100644 --- a/client/rest-high-level/src/main/resources/forbidden/rest-high-level-signatures.txt +++ b/client/rest-high-level/src/main/resources/forbidden/rest-high-level-signatures.txt @@ -14,7 +14,7 @@ # either express or implied. See the License for the specific # language governing permissions and limitations under the License. -@defaultMessage Use Request#createContentType(XContentType) to be sure to pass the right MIME type +@defaultMessage Use Request#createContentType(MediaType) to be sure to pass the right MIME type org.apache.hc.core5.http.ContentType#create(java.lang.String) org.apache.hc.core5.http.ContentType#create(java.lang.String,java.lang.String) org.apache.hc.core5.http.ContentType#create(java.lang.String,java.nio.charset.Charset) diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorIT.java index 2aeb47de150d6..077e1e5bf8aa5 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorIT.java @@ -42,12 +42,12 @@ import org.opensearch.action.get.MultiGetResponse; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.search.SearchRequest; +import org.opensearch.common.unit.TimeValue; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.unit.ByteSizeValue; -import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.search.SearchHit; import org.hamcrest.Matcher; @@ -277,12 +277,12 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception // let's make sure we get at least 1 item in the MultiGetRequest regardless of the randomising roulette if (randomBoolean() || multiGetRequest.getItems().size() == 0) { testDocs++; - processor.add(new IndexRequest("test").id(Integer.toString(testDocs)).source(XContentType.JSON, "field", "value")); + processor.add(new IndexRequest("test").id(Integer.toString(testDocs)).source(MediaTypeRegistry.JSON, "field", "value")); multiGetRequest.add("test", Integer.toString(testDocs)); } else { testReadOnlyDocs++; processor.add( - new IndexRequest("test-ro").id(Integer.toString(testReadOnlyDocs)).source(XContentType.JSON, "field", "value") + new IndexRequest("test-ro").id(Integer.toString(testReadOnlyDocs)).source(MediaTypeRegistry.JSON, "field", "value") ); } } @@ -333,9 +333,9 @@ public void testGlobalParametersAndSingleRequest() throws Exception { processor.add(new IndexRequest() // <1> - .source(XContentType.JSON, "user", "some user")); + .source(MediaTypeRegistry.JSON, "user", "some user")); processor.add(new IndexRequest("blogs").id("1") // <2> - .source(XContentType.JSON, "title", "some title")); + .source(MediaTypeRegistry.JSON, "title", "some title")); } // end::bulk-processor-mix-parameters latch.await(); @@ -399,11 +399,11 @@ private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String l if (randomBoolean()) { processor.add( new IndexRequest(localIndex).id(Integer.toString(i)) - .source(XContentType.JSON, "field", randomRealisticUnicodeOfLengthBetween(1, 30)) + .source(MediaTypeRegistry.JSON, "field", randomRealisticUnicodeOfLengthBetween(1, 30)) ); } else { BytesArray data = bytesBulkRequest(localIndex, i); - processor.add(data, globalIndex, globalPipeline, XContentType.JSON); + processor.add(data, globalIndex, globalPipeline, MediaTypeRegistry.JSON); } multiGetRequest.add(localIndex, Integer.toString(i)); } diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorRetryIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorRetryIT.java index 44bd085788203..b7f6328b3c88e 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorRetryIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorRetryIT.java @@ -40,8 +40,8 @@ import org.opensearch.action.get.MultiGetRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.rest.RestStatus; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.transport.RemoteTransportException; import java.util.Collections; @@ -170,7 +170,7 @@ private static MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) { for (int i = 1; i <= numDocs; i++) { processor.add( new IndexRequest(INDEX_NAME).id(Integer.toString(i)) - .source(XContentType.JSON, "field", randomRealisticUnicodeOfCodepointLengthBetween(1, 30)) + .source(MediaTypeRegistry.JSON, "field", randomRealisticUnicodeOfCodepointLengthBetween(1, 30)) ); multiGetRequest.add(INDEX_NAME, Integer.toString(i)); } diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/BulkRequestWithGlobalParametersIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/BulkRequestWithGlobalParametersIT.java index 35fc9d88e316c..d392aa842fb35 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/BulkRequestWithGlobalParametersIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/BulkRequestWithGlobalParametersIT.java @@ -36,7 +36,7 @@ import org.opensearch.action.bulk.BulkResponse; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.search.SearchRequest; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.search.SearchHit; import java.io.IOException; @@ -59,8 +59,8 @@ public void testGlobalPipelineOnBulkRequest() throws IOException { createFieldAddingPipleine("xyz", "fieldNameXYZ", "valueXYZ"); BulkRequest request = new BulkRequest(); - request.add(new IndexRequest("test").id("1").source(XContentType.JSON, "field", "bulk1")); - request.add(new IndexRequest("test").id("2").source(XContentType.JSON, "field", "bulk2")); + request.add(new IndexRequest("test").id("1").source(MediaTypeRegistry.JSON, "field", "bulk1")); + request.add(new IndexRequest("test").id("2").source(MediaTypeRegistry.JSON, "field", "bulk2")); request.pipeline("xyz"); bulk(request); @@ -76,8 +76,8 @@ public void testPipelineOnRequestOverridesGlobalPipeline() throws IOException { BulkRequest request = new BulkRequest(); request.pipeline("globalId"); - request.add(new IndexRequest("test").id("1").source(XContentType.JSON, "field", "bulk1").setPipeline("perIndexId")); - request.add(new IndexRequest("test").id("2").source(XContentType.JSON, "field", "bulk2").setPipeline("perIndexId")); + request.add(new IndexRequest("test").id("1").source(MediaTypeRegistry.JSON, "field", "bulk1").setPipeline("perIndexId")); + request.add(new IndexRequest("test").id("2").source(MediaTypeRegistry.JSON, "field", "bulk2").setPipeline("perIndexId")); bulk(request); @@ -96,11 +96,11 @@ public void testMixPipelineOnRequestAndGlobal() throws IOException { request.pipeline("globalId"); request.add(new IndexRequest("test").id("1") - .source(XContentType.JSON, "field", "bulk1") + .source(MediaTypeRegistry.JSON, "field", "bulk1") .setPipeline("perIndexId")); // <1> request.add(new IndexRequest("test").id("2") - .source(XContentType.JSON, "field", "bulk2")); // <2> + .source(MediaTypeRegistry.JSON, "field", "bulk2")); // <2> // end::bulk-request-mix-pipeline bulk(request); @@ -116,8 +116,8 @@ public void testMixPipelineOnRequestAndGlobal() throws IOException { public void testGlobalIndex() throws IOException { BulkRequest request = new BulkRequest("global_index"); - request.add(new IndexRequest().id("1").source(XContentType.JSON, "field", "bulk1")); - request.add(new IndexRequest().id("2").source(XContentType.JSON, "field", "bulk2")); + request.add(new IndexRequest().id("1").source(MediaTypeRegistry.JSON, "field", "bulk1")); + request.add(new IndexRequest().id("2").source(MediaTypeRegistry.JSON, "field", "bulk2")); bulk(request); @@ -128,10 +128,10 @@ public void testGlobalIndex() throws IOException { @SuppressWarnings("unchecked") public void testIndexGlobalAndPerRequest() throws IOException { BulkRequest request = new BulkRequest("global_index"); - request.add(new IndexRequest("local_index").id("1").source(XContentType.JSON, "field", "bulk1")); + request.add(new IndexRequest("local_index").id("1").source(MediaTypeRegistry.JSON, "field", "bulk1")); request.add( new IndexRequest().id("2") // will take global index - .source(XContentType.JSON, "field", "bulk2") + .source(MediaTypeRegistry.JSON, "field", "bulk2") ); bulk(request); @@ -143,8 +143,8 @@ public void testIndexGlobalAndPerRequest() throws IOException { public void testGlobalRouting() throws IOException { createIndexWithMultipleShards("index"); BulkRequest request = new BulkRequest((String) null); - request.add(new IndexRequest("index").id("1").source(XContentType.JSON, "field", "bulk1")); - request.add(new IndexRequest("index").id("2").source(XContentType.JSON, "field", "bulk1")); + request.add(new IndexRequest("index").id("1").source(MediaTypeRegistry.JSON, "field", "bulk1")); + request.add(new IndexRequest("index").id("2").source(MediaTypeRegistry.JSON, "field", "bulk1")); request.routing("1"); bulk(request); @@ -158,8 +158,8 @@ public void testGlobalRouting() throws IOException { public void testMixLocalAndGlobalRouting() throws IOException { BulkRequest request = new BulkRequest((String) null); request.routing("globalRouting"); - request.add(new IndexRequest("index").id("1").source(XContentType.JSON, "field", "bulk1")); - request.add(new IndexRequest("index").id("2").routing("localRouting").source(XContentType.JSON, "field", "bulk1")); + request.add(new IndexRequest("index").id("1").source(MediaTypeRegistry.JSON, "field", "bulk1")); + request.add(new IndexRequest("index").id("2").routing("localRouting").source(MediaTypeRegistry.JSON, "field", "bulk1")); bulk(request); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/ClusterClientIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/ClusterClientIT.java index 3c7d988e3f01d..54cb15b9cb767 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/ClusterClientIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/ClusterClientIT.java @@ -63,8 +63,8 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.support.XContentMapValues; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.indices.recovery.RecoverySettings; import org.opensearch.core.rest.RestStatus; import org.opensearch.transport.RemoteClusterService; @@ -125,7 +125,7 @@ public void testClusterPutSettings() throws IOException { ClusterUpdateSettingsRequest resetRequest = new ClusterUpdateSettingsRequest(); resetRequest.transientSettings(Settings.builder().putNull(transientSettingKey)); - resetRequest.persistentSettings("{\"" + persistentSettingKey + "\": null }", XContentType.JSON); + resetRequest.persistentSettings("{\"" + persistentSettingKey + "\": null }", MediaTypeRegistry.JSON); ClusterUpdateSettingsResponse resetResponse = execute( resetRequest, diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java index cefe992b58c64..132be80efaab2 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java @@ -63,6 +63,8 @@ import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; @@ -202,7 +204,7 @@ public void testExists() throws IOException { assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); } IndexRequest index = new IndexRequest("index").id("id"); - index.source("{\"field1\":\"value1\",\"field2\":\"value2\"}", XContentType.JSON); + index.source("{\"field1\":\"value1\",\"field2\":\"value2\"}", MediaTypeRegistry.JSON); index.setRefreshPolicy(RefreshPolicy.IMMEDIATE); highLevelClient().index(index, RequestOptions.DEFAULT); { @@ -227,7 +229,7 @@ public void testDeprecatedSourceExists() throws IOException { assertFalse(execute(getRequest, highLevelClient()::existsSource, highLevelClient()::existsSourceAsync)); } IndexRequest index = new IndexRequest("index").id("id"); - index.source("{\"field1\":\"value1\",\"field2\":\"value2\"}", XContentType.JSON); + index.source("{\"field1\":\"value1\",\"field2\":\"value2\"}", MediaTypeRegistry.JSON); index.setRefreshPolicy(RefreshPolicy.IMMEDIATE); highLevelClient().index(index, RequestOptions.DEFAULT); { @@ -250,7 +252,7 @@ public void testSourceExists() throws IOException { assertFalse(execute(getRequest, highLevelClient()::existsSource, highLevelClient()::existsSourceAsync)); } IndexRequest index = new IndexRequest("index").id("id"); - index.source("{\"field1\":\"value1\",\"field2\":\"value2\"}", XContentType.JSON); + index.source("{\"field1\":\"value1\",\"field2\":\"value2\"}", MediaTypeRegistry.JSON); index.setRefreshPolicy(RefreshPolicy.IMMEDIATE); highLevelClient().index(index, RequestOptions.DEFAULT); { @@ -274,9 +276,9 @@ public void testSourceDoesNotExist() throws IOException { RestStatus.OK, highLevelClient().bulk( new BulkRequest().add( - new IndexRequest(noSourceIndex).id("1").source(Collections.singletonMap("foo", 1), XContentType.JSON) + new IndexRequest(noSourceIndex).id("1").source(Collections.singletonMap("foo", 1), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(noSourceIndex).id("2").source(Collections.singletonMap("foo", 2), XContentType.JSON)) + .add(new IndexRequest(noSourceIndex).id("2").source(Collections.singletonMap("foo", 2), MediaTypeRegistry.JSON)) .setRefreshPolicy(RefreshPolicy.IMMEDIATE), RequestOptions.DEFAULT ).status() @@ -306,7 +308,7 @@ public void testGet() throws IOException { } IndexRequest index = new IndexRequest("index").id("id"); String document = "{\"field1\":\"value1\",\"field2\":\"value2\"}"; - index.source(document, XContentType.JSON); + index.source(document, MediaTypeRegistry.JSON); index.setRefreshPolicy(RefreshPolicy.IMMEDIATE); highLevelClient().index(index, RequestOptions.DEFAULT); { @@ -406,10 +408,10 @@ public void testMultiGet() throws IOException { BulkRequest bulk = new BulkRequest(); bulk.setRefreshPolicy(RefreshPolicy.IMMEDIATE); IndexRequest index = new IndexRequest("index").id("id1"); - index.source("{\"field\":\"value1\"}", XContentType.JSON); + index.source("{\"field\":\"value1\"}", MediaTypeRegistry.JSON); bulk.add(index); index = new IndexRequest("index").id("id2"); - index.source("{\"field\":\"value2\"}", XContentType.JSON); + index.source("{\"field\":\"value2\"}", MediaTypeRegistry.JSON); bulk.add(index); highLevelClient().bulk(bulk, RequestOptions.DEFAULT); { @@ -436,8 +438,8 @@ public void testMultiGet() throws IOException { public void testMultiGetWithIds() throws IOException { BulkRequest bulk = new BulkRequest(); bulk.setRefreshPolicy(RefreshPolicy.IMMEDIATE); - bulk.add(new IndexRequest("index").id("id1").source("{\"field\":\"value1\"}", XContentType.JSON)); - bulk.add(new IndexRequest("index").id("id2").source("{\"field\":\"value2\"}", XContentType.JSON)); + bulk.add(new IndexRequest("index").id("id1").source("{\"field\":\"value1\"}", MediaTypeRegistry.JSON)); + bulk.add(new IndexRequest("index").id("id2").source("{\"field\":\"value2\"}", MediaTypeRegistry.JSON)); MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.add("index", "id1"); @@ -457,7 +459,7 @@ public void testGetSource() throws IOException { } IndexRequest index = new IndexRequest("index").id("id"); String document = "{\"field1\":\"value1\",\"field2\":\"value2\"}"; - index.source(document, XContentType.JSON); + index.source(document, MediaTypeRegistry.JSON); index.setRefreshPolicy(RefreshPolicy.IMMEDIATE); highLevelClient().index(index, RequestOptions.DEFAULT); { @@ -815,7 +817,7 @@ public void testUpdate() throws IOException { { IllegalStateException exception = expectThrows(IllegalStateException.class, () -> { UpdateRequest updateRequest = new UpdateRequest("index", "id"); - updateRequest.doc(new IndexRequest().source(Collections.singletonMap("field", "doc"), XContentType.JSON)); + updateRequest.doc(new IndexRequest().source(Collections.singletonMap("field", "doc"), MediaTypeRegistry.JSON)); updateRequest.upsert(new IndexRequest().source(Collections.singletonMap("field", "upsert"), XContentType.YAML)); execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); }); @@ -827,7 +829,7 @@ public void testUpdate() throws IOException { { OpenSearchException exception = expectThrows(OpenSearchException.class, () -> { UpdateRequest updateRequest = new UpdateRequest("index", "require_alias").setRequireAlias(true); - updateRequest.doc(new IndexRequest().source(Collections.singletonMap("field", "doc"), XContentType.JSON)); + updateRequest.doc(new IndexRequest().source(Collections.singletonMap("field", "doc"), MediaTypeRegistry.JSON)); execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); }); assertEquals(RestStatus.NOT_FOUND, exception.status()); @@ -842,7 +844,7 @@ public void testBulk() throws IOException { int nbItems = randomIntBetween(10, 100); boolean[] errors = new boolean[nbItems]; - XContentType xContentType = randomFrom(XContentType.JSON, XContentType.SMILE); + MediaType mediaType = randomFrom(MediaTypeRegistry.JSON, XContentType.SMILE); BulkRequest bulkRequest = new BulkRequest(); for (int i = 0; i < nbItems; i++) { @@ -863,10 +865,10 @@ public void testBulk() throws IOException { } else { BytesReference source = BytesReference.bytes( - XContentBuilder.builder(xContentType.xContent()).startObject().field("id", i).endObject() + XContentBuilder.builder(mediaType.xContent()).startObject().field("id", i).endObject() ); if (opType == DocWriteRequest.OpType.INDEX) { - IndexRequest indexRequest = new IndexRequest("index").id(id).source(source, xContentType); + IndexRequest indexRequest = new IndexRequest("index").id(id).source(source, mediaType); if (erroneous) { indexRequest.setIfSeqNo(12L); indexRequest.setIfPrimaryTerm(12L); @@ -874,14 +876,14 @@ public void testBulk() throws IOException { bulkRequest.add(indexRequest); } else if (opType == DocWriteRequest.OpType.CREATE) { - IndexRequest createRequest = new IndexRequest("index").id(id).source(source, xContentType).create(true); + IndexRequest createRequest = new IndexRequest("index").id(id).source(source, mediaType).create(true); if (erroneous) { assertEquals(RestStatus.CREATED, highLevelClient().index(createRequest, RequestOptions.DEFAULT).status()); } bulkRequest.add(createRequest); } else if (opType == DocWriteRequest.OpType.UPDATE) { - UpdateRequest updateRequest = new UpdateRequest("index", id).doc(new IndexRequest().source(source, xContentType)); + UpdateRequest updateRequest = new UpdateRequest("index", id).doc(new IndexRequest().source(source, mediaType)); if (erroneous == false) { assertEquals( RestStatus.CREATED, @@ -905,7 +907,7 @@ public void testBulkProcessorIntegration() throws IOException { int nbItems = randomIntBetween(10, 100); boolean[] errors = new boolean[nbItems]; - XContentType xContentType = randomFrom(XContentType.JSON, XContentType.SMILE); + MediaType mediaType = randomFrom(MediaTypeRegistry.JSON, XContentType.SMILE); AtomicReference responseRef = new AtomicReference<>(); AtomicReference requestRef = new AtomicReference<>(); @@ -953,7 +955,7 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) } else { if (opType == DocWriteRequest.OpType.INDEX) { - IndexRequest indexRequest = new IndexRequest("index").id(id).source(xContentType, "id", i); + IndexRequest indexRequest = new IndexRequest("index").id(id).source(mediaType, "id", i); if (erroneous) { indexRequest.setIfSeqNo(12L); indexRequest.setIfPrimaryTerm(12L); @@ -961,14 +963,14 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) processor.add(indexRequest); } else if (opType == DocWriteRequest.OpType.CREATE) { - IndexRequest createRequest = new IndexRequest("index").id(id).source(xContentType, "id", i).create(true); + IndexRequest createRequest = new IndexRequest("index").id(id).source(mediaType, "id", i).create(true); if (erroneous) { assertEquals(RestStatus.CREATED, highLevelClient().index(createRequest, RequestOptions.DEFAULT).status()); } processor.add(createRequest); } else if (opType == DocWriteRequest.OpType.UPDATE) { - UpdateRequest updateRequest = new UpdateRequest("index", id).doc(new IndexRequest().source(xContentType, "id", i)); + UpdateRequest updateRequest = new UpdateRequest("index", id).doc(new IndexRequest().source(mediaType, "id", i)); if (erroneous == false) { assertEquals( RestStatus.CREATED, @@ -1106,9 +1108,12 @@ public void testTermvectors() throws IOException { RestStatus.OK, highLevelClient().bulk( new BulkRequest().add( - new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("field", "value1"), XContentType.JSON) + new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("field", "value1"), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("field", "value2"), XContentType.JSON)) + .add( + new IndexRequest(sourceIndex).id("2") + .source(Collections.singletonMap("field", "value2"), MediaTypeRegistry.JSON) + ) .setRefreshPolicy(RefreshPolicy.IMMEDIATE), RequestOptions.DEFAULT ).status() @@ -1201,8 +1206,8 @@ public void testMultiTermvectors() throws IOException { assertEquals( RestStatus.OK, highLevelClient().bulk( - new BulkRequest().add(new IndexRequest(sourceIndex).id("1").source(doc1, XContentType.JSON)) - .add(new IndexRequest(sourceIndex).id("2").source(doc2, XContentType.JSON)) + new BulkRequest().add(new IndexRequest(sourceIndex).id("1").source(doc1, MediaTypeRegistry.JSON)) + .add(new IndexRequest(sourceIndex).id("2").source(doc2, MediaTypeRegistry.JSON)) .setRefreshPolicy(RefreshPolicy.IMMEDIATE), RequestOptions.DEFAULT ).status() diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/CustomRestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/CustomRestHighLevelClientTests.java index 972c96999945f..93eeee349db14 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/CustomRestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/CustomRestHighLevelClientTests.java @@ -49,8 +49,8 @@ import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.ClusterName; import org.opensearch.common.SuppressForbidden; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.test.OpenSearchTestCase; import org.junit.Before; @@ -174,7 +174,7 @@ private Response mockPerformRequest(Request request) throws IOException { when(mockResponse.getStatusLine()).thenReturn(new StatusLine(protocol, 200, "OK")); MainResponse response = new MainResponse(httpHeader.getValue(), Version.CURRENT, ClusterName.DEFAULT, "_na", Build.CURRENT); - BytesRef bytesRef = XContentHelper.toXContent(response, XContentType.JSON, false).toBytesRef(); + BytesRef bytesRef = XContentHelper.toXContent(response, MediaTypeRegistry.JSON, false).toBytesRef(); when(mockResponse.getEntity()).thenReturn(new ByteArrayEntity(bytesRef.bytes, ContentType.APPLICATION_JSON)); RequestLine requestLine = new RequestLine(HttpGet.METHOD_NAME, ENDPOINT, protocol); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java index ea57f1857fbfb..1dda4f3db8138 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java @@ -116,9 +116,9 @@ import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.index.IndexSettings; @@ -1074,7 +1074,7 @@ public void testRollover() throws IOException { } { String mappings = "{\"properties\":{\"field2\":{\"type\":\"keyword\"}}}"; - rolloverRequest.getCreateIndexRequest().mapping(mappings, XContentType.JSON); + rolloverRequest.getCreateIndexRequest().mapping(mappings, MediaTypeRegistry.JSON); rolloverRequest.dryRun(false); rolloverRequest.addMaxIndexSizeCondition(new ByteSizeValue(1, ByteSizeUnit.MB)); RolloverResponse rolloverResponse = execute( @@ -1489,7 +1489,7 @@ public void testPutTemplate() throws Exception { .order(10) .create(randomBoolean()) .settings(Settings.builder().put("number_of_shards", "3").put("number_of_replicas", "0")) - .mapping("{ \"properties\": { \"host_name\": { \"type\": \"keyword\" } } }", XContentType.JSON) + .mapping("{ \"properties\": { \"host_name\": { \"type\": \"keyword\" } } }", MediaTypeRegistry.JSON) .alias(new Alias("alias-1").indexRouting("abc")) .alias(new Alias("alias-1").indexRouting("abc")) .alias(new Alias("{index}-write").searchRouting("xyz")); @@ -1558,7 +1558,7 @@ public void testPutTemplateWithTypesUsingUntypedAPI() throws Exception { + " }" + " }" + "}", - XContentType.JSON + MediaTypeRegistry.JSON ) .alias(new Alias("alias-1").indexRouting("abc")) .alias(new Alias("{index}-write").searchRouting("xyz")); @@ -1664,7 +1664,7 @@ public void testCRUDIndexTemplate() throws Exception { equalTo(true) ); PutIndexTemplateRequest putTemplate2 = new PutIndexTemplateRequest("template-2").patterns(Arrays.asList("pattern-2", "name-2")) - .mapping("{\"properties\": { \"name\": { \"type\": \"text\" }}}", XContentType.JSON) + .mapping("{\"properties\": { \"name\": { \"type\": \"text\" }}}", MediaTypeRegistry.JSON) .settings(Settings.builder().put("number_of_shards", "2").put("number_of_replicas", "0")); assertThat( execute(putTemplate2, client.indices()::putTemplate, client.indices()::putTemplateAsync).isAcknowledged(), diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java index 75c5a71303af4..74ca9ae1720c5 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java @@ -75,8 +75,8 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.core.common.util.CollectionUtils; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchTestCase; import org.junit.Assert; import org.opensearch.core.common.unit.ByteSizeValue; @@ -858,7 +858,7 @@ public void testPutTemplateRequest() throws Exception { + "\" : { \"type\" : \"" + OpenSearchTestCase.randomFrom("text", "keyword") + "\" }}}", - XContentType.JSON + MediaTypeRegistry.JSON ); } if (OpenSearchTestCase.randomBoolean()) { diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/IngestRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/IngestRequestConvertersTests.java index 0f377720b7aed..81d6a448cdfc6 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/IngestRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/IngestRequestConvertersTests.java @@ -38,7 +38,7 @@ import org.opensearch.action.ingest.SimulatePipelineRequest; import org.opensearch.action.support.master.AcknowledgedRequest; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchTestCase; import org.apache.hc.client5.http.classic.methods.HttpDelete; import org.apache.hc.client5.http.classic.methods.HttpGet; @@ -59,7 +59,7 @@ public void testPutPipeline() throws IOException { PutPipelineRequest request = new PutPipelineRequest( "some_pipeline_id", new BytesArray("{}".getBytes(StandardCharsets.UTF_8)), - XContentType.JSON + MediaTypeRegistry.JSON ); Map expectedParams = new HashMap<>(); RequestConvertersTests.setRandomClusterManagerTimeout(request, expectedParams); @@ -130,7 +130,7 @@ public void testSimulatePipeline() throws IOException { + "}"; SimulatePipelineRequest request = new SimulatePipelineRequest( new BytesArray(json.getBytes(StandardCharsets.UTF_8)), - XContentType.JSON + MediaTypeRegistry.JSON ); request.setId(pipelineId); request.setVerbose(verbose); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/OpenSearchRestHighLevelClientTestCase.java b/client/rest-high-level/src/test/java/org/opensearch/client/OpenSearchRestHighLevelClientTestCase.java index ee1f217f47ef2..97eee0353dd63 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/OpenSearchRestHighLevelClientTestCase.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/OpenSearchRestHighLevelClientTestCase.java @@ -51,6 +51,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; @@ -223,7 +224,7 @@ protected static void createFieldAddingPipleine(String id, String fieldName, Str .endArray() .endObject(); - createPipeline(new PutPipelineRequest(id, BytesReference.bytes(pipeline), XContentType.JSON)); + createPipeline(new PutPipelineRequest(id, BytesReference.bytes(pipeline), MediaTypeRegistry.JSON)); } protected static void createPipeline(String pipelineId) throws IOException { diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/ReindexIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/ReindexIT.java index 65888e79683e3..be4fd71c6f5e8 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/ReindexIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/ReindexIT.java @@ -42,7 +42,7 @@ import org.opensearch.action.support.WriteRequest; import org.opensearch.client.tasks.TaskSubmissionResponse; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.query.IdsQueryBuilder; import org.opensearch.index.reindex.BulkByScrollResponse; import org.opensearch.index.reindex.DeleteByQueryAction; @@ -76,9 +76,9 @@ public void testReindex() throws IOException { createIndex(sourceIndex, settings); createIndex(destinationIndex, settings); BulkRequest bulkRequest = new BulkRequest().add( - new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", "bar"), XContentType.JSON) + new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", "bar"), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo2", "bar2"), XContentType.JSON)) + .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo2", "bar2"), MediaTypeRegistry.JSON)) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); assertEquals(RestStatus.OK, highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT).status()); } @@ -132,9 +132,9 @@ public void testReindexTask() throws Exception { createIndex(sourceIndex, settings); createIndex(destinationIndex, settings); BulkRequest bulkRequest = new BulkRequest().add( - new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", "bar"), XContentType.JSON) + new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", "bar"), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo2", "bar2"), XContentType.JSON)) + .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo2", "bar2"), MediaTypeRegistry.JSON)) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); assertEquals(RestStatus.OK, highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT).status()); } @@ -163,9 +163,9 @@ public void testReindexConflict() throws IOException { createIndex(sourceIndex, settings); createIndex(destIndex, settings); final BulkRequest bulkRequest = new BulkRequest().add( - new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", "bar"), XContentType.JSON) + new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", "bar"), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo", "bar"), XContentType.JSON)) + .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo", "bar"), MediaTypeRegistry.JSON)) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); assertThat(highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT).status(), equalTo(RestStatus.OK)); @@ -205,10 +205,10 @@ public void testDeleteByQuery() throws Exception { RestStatus.OK, highLevelClient().bulk( new BulkRequest().add( - new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", 1), XContentType.JSON) + new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", 1), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo", 2), XContentType.JSON)) - .add(new IndexRequest(sourceIndex).id("3").source(Collections.singletonMap("foo", 3), XContentType.JSON)) + .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo", 2), MediaTypeRegistry.JSON)) + .add(new IndexRequest(sourceIndex).id("3").source(Collections.singletonMap("foo", 3), MediaTypeRegistry.JSON)) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE), RequestOptions.DEFAULT ).status() @@ -305,10 +305,10 @@ public void testDeleteByQueryTask() throws Exception { RestStatus.OK, highLevelClient().bulk( new BulkRequest().add( - new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", 1), XContentType.JSON) + new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", 1), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo", 2), XContentType.JSON)) - .add(new IndexRequest(sourceIndex).id("3").source(Collections.singletonMap("foo", 3), XContentType.JSON)) + .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo", 2), MediaTypeRegistry.JSON)) + .add(new IndexRequest(sourceIndex).id("3").source(Collections.singletonMap("foo", 3), MediaTypeRegistry.JSON)) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE), RequestOptions.DEFAULT ).status() diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java index 15a99b3e91685..239749e13b08b 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java @@ -72,11 +72,11 @@ import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.lucene.uid.Versions; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -852,7 +852,7 @@ private static void setRandomIfSeqNoAndTerm(DocWriteRequest request, Map { UpdateRequest updateRequest = new UpdateRequest(); - updateRequest.doc(new IndexRequest().source(singletonMap("field", "doc"), XContentType.JSON)); + updateRequest.doc(new IndexRequest().source(singletonMap("field", "doc"), MediaTypeRegistry.JSON)); updateRequest.upsert(new IndexRequest().source(singletonMap("field", "upsert"), XContentType.YAML)); RequestConverters.update(updateRequest); }); @@ -876,7 +876,7 @@ public void testBulk() throws IOException { setRandomRefreshPolicy(bulkRequest::setRefreshPolicy, expectedParams); - XContentType xContentType = randomFrom(XContentType.JSON, XContentType.SMILE); + MediaType mediaType = randomFrom(MediaTypeRegistry.JSON, XContentType.SMILE); int nbItems = randomIntBetween(10, 100); DocWriteRequest[] requests = new DocWriteRequest[nbItems]; @@ -884,21 +884,21 @@ public void testBulk() throws IOException { String index = randomAlphaOfLength(5); String id = randomAlphaOfLength(5); - BytesReference source = RandomObjects.randomSource(random(), xContentType); + BytesReference source = RandomObjects.randomSource(random(), mediaType); DocWriteRequest.OpType opType = randomFrom(DocWriteRequest.OpType.values()); DocWriteRequest docWriteRequest; if (opType == DocWriteRequest.OpType.INDEX) { - IndexRequest indexRequest = new IndexRequest(index).id(id).source(source, xContentType); + IndexRequest indexRequest = new IndexRequest(index).id(id).source(source, mediaType); docWriteRequest = indexRequest; if (randomBoolean()) { indexRequest.setPipeline(randomAlphaOfLength(5)); } } else if (opType == DocWriteRequest.OpType.CREATE) { - IndexRequest createRequest = new IndexRequest(index).id(id).source(source, xContentType).create(true); + IndexRequest createRequest = new IndexRequest(index).id(id).source(source, mediaType).create(true); docWriteRequest = createRequest; } else if (opType == DocWriteRequest.OpType.UPDATE) { - final UpdateRequest updateRequest = new UpdateRequest(index, id).doc(new IndexRequest().source(source, xContentType)); + final UpdateRequest updateRequest = new UpdateRequest(index, id).doc(new IndexRequest().source(source, mediaType)); docWriteRequest = updateRequest; if (randomBoolean()) { updateRequest.retryOnConflict(randomIntBetween(1, 5)); @@ -927,14 +927,14 @@ public void testBulk() throws IOException { assertEquals("/_bulk", request.getEndpoint()); assertEquals(expectedParams, request.getParameters()); assertEquals(HttpPost.METHOD_NAME, request.getMethod()); - assertEquals(xContentType.mediaTypeWithoutParameters(), request.getEntity().getContentType()); + assertEquals(mediaType.mediaTypeWithoutParameters(), request.getEntity().getContentType()); byte[] content = new byte[(int) request.getEntity().getContentLength()]; try (InputStream inputStream = request.getEntity().getContent()) { Streams.readFully(inputStream, content); } BulkRequest parsedBulkRequest = new BulkRequest(); - parsedBulkRequest.add(content, 0, content.length, xContentType); + parsedBulkRequest.add(content, 0, content.length, mediaType); assertEquals(bulkRequest.numberOfActions(), parsedBulkRequest.numberOfActions()); for (int i = 0; i < bulkRequest.numberOfActions(); i++) { @@ -956,7 +956,7 @@ public void testBulk() throws IOException { IndexRequest parsedIndexRequest = (IndexRequest) parsedRequest; assertEquals(indexRequest.getPipeline(), parsedIndexRequest.getPipeline()); - assertToXContentEquivalent(indexRequest.source(), parsedIndexRequest.source(), xContentType); + assertToXContentEquivalent(indexRequest.source(), parsedIndexRequest.source(), mediaType); } else if (opType == DocWriteRequest.OpType.UPDATE) { UpdateRequest updateRequest = (UpdateRequest) originalRequest; UpdateRequest parsedUpdateRequest = (UpdateRequest) parsedRequest; @@ -964,7 +964,7 @@ public void testBulk() throws IOException { assertEquals(updateRequest.retryOnConflict(), parsedUpdateRequest.retryOnConflict()); assertEquals(updateRequest.fetchSource(), parsedUpdateRequest.fetchSource()); if (updateRequest.doc() != null) { - assertToXContentEquivalent(updateRequest.doc().source(), parsedUpdateRequest.doc().source(), xContentType); + assertToXContentEquivalent(updateRequest.doc().source(), parsedUpdateRequest.doc().source(), mediaType); } else { assertNull(parsedUpdateRequest.doc()); } @@ -980,34 +980,34 @@ public void testBulkWithDifferentContentTypes() throws IOException { bulkRequest.add(new DeleteRequest("index", "2")); Request request = RequestConverters.bulk(bulkRequest); - assertEquals(XContentType.JSON.mediaTypeWithoutParameters(), request.getEntity().getContentType()); + assertEquals(MediaTypeRegistry.JSON.mediaTypeWithoutParameters(), request.getEntity().getContentType()); } { - XContentType xContentType = randomFrom(XContentType.JSON, XContentType.SMILE); + MediaType mediaType = randomFrom(MediaTypeRegistry.JSON, XContentType.SMILE); BulkRequest bulkRequest = new BulkRequest(); bulkRequest.add(new DeleteRequest("index", "0")); - bulkRequest.add(new IndexRequest("index").id("0").source(singletonMap("field", "value"), xContentType)); + bulkRequest.add(new IndexRequest("index").id("0").source(singletonMap("field", "value"), mediaType)); bulkRequest.add(new DeleteRequest("index", "2")); Request request = RequestConverters.bulk(bulkRequest); - assertEquals(xContentType.mediaTypeWithoutParameters(), request.getEntity().getContentType()); + assertEquals(mediaType.mediaTypeWithoutParameters(), request.getEntity().getContentType()); } { - XContentType xContentType = randomFrom(XContentType.JSON, XContentType.SMILE); + MediaType mediaType = randomFrom(MediaTypeRegistry.JSON, XContentType.SMILE); UpdateRequest updateRequest = new UpdateRequest("index", "0"); if (randomBoolean()) { - updateRequest.doc(new IndexRequest().source(singletonMap("field", "value"), xContentType)); + updateRequest.doc(new IndexRequest().source(singletonMap("field", "value"), mediaType)); } else { - updateRequest.upsert(new IndexRequest().source(singletonMap("field", "value"), xContentType)); + updateRequest.upsert(new IndexRequest().source(singletonMap("field", "value"), mediaType)); } Request request = RequestConverters.bulk(new BulkRequest().add(updateRequest)); - assertEquals(xContentType.mediaTypeWithoutParameters(), request.getEntity().getContentType()); + assertEquals(mediaType.mediaTypeWithoutParameters(), request.getEntity().getContentType()); } { BulkRequest bulkRequest = new BulkRequest(); bulkRequest.add(new IndexRequest("index").id("0").source(singletonMap("field", "value"), XContentType.SMILE)); - bulkRequest.add(new IndexRequest("index").id("1").source(singletonMap("field", "value"), XContentType.JSON)); + bulkRequest.add(new IndexRequest("index").id("1").source(singletonMap("field", "value"), MediaTypeRegistry.JSON)); IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> RequestConverters.bulk(bulkRequest)); assertEquals( "Mismatching content-type found for request with content-type [JSON], " + "previous requests have content-type [SMILE]", @@ -1016,10 +1016,10 @@ public void testBulkWithDifferentContentTypes() throws IOException { } { BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(new IndexRequest("index").id("0").source(singletonMap("field", "value"), XContentType.JSON)); - bulkRequest.add(new IndexRequest("index").id("1").source(singletonMap("field", "value"), XContentType.JSON)); + bulkRequest.add(new IndexRequest("index").id("0").source(singletonMap("field", "value"), MediaTypeRegistry.JSON)); + bulkRequest.add(new IndexRequest("index").id("1").source(singletonMap("field", "value"), MediaTypeRegistry.JSON)); bulkRequest.add( - new UpdateRequest("index", "2").doc(new IndexRequest().source(singletonMap("field", "value"), XContentType.JSON)) + new UpdateRequest("index", "2").doc(new IndexRequest().source(singletonMap("field", "value"), MediaTypeRegistry.JSON)) .upsert(new IndexRequest().source(singletonMap("field", "value"), XContentType.SMILE)) ); IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> RequestConverters.bulk(bulkRequest)); @@ -1032,10 +1032,10 @@ public void testBulkWithDifferentContentTypes() throws IOException { XContentType xContentType = randomFrom(XContentType.CBOR, XContentType.YAML); BulkRequest bulkRequest = new BulkRequest(); bulkRequest.add(new DeleteRequest("index", "0")); - bulkRequest.add(new IndexRequest("index").id("1").source(singletonMap("field", "value"), XContentType.JSON)); + bulkRequest.add(new IndexRequest("index").id("1").source(singletonMap("field", "value"), MediaTypeRegistry.JSON)); bulkRequest.add(new DeleteRequest("index", "2")); bulkRequest.add(new DeleteRequest("index", "3")); - bulkRequest.add(new IndexRequest("index").id("4").source(singletonMap("field", "value"), XContentType.JSON)); + bulkRequest.add(new IndexRequest("index").id("4").source(singletonMap("field", "value"), MediaTypeRegistry.JSON)); bulkRequest.add(new IndexRequest("index").id("1").source(singletonMap("field", "value"), xContentType)); IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> RequestConverters.bulk(bulkRequest)); assertEquals( @@ -1048,9 +1048,9 @@ public void testBulkWithDifferentContentTypes() throws IOException { public void testGlobalPipelineOnBulkRequest() throws IOException { BulkRequest bulkRequest = new BulkRequest(); bulkRequest.pipeline("xyz"); - bulkRequest.add(new IndexRequest("test").id("11").source(XContentType.JSON, "field", "bulk1")); - bulkRequest.add(new IndexRequest("test").id("12").source(XContentType.JSON, "field", "bulk2")); - bulkRequest.add(new IndexRequest("test").id("13").source(XContentType.JSON, "field", "bulk3")); + bulkRequest.add(new IndexRequest("test").id("11").source(MediaTypeRegistry.JSON, "field", "bulk1")); + bulkRequest.add(new IndexRequest("test").id("12").source(MediaTypeRegistry.JSON, "field", "bulk2")); + bulkRequest.add(new IndexRequest("test").id("13").source(MediaTypeRegistry.JSON, "field", "bulk3")); Request request = RequestConverters.bulk(bulkRequest); @@ -1456,8 +1456,11 @@ public void testMultiSearchTemplate() throws Exception { assertEquals(expectedParams, multiRequest.getParameters()); HttpEntity actualEntity = multiRequest.getEntity(); - byte[] expectedBytes = MultiSearchTemplateRequest.writeMultiLineFormat(multiSearchTemplateRequest, XContentType.JSON.xContent()); - assertEquals(XContentType.JSON.mediaTypeWithoutParameters(), actualEntity.getContentType()); + byte[] expectedBytes = MultiSearchTemplateRequest.writeMultiLineFormat( + multiSearchTemplateRequest, + MediaTypeRegistry.JSON.xContent() + ); + assertEquals(MediaTypeRegistry.JSON.mediaTypeWithoutParameters(), actualEntity.getContentType()); assertEquals(new BytesArray(expectedBytes), new BytesArray(EntityUtils.toByteArray(actualEntity))); } @@ -1763,8 +1766,12 @@ public void testDeleteScriptRequest() { } static void assertToXContentBody(ToXContent expectedBody, HttpEntity actualEntity) throws IOException { - BytesReference expectedBytes = XContentHelper.toXContent(expectedBody, REQUEST_BODY_CONTENT_TYPE, false); - assertEquals(XContentType.JSON.mediaTypeWithoutParameters(), actualEntity.getContentType()); + BytesReference expectedBytes = org.opensearch.core.xcontent.XContentHelper.toXContent( + expectedBody, + REQUEST_BODY_CONTENT_TYPE, + false + ); + assertEquals(MediaTypeRegistry.JSON.mediaTypeWithoutParameters(), actualEntity.getContentType()); assertEquals(expectedBytes, new BytesArray(EntityUtils.toByteArray(actualEntity))); } @@ -1913,12 +1920,12 @@ public void testCreateContentType() { } public void testEnforceSameContentType() { - XContentType xContentType = randomFrom(XContentType.JSON, XContentType.SMILE); - IndexRequest indexRequest = new IndexRequest().source(singletonMap("field", "value"), xContentType); - assertEquals(xContentType, enforceSameContentType(indexRequest, null)); - assertEquals(xContentType, enforceSameContentType(indexRequest, xContentType)); + MediaType mediaType = randomFrom(MediaTypeRegistry.JSON, XContentType.SMILE); + IndexRequest indexRequest = new IndexRequest().source(singletonMap("field", "value"), mediaType); + assertEquals(mediaType, enforceSameContentType(indexRequest, null)); + assertEquals(mediaType, enforceSameContentType(indexRequest, mediaType)); - XContentType bulkContentType = randomBoolean() ? xContentType : null; + MediaType bulkContentType = randomBoolean() ? mediaType : null; IllegalArgumentException exception = expectThrows( IllegalArgumentException.class, @@ -1938,18 +1945,18 @@ public void testEnforceSameContentType() { exception.getMessage() ); - XContentType requestContentType = xContentType == XContentType.JSON ? XContentType.SMILE : XContentType.JSON; + MediaType requestContentType = mediaType == MediaTypeRegistry.JSON ? XContentType.SMILE : MediaTypeRegistry.JSON; exception = expectThrows( IllegalArgumentException.class, - () -> enforceSameContentType(new IndexRequest().source(singletonMap("field", "value"), requestContentType), xContentType) + () -> enforceSameContentType(new IndexRequest().source(singletonMap("field", "value"), requestContentType), mediaType) ); assertEquals( "Mismatching content-type found for request with content-type [" + requestContentType + "], " + "previous requests have content-type [" - + xContentType + + mediaType + "]", exception.getMessage() ); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/RestHighLevelClientTests.java index 24b0fda6c18d5..0b3d395fcd118 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/RestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/RestHighLevelClientTests.java @@ -106,7 +106,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.hamcrest.CoreMatchers.endsWith; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java index 233ea0ca5f48d..53a20aa58e5f8 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java @@ -54,9 +54,9 @@ import org.opensearch.client.core.CountResponse; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.query.MatchQueryBuilder; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; @@ -1200,7 +1200,7 @@ public void testRenderSearchTemplate() throws IOException { BytesReference actualSource = searchTemplateResponse.getSource(); assertNotNull(actualSource); - assertToXContentEquivalent(expectedSource, actualSource, XContentType.JSON); + assertToXContentEquivalent(expectedSource, actualSource, MediaTypeRegistry.JSON); } public void testMultiSearchTemplate() throws Exception { diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/SnapshotIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/SnapshotIT.java index df99d26a0a530..72072f2b7b790 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/SnapshotIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/SnapshotIT.java @@ -54,7 +54,7 @@ import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.repositories.fs.FsRepository; import org.opensearch.core.rest.RestStatus; import org.opensearch.snapshots.RestoreInfo; @@ -76,7 +76,7 @@ public class SnapshotIT extends OpenSearchRestHighLevelClientTestCase { private AcknowledgedResponse createTestRepository(String repository, String type, String settings) throws IOException { PutRepositoryRequest request = new PutRepositoryRequest(repository); - request.settings(settings, XContentType.JSON); + request.settings(settings, MediaTypeRegistry.JSON); request.type(type); return execute(request, highLevelClient().snapshot()::createRepository, highLevelClient().snapshot()::createRepositoryAsync); } diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/StoredScriptsIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/StoredScriptsIT.java index c86de6ae645c1..4d792e53c6064 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/StoredScriptsIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/StoredScriptsIT.java @@ -38,8 +38,8 @@ import org.opensearch.action.admin.cluster.storedscripts.GetStoredScriptResponse; import org.opensearch.action.admin.cluster.storedscripts.PutStoredScriptRequest; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.rest.RestStatus; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.script.Script; import org.opensearch.script.StoredScriptSource; @@ -58,10 +58,16 @@ public void testGetStoredScript() throws Exception { final StoredScriptSource scriptSource = new StoredScriptSource( "painless", "Math.log(_score * 2) + params.my_modifier", - Collections.singletonMap(Script.CONTENT_TYPE_OPTION, XContentType.JSON.mediaType()) + Collections.singletonMap(Script.CONTENT_TYPE_OPTION, MediaTypeRegistry.JSON.mediaType()) ); - PutStoredScriptRequest request = new PutStoredScriptRequest(id, "score", new BytesArray("{}"), XContentType.JSON, scriptSource); + PutStoredScriptRequest request = new PutStoredScriptRequest( + id, + "score", + new BytesArray("{}"), + MediaTypeRegistry.JSON, + scriptSource + ); assertAcked(execute(request, highLevelClient()::putScript, highLevelClient()::putScriptAsync)); GetStoredScriptRequest getRequest = new GetStoredScriptRequest("calculate-score"); @@ -76,10 +82,16 @@ public void testDeleteStoredScript() throws Exception { final StoredScriptSource scriptSource = new StoredScriptSource( "painless", "Math.log(_score * 2) + params.my_modifier", - Collections.singletonMap(Script.CONTENT_TYPE_OPTION, XContentType.JSON.mediaType()) + Collections.singletonMap(Script.CONTENT_TYPE_OPTION, MediaTypeRegistry.JSON.mediaType()) ); - PutStoredScriptRequest request = new PutStoredScriptRequest(id, "score", new BytesArray("{}"), XContentType.JSON, scriptSource); + PutStoredScriptRequest request = new PutStoredScriptRequest( + id, + "score", + new BytesArray("{}"), + MediaTypeRegistry.JSON, + scriptSource + ); assertAcked(execute(request, highLevelClient()::putScript, highLevelClient()::putScriptAsync)); DeleteStoredScriptRequest deleteRequest = new DeleteStoredScriptRequest(id); @@ -100,10 +112,16 @@ public void testPutScript() throws Exception { final StoredScriptSource scriptSource = new StoredScriptSource( "painless", "Math.log(_score * 2) + params.my_modifier", - Collections.singletonMap(Script.CONTENT_TYPE_OPTION, XContentType.JSON.mediaType()) + Collections.singletonMap(Script.CONTENT_TYPE_OPTION, MediaTypeRegistry.JSON.mediaType()) ); - PutStoredScriptRequest request = new PutStoredScriptRequest(id, "score", new BytesArray("{}"), XContentType.JSON, scriptSource); + PutStoredScriptRequest request = new PutStoredScriptRequest( + id, + "score", + new BytesArray("{}"), + MediaTypeRegistry.JSON, + scriptSource + ); assertAcked(execute(request, highLevelClient()::putScript, highLevelClient()::putScriptAsync)); Map script = getAsMap("/_scripts/" + id); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/TasksIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/TasksIT.java index 24edd5f93bdba..7db593f57d55f 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/TasksIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/TasksIT.java @@ -32,6 +32,7 @@ package org.opensearch.client; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.reindex.ReindexRequest; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; @@ -46,7 +47,6 @@ import org.opensearch.client.tasks.TaskId; import org.opensearch.client.tasks.TaskSubmissionResponse; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.rest.RestStatus; import java.io.IOException; @@ -94,9 +94,9 @@ public void testGetValidTask() throws Exception { createIndex(sourceIndex, settings); createIndex(destinationIndex, settings); BulkRequest bulkRequest = new BulkRequest().add( - new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", "bar"), XContentType.JSON) + new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", "bar"), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo2", "bar2"), XContentType.JSON)) + .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo2", "bar2"), MediaTypeRegistry.JSON)) .setRefreshPolicy(RefreshPolicy.IMMEDIATE); assertEquals(RestStatus.OK, highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT).status()); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/UpdateByQueryIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/UpdateByQueryIT.java index e5fbb30d29292..c0447b30b73d6 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/UpdateByQueryIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/UpdateByQueryIT.java @@ -41,7 +41,7 @@ import org.opensearch.action.support.WriteRequest; import org.opensearch.client.tasks.TaskSubmissionResponse; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.query.IdsQueryBuilder; import org.opensearch.index.reindex.BulkByScrollResponse; import org.opensearch.index.reindex.UpdateByQueryAction; @@ -76,9 +76,9 @@ public void testUpdateByQuery() throws Exception { RestStatus.OK, highLevelClient().bulk( new BulkRequest().add( - new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", 1), XContentType.JSON) + new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", 1), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo", 2), XContentType.JSON)) + .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo", 2), MediaTypeRegistry.JSON)) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE), RequestOptions.DEFAULT ).status() @@ -197,10 +197,10 @@ public void testUpdateByQueryTask() throws Exception { RestStatus.OK, highLevelClient().bulk( new BulkRequest().add( - new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", 1), XContentType.JSON) + new IndexRequest(sourceIndex).id("1").source(Collections.singletonMap("foo", 1), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo", 2), XContentType.JSON)) - .add(new IndexRequest(sourceIndex).id("3").source(Collections.singletonMap("foo", 3), XContentType.JSON)) + .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo", 2), MediaTypeRegistry.JSON)) + .add(new IndexRequest(sourceIndex).id("3").source(Collections.singletonMap("foo", 3), MediaTypeRegistry.JSON)) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE), RequestOptions.DEFAULT ).status() @@ -230,9 +230,9 @@ public void testUpdateByQueryConflict() throws IOException { final Settings settings = Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).build(); createIndex(index, settings); final BulkRequest bulkRequest = new BulkRequest().add( - new IndexRequest(index).id("1").source(Collections.singletonMap("foo", "bar"), XContentType.JSON) + new IndexRequest(index).id("1").source(Collections.singletonMap("foo", "bar"), MediaTypeRegistry.JSON) ) - .add(new IndexRequest(index).id("2").source(Collections.singletonMap("foo", "bar"), XContentType.JSON)) + .add(new IndexRequest(index).id("2").source(Collections.singletonMap("foo", "bar"), MediaTypeRegistry.JSON)) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); assertThat(highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT).status(), equalTo(RestStatus.OK)); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java index 010b16a3f5720..58be005b94a8a 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java @@ -80,9 +80,9 @@ import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.VersionType; import org.opensearch.index.get.GetResult; @@ -173,7 +173,7 @@ public void testIndex() throws Exception { "\"postDate\":\"2013-01-30\"," + "\"message\":\"trying out OpenSearch\"" + "}"; - request.source(jsonString, XContentType.JSON); // <3> + request.source(jsonString, MediaTypeRegistry.JSON); // <3> //end::index-request-string // tag::index-execute @@ -380,7 +380,7 @@ public void testUpdate() throws Exception { "\"updated\":\"2017-01-01\"," + "\"reason\":\"daily update\"" + "}"; - request.doc(jsonString, XContentType.JSON); // <1> + request.doc(jsonString, MediaTypeRegistry.JSON); // <1> //end::update-request-with-doc-as-string request.fetchSource(true); // tag::update-execute @@ -524,7 +524,7 @@ public void testUpdate() throws Exception { // end::update-request-detect-noop // tag::update-request-upsert String jsonString = "{\"created\":\"2017-01-01\"}"; - request.upsert(jsonString, XContentType.JSON); // <1> + request.upsert(jsonString, MediaTypeRegistry.JSON); // <1> // end::update-request-upsert // tag::update-request-scripted-upsert request.scriptedUpsert(true); // <1> @@ -698,11 +698,11 @@ public void testBulk() throws Exception { // tag::bulk-request BulkRequest request = new BulkRequest(); // <1> request.add(new IndexRequest("posts").id("1") // <2> - .source(XContentType.JSON,"field", "foo")); + .source(MediaTypeRegistry.JSON,"field", "foo")); request.add(new IndexRequest("posts").id("2") // <3> - .source(XContentType.JSON,"field", "bar")); + .source(MediaTypeRegistry.JSON,"field", "bar")); request.add(new IndexRequest("posts").id("3") // <4> - .source(XContentType.JSON,"field", "baz")); + .source(MediaTypeRegistry.JSON,"field", "baz")); // end::bulk-request // tag::bulk-execute BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); @@ -715,9 +715,9 @@ public void testBulk() throws Exception { BulkRequest request = new BulkRequest(); request.add(new DeleteRequest("posts", "3")); // <1> request.add(new UpdateRequest("posts", "2") // <2> - .doc(XContentType.JSON,"other", "test")); + .doc(MediaTypeRegistry.JSON,"other", "test")); request.add(new IndexRequest("posts").id("4") // <3> - .source(XContentType.JSON,"field", "baz")); + .source(MediaTypeRegistry.JSON,"field", "baz")); // end::bulk-request-with-mixed-operations BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); assertSame(RestStatus.OK, bulkResponse.status()); @@ -1580,13 +1580,13 @@ public void afterBulk(long executionId, BulkRequest request, // tag::bulk-processor-add IndexRequest one = new IndexRequest("posts").id("1") - .source(XContentType.JSON, "title", + .source(MediaTypeRegistry.JSON, "title", "In which order are my OpenSearch queries executed?"); IndexRequest two = new IndexRequest("posts").id("2") - .source(XContentType.JSON, "title", + .source(MediaTypeRegistry.JSON, "title", "Current status and upcoming changes in OpenSearch"); IndexRequest three = new IndexRequest("posts").id("3") - .source(XContentType.JSON, "title", + .source(MediaTypeRegistry.JSON, "title", "The Future of Federated Search in OpenSearch"); bulkProcessor.add(one); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java index ccbb64b13b2d2..07062c4796bcb 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java @@ -65,7 +65,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.indices.recovery.RecoverySettings; import org.opensearch.core.rest.RestStatus; @@ -138,7 +138,7 @@ public void testClusterPutSettings() throws IOException { // tag::put-settings-settings-source request.transientSettings( "{\"indices.recovery.max_bytes_per_sec\": \"10b\"}" - , XContentType.JSON); // <1> + , MediaTypeRegistry.JSON); // <1> // end::put-settings-settings-source } diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java index de2eb91c6660b..5cad389d32c87 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java @@ -107,9 +107,9 @@ import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.IndexSettings; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; @@ -329,7 +329,7 @@ public void testCreateIndex() throws IOException { " }\n" + " }\n" + "}", // <2> - XContentType.JSON); + MediaTypeRegistry.JSON); // end::create-index-request-mappings CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); @@ -407,7 +407,7 @@ public void testCreateIndex() throws IOException { " \"aliases\" : {\n" + " \"twitter_alias\" : {}\n" + " }\n" + - "}", XContentType.JSON); // <1> + "}", MediaTypeRegistry.JSON); // <1> // end::create-index-whole-source // tag::create-index-execute @@ -480,7 +480,7 @@ public void testPutMapping() throws IOException { " }\n" + " }\n" + "}", // <1> - XContentType.JSON); + MediaTypeRegistry.JSON); // end::put-mapping-request-source AcknowledgedResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); @@ -585,7 +585,7 @@ public void testGetMapping() throws IOException { CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); PutMappingRequest request = new PutMappingRequest("twitter"); - request.source("{ \"properties\": { \"message\": { \"type\": \"text\" } } }", XContentType.JSON); + request.source("{ \"properties\": { \"message\": { \"type\": \"text\" } } }", MediaTypeRegistry.JSON); AcknowledgedResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); } @@ -631,7 +631,7 @@ public void testGetMappingAsync() throws Exception { CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); PutMappingRequest request = new PutMappingRequest("twitter"); - request.source("{ \"properties\": { \"message\": { \"type\": \"text\" } } }", XContentType.JSON); + request.source("{ \"properties\": { \"message\": { \"type\": \"text\" } } }", MediaTypeRegistry.JSON); AcknowledgedResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); } @@ -703,7 +703,7 @@ public void testGetFieldMapping() throws IOException, InterruptedException { + " }\n" + " }\n" + "}", // <1> - XContentType.JSON + MediaTypeRegistry.JSON ); AcknowledgedResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); @@ -1127,7 +1127,8 @@ public void testGetIndex() throws Exception { { Settings settings = Settings.builder().put("number_of_shards", 3).build(); String mappings = "{\"properties\":{\"field-1\":{\"type\":\"integer\"}}}"; - CreateIndexRequest createIndexRequest = new CreateIndexRequest("index").settings(settings).mapping(mappings, XContentType.JSON); + CreateIndexRequest createIndexRequest = new CreateIndexRequest("index").settings(settings) + .mapping(mappings, MediaTypeRegistry.JSON); CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); } @@ -1830,7 +1831,7 @@ public void testRolloverIndex() throws Exception { // end::rollover-index-request-settings // tag::rollover-index-request-mapping String mappings = "{\"properties\":{\"field-1\":{\"type\":\"keyword\"}}}"; - request.getCreateIndexRequest().mapping(mappings, XContentType.JSON); // <1> + request.getCreateIndexRequest().mapping(mappings, MediaTypeRegistry.JSON); // <1> // end::rollover-index-request-mapping // tag::rollover-index-request-alias request.getCreateIndexRequest().alias(new Alias("another_alias")); // <1> @@ -2009,7 +2010,7 @@ public void testIndexPutSettings() throws Exception { // tag::indices-put-settings-settings-source request.settings( "{\"index.number_of_replicas\": \"2\"}" - , XContentType.JSON); // <1> + , MediaTypeRegistry.JSON); // <1> // end::indices-put-settings-settings-source } @@ -2090,7 +2091,7 @@ public void testPutTemplate() throws Exception { " }\n" + " }\n" + "}", - XContentType.JSON); + MediaTypeRegistry.JSON); // end::put-template-request-mappings-json assertTrue(client.indices().putTemplate(request, RequestOptions.DEFAULT).isAcknowledged()); } @@ -2165,7 +2166,7 @@ public void testPutTemplate() throws Exception { " \"alias-1\": {},\n" + " \"{index}-alias\": {}\n" + " }\n" + - "}", XContentType.JSON); // <1> + "}", MediaTypeRegistry.JSON); // <1> // end::put-template-whole-source // tag::put-template-request-create @@ -2220,7 +2221,7 @@ public void testGetTemplates() throws Exception { PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest("my-template"); putRequest.patterns(Arrays.asList("pattern-1", "log-*")); putRequest.settings(Settings.builder().put("index.number_of_shards", 3).put("index.number_of_replicas", 1)); - putRequest.mapping("{ \"properties\": { \"message\": { \"type\": \"text\" } } }", XContentType.JSON); + putRequest.mapping("{ \"properties\": { \"message\": { \"type\": \"text\" } } }", MediaTypeRegistry.JSON); assertTrue(client.indices().putTemplate(putRequest, RequestOptions.DEFAULT).isAcknowledged()); } diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IngestClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IngestClientDocumentationIT.java index 6c11aff3d292e..61b004b5ff733 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IngestClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IngestClientDocumentationIT.java @@ -50,7 +50,7 @@ import org.opensearch.client.RestHighLevelClient; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.ingest.PipelineConfiguration; import java.io.IOException; @@ -91,7 +91,7 @@ public void testPutPipeline() throws IOException { PutPipelineRequest request = new PutPipelineRequest( "my-pipeline-id", // <1> new BytesArray(source.getBytes(StandardCharsets.UTF_8)), // <2> - XContentType.JSON // <3> + MediaTypeRegistry.JSON // <3> ); // end::put-pipeline-request @@ -125,7 +125,7 @@ public void testPutPipelineAsync() throws Exception { PutPipelineRequest request = new PutPipelineRequest( "my-pipeline-id", new BytesArray(source.getBytes(StandardCharsets.UTF_8)), - XContentType.JSON + MediaTypeRegistry.JSON ); // tag::put-pipeline-execute-listener @@ -314,7 +314,7 @@ public void testSimulatePipeline() throws IOException { "}"; SimulatePipelineRequest request = new SimulatePipelineRequest( new BytesArray(source.getBytes(StandardCharsets.UTF_8)), // <1> - XContentType.JSON // <2> + MediaTypeRegistry.JSON // <2> ); // end::simulate-pipeline-request @@ -370,7 +370,7 @@ public void testSimulatePipelineAsync() throws Exception { + "}"; SimulatePipelineRequest request = new SimulatePipelineRequest( new BytesArray(source.getBytes(StandardCharsets.UTF_8)), - XContentType.JSON + MediaTypeRegistry.JSON ); // tag::simulate-pipeline-execute-listener diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SearchDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SearchDocumentationIT.java index 7f7062f0e8a4c..24aae6d66d8bf 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SearchDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SearchDocumentationIT.java @@ -71,7 +71,7 @@ import org.opensearch.common.unit.Fuzziness; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.get.GetResult; import org.opensearch.index.query.MatchQueryBuilder; import org.opensearch.index.query.QueryBuilder; @@ -319,9 +319,9 @@ public void testSearchRequestAggregations() throws IOException { RestHighLevelClient client = highLevelClient(); { BulkRequest request = new BulkRequest(); - request.add(new IndexRequest("posts").id("1").source(XContentType.JSON, "company", "OpenSearch", "age", 20)); - request.add(new IndexRequest("posts").id("2").source(XContentType.JSON, "company", "OpenSearch", "age", 30)); - request.add(new IndexRequest("posts").id("3").source(XContentType.JSON, "company", "OpenSearch", "age", 40)); + request.add(new IndexRequest("posts").id("1").source(MediaTypeRegistry.JSON, "company", "OpenSearch", "age", 20)); + request.add(new IndexRequest("posts").id("2").source(MediaTypeRegistry.JSON, "company", "OpenSearch", "age", 30)); + request.add(new IndexRequest("posts").id("3").source(MediaTypeRegistry.JSON, "company", "OpenSearch", "age", 40)); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); assertSame(RestStatus.OK, bulkResponse.status()); @@ -392,10 +392,10 @@ public void testSearchRequestSuggestions() throws IOException { RestHighLevelClient client = highLevelClient(); { BulkRequest request = new BulkRequest(); - request.add(new IndexRequest("posts").id("1").source(XContentType.JSON, "user", "foobar")); - request.add(new IndexRequest("posts").id("2").source(XContentType.JSON, "user", "quxx")); - request.add(new IndexRequest("posts").id("3").source(XContentType.JSON, "user", "quzz")); - request.add(new IndexRequest("posts").id("4").source(XContentType.JSON, "user", "corge")); + request.add(new IndexRequest("posts").id("1").source(MediaTypeRegistry.JSON, "user", "foobar")); + request.add(new IndexRequest("posts").id("2").source(MediaTypeRegistry.JSON, "user", "quxx")); + request.add(new IndexRequest("posts").id("3").source(MediaTypeRegistry.JSON, "user", "quzz")); + request.add(new IndexRequest("posts").id("4").source(MediaTypeRegistry.JSON, "user", "corge")); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); assertSame(RestStatus.OK, bulkResponse.status()); @@ -438,7 +438,7 @@ public void testSearchRequestHighlighting() throws IOException { request.add( new IndexRequest("posts").id("1") .source( - XContentType.JSON, + MediaTypeRegistry.JSON, "title", "In which order are my OpenSearch queries executed?", "user", @@ -450,7 +450,7 @@ public void testSearchRequestHighlighting() throws IOException { request.add( new IndexRequest("posts").id("2") .source( - XContentType.JSON, + MediaTypeRegistry.JSON, "title", "Current status and upcoming changes in OpenSearch", "user", @@ -462,7 +462,7 @@ public void testSearchRequestHighlighting() throws IOException { request.add( new IndexRequest("posts").id("3") .source( - XContentType.JSON, + MediaTypeRegistry.JSON, "title", "The Future of Federated Search in OpenSearch", "user", @@ -525,7 +525,7 @@ public void testSearchRequestHighlighting() throws IOException { public void testSearchRequestProfiling() throws IOException { RestHighLevelClient client = highLevelClient(); { - IndexRequest request = new IndexRequest("posts").id("1").source(XContentType.JSON, "tags", "opensearch", "comments", 123); + IndexRequest request = new IndexRequest("posts").id("1").source(MediaTypeRegistry.JSON, "tags", "opensearch", "comments", 123); request.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL); IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT); assertSame(RestStatus.CREATED, indexResponse.status()); @@ -597,13 +597,15 @@ public void testScroll() throws Exception { { BulkRequest request = new BulkRequest(); request.add( - new IndexRequest("posts").id("1").source(XContentType.JSON, "title", "In which order are my OpenSearch queries executed?") + new IndexRequest("posts").id("1") + .source(MediaTypeRegistry.JSON, "title", "In which order are my OpenSearch queries executed?") ); request.add( - new IndexRequest("posts").id("2").source(XContentType.JSON, "title", "Current status and upcoming changes in OpenSearch") + new IndexRequest("posts").id("2") + .source(MediaTypeRegistry.JSON, "title", "Current status and upcoming changes in OpenSearch") ); request.add( - new IndexRequest("posts").id("3").source(XContentType.JSON, "title", "The Future of Federated Search in OpenSearch") + new IndexRequest("posts").id("3").source(MediaTypeRegistry.JSON, "title", "The Future of Federated Search in OpenSearch") ); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); @@ -1320,7 +1322,7 @@ private void indexSearchTestData() throws IOException { bulkRequest.add( new IndexRequest("posts").id("1") .source( - XContentType.JSON, + MediaTypeRegistry.JSON, "id", 1, "title", @@ -1334,7 +1336,7 @@ private void indexSearchTestData() throws IOException { bulkRequest.add( new IndexRequest("posts").id("2") .source( - XContentType.JSON, + MediaTypeRegistry.JSON, "id", 2, "title", @@ -1348,7 +1350,7 @@ private void indexSearchTestData() throws IOException { bulkRequest.add( new IndexRequest("posts").id("3") .source( - XContentType.JSON, + MediaTypeRegistry.JSON, "id", 3, "title", @@ -1360,8 +1362,8 @@ private void indexSearchTestData() throws IOException { ) ); - bulkRequest.add(new IndexRequest("authors").id("1").source(XContentType.JSON, "id", 1, "user", "foobar")); - bulkRequest.add(new IndexRequest("contributors").id("1").source(XContentType.JSON, "id", 1, "user", "quuz")); + bulkRequest.add(new IndexRequest("authors").id("1").source(MediaTypeRegistry.JSON, "id", 1, "user", "foobar")); + bulkRequest.add(new IndexRequest("contributors").id("1").source(MediaTypeRegistry.JSON, "id", 1, "user", "quuz")); bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); BulkResponse bulkResponse = highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT); @@ -1472,7 +1474,7 @@ private static void indexCountTestData() throws IOException { bulkRequest.add( new IndexRequest("blog").id("1") .source( - XContentType.JSON, + MediaTypeRegistry.JSON, "title", "Doubling Down on Open?", "user", @@ -1484,7 +1486,7 @@ private static void indexCountTestData() throws IOException { bulkRequest.add( new IndexRequest("blog").id("2") .source( - XContentType.JSON, + MediaTypeRegistry.JSON, "title", "XYZ Joins Forces with OpenSearch", "user", @@ -1496,7 +1498,7 @@ private static void indexCountTestData() throws IOException { bulkRequest.add( new IndexRequest("blog").id("3") .source( - XContentType.JSON, + MediaTypeRegistry.JSON, "title", "On Net Neutrality", "user", @@ -1506,7 +1508,7 @@ private static void indexCountTestData() throws IOException { ) ); - bulkRequest.add(new IndexRequest("author").id("1").source(XContentType.JSON, "user", "foobar")); + bulkRequest.add(new IndexRequest("author").id("1").source(MediaTypeRegistry.JSON, "user", "foobar")); bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); BulkResponse bulkResponse = highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SnapshotClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SnapshotClientDocumentationIT.java index 976c69910d309..dcd1335e242b0 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SnapshotClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SnapshotClientDocumentationIT.java @@ -64,7 +64,7 @@ import org.opensearch.common.Booleans; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.repositories.fs.FsRepository; import org.opensearch.core.rest.RestStatus; import org.opensearch.snapshots.RestoreInfo; @@ -156,7 +156,7 @@ public void testSnapshotCreateRepository() throws IOException { { // tag::create-repository-settings-source request.settings("{\"location\": \".\", \"compress\": \"true\"}", - XContentType.JSON); // <1> + MediaTypeRegistry.JSON); // <1> // end::create-repository-settings-source } @@ -818,7 +818,7 @@ public void onFailure(Exception e) { private void createTestRepositories() throws IOException { PutRepositoryRequest request = new PutRepositoryRequest(repositoryName); request.type(FsRepository.TYPE); - request.settings("{\"location\": \".\"}", XContentType.JSON); + request.settings("{\"location\": \".\"}", MediaTypeRegistry.JSON); assertTrue(highLevelClient().snapshot().createRepository(request, RequestOptions.DEFAULT).isAcknowledged()); } diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/StoredScriptsDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/StoredScriptsDocumentationIT.java index 742dfa69e718b..551973a3912ce 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/StoredScriptsDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/StoredScriptsDocumentationIT.java @@ -45,9 +45,9 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.script.Script; import org.opensearch.script.StoredScriptSource; @@ -88,7 +88,7 @@ public void testGetStoredScript() throws Exception { final StoredScriptSource scriptSource = new StoredScriptSource( "painless", "Math.log(_score * 2) + params.my_modifier", - Collections.singletonMap(Script.CONTENT_TYPE_OPTION, XContentType.JSON.mediaType()) + Collections.singletonMap(Script.CONTENT_TYPE_OPTION, MediaTypeRegistry.JSON.mediaType()) ); putStoredScript("calculate-score", scriptSource); @@ -152,7 +152,7 @@ public void testDeleteStoredScript() throws Exception { final StoredScriptSource scriptSource = new StoredScriptSource( "painless", "Math.log(_score * 2) + params.my_modifier", - Collections.singletonMap(Script.CONTENT_TYPE_OPTION, XContentType.JSON.mediaType()) + Collections.singletonMap(Script.CONTENT_TYPE_OPTION, MediaTypeRegistry.JSON.mediaType()) ); putStoredScript("calculate-score", scriptSource); @@ -221,7 +221,7 @@ public void testPutScript() throws Exception { "\"source\": \"Math.log(_score * 2) + params.multiplier\"" + "}\n" + "}\n" - ), XContentType.JSON); // <2> + ), MediaTypeRegistry.JSON); // <2> // end::put-stored-script-request // tag::put-stored-script-context @@ -255,7 +255,7 @@ public void testPutScript() throws Exception { builder.endObject(); } builder.endObject(); - request.content(BytesReference.bytes(builder), XContentType.JSON); // <1> + request.content(BytesReference.bytes(builder), MediaTypeRegistry.JSON); // <1> // end::put-stored-script-content-painless // tag::put-stored-script-execute @@ -310,7 +310,7 @@ public void onFailure(Exception e) { builder.endObject(); } builder.endObject(); - request.content(BytesReference.bytes(builder), XContentType.JSON); // <1> + request.content(BytesReference.bytes(builder), MediaTypeRegistry.JSON); // <1> // end::put-stored-script-content-mustache client.putScript(request, RequestOptions.DEFAULT); @@ -322,7 +322,13 @@ public void onFailure(Exception e) { } private void putStoredScript(String id, StoredScriptSource scriptSource) throws IOException { - PutStoredScriptRequest request = new PutStoredScriptRequest(id, "score", new BytesArray("{}"), XContentType.JSON, scriptSource); + PutStoredScriptRequest request = new PutStoredScriptRequest( + id, + "score", + new BytesArray("{}"), + MediaTypeRegistry.JSON, + scriptSource + ); assertAcked(execute(request, highLevelClient()::putScript, highLevelClient()::putScriptAsync)); } } diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/indices/GetIndexTemplatesResponseTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/indices/GetIndexTemplatesResponseTests.java index 8c83791d94d42..d1584e5230e34 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/indices/GetIndexTemplatesResponseTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/indices/GetIndexTemplatesResponseTests.java @@ -164,7 +164,7 @@ private Predicate randomFieldsExcludeFilter() { private static void assertEqualInstances(GetIndexTemplatesResponse expectedInstance, GetIndexTemplatesResponse newInstance) { assertEquals(expectedInstance, newInstance); // Check there's no doc types at the root of the mapping - Map expectedMap = XContentHelper.convertToMap(new BytesArray(mappingString), true, XContentType.JSON).v2(); + Map expectedMap = XContentHelper.convertToMap(new BytesArray(mappingString), true, MediaTypeRegistry.JSON).v2(); for (IndexTemplateMetadata template : newInstance.getIndexTemplates()) { MappingMetadata mappingMD = template.mappings(); if (mappingMD != null) { @@ -194,7 +194,7 @@ static GetIndexTemplatesResponse createTestInstance() { templateBuilder.version(between(0, 100)); } if (randomBoolean()) { - Map map = XContentHelper.convertToMap(new BytesArray(mappingString), true, XContentType.JSON).v2(); + Map map = XContentHelper.convertToMap(new BytesArray(mappingString), true, MediaTypeRegistry.JSON).v2(); MappingMetadata mapping = new MappingMetadata(MapperService.SINGLE_MAPPING_NAME, map); templateBuilder.mapping(mapping); } diff --git a/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/NodeRestUsageIT.java b/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/NodeRestUsageIT.java index 0f21984e5d8b9..c95cad310f126 100644 --- a/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/NodeRestUsageIT.java +++ b/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/NodeRestUsageIT.java @@ -37,6 +37,7 @@ import org.opensearch.client.ResponseException; import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.search.aggregations.AggregationBuilders; import org.opensearch.search.builder.SearchSourceBuilder; @@ -172,8 +173,8 @@ public void testAggregationUsage() throws IOException { .aggregation(AggregationBuilders.terms("str_terms").field("str.keyword")) .aggregation(AggregationBuilders.terms("num_terms").field("num")) .aggregation(AggregationBuilders.avg("num_avg").field("num")); - searchRequest.setJsonEntity(Strings.toString(XContentType.JSON, searchSource)); - searchRequest.setJsonEntity(Strings.toString(XContentType.JSON, searchSource)); + searchRequest.setJsonEntity(Strings.toString(MediaTypeRegistry.JSON, searchSource)); + searchRequest.setJsonEntity(Strings.toString(MediaTypeRegistry.JSON, searchSource)); client().performRequest(searchRequest); searchRequest = new Request("GET", "/test/_search"); @@ -182,8 +183,8 @@ public void testAggregationUsage() throws IOException { .aggregation(AggregationBuilders.avg("num1").field("num")) .aggregation(AggregationBuilders.avg("num2").field("num")) .aggregation(AggregationBuilders.terms("foo").field("foo.keyword")); - String r = Strings.toString(XContentType.JSON, searchSource); - searchRequest.setJsonEntity(Strings.toString(XContentType.JSON, searchSource)); + String r = Strings.toString(MediaTypeRegistry.JSON, searchSource); + searchRequest.setJsonEntity(Strings.toString(MediaTypeRegistry.JSON, searchSource)); client().performRequest(searchRequest); Response response = client().performRequest(new Request("GET", "_nodes/usage")); diff --git a/libs/core/src/main/java/org/opensearch/core/xcontent/MapXContentParser.java b/libs/core/src/main/java/org/opensearch/core/xcontent/MapXContentParser.java index 54329038e1fc5..254c340f8836f 100644 --- a/libs/core/src/main/java/org/opensearch/core/xcontent/MapXContentParser.java +++ b/libs/core/src/main/java/org/opensearch/core/xcontent/MapXContentParser.java @@ -45,7 +45,7 @@ */ public class MapXContentParser extends AbstractXContentParser { - private MediaType xContentType; + private MediaType mediaType; private TokenIterator iterator; private boolean closed; @@ -53,10 +53,10 @@ public MapXContentParser( NamedXContentRegistry xContentRegistry, DeprecationHandler deprecationHandler, Map map, - MediaType xContentType + MediaType mediaType ) { super(xContentRegistry, deprecationHandler); - this.xContentType = xContentType; + this.mediaType = mediaType; this.iterator = new MapIterator(null, null, map); } @@ -105,7 +105,7 @@ protected BigInteger doBigIntegerValue() throws IOException { @Override public MediaType contentType() { - return xContentType; + return mediaType; } @Override diff --git a/libs/core/src/main/java/org/opensearch/core/xcontent/XContentHelper.java b/libs/core/src/main/java/org/opensearch/core/xcontent/XContentHelper.java new file mode 100644 index 0000000000000..a99a12273a6f0 --- /dev/null +++ b/libs/core/src/main/java/org/opensearch/core/xcontent/XContentHelper.java @@ -0,0 +1,53 @@ +/* + * 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. + */ + +package org.opensearch.core.xcontent; + +import org.opensearch.core.common.bytes.BytesReference; + +import java.io.IOException; + +/** + * Core XContent Helper Utilities + * + * @opensearch.internal + */ +public final class XContentHelper { + // no instance + private XContentHelper() {} + + /** + * Returns the bytes that represent the XContent output of the provided {@link ToXContent} object, using the provided + * {@link MediaType}. Wraps the output into a new anonymous object according to the value returned + * by the {@link ToXContent#isFragment()} method returns. + */ + @Deprecated + public static BytesReference toXContent(ToXContent toXContent, MediaType mediaType, boolean humanReadable) throws IOException { + return toXContent(toXContent, mediaType, ToXContent.EMPTY_PARAMS, humanReadable); + } + + /** + * Returns the bytes that represent the XContent output of the provided {@link ToXContent} object, using the provided + * {@link MediaType}. Wraps the output into a new anonymous object according to the value returned + * by the {@link ToXContent#isFragment()} method returns. + */ + public static BytesReference toXContent(ToXContent toXContent, MediaType mediaType, ToXContent.Params params, boolean humanReadable) + throws IOException { + try (XContentBuilder builder = XContentBuilder.builder(mediaType.xContent())) { + builder.humanReadable(humanReadable); + if (toXContent.isFragment()) { + builder.startObject(); + } + toXContent.toXContent(builder, params); + if (toXContent.isFragment()) { + builder.endObject(); + } + return BytesReference.bytes(builder); + } + } +} diff --git a/libs/core/src/main/java/org/opensearch/core/xcontent/XContentParser.java b/libs/core/src/main/java/org/opensearch/core/xcontent/XContentParser.java index 328eaa4bc36e9..a2f16209a5b7f 100644 --- a/libs/core/src/main/java/org/opensearch/core/xcontent/XContentParser.java +++ b/libs/core/src/main/java/org/opensearch/core/xcontent/XContentParser.java @@ -48,8 +48,8 @@ * To obtain an instance of this class use the following pattern: * *
- *     XContentType xContentType = XContentType.JSON;
- *     XContentParser parser = xContentType.xContent().createParser(
+ *     MediaType mediaType = MediaTypeRegistry.JSON;
+ *     XContentParser parser = mediaType.xContent().createParser(
  *          NamedXContentRegistry.EMPTY, ParserField."{\"key\" : \"value\"}");
  * 
* diff --git a/libs/core/src/test/java/org/opensearch/core/action/support/DefaultShardOperationFailedExceptionTests.java b/libs/core/src/test/java/org/opensearch/core/action/support/DefaultShardOperationFailedExceptionTests.java index 9801e9cbcdb44..985a7fdf3614b 100644 --- a/libs/core/src/test/java/org/opensearch/core/action/support/DefaultShardOperationFailedExceptionTests.java +++ b/libs/core/src/test/java/org/opensearch/core/action/support/DefaultShardOperationFailedExceptionTests.java @@ -44,6 +44,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -92,7 +93,7 @@ public void testToXContent() throws IOException { assertEquals( "{\"shard\":-1,\"index\":null,\"status\":\"INTERNAL_SERVER_ERROR\"," + "\"reason\":{\"type\":\"exception\",\"reason\":\"foo\"}}", - Strings.toString(XContentType.JSON, exception) + Strings.toString(MediaTypeRegistry.JSON, exception) ); } { @@ -102,7 +103,7 @@ public void testToXContent() throws IOException { assertEquals( "{\"shard\":-1,\"index\":null,\"status\":\"INTERNAL_SERVER_ERROR\",\"reason\":{\"type\":\"exception\"," + "\"reason\":\"foo\",\"caused_by\":{\"type\":\"illegal_argument_exception\",\"reason\":\"bar\"}}}", - Strings.toString(XContentType.JSON, exception) + Strings.toString(MediaTypeRegistry.JSON, exception) ); } { @@ -112,7 +113,7 @@ public void testToXContent() throws IOException { assertEquals( "{\"shard\":2,\"index\":\"test\",\"status\":\"INTERNAL_SERVER_ERROR\"," + "\"reason\":{\"type\":\"illegal_state_exception\",\"reason\":\"bar\"}}", - Strings.toString(XContentType.JSON, exception) + Strings.toString(MediaTypeRegistry.JSON, exception) ); } { @@ -124,7 +125,7 @@ public void testToXContent() throws IOException { assertEquals( "{\"shard\":1,\"index\":\"test\",\"status\":\"BAD_REQUEST\"," + "\"reason\":{\"type\":\"illegal_argument_exception\",\"reason\":\"foo\"}}", - Strings.toString(XContentType.JSON, exception) + Strings.toString(MediaTypeRegistry.JSON, exception) ); } } diff --git a/libs/x-content/src/test/java/org/opensearch/common/xcontent/ObjectParserTests.java b/libs/x-content/src/test/java/org/opensearch/common/xcontent/ObjectParserTests.java index 6e7de4aa6bfe5..22ba914d9b165 100644 --- a/libs/x-content/src/test/java/org/opensearch/common/xcontent/ObjectParserTests.java +++ b/libs/x-content/src/test/java/org/opensearch/common/xcontent/ObjectParserTests.java @@ -33,6 +33,7 @@ import org.opensearch.common.CheckedFunction; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParserUtils; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ObjectParser.NamedObjectParser; @@ -394,7 +395,7 @@ public void testAllVariants() throws IOException { double expectedNullableDouble; int expectedNullableInt; - XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder(); builder.startObject(); builder.field("int_field", randomBoolean() ? "1" : 1); if (randomBoolean()) { @@ -646,7 +647,7 @@ public void testParseNamedObjectsInOrderNotSupported() throws IOException { } public void testIgnoreUnknownFields() throws IOException { - XContentBuilder b = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder b = MediaTypeRegistry.JSON.contentBuilder(); b.startObject(); { b.field("test", "foo"); @@ -668,7 +669,7 @@ class TestStruct { } public void testIgnoreUnknownObjects() throws IOException { - XContentBuilder b = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder b = MediaTypeRegistry.JSON.contentBuilder(); b.startObject(); { b.field("test", "foo"); @@ -694,7 +695,7 @@ class TestStruct { } public void testIgnoreUnknownArrays() throws IOException { - XContentBuilder b = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder b = MediaTypeRegistry.JSON.contentBuilder(); b.startObject(); { b.field("test", "foo"); diff --git a/modules/ingest-common/src/internalClusterTest/java/org/opensearch/ingest/common/IngestRestartIT.java b/modules/ingest-common/src/internalClusterTest/java/org/opensearch/ingest/common/IngestRestartIT.java index 49c7c7ae152c0..3dc450df534f3 100644 --- a/modules/ingest-common/src/internalClusterTest/java/org/opensearch/ingest/common/IngestRestartIT.java +++ b/modules/ingest-common/src/internalClusterTest/java/org/opensearch/ingest/common/IngestRestartIT.java @@ -36,7 +36,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.ingest.IngestStats; import org.opensearch.plugins.Plugin; import org.opensearch.script.MockScriptEngine; @@ -108,7 +108,7 @@ public void testFailureInConditionalProcessor() { + " ]\n" + "}" ), - XContentType.JSON + MediaTypeRegistry.JSON ) .get(); @@ -160,8 +160,8 @@ public void testScriptDisabled() throws Exception { equalTo(id) ); - client().admin().cluster().preparePutPipeline(pipelineIdWithScript, pipelineWithScript, XContentType.JSON).get(); - client().admin().cluster().preparePutPipeline(pipelineIdWithoutScript, pipelineWithoutScript, XContentType.JSON).get(); + client().admin().cluster().preparePutPipeline(pipelineIdWithScript, pipelineWithScript, MediaTypeRegistry.JSON).get(); + client().admin().cluster().preparePutPipeline(pipelineIdWithoutScript, pipelineWithoutScript, MediaTypeRegistry.JSON).get(); checkPipelineExists.accept(pipelineIdWithScript); checkPipelineExists.accept(pipelineIdWithoutScript); @@ -225,7 +225,7 @@ public void testPipelineWithScriptProcessorThatHasStoredScript() throws Exceptio .setId("1") .setContent( new BytesArray("{\"script\": {\"lang\": \"" + MockScriptEngine.NAME + "\", \"source\": \"my_script\"} }"), - XContentType.JSON + MediaTypeRegistry.JSON ) .get(); BytesReference pipeline = new BytesArray( @@ -236,7 +236,7 @@ public void testPipelineWithScriptProcessorThatHasStoredScript() throws Exceptio + " ]\n" + "}" ); - client().admin().cluster().preparePutPipeline("_id", pipeline, XContentType.JSON).get(); + client().admin().cluster().preparePutPipeline("_id", pipeline, MediaTypeRegistry.JSON).get(); client().prepareIndex("index") .setId("1") @@ -277,7 +277,7 @@ public void testWithDedicatedIngestNode() throws Exception { BytesReference pipeline = new BytesArray( "{\n" + " \"processors\" : [\n" + " {\"set\" : {\"field\": \"y\", \"value\": 0}}\n" + " ]\n" + "}" ); - client().admin().cluster().preparePutPipeline("_id", pipeline, XContentType.JSON).get(); + client().admin().cluster().preparePutPipeline("_id", pipeline, MediaTypeRegistry.JSON).get(); client().prepareIndex("index") .setId("1") diff --git a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ScriptProcessor.java b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ScriptProcessor.java index b66d0b709a824..6a22a0b1385a6 100644 --- a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ScriptProcessor.java +++ b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ScriptProcessor.java @@ -36,10 +36,10 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.util.CollectionUtils; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.ingest.AbstractProcessor; import org.opensearch.ingest.IngestDocument; @@ -137,7 +137,7 @@ public ScriptProcessor create( try ( XContentBuilder builder = XContentBuilder.builder(JsonXContent.jsonXContent).map(config); InputStream stream = BytesReference.bytes(builder).streamInput(); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, stream) ) { Script script = Script.parse(parser); diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/JsonProcessorTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/JsonProcessorTests.java index 531e22a386236..a197b5c9a7d89 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/JsonProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/JsonProcessorTests.java @@ -33,9 +33,9 @@ package org.opensearch.ingest.common; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.ingest.IngestDocument; import org.opensearch.ingest.RandomDocumentPicks; @@ -61,7 +61,7 @@ public void testExecute() throws Exception { Map randomJsonMap = RandomDocumentPicks.randomSource(random()); XContentBuilder builder = JsonXContent.contentBuilder().map(randomJsonMap); - String randomJson = XContentHelper.convertToJson(BytesReference.bytes(builder), false, XContentType.JSON); + String randomJson = XContentHelper.convertToJson(BytesReference.bytes(builder), false, MediaTypeRegistry.JSON); document.put(randomField, randomJson); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document); diff --git a/modules/ingest-geoip/src/internalClusterTest/java/org/opensearch/ingest/geoip/GeoIpProcessorNonIngestNodeIT.java b/modules/ingest-geoip/src/internalClusterTest/java/org/opensearch/ingest/geoip/GeoIpProcessorNonIngestNodeIT.java index b947f929fce76..ebf298be74a80 100644 --- a/modules/ingest-geoip/src/internalClusterTest/java/org/opensearch/ingest/geoip/GeoIpProcessorNonIngestNodeIT.java +++ b/modules/ingest-geoip/src/internalClusterTest/java/org/opensearch/ingest/geoip/GeoIpProcessorNonIngestNodeIT.java @@ -39,8 +39,8 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.ingest.IngestService; import org.opensearch.plugins.Plugin; @@ -158,7 +158,7 @@ public void testLazyLoading() throws IOException { builder.endObject(); bytes = BytesReference.bytes(builder); } - assertAcked(client().admin().cluster().putPipeline(new PutPipelineRequest("geoip", bytes, XContentType.JSON)).actionGet()); + assertAcked(client().admin().cluster().putPipeline(new PutPipelineRequest("geoip", bytes, MediaTypeRegistry.JSON)).actionGet()); // the geo-IP databases should not be loaded on any nodes as they are all non-ingest nodes Arrays.stream(internalCluster().getNodeNames()).forEach(node -> assertDatabaseLoadStatus(node, false)); diff --git a/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/StoredExpressionIT.java b/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/StoredExpressionIT.java index 7527092f4344c..3344d4e419924 100644 --- a/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/StoredExpressionIT.java +++ b/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/StoredExpressionIT.java @@ -34,7 +34,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.plugins.Plugin; import org.opensearch.script.Script; import org.opensearch.script.ScriptType; @@ -67,9 +67,9 @@ public void testAllOpsDisabledIndexedScripts() throws IOException { .cluster() .preparePutStoredScript() .setId("script1") - .setContent(new BytesArray("{\"script\": {\"lang\": \"expression\", \"source\": \"2\"} }"), XContentType.JSON) + .setContent(new BytesArray("{\"script\": {\"lang\": \"expression\", \"source\": \"2\"} }"), MediaTypeRegistry.JSON) .get(); - client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", MediaTypeRegistry.JSON).get(); try { client().prepareUpdate("test", "1").setScript(new Script(ScriptType.STORED, null, "script1", Collections.emptyMap())).get(); fail("update script should have been rejected"); diff --git a/modules/lang-mustache/src/internalClusterTest/java/org/opensearch/script/mustache/SearchTemplateIT.java b/modules/lang-mustache/src/internalClusterTest/java/org/opensearch/script/mustache/SearchTemplateIT.java index d0a0b7bcd3e3e..9cdd89dadfd8d 100644 --- a/modules/lang-mustache/src/internalClusterTest/java/org/opensearch/script/mustache/SearchTemplateIT.java +++ b/modules/lang-mustache/src/internalClusterTest/java/org/opensearch/script/mustache/SearchTemplateIT.java @@ -36,8 +36,8 @@ import org.opensearch.action.bulk.BulkRequestBuilder; import org.opensearch.action.search.SearchRequest; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.plugins.Plugin; import org.opensearch.script.ScriptType; import org.opensearch.test.OpenSearchSingleNodeTestCase; @@ -177,7 +177,7 @@ public void testIndexedTemplateClient() throws Exception { + " }" + "}" ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -185,11 +185,11 @@ public void testIndexedTemplateClient() throws Exception { assertNotNull(getResponse.getSource()); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); - bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("2").setSource("{\"theField\":\"foo 2\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("3").setSource("{\"theField\":\"foo 3\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("2").setSource("{\"theField\":\"foo 2\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("3").setSource("{\"theField\":\"foo 3\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", MediaTypeRegistry.JSON)); bulkRequestBuilder.get(); client().admin().indices().prepareRefresh().get(); @@ -224,16 +224,22 @@ public void testIndexedTemplate() throws Exception { + " }" + "}"; - assertAcked(client().admin().cluster().preparePutStoredScript().setId("1a").setContent(new BytesArray(script), XContentType.JSON)); - assertAcked(client().admin().cluster().preparePutStoredScript().setId("2").setContent(new BytesArray(script), XContentType.JSON)); - assertAcked(client().admin().cluster().preparePutStoredScript().setId("3").setContent(new BytesArray(script), XContentType.JSON)); + assertAcked( + client().admin().cluster().preparePutStoredScript().setId("1a").setContent(new BytesArray(script), MediaTypeRegistry.JSON) + ); + assertAcked( + client().admin().cluster().preparePutStoredScript().setId("2").setContent(new BytesArray(script), MediaTypeRegistry.JSON) + ); + assertAcked( + client().admin().cluster().preparePutStoredScript().setId("3").setContent(new BytesArray(script), MediaTypeRegistry.JSON) + ); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); - bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("2").setSource("{\"theField\":\"foo 2\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("3").setSource("{\"theField\":\"foo 3\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("2").setSource("{\"theField\":\"foo 2\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("3").setSource("{\"theField\":\"foo 3\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", MediaTypeRegistry.JSON)); bulkRequestBuilder.get(); client().admin().indices().prepareRefresh().get(); @@ -295,7 +301,7 @@ public void testIndexedTemplateOverwrite() throws Exception { .cluster() .preparePutStoredScript() .setId("git01") - .setContent(new BytesArray(query.replace("{{slop}}", Integer.toString(-1))), XContentType.JSON) + .setContent(new BytesArray(query.replace("{{slop}}", Integer.toString(-1))), MediaTypeRegistry.JSON) ); GetStoredScriptResponse getResponse = client().admin().cluster().prepareGetStoredScript("git01").get(); @@ -319,7 +325,7 @@ public void testIndexedTemplateOverwrite() throws Exception { .cluster() .preparePutStoredScript() .setId("git01") - .setContent(new BytesArray(query.replace("{{slop}}", Integer.toString(0))), XContentType.JSON) + .setContent(new BytesArray(query.replace("{{slop}}", Integer.toString(0))), MediaTypeRegistry.JSON) ); SearchTemplateResponse searchResponse = new SearchTemplateRequestBuilder(client()).setRequest(new SearchRequest("testindex")) @@ -349,14 +355,14 @@ public void testIndexedTemplateWithArray() throws Exception { + " }\n" + "}"; assertAcked( - client().admin().cluster().preparePutStoredScript().setId("4").setContent(new BytesArray(multiQuery), XContentType.JSON) + client().admin().cluster().preparePutStoredScript().setId("4").setContent(new BytesArray(multiQuery), MediaTypeRegistry.JSON) ); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); - bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("2").setSource("{\"theField\":\"foo 2\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("3").setSource("{\"theField\":\"foo 3\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", XContentType.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("2").setSource("{\"theField\":\"foo 2\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("3").setSource("{\"theField\":\"foo 3\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("4").setSource("{\"theField\":\"foo 4\"}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("test").setId("5").setSource("{\"theField\":\"bar\"}", MediaTypeRegistry.JSON)); bulkRequestBuilder.get(); client().admin().indices().prepareRefresh().get(); diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/CustomMustacheFactory.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/CustomMustacheFactory.java index 0cf1ed525fbfe..55f530740813b 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/CustomMustacheFactory.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/CustomMustacheFactory.java @@ -44,8 +44,8 @@ import com.github.mustachejava.codes.IterableCode; import com.github.mustachejava.codes.WriteCode; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.io.StringWriter; @@ -214,7 +214,7 @@ protected Function createFunction(Object resolved) { if (resolved == null) { return null; } - try (XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent())) { + try (XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder()) { if (resolved instanceof Iterable) { builder.startArray(); for (Object o : (Iterable) resolved) { diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java index 49f5d4194d446..9587b9583aeb2 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java @@ -41,7 +41,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -200,6 +200,6 @@ public static MultiSearchTemplateResponse fromXContext(XContentParser parser) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/SearchTemplateResponse.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/SearchTemplateResponse.java index da67a0d2dd13a..66dcc89261229 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/SearchTemplateResponse.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/SearchTemplateResponse.java @@ -43,7 +43,6 @@ import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.rest.RestStatus; import java.io.IOException; @@ -104,7 +103,7 @@ public static SearchTemplateResponse fromXContent(XContentParser parser) throws if (contentAsMap.containsKey(TEMPLATE_OUTPUT_FIELD.getPreferredName())) { Object source = contentAsMap.get(TEMPLATE_OUTPUT_FIELD.getPreferredName()); - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON).value(source); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON).value(source); searchTemplateResponse.setSource(BytesReference.bytes(builder)); } else { MediaType contentType = parser.contentType(); @@ -126,7 +125,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.startObject(); // we can assume the template is always json as we convert it before compiling it try (InputStream stream = source.streamInput()) { - builder.rawField(TEMPLATE_OUTPUT_FIELD.getPreferredName(), stream, XContentType.JSON); + builder.rawField(TEMPLATE_OUTPUT_FIELD.getPreferredName(), stream, MediaTypeRegistry.JSON); } builder.endObject(); } diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java index f6b0cc4eecf9a..6ec5dc8f7f9ca 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java @@ -41,9 +41,9 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.inject.Inject; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.rest.action.search.RestSearchAction; import org.opensearch.script.Script; import org.opensearch.script.ScriptService; @@ -131,7 +131,8 @@ static SearchRequest convert( } try ( - XContentParser parser = XContentType.JSON.xContent().createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, source) + XContentParser parser = MediaTypeRegistry.JSON.xContent() + .createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, source) ) { SearchSourceBuilder builder = SearchSourceBuilder.searchSource(); builder.parseXContent(parser, false); diff --git a/modules/lang-mustache/src/test/java/org/opensearch/script/mustache/MultiSearchTemplateRequestTests.java b/modules/lang-mustache/src/test/java/org/opensearch/script/mustache/MultiSearchTemplateRequestTests.java index 311f14cb8d80d..7499d86f70b2b 100644 --- a/modules/lang-mustache/src/test/java/org/opensearch/script/mustache/MultiSearchTemplateRequestTests.java +++ b/modules/lang-mustache/src/test/java/org/opensearch/script/mustache/MultiSearchTemplateRequestTests.java @@ -34,7 +34,7 @@ import org.opensearch.action.search.SearchRequest; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.rest.RestRequest; import org.opensearch.script.ScriptType; import org.opensearch.search.Scroll; @@ -56,7 +56,7 @@ public class MultiSearchTemplateRequestTests extends OpenSearchTestCase { public void testParseRequest() throws Exception { byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/opensearch/script/mustache/simple-msearch-template.json"); - RestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(data), XContentType.JSON) + RestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(data), MediaTypeRegistry.JSON) .build(); MultiSearchTemplateRequest request = RestMultiSearchTemplateAction.parseRequest(restRequest, true); @@ -92,8 +92,10 @@ public void testParseRequest() throws Exception { public void testParseWithCarriageReturn() throws Exception { final String content = "{\"index\":[\"test0\", \"test1\"], \"request_cache\": true}\r\n" + "{\"source\": {\"query\" : {\"match_{{template}}\" :{}}}, \"params\": {\"template\": \"all\" } }\r\n"; - RestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(content), XContentType.JSON) - .build(); + RestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent( + new BytesArray(content), + MediaTypeRegistry.JSON + ).build(); MultiSearchTemplateRequest request = RestMultiSearchTemplateAction.parseRequest(restRequest, true); @@ -144,8 +146,10 @@ public void testMultiSearchTemplateToJson() throws Exception { String serialized = toJsonString(multiSearchTemplateRequest); // Deserialize the request - RestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(serialized), XContentType.JSON) - .build(); + RestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent( + new BytesArray(serialized), + MediaTypeRegistry.JSON + ).build(); MultiSearchTemplateRequest deser = RestMultiSearchTemplateAction.parseRequest(restRequest, true); // For object equality purposes need to set the search requests' source to non-null @@ -163,7 +167,7 @@ public void testMultiSearchTemplateToJson() throws Exception { } protected String toJsonString(MultiSearchTemplateRequest multiSearchTemplateRequest) throws IOException { - byte[] bytes = MultiSearchTemplateRequest.writeMultiLineFormat(multiSearchTemplateRequest, XContentType.JSON.xContent()); + byte[] bytes = MultiSearchTemplateRequest.writeMultiLineFormat(multiSearchTemplateRequest, MediaTypeRegistry.JSON.xContent()); return new String(bytes, StandardCharsets.UTF_8); } diff --git a/modules/lang-mustache/src/test/java/org/opensearch/script/mustache/SearchTemplateResponseTests.java b/modules/lang-mustache/src/test/java/org/opensearch/script/mustache/SearchTemplateResponseTests.java index fd0a4e9612a8f..2c9500852897f 100644 --- a/modules/lang-mustache/src/test/java/org/opensearch/script/mustache/SearchTemplateResponseTests.java +++ b/modules/lang-mustache/src/test/java/org/opensearch/script/mustache/SearchTemplateResponseTests.java @@ -130,7 +130,7 @@ protected void assertEqualInstances(SearchTemplateResponse expectedInstance, Sea assertEquals(expectedSource == null, newSource == null); if (expectedSource != null) { try { - assertToXContentEquivalent(expectedSource, newSource, XContentType.JSON); + assertToXContentEquivalent(expectedSource, newSource, MediaTypeRegistry.JSON); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/action/PainlessExecuteApiTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/action/PainlessExecuteApiTests.java index e80cc2d23e290..3bc1e806879ce 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/action/PainlessExecuteApiTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/action/PainlessExecuteApiTests.java @@ -33,7 +33,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.query.MatchQueryBuilder; import org.opensearch.painless.PainlessModulePlugin; @@ -92,13 +92,13 @@ public void testFilterExecutionContext() throws IOException { IndexService indexService = createIndex("index", Settings.EMPTY, "doc", "field", "type=long"); Request.ContextSetup contextSetup = new Request.ContextSetup("index", new BytesArray("{\"field\": 3}"), null); - contextSetup.setXContentType(XContentType.JSON); + contextSetup.setXContentType(MediaTypeRegistry.JSON); Request request = new Request(new Script("doc['field'].value >= 3"), "filter", contextSetup); Response response = innerShardOperation(request, scriptService, indexService); assertThat(response.getResult(), equalTo(true)); contextSetup = new Request.ContextSetup("index", new BytesArray("{\"field\": 3}"), null); - contextSetup.setXContentType(XContentType.JSON); + contextSetup.setXContentType(MediaTypeRegistry.JSON); request = new Request( new Script(ScriptType.INLINE, "painless", "doc['field'].value >= params.max", singletonMap("max", 3)), "filter", @@ -108,7 +108,7 @@ public void testFilterExecutionContext() throws IOException { assertThat(response.getResult(), equalTo(true)); contextSetup = new Request.ContextSetup("index", new BytesArray("{\"field\": 2}"), null); - contextSetup.setXContentType(XContentType.JSON); + contextSetup.setXContentType(MediaTypeRegistry.JSON); request = new Request( new Script(ScriptType.INLINE, "painless", "doc['field'].value >= params.max", singletonMap("max", 3)), "filter", @@ -127,7 +127,7 @@ public void testScoreExecutionContext() throws IOException { new BytesArray("{\"rank\": 4.0, \"text\": \"quick brown fox\"}"), new MatchQueryBuilder("text", "fox") ); - contextSetup.setXContentType(XContentType.JSON); + contextSetup.setXContentType(MediaTypeRegistry.JSON); Request request = new Request( new Script( ScriptType.INLINE, diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/BWCTemplateTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/BWCTemplateTests.java index d498116efc108..6b14a1d930287 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/BWCTemplateTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/BWCTemplateTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.mapper; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchSingleNodeTestCase; @@ -54,9 +54,9 @@ public void testBeatsTemplatesBWC() throws Exception { byte[] metricBeat = copyToBytesFromClasspath("/org/opensearch/index/mapper/metricbeat-6.0.template.json"); byte[] packetBeat = copyToBytesFromClasspath("/org/opensearch/index/mapper/packetbeat-6.0.template.json"); byte[] fileBeat = copyToBytesFromClasspath("/org/opensearch/index/mapper/filebeat-6.0.template.json"); - client().admin().indices().preparePutTemplate("metricbeat").setSource(metricBeat, XContentType.JSON).get(); - client().admin().indices().preparePutTemplate("packetbeat").setSource(packetBeat, XContentType.JSON).get(); - client().admin().indices().preparePutTemplate("filebeat").setSource(fileBeat, XContentType.JSON).get(); + client().admin().indices().preparePutTemplate("metricbeat").setSource(metricBeat, MediaTypeRegistry.JSON).get(); + client().admin().indices().preparePutTemplate("packetbeat").setSource(packetBeat, MediaTypeRegistry.JSON).get(); + client().admin().indices().preparePutTemplate("filebeat").setSource(fileBeat, MediaTypeRegistry.JSON).get(); client().prepareIndex("metricbeat-foo").setId("1").setSource("message", "foo").get(); client().prepareIndex("packetbeat-foo").setId("1").setSource("message", "foo").get(); diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureMetaFieldMapperTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureMetaFieldMapperTests.java index d35368350592c..c0b4b44b7935f 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureMetaFieldMapperTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureMetaFieldMapperTests.java @@ -34,7 +34,6 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.plugins.Plugin; @@ -91,7 +90,7 @@ public void testDocumentParsingFailsOnMetaField() throws Exception { ); MapperParsingException e = expectThrows( MapperParsingException.class, - () -> mapper.parse(new SourceToParse("test", "1", bytes, XContentType.JSON)) + () -> mapper.parse(new SourceToParse("test", "1", bytes, MediaTypeRegistry.JSON)) ); assertTrue( e.getCause().getMessage().contains("Field [" + rfMetaField + "] is a metadata field and cannot be added inside a document.") diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/ScaledFloatFieldMapperTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/ScaledFloatFieldMapperTests.java index 4de11d7f64e8e..f0cd389fe3f94 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/ScaledFloatFieldMapperTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/ScaledFloatFieldMapperTests.java @@ -35,9 +35,9 @@ import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.IndexableField; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.plugins.Plugin; import java.io.IOException; @@ -135,7 +135,7 @@ public void testNotIndexed() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", 123).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -156,7 +156,7 @@ public void testNoDocValues() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", 123).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -177,7 +177,7 @@ public void testStore() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", 123).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -200,7 +200,7 @@ public void testCoerce() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "123").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = doc.rootDoc().getFields("field"); @@ -219,7 +219,7 @@ public void testCoerce() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "123").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); MapperParsingException e = expectThrows(MapperParsingException.class, runnable); @@ -243,7 +243,7 @@ private void doTestIgnoreMalformed(Object value, String exceptionMessageContains "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", value).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); MapperParsingException e = expectThrows(MapperParsingException.class, runnable); @@ -257,7 +257,7 @@ private void doTestIgnoreMalformed(Object value, String exceptionMessageContains "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", value).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -272,7 +272,7 @@ public void testNullValue() throws IOException { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().nullField("field").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); assertArrayEquals(new IndexableField[0], doc.rootDoc().getFields("field")); @@ -285,7 +285,7 @@ public void testNullValue() throws IOException { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().nullField("field").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = doc.rootDoc().getFields("field"); diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldMapperTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldMapperTests.java index 551bd38b65f59..b5f687ce34d4b 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldMapperTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldMapperTests.java @@ -51,8 +51,8 @@ import org.apache.lucene.search.SynonymQuery; import org.apache.lucene.search.TermQuery; import org.opensearch.common.lucene.search.MultiPhrasePrefixQuery; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.IndexSettings; import org.opensearch.index.analysis.AnalyzerScope; @@ -600,7 +600,7 @@ public void testAnalyzerSerialization() throws IOException { b.field("type", "search_as_you_type"); b.field("analyzer", "simple"); })); - String serialized = Strings.toString(XContentType.JSON, ms.documentMapper()); + String serialized = Strings.toString(MediaTypeRegistry.JSON, ms.documentMapper()); assertEquals( serialized, "{\"_doc\":{\"properties\":{\"field\":" @@ -608,7 +608,7 @@ public void testAnalyzerSerialization() throws IOException { ); merge(ms, mapping(b -> {})); - assertEquals(serialized, Strings.toString(XContentType.JSON, ms.documentMapper())); + assertEquals(serialized, Strings.toString(MediaTypeRegistry.JSON, ms.documentMapper())); } private void documentParsingTestCase(Collection values) throws IOException { diff --git a/modules/parent-join/src/test/java/org/opensearch/join/mapper/ParentJoinFieldMapperTests.java b/modules/parent-join/src/test/java/org/opensearch/join/mapper/ParentJoinFieldMapperTests.java index 213ba43ee34cd..ed6a8259d6e90 100644 --- a/modules/parent-join/src/test/java/org/opensearch/join/mapper/ParentJoinFieldMapperTests.java +++ b/modules/parent-join/src/test/java/org/opensearch/join/mapper/ParentJoinFieldMapperTests.java @@ -34,8 +34,8 @@ import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.DocumentMapper; import org.opensearch.index.mapper.MapperException; @@ -78,7 +78,12 @@ public void testSingleLevel() throws Exception { // Doc without join ParsedDocument doc = docMapper.parse( - new SourceToParse("test", "0", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()), XContentType.JSON) + new SourceToParse( + "test", + "0", + BytesReference.bytes(MediaTypeRegistry.JSON.contentBuilder().startObject().endObject()), + MediaTypeRegistry.JSON + ) ); assertNull(doc.rootDoc().getBinaryValue("join_field")); @@ -88,7 +93,7 @@ public void testSingleLevel() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("join_field", "parent").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); assertEquals("1", doc.rootDoc().getBinaryValue("join_field#parent").utf8ToString()); @@ -108,7 +113,7 @@ public void testSingleLevel() throws Exception { .endObject() .endObject() ), - XContentType.JSON, + MediaTypeRegistry.JSON, "1" ) ); @@ -123,7 +128,7 @@ public void testSingleLevel() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("join_field", "unknown").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ); @@ -159,7 +164,7 @@ public void testParentIdSpecifiedAsNumber() throws Exception { .endObject() .endObject() ), - XContentType.JSON, + MediaTypeRegistry.JSON, "1" ) ); @@ -178,7 +183,7 @@ public void testParentIdSpecifiedAsNumber() throws Exception { .endObject() .endObject() ), - XContentType.JSON, + MediaTypeRegistry.JSON, "1" ) ); @@ -207,7 +212,12 @@ public void testMultipleLevels() throws Exception { // Doc without join ParsedDocument doc = docMapper.parse( - new SourceToParse("test", "0", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()), XContentType.JSON) + new SourceToParse( + "test", + "0", + BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()), + MediaTypeRegistry.JSON + ) ); assertNull(doc.rootDoc().getBinaryValue("join_field")); @@ -217,7 +227,7 @@ public void testMultipleLevels() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("join_field", "parent").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); assertEquals("1", doc.rootDoc().getBinaryValue("join_field#parent").utf8ToString()); @@ -237,7 +247,7 @@ public void testMultipleLevels() throws Exception { .endObject() .endObject() ), - XContentType.JSON, + MediaTypeRegistry.JSON, "1" ) ); @@ -253,7 +263,7 @@ public void testMultipleLevels() throws Exception { "test", "2", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("join_field", "child").endObject()), - XContentType.JSON, + MediaTypeRegistry.JSON, "1" ) ) @@ -276,7 +286,7 @@ public void testMultipleLevels() throws Exception { .endObject() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ); @@ -296,7 +306,7 @@ public void testMultipleLevels() throws Exception { .endObject() .endObject() ), - XContentType.JSON, + MediaTypeRegistry.JSON, "1" ) ); @@ -311,7 +321,7 @@ public void testMultipleLevels() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("join_field", "unknown").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ); diff --git a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java index 278a8c1cc0ebc..8c091bd8de439 100644 --- a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java @@ -41,6 +41,7 @@ import org.opensearch.common.geo.GeoPoint; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.DistanceUnit; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; @@ -125,14 +126,16 @@ public void testPercolatorQuery() throws Exception { BytesReference source = BytesReference.bytes(jsonBuilder().startObject().endObject()); logger.info("percolating empty doc"); - SearchResponse response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get(); + SearchResponse response = client().prepareSearch() + .setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)) + .get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("1")); source = BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").endObject()); logger.info("percolating doc with 1 field"); response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)) + .setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)) .addSort("id", SortOrder.ASC) .get(); assertHitCount(response, 2); @@ -144,7 +147,7 @@ public void testPercolatorQuery() throws Exception { source = BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").field("field2", "value").endObject()); logger.info("percolating doc with 2 fields"); response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)) + .setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)) .addSort("id", SortOrder.ASC) .get(); assertHitCount(response, 3); @@ -164,7 +167,7 @@ public void testPercolatorQuery() throws Exception { BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").endObject()), BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").field("field2", "value").endObject()) ), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .addSort("id", SortOrder.ASC) @@ -267,44 +270,46 @@ public void testPercolatorRangeQueries() throws Exception { // Test long range: BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field1", 12).endObject()); - SearchResponse response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get(); + SearchResponse response = client().prepareSearch() + .setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)) + .get(); logger.info("response={}", response); assertHitCount(response, 2); assertThat(response.getHits().getAt(0).getId(), equalTo("3")); assertThat(response.getHits().getAt(1).getId(), equalTo("1")); source = BytesReference.bytes(jsonBuilder().startObject().field("field1", 11).endObject()); - response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get(); + response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)).get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("1")); // Test double range: source = BytesReference.bytes(jsonBuilder().startObject().field("field2", 12).endObject()); - response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get(); + response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)).get(); assertHitCount(response, 2); assertThat(response.getHits().getAt(0).getId(), equalTo("6")); assertThat(response.getHits().getAt(1).getId(), equalTo("4")); source = BytesReference.bytes(jsonBuilder().startObject().field("field2", 11).endObject()); - response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get(); + response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)).get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("4")); // Test IP range: source = BytesReference.bytes(jsonBuilder().startObject().field("field3", "192.168.1.5").endObject()); - response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get(); + response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)).get(); assertHitCount(response, 2); assertThat(response.getHits().getAt(0).getId(), equalTo("9")); assertThat(response.getHits().getAt(1).getId(), equalTo("7")); source = BytesReference.bytes(jsonBuilder().startObject().field("field3", "192.168.1.4").endObject()); - response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get(); + response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)).get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("7")); // Test date range: source = BytesReference.bytes(jsonBuilder().startObject().field("field4", "2016-05-15").endObject()); - response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get(); + response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)).get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("10")); } @@ -355,7 +360,7 @@ public void testPercolatorGeoQueries() throws Exception { jsonBuilder().startObject().startObject("field1").field("lat", 52.20).field("lon", 4.51).endObject().endObject() ); SearchResponse response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)) + .setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)) .addSort("id", SortOrder.ASC) .get(); assertHitCount(response, 3); @@ -390,9 +395,9 @@ public void testPercolatorQueryExistingDocument() throws Exception { ) .get(); - client().prepareIndex("test").setId("4").setSource("{\"id\": \"4\"}", XContentType.JSON).get(); - client().prepareIndex("test").setId("5").setSource(XContentType.JSON, "id", "5", "field1", "value").get(); - client().prepareIndex("test").setId("6").setSource(XContentType.JSON, "id", "6", "field1", "value", "field2", "value").get(); + client().prepareIndex("test").setId("4").setSource("{\"id\": \"4\"}", MediaTypeRegistry.JSON).get(); + client().prepareIndex("test").setId("5").setSource(MediaTypeRegistry.JSON, "id", "5", "field1", "value").get(); + client().prepareIndex("test").setId("6").setSource(MediaTypeRegistry.JSON, "id", "6", "field1", "value", "field2", "value").get(); client().admin().indices().prepareRefresh().get(); logger.info("percolating empty doc"); @@ -432,7 +437,7 @@ public void testPercolatorQueryExistingDocumentSourceDisabled() throws Exception client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject()).get(); - client().prepareIndex("test").setId("2").setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId("2").setSource("{}", MediaTypeRegistry.JSON).get(); client().admin().indices().prepareRefresh().get(); logger.info("percolating empty doc with source disabled"); @@ -528,7 +533,7 @@ public void testPercolatorSpecificQueries() throws Exception { .endObject() ); SearchResponse response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)) + .setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)) .addSort("id", SortOrder.ASC) .get(); assertHitCount(response, 4); @@ -586,7 +591,7 @@ public void testPercolatorQueryWithHighlighting() throws Exception { jsonBuilder().startObject().field("field1", "The quick brown fox jumps over the lazy dog").endObject() ); SearchResponse searchResponse = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", document, XContentType.JSON)) + .setQuery(new PercolateQueryBuilder("query", document, MediaTypeRegistry.JSON)) .highlighter(new HighlightBuilder().field("field1")) .addSort("id", SortOrder.ASC) .get(); @@ -619,8 +624,8 @@ public void testPercolatorQueryWithHighlighting() throws Exception { BytesReference document2 = BytesReference.bytes(jsonBuilder().startObject().field("field1", "over the lazy dog").endObject()); searchResponse = client().prepareSearch() .setQuery( - boolQuery().should(new PercolateQueryBuilder("query", document1, XContentType.JSON).setName("query1")) - .should(new PercolateQueryBuilder("query", document2, XContentType.JSON).setName("query2")) + boolQuery().should(new PercolateQueryBuilder("query", document1, MediaTypeRegistry.JSON).setName("query1")) + .should(new PercolateQueryBuilder("query", document2, MediaTypeRegistry.JSON).setName("query2")) ) .highlighter(new HighlightBuilder().field("field1")) .addSort("id", SortOrder.ASC) @@ -659,7 +664,7 @@ public void testPercolatorQueryWithHighlighting() throws Exception { BytesReference.bytes(jsonBuilder().startObject().field("field1", "jumps").endObject()), BytesReference.bytes(jsonBuilder().startObject().field("field1", "brown fox").endObject()) ), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .highlighter(new HighlightBuilder().field("field1")) @@ -712,7 +717,7 @@ public void testPercolatorQueryWithHighlighting() throws Exception { BytesReference.bytes(jsonBuilder().startObject().field("field1", "dog").endObject()), BytesReference.bytes(jsonBuilder().startObject().field("field1", "fox").endObject()) ), - XContentType.JSON + MediaTypeRegistry.JSON ).setName("query1") ) .should( @@ -722,7 +727,7 @@ public void testPercolatorQueryWithHighlighting() throws Exception { BytesReference.bytes(jsonBuilder().startObject().field("field1", "jumps").endObject()), BytesReference.bytes(jsonBuilder().startObject().field("field1", "brown fox").endObject()) ), - XContentType.JSON + MediaTypeRegistry.JSON ).setName("query2") ) ) @@ -811,7 +816,7 @@ public void testTakePositionOffsetGapIntoAccount() throws Exception { client().admin().indices().prepareRefresh().get(); SearchResponse response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", new BytesArray("{\"field\" : [\"brown\", \"fox\"]}"), XContentType.JSON)) + .setQuery(new PercolateQueryBuilder("query", new BytesArray("{\"field\" : [\"brown\", \"fox\"]}"), MediaTypeRegistry.JSON)) .get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("2")); @@ -899,7 +904,7 @@ public void testWithMultiplePercolatorFields() throws Exception { BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field", "value").endObject()); SearchResponse response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder(queryFieldName, source, XContentType.JSON)) + .setQuery(new PercolateQueryBuilder(queryFieldName, source, MediaTypeRegistry.JSON)) .setIndices("test1") .get(); assertHitCount(response, 1); @@ -907,7 +912,7 @@ public void testWithMultiplePercolatorFields() throws Exception { assertThat(response.getHits().getAt(0).getIndex(), equalTo("test1")); response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("object_field." + queryFieldName, source, XContentType.JSON)) + .setQuery(new PercolateQueryBuilder("object_field." + queryFieldName, source, MediaTypeRegistry.JSON)) .setIndices("test2") .get(); assertHitCount(response, 1); @@ -1012,7 +1017,7 @@ public void testPercolateQueryWithNestedDocuments() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .addSort("id", SortOrder.ASC) @@ -1039,7 +1044,7 @@ public void testPercolateQueryWithNestedDocuments() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .addSort("id", SortOrder.ASC) @@ -1052,7 +1057,7 @@ public void testPercolateQueryWithNestedDocuments() throws Exception { new PercolateQueryBuilder( "query", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("companyname", "notstark").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .addSort("id", SortOrder.ASC) @@ -1105,7 +1110,7 @@ public void testPercolateQueryWithNestedDocuments() throws Exception { .endObject() ) ), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .addSort("id", SortOrder.ASC) @@ -1158,7 +1163,7 @@ public void testPercolatorQueryViaMultiSearch() throws Exception { new PercolateQueryBuilder( "query", BytesReference.bytes(jsonBuilder().startObject().field("field1", "b").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ) @@ -1178,7 +1183,7 @@ public void testPercolatorQueryViaMultiSearch() throws Exception { new PercolateQueryBuilder( "query", BytesReference.bytes(jsonBuilder().startObject().field("field1", "b c").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ) @@ -1188,7 +1193,7 @@ public void testPercolatorQueryViaMultiSearch() throws Exception { new PercolateQueryBuilder( "query", BytesReference.bytes(jsonBuilder().startObject().field("field1", "d").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ) @@ -1248,7 +1253,7 @@ public void testDisallowExpensiveQueries() throws IOException { // Execute with search.allow_expensive_queries = null => default value = false => success BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").endObject()); SearchResponse response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)) + .setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)) .get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("1")); @@ -1261,7 +1266,7 @@ public void testDisallowExpensiveQueries() throws IOException { OpenSearchException e = expectThrows( OpenSearchException.class, - () -> client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get() + () -> client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)).get() ); assertEquals( "[percolate] queries cannot be executed when 'search.allow_expensive_queries' is set to false.", @@ -1273,7 +1278,7 @@ public void testDisallowExpensiveQueries() throws IOException { updateSettingsRequest.persistentSettings(Settings.builder().put("search.allow_expensive_queries", true)); assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); - response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, XContentType.JSON)).get(); + response = client().prepareSearch().setQuery(new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON)).get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("1")); assertThat(response.getHits().getAt(0).getFields().get("_percolator_document_slot").getValue(), equalTo(0)); @@ -1307,7 +1312,7 @@ public void testWrappedWithConstantScore() throws Exception { new PercolateQueryBuilder( "q", BytesReference.bytes(jsonBuilder().startObject().field("d", "2020-02-01T15:00:00.000+11:00").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .get(); @@ -1318,7 +1323,7 @@ public void testWrappedWithConstantScore() throws Exception { new PercolateQueryBuilder( "q", BytesReference.bytes(jsonBuilder().startObject().field("d", "2020-02-01T15:00:00.000+11:00").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .addSort("_doc", SortOrder.ASC) @@ -1331,7 +1336,7 @@ public void testWrappedWithConstantScore() throws Exception { new PercolateQueryBuilder( "q", BytesReference.bytes(jsonBuilder().startObject().field("d", "2020-02-01T15:00:00.000+11:00").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ) diff --git a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java index 9f49843c37ea5..3882cbbfd4b35 100644 --- a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java +++ b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java @@ -139,10 +139,10 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder pqb.toQuery(createShardContext())); assertThat(e.getMessage(), equalTo("query builder must be rewritten first")); QueryBuilder rewrite = rewriteAndFetch(pqb, createShardContext()); - PercolateQueryBuilder geoShapeQueryBuilder = new PercolateQueryBuilder(pqb.getField(), documentSource, XContentType.JSON); + PercolateQueryBuilder geoShapeQueryBuilder = new PercolateQueryBuilder(pqb.getField(), documentSource, MediaTypeRegistry.JSON); assertEquals(geoShapeQueryBuilder, rewrite); } @@ -243,13 +243,13 @@ protected Set getObjectsHoldingArbitraryContent() { public void testRequiredParameters() { IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> { - new PercolateQueryBuilder(null, new BytesArray("{}"), XContentType.JSON); + new PercolateQueryBuilder(null, new BytesArray("{}"), MediaTypeRegistry.JSON); }); assertThat(e.getMessage(), equalTo("[field] is a required argument")); e = expectThrows( IllegalArgumentException.class, - () -> new PercolateQueryBuilder("_field", (List) null, XContentType.JSON) + () -> new PercolateQueryBuilder("_field", (List) null, MediaTypeRegistry.JSON) ); assertThat(e.getMessage(), equalTo("[document] is a required argument")); diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java index 677d169162c74..f8f9ab1fe8aa5 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java @@ -35,7 +35,7 @@ import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.compress.CompressedXContent; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryShardContext; @@ -57,7 +57,11 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws public void testDetectsNestedDocuments() throws IOException { QueryShardContext shardContext = createShardContext(); - PercolateQueryBuilder builder = new PercolateQueryBuilder(queryField, new BytesArray("{ \"foo\": \"bar\" }"), XContentType.JSON); + PercolateQueryBuilder builder = new PercolateQueryBuilder( + queryField, + new BytesArray("{ \"foo\": \"bar\" }"), + MediaTypeRegistry.JSON + ); QueryBuilder rewrittenBuilder = rewriteAndFetch(builder, shardContext); PercolateQuery query = (PercolateQuery) rewrittenBuilder.toQuery(shardContext); assertFalse(query.excludesNestedDocs()); @@ -65,7 +69,7 @@ public void testDetectsNestedDocuments() throws IOException { builder = new PercolateQueryBuilder( queryField, new BytesArray("{ \"foo\": \"bar\", \"some_nested_object\": [ { \"baz\": 42 } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ); rewrittenBuilder = rewriteAndFetch(builder, shardContext); query = (PercolateQuery) rewrittenBuilder.toQuery(shardContext); diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorFieldMapperTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorFieldMapperTests.java index c5e2a1f68de9c..b91d284770d52 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorFieldMapperTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorFieldMapperTests.java @@ -67,9 +67,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.network.InetAddresses; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.IndexService; import org.opensearch.index.IndexSettings; import org.opensearch.index.mapper.DocumentMapper; @@ -557,7 +557,7 @@ public void testPercolatorFieldMapper() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, queryBuilder).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -577,7 +577,7 @@ public void testPercolatorFieldMapper() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, queryBuilder).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); assertThat(doc.rootDoc().getFields(fieldType.extractionResultField.name()).length, equalTo(1)); @@ -594,7 +594,7 @@ public void testPercolatorFieldMapper() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, queryBuilder).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); assertThat(doc.rootDoc().getFields(fieldType.extractionResultField.name()).length, equalTo(1)); @@ -622,7 +622,7 @@ public void testStoringQueries() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, query).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); BytesRef qbSource = doc.rootDoc().getFields(fieldType.queryBuilderField.name())[0].binaryValue(); @@ -640,7 +640,7 @@ public void testQueryWithRewrite() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, queryBuilder).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); BytesRef qbSource = doc.rootDoc().getFields(fieldType.queryBuilderField.name())[0].binaryValue(); @@ -666,7 +666,7 @@ public void testPercolatorFieldMapperUnMappedField() throws Exception { BytesReference.bytes( XContentFactory.jsonBuilder().startObject().field(fieldName, termQuery("unmapped_field", "value")).endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); }); @@ -682,7 +682,7 @@ public void testPercolatorFieldMapper_noQuery() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); assertThat(doc.rootDoc().getFields(fieldType.queryBuilderField.name()).length, equalTo(0)); @@ -694,7 +694,7 @@ public void testPercolatorFieldMapper_noQuery() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().nullField(fieldName).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); } catch (MapperParsingException e) { @@ -756,7 +756,7 @@ public void testMultiplePercolatorFields() throws Exception { BytesReference.bytes( jsonBuilder().startObject().field("query_field1", queryBuilder).field("query_field2", queryBuilder).endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); assertThat(doc.rootDoc().getFields().size(), equalTo(16)); // also includes all other meta fields @@ -797,7 +797,7 @@ public void testNestedPercolatorField() throws Exception { BytesReference.bytes( jsonBuilder().startObject().startObject("object_field").field("query_field", queryBuilder).endObject().endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); assertThat(doc.rootDoc().getFields().size(), equalTo(12)); // also includes all other meta fields @@ -822,7 +822,7 @@ public void testNestedPercolatorField() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); assertThat(doc.rootDoc().getFields().size(), equalTo(12)); // also includes all other meta fields @@ -847,7 +847,7 @@ public void testNestedPercolatorField() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); }); @@ -947,7 +947,7 @@ public void testImplicitlySetDefaultScriptLang() throws Exception { .rawField(fieldName, new BytesArray(query.toString()).streamInput(), query.contentType()) .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); BytesRef querySource = doc.rootDoc().getFields(fieldType.queryBuilderField.name())[0].binaryValue(); @@ -994,7 +994,7 @@ public void testImplicitlySetDefaultScriptLang() throws Exception { .rawField(fieldName, new BytesArray(query.toString()).streamInput(), query.contentType()) .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); querySource = doc.rootDoc().getFields(fieldType.queryBuilderField.name())[0].binaryValue(); @@ -1083,7 +1083,7 @@ public void testDuplicatedClauses() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, qb).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -1108,7 +1108,7 @@ public void testDuplicatedClauses() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, qb).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -1136,7 +1136,7 @@ public void testDuplicatedClauses() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field(fieldName, qb).endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java index 7f0437a8a29aa..85cf6d86e29c7 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java @@ -37,9 +37,9 @@ import org.opensearch.action.support.WriteRequest; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.IndexService; import org.opensearch.index.cache.bitset.BitsetFilterCache; import org.opensearch.index.engine.Engine; @@ -115,7 +115,7 @@ public void testPercolateScriptQuery() throws IOException { new PercolateQueryBuilder( "query", BytesReference.bytes(jsonBuilder().startObject().field("field1", "b").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .get(); @@ -188,7 +188,7 @@ public void testPercolateQueryWithNestedDocuments_doNotLeakBitsetCacheEntries() .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .addSort("_doc", SortOrder.ASC) @@ -269,7 +269,7 @@ public void testPercolateQueryWithNestedDocuments_doLeakFieldDataCacheEntries() doc.endObject(); for (int i = 0; i < 32; i++) { SearchResponse response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", BytesReference.bytes(doc), XContentType.JSON)) + .setQuery(new PercolateQueryBuilder("query", BytesReference.bytes(doc), MediaTypeRegistry.JSON)) .addSort("_doc", SortOrder.ASC) .get(); assertHitCount(response, 1); @@ -293,7 +293,7 @@ public void testMapUnmappedFieldAsText() throws IOException { new PercolateQueryBuilder( "query", BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ) .get(); @@ -348,13 +348,13 @@ public void testRangeQueriesWithNow() throws Exception { BytesReference source = BytesReference.bytes( jsonBuilder().startObject().field("field1", "value").field("field2", currentTime[0]).endObject() ); - QueryBuilder queryBuilder = new PercolateQueryBuilder("query", source, XContentType.JSON); + QueryBuilder queryBuilder = new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON); Query query = queryBuilder.toQuery(queryShardContext); assertThat(searcher.count(query), equalTo(3)); currentTime[0] = currentTime[0] + 10800000; // + 3 hours source = BytesReference.bytes(jsonBuilder().startObject().field("field1", "value").field("field2", currentTime[0]).endObject()); - queryBuilder = new PercolateQueryBuilder("query", source, XContentType.JSON); + queryBuilder = new PercolateQueryBuilder("query", source, MediaTypeRegistry.JSON); query = queryBuilder.toQuery(queryShardContext); assertThat(searcher.count(query), equalTo(3)); } diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalResponse.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalResponse.java index 68c61183a4486..496320dabe650 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalResponse.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalResponse.java @@ -40,11 +40,11 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.XContentParserUtils; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Collections; @@ -106,7 +106,7 @@ public Map getFailures() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalSpec.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalSpec.java index 44eeceb117794..229782b5fb5d1 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalSpec.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalSpec.java @@ -39,11 +39,11 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.XContentParserUtils; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.script.Script; import java.io.IOException; @@ -250,7 +250,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RatedDocument.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RatedDocument.java index e91b8671d0804..bb11a594baf77 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RatedDocument.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RatedDocument.java @@ -36,9 +36,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -129,7 +129,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RatedRequest.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RatedRequest.java index 78c2dbd33182f..83b7d9bb82d8e 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RatedRequest.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RatedRequest.java @@ -37,9 +37,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -341,7 +341,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java index 688a0787c95b8..cc34be0485150 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java @@ -44,9 +44,9 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.script.Script; import org.opensearch.script.ScriptService; import org.opensearch.script.TemplateScript; @@ -126,7 +126,7 @@ protected void doExecute(Task task, RankEvalRequest request, ActionListener buildRequest(Hit doc } }; ScrollableHitSource.BasicHit hit = new ScrollableHitSource.BasicHit("index", "id", 0); - hit.setSource(new BytesArray("{}"), XContentType.JSON); + hit.setSource(new BytesArray("{}"), MediaTypeRegistry.JSON); ScrollableHitSource.Response response = new ScrollableHitSource.Response(false, emptyList(), 1, singletonList(hit), null); simulateScrollResponse(action, System.nanoTime(), 0, response); ExecutionException e = expectThrows(ExecutionException.class, () -> listener.get()); diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/CancelTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/CancelTests.java index 26fcfd226371f..6dd168c07a8ea 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/CancelTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/CancelTests.java @@ -41,7 +41,7 @@ import org.opensearch.action.ingest.DeletePipelineRequest; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexModule; import org.opensearch.index.engine.Engine; import org.opensearch.index.engine.Engine.Operation.Origin; @@ -263,7 +263,7 @@ public void testUpdateByQueryCancel() throws Exception { + " } ]\n" + "}" ); - assertAcked(client().admin().cluster().preparePutPipeline("set-processed", pipeline, XContentType.JSON).get()); + assertAcked(client().admin().cluster().preparePutPipeline("set-processed", pipeline, MediaTypeRegistry.JSON).get()); testCancel(UpdateByQueryAction.NAME, updateByQuery().setPipeline("set-processed").source(INDEX), (response, total, modified) -> { assertThat(response, matcher().updated(modified).reasonCancelled(equalTo("by user request"))); @@ -307,7 +307,7 @@ public void testUpdateByQueryCancelWithWorkers() throws Exception { + " } ]\n" + "}" ); - assertAcked(client().admin().cluster().preparePutPipeline("set-processed", pipeline, XContentType.JSON).get()); + assertAcked(client().admin().cluster().preparePutPipeline("set-processed", pipeline, MediaTypeRegistry.JSON).get()); testCancel( UpdateByQueryAction.NAME, diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/RestReindexActionTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/RestReindexActionTests.java index 651ccd47df7bd..1269cbe6b5438 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/RestReindexActionTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/RestReindexActionTests.java @@ -35,8 +35,8 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.test.rest.FakeRestRequest; import org.opensearch.test.rest.RestActionTestCase; @@ -88,14 +88,14 @@ public void testPipelineQueryParameterIsError() throws IOException { public void testSetScrollTimeout() throws IOException { { FakeRestRequest.Builder requestBuilder = new FakeRestRequest.Builder(xContentRegistry()); - requestBuilder.withContent(new BytesArray("{}"), XContentType.JSON); + requestBuilder.withContent(new BytesArray("{}"), MediaTypeRegistry.JSON); ReindexRequest request = action.buildRequest(requestBuilder.build(), new NamedWriteableRegistry(Collections.emptyList())); assertEquals(AbstractBulkByScrollRequest.DEFAULT_SCROLL_TIMEOUT, request.getScrollTime()); } { FakeRestRequest.Builder requestBuilder = new FakeRestRequest.Builder(xContentRegistry()); requestBuilder.withParams(singletonMap("scroll", "10m")); - requestBuilder.withContent(new BytesArray("{}"), XContentType.JSON); + requestBuilder.withContent(new BytesArray("{}"), MediaTypeRegistry.JSON); ReindexRequest request = action.buildRequest(requestBuilder.build(), new NamedWriteableRegistry(Collections.emptyList())); assertEquals("10m", request.getScrollTime().toString()); } diff --git a/modules/search-pipeline-common/src/internalClusterTest/java/org/opensearch/search/pipeline/common/SearchPipelineCommonIT.java b/modules/search-pipeline-common/src/internalClusterTest/java/org/opensearch/search/pipeline/common/SearchPipelineCommonIT.java index faa0859e8e33f..c7b891080b321 100644 --- a/modules/search-pipeline-common/src/internalClusterTest/java/org/opensearch/search/pipeline/common/SearchPipelineCommonIT.java +++ b/modules/search-pipeline-common/src/internalClusterTest/java/org/opensearch/search/pipeline/common/SearchPipelineCommonIT.java @@ -19,7 +19,7 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.query.MatchAllQueryBuilder; import org.opensearch.plugins.Plugin; import org.opensearch.core.rest.RestStatus; @@ -58,7 +58,7 @@ public void testFilterQuery() { + "]" + "}" ), - XContentType.JSON + MediaTypeRegistry.JSON ); AcknowledgedResponse ackRsp = client().admin().cluster().putSearchPipeline(putSearchPipelineRequest).actionGet(); assertTrue(ackRsp.isAcknowledged()); diff --git a/modules/search-pipeline-common/src/main/java/org/opensearch/search/pipeline/common/FilterQueryRequestProcessor.java b/modules/search-pipeline-common/src/main/java/org/opensearch/search/pipeline/common/FilterQueryRequestProcessor.java index eab8bc95bd668..6ec3da02854cb 100644 --- a/modules/search-pipeline-common/src/main/java/org/opensearch/search/pipeline/common/FilterQueryRequestProcessor.java +++ b/modules/search-pipeline-common/src/main/java/org/opensearch/search/pipeline/common/FilterQueryRequestProcessor.java @@ -11,8 +11,8 @@ import org.opensearch.action.search.SearchRequest; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.xcontent.LoggingDeprecationHandler; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -114,7 +114,7 @@ public FilterQueryRequestProcessor create( try ( XContentBuilder builder = XContentBuilder.builder(JsonXContent.jsonXContent).map(query); InputStream stream = BytesReference.bytes(builder).streamInput(); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(namedXContentRegistry, LoggingDeprecationHandler.INSTANCE, stream) ) { return new FilterQueryRequestProcessor(tag, description, ignoreFailure, parseInnerQueryBuilder(parser)); diff --git a/modules/search-pipeline-common/src/main/java/org/opensearch/search/pipeline/common/ScriptRequestProcessor.java b/modules/search-pipeline-common/src/main/java/org/opensearch/search/pipeline/common/ScriptRequestProcessor.java index 3849d2f905490..e39f0b15aa538 100644 --- a/modules/search-pipeline-common/src/main/java/org/opensearch/search/pipeline/common/ScriptRequestProcessor.java +++ b/modules/search-pipeline-common/src/main/java/org/opensearch/search/pipeline/common/ScriptRequestProcessor.java @@ -13,10 +13,10 @@ import org.opensearch.common.Nullable; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.script.Script; @@ -163,7 +163,7 @@ public ScriptRequestProcessor create( try ( XContentBuilder builder = XContentBuilder.builder(JsonXContent.jsonXContent).map(scriptConfig); InputStream stream = BytesReference.bytes(builder).streamInput(); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, stream) ) { Script script = Script.parse(parser); diff --git a/plugins/analysis-icu/src/internalClusterTest/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperIT.java b/plugins/analysis-icu/src/internalClusterTest/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperIT.java index 4f596034bfece..ea3c7d2e47504 100644 --- a/plugins/analysis-icu/src/internalClusterTest/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperIT.java +++ b/plugins/analysis-icu/src/internalClusterTest/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperIT.java @@ -42,8 +42,8 @@ import com.ibm.icu.util.ULocale; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.query.QueryBuilders; import org.opensearch.plugin.analysis.icu.AnalysisICUPlugin; import org.opensearch.plugins.Plugin; @@ -91,8 +91,12 @@ public void testBasicUsage() throws Exception { // both values should collate to same value indexRandom( true, - client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON), - client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON) + client().prepareIndex(index) + .setId("1") + .setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index) + .setId("2") + .setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", MediaTypeRegistry.JSON) ); // searching for either of the terms should return both results since they collate to the same value @@ -134,8 +138,10 @@ public void testMultipleValues() throws Exception { true, client().prepareIndex(index) .setId("1") - .setSource("{\"id\":\"1\", \"collate\":[\"" + equivalent[0] + "\", \"" + equivalent[1] + "\"]}", XContentType.JSON), - client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[2] + "\"}", XContentType.JSON) + .setSource("{\"id\":\"1\", \"collate\":[\"" + equivalent[0] + "\", \"" + equivalent[1] + "\"]}", MediaTypeRegistry.JSON), + client().prepareIndex(index) + .setId("2") + .setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[2] + "\"}", MediaTypeRegistry.JSON) ); // using sort mode = max, values B and C will be used for the sort @@ -195,8 +201,12 @@ public void testNormalization() throws Exception { indexRandom( true, - client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON), - client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON) + client().prepareIndex(index) + .setId("1") + .setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index) + .setId("2") + .setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", MediaTypeRegistry.JSON) ); // searching for either of the terms should return both results since they collate to the same value @@ -240,8 +250,12 @@ public void testSecondaryStrength() throws Exception { indexRandom( true, - client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON), - client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON) + client().prepareIndex(index) + .setId("1") + .setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index) + .setId("2") + .setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", MediaTypeRegistry.JSON) ); SearchRequest request = new SearchRequest().indices(index) @@ -285,8 +299,12 @@ public void testIgnorePunctuation() throws Exception { indexRandom( true, - client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON), - client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON) + client().prepareIndex(index) + .setId("1") + .setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index) + .setId("2") + .setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", MediaTypeRegistry.JSON) ); SearchRequest request = new SearchRequest().indices(index) @@ -330,9 +348,9 @@ public void testIgnoreWhitespace() throws Exception { indexRandom( true, - client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"foo bar\"}", XContentType.JSON), - client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"foobar\"}", XContentType.JSON), - client().prepareIndex(index).setId("3").setSource("{\"id\":\"3\",\"collate\":\"foo-bar\"}", XContentType.JSON) + client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"foo bar\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"foobar\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index).setId("3").setSource("{\"id\":\"3\",\"collate\":\"foo-bar\"}", MediaTypeRegistry.JSON) ); SearchRequest request = new SearchRequest().indices(index) @@ -372,8 +390,8 @@ public void testNumerics() throws Exception { indexRandom( true, - client().prepareIndex(index).setId("1").setSource("{\"collate\":\"foobar-10\"}", XContentType.JSON), - client().prepareIndex(index).setId("2").setSource("{\"collate\":\"foobar-9\"}", XContentType.JSON) + client().prepareIndex(index).setId("1").setSource("{\"collate\":\"foobar-10\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index).setId("2").setSource("{\"collate\":\"foobar-9\"}", MediaTypeRegistry.JSON) ); SearchRequest request = new SearchRequest().indices(index) @@ -411,10 +429,10 @@ public void testIgnoreAccentsButNotCase() throws Exception { indexRandom( true, - client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"résumé\"}", XContentType.JSON), - client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"Resume\"}", XContentType.JSON), - client().prepareIndex(index).setId("3").setSource("{\"id\":\"3\",\"collate\":\"resume\"}", XContentType.JSON), - client().prepareIndex(index).setId("4").setSource("{\"id\":\"4\",\"collate\":\"Résumé\"}", XContentType.JSON) + client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"résumé\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"Resume\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index).setId("3").setSource("{\"id\":\"3\",\"collate\":\"resume\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index).setId("4").setSource("{\"id\":\"4\",\"collate\":\"Résumé\"}", MediaTypeRegistry.JSON) ); SearchRequest request = new SearchRequest().indices(index) @@ -449,8 +467,8 @@ public void testUpperCaseFirst() throws Exception { indexRandom( true, - client().prepareIndex(index).setId("1").setSource("{\"collate\":\"resume\"}", XContentType.JSON), - client().prepareIndex(index).setId("2").setSource("{\"collate\":\"Resume\"}", XContentType.JSON) + client().prepareIndex(index).setId("1").setSource("{\"collate\":\"resume\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index).setId("2").setSource("{\"collate\":\"Resume\"}", MediaTypeRegistry.JSON) ); SearchRequest request = new SearchRequest().indices(index) @@ -497,8 +515,12 @@ public void testCustomRules() throws Exception { indexRandom( true, - client().prepareIndex(index).setId("1").setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", XContentType.JSON), - client().prepareIndex(index).setId("2").setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", XContentType.JSON) + client().prepareIndex(index) + .setId("1") + .setSource("{\"id\":\"1\",\"collate\":\"" + equivalent[0] + "\"}", MediaTypeRegistry.JSON), + client().prepareIndex(index) + .setId("2") + .setSource("{\"id\":\"2\",\"collate\":\"" + equivalent[1] + "\"}", MediaTypeRegistry.JSON) ); SearchRequest request = new SearchRequest().indices(index) diff --git a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/IndexUtils.java b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/IndexUtils.java index a240fa17d1d22..d40e986e4b0d1 100644 --- a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/IndexUtils.java +++ b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/IndexUtils.java @@ -15,7 +15,7 @@ import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.xcontent.LoggingDeprecationHandler; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; @@ -80,7 +80,7 @@ public static Boolean shouldUpdateIndex(IndexMetadata index, String mapping) thr * @throws IOException IOException */ public static Integer getSchemaVersion(String mapping) throws IOException { - XContentParser xcp = XContentType.JSON.xContent() + XContentParser xcp = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, mapping); while (!xcp.isClosed()) { @@ -129,7 +129,7 @@ public static void updateIndexMapping( ) throws IOException { if (clusterState.metadata().indices().containsKey(index)) { if (shouldUpdateIndex(clusterState.metadata().index(index), mapping)) { - PutMappingRequest putMappingRequest = new PutMappingRequest(index).source(mapping, XContentType.JSON); + PutMappingRequest putMappingRequest = new PutMappingRequest(index).source(mapping, MediaTypeRegistry.JSON); client.putMapping(putMappingRequest, actionListener); } else { actionListener.onResponse(new AcknowledgedResponse(true)); diff --git a/plugins/events-correlation-engine/src/test/java/org/opensearch/plugin/correlation/core/index/query/CorrelationQueryBuilderTests.java b/plugins/events-correlation-engine/src/test/java/org/opensearch/plugin/correlation/core/index/query/CorrelationQueryBuilderTests.java index 3489dfdcc4530..cc229acaad4d3 100644 --- a/plugins/events-correlation-engine/src/test/java/org/opensearch/plugin/correlation/core/index/query/CorrelationQueryBuilderTests.java +++ b/plugins/events-correlation-engine/src/test/java/org/opensearch/plugin/correlation/core/index/query/CorrelationQueryBuilderTests.java @@ -14,12 +14,12 @@ import org.opensearch.cluster.ClusterModule; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.NamedWriteableAwareStreamInput; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -114,7 +114,7 @@ public void testFromXContentFromString() throws IOException { XContentParser contentParser = createParser(JsonXContent.jsonXContent, correlationQuery); contentParser.nextToken(); CorrelationQueryBuilder actualBuilder = CorrelationQueryBuilder.parse(contentParser); - Assert.assertEquals(correlationQuery.replace("\n", "").replace(" ", ""), Strings.toString(XContentType.JSON, actualBuilder)); + Assert.assertEquals(correlationQuery.replace("\n", "").replace(" ", ""), Strings.toString(MediaTypeRegistry.JSON, actualBuilder)); } /** diff --git a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java index 2c307ef4cc015..51e0979324623 100644 --- a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java +++ b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java @@ -34,8 +34,8 @@ import org.opensearch.action.admin.indices.mapping.get.GetMappingsResponse; import org.opensearch.action.get.GetResponse; import org.opensearch.action.support.master.AcknowledgedResponse; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.plugin.mapper.MapperSizePlugin; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -123,7 +123,7 @@ private void assertSizeMappingEnabled(String index, boolean enabled) throws IOEx public void testBasic() throws Exception { assertAcked(prepareCreate("test").setMapping("_size", "enabled=true")); final String source = "{\"f\":10}"; - indexRandom(true, client().prepareIndex("test").setId("1").setSource(source, XContentType.JSON)); + indexRandom(true, client().prepareIndex("test").setId("1").setSource(source, MediaTypeRegistry.JSON)); GetResponse getResponse = client().prepareGet("test", "1").setStoredFields("_size").get(); assertNotNull(getResponse.getField("_size")); assertEquals(source.length(), (int) getResponse.getField("_size").getValue()); diff --git a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingTests.java b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingTests.java index 87b1624cbcd64..72df59e2097d5 100644 --- a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingTests.java +++ b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingTests.java @@ -38,7 +38,7 @@ import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.MapperService; import org.opensearch.index.mapper.DocumentMapper; @@ -65,7 +65,7 @@ public void testSizeEnabled() throws Exception { DocumentMapper docMapper = service.mapperService().documentMapper(); BytesReference source = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject()); - ParsedDocument doc = docMapper.parse(new SourceToParse("test", "1", source, XContentType.JSON)); + ParsedDocument doc = docMapper.parse(new SourceToParse("test", "1", source, MediaTypeRegistry.JSON)); boolean stored = false; boolean points = false; @@ -82,7 +82,7 @@ public void testSizeDisabled() throws Exception { DocumentMapper docMapper = service.mapperService().documentMapper(); BytesReference source = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject()); - ParsedDocument doc = docMapper.parse(new SourceToParse("test", "1", source, XContentType.JSON)); + ParsedDocument doc = docMapper.parse(new SourceToParse("test", "1", source, MediaTypeRegistry.JSON)); assertThat(doc.rootDoc().getField("_size"), nullValue()); } @@ -92,7 +92,7 @@ public void testSizeNotSet() throws Exception { DocumentMapper docMapper = service.mapperService().documentMapper(); BytesReference source = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject()); - ParsedDocument doc = docMapper.parse(new SourceToParse("test", "1", source, XContentType.JSON)); + ParsedDocument doc = docMapper.parse(new SourceToParse("test", "1", source, MediaTypeRegistry.JSON)); assertThat(doc.rootDoc().getField("_size"), nullValue()); } diff --git a/plugins/repository-gcs/src/test/java/org/opensearch/repositories/gcs/TestUtils.java b/plugins/repository-gcs/src/test/java/org/opensearch/repositories/gcs/TestUtils.java index bc5a542972e83..648955c079b3e 100644 --- a/plugins/repository-gcs/src/test/java/org/opensearch/repositories/gcs/TestUtils.java +++ b/plugins/repository-gcs/src/test/java/org/opensearch/repositories/gcs/TestUtils.java @@ -31,8 +31,8 @@ package org.opensearch.repositories.gcs; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import java.io.ByteArrayOutputStream; import java.security.KeyPairGenerator; @@ -54,7 +54,7 @@ static byte[] createServiceAccount(final Random random) { final String privateKey = Base64.getEncoder().encodeToString(keyPairGenerator.generateKeyPair().getPrivate().getEncoded()); final ByteArrayOutputStream out = new ByteArrayOutputStream(); - try (XContentBuilder builder = new XContentBuilder(XContentType.JSON.xContent(), out)) { + try (XContentBuilder builder = new XContentBuilder(MediaTypeRegistry.JSON.xContent(), out)) { builder.startObject(); { builder.field("type", "service_account"); diff --git a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java index 95bc7f8dc404e..cbd13357fedd9 100644 --- a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java @@ -46,6 +46,7 @@ import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.IndexSettings; import org.opensearch.test.NotEqualMessageBuilder; @@ -1365,7 +1366,7 @@ public void testResize() throws Exception { if (randomBoolean()) { settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true); } - shrinkRequest.setJsonEntity("{\"settings\":" + Strings.toString(XContentType.JSON, settings.build()) + "}"); + shrinkRequest.setJsonEntity("{\"settings\":" + Strings.toString(MediaTypeRegistry.JSON, settings.build()) + "}"); client().performRequest(shrinkRequest); ensureGreenLongWait(target); assertNumHits(target, numDocs + moreDocs, 1); @@ -1377,7 +1378,7 @@ public void testResize() throws Exception { settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true); } Request splitRequest = new Request("PUT", "/" + index + "/_split/" + target); - splitRequest.setJsonEntity("{\"settings\":" + Strings.toString(XContentType.JSON, settings.build()) + "}"); + splitRequest.setJsonEntity("{\"settings\":" + Strings.toString(MediaTypeRegistry.JSON, settings.build()) + "}"); client().performRequest(splitRequest); ensureGreenLongWait(target); assertNumHits(target, numDocs + moreDocs, 6); diff --git a/qa/multi-cluster-search/src/test/java/org/opensearch/search/CCSDuelIT.java b/qa/multi-cluster-search/src/test/java/org/opensearch/search/CCSDuelIT.java index 1f2409741a878..218254a8cdba4 100644 --- a/qa/multi-cluster-search/src/test/java/org/opensearch/search/CCSDuelIT.java +++ b/qa/multi-cluster-search/src/test/java/org/opensearch/search/CCSDuelIT.java @@ -54,11 +54,11 @@ import org.opensearch.client.indices.CreateIndexRequest; import org.opensearch.client.indices.CreateIndexResponse; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.index.query.InnerHitBuilder; import org.opensearch.index.query.MatchQueryBuilder; import org.opensearch.index.query.QueryBuilders; @@ -198,7 +198,7 @@ private static void indexDocuments(String idPrefix) throws IOException, Interrup createIndexRequest.mapping("{\"properties\":{" + "\"id\":{\"type\":\"keyword\"}," + "\"suggest\":{\"type\":\"completion\"}," + - "\"join\":{\"type\":\"join\", \"relations\": {\"question\":\"answer\"}}}}", XContentType.JSON); + "\"join\":{\"type\":\"join\", \"relations\": {\"question\":\"answer\"}}}}", MediaTypeRegistry.JSON); CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(createIndexRequest, RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); @@ -255,7 +255,7 @@ private static IndexRequest buildIndexRequest(String id, String type, String que if (questionId != null) { joinField.put("parent", questionId); } - indexRequest.source(XContentType.JSON, + indexRequest.source(MediaTypeRegistry.JSON, "id", id, "type", type, "votes", randomIntBetween(0, 30), @@ -726,7 +726,7 @@ public void testCompletionSuggester() throws Exception { sourceBuilder.suggest(suggestBuilder); duelSearch(searchRequest, response -> { assertMultiClusterSearchResponse(response); - assertEquals(Strings.toString(XContentType.JSON, response, true, true), 3, response.getSuggest().size()); + assertEquals(Strings.toString(MediaTypeRegistry.JSON, response, true, true), 3, response.getSuggest().size()); assertThat(response.getSuggest().getSuggestion("python").getEntries().size(), greaterThan(0)); assertThat(response.getSuggest().getSuggestion("java").getEntries().size(), greaterThan(0)); assertThat(response.getSuggest().getSuggestion("ruby").getEntries().size(), greaterThan(0)); @@ -827,8 +827,8 @@ private static void assertAggs(SearchResponse response) { @SuppressWarnings("unchecked") private static Map responseToMap(SearchResponse response) throws IOException { - BytesReference bytesReference = XContentHelper.toXContent(response, XContentType.JSON, false); - Map responseMap = XContentHelper.convertToMap(bytesReference, false, XContentType.JSON).v2(); + BytesReference bytesReference = XContentHelper.toXContent(response, MediaTypeRegistry.JSON, false); + Map responseMap = org.opensearch.common.xcontent.XContentHelper.convertToMap(bytesReference, false, MediaTypeRegistry.JSON).v2(); assertNotNull(responseMap.put("took", -1)); responseMap.remove("num_reduce_phases"); Map profile = (Map)responseMap.get("profile"); diff --git a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java index 6d143d08452e9..6c7cea5e3af93 100644 --- a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java @@ -45,6 +45,7 @@ import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.mapper.MapperService; import org.opensearch.core.rest.RestStatus; @@ -733,7 +734,7 @@ public void testSoftDeletesDisabledWarning() throws Exception { settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), softDeletesEnabled); } Request request = new Request("PUT", "/" + indexName); - request.setJsonEntity("{\"settings\": " + Strings.toString(XContentType.JSON, settings.build()) + "}"); + request.setJsonEntity("{\"settings\": " + Strings.toString(MediaTypeRegistry.JSON, settings.build()) + "}"); if (softDeletesEnabled == false) { expectSoftDeletesWarning(request, indexName); } diff --git a/qa/smoke-test-http/src/test/java/org/opensearch/http/SearchRestCancellationIT.java b/qa/smoke-test-http/src/test/java/org/opensearch/http/SearchRestCancellationIT.java index b1143ad647327..29e3d8bdcd41b 100644 --- a/qa/smoke-test-http/src/test/java/org/opensearch/http/SearchRestCancellationIT.java +++ b/qa/smoke-test-http/src/test/java/org/opensearch/http/SearchRestCancellationIT.java @@ -48,8 +48,9 @@ import org.opensearch.client.Response; import org.opensearch.client.ResponseListener; import org.opensearch.common.SetOnce; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.plugins.Plugin; import org.opensearch.plugins.PluginsService; import org.opensearch.script.MockScriptPlugin; @@ -98,12 +99,12 @@ public void testAutomaticCancellationDuringQueryPhase() throws Exception { Request searchRequest = new Request("GET", "/test/_search"); SearchSourceBuilder searchSource = new SearchSourceBuilder().query(scriptQuery( new Script(ScriptType.INLINE, "mockscript", ScriptedBlockPlugin.SCRIPT_NAME, Collections.emptyMap()))); - searchRequest.setJsonEntity(Strings.toString(XContentType.JSON, searchSource)); + searchRequest.setJsonEntity(Strings.toString(MediaTypeRegistry.JSON, searchSource)); verifyCancellationDuringQueryPhase(SearchAction.NAME, searchRequest); } public void testAutomaticCancellationMultiSearchDuringQueryPhase() throws Exception { - XContentType contentType = XContentType.JSON; + MediaType contentType = MediaTypeRegistry.JSON; MultiSearchRequest multiSearchRequest = new MultiSearchRequest().add(new SearchRequest("test") .source(new SearchSourceBuilder().scriptField("test_field", new Script(ScriptType.INLINE, "mockscript", ScriptedBlockPlugin.SCRIPT_NAME, Collections.emptyMap())))); @@ -147,12 +148,12 @@ public void testAutomaticCancellationDuringFetchPhase() throws Exception { Request searchRequest = new Request("GET", "/test/_search"); SearchSourceBuilder searchSource = new SearchSourceBuilder().scriptField("test_field", new Script(ScriptType.INLINE, "mockscript", ScriptedBlockPlugin.SCRIPT_NAME, Collections.emptyMap())); - searchRequest.setJsonEntity(Strings.toString(XContentType.JSON, searchSource)); + searchRequest.setJsonEntity(Strings.toString(MediaTypeRegistry.JSON, searchSource)); verifyCancellationDuringFetchPhase(SearchAction.NAME, searchRequest); } public void testAutomaticCancellationMultiSearchDuringFetchPhase() throws Exception { - XContentType contentType = XContentType.JSON; + MediaType contentType = MediaTypeRegistry.JSON; MultiSearchRequest multiSearchRequest = new MultiSearchRequest().add(new SearchRequest("test") .source(new SearchSourceBuilder().scriptField("test_field", new Script(ScriptType.INLINE, "mockscript", ScriptedBlockPlugin.SCRIPT_NAME, Collections.emptyMap())))); @@ -298,7 +299,7 @@ public Map, Object>> pluginScripts() { } } - private static ContentType createContentType(final XContentType xContentType) { - return ContentType.create(xContentType.mediaTypeWithoutParameters(), (Charset) null); + private static ContentType createContentType(final MediaType mediaType) { + return ContentType.create(mediaType.mediaTypeWithoutParameters(), (Charset) null); } } diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/AbstractTasksIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/AbstractTasksIT.java index 84e7d82d25ab2..8ba566aaa69b2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/AbstractTasksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/AbstractTasksIT.java @@ -16,8 +16,8 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.collect.Tuple; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.plugins.Plugin; import org.opensearch.tasks.TaskId; import org.opensearch.tasks.TaskInfo; @@ -182,7 +182,7 @@ protected void indexDocumentsWithRefresh(String indexName, int numDocs) { for (int i = 0; i < numDocs; i++) { client().prepareIndex(indexName) .setId("test_id_" + String.valueOf(i)) - .setSource("{\"foo_" + String.valueOf(i) + "\": \"bar_" + String.valueOf(i) + "\"}", XContentType.JSON) + .setSource("{\"foo_" + String.valueOf(i) + "\": \"bar_" + String.valueOf(i) + "\"}", MediaTypeRegistry.JSON) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) .get(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TasksIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TasksIT.java index 67e52529ae86b..e6b578f41e4cf 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TasksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TasksIT.java @@ -59,7 +59,7 @@ import org.opensearch.common.collect.Tuple; import org.opensearch.common.regex.Regex; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.query.QueryBuilders; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.tasks.Task; @@ -287,7 +287,9 @@ public void testTransportBulkTasks() { ensureGreen("test"); // Make sure all shards are allocated to catch replication tasks // ensures the mapping is available on all nodes so we won't retry the request (in case replicas don't have the right mapping). client().admin().indices().preparePutMapping("test").setSource("foo", "type=keyword").get(); - client().prepareBulk().add(client().prepareIndex("test").setId("test_id").setSource("{\"foo\": \"bar\"}", XContentType.JSON)).get(); + client().prepareBulk() + .add(client().prepareIndex("test").setId("test_id").setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON)) + .get(); // the bulk operation should produce one main task List topTask = findEvents(BulkAction.NAME, Tuple::v1); @@ -338,7 +340,7 @@ public void testSearchTaskDescriptions() { ensureGreen("test"); // Make sure all shards are allocated to catch replication tasks client().prepareIndex("test") .setId("test_id") - .setSource("{\"foo\": \"bar\"}", XContentType.JSON) + .setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) .get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CloneIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CloneIndexIT.java index 98fc6483703c4..0551d19b02b8f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CloneIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CloneIndexIT.java @@ -37,7 +37,7 @@ import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; import org.opensearch.cluster.routing.allocation.decider.EnableAllocationDecider; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.query.TermsQueryBuilder; import org.opensearch.index.seqno.SeqNoStats; import org.opensearch.test.OpenSearchIntegTestCase; @@ -62,7 +62,7 @@ public void testCreateCloneIndex() { ).get(); final int docs = randomIntBetween(0, 128); for (int i = 0; i < docs; i++) { - client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } internalCluster().ensureAtLeastNumDataNodes(2); // ensure all shards are allocated otherwise the ensure green below might not succeed since we require the merge node @@ -122,7 +122,7 @@ public void testCreateCloneIndex() { } for (int i = docs; i < 2 * docs; i++) { - client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } flushAndRefresh(); assertHitCount( diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java index a75448dadf427..de767c0ee95bc 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java @@ -67,8 +67,8 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.Index; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.engine.SegmentsStats; import org.opensearch.index.query.TermsQueryBuilder; @@ -109,7 +109,7 @@ public void testCreateShrinkIndexToN() { for (int i = 0; i < 20; i++) { client().prepareIndex("source") .setId(Integer.toString(i)) - .setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON) + .setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON) .get(); } final Map dataNodes = client().admin().cluster().prepareState().get().getState().nodes().getDataNodes(); @@ -147,7 +147,7 @@ public void testCreateShrinkIndexToN() { for (int i = 0; i < 20; i++) { // now update client().prepareIndex("first_shrink") .setId(Integer.toString(i)) - .setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON) + .setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON) .get(); } flushAndRefresh(); @@ -190,7 +190,7 @@ public void testCreateShrinkIndexToN() { for (int i = 0; i < 20; i++) { // now update client().prepareIndex("second_shrink") .setId(Integer.toString(i)) - .setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON) + .setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON) .get(); } flushAndRefresh(); @@ -232,7 +232,7 @@ public void testShrinkIndexPrimaryTerm() throws Exception { final int hash = Math.floorMod(Murmur3HashFunction.hash(s), numberOfShards); if (hash == shardId) { final IndexRequest request = new IndexRequest("source").id(s) - .source("{ \"f\": \"" + s + "\"}", XContentType.JSON); + .source("{ \"f\": \"" + s + "\"}", MediaTypeRegistry.JSON); client().index(request).get(); break; } else { @@ -283,7 +283,7 @@ public void testCreateShrinkIndex() { ).get(); final int docs = randomIntBetween(0, 128); for (int i = 0; i < docs; i++) { - client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } final Map dataNodes = client().admin().cluster().prepareState().get().getState().nodes().getDataNodes(); assertTrue("at least 2 nodes but was: " + dataNodes.size(), dataNodes.size() >= 2); @@ -378,7 +378,7 @@ public void testCreateShrinkIndex() { } for (int i = docs; i < 2 * docs; i++) { - client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } flushAndRefresh(); assertHitCount(client().prepareSearch("target").setSize(2 * size).setQuery(new TermsQueryBuilder("foo", "bar")).get(), 2 * docs); @@ -405,7 +405,7 @@ public void testCreateShrinkIndexFails() throws Exception { Settings.builder().put(indexSettings()).put("number_of_shards", randomIntBetween(2, 7)).put("number_of_replicas", 0) ).get(); for (int i = 0; i < 20; i++) { - client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } final Map dataNodes = client().admin().cluster().prepareState().get().getState().nodes().getDataNodes(); assertTrue("at least 2 nodes but was: " + dataNodes.size(), dataNodes.size() >= 2); @@ -506,7 +506,7 @@ public void testCreateShrinkWithIndexSort() throws Exception { for (int i = 0; i < 20; i++) { client().prepareIndex("source") .setId(Integer.toString(i)) - .setSource("{\"foo\" : \"bar\", \"id\" : " + i + "}", XContentType.JSON) + .setSource("{\"foo\" : \"bar\", \"id\" : " + i + "}", MediaTypeRegistry.JSON) .get(); } final Map dataNodes = client().admin().cluster().prepareState().get().getState().nodes().getDataNodes(); @@ -569,7 +569,7 @@ public void testCreateShrinkWithIndexSort() throws Exception { // ... and that the index sort is also applied to updates for (int i = 20; i < 40; i++) { - client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } flushAndRefresh(); assertSortedSegments("target", expectedIndexSort); @@ -580,7 +580,7 @@ public void testShrinkCommitsMergeOnIdle() throws Exception { Settings.builder().put(indexSettings()).put("index.number_of_replicas", 0).put("number_of_shards", 5) ).get(); for (int i = 0; i < 30; i++) { - client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } client().admin().indices().prepareFlush("source").get(); final Map dataNodes = client().admin().cluster().prepareState().get().getState().nodes().getDataNodes(); @@ -737,7 +737,7 @@ public void testCreateShrinkIndexWithMaxShardSize() { .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, shardCount) ).get(); for (int i = 0; i < 20; i++) { - client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } client().admin().indices().prepareFlush("source").get(); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java index ea53efe176eaf..48ef1ab52747c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java @@ -61,8 +61,8 @@ import org.opensearch.cluster.routing.allocation.decider.EnableAllocationDecider; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.Index; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.engine.SegmentsStats; import org.opensearch.index.query.TermsQueryBuilder; @@ -347,7 +347,7 @@ public void testSplitIndexPrimaryTerm() throws Exception { final int hash = Math.floorMod(Murmur3HashFunction.hash(s), numberOfShards); if (hash == shardId) { final IndexRequest request = new IndexRequest("source").id(s) - .source("{ \"f\": \"" + s + "\"}", XContentType.JSON); + .source("{ \"f\": \"" + s + "\"}", MediaTypeRegistry.JSON); client().index(request).get(); break; } else { @@ -403,7 +403,7 @@ public void testCreateSplitIndex() throws Exception { ).get(); final int docs = randomIntBetween(0, 128); for (int i = 0; i < docs; i++) { - client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } // ensure all shards are allocated otherwise the ensure green below might not succeed since we require the merge node // if we change the setting too quickly we will end up with one replica unassigned which can't be assigned anymore due @@ -487,7 +487,7 @@ public void testCreateSplitIndex() throws Exception { } for (int i = docs; i < 2 * docs; i++) { - client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } flushAndRefresh(); assertHitCount( @@ -526,7 +526,7 @@ public void testCreateSplitWithIndexSort() throws Exception { for (int i = 0; i < 20; i++) { client().prepareIndex("source") .setId(Integer.toString(i)) - .setSource("{\"foo\" : \"bar\", \"id\" : " + i + "}", XContentType.JSON) + .setSource("{\"foo\" : \"bar\", \"id\" : " + i + "}", MediaTypeRegistry.JSON) .get(); } // ensure all shards are allocated otherwise the ensure green below might not succeed since we require the merge node @@ -582,7 +582,7 @@ public void testCreateSplitWithIndexSort() throws Exception { // ... and that the index sort is also applied to updates for (int i = 20; i < 40; i++) { - client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get(); + client().prepareIndex("target").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", MediaTypeRegistry.JSON).get(); } flushAndRefresh(); assertSortedSegments("target", expectedIndexSort); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamTestCase.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamTestCase.java index 44f66dd4e0f90..13bb576c35984 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamTestCase.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamTestCase.java @@ -19,8 +19,8 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentHelper; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.test.OpenSearchIntegTestCase; import java.util.List; @@ -90,7 +90,7 @@ public AcknowledgedResponse createDataStreamIndexTemplate(String name, List index(new IndexRequest("logs-demo").id("doc-1").source("{}", XContentType.JSON))); + exception = expectThrows( + Exception.class, + () -> index(new IndexRequest("logs-demo").id("doc-1").source("{}", MediaTypeRegistry.JSON)) + ); assertThat(exception.getMessage(), containsString("only write ops with an op_type of create are allowed in data streams")); // Documents must contain a valid timestamp field. exception = expectThrows( Exception.class, - () -> index(new IndexRequest("logs-demo").id("doc-1").source("{}", XContentType.JSON).opType(DocWriteRequest.OpType.CREATE)) + () -> index( + new IndexRequest("logs-demo").id("doc-1").source("{}", MediaTypeRegistry.JSON).opType(DocWriteRequest.OpType.CREATE) + ) ); assertThat( exception.getMessage(), diff --git a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkIntegrationIT.java index 1c2e8200abb6d..e8db4038db6ae 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkIntegrationIT.java @@ -46,8 +46,8 @@ import org.opensearch.action.update.UpdateRequest; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.ingest.IngestTestPlugin; import org.opensearch.plugins.Plugin; import org.opensearch.core.rest.RestStatus; @@ -84,7 +84,7 @@ protected Collection> nodePlugins() { public void testBulkIndexCreatesMapping() throws Exception { String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/bulk-log.json"); BulkRequestBuilder bulkBuilder = client().prepareBulk(); - bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); + bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON); bulkBuilder.get(); assertBusy(() -> { GetMappingsResponse mappingsResponse = client().admin().indices().prepareGetMappings().get(); @@ -155,7 +155,7 @@ public void testBulkWithGlobalDefaults() throws Exception { String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk-missing-index-type.json"); { BulkRequestBuilder bulkBuilder = client().prepareBulk(); - bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); + bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON); ActionRequestValidationException ex = expectThrows(ActionRequestValidationException.class, bulkBuilder::get); assertThat(ex.validationErrors(), containsInAnyOrder("index is missing", "index is missing", "index is missing")); @@ -165,7 +165,7 @@ public void testBulkWithGlobalDefaults() throws Exception { createSamplePipeline("pipeline"); BulkRequestBuilder bulkBuilder = client().prepareBulk("test").routing("routing").pipeline("pipeline"); - bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); + bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON); BulkResponse bulkItemResponses = bulkBuilder.get(); assertFalse(bulkItemResponses.hasFailures()); } @@ -183,7 +183,7 @@ private void createSamplePipeline(String pipelineId) throws IOException, Executi AcknowledgedResponse acknowledgedResponse = client().admin() .cluster() - .putPipeline(new PutPipelineRequest(pipelineId, BytesReference.bytes(pipeline), XContentType.JSON)) + .putPipeline(new PutPipelineRequest(pipelineId, BytesReference.bytes(pipeline), MediaTypeRegistry.JSON)) .get(); assertTrue(acknowledgedResponse.isAcknowledged()); @@ -201,7 +201,7 @@ public void testDeleteIndexWhileIndexing() throws Exception { try { IndexResponse response = client().prepareIndex(index) .setId(id) - .setSource(Collections.singletonMap("f" + randomIntBetween(1, 10), randomNonNegativeLong()), XContentType.JSON) + .setSource(Collections.singletonMap("f" + randomIntBetween(1, 10), randomNonNegativeLong()), MediaTypeRegistry.JSON) .get(); assertThat(response.getResult(), is(oneOf(CREATED, UPDATED))); logger.info("--> index id={} seq_no={}", response.getId(), response.getSeqNo()); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkProcessorClusterSettingsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkProcessorClusterSettingsIT.java index 14531787e9903..ea7af48266905 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkProcessorClusterSettingsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkProcessorClusterSettingsIT.java @@ -33,7 +33,7 @@ package org.opensearch.action.bulk; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope; import org.opensearch.test.OpenSearchIntegTestCase.Scope; @@ -50,9 +50,9 @@ public void testBulkProcessorAutoCreateRestrictions() throws Exception { client().admin().cluster().prepareHealth("willwork").setWaitForGreenStatus().execute().actionGet(); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); - bulkRequestBuilder.add(client().prepareIndex("willwork").setId("1").setSource("{\"foo\":1}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("wontwork").setId("2").setSource("{\"foo\":2}", XContentType.JSON)); - bulkRequestBuilder.add(client().prepareIndex("willwork").setId("3").setSource("{\"foo\":3}", XContentType.JSON)); + bulkRequestBuilder.add(client().prepareIndex("willwork").setId("1").setSource("{\"foo\":1}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("wontwork").setId("2").setSource("{\"foo\":2}", MediaTypeRegistry.JSON)); + bulkRequestBuilder.add(client().prepareIndex("willwork").setId("3").setSource("{\"foo\":3}", MediaTypeRegistry.JSON)); BulkResponse br = bulkRequestBuilder.get(); BulkItemResponse[] responses = br.getItems(); assertEquals(3, responses.length); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java index 139b2cb896ded..ce6cbe23d4701 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java @@ -47,8 +47,8 @@ import org.opensearch.client.Requests; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.VersionType; import org.opensearch.indices.IndexClosedException; import org.opensearch.plugins.Plugin; @@ -618,19 +618,19 @@ public void testThatInvalidIndexNamesShouldNotBreakCompleteBulkRequest() { // issue 6630 public void testThatFailedUpdateRequestReturnsCorrectType() throws Exception { BulkResponse indexBulkItemResponse = client().prepareBulk() - .add(new IndexRequest("test").id("3").source("{ \"title\" : \"Great Title of doc 3\" }", XContentType.JSON)) - .add(new IndexRequest("test").id("4").source("{ \"title\" : \"Great Title of doc 4\" }", XContentType.JSON)) - .add(new IndexRequest("test").id("5").source("{ \"title\" : \"Great Title of doc 5\" }", XContentType.JSON)) - .add(new IndexRequest("test").id("6").source("{ \"title\" : \"Great Title of doc 6\" }", XContentType.JSON)) + .add(new IndexRequest("test").id("3").source("{ \"title\" : \"Great Title of doc 3\" }", MediaTypeRegistry.JSON)) + .add(new IndexRequest("test").id("4").source("{ \"title\" : \"Great Title of doc 4\" }", MediaTypeRegistry.JSON)) + .add(new IndexRequest("test").id("5").source("{ \"title\" : \"Great Title of doc 5\" }", MediaTypeRegistry.JSON)) + .add(new IndexRequest("test").id("6").source("{ \"title\" : \"Great Title of doc 6\" }", MediaTypeRegistry.JSON)) .setRefreshPolicy(RefreshPolicy.IMMEDIATE) .get(); assertNoFailures(indexBulkItemResponse); BulkResponse bulkItemResponse = client().prepareBulk() - .add(new IndexRequest("test").id("1").source("{ \"title\" : \"Great Title of doc 1\" }", XContentType.JSON)) - .add(new IndexRequest("test").id("2").source("{ \"title\" : \"Great Title of doc 2\" }", XContentType.JSON)) - .add(new UpdateRequest("test", "3").doc("{ \"date\" : \"2014-01-30T23:59:57\"}", XContentType.JSON)) - .add(new UpdateRequest("test", "4").doc("{ \"date\" : \"2014-13-30T23:59:57\"}", XContentType.JSON)) + .add(new IndexRequest("test").id("1").source("{ \"title\" : \"Great Title of doc 1\" }", MediaTypeRegistry.JSON)) + .add(new IndexRequest("test").id("2").source("{ \"title\" : \"Great Title of doc 2\" }", MediaTypeRegistry.JSON)) + .add(new UpdateRequest("test", "3").doc("{ \"date\" : \"2014-01-30T23:59:57\"}", MediaTypeRegistry.JSON)) + .add(new UpdateRequest("test", "4").doc("{ \"date\" : \"2014-13-30T23:59:57\"}", MediaTypeRegistry.JSON)) .add(new DeleteRequest("test", "5")) .add(new DeleteRequest("test", "6")) .get(); @@ -732,7 +732,11 @@ public void testNoopUpdate() { final BulkItemResponse noopUpdate = bulkResponse.getItems()[0]; assertThat(noopUpdate.getResponse().getResult(), equalTo(DocWriteResponse.Result.NOOP)); - assertThat(Strings.toString(XContentType.JSON, noopUpdate), noopUpdate.getResponse().getShardInfo().getSuccessful(), equalTo(2)); + assertThat( + Strings.toString(MediaTypeRegistry.JSON, noopUpdate), + noopUpdate.getResponse().getShardInfo().getSuccessful(), + equalTo(2) + ); final BulkItemResponse notFoundUpdate = bulkResponse.getItems()[1]; assertNotNull(notFoundUpdate.getFailure()); @@ -740,7 +744,7 @@ public void testNoopUpdate() { final BulkItemResponse notFoundDelete = bulkResponse.getItems()[2]; assertThat(notFoundDelete.getResponse().getResult(), equalTo(DocWriteResponse.Result.NOT_FOUND)); assertThat( - Strings.toString(XContentType.JSON, notFoundDelete), + Strings.toString(MediaTypeRegistry.JSON, notFoundDelete), notFoundDelete.getResponse().getShardInfo().getSuccessful(), equalTo(2) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/ingest/AsyncIngestProcessorIT.java b/server/src/internalClusterTest/java/org/opensearch/action/ingest/AsyncIngestProcessorIT.java index 58c18be59fdac..c62c61d5919d6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/ingest/AsyncIngestProcessorIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/ingest/AsyncIngestProcessorIT.java @@ -42,8 +42,8 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.env.Environment; import org.opensearch.env.NodeEnvironment; import org.opensearch.ingest.AbstractProcessor; @@ -84,12 +84,12 @@ protected Collection> getPlugins() { public void testAsyncProcessorImplementation() { // A pipeline with 2 processors: the test async processor and sync test processor. BytesReference pipelineBody = new BytesArray("{\"processors\": [{\"test-async\": {}, \"test\": {}}]}"); - client().admin().cluster().putPipeline(new PutPipelineRequest("_id", pipelineBody, XContentType.JSON)).actionGet(); + client().admin().cluster().putPipeline(new PutPipelineRequest("_id", pipelineBody, MediaTypeRegistry.JSON)).actionGet(); BulkRequest bulkRequest = new BulkRequest(); int numDocs = randomIntBetween(8, 256); for (int i = 0; i < numDocs; i++) { - bulkRequest.add(new IndexRequest("foobar").id(Integer.toString(i)).source("{}", XContentType.JSON).setPipeline("_id")); + bulkRequest.add(new IndexRequest("foobar").id(Integer.toString(i)).source("{}", MediaTypeRegistry.JSON).setPipeline("_id")); } BulkResponse bulkResponse = client().bulk(bulkRequest).actionGet(); assertThat(bulkResponse.getItems().length, equalTo(numDocs)); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/support/WaitActiveShardCountIT.java b/server/src/internalClusterTest/java/org/opensearch/action/support/WaitActiveShardCountIT.java index c82af8bce6e2d..1300a82a52e86 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/support/WaitActiveShardCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/support/WaitActiveShardCountIT.java @@ -39,8 +39,8 @@ import org.opensearch.cluster.health.ClusterHealthStatus; import org.opensearch.common.Priority; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.rest.RestStatus; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchIntegTestCase; import static org.opensearch.common.unit.TimeValue.timeValueMillis; @@ -63,11 +63,11 @@ public void testReplicationWaitsForActiveShardCount() throws Exception { assertAcked(createIndexResponse); // indexing, by default, will work (waiting for one shard copy only) - client().prepareIndex("test").setId("1").setSource(source("1", "test"), XContentType.JSON).execute().actionGet(); + client().prepareIndex("test").setId("1").setSource(source("1", "test"), MediaTypeRegistry.JSON).execute().actionGet(); try { client().prepareIndex("test") .setId("1") - .setSource(source("1", "test"), XContentType.JSON) + .setSource(source("1", "test"), MediaTypeRegistry.JSON) .setWaitForActiveShards(2) // wait for 2 active shard copies .setTimeout(timeValueMillis(100)) .execute() @@ -99,7 +99,7 @@ public void testReplicationWaitsForActiveShardCount() throws Exception { // this should work, since we now have two client().prepareIndex("test") .setId("1") - .setSource(source("1", "test"), XContentType.JSON) + .setSource(source("1", "test"), MediaTypeRegistry.JSON) .setWaitForActiveShards(2) .setTimeout(timeValueSeconds(1)) .execute() @@ -108,7 +108,7 @@ public void testReplicationWaitsForActiveShardCount() throws Exception { try { client().prepareIndex("test") .setId("1") - .setSource(source("1", "test"), XContentType.JSON) + .setSource(source("1", "test"), MediaTypeRegistry.JSON) .setWaitForActiveShards(ActiveShardCount.ALL) .setTimeout(timeValueMillis(100)) .execute() @@ -143,7 +143,7 @@ public void testReplicationWaitsForActiveShardCount() throws Exception { // this should work, since we now have all shards started client().prepareIndex("test") .setId("1") - .setSource(source("1", "test"), XContentType.JSON) + .setSource(source("1", "test"), MediaTypeRegistry.JSON) .setWaitForActiveShards(ActiveShardCount.ALL) .setTimeout(timeValueSeconds(1)) .execute() diff --git a/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java b/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java index 0b050fd60f920..f91df19232971 100644 --- a/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java @@ -50,7 +50,7 @@ import org.opensearch.common.StopWatch; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.query.TermQueryBuilder; @@ -115,7 +115,7 @@ public void testAliases() throws Exception { logger.info("--> indexing against [alias1], should fail now"); IllegalArgumentException exception = expectThrows( IllegalArgumentException.class, - () -> client().index(indexRequest("alias1").id("1").source(source("2", "test"), XContentType.JSON)).actionGet() + () -> client().index(indexRequest("alias1").id("1").source(source("2", "test"), MediaTypeRegistry.JSON)).actionGet() ); assertThat( exception.getMessage(), @@ -132,7 +132,7 @@ public void testAliases() throws Exception { }); logger.info("--> indexing against [alias1], should work now"); - IndexResponse indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), XContentType.JSON)) + IndexResponse indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), MediaTypeRegistry.JSON)) .actionGet(); assertThat(indexResponse.getIndex(), equalTo("test")); @@ -149,7 +149,7 @@ public void testAliases() throws Exception { logger.info("--> indexing against [alias1], should fail now"); exception = expectThrows( IllegalArgumentException.class, - () -> client().index(indexRequest("alias1").id("1").source(source("2", "test"), XContentType.JSON)).actionGet() + () -> client().index(indexRequest("alias1").id("1").source(source("2", "test"), MediaTypeRegistry.JSON)).actionGet() ); assertThat( exception.getMessage(), @@ -177,7 +177,7 @@ public void testAliases() throws Exception { }); logger.info("--> indexing against [alias1], should work now"); - indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), XContentType.JSON)).actionGet(); + indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), MediaTypeRegistry.JSON)).actionGet(); assertThat(indexResponse.getIndex(), equalTo("test")); assertAliasesVersionIncreases("test_x", () -> { @@ -186,7 +186,7 @@ public void testAliases() throws Exception { }); logger.info("--> indexing against [alias1], should work now"); - indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), XContentType.JSON)).actionGet(); + indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), MediaTypeRegistry.JSON)).actionGet(); assertThat(indexResponse.getIndex(), equalTo("test_x")); logger.info("--> deleting against [alias1], should fail now"); @@ -199,7 +199,7 @@ public void testAliases() throws Exception { }); logger.info("--> indexing against [alias1], should work against [test_x]"); - indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), XContentType.JSON)).actionGet(); + indexResponse = client().index(indexRequest("alias1").id("1").source(source("1", "test"), MediaTypeRegistry.JSON)).actionGet(); assertThat(indexResponse.getIndex(), equalTo("test_x")); } @@ -281,16 +281,18 @@ public void testSearchingFilteringAliasesSingleIndex() throws Exception { logger.info("--> indexing against [test]"); client().index( - indexRequest("test").id("1").source(source("1", "foo test"), XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE) + indexRequest("test").id("1").source(source("1", "foo test"), MediaTypeRegistry.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE) ).actionGet(); client().index( - indexRequest("test").id("2").source(source("2", "bar test"), XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE) + indexRequest("test").id("2").source(source("2", "bar test"), MediaTypeRegistry.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE) ).actionGet(); client().index( - indexRequest("test").id("3").source(source("3", "baz test"), XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE) + indexRequest("test").id("3").source(source("3", "baz test"), MediaTypeRegistry.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE) ).actionGet(); client().index( - indexRequest("test").id("4").source(source("4", "something else"), XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE) + indexRequest("test").id("4") + .source(source("4", "something else"), MediaTypeRegistry.JSON) + .setRefreshPolicy(RefreshPolicy.IMMEDIATE) ).actionGet(); logger.info("--> checking single filtering alias search"); @@ -387,16 +389,16 @@ public void testSearchingFilteringAliasesTwoIndices() throws Exception { ); logger.info("--> indexing against [test1]"); - client().index(indexRequest("test1").id("1").source(source("1", "foo test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").id("2").source(source("2", "bar test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").id("3").source(source("3", "baz test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").id("4").source(source("4", "something else"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("1").source(source("1", "foo test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test1").id("2").source(source("2", "bar test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test1").id("3").source(source("3", "baz test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test1").id("4").source(source("4", "something else"), MediaTypeRegistry.JSON)).get(); logger.info("--> indexing against [test2]"); - client().index(indexRequest("test2").id("5").source(source("5", "foo test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").id("6").source(source("6", "bar test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").id("7").source(source("7", "baz test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").id("8").source(source("8", "something else"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("5").source(source("5", "foo test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test2").id("6").source(source("6", "bar test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test2").id("7").source(source("7", "baz test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test2").id("8").source(source("8", "something else"), MediaTypeRegistry.JSON)).get(); refresh(); @@ -501,17 +503,17 @@ public void testSearchingFilteringAliasesMultipleIndices() throws Exception { ); logger.info("--> indexing against [test1]"); - client().index(indexRequest("test1").id("11").source(source("11", "foo test1"), XContentType.JSON)).get(); - client().index(indexRequest("test1").id("12").source(source("12", "bar test1"), XContentType.JSON)).get(); - client().index(indexRequest("test1").id("13").source(source("13", "baz test1"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("11").source(source("11", "foo test1"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test1").id("12").source(source("12", "bar test1"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test1").id("13").source(source("13", "baz test1"), MediaTypeRegistry.JSON)).get(); - client().index(indexRequest("test2").id("21").source(source("21", "foo test2"), XContentType.JSON)).get(); - client().index(indexRequest("test2").id("22").source(source("22", "bar test2"), XContentType.JSON)).get(); - client().index(indexRequest("test2").id("23").source(source("23", "baz test2"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("21").source(source("21", "foo test2"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test2").id("22").source(source("22", "bar test2"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test2").id("23").source(source("23", "baz test2"), MediaTypeRegistry.JSON)).get(); - client().index(indexRequest("test3").id("31").source(source("31", "foo test3"), XContentType.JSON)).get(); - client().index(indexRequest("test3").id("32").source(source("32", "bar test3"), XContentType.JSON)).get(); - client().index(indexRequest("test3").id("33").source(source("33", "baz test3"), XContentType.JSON)).get(); + client().index(indexRequest("test3").id("31").source(source("31", "foo test3"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test3").id("32").source(source("32", "bar test3"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test3").id("33").source(source("33", "baz test3"), MediaTypeRegistry.JSON)).get(); refresh(); @@ -624,16 +626,16 @@ public void testDeletingByQueryFilteringAliases() throws Exception { ); logger.info("--> indexing against [test1]"); - client().index(indexRequest("test1").id("1").source(source("1", "foo test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").id("2").source(source("2", "bar test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").id("3").source(source("3", "baz test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").id("4").source(source("4", "something else"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("1").source(source("1", "foo test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test1").id("2").source(source("2", "bar test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test1").id("3").source(source("3", "baz test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test1").id("4").source(source("4", "something else"), MediaTypeRegistry.JSON)).get(); logger.info("--> indexing against [test2]"); - client().index(indexRequest("test2").id("5").source(source("5", "foo test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").id("6").source(source("6", "bar test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").id("7").source(source("7", "baz test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").id("8").source(source("8", "something else"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("5").source(source("5", "foo test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test2").id("6").source(source("6", "bar test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test2").id("7").source(source("7", "baz test"), MediaTypeRegistry.JSON)).get(); + client().index(indexRequest("test2").id("8").source(source("8", "something else"), MediaTypeRegistry.JSON)).get(); refresh(); @@ -722,7 +724,7 @@ public void testWaitForAliasCreationMultipleShards() throws Exception { for (int i = 0; i < 10; i++) { final String aliasName = "alias" + i; assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName))); - client().index(indexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).get(); + client().index(indexRequest(aliasName).id("1").source(source("1", "test"), MediaTypeRegistry.JSON)).get(); } } @@ -743,7 +745,7 @@ public void testWaitForAliasCreationSingleShard() throws Exception { for (int i = 0; i < 10; i++) { final String aliasName = "alias" + i; assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName))); - client().index(indexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).get(); + client().index(indexRequest(aliasName).id("1").source(source("1", "test"), MediaTypeRegistry.JSON)).get(); } } @@ -765,7 +767,7 @@ public void run() { "test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName)) ); - client().index(indexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).actionGet(); + client().index(indexRequest(aliasName).id("1").source(source("1", "test"), MediaTypeRegistry.JSON)).actionGet(); } }); } @@ -1086,7 +1088,7 @@ public void testCreateIndexWithAliasesInSource() throws Exception { + " \"alias4\" : {\"is_hidden\": true}\n" + " }\n" + "}", - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -1379,12 +1381,13 @@ public void testIndexingAndQueryingHiddenAliases() throws Exception { ensureGreen(); // Put a couple docs in each index directly - IndexResponse res = client().index(indexRequest(nonWriteIndex).id("1").source(source("1", "nonwrite"), XContentType.JSON)).get(); + IndexResponse res = client().index(indexRequest(nonWriteIndex).id("1").source(source("1", "nonwrite"), MediaTypeRegistry.JSON)) + .get(); assertThat(res.status().getStatus(), equalTo(201)); - res = client().index(indexRequest(writeIndex).id("2").source(source("2", "writeindex"), XContentType.JSON)).get(); + res = client().index(indexRequest(writeIndex).id("2").source(source("2", "writeindex"), MediaTypeRegistry.JSON)).get(); assertThat(res.status().getStatus(), equalTo(201)); // And through the alias - res = client().index(indexRequest(alias).id("3").source(source("3", "through alias"), XContentType.JSON)).get(); + res = client().index(indexRequest(alias).id("3").source(source("3", "through alias"), MediaTypeRegistry.JSON)).get(); assertThat(res.status().getStatus(), equalTo(201)); refresh(writeIndex, nonWriteIndex); diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleDataNodesIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleDataNodesIT.java index d7adf57593953..86b3b842a7da1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleDataNodesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleDataNodesIT.java @@ -41,7 +41,7 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.Priority; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope; import org.opensearch.test.OpenSearchIntegTestCase.Scope; @@ -62,7 +62,7 @@ public void testIndexingBeforeAndAfterDataNodesStart() { internalCluster().startNode(nonDataNode()); client().admin().indices().create(createIndexRequest("test").waitForActiveShards(ActiveShardCount.NONE)).actionGet(); try { - client().index(Requests.indexRequest("test").id("1").source(SOURCE, XContentType.JSON).timeout(timeValueSeconds(1))) + client().index(Requests.indexRequest("test").id("1").source(SOURCE, MediaTypeRegistry.JSON).timeout(timeValueSeconds(1))) .actionGet(); fail("no allocation should happen"); } catch (UnavailableShardsException e) { @@ -85,7 +85,7 @@ public void testIndexingBeforeAndAfterDataNodesStart() { // still no shard should be allocated try { - client().index(Requests.indexRequest("test").id("1").source(SOURCE, XContentType.JSON).timeout(timeValueSeconds(1))) + client().index(Requests.indexRequest("test").id("1").source(SOURCE, MediaTypeRegistry.JSON).timeout(timeValueSeconds(1))) .actionGet(); fail("no allocation should happen"); } catch (UnavailableShardsException e) { @@ -107,7 +107,8 @@ public void testIndexingBeforeAndAfterDataNodesStart() { equalTo(false) ); - IndexResponse indexResponse = client().index(Requests.indexRequest("test").id("1").source(SOURCE, XContentType.JSON)).actionGet(); + IndexResponse indexResponse = client().index(Requests.indexRequest("test").id("1").source(SOURCE, MediaTypeRegistry.JSON)) + .actionGet(); assertThat(indexResponse.getId(), equalTo("1")); } diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/routing/PrimaryAllocationIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/routing/PrimaryAllocationIT.java index 14b6ffcd50825..20fa2199e642b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/routing/PrimaryAllocationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/routing/PrimaryAllocationIT.java @@ -48,8 +48,8 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.set.Sets; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.gateway.GatewayAllocator; import org.opensearch.index.IndexNotFoundException; import org.opensearch.index.engine.Engine; @@ -136,7 +136,7 @@ public void testBulkWeirdScenario() throws Exception { assertThat(bulkResponse.hasFailures(), equalTo(false)); assertThat(bulkResponse.getItems().length, equalTo(2)); - logger.info(Strings.toString(XContentType.JSON, bulkResponse, true, true)); + logger.info(Strings.toString(MediaTypeRegistry.JSON, bulkResponse, true, true)); internalCluster().assertSeqNos(); diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionCleanSettingsIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionCleanSettingsIT.java index 7040bfb950663..5b33ef5c7b513 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionCleanSettingsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionCleanSettingsIT.java @@ -39,7 +39,7 @@ import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.indices.store.IndicesStoreIntegrationIT; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -80,7 +80,7 @@ public void testSearchWithRelocationAndSlowClusterStateProcessing() throws Excep final String node_2 = internalCluster().startDataOnlyNode(); List indexRequestBuilderList = new ArrayList<>(); for (int i = 0; i < 100; i++) { - indexRequestBuilderList.add(client().prepareIndex().setIndex("test").setSource("{\"int_field\":1}", XContentType.JSON)); + indexRequestBuilderList.add(client().prepareIndex().setIndex("test").setSource("{\"int_field\":1}", MediaTypeRegistry.JSON)); } indexRandom(true, indexRequestBuilderList); diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java index 184c866aee2db..7535762fe7d1a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java @@ -53,7 +53,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.ConcurrentCollections; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.VersionType; import org.opensearch.index.shard.IndexShard; import org.opensearch.index.shard.IndexShardTestCase; @@ -173,7 +173,10 @@ public void testAckedIndexing() throws Exception { logger.trace("[{}] indexing id [{}] through node [{}] targeting shard [{}]", name, id, node, shard); IndexRequestBuilder indexRequestBuilder = client.prepareIndex("test") .setId(id) - .setSource(Collections.singletonMap(randomFrom(fieldNames), randomNonNegativeLong()), XContentType.JSON) + .setSource( + Collections.singletonMap(randomFrom(fieldNames), randomNonNegativeLong()), + MediaTypeRegistry.JSON + ) .setTimeout(timeout); if (conflictMode == ConflictMode.external) { @@ -515,7 +518,10 @@ public void testRestartNodeWhileIndexing() throws Exception { try { IndexResponse response = client().prepareIndex(index) .setId(id) - .setSource(Collections.singletonMap("f" + randomIntBetween(1, 10), randomNonNegativeLong()), XContentType.JSON) + .setSource( + Collections.singletonMap("f" + randomIntBetween(1, 10), randomNonNegativeLong()), + MediaTypeRegistry.JSON + ) .get(); assertThat(response.getResult(), is(oneOf(CREATED, UPDATED))); logger.info("--> index id={} seq_no={}", response.getId(), response.getSeqNo()); diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java index 7a7cdb5885054..1463c45aa9b2f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java @@ -41,7 +41,7 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.disruption.BlockClusterManagerServiceOnClusterManager; import org.opensearch.test.disruption.IntermittentLongGCDisruption; @@ -326,9 +326,9 @@ public void testMappingTimeout() throws Exception { disruption.startDisrupting(); BulkRequestBuilder bulk = client().prepareBulk(); - bulk.add(client().prepareIndex("test").setId("2").setSource("{ \"f\": 1 }", XContentType.JSON)); - bulk.add(client().prepareIndex("test").setId("3").setSource("{ \"g\": 1 }", XContentType.JSON)); - bulk.add(client().prepareIndex("test").setId("4").setSource("{ \"f\": 1 }", XContentType.JSON)); + bulk.add(client().prepareIndex("test").setId("2").setSource("{ \"f\": 1 }", MediaTypeRegistry.JSON)); + bulk.add(client().prepareIndex("test").setId("3").setSource("{ \"g\": 1 }", MediaTypeRegistry.JSON)); + bulk.add(client().prepareIndex("test").setId("4").setSource("{ \"f\": 1 }", MediaTypeRegistry.JSON)); BulkResponse bulkResponse = bulk.get(); assertTrue(bulkResponse.hasFailures()); diff --git a/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java b/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java index 10e6aa906ecc9..7bccb81a38633 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java @@ -43,9 +43,9 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.cluster.health.ClusterHealthStatus; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.hamcrest.OpenSearchAssertions; @@ -210,7 +210,7 @@ public void testBulk() throws Exception { .add(client().prepareIndex().setIndex("test").setSource(source("3", "test"))) .add(client().prepareIndex().setIndex("test").setCreate(true).setSource(source("4", "test"))) .add(client().prepareDelete().setIndex("test").setId("1")) - .add(client().prepareIndex().setIndex("test").setSource("{ xxx }", XContentType.JSON)) // failure + .add(client().prepareIndex().setIndex("test").setSource("{ xxx }", MediaTypeRegistry.JSON)) // failure .execute() .actionGet(); diff --git a/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java b/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java index 5f217548794db..4912997206a06 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java @@ -44,7 +44,7 @@ import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchIntegTestCase; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; @@ -60,7 +60,7 @@ public class ShardInfoIT extends OpenSearchIntegTestCase { public void testIndexAndDelete() throws Exception { prepareIndex(1); - IndexResponse indexResponse = client().prepareIndex("idx").setSource("{}", XContentType.JSON).get(); + IndexResponse indexResponse = client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON).get(); assertShardInfo(indexResponse); DeleteResponse deleteResponse = client().prepareDelete("idx", indexResponse.getId()).get(); assertShardInfo(deleteResponse); @@ -68,7 +68,7 @@ public void testIndexAndDelete() throws Exception { public void testUpdate() throws Exception { prepareIndex(1); - UpdateResponse updateResponse = client().prepareUpdate("idx", "1").setDoc("{}", XContentType.JSON).setDocAsUpsert(true).get(); + UpdateResponse updateResponse = client().prepareUpdate("idx", "1").setDoc("{}", MediaTypeRegistry.JSON).setDocAsUpsert(true).get(); assertShardInfo(updateResponse); } @@ -76,7 +76,7 @@ public void testBulkWithIndexAndDeleteItems() throws Exception { prepareIndex(1); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); for (int i = 0; i < 10; i++) { - bulkRequestBuilder.add(client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + bulkRequestBuilder.add(client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); } BulkResponse bulkResponse = bulkRequestBuilder.get(); @@ -98,7 +98,9 @@ public void testBulkWithUpdateItems() throws Exception { prepareIndex(1); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); for (int i = 0; i < 10; i++) { - bulkRequestBuilder.add(client().prepareUpdate("idx", Integer.toString(i)).setDoc("{}", XContentType.JSON).setDocAsUpsert(true)); + bulkRequestBuilder.add( + client().prepareUpdate("idx", Integer.toString(i)).setDoc("{}", MediaTypeRegistry.JSON).setDocAsUpsert(true) + ); } BulkResponse bulkResponse = bulkRequestBuilder.get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java index 2375c62342533..dd162e5b1f3b2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java @@ -48,9 +48,9 @@ import org.opensearch.common.lucene.uid.Versions; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.engine.VersionConflictEngineException; import org.opensearch.plugins.Plugin; import org.opensearch.core.rest.RestStatus; @@ -632,7 +632,7 @@ public void testGetFieldsComplexField() throws Exception { logger.info("indexing documents"); - client().prepareIndex("my-index").setId("1").setSource(source, XContentType.JSON).get(); + client().prepareIndex("my-index").setId("1").setSource(source, MediaTypeRegistry.JSON).get(); logger.info("checking real time retrieval"); @@ -691,7 +691,7 @@ public void testUngeneratedFieldsThatAreNeverStored() throws IOException { + " }\n" + " }\n" + "}"; - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSource(createIndexSource, XContentType.JSON)); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSource(createIndexSource, MediaTypeRegistry.JSON)); ensureGreen(); String doc = "{\n" + " \"suggest\": {\n" @@ -721,10 +721,10 @@ public void testUngeneratedFieldsThatAreAlwaysStored() throws IOException { + " \"refresh_interval\": \"-1\"\n" + " }\n" + "}"; - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSource(createIndexSource, XContentType.JSON)); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSource(createIndexSource, MediaTypeRegistry.JSON)); ensureGreen(); - client().prepareIndex("test").setId("1").setRouting("routingValue").setId("1").setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setRouting("routingValue").setId("1").setSource("{}", MediaTypeRegistry.JSON).get(); String[] fieldsList = { "_routing" }; // before refresh - document is only in translog @@ -745,10 +745,10 @@ public void testUngeneratedFieldsNotPartOfSourceStored() throws IOException { + " }\n" + "}"; - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSource(createIndexSource, XContentType.JSON)); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSource(createIndexSource, MediaTypeRegistry.JSON)); ensureGreen(); String doc = "{\n" + " \"text\": \"some text.\"\n" + "}\n"; - client().prepareIndex("test").setId("1").setSource(doc, XContentType.JSON).setRouting("1").get(); + client().prepareIndex("test").setId("1").setSource(doc, MediaTypeRegistry.JSON).setRouting("1").get(); String[] fieldsList = { "_routing" }; // before refresh - document is only in translog assertGetFieldsAlwaysWorks(indexOrAlias(), "_doc", "1", fieldsList, "1"); @@ -816,7 +816,7 @@ void indexSingleDocumentWithStringFieldsGeneratedFromText(boolean stored, boolea + " }\n" + "}"; - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSource(createIndexSource, XContentType.JSON)); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSource(createIndexSource, MediaTypeRegistry.JSON)); ensureGreen(); String doc = "{\n" + " \"text1\": \"some text.\"\n," + " \"text2\": \"more text.\"\n" + "}\n"; index("test", "_doc", "1", doc); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/FinalPipelineIT.java b/server/src/internalClusterTest/java/org/opensearch/index/FinalPipelineIT.java index 22dc1224f6e09..5ea71efbe504e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/FinalPipelineIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/FinalPipelineIT.java @@ -49,8 +49,8 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.env.Environment; import org.opensearch.env.NodeEnvironment; import org.opensearch.ingest.AbstractProcessor; @@ -103,7 +103,10 @@ public void testFinalPipelineCantChangeDestination() { createIndex("index", settings); final BytesReference finalPipelineBody = new BytesArray("{\"processors\": [{\"changing_dest\": {}}]}"); - client().admin().cluster().putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, XContentType.JSON)).actionGet(); + client().admin() + .cluster() + .putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, MediaTypeRegistry.JSON)) + .actionGet(); final IllegalStateException e = expectThrows( IllegalStateException.class, @@ -122,11 +125,14 @@ public void testFinalPipelineOfOldDestinationIsNotInvoked() { BytesReference defaultPipelineBody = new BytesArray("{\"processors\": [{\"changing_dest\": {}}]}"); client().admin() .cluster() - .putPipeline(new PutPipelineRequest("default_pipeline", defaultPipelineBody, XContentType.JSON)) + .putPipeline(new PutPipelineRequest("default_pipeline", defaultPipelineBody, MediaTypeRegistry.JSON)) .actionGet(); BytesReference finalPipelineBody = new BytesArray("{\"processors\": [{\"final\": {\"exists\":\"no_such_field\"}}]}"); - client().admin().cluster().putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, XContentType.JSON)).actionGet(); + client().admin() + .cluster() + .putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, MediaTypeRegistry.JSON)) + .actionGet(); IndexResponse indexResponse = client().prepareIndex("index") .setId("1") @@ -149,11 +155,14 @@ public void testFinalPipelineOfNewDestinationIsInvoked() { BytesReference defaultPipelineBody = new BytesArray("{\"processors\": [{\"changing_dest\": {}}]}"); client().admin() .cluster() - .putPipeline(new PutPipelineRequest("default_pipeline", defaultPipelineBody, XContentType.JSON)) + .putPipeline(new PutPipelineRequest("default_pipeline", defaultPipelineBody, MediaTypeRegistry.JSON)) .actionGet(); BytesReference finalPipelineBody = new BytesArray("{\"processors\": [{\"final\": {}}]}"); - client().admin().cluster().putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, XContentType.JSON)).actionGet(); + client().admin() + .cluster() + .putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, MediaTypeRegistry.JSON)) + .actionGet(); IndexResponse indexResponse = client().prepareIndex("index") .setId("1") @@ -176,13 +185,13 @@ public void testDefaultPipelineOfNewDestinationIsNotInvoked() { BytesReference defaultPipelineBody = new BytesArray("{\"processors\": [{\"changing_dest\": {}}]}"); client().admin() .cluster() - .putPipeline(new PutPipelineRequest("default_pipeline", defaultPipelineBody, XContentType.JSON)) + .putPipeline(new PutPipelineRequest("default_pipeline", defaultPipelineBody, MediaTypeRegistry.JSON)) .actionGet(); BytesReference targetPipeline = new BytesArray("{\"processors\": [{\"final\": {}}]}"); client().admin() .cluster() - .putPipeline(new PutPipelineRequest("target_default_pipeline", targetPipeline, XContentType.JSON)) + .putPipeline(new PutPipelineRequest("target_default_pipeline", targetPipeline, MediaTypeRegistry.JSON)) .actionGet(); IndexResponse indexResponse = client().prepareIndex("index") @@ -212,10 +221,13 @@ public void testRequestPipelineAndFinalPipeline() { final BytesReference requestPipelineBody = new BytesArray("{\"processors\": [{\"request\": {}}]}"); client().admin() .cluster() - .putPipeline(new PutPipelineRequest("request_pipeline", requestPipelineBody, XContentType.JSON)) + .putPipeline(new PutPipelineRequest("request_pipeline", requestPipelineBody, MediaTypeRegistry.JSON)) .actionGet(); final BytesReference finalPipelineBody = new BytesArray("{\"processors\": [{\"final\": {\"exists\":\"request\"}}]}"); - client().admin().cluster().putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, XContentType.JSON)).actionGet(); + client().admin() + .cluster() + .putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, MediaTypeRegistry.JSON)) + .actionGet(); final Settings settings = Settings.builder().put(IndexSettings.FINAL_PIPELINE.getKey(), "final_pipeline").build(); createIndex("index", settings); final IndexRequestBuilder index = client().prepareIndex("index").setId("1"); @@ -238,10 +250,13 @@ public void testDefaultAndFinalPipeline() { final BytesReference defaultPipelineBody = new BytesArray("{\"processors\": [{\"default\": {}}]}"); client().admin() .cluster() - .putPipeline(new PutPipelineRequest("default_pipeline", defaultPipelineBody, XContentType.JSON)) + .putPipeline(new PutPipelineRequest("default_pipeline", defaultPipelineBody, MediaTypeRegistry.JSON)) .actionGet(); final BytesReference finalPipelineBody = new BytesArray("{\"processors\": [{\"final\": {\"exists\":\"default\"}}]}"); - client().admin().cluster().putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, XContentType.JSON)).actionGet(); + client().admin() + .cluster() + .putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, MediaTypeRegistry.JSON)) + .actionGet(); final Settings settings = Settings.builder() .put(IndexSettings.DEFAULT_PIPELINE.getKey(), "default_pipeline") .put(IndexSettings.FINAL_PIPELINE.getKey(), "final_pipeline") @@ -266,10 +281,13 @@ public void testDefaultAndFinalPipelineFromTemplates() { final BytesReference defaultPipelineBody = new BytesArray("{\"processors\": [{\"default\": {}}]}"); client().admin() .cluster() - .putPipeline(new PutPipelineRequest("default_pipeline", defaultPipelineBody, XContentType.JSON)) + .putPipeline(new PutPipelineRequest("default_pipeline", defaultPipelineBody, MediaTypeRegistry.JSON)) .actionGet(); final BytesReference finalPipelineBody = new BytesArray("{\"processors\": [{\"final\": {\"exists\":\"default\"}}]}"); - client().admin().cluster().putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, XContentType.JSON)).actionGet(); + client().admin() + .cluster() + .putPipeline(new PutPipelineRequest("final_pipeline", finalPipelineBody, MediaTypeRegistry.JSON)) + .actionGet(); final int lowOrder = randomIntBetween(0, Integer.MAX_VALUE - 1); final int highOrder = randomIntBetween(lowOrder + 1, Integer.MAX_VALUE); final int finalPipelineOrder; diff --git a/server/src/internalClusterTest/java/org/opensearch/index/IndexRequestBuilderIT.java b/server/src/internalClusterTest/java/org/opensearch/index/IndexRequestBuilderIT.java index 925a1b50fd6a8..57bdaff645838 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/IndexRequestBuilderIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/IndexRequestBuilderIT.java @@ -36,7 +36,7 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.query.QueryBuilders; import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.hamcrest.OpenSearchAssertions; @@ -54,11 +54,11 @@ public void testSetSource() throws InterruptedException, ExecutionException { map.put("test_field", "foobar"); IndexRequestBuilder[] builders = new IndexRequestBuilder[] { client().prepareIndex("test").setSource("test_field", "foobar"), - client().prepareIndex("test").setSource("{\"test_field\" : \"foobar\"}", XContentType.JSON), - client().prepareIndex("test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}"), XContentType.JSON), - client().prepareIndex("test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}"), XContentType.JSON), + client().prepareIndex("test").setSource("{\"test_field\" : \"foobar\"}", MediaTypeRegistry.JSON), + client().prepareIndex("test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}"), MediaTypeRegistry.JSON), + client().prepareIndex("test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}"), MediaTypeRegistry.JSON), client().prepareIndex("test") - .setSource(BytesReference.toBytes(new BytesArray("{\"test_field\" : \"foobar\"}")), XContentType.JSON), + .setSource(BytesReference.toBytes(new BytesArray("{\"test_field\" : \"foobar\"}")), MediaTypeRegistry.JSON), client().prepareIndex("test").setSource(map) }; indexRandom(true, builders); SearchResponse searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.termQuery("test_field", "foobar")).get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/engine/MaxDocsLimitIT.java b/server/src/internalClusterTest/java/org/opensearch/index/engine/MaxDocsLimitIT.java index 2a47e6ce74e58..2362e6f9f33b5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/engine/MaxDocsLimitIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/engine/MaxDocsLimitIT.java @@ -36,7 +36,7 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.query.MatchAllQueryBuilder; import org.opensearch.index.translog.Translog; @@ -204,7 +204,7 @@ static IndexingResult indexDocs(int numRequests, int numThreads) throws Exceptio phaser.arriveAndAwaitAdvance(); while (completedRequests.incrementAndGet() <= numRequests) { try { - final IndexResponse resp = client().prepareIndex("test").setSource("{}", XContentType.JSON).get(); + final IndexResponse resp = client().prepareIndex("test").setSource("{}", MediaTypeRegistry.JSON).get(); numSuccess.incrementAndGet(); assertThat(resp.status(), equalTo(RestStatus.CREATED)); } catch (IllegalArgumentException e) { diff --git a/server/src/internalClusterTest/java/org/opensearch/index/seqno/GlobalCheckpointSyncIT.java b/server/src/internalClusterTest/java/org/opensearch/index/seqno/GlobalCheckpointSyncIT.java index ce7cb81dbd2df..1524c0eb8982f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/seqno/GlobalCheckpointSyncIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/seqno/GlobalCheckpointSyncIT.java @@ -37,7 +37,7 @@ import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.IndexSettings; import org.opensearch.index.shard.IndexShard; @@ -82,7 +82,7 @@ public void testGlobalCheckpointSyncWithAsyncDurability() throws Exception { for (int j = 0; j < 10; j++) { final String id = Integer.toString(j); - client().prepareIndex("test").setId(id).setSource("{\"foo\": " + id + "}", XContentType.JSON).get(); + client().prepareIndex("test").setId(id).setSource("{\"foo\": " + id + "}", MediaTypeRegistry.JSON).get(); } assertBusy(() -> { @@ -194,7 +194,7 @@ private void runGlobalCheckpointSyncTest( } for (int j = 0; j < numberOfDocuments; j++) { final String id = Integer.toString(index * numberOfDocuments + j); - client().prepareIndex("test").setId(id).setSource("{\"foo\": " + id + "}", XContentType.JSON).get(); + client().prepareIndex("test").setId(id).setSource("{\"foo\": " + id + "}", MediaTypeRegistry.JSON).get(); } try { barrier.await(); @@ -251,7 +251,7 @@ public void testPersistGlobalCheckpoint() throws Exception { } int numDocs = randomIntBetween(1, 20); for (int i = 0; i < numDocs; i++) { - client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", MediaTypeRegistry.JSON).get(); } ensureGreen("test"); assertBusy(() -> { @@ -281,7 +281,7 @@ public void testPersistLocalCheckpoint() { logger.info("numDocs {}", numDocs); long maxSeqNo = 0; for (int i = 0; i < numDocs; i++) { - maxSeqNo = client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get().getSeqNo(); + maxSeqNo = client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", MediaTypeRegistry.JSON).get().getSeqNo(); logger.info("got {}", maxSeqNo); } for (IndicesService indicesService : internalCluster().getDataNodeInstances(IndicesService.class)) { diff --git a/server/src/internalClusterTest/java/org/opensearch/index/shard/GlobalCheckpointListenersIT.java b/server/src/internalClusterTest/java/org/opensearch/index/shard/GlobalCheckpointListenersIT.java index 76ff2f809cb83..d60e852a82ca0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/shard/GlobalCheckpointListenersIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/shard/GlobalCheckpointListenersIT.java @@ -34,7 +34,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.indices.IndicesService; import org.opensearch.test.OpenSearchSingleNodeTestCase; @@ -88,7 +88,7 @@ public void accept(final long g, final Exception e) { } }, null); - client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", MediaTypeRegistry.JSON).get(); assertBusy(() -> assertThat(globalCheckpoint.get(), equalTo((long) index))); // adding a listener expecting a lower global checkpoint should fire immediately final AtomicLong immediateGlobalCheckpint = new AtomicLong(); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java b/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java index d9eeb3f7f8f42..6702690c2f671 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java @@ -61,9 +61,9 @@ import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.env.Environment; import org.opensearch.env.NodeEnvironment; import org.opensearch.env.ShardLock; @@ -176,7 +176,7 @@ public void testLockTryingToDelete() throws Exception { public void testDurableFlagHasEffect() throws Exception { createIndex("test"); ensureGreen(); - client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setSource("{}", MediaTypeRegistry.JSON).get(); IndicesService indicesService = getInstanceFromNode(IndicesService.class); IndexService test = indicesService.indexService(resolveIndex("test")); IndexShard shard = test.getShardOrNull(0); @@ -196,7 +196,7 @@ public void testDurableFlagHasEffect() throws Exception { setDurability(shard, Translog.Durability.REQUEST); assertFalse(needsSync.test(translog)); setDurability(shard, Translog.Durability.ASYNC); - client().prepareIndex("test").setId("2").setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId("2").setSource("{}", MediaTypeRegistry.JSON).get(); assertTrue(needsSync.test(translog)); setDurability(shard, Translog.Durability.REQUEST); client().prepareDelete("test", "1").get(); @@ -208,7 +208,7 @@ public void testDurableFlagHasEffect() throws Exception { setDurability(shard, Translog.Durability.REQUEST); assertNoFailures( client().prepareBulk() - .add(client().prepareIndex("test").setId("3").setSource("{}", XContentType.JSON)) + .add(client().prepareIndex("test").setId("3").setSource("{}", MediaTypeRegistry.JSON)) .add(client().prepareDelete("test", "1")) .get() ); @@ -217,7 +217,7 @@ public void testDurableFlagHasEffect() throws Exception { setDurability(shard, Translog.Durability.ASYNC); assertNoFailures( client().prepareBulk() - .add(client().prepareIndex("test").setId("4").setSource("{}", XContentType.JSON)) + .add(client().prepareIndex("test").setId("4").setSource("{}", MediaTypeRegistry.JSON)) .add(client().prepareDelete("test", "3")) .get() ); @@ -255,7 +255,7 @@ public void testIndexDirIsDeletedWhenShardRemoved() throws Exception { Settings idxSettings = Settings.builder().put(IndexMetadata.SETTING_DATA_PATH, idxPath).build(); createIndex("test", idxSettings); ensureGreen("test"); - client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).setRefreshPolicy(IMMEDIATE).get(); + client().prepareIndex("test").setId("1").setSource("{}", MediaTypeRegistry.JSON).setRefreshPolicy(IMMEDIATE).get(); SearchResponse response = client().prepareSearch("test").get(); assertHitCount(response, 1L); client().admin().indices().prepareDelete("test").get(); @@ -271,7 +271,7 @@ public void testExpectedShardSizeIsPresent() throws InterruptedException { .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) ); for (int i = 0; i < 50; i++) { - client().prepareIndex("test").setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setSource("{}", MediaTypeRegistry.JSON).get(); } ensureGreen("test"); InternalClusterInfoService clusterInfoService = (InternalClusterInfoService) getInstanceFromNode(ClusterInfoService.class); @@ -394,14 +394,14 @@ public void testMaybeFlush() throws Exception { .get(); client().prepareIndex("test") .setId("0") - .setSource("{}", XContentType.JSON) + .setSource("{}", MediaTypeRegistry.JSON) .setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE) .get(); assertFalse(shard.shouldPeriodicallyFlush()); shard.applyIndexOperationOnPrimary( Versions.MATCH_ANY, VersionType.INTERNAL, - new SourceToParse("test", "1", new BytesArray("{}"), XContentType.JSON), + new SourceToParse("test", "1", new BytesArray("{}"), MediaTypeRegistry.JSON), SequenceNumbers.UNASSIGNED_SEQ_NO, 0, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, @@ -413,7 +413,7 @@ public void testMaybeFlush() throws Exception { assertThat(shard.flushStats().getTotal(), equalTo(0L)); client().prepareIndex("test") .setId("2") - .setSource("{}", XContentType.JSON) + .setSource("{}", MediaTypeRegistry.JSON) .setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE) .get(); assertThat(shard.getLastKnownGlobalCheckpoint(), equalTo(2L)); @@ -454,7 +454,7 @@ public void testMaybeFlush() throws Exception { final FlushStats flushStats = shard.flushStats(); logger.info( "--> translog stats [{}] gen [{}] commit_stats [{}] flush_stats [{}/{}]", - Strings.toString(XContentType.JSON, translogStats), + Strings.toString(MediaTypeRegistry.JSON, translogStats), translog.getGeneration().translogFileGeneration, commitStats.getUserData(), flushStats.getPeriodic(), @@ -486,7 +486,7 @@ public void testMaybeRollTranslogGeneration() throws Exception { final Engine.IndexResult result = shard.applyIndexOperationOnPrimary( Versions.MATCH_ANY, VersionType.INTERNAL, - new SourceToParse("test", "1", new BytesArray("{}"), XContentType.JSON), + new SourceToParse("test", "1", new BytesArray("{}"), MediaTypeRegistry.JSON), SequenceNumbers.UNASSIGNED_SEQ_NO, 0, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, @@ -522,7 +522,7 @@ public void testStressMaybeFlushOrRollTranslogGeneration() throws Exception { client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get(); client().prepareIndex("test") .setId("0") - .setSource("{}", XContentType.JSON) + .setSource("{}", MediaTypeRegistry.JSON) .setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE) .get(); assertFalse(shard.shouldPeriodicallyFlush()); @@ -547,7 +547,7 @@ public void testStressMaybeFlushOrRollTranslogGeneration() throws Exception { final CheckedRunnable check; if (flush) { final FlushStats initialStats = shard.flushStats(); - client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setSource("{}", MediaTypeRegistry.JSON).get(); check = () -> { assertFalse(shard.shouldPeriodicallyFlush()); final FlushStats currentStats = shard.flushStats(); @@ -572,7 +572,7 @@ public void testStressMaybeFlushOrRollTranslogGeneration() throws Exception { }; } else { final long generation = getTranslog(shard).currentFileGeneration(); - client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setSource("{}", MediaTypeRegistry.JSON).get(); check = () -> { assertFalse(shard.shouldRollTranslogGeneration()); assertEquals(generation + 1, getTranslog(shard).currentFileGeneration()); @@ -593,7 +593,7 @@ public void testFlushStats() throws Exception { client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get(); final int numDocs = between(10, 100); for (int i = 0; i < numDocs; i++) { - client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", MediaTypeRegistry.JSON).get(); } // A flush stats may include the new total count but the old period count - assert eventually. assertBusy(() -> { @@ -604,7 +604,7 @@ public void testFlushStats() throws Exception { settings = Settings.builder().put("index.translog.flush_threshold_size", (String) null).build(); client().admin().indices().prepareUpdateSettings("test").setSettings(settings).get(); - client().prepareIndex("test").setId(UUIDs.randomBase64UUID()).setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId(UUIDs.randomBase64UUID()).setSource("{}", MediaTypeRegistry.JSON).get(); client().admin().indices().prepareFlush("test").setForce(randomBoolean()).setWaitIfOngoing(true).get(); final FlushStats flushStats = client().admin().indices().prepareStats("test").clear().setFlush(true).get().getTotal().flush; assertThat(flushStats.getTotal(), greaterThan(flushStats.getPeriodic())); @@ -616,9 +616,9 @@ public void testShardHasMemoryBufferOnTranslogRecover() throws Throwable { IndicesService indicesService = getInstanceFromNode(IndicesService.class); IndexService indexService = indicesService.indexService(resolveIndex("test")); IndexShard shard = indexService.getShardOrNull(0); - client().prepareIndex("test").setId("0").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("0").setSource("{\"foo\" : \"bar\"}", MediaTypeRegistry.JSON).get(); client().prepareDelete("test", "0").get(); - client().prepareIndex("test").setId("1").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).setRefreshPolicy(IMMEDIATE).get(); + client().prepareIndex("test").setId("1").setSource("{\"foo\" : \"bar\"}", MediaTypeRegistry.JSON).setRefreshPolicy(IMMEDIATE).get(); CheckedFunction wrapper = directoryReader -> directoryReader; shard.close("simon says", false, false); @@ -734,7 +734,7 @@ public void testInvalidateIndicesRequestCacheWhenRollbackEngine() throws Excepti final SearchRequest countRequest = new SearchRequest("test").source(new SearchSourceBuilder().size(0)); final long numDocs = between(10, 20); for (int i = 0; i < numDocs; i++) { - client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", MediaTypeRegistry.JSON).get(); if (randomBoolean()) { shard.refresh("test"); } @@ -756,7 +756,7 @@ public void testInvalidateIndicesRequestCacheWhenRollbackEngine() throws Excepti final long moreDocs = between(10, 20); for (int i = 0; i < moreDocs; i++) { - client().prepareIndex("test").setId(Long.toString(i + numDocs)).setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId(Long.toString(i + numDocs)).setSource("{}", MediaTypeRegistry.JSON).get(); if (randomBoolean()) { shard.refresh("test"); } @@ -787,7 +787,7 @@ public void testShardChangesWithDefaultDocType() throws Exception { int numOps = between(1, 10); for (int i = 0; i < numOps; i++) { if (randomBoolean()) { - client().prepareIndex("index").setId(randomFrom("1", "2")).setSource("{}", XContentType.JSON).get(); + client().prepareIndex("index").setId(randomFrom("1", "2")).setSource("{}", MediaTypeRegistry.JSON).get(); } else { client().prepareDelete("index", randomFrom("1", "2")).get(); } @@ -850,7 +850,7 @@ public void testLimitNumberOfRetainedTranslogFiles() throws Exception { } }; for (int i = 0; i < 100; i++) { - client().prepareIndex(indexName).setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get(); + client().prepareIndex(indexName).setId(Integer.toString(i)).setSource("{}", MediaTypeRegistry.JSON).get(); if (randomInt(100) < 10) { client().admin().indices().prepareFlush(indexName).setWaitIfOngoing(true).get(); checkTranslog.run(); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/shard/SearchIdleIT.java b/server/src/internalClusterTest/java/org/opensearch/index/shard/SearchIdleIT.java index 9382960b906e3..7a02f7831fb59 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/shard/SearchIdleIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/shard/SearchIdleIT.java @@ -38,7 +38,7 @@ import org.opensearch.action.index.IndexResponse; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.IndexSettings; import org.opensearch.test.OpenSearchSingleNodeTestCase; @@ -102,7 +102,7 @@ private void runTestAutomaticRefresh(final IntToLongFunction count) throws Inter int numDocs = scaledRandomIntBetween(25, 100); totalNumDocs.set(numDocs); CountDownLatch indexingDone = new CountDownLatch(numDocs); - client().prepareIndex("test").setId("0").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("0").setSource("{\"foo\" : \"bar\"}", MediaTypeRegistry.JSON).get(); indexingDone.countDown(); // one doc is indexed above blocking IndexShard shard = indexService.getShard(0); boolean hasRefreshed = shard.scheduledRefresh(); @@ -135,7 +135,7 @@ private void runTestAutomaticRefresh(final IntToLongFunction count) throws Inter for (int i = 1; i < numDocs; i++) { client().prepareIndex("test") .setId("" + i) - .setSource("{\"foo\" : \"bar\"}", XContentType.JSON) + .setSource("{\"foo\" : \"bar\"}", MediaTypeRegistry.JSON) .execute(new ActionListener() { @Override public void onResponse(IndexResponse indexResponse) { @@ -159,7 +159,7 @@ public void testPendingRefreshWithIntervalChange() throws Exception { IndexService indexService = createIndex("test", builder.build()); assertFalse(indexService.getIndexSettings().isExplicitRefresh()); ensureGreen(); - client().prepareIndex("test").setId("0").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("0").setSource("{\"foo\" : \"bar\"}", MediaTypeRegistry.JSON).get(); IndexShard shard = indexService.getShard(0); assertFalse(shard.scheduledRefresh()); assertTrue(shard.isSearchIdle()); @@ -167,7 +167,7 @@ public void testPendingRefreshWithIntervalChange() throws Exception { client().admin().indices().prepareRefresh().execute(ActionListener.wrap(refreshLatch::countDown));// async on purpose to make sure // it happens concurrently assertHitCount(client().prepareSearch().get(), 1); - client().prepareIndex("test").setId("1").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setSource("{\"foo\" : \"bar\"}", MediaTypeRegistry.JSON).get(); assertFalse(shard.scheduledRefresh()); assertTrue(shard.hasRefreshPending()); @@ -186,7 +186,7 @@ public void testPendingRefreshWithIntervalChange() throws Exception { // We need to ensure a `scheduledRefresh` triggered by the internal refresh setting update is executed before we index a new doc; // otherwise, it will compete to call `Engine#maybeRefresh` with the `scheduledRefresh` that we are going to verify. ensureNoPendingScheduledRefresh(indexService.getThreadPool()); - client().prepareIndex("test").setId("2").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("2").setSource("{\"foo\" : \"bar\"}", MediaTypeRegistry.JSON).get(); assertTrue(shard.scheduledRefresh()); assertFalse(shard.hasRefreshPending()); assertTrue(shard.isSearchIdle()); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/DateMathIndexExpressionsIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/DateMathIndexExpressionsIntegrationIT.java index 7236c32697384..b7024ff091e66 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/DateMathIndexExpressionsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/DateMathIndexExpressionsIntegrationIT.java @@ -41,7 +41,7 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.IndexMetadata; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchIntegTestCase; import org.joda.time.DateTime; @@ -71,9 +71,9 @@ public void testIndexNameDateMathExpressions() { String dateMathExp1 = "<.marvel-{now/d}>"; String dateMathExp2 = "<.marvel-{now/d-1d}>"; String dateMathExp3 = "<.marvel-{now/d-2d}>"; - client().prepareIndex(dateMathExp1).setId("1").setSource("{}", XContentType.JSON).get(); - client().prepareIndex(dateMathExp2).setId("2").setSource("{}", XContentType.JSON).get(); - client().prepareIndex(dateMathExp3).setId("3").setSource("{}", XContentType.JSON).get(); + client().prepareIndex(dateMathExp1).setId("1").setSource("{}", MediaTypeRegistry.JSON).get(); + client().prepareIndex(dateMathExp2).setId("2").setSource("{}", MediaTypeRegistry.JSON).get(); + client().prepareIndex(dateMathExp3).setId("3").setSource("{}", MediaTypeRegistry.JSON).get(); refresh(); SearchResponse searchResponse = client().prepareSearch(dateMathExp1, dateMathExp2, dateMathExp3).get(); @@ -131,9 +131,9 @@ public void testAutoCreateIndexWithDateMathExpression() throws Exception { String dateMathExp1 = "<.marvel-{now/d}>"; String dateMathExp2 = "<.marvel-{now/d-1d}>"; String dateMathExp3 = "<.marvel-{now/d-2d}>"; - client().prepareIndex(dateMathExp1).setId("1").setSource("{}", XContentType.JSON).get(); - client().prepareIndex(dateMathExp2).setId("2").setSource("{}", XContentType.JSON).get(); - client().prepareIndex(dateMathExp3).setId("3").setSource("{}", XContentType.JSON).get(); + client().prepareIndex(dateMathExp1).setId("1").setSource("{}", MediaTypeRegistry.JSON).get(); + client().prepareIndex(dateMathExp2).setId("2").setSource("{}", MediaTypeRegistry.JSON).get(); + client().prepareIndex(dateMathExp3).setId("3").setSource("{}", MediaTypeRegistry.JSON).get(); refresh(); SearchResponse searchResponse = client().prepareSearch(dateMathExp1, dateMathExp2, dateMathExp3).get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/UpdateMappingIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/UpdateMappingIntegrationIT.java index da3dcdc6b750e..78011e4dd4beb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/UpdateMappingIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/UpdateMappingIntegrationIT.java @@ -43,9 +43,9 @@ import org.opensearch.common.Priority; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.common.xcontent.support.XContentMapValues; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.index.mapper.MapperService; @@ -153,7 +153,7 @@ public void testUpdateMappingWithoutType() { AcknowledgedResponse putMappingResponse = client().admin() .indices() .preparePutMapping("test") - .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON) + .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", MediaTypeRegistry.JSON) .execute() .actionGet(); @@ -178,7 +178,7 @@ public void testUpdateMappingWithoutTypeMultiObjects() { AcknowledgedResponse putMappingResponse = client().admin() .indices() .preparePutMapping("test") - .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON) + .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", MediaTypeRegistry.JSON) .execute() .actionGet(); @@ -207,7 +207,7 @@ public void testUpdateMappingWithConflicts() { .preparePutMapping("test") .setSource( "{\"" + MapperService.SINGLE_MAPPING_NAME + "\":{\"properties\":{\"body\":{\"type\":\"integer\"}}}}", - XContentType.JSON + MediaTypeRegistry.JSON ) .execute() .actionGet(); @@ -230,7 +230,7 @@ public void testUpdateMappingWithNormsConflicts() { .preparePutMapping("test") .setSource( "{\"" + MapperService.SINGLE_MAPPING_NAME + "\":{\"properties\":{\"body\":{\"type\":\"text\", \"norms\": true }}}}", - XContentType.JSON + MediaTypeRegistry.JSON ) .execute() .actionGet(); @@ -256,7 +256,7 @@ public void testUpdateMappingNoChanges() { AcknowledgedResponse putMappingResponse = client().admin() .indices() .preparePutMapping("test") - .setSource("{\"properties\":{\"body\":{\"type\":\"text\"}}}", XContentType.JSON) + .setSource("{\"properties\":{\"body\":{\"type\":\"text\"}}}", MediaTypeRegistry.JSON) .execute() .actionGet(); @@ -347,7 +347,7 @@ public void testPutMappingsWithBlocks() { client().admin() .indices() .preparePutMapping("test") - .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON) + .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", MediaTypeRegistry.JSON) ); } finally { disableIndexBlock("test", block); @@ -361,7 +361,7 @@ public void testPutMappingsWithBlocks() { client().admin() .indices() .preparePutMapping("test") - .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON) + .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", MediaTypeRegistry.JSON) ); } finally { disableIndexBlock("test", block); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java index efd43ec5ad82d..6b3e8a227118f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java @@ -82,7 +82,7 @@ import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.gateway.ReplicaShardAllocatorIT; import org.opensearch.core.index.Index; import org.opensearch.index.IndexService; @@ -899,14 +899,14 @@ public void testTransientErrorsDuringRecoveryAreRetried() throws Exception { // is a mix of file chunks and translog ops int threeFourths = (int) (numDocs * 0.75); for (int i = 0; i < threeFourths; i++) { - requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON)); + requests.add(client().prepareIndex(indexName).setSource("{}", MediaTypeRegistry.JSON)); } indexRandom(true, requests); flush(indexName); requests.clear(); for (int i = threeFourths; i < numDocs; i++) { - requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON)); + requests.add(client().prepareIndex(indexName).setSource("{}", MediaTypeRegistry.JSON)); } indexRandom(true, requests); ensureSearchable(indexName); @@ -1098,7 +1098,7 @@ public void testDisconnectsWhileRecovering() throws Exception { List requests = new ArrayList<>(); int numDocs = scaledRandomIntBetween(25, 250); for (int i = 0; i < numDocs; i++) { - requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON)); + requests.add(client().prepareIndex(indexName).setSource("{}", MediaTypeRegistry.JSON)); } indexRandom(true, requests); ensureSearchable(indexName); @@ -1252,7 +1252,7 @@ public void testDisconnectsDuringRecovery() throws Exception { List requests = new ArrayList<>(); int numDocs = scaledRandomIntBetween(25, 250); for (int i = 0; i < numDocs; i++) { - requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON)); + requests.add(client().prepareIndex(indexName).setSource("{}", MediaTypeRegistry.JSON)); } indexRandom(true, requests); ensureSearchable(indexName); @@ -1395,7 +1395,7 @@ public void testHistoryRetention() throws Exception { final List requests = new ArrayList<>(); final int replicatedDocCount = scaledRandomIntBetween(25, 250); while (requests.size() < replicatedDocCount) { - requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON)); + requests.add(client().prepareIndex(indexName).setSource("{}", MediaTypeRegistry.JSON)); } indexRandom(true, requests); if (randomBoolean()) { @@ -1417,7 +1417,7 @@ public void testHistoryRetention() throws Exception { final int numNewDocs = scaledRandomIntBetween(25, 250); for (int i = 0; i < numNewDocs; i++) { - client().prepareIndex(indexName).setSource("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); + client().prepareIndex(indexName).setSource("{}", MediaTypeRegistry.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); } // Flush twice to update the safe commit's local checkpoint assertThat(client().admin().indices().prepareFlush(indexName).setForce(true).execute().get().getFailedShards(), equalTo(0)); @@ -1458,7 +1458,7 @@ public void testDoNotInfinitelyWaitForMapping() { for (int i = 0; i < numDocs; i++) { client().prepareIndex("test") .setId("u" + i) - .setSource(singletonMap("test_field", Integer.toString(i)), XContentType.JSON) + .setSource(singletonMap("test_field", Integer.toString(i)), MediaTypeRegistry.JSON) .get(); } Semaphore recoveryBlocked = new Semaphore(1); @@ -1610,7 +1610,7 @@ public void testRecoverLocallyUpToGlobalCheckpoint() throws Exception { throw new AssertionError( "expect an operation-based recovery:" + "retention leases" - + Strings.toString(XContentType.JSON, retentionLeases) + + Strings.toString(MediaTypeRegistry.JSON, retentionLeases) + "]" ); } @@ -2187,7 +2187,10 @@ public void testPeerRecoveryTrimsLocalTranslog() throws Exception { while (stopped.get() == false) { try { IndexResponse response = client().prepareIndex(indexName) - .setSource(Collections.singletonMap("f" + randomIntBetween(1, 10), randomNonNegativeLong()), XContentType.JSON) + .setSource( + Collections.singletonMap("f" + randomIntBetween(1, 10), randomNonNegativeLong()), + MediaTypeRegistry.JSON + ) .get(); assertThat(response.getResult(), isOneOf(CREATED, UPDATED)); } catch (IllegalStateException | OpenSearchException ignored) {} diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java index 35f2b99c94625..233c8811ca6f4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java @@ -55,8 +55,8 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexModule; import org.opensearch.index.IndexService; import org.opensearch.index.IndexSettings; @@ -1012,7 +1012,10 @@ public void testCompletionFieldsParam() throws Exception { ); ensureGreen(); - client().prepareIndex("test1").setId(Integer.toString(1)).setSource("{\"bar\":\"bar\",\"baz\":\"baz\"}", XContentType.JSON).get(); + client().prepareIndex("test1") + .setId(Integer.toString(1)) + .setSource("{\"bar\":\"bar\",\"baz\":\"baz\"}", MediaTypeRegistry.JSON) + .get(); refresh(); IndicesStatsRequestBuilder builder = client().admin().indices().prepareStats(); @@ -1357,7 +1360,7 @@ public void testConcurrentIndexingAndStatsRequests() throws BrokenBarrierExcepti } while (!stop.get()) { final String id = Integer.toString(idGenerator.incrementAndGet()); - final IndexResponse response = client().prepareIndex("test").setId(id).setSource("{}", XContentType.JSON).get(); + final IndexResponse response = client().prepareIndex("test").setId(id).setSource("{}", MediaTypeRegistry.JSON).get(); assertThat(response.getResult(), equalTo(DocWriteResponse.Result.CREATED)); } }); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java index a6381b4450010..3be234b393a7a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java @@ -50,7 +50,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.SettingsException; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.mapper.MapperParsingException; import org.opensearch.index.query.QueryBuilders; import org.opensearch.indices.InvalidAliasNameException; @@ -478,7 +478,7 @@ public void testBrokenMapping() throws Exception { .indices() .preparePutTemplate("template_1") .setPatterns(Collections.singletonList("te*")) - .setMapping("{\"foo\": \"abcde\"}", XContentType.JSON) + .setMapping("{\"foo\": \"abcde\"}", MediaTypeRegistry.JSON) .get() ); assertThat(e.getMessage(), containsString("Failed to parse mapping ")); @@ -591,7 +591,7 @@ public void testIndexTemplateWithAliasesInSource() { + " }\n" + "}" ), - XContentType.JSON + MediaTypeRegistry.JSON ) .get(); @@ -803,8 +803,8 @@ public void testStrictAliasParsingInIndicesCreatedViaTemplates() throws Exceptio .addAlias(new Alias("alias4").filter(termQuery("field", "value"))) .get(); - client().prepareIndex("a1").setId("test").setSource("{}", XContentType.JSON).get(); - BulkResponse response = client().prepareBulk().add(new IndexRequest("a2").id("test").source("{}", XContentType.JSON)).get(); + client().prepareIndex("a1").setId("test").setSource("{}", MediaTypeRegistry.JSON).get(); + BulkResponse response = client().prepareBulk().add(new IndexRequest("a2").id("test").source("{}", MediaTypeRegistry.JSON)).get(); assertThat(response.hasFailures(), is(false)); assertThat(response.getItems()[0].isFailed(), equalTo(false)); assertThat(response.getItems()[0].getIndex(), equalTo("a2")); @@ -819,9 +819,9 @@ public void testStrictAliasParsingInIndicesCreatedViaTemplates() throws Exceptio // So the aliases defined in the index template for this index will not fail // even though the fields in the alias fields don't exist yet and indexing into // an index that doesn't exist yet will succeed - client().prepareIndex("b1").setId("test").setSource("{}", XContentType.JSON).get(); + client().prepareIndex("b1").setId("test").setSource("{}", MediaTypeRegistry.JSON).get(); - response = client().prepareBulk().add(new IndexRequest("b2").id("test").source("{}", XContentType.JSON)).get(); + response = client().prepareBulk().add(new IndexRequest("b2").id("test").source("{}", MediaTypeRegistry.JSON)).get(); assertThat(response.hasFailures(), is(false)); assertThat(response.getItems()[0].isFailed(), equalTo(false)); assertThat(response.getItems()[0].getId(), equalTo("test")); @@ -854,7 +854,7 @@ public void testCombineTemplates() throws Exception { + " }\n" + " }\n" + " }\n", - XContentType.JSON + MediaTypeRegistry.JSON ) .get(); @@ -992,7 +992,7 @@ public void testPartitionedTemplate() throws Exception { .indices() .preparePutTemplate("template_2") .setPatterns(Collections.singletonList("te*")) - .setMapping("{\"_routing\":{\"required\":false}}", XContentType.JSON) + .setMapping("{\"_routing\":{\"required\":false}}", MediaTypeRegistry.JSON) .setSettings(Settings.builder().put("index.number_of_shards", "6").put("index.routing_partition_size", "3")) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/ingest/IngestClientIT.java b/server/src/internalClusterTest/java/org/opensearch/ingest/IngestClientIT.java index 49d09cada59b3..17fd54ff8fdb6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/ingest/IngestClientIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/ingest/IngestClientIT.java @@ -53,8 +53,8 @@ import org.opensearch.client.Requests; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -100,7 +100,7 @@ public void testSimulate() throws Exception { .endArray() .endObject() ); - client().admin().cluster().preparePutPipeline("_id", pipelineSource, XContentType.JSON).get(); + client().admin().cluster().preparePutPipeline("_id", pipelineSource, MediaTypeRegistry.JSON).get(); GetPipelineResponse getResponse = client().admin().cluster().prepareGetPipeline("_id").get(); assertThat(getResponse.isFound(), is(true)); assertThat(getResponse.pipelines().size(), equalTo(1)); @@ -122,9 +122,9 @@ public void testSimulate() throws Exception { ); SimulatePipelineResponse response; if (randomBoolean()) { - response = client().admin().cluster().prepareSimulatePipeline(bytes, XContentType.JSON).setId("_id").get(); + response = client().admin().cluster().prepareSimulatePipeline(bytes, MediaTypeRegistry.JSON).setId("_id").get(); } else { - SimulatePipelineRequest request = new SimulatePipelineRequest(bytes, XContentType.JSON); + SimulatePipelineRequest request = new SimulatePipelineRequest(bytes, MediaTypeRegistry.JSON); request.setId("_id"); response = client().admin().cluster().simulatePipeline(request).get(); } @@ -160,7 +160,7 @@ public void testBulkWithIngestFailures() throws Exception { .endArray() .endObject() ); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, MediaTypeRegistry.JSON); client().admin().cluster().putPipeline(putPipelineRequest).get(); int numRequests = scaledRandomIntBetween(32, 128); @@ -211,7 +211,7 @@ public void testBulkWithUpsert() throws Exception { .endArray() .endObject() ); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, MediaTypeRegistry.JSON); client().admin().cluster().putPipeline(putPipelineRequest).get(); BulkRequest bulkRequest = new BulkRequest(); @@ -220,7 +220,7 @@ public void testBulkWithUpsert() throws Exception { bulkRequest.add(indexRequest); UpdateRequest updateRequest = new UpdateRequest("index", "2"); updateRequest.doc("{}", Requests.INDEX_CONTENT_TYPE); - updateRequest.upsert("{\"field1\":\"upserted_val\"}", XContentType.JSON).upsertRequest().setPipeline("_id"); + updateRequest.upsert("{\"field1\":\"upserted_val\"}", MediaTypeRegistry.JSON).upsertRequest().setPipeline("_id"); bulkRequest.add(updateRequest); BulkResponse response = client().bulk(bulkRequest).actionGet(); @@ -246,7 +246,7 @@ public void test() throws Exception { .endArray() .endObject() ); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, MediaTypeRegistry.JSON); client().admin().cluster().putPipeline(putPipelineRequest).get(); GetPipelineRequest getPipelineRequest = new GetPipelineRequest("_id"); @@ -290,7 +290,7 @@ public void testPutWithPipelineFactoryError() throws Exception { .endArray() .endObject() ); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id2", source, XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id2", source, MediaTypeRegistry.JSON); Exception e = expectThrows( OpenSearchParseException.class, () -> client().admin().cluster().putPipeline(putPipelineRequest).actionGet() @@ -314,7 +314,7 @@ public void testWithDedicatedClusterManager() throws Exception { .endArray() .endObject() ); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, MediaTypeRegistry.JSON); client().admin().cluster().putPipeline(putPipelineRequest).get(); BulkItemResponse item = client(clusterManagerOnlyNode).prepareBulk() @@ -340,7 +340,7 @@ public void testPipelineOriginHeader() throws Exception { source.endArray(); } source.endObject(); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("1", BytesReference.bytes(source), XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("1", BytesReference.bytes(source), MediaTypeRegistry.JSON); client().admin().cluster().putPipeline(putPipelineRequest).get(); } { @@ -357,7 +357,7 @@ public void testPipelineOriginHeader() throws Exception { source.endArray(); } source.endObject(); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("2", BytesReference.bytes(source), XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("2", BytesReference.bytes(source), MediaTypeRegistry.JSON); client().admin().cluster().putPipeline(putPipelineRequest).get(); } { @@ -373,13 +373,13 @@ public void testPipelineOriginHeader() throws Exception { source.endArray(); } source.endObject(); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("3", BytesReference.bytes(source), XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("3", BytesReference.bytes(source), MediaTypeRegistry.JSON); client().admin().cluster().putPipeline(putPipelineRequest).get(); } Exception e = expectThrows(Exception.class, () -> { IndexRequest indexRequest = new IndexRequest("test"); - indexRequest.source("{}", XContentType.JSON); + indexRequest.source("{}", MediaTypeRegistry.JSON); indexRequest.setPipeline("1"); client().index(indexRequest).get(); }); @@ -413,7 +413,7 @@ public void testPipelineProcessorOnFailure() throws Exception { source.endArray(); } source.endObject(); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("1", BytesReference.bytes(source), XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("1", BytesReference.bytes(source), MediaTypeRegistry.JSON); client().admin().cluster().putPipeline(putPipelineRequest).get(); } { @@ -430,7 +430,7 @@ public void testPipelineProcessorOnFailure() throws Exception { source.endArray(); } source.endObject(); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("2", BytesReference.bytes(source), XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("2", BytesReference.bytes(source), MediaTypeRegistry.JSON); client().admin().cluster().putPipeline(putPipelineRequest).get(); } { @@ -446,11 +446,11 @@ public void testPipelineProcessorOnFailure() throws Exception { source.endArray(); } source.endObject(); - PutPipelineRequest putPipelineRequest = new PutPipelineRequest("3", BytesReference.bytes(source), XContentType.JSON); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("3", BytesReference.bytes(source), MediaTypeRegistry.JSON); client().admin().cluster().putPipeline(putPipelineRequest).get(); } - client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).setPipeline("1").get(); + client().prepareIndex("test").setId("1").setSource("{}", MediaTypeRegistry.JSON).setPipeline("1").get(); Map inserted = client().prepareGet("test", "1").get().getSourceAsMap(); assertThat(inserted.get("readme"), equalTo("pipeline with id [3] is a bad pipeline")); } diff --git a/server/src/internalClusterTest/java/org/opensearch/ingest/IngestProcessorNotInstalledOnAllNodesIT.java b/server/src/internalClusterTest/java/org/opensearch/ingest/IngestProcessorNotInstalledOnAllNodesIT.java index 4b4a0d9d0157c..38f1375bc7504 100644 --- a/server/src/internalClusterTest/java/org/opensearch/ingest/IngestProcessorNotInstalledOnAllNodesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/ingest/IngestProcessorNotInstalledOnAllNodesIT.java @@ -35,7 +35,7 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.node.NodeService; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -84,7 +84,7 @@ public void testFailPipelineCreation() throws Exception { ensureStableCluster(2, node2); try { - client().admin().cluster().preparePutPipeline("_id", pipelineSource, XContentType.JSON).get(); + client().admin().cluster().preparePutPipeline("_id", pipelineSource, MediaTypeRegistry.JSON).get(); fail("exception expected"); } catch (OpenSearchParseException e) { assertThat(e.getMessage(), containsString("Processor type [test] is not installed on node")); @@ -97,7 +97,7 @@ public void testFailPipelineCreationProcessorNotInstalledOnClusterManagerNode() internalCluster().startNode(); try { - client().admin().cluster().preparePutPipeline("_id", pipelineSource, XContentType.JSON).get(); + client().admin().cluster().preparePutPipeline("_id", pipelineSource, MediaTypeRegistry.JSON).get(); fail("exception expected"); } catch (OpenSearchParseException e) { assertThat(e.getMessage(), equalTo("No processor type exists with name [test]")); @@ -110,7 +110,7 @@ public void testFailStartNode() throws Exception { installPlugin = true; String node1 = internalCluster().startNode(); - AcknowledgedResponse response = client().admin().cluster().preparePutPipeline("_id", pipelineSource, XContentType.JSON).get(); + AcknowledgedResponse response = client().admin().cluster().preparePutPipeline("_id", pipelineSource, MediaTypeRegistry.JSON).get(); assertThat(response.isAcknowledged(), is(true)); Pipeline pipeline = internalCluster().getInstance(NodeService.class, node1).getIngestService().getPipeline("_id"); assertThat(pipeline, notNullValue()); diff --git a/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java b/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java index 7109d8e331ce3..3b72ff251c4fa 100644 --- a/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java @@ -41,7 +41,7 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.search.fetch.subphase.FetchSourceContext; import org.opensearch.test.OpenSearchIntegTestCase; @@ -159,7 +159,7 @@ public void testThatSourceFilteringIsSupported() throws Exception { .endObject() ); for (int i = 0; i < 100; i++) { - client().prepareIndex("test").setId(Integer.toString(i)).setSource(sourceBytesRef, XContentType.JSON).get(); + client().prepareIndex("test").setId(Integer.toString(i)).setSource(sourceBytesRef, MediaTypeRegistry.JSON).get(); } MultiGetRequestBuilder request = client().prepareMultiGet(); diff --git a/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java b/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java index b3821c7896b8e..796f253990bcb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java @@ -54,7 +54,7 @@ import org.opensearch.common.Priority; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.env.NodeEnvironment; import org.opensearch.index.IndexService; import org.opensearch.index.IndexSettings; @@ -374,12 +374,12 @@ public void indexShardStateChanged( List builders1 = new ArrayList<>(); for (int numDocs = randomIntBetween(10, 30); numDocs > 0; numDocs--) { - builders1.add(client().prepareIndex("test").setSource("{}", XContentType.JSON)); + builders1.add(client().prepareIndex("test").setSource("{}", MediaTypeRegistry.JSON)); } List builders2 = new ArrayList<>(); for (int numDocs = randomIntBetween(10, 30); numDocs > 0; numDocs--) { - builders2.add(client().prepareIndex("test").setSource("{}", XContentType.JSON)); + builders2.add(client().prepareIndex("test").setSource("{}", MediaTypeRegistry.JSON)); } logger.info("--> START relocate the shard from {} to {}", nodes[fromNode], nodes[toNode]); @@ -439,7 +439,7 @@ public void testCancellationCleansTempFiles() throws Exception { List requests = new ArrayList<>(); int numDocs = scaledRandomIntBetween(25, 250); for (int i = 0; i < numDocs; i++) { - requests.add(client().prepareIndex(indexName).setSource("{}", XContentType.JSON)); + requests.add(client().prepareIndex(indexName).setSource("{}", MediaTypeRegistry.JSON)); } indexRandom(true, requests); assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("3").setWaitForGreenStatus().get().isTimedOut()); diff --git a/server/src/internalClusterTest/java/org/opensearch/recovery/SimpleRecoveryIT.java b/server/src/internalClusterTest/java/org/opensearch/recovery/SimpleRecoveryIT.java index 4ebb840c600d2..ef4f5c3eeea86 100644 --- a/server/src/internalClusterTest/java/org/opensearch/recovery/SimpleRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/recovery/SimpleRecoveryIT.java @@ -36,7 +36,7 @@ import org.opensearch.action.admin.indices.refresh.RefreshResponse; import org.opensearch.action.get.GetResponse; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchIntegTestCase; import static org.opensearch.client.Requests.flushRequest; @@ -67,12 +67,12 @@ public void testSimpleRecovery() throws Exception { NumShards numShards = getNumShards("test"); - client().index(indexRequest("test").id("1").source(source("1", "test"), XContentType.JSON)).actionGet(); + client().index(indexRequest("test").id("1").source(source("1", "test"), MediaTypeRegistry.JSON)).actionGet(); FlushResponse flushResponse = client().admin().indices().flush(flushRequest("test")).actionGet(); assertThat(flushResponse.getTotalShards(), equalTo(numShards.totalNumShards)); assertThat(flushResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries)); assertThat(flushResponse.getFailedShards(), equalTo(0)); - client().index(indexRequest("test").id("2").source(source("2", "test"), XContentType.JSON)).actionGet(); + client().index(indexRequest("test").id("2").source(source("2", "test"), MediaTypeRegistry.JSON)).actionGet(); RefreshResponse refreshResponse = client().admin().indices().refresh(refreshRequest("test")).actionGet(); assertThat(refreshResponse.getTotalShards(), equalTo(numShards.totalNumShards)); assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries)); diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/PrimaryTermValidationIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/PrimaryTermValidationIT.java index ee32c880257d1..9e42e5b4d8565 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/PrimaryTermValidationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/PrimaryTermValidationIT.java @@ -21,7 +21,7 @@ import org.opensearch.common.UUIDs; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.shard.ShardNotFoundException; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -163,7 +163,7 @@ public void testPrimaryTermValidation() throws Exception { private IndexResponse indexSameDoc(String nodeName, String indexName) { return client(nodeName).prepareIndex(indexName) .setId(UUIDs.randomBase64UUID()) - .setSource("{\"foo\" : \"bar\"}", XContentType.JSON) + .setSource("{\"foo\" : \"bar\"}", MediaTypeRegistry.JSON) .get(); } } diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBackpressureIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBackpressureIT.java index 9641c013bf226..703cb7da3d009 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBackpressureIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBackpressureIT.java @@ -13,10 +13,10 @@ import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; import org.opensearch.common.settings.Settings; import org.opensearch.core.common.unit.ByteSizeUnit; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.remote.RemoteSegmentTransferTracker; import org.opensearch.repositories.RepositoriesService; import org.opensearch.snapshots.mockstore.MockRepository; @@ -128,7 +128,7 @@ private RemoteSegmentTransferTracker.Stats stats() { private void indexDocAndRefresh(BytesReference source, int iterations) { for (int i = 0; i < iterations; i++) { - client().prepareIndex(INDEX_NAME).setSource(source, XContentType.JSON).get(); + client().prepareIndex(INDEX_NAME).setSource(source, MediaTypeRegistry.JSON).get(); refresh(INDEX_NAME); } } diff --git a/server/src/internalClusterTest/java/org/opensearch/script/StoredScriptsIT.java b/server/src/internalClusterTest/java/org/opensearch/script/StoredScriptsIT.java index 448bbf5e883ec..583693741f3dd 100644 --- a/server/src/internalClusterTest/java/org/opensearch/script/StoredScriptsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/script/StoredScriptsIT.java @@ -33,7 +33,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -69,7 +69,7 @@ public void testBasics() { .cluster() .preparePutStoredScript() .setId("foobar") - .setContent(new BytesArray("{\"script\": {\"lang\": \"" + LANG + "\", \"source\": \"1\"} }"), XContentType.JSON) + .setContent(new BytesArray("{\"script\": {\"lang\": \"" + LANG + "\", \"source\": \"1\"} }"), MediaTypeRegistry.JSON) ); String script = client().admin().cluster().prepareGetStoredScript("foobar").get().getSource().getSource(); assertNotNull(script); @@ -81,7 +81,12 @@ public void testBasics() { IllegalArgumentException e = expectThrows( IllegalArgumentException.class, - () -> client().admin().cluster().preparePutStoredScript().setId("id#").setContent(new BytesArray("{}"), XContentType.JSON).get() + () -> client().admin() + .cluster() + .preparePutStoredScript() + .setId("id#") + .setContent(new BytesArray("{}"), MediaTypeRegistry.JSON) + .get() ); assertEquals("Validation Failed: 1: id cannot contain '#' for stored script;", e.getMessage()); } @@ -95,7 +100,7 @@ public void testMaxScriptSize() { .setId("foobar") .setContent( new BytesArray("{\"script\": { \"lang\": \"" + LANG + "\"," + " \"source\":\"0123456789abcdef\"} }"), - XContentType.JSON + MediaTypeRegistry.JSON ) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/SearchCancellationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/SearchCancellationIT.java index eedd9328826a5..7fb0bc45fb084 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/SearchCancellationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/SearchCancellationIT.java @@ -50,8 +50,8 @@ import org.opensearch.action.support.WriteRequest; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.plugins.Plugin; import org.opensearch.plugins.PluginsService; import org.opensearch.script.MockScriptPlugin; @@ -229,7 +229,7 @@ public void testCancellationDuringQueryPhase() throws Exception { awaitForBlock(plugins); cancelSearch(SearchAction.NAME); disableBlocks(plugins); - logger.info("Segments {}", Strings.toString(XContentType.JSON, client().admin().indices().prepareSegments("test").get())); + logger.info("Segments {}", Strings.toString(MediaTypeRegistry.JSON, client().admin().indices().prepareSegments("test").get())); ensureSearchWasCancelled(searchResponse); } @@ -283,7 +283,7 @@ public void testCancellationDuringFetchPhase() throws Exception { awaitForBlock(plugins); cancelSearch(SearchAction.NAME); disableBlocks(plugins); - logger.info("Segments {}", Strings.toString(XContentType.JSON, client().admin().indices().prepareSegments("test").get())); + logger.info("Segments {}", Strings.toString(MediaTypeRegistry.JSON, client().admin().indices().prepareSegments("test").get())); ensureSearchWasCancelled(searchResponse); } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java index ed3edc8c624f8..0579fa8aa63c0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java @@ -38,8 +38,8 @@ import org.opensearch.action.search.SearchRequestBuilder; import org.opensearch.action.search.SearchResponse; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.query.InnerHitBuilder; import org.opensearch.core.rest.RestStatus; import org.opensearch.search.aggregations.Aggregator.SubAggCollectionMode; @@ -461,7 +461,7 @@ public void testParentFilterResolvedCorrectly() throws Exception { "{\"dates\": {\"month\": {\"label\": \"2014-11\", \"end\": \"2014-11-30\", \"start\": \"2014-11-01\"}, " + "\"day\": \"2014-11-30\"}, \"comments\": [{\"cid\": 3,\"identifier\": \"29111\"}, {\"cid\": 4,\"tags\": [" + "{\"tid\" :44,\"name\": \"Roles\"}], \"identifier\": \"29101\"}]}", - XContentType.JSON + MediaTypeRegistry.JSON ) ); indexRequests.add( @@ -471,7 +471,7 @@ public void testParentFilterResolvedCorrectly() throws Exception { "{\"dates\": {\"month\": {\"label\": \"2014-12\", \"end\": \"2014-12-31\", \"start\": \"2014-12-01\"}, " + "\"day\": \"2014-12-03\"}, \"comments\": [{\"cid\": 1, \"identifier\": \"29111\"}, {\"cid\": 2,\"tags\": [" + "{\"tid\" : 22, \"name\": \"DataChannels\"}], \"identifier\": \"29101\"}]}", - XContentType.JSON + MediaTypeRegistry.JSON ) ); indexRandom(true, indexRequests); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java index 0854faf6c515c..4f067a48875b3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java @@ -36,10 +36,10 @@ import org.opensearch.action.search.SearchRequestBuilder; import org.opensearch.action.search.SearchResponse; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.query.TermQueryBuilder; @@ -242,7 +242,7 @@ public void testConsistencyWithDifferentShardCounts() throws Exception { public void testPopularTermManyDeletedDocs() throws Exception { String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}"; assertAcked( - prepareCreate(INDEX_NAME).setSettings(settings, XContentType.JSON) + prepareCreate(INDEX_NAME).setSettings(settings, MediaTypeRegistry.JSON) .setMapping("text", "type=keyword", CLASS_FIELD, "type=keyword") ); String[] cat1v1 = { "constant", "one" }; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java index 852c3760751b3..e7e826d981c84 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java @@ -34,7 +34,7 @@ import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchResponse; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.query.QueryBuilders; import org.opensearch.search.aggregations.BucketOrder; import org.opensearch.search.aggregations.bucket.filter.InternalFilter; @@ -124,10 +124,10 @@ private void addTermsDocs(String term, int numInClass, int numNotInClass, List builders) { String sourceClass = "{\"text\": \"" + term + "\"}"; for (int i = 0; i < numDocs; i++) { - builders.add(client().prepareIndex(index).setSource(sourceClass, XContentType.JSON)); + builders.add(client().prepareIndex(index).setSource(sourceClass, MediaTypeRegistry.JSON)); } } } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java index 2034bbb7e13bc..e762801f51ef5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java @@ -38,8 +38,8 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.support.XContentMapValues; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.plugins.Plugin; import org.opensearch.script.MockScriptPlugin; import org.opensearch.script.Script; @@ -332,7 +332,7 @@ public void setupSuiteScopeCluster() throws Exception { new BytesArray( "{\"script\": {\"lang\": \"" + MockScriptPlugin.NAME + "\"," + " \"source\": \"vars.multiplier = 3\"} }" ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -345,7 +345,7 @@ public void setupSuiteScopeCluster() throws Exception { new BytesArray( "{\"script\": {\"lang\": \"" + MockScriptPlugin.NAME + "\"," + " \"source\": \"state.list.add(vars.multiplier)\"} }" ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -361,7 +361,7 @@ public void setupSuiteScopeCluster() throws Exception { + "\"," + " \"source\": \"sum state values as a new aggregation\"} }" ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -377,7 +377,7 @@ public void setupSuiteScopeCluster() throws Exception { + "\"," + " \"source\": \"sum all states (lists) values as a new aggregation\"} }" ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketScriptIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketScriptIT.java index e8e21d3580e1c..32d86072393f9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketScriptIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketScriptIT.java @@ -35,9 +35,9 @@ import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchResponse; import org.opensearch.core.common.bytes.BytesArray; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.plugins.Plugin; import org.opensearch.script.MockScriptPlugin; import org.opensearch.script.Script; @@ -551,7 +551,7 @@ public void testStoredScript() { // Script source is not interpreted but it references a pre-defined script from CustomScriptPlugin .setContent( new BytesArray("{ \"script\": {\"lang\": \"" + CustomScriptPlugin.NAME + "\"," + " \"source\": \"my_script\" } }"), - XContentType.JSON + MediaTypeRegistry.JSON ) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketSelectorIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketSelectorIT.java index 8fe8876c7593b..7b802478a46d8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketSelectorIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketSelectorIT.java @@ -35,8 +35,8 @@ import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchResponse; import org.opensearch.core.common.bytes.BytesArray; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.plugins.Plugin; import org.opensearch.script.MockScriptPlugin; import org.opensearch.script.Script; @@ -488,7 +488,7 @@ public void testStoredScript() { + "\", " + "\"source\": \"Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)\" } }" ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java index bb7aa9514564a..9e183248eabbd 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java @@ -36,9 +36,9 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.action.support.WriteRequest; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.search.aggregations.AggregationBuilders; import org.opensearch.search.aggregations.BucketOrder; import org.opensearch.search.aggregations.PipelineAggregatorBuilders; @@ -585,7 +585,7 @@ public void testFieldIsntWrittenOutTwice() throws Exception { groupByLicenseAgg.subAggregation(peakPipelineAggBuilder); SearchResponse response = client().prepareSearch("foo_*").setSize(0).addAggregation(groupByLicenseAgg).get(); - BytesReference bytes = XContentHelper.toXContent(response, XContentType.JSON, false); - XContentHelper.convertToMap(bytes, false, XContentType.JSON); + BytesReference bytes = org.opensearch.core.xcontent.XContentHelper.toXContent(response, MediaTypeRegistry.JSON, false); + XContentHelper.convertToMap(bytes, false, MediaTypeRegistry.JSON); } } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/MatchedQueriesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/MatchedQueriesIT.java index d83f1eb776b20..2d38d4531fede 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/MatchedQueriesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/MatchedQueriesIT.java @@ -34,8 +34,8 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.XContentHelper; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.query.MatchQueryBuilder; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; @@ -354,9 +354,9 @@ public void testMatchedWithWrapperQuery() throws Exception { refresh(); MatchQueryBuilder matchQueryBuilder = matchQuery("content", "amet").queryName("abc"); - BytesReference matchBytes = XContentHelper.toXContent(matchQueryBuilder, XContentType.JSON, false); + BytesReference matchBytes = XContentHelper.toXContent(matchQueryBuilder, MediaTypeRegistry.JSON, false); TermQueryBuilder termQueryBuilder = termQuery("content", "amet").queryName("abc"); - BytesReference termBytes = XContentHelper.toXContent(termQueryBuilder, XContentType.JSON, false); + BytesReference termBytes = XContentHelper.toXContent(termQueryBuilder, MediaTypeRegistry.JSON, false); QueryBuilder[] queries = new QueryBuilder[] { wrapperQuery(matchBytes), constantScoreQuery(wrapperQuery(termBytes)) }; for (QueryBuilder query : queries) { SearchResponse searchResponse = client().prepareSearch().setQuery(query).get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java index 53eb290e1edbf..20dede0d78799 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java @@ -43,9 +43,9 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.time.DateFormatter; import org.opensearch.common.time.DateUtils; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.index.fielddata.ScriptDocValues; import org.opensearch.index.mapper.MapperService; @@ -221,7 +221,7 @@ public void testStoredFields() throws Exception { .endObject() .toString(); - client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, MediaTypeRegistry.JSON).get(); client().prepareIndex("test") .setId("1") @@ -315,7 +315,7 @@ public void testScriptDocAndFields() throws Exception { .endObject() .toString(); - client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, MediaTypeRegistry.JSON).get(); client().prepareIndex("test") .setId("1") @@ -416,7 +416,7 @@ public void testScriptWithUnsignedLong() throws Exception { .endObject() .toString(); - client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, MediaTypeRegistry.JSON).get(); client().prepareIndex("test") .setId("1") @@ -517,7 +517,7 @@ public void testScriptFieldWithNanos() throws Exception { .endObject() .toString(); - client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, MediaTypeRegistry.JSON).get(); String date = "2019-01-31T10:00:00.123456789Z"; indexRandom( true, @@ -753,7 +753,7 @@ public void testStoredFieldsWithoutSource() throws Exception { .endObject() .toString(); - client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, MediaTypeRegistry.JSON).get(); ZonedDateTime date = ZonedDateTime.of(2012, 3, 22, 0, 0, 0, 0, ZoneOffset.UTC); client().prepareIndex("test") @@ -911,7 +911,7 @@ public void testGetFieldsComplexField() throws Exception { .endObject() ); - client().prepareIndex("my-index").setId("1").setRefreshPolicy(IMMEDIATE).setSource(source, XContentType.JSON).get(); + client().prepareIndex("my-index").setId("1").setRefreshPolicy(IMMEDIATE).setSource(source, MediaTypeRegistry.JSON).get(); String field = "field1.field2.field3.field4"; @@ -991,7 +991,7 @@ public void testDocValueFields() throws Exception { .endObject() .toString(); - client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, MediaTypeRegistry.JSON).get(); ZonedDateTime date = ZonedDateTime.of(2012, 3, 22, 0, 0, 0, 0, ZoneOffset.UTC); client().prepareIndex("test") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java index d4467b49d1c18..9be9e712fcca0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java @@ -56,9 +56,9 @@ import org.opensearch.common.geo.builders.PointBuilder; import org.opensearch.common.geo.builders.PolygonBuilder; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.Streams; import org.opensearch.index.query.QueryBuilders; import org.opensearch.search.SearchHit; @@ -242,7 +242,7 @@ public void testShapeRelations() throws Exception { ); BytesReference data = BytesReference.bytes(jsonBuilder().startObject().field("area", polygon).endObject()); - client().prepareIndex("shapes").setId("1").setSource(data, XContentType.JSON).get(); + client().prepareIndex("shapes").setId("1").setSource(data, MediaTypeRegistry.JSON).get(); client().admin().indices().prepareRefresh().get(); // Point in polygon @@ -305,7 +305,7 @@ public void testShapeRelations() throws Exception { ); data = BytesReference.bytes(jsonBuilder().startObject().field("area", inverse).endObject()); - client().prepareIndex("shapes").setId("2").setSource(data, XContentType.JSON).get(); + client().prepareIndex("shapes").setId("2").setSource(data, MediaTypeRegistry.JSON).get(); client().admin().indices().prepareRefresh().get(); // re-check point on polygon hole @@ -344,7 +344,7 @@ public void testShapeRelations() throws Exception { ); data = BytesReference.bytes(jsonBuilder().startObject().field("area", builder).endObject()); - client().prepareIndex("shapes").setId("1").setSource(data, XContentType.JSON).get(); + client().prepareIndex("shapes").setId("1").setSource(data, MediaTypeRegistry.JSON).get(); client().admin().indices().prepareRefresh().get(); // Create a polygon crossing longitude 180 with hole. @@ -357,7 +357,7 @@ public void testShapeRelations() throws Exception { ); data = BytesReference.bytes(jsonBuilder().startObject().field("area", builder).endObject()); - client().prepareIndex("shapes").setId("1").setSource(data, XContentType.JSON).get(); + client().prepareIndex("shapes").setId("1").setSource(data, MediaTypeRegistry.JSON).get(); client().admin().indices().prepareRefresh().get(); result = client().prepareSearch() diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java index cf1a1f82d7200..aef9c0714f6da 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java @@ -40,7 +40,7 @@ import org.opensearch.common.geo.builders.ShapeBuilder; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.GeoShapeFieldMapper; import org.opensearch.index.mapper.MappedFieldType; @@ -196,7 +196,7 @@ public void testMappingUpdate() throws Exception { IllegalArgumentException e = expectThrows( IllegalArgumentException.class, - () -> client().admin().indices().preparePutMapping("test").setSource(update, XContentType.JSON).get() + () -> client().admin().indices().preparePutMapping("test").setSource(update, MediaTypeRegistry.JSON).get() ); assertThat(e.getMessage(), containsString("using [BKD] strategy cannot be merged with")); } @@ -227,7 +227,7 @@ public void testIndexShapeRouting() throws Exception { + " }\n" + "}"; - indexRandom(true, client().prepareIndex("test").setId("0").setSource(source, XContentType.JSON).setRouting("ABC")); + indexRandom(true, client().prepareIndex("test").setId("0").setSource(source, MediaTypeRegistry.JSON).setRouting("ABC")); SearchResponse searchResponse = client().prepareSearch("test") .setQuery(geoShapeQuery("shape", "0").indexedShapeIndex("test").indexedShapeRouting("ABC")) @@ -263,8 +263,8 @@ public void testIndexPolygonDateLine() throws Exception { String source = "{\n" + " \"shape\" : \"POLYGON((179 0, -179 0, -179 2, 179 2, 179 0))\"" + "}"; - indexRandom(true, client().prepareIndex("quad").setId("0").setSource(source, XContentType.JSON)); - indexRandom(true, client().prepareIndex("vector").setId("0").setSource(source, XContentType.JSON)); + indexRandom(true, client().prepareIndex("quad").setId("0").setSource(source, MediaTypeRegistry.JSON)); + indexRandom(true, client().prepareIndex("vector").setId("0").setSource(source, MediaTypeRegistry.JSON)); try { ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java index 6332e2b94750d..1a40471ca2d51 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java @@ -39,9 +39,9 @@ import org.opensearch.cluster.routing.IndexShardRoutingTable; import org.opensearch.common.geo.builders.ShapeBuilder; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.geometry.Circle; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.LegacyGeoShapeFieldMapper; @@ -203,7 +203,7 @@ public void testIndexShapeRouting() throws Exception { + " }\n" + "}"; - indexRandom(true, client().prepareIndex("test").setId("0").setSource(source, XContentType.JSON).setRouting("ABC")); + indexRandom(true, client().prepareIndex("test").setId("0").setSource(source, MediaTypeRegistry.JSON).setRouting("ABC")); SearchResponse searchResponse = client().prepareSearch("test") .setQuery(geoShapeQuery("shape", "0").indexedShapeIndex("test").indexedShapeRouting("ABC")) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/msearch/MultiSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/msearch/MultiSearchIT.java index 8226663abf49e..9c2ddbba89903 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/msearch/MultiSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/msearch/MultiSearchIT.java @@ -34,7 +34,7 @@ import org.opensearch.action.search.MultiSearchRequest; import org.opensearch.action.search.MultiSearchResponse; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.query.QueryBuilders; import org.opensearch.test.OpenSearchIntegTestCase; @@ -73,7 +73,7 @@ public void testSimpleMultiSearchMoreRequests() { createIndex("test"); int numDocs = randomIntBetween(0, 16); for (int i = 0; i < numDocs; i++) { - client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", XContentType.JSON).get(); + client().prepareIndex("test").setId(Integer.toString(i)).setSource("{}", MediaTypeRegistry.JSON).get(); } refresh(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java index bd67f5f83375e..b5ffb13918259 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java @@ -45,9 +45,9 @@ import org.opensearch.action.search.SearchType; import org.opensearch.cluster.health.ClusterHealthStatus; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.query.QueryBuilders; import org.opensearch.search.sort.NestedSortBuilder; import org.opensearch.search.sort.SortBuilders; @@ -783,7 +783,7 @@ public void testNestedSortWithMultiLevelFiltering() throws Exception { + " }\n" + " ]\n" + "}", - XContentType.JSON + MediaTypeRegistry.JSON ) .get(); @@ -835,7 +835,7 @@ public void testNestedSortWithMultiLevelFiltering() throws Exception { + " }\n" + " ]\n" + "}", - XContentType.JSON + MediaTypeRegistry.JSON ) .get(); refresh(); @@ -987,7 +987,7 @@ public void testLeakingSortValues() throws Exception { + " }\n" + " ]\n" + "}", - XContentType.JSON + MediaTypeRegistry.JSON ) .get(); @@ -1006,7 +1006,7 @@ public void testLeakingSortValues() throws Exception { + " } \n" + " ]\n" + "}", - XContentType.JSON + MediaTypeRegistry.JSON ) .get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/preference/SearchPreferenceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/preference/SearchPreferenceIT.java index 55a2a1fdde2b5..a5084ec2d2e2d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/preference/SearchPreferenceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/preference/SearchPreferenceIT.java @@ -42,8 +42,8 @@ import org.opensearch.cluster.routing.OperationRouting; import org.opensearch.cluster.routing.allocation.decider.EnableAllocationDecider; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.node.Node; import org.opensearch.core.rest.RestStatus; import org.opensearch.test.OpenSearchIntegTestCase; @@ -136,7 +136,7 @@ public void testNoPreferenceRandom() { } public void testSimplePreference() { - client().admin().indices().prepareCreate("test").setSettings("{\"number_of_replicas\": 1}", XContentType.JSON).get(); + client().admin().indices().prepareCreate("test").setSettings("{\"number_of_replicas\": 1}", MediaTypeRegistry.JSON).get(); ensureGreen(); client().prepareIndex("test").setSource("field1", "value1").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/QueryStringIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/QueryStringIT.java index 36de3f7ebaa60..53a41af46790b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/QueryStringIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/QueryStringIT.java @@ -36,8 +36,8 @@ import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchResponse; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.Operator; import org.opensearch.index.query.QueryStringQueryBuilder; @@ -76,7 +76,7 @@ public static void createRandomClusterSetting() { @Before public void setup() throws Exception { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); - prepareCreate("test").setSource(indexBody, XContentType.JSON).get(); + prepareCreate("test").setSource(indexBody, MediaTypeRegistry.JSON).get(); ensureGreen("test"); } @@ -161,7 +161,7 @@ public void testWithLotsOfTypes() throws Exception { public void testDocWithAllTypes() throws Exception { List reqs = new ArrayList<>(); String docBody = copyToStringFromClasspath("/org/opensearch/search/query/all-example-document.json"); - reqs.add(client().prepareIndex("test").setId("1").setSource(docBody, XContentType.JSON)); + reqs.add(client().prepareIndex("test").setId("1").setSource(docBody, MediaTypeRegistry.JSON)); indexRandom(true, false, reqs); SearchResponse resp = client().prepareSearch("test").setQuery(queryStringQuery("foo")).get(); @@ -253,7 +253,7 @@ public void testAllFields() throws Exception { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); Settings.Builder settings = Settings.builder().put("index.query.default_field", "*"); - prepareCreate("test_1").setSource(indexBody, XContentType.JSON).setSettings(settings).get(); + prepareCreate("test_1").setSource(indexBody, MediaTypeRegistry.JSON).setSettings(settings).get(); ensureGreen("test_1"); List reqs = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java index 0e0f4873297ba..e8167471f074a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java @@ -50,9 +50,9 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.time.DateFormatter; import org.opensearch.common.unit.Fuzziness; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.analysis.CharFilterFactory; import org.opensearch.index.analysis.NormalizingCharFilterFactory; import org.opensearch.index.analysis.TokenizerFactory; @@ -1897,8 +1897,8 @@ public void testRangeQueryWithLocaleMapping() throws Exception { } public void testSearchEmptyDoc() { - assertAcked(prepareCreate("test").setSettings("{\"index.analysis.analyzer.default.type\":\"keyword\"}", XContentType.JSON)); - client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).get(); + assertAcked(prepareCreate("test").setSettings("{\"index.analysis.analyzer.default.type\":\"keyword\"}", MediaTypeRegistry.JSON)); + client().prepareIndex("test").setId("1").setSource("{}", MediaTypeRegistry.JSON).get(); refresh(); assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1L); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/SimpleQueryStringIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/SimpleQueryStringIT.java index e2491600a9261..3e49186c4dda8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/SimpleQueryStringIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/SimpleQueryStringIT.java @@ -42,9 +42,9 @@ import org.opensearch.action.search.SearchPhaseExecutionException; import org.opensearch.action.search.SearchResponse; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.analysis.PreConfiguredTokenFilter; import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.BoolQueryBuilder; @@ -441,7 +441,7 @@ public void testEmptySimpleQueryStringWithAnalysis() throws Exception { public void testBasicAllQuery() throws Exception { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); - prepareCreate("test").setSource(indexBody, XContentType.JSON).get(); + prepareCreate("test").setSource(indexBody, MediaTypeRegistry.JSON).get(); ensureGreen("test"); List reqs = new ArrayList<>(); @@ -465,7 +465,7 @@ public void testBasicAllQuery() throws Exception { public void testWithDate() throws Exception { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); - prepareCreate("test").setSource(indexBody, XContentType.JSON).get(); + prepareCreate("test").setSource(indexBody, MediaTypeRegistry.JSON).get(); ensureGreen("test"); List reqs = new ArrayList<>(); @@ -492,7 +492,7 @@ public void testWithDate() throws Exception { public void testWithLotsOfTypes() throws Exception { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); - prepareCreate("test").setSource(indexBody, XContentType.JSON).get(); + prepareCreate("test").setSource(indexBody, MediaTypeRegistry.JSON).get(); ensureGreen("test"); List reqs = new ArrayList<>(); @@ -523,12 +523,12 @@ public void testWithLotsOfTypes() throws Exception { public void testDocWithAllTypes() throws Exception { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); - prepareCreate("test").setSource(indexBody, XContentType.JSON).get(); + prepareCreate("test").setSource(indexBody, MediaTypeRegistry.JSON).get(); ensureGreen("test"); List reqs = new ArrayList<>(); String docBody = copyToStringFromClasspath("/org/opensearch/search/query/all-example-document.json"); - reqs.add(client().prepareIndex("test").setId("1").setSource(docBody, XContentType.JSON)); + reqs.add(client().prepareIndex("test").setId("1").setSource(docBody, MediaTypeRegistry.JSON)); indexRandom(true, false, reqs); SearchResponse resp = client().prepareSearch("test").setQuery(simpleQueryStringQuery("foo")).get(); @@ -568,7 +568,7 @@ public void testDocWithAllTypes() throws Exception { public void testKeywordWithWhitespace() throws Exception { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); - prepareCreate("test").setSource(indexBody, XContentType.JSON).get(); + prepareCreate("test").setSource(indexBody, MediaTypeRegistry.JSON).get(); ensureGreen("test"); List reqs = new ArrayList<>(); @@ -588,7 +588,7 @@ public void testKeywordWithWhitespace() throws Exception { public void testAllFieldsWithSpecifiedLeniency() throws IOException { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); - prepareCreate("test").setSource(indexBody, XContentType.JSON).get(); + prepareCreate("test").setSource(indexBody, MediaTypeRegistry.JSON).get(); ensureGreen("test"); SearchPhaseExecutionException e = expectThrows( @@ -635,7 +635,7 @@ private void doAssertLimitExceededException(String field, int exceedingFieldCoun public void testFieldAlias() throws Exception { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); - assertAcked(prepareCreate("test").setSource(indexBody, XContentType.JSON)); + assertAcked(prepareCreate("test").setSource(indexBody, MediaTypeRegistry.JSON)); ensureGreen("test"); List indexRequests = new ArrayList<>(); @@ -653,7 +653,7 @@ public void testFieldAlias() throws Exception { public void testFieldAliasWithWildcardField() throws Exception { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); - assertAcked(prepareCreate("test").setSource(indexBody, XContentType.JSON)); + assertAcked(prepareCreate("test").setSource(indexBody, MediaTypeRegistry.JSON)); ensureGreen("test"); List indexRequests = new ArrayList<>(); @@ -671,7 +671,7 @@ public void testFieldAliasWithWildcardField() throws Exception { public void testFieldAliasOnDisallowedFieldType() throws Exception { String indexBody = copyToStringFromClasspath("/org/opensearch/search/query/all-query-index.json"); - assertAcked(prepareCreate("test").setSource(indexBody, XContentType.JSON)); + assertAcked(prepareCreate("test").setSource(indexBody, MediaTypeRegistry.JSON)); ensureGreen("test"); List indexRequests = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java index 5d7c6d5891b83..6e1b38792d635 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java @@ -39,8 +39,8 @@ import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.IndexSettings; import org.opensearch.index.mapper.MapperService; @@ -326,7 +326,7 @@ public void testSimpleIndexSortEarlyTerminate() throws Exception { public void testInsaneFromAndSize() throws Exception { createIndex("idx"); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertWindowFails(client().prepareSearch("idx").setFrom(Integer.MAX_VALUE)); assertWindowFails(client().prepareSearch("idx").setSize(Integer.MAX_VALUE)); @@ -334,7 +334,7 @@ public void testInsaneFromAndSize() throws Exception { public void testTooLargeFromAndSize() throws Exception { createIndex("idx"); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertWindowFails(client().prepareSearch("idx").setFrom(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY))); assertWindowFails(client().prepareSearch("idx").setSize(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY) + 1)); @@ -347,7 +347,7 @@ public void testTooLargeFromAndSize() throws Exception { public void testLargeFromAndSizeSucceeds() throws Exception { createIndex("idx"); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertHitCount(client().prepareSearch("idx").setFrom(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY) - 10).get(), 1); assertHitCount(client().prepareSearch("idx").setSize(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY)).get(), 1); @@ -365,7 +365,7 @@ public void testTooLargeFromAndSizeOkBySetting() throws Exception { Settings.builder() .put(IndexSettings.MAX_RESULT_WINDOW_SETTING.getKey(), IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY) * 2) ).get(); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertHitCount(client().prepareSearch("idx").setFrom(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY)).get(), 1); assertHitCount(client().prepareSearch("idx").setSize(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY) + 1).get(), 1); @@ -393,7 +393,7 @@ public void testTooLargeFromAndSizeOkByDynamicSetting() throws Exception { ) .get() ); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertHitCount(client().prepareSearch("idx").setFrom(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY)).get(), 1); assertHitCount(client().prepareSearch("idx").setSize(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY) + 1).get(), 1); @@ -408,7 +408,7 @@ public void testTooLargeFromAndSizeOkByDynamicSetting() throws Exception { public void testTooLargeFromAndSizeBackwardsCompatibilityRecommendation() throws Exception { prepareCreate("idx").setSettings(Settings.builder().put(IndexSettings.MAX_RESULT_WINDOW_SETTING.getKey(), Integer.MAX_VALUE)).get(); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertHitCount(client().prepareSearch("idx").setFrom(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY) * 10).get(), 1); assertHitCount(client().prepareSearch("idx").setSize(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY) * 10).get(), 1); @@ -423,7 +423,7 @@ public void testTooLargeFromAndSizeBackwardsCompatibilityRecommendation() throws public void testTooLargeRescoreWindow() throws Exception { createIndex("idx"); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertRescoreWindowFails(Integer.MAX_VALUE); assertRescoreWindowFails(IndexSettings.MAX_RESCORE_WINDOW_SETTING.get(Settings.EMPTY) + 1); @@ -433,7 +433,7 @@ public void testTooLargeRescoreOkBySetting() throws Exception { int defaultMaxWindow = IndexSettings.MAX_RESCORE_WINDOW_SETTING.get(Settings.EMPTY); prepareCreate("idx").setSettings(Settings.builder().put(IndexSettings.MAX_RESCORE_WINDOW_SETTING.getKey(), defaultMaxWindow * 2)) .get(); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertHitCount( client().prepareSearch("idx").addRescorer(new QueryRescorerBuilder(matchAllQuery()).windowSize(defaultMaxWindow + 1)).get(), @@ -450,7 +450,7 @@ public void testTooLargeRescoreOkByResultWindowSetting() throws Exception { defaultMaxWindow * 2 ) ).get(); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertHitCount( client().prepareSearch("idx").addRescorer(new QueryRescorerBuilder(matchAllQuery()).windowSize(defaultMaxWindow + 1)).get(), @@ -468,7 +468,7 @@ public void testTooLargeRescoreOkByDynamicSetting() throws Exception { .setSettings(Settings.builder().put(IndexSettings.MAX_RESCORE_WINDOW_SETTING.getKey(), defaultMaxWindow * 2)) .get() ); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertHitCount( client().prepareSearch("idx").addRescorer(new QueryRescorerBuilder(matchAllQuery()).windowSize(defaultMaxWindow + 1)).get(), @@ -489,7 +489,7 @@ public void testTooLargeRescoreOkByDynamicResultWindowSetting() throws Exception ) .get() ); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); assertHitCount( client().prepareSearch("idx").addRescorer(new QueryRescorerBuilder(matchAllQuery()).windowSize(defaultMaxWindow + 1)).get(), @@ -515,7 +515,7 @@ public void testTermQueryBigInt() throws Exception { client().prepareIndex("idx") .setId("1") - .setSource("{\"field\" : 80315953321748200608 }", XContentType.JSON) + .setSource("{\"field\" : 80315953321748200608 }", MediaTypeRegistry.JSON) .setRefreshPolicy(RefreshPolicy.IMMEDIATE) .get(); @@ -529,7 +529,7 @@ public void testTermQueryBigInt() throws Exception { public void testTooLongRegexInRegexpQuery() throws Exception { createIndex("idx"); - indexRandom(true, client().prepareIndex("idx").setSource("{}", XContentType.JSON)); + indexRandom(true, client().prepareIndex("idx").setSource("{}", MediaTypeRegistry.JSON)); int defaultMaxRegexLength = IndexSettings.MAX_REGEX_LENGTH_SETTING.get(Settings.EMPTY); StringBuilder regexp = new StringBuilder(defaultMaxRegexLength); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java index 83e732b39103e..69424954d6511 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java @@ -46,9 +46,9 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.Numbers; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.fielddata.ScriptDocValues; import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.query.functionscore.ScoreFunctionBuilders; @@ -145,7 +145,7 @@ public void testIssue8226() { assertAcked(prepareCreate("test_" + i).addAlias(new Alias("test"))); } if (i > 0) { - client().prepareIndex("test_" + i).setId("" + i).setSource("{\"entry\": " + i + "}", XContentType.JSON).get(); + client().prepareIndex("test_" + i).setId("" + i).setSource("{\"entry\": " + i + "}", MediaTypeRegistry.JSON).get(); } } refresh(); @@ -497,9 +497,9 @@ public void testScoreSortDirectionWithFunctionScore() throws Exception { public void testIssue2986() { assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=keyword").get()); - client().prepareIndex("test").setId("1").setSource("{\"field1\":\"value1\"}", XContentType.JSON).get(); - client().prepareIndex("test").setId("2").setSource("{\"field1\":\"value2\"}", XContentType.JSON).get(); - client().prepareIndex("test").setId("3").setSource("{\"field1\":\"value3\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setSource("{\"field1\":\"value1\"}", MediaTypeRegistry.JSON).get(); + client().prepareIndex("test").setId("2").setSource("{\"field1\":\"value2\"}", MediaTypeRegistry.JSON).get(); + client().prepareIndex("test").setId("3").setSource("{\"field1\":\"value3\"}", MediaTypeRegistry.JSON).get(); refresh(); SearchResponse result = client().prepareSearch("test") .setQuery(matchAllQuery()) @@ -2259,7 +2259,7 @@ public void testLongSortOptimizationCorrectResults() { bulkBuilder = client().prepareBulk(); } String source = "{\"long_field\":" + randomLong() + "}"; - bulkBuilder.add(client().prepareIndex("test1").setId(Integer.toString(i)).setSource(source, XContentType.JSON)); + bulkBuilder.add(client().prepareIndex("test1").setId(Integer.toString(i)).setSource(source, MediaTypeRegistry.JSON)); } refresh(); diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotCustomPluginStateIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotCustomPluginStateIT.java index 85fedead80a85..eae7a92bf304e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotCustomPluginStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotCustomPluginStateIT.java @@ -43,7 +43,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.ingest.IngestTestPlugin; import org.opensearch.plugins.Plugin; import org.opensearch.script.MockScriptEngine; @@ -115,7 +115,7 @@ public void testIncludeGlobalState() throws Exception { .endArray() .endObject() ); - assertAcked(clusterAdmin().preparePutPipeline("barbaz", pipelineSource, XContentType.JSON).get()); + assertAcked(clusterAdmin().preparePutPipeline("barbaz", pipelineSource, MediaTypeRegistry.JSON).get()); } if (testScript) { @@ -125,7 +125,7 @@ public void testIncludeGlobalState() throws Exception { .setId("foobar") .setContent( new BytesArray("{\"script\": { \"lang\": \"" + MockScriptEngine.NAME + "\", \"source\": \"1\"} }"), - XContentType.JSON + MediaTypeRegistry.JSON ) ); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java index 019a1e1417510..f5bfa5b256069 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java @@ -45,9 +45,9 @@ import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.StatusToXContentObject; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -421,7 +421,7 @@ public void writeTo(StreamOutput out) throws IOException { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksResponse.java index f2ebde642d2be..979489999cc6e 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksResponse.java @@ -37,8 +37,8 @@ import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.tasks.TaskInfo; @@ -81,6 +81,6 @@ public static CancelTasksResponse fromXContent(XContentParser parser) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskResponse.java index 36bec88109cf1..96fb65a9a1391 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskResponse.java @@ -36,7 +36,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.tasks.TaskResult; @@ -85,6 +85,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java index 1e2e432882623..99b4d3dd006c8 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java @@ -43,8 +43,8 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -262,6 +262,6 @@ public static ListTasksResponse fromXContent(XContentParser parser) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java index fd29c324d51a1..e2dfba791f752 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequest.java @@ -13,8 +13,8 @@ import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -205,7 +205,7 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/stats/RemoteStoreStatsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/stats/RemoteStoreStatsResponse.java index 4f0832816fd8a..91dd0483f2df5 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/stats/RemoteStoreStatsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/stats/RemoteStoreStatsResponse.java @@ -13,7 +13,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import java.io.IOException; @@ -89,7 +89,7 @@ protected void addCustomXContentFields(XContentBuilder builder, Params params) t @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, false); + return Strings.toString(MediaTypeRegistry.JSON, this, true, false); } static final class Fields { diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/put/PutRepositoryRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/put/PutRepositoryRequest.java index b001e9456e78c..c8ebcb6e6fcd3 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/put/PutRepositoryRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/put/PutRepositoryRequest.java @@ -37,9 +37,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Map; @@ -164,11 +164,11 @@ public PutRepositoryRequest settings(Settings.Builder settings) { * Sets the repository settings. * * @param source repository settings in json or yaml format - * @param xContentType the content type of the source + * @param mediaType the content type of the source * @return this request */ - public PutRepositoryRequest settings(String source, XContentType xContentType) { - this.settings = Settings.builder().loadFromSource(source, xContentType).build(); + public PutRepositoryRequest settings(String source, final MediaType mediaType) { + this.settings = Settings.builder().loadFromSource(source, mediaType).build(); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java index 9a97b67e1c2b7..f01854fc5d29d 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java @@ -39,7 +39,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -196,7 +196,7 @@ public static VerifyRepositoryResponse fromXContent(XContentParser parser) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterGetSettingsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterGetSettingsResponse.java index 9a8206a4cfdba..521ba824e6e57 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterGetSettingsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterGetSettingsResponse.java @@ -38,11 +38,11 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.settings.Settings; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Objects; @@ -176,7 +176,7 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsRequest.java index aaa89ee269fd8..628d6e972f82c 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsRequest.java @@ -38,11 +38,11 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Map; @@ -120,8 +120,8 @@ public ClusterUpdateSettingsRequest transientSettings(Settings.Builder settings) /** * Sets the source containing the transient settings to be updated. They will not survive a full cluster restart */ - public ClusterUpdateSettingsRequest transientSettings(String source, XContentType xContentType) { - this.transientSettings = Settings.builder().loadFromSource(source, xContentType).build(); + public ClusterUpdateSettingsRequest transientSettings(String source, final MediaType mediaType) { + this.transientSettings = Settings.builder().loadFromSource(source, mediaType).build(); return this; } @@ -152,8 +152,8 @@ public ClusterUpdateSettingsRequest persistentSettings(Settings.Builder settings /** * Sets the source containing the persistent settings to be updated. They will get applied cross restarts */ - public ClusterUpdateSettingsRequest persistentSettings(String source, XContentType xContentType) { - this.persistentSettings = Settings.builder().loadFromSource(source, xContentType).build(); + public ClusterUpdateSettingsRequest persistentSettings(String source, final MediaType mediaType) { + this.persistentSettings = Settings.builder().loadFromSource(source, mediaType).build(); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/clone/CloneSnapshotRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/clone/CloneSnapshotRequest.java index 5729386259df1..694b13e37bb03 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/clone/CloneSnapshotRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/clone/CloneSnapshotRequest.java @@ -39,7 +39,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -187,6 +187,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotRequest.java index 9736d99b9f886..cb6136b84ba18 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotRequest.java @@ -48,7 +48,6 @@ import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Arrays; @@ -388,7 +387,7 @@ public CreateSnapshotRequest settings(String source, MediaType mediaType) { */ public CreateSnapshotRequest settings(Map source) { try { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.map(source); settings(builder.toString(), builder.contentType()); } catch (IOException e) { diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java index b8b4d972c95f7..12f441960ccaf 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java @@ -36,9 +36,9 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -128,6 +128,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java index 0f9aa65afe3c2..767b68bc4ac52 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java @@ -43,6 +43,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.util.FeatureFlags; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; @@ -749,6 +750,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java index c7690ea0d7817..6289dc95484cc 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java @@ -38,12 +38,12 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.XContentParserUtils; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; @@ -357,7 +357,7 @@ void add(SnapshotStats stats, boolean updateTimestamps) { time = endTime - startTime; } assert time >= 0 : "Update with [" - + Strings.toString(XContentType.JSON, stats) + + Strings.toString(MediaTypeRegistry.JSON, stats) + "][" + updateTimestamps + "] resulted in negative total time [" diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java index d1e25c1f1bdc4..5f2afa24c4ab7 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java @@ -39,9 +39,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -206,7 +206,7 @@ public void writeTo(StreamOutput out) throws IOException { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, false); + return Strings.toString(MediaTypeRegistry.JSON, this, true, false); } /** diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/stats/AnalysisStats.java b/server/src/main/java/org/opensearch/action/admin/cluster/stats/AnalysisStats.java index 84b093f9bb238..9190cae4c49d8 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/stats/AnalysisStats.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/stats/AnalysisStats.java @@ -40,7 +40,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; @@ -347,6 +347,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/stats/MappingStats.java b/server/src/main/java/org/opensearch/action/admin/cluster/stats/MappingStats.java index 66d1fc6a52295..64218765a57e6 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/stats/MappingStats.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/stats/MappingStats.java @@ -39,7 +39,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; @@ -131,7 +131,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java index 8b328bc3879dd..bbbec60036b0b 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java @@ -140,10 +140,10 @@ public StoredScriptSource source() { /** * Set the script source and the content type of the bytes. */ - public PutStoredScriptRequest content(BytesReference content, XContentType xContentType) { + public PutStoredScriptRequest content(BytesReference content, MediaType mediaType) { this.content = content; - this.mediaType = Objects.requireNonNull(xContentType); - this.source = StoredScriptSource.parse(content, xContentType); + this.mediaType = Objects.requireNonNull(mediaType); + this.source = StoredScriptSource.parse(content, mediaType); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequestBuilder.java index ed46b12d96106..2a06cd23c10b6 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequestBuilder.java @@ -36,7 +36,7 @@ import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.client.OpenSearchClient; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaType; /** * Transport request builder for putting stored script @@ -60,8 +60,8 @@ public PutStoredScriptRequestBuilder setId(String id) { /** * Set the source of the script along with the content type of the source */ - public PutStoredScriptRequestBuilder setContent(BytesReference source, XContentType xContentType) { - request.content(source, xContentType); + public PutStoredScriptRequestBuilder setContent(BytesReference source, MediaType mediaType) { + request.content(source, mediaType); return this; } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/alias/IndicesAliasesRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/alias/IndicesAliasesRequest.java index cd99a1067a8a4..5e011409e8f9c 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/alias/IndicesAliasesRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/alias/IndicesAliasesRequest.java @@ -45,7 +45,6 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ConstructingObjectParser; import org.opensearch.core.xcontent.MediaTypeRegistry; @@ -429,7 +428,7 @@ public AliasActions filter(Map filter) { return this; } try { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder(); builder.map(filter); this.filter = builder.toString(); return this; @@ -533,7 +532,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws } if (false == Strings.isEmpty(filter)) { try (InputStream stream = new BytesArray(filter).streamInput()) { - builder.rawField(FILTER.getPreferredName(), stream, XContentType.JSON); + builder.rawField(FILTER.getPreferredName(), stream, MediaTypeRegistry.JSON); } } if (false == Strings.isEmpty(routing)) { diff --git a/server/src/main/java/org/opensearch/action/admin/indices/analyze/AnalyzeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/analyze/AnalyzeAction.java index 00144eedc438f..b4499f9cd71f8 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/analyze/AnalyzeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/analyze/AnalyzeAction.java @@ -40,8 +40,8 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.ToXContentObject; @@ -386,7 +386,7 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } /** diff --git a/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexResponse.java index c069cd17b8c51..8a6210defeb66 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexResponse.java @@ -40,7 +40,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.common.util.CollectionUtils; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.index.Index; @@ -93,7 +93,7 @@ protected void addCustomFields(final XContentBuilder builder, final Params param @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** @@ -192,7 +192,7 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } @@ -251,7 +251,7 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** @@ -297,7 +297,7 @@ public XContentBuilder innerToXContent(final XContentBuilder builder, final Para @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } static Failure readFailure(final StreamInput in) throws IOException { diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java index 001b466fc47e5..1ea76ff055fac 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java @@ -220,7 +220,7 @@ public CreateIndexRequest settings(String source, XContentType xContentType) { /** * The settings to create the index with (using a generic MediaType) */ - private CreateIndexRequest settings(String source, MediaType mediaType) { + public CreateIndexRequest settings(String source, MediaType mediaType) { this.settings = Settings.builder().loadFromSource(source, mediaType).build(); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java index 27f20f028ea74..aff56905ddadb 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java @@ -98,8 +98,8 @@ public CreateIndexRequestBuilder setSettings(XContentBuilder builder) { /** * The settings to create the index with (either json or yaml format) */ - public CreateIndexRequestBuilder setSettings(String source, XContentType xContentType) { - request.settings(source, xContentType); + public CreateIndexRequestBuilder setSettings(String source, MediaType mediaType) { + request.settings(source, mediaType); return this; } @@ -209,16 +209,16 @@ public CreateIndexRequestBuilder setSource(String source, MediaType mediaType) { /** * Sets the settings and mappings as a single source. */ - public CreateIndexRequestBuilder setSource(BytesReference source, XContentType xContentType) { - request.source(source, xContentType); + public CreateIndexRequestBuilder setSource(BytesReference source, MediaType mediaType) { + request.source(source, mediaType); return this; } /** * Sets the settings and mappings as a single source. */ - public CreateIndexRequestBuilder setSource(byte[] source, XContentType xContentType) { - request.source(source, xContentType); + public CreateIndexRequestBuilder setSource(byte[] source, MediaType mediaType) { + request.source(source, mediaType); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java index b0fc6856eb43c..edfc7b1bf4fc9 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java @@ -40,7 +40,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.mapper.MapperService; @@ -328,7 +328,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java index a06121b1d448d..2c6e1814f57d3 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java @@ -39,13 +39,13 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.Mapper; import org.opensearch.index.mapper.MapperService; @@ -214,7 +214,7 @@ public String fullName() { /** Returns the mappings as a map. Note that the returned map has a single key which is always the field's {@link Mapper#name}. */ public Map sourceAsMap() { - return XContentHelper.convertToMap(source, true, XContentType.JSON).v2(); + return XContentHelper.convertToMap(source, true, MediaTypeRegistry.JSON).v2(); } // pkg-private for testing @@ -233,7 +233,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field("mapping", sourceAsMap()); } else { try (InputStream stream = source.streamInput()) { - builder.rawField(MAPPING.getPreferredName(), stream, XContentType.JSON); + builder.rawField(MAPPING.getPreferredName(), stream, MediaTypeRegistry.JSON); } } return builder; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetMappingsResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetMappingsResponse.java index 6b3fff19d532f..e5ac85b713ed9 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetMappingsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetMappingsResponse.java @@ -38,8 +38,8 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.mapper.MapperService; @@ -132,7 +132,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java index 435034c77b921..40becceef53dd 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java @@ -46,9 +46,9 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.regex.Regex; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.MappingLookup; import org.opensearch.index.mapper.DocumentMapper; @@ -220,7 +220,7 @@ private static void addFieldMapper( try { BytesReference bytes = XContentHelper.toXContent( fieldMapper, - XContentType.JSON, + MediaTypeRegistry.JSON, includeDefaults ? includeDefaultsParams : ToXContent.EMPTY_PARAMS, false ); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java index 373331eb1554b..5c8bcbb1e92a7 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -46,7 +46,6 @@ import org.opensearch.core.common.util.CollectionUtils; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; @@ -299,7 +298,7 @@ public PutMappingRequest source(XContentBuilder mappingBuilder) { */ public PutMappingRequest source(Map mappingSource) { try { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.map(mappingSource); return source(BytesReference.bytes(builder), builder.contentType()); } catch (IOException e) { @@ -310,8 +309,8 @@ public PutMappingRequest source(Map mappingSource) { /** * The mapping source definition. */ - public PutMappingRequest source(String mappingSource, XContentType xContentType) { - return source(new BytesArray(mappingSource), xContentType); + public PutMappingRequest source(String mappingSource, MediaType mediaType) { + return source(new BytesArray(mappingSource), mediaType); } /** @@ -354,7 +353,7 @@ public void writeTo(StreamOutput out) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (source != null) { try (InputStream stream = new BytesArray(source).streamInput()) { - builder.rawValue(stream, XContentType.JSON); + builder.rawValue(stream, MediaTypeRegistry.JSON); } } else { builder.startObject().endObject(); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java index a1300b5859ce5..5b0e74eb1f435 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java @@ -36,8 +36,8 @@ import org.opensearch.action.support.master.AcknowledgedRequestBuilder; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.client.OpenSearchClient; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.Index; import java.util.Map; @@ -95,8 +95,8 @@ public PutMappingRequestBuilder setSource(Map mappingSource) { /** * The mapping source definition. */ - public PutMappingRequestBuilder setSource(String mappingSource, XContentType xContentType) { - request.source(mappingSource, xContentType); + public PutMappingRequestBuilder setSource(String mappingSource, MediaType mediaType) { + request.source(mappingSource, mediaType); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/readonly/AddIndexBlockResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/readonly/AddIndexBlockResponse.java index 42dacfdb3ca2d..ce08997de443f 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/readonly/AddIndexBlockResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/readonly/AddIndexBlockResponse.java @@ -40,7 +40,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.common.util.CollectionUtils; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.index.Index; @@ -93,7 +93,7 @@ protected void addCustomFields(final XContentBuilder builder, final Params param @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** @@ -192,7 +192,7 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } @@ -252,7 +252,7 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** @@ -298,7 +298,7 @@ public XContentBuilder innerToXContent(final XContentBuilder builder, final Para @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } static Failure readFailure(final StreamInput in) throws IOException { diff --git a/server/src/main/java/org/opensearch/action/admin/indices/recovery/RecoveryResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/recovery/RecoveryResponse.java index a7015a9d580df..4fc8788711f73 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/recovery/RecoveryResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/recovery/RecoveryResponse.java @@ -37,7 +37,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.indices.recovery.RecoveryState; @@ -120,6 +120,6 @@ public void writeTo(StreamOutput out) throws IOException { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/replication/SegmentReplicationStatsResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/replication/SegmentReplicationStatsResponse.java index 99ff501c1eed8..bf0eb54e6c519 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/replication/SegmentReplicationStatsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/replication/SegmentReplicationStatsResponse.java @@ -13,7 +13,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.SegmentReplicationPerGroupStats; @@ -91,6 +91,6 @@ public void writeTo(StreamOutput out) throws IOException { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverInfo.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverInfo.java index 8503c9b882c93..a4d4644fd12c0 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverInfo.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverInfo.java @@ -38,9 +38,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -149,6 +149,6 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/settings/put/UpdateSettingsRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/settings/put/UpdateSettingsRequest.java index 3c12f3eb8b728..707429f65fe42 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/settings/put/UpdateSettingsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/settings/put/UpdateSettingsRequest.java @@ -40,10 +40,11 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Arrays; @@ -157,8 +158,8 @@ public UpdateSettingsRequest settings(Settings.Builder settings) { /** * Sets the settings to be updated (either json or yaml format) */ - public UpdateSettingsRequest settings(String source, XContentType xContentType) { - this.settings = Settings.builder().loadFromSource(source, xContentType).build(); + public UpdateSettingsRequest settings(String source, MediaType mediaType) { + this.settings = Settings.builder().loadFromSource(source, mediaType).build(); return this; } @@ -221,7 +222,7 @@ public UpdateSettingsRequest fromXContent(XContentParser parser) throws IOExcept @Override public String toString() { - return "indices : " + Arrays.toString(indices) + "," + Strings.toString(XContentType.JSON, this); + return "indices : " + Arrays.toString(indices) + "," + Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/indices/stats/IndicesStatsResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/stats/IndicesStatsResponse.java index b262835dc2f2a..8ba924f28f08c 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/stats/IndicesStatsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/stats/IndicesStatsResponse.java @@ -39,7 +39,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.index.Index; @@ -226,6 +226,6 @@ static final class Fields { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, false); + return Strings.toString(MediaTypeRegistry.JSON, this, true, false); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index 011f10bfaf6d6..ccb6efe332f45 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -225,8 +225,8 @@ public PutIndexTemplateRequest settings(Settings.Builder settings) { /** * The settings to create the index template with (either json/yaml format). */ - public PutIndexTemplateRequest settings(String source, XContentType xContentType) { - this.settings = Settings.builder().loadFromSource(source, xContentType).build(); + public PutIndexTemplateRequest settings(String source, MediaType mediaType) { + this.settings = Settings.builder().loadFromSource(source, mediaType).build(); return this; } @@ -397,15 +397,15 @@ public PutIndexTemplateRequest source(String templateSource, XContentType xConte /** * The template source definition. */ - public PutIndexTemplateRequest source(byte[] source, XContentType xContentType) { - return source(source, 0, source.length, xContentType); + public PutIndexTemplateRequest source(byte[] source, MediaType mediaType) { + return source(source, 0, source.length, mediaType); } /** * The template source definition. */ - public PutIndexTemplateRequest source(byte[] source, int offset, int length, XContentType xContentType) { - return source(new BytesArray(source, offset, length), xContentType); + public PutIndexTemplateRequest source(byte[] source, int offset, int length, MediaType mediaType) { + return source(new BytesArray(source, offset, length), mediaType); } /** diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java index eae2f9d9c94e0..65df611983caf 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java @@ -37,6 +37,7 @@ import org.opensearch.client.OpenSearchClient; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; @@ -113,8 +114,8 @@ public PutIndexTemplateRequestBuilder setSettings(Settings.Builder settings) { /** * The settings to crete the index template with (either json or yaml format) */ - public PutIndexTemplateRequestBuilder setSettings(String source, XContentType xContentType) { - request.settings(source, xContentType); + public PutIndexTemplateRequestBuilder setSettings(String source, MediaType mediaType) { + request.settings(source, mediaType); return this; } @@ -130,10 +131,10 @@ public PutIndexTemplateRequestBuilder setSettings(Map source) { * Adds mapping that will be added when the index template gets created. * * @param source The mapping source - * @param xContentType The type/format of the source + * @param mediaType The type/format of the source */ - public PutIndexTemplateRequestBuilder setMapping(String source, XContentType xContentType) { - request.mapping(source, xContentType); + public PutIndexTemplateRequestBuilder setMapping(String source, MediaType mediaType) { + request.mapping(source, mediaType); return this; } @@ -226,16 +227,16 @@ public PutIndexTemplateRequestBuilder setSource(Map templateSour /** * The template source definition. */ - public PutIndexTemplateRequestBuilder setSource(BytesReference templateSource, XContentType xContentType) { - request.source(templateSource, xContentType); + public PutIndexTemplateRequestBuilder setSource(BytesReference templateSource, MediaType mediaType) { + request.source(templateSource, mediaType); return this; } /** * The template source definition. */ - public PutIndexTemplateRequestBuilder setSource(byte[] templateSource, XContentType xContentType) { - request.source(templateSource, xContentType); + public PutIndexTemplateRequestBuilder setSource(byte[] templateSource, MediaType mediaType) { + request.source(templateSource, mediaType); return this; } diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkItemRequest.java b/server/src/main/java/org/opensearch/action/bulk/BulkItemRequest.java index bbf887b71cbb2..c0e0a5d8532b6 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkItemRequest.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkItemRequest.java @@ -40,8 +40,8 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaTypeRegistry; import java.io.IOException; import java.util.Objects; @@ -114,7 +114,7 @@ public void abort(String index, Exception cause) { setPrimaryResponse(new BulkItemResponse(id, request.opType(), failure)); } else { assert primaryResponse.isFailed() && primaryResponse.getFailure().isAborted() : "response [" - + Strings.toString(XContentType.JSON, primaryResponse) + + Strings.toString(MediaTypeRegistry.JSON, primaryResponse) + "]; cause [" + cause + "]"; diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java b/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java index 08a8e7b6d7865..c6228d7ec854e 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java @@ -46,9 +46,9 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.xcontent.StatusToXContentObject; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -368,7 +368,7 @@ public static Failure fromXContent(XContentParser parser) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkProcessor.java b/server/src/main/java/org/opensearch/action/bulk/BulkProcessor.java index a01fc82fffd01..e99d09de89b74 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkProcessor.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkProcessor.java @@ -45,6 +45,7 @@ import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.threadpool.Scheduler; import org.opensearch.threadpool.ThreadPool; @@ -457,17 +458,13 @@ public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, XCo /** * Adds the data from the bytes to be processed by the bulk processor */ - public BulkProcessor add( - BytesReference data, - @Nullable String defaultIndex, - @Nullable String defaultPipeline, - XContentType xContentType - ) throws Exception { + public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultPipeline, MediaType mediaType) + throws Exception { Tuple bulkRequestToExecute = null; lock.lock(); try { ensureOpen(); - bulkRequest.add(data, defaultIndex, null, null, defaultPipeline, null, true, xContentType); + bulkRequest.add(data, defaultIndex, null, null, defaultPipeline, null, true, mediaType); bulkRequestToExecute = newBulkRequestIfNeeded(); } finally { lock.unlock(); diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkRequestParser.java b/server/src/main/java/org/opensearch/action/bulk/BulkRequestParser.java index 3a86ccd578991..481638028b95d 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkRequestParser.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkRequestParser.java @@ -43,6 +43,7 @@ import org.opensearch.common.lucene.uid.Versions; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContent; import org.opensearch.core.xcontent.XContentParser; @@ -105,7 +106,7 @@ private static BytesReference sliceTrimmingCarriageReturn( MediaType mediaType ) { final int length; - if (XContentType.JSON == mediaType && bytesReference.get(nextMarker - 1) == (byte) '\r') { + if (MediaTypeRegistry.JSON == mediaType && bytesReference.get(nextMarker - 1) == (byte) '\r') { length = nextMarker - from - 1; } else { length = nextMarker - from; diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java index c4298e75f8302..3a5b687f19dac 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java @@ -36,9 +36,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -289,7 +289,7 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java index 5b14a0d5a40b4..641cb4ae20e3e 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java @@ -39,11 +39,11 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.XContentParserUtils; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Arrays; @@ -213,6 +213,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/action/get/GetResponse.java b/server/src/main/java/org/opensearch/action/get/GetResponse.java index abb1ddfe041c9..c3ae5d9cf2007 100644 --- a/server/src/main/java/org/opensearch/action/get/GetResponse.java +++ b/server/src/main/java/org/opensearch/action/get/GetResponse.java @@ -40,7 +40,7 @@ import org.opensearch.common.document.DocumentField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -238,6 +238,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java b/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java index 3a28b123b6539..5549d44c1e7ac 100644 --- a/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java @@ -48,8 +48,8 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.lucene.uid.Versions; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -261,7 +261,7 @@ public int hashCode() { } public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/action/index/IndexRequestBuilder.java b/server/src/main/java/org/opensearch/action/index/IndexRequestBuilder.java index ca25409556398..4bf7634dcb7e1 100644 --- a/server/src/main/java/org/opensearch/action/index/IndexRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/index/IndexRequestBuilder.java @@ -38,8 +38,8 @@ import org.opensearch.client.OpenSearchClient; import org.opensearch.common.Nullable; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.VersionType; import java.util.Map; @@ -82,8 +82,8 @@ public IndexRequestBuilder setRouting(String routing) { /** * Sets the source. */ - public IndexRequestBuilder setSource(BytesReference source, XContentType xContentType) { - request.source(source, xContentType); + public IndexRequestBuilder setSource(BytesReference source, MediaType mediaType) { + request.source(source, mediaType); return this; } @@ -102,7 +102,7 @@ public IndexRequestBuilder setSource(Map source) { * * @param source The map to index */ - public IndexRequestBuilder setSource(Map source, XContentType contentType) { + public IndexRequestBuilder setSource(Map source, MediaType contentType) { request.source(source, contentType); return this; } @@ -111,10 +111,10 @@ public IndexRequestBuilder setSource(Map source, XContentType content * Sets the document source to index. * */ - public IndexRequestBuilder setSource(XContentType xContentType, Object... source) { - request.source(xContentType, source); + public IndexRequestBuilder setSource(MediaType mediaType, Object... source) { + request.source(mediaType, source); return this; } diff --git a/server/src/main/java/org/opensearch/action/index/IndexResponse.java b/server/src/main/java/org/opensearch/action/index/IndexResponse.java index c7c2138a63b4e..69b38be93663a 100644 --- a/server/src/main/java/org/opensearch/action/index/IndexResponse.java +++ b/server/src/main/java/org/opensearch/action/index/IndexResponse.java @@ -35,7 +35,7 @@ import org.opensearch.action.DocWriteResponse; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.index.shard.ShardId; import org.opensearch.core.rest.RestStatus; @@ -90,7 +90,7 @@ public String toString() { builder.append(",result=").append(getResult().getLowercase()); builder.append(",seqNo=").append(getSeqNo()); builder.append(",primaryTerm=").append(getPrimaryTerm()); - builder.append(",shards=").append(Strings.toString(XContentType.JSON, getShardInfo())); + builder.append(",shards=").append(Strings.toString(MediaTypeRegistry.JSON, getShardInfo())); return builder.append("]").toString(); } diff --git a/server/src/main/java/org/opensearch/action/ingest/GetPipelineResponse.java b/server/src/main/java/org/opensearch/action/ingest/GetPipelineResponse.java index a22f499c4add4..cd87bbf02f75a 100644 --- a/server/src/main/java/org/opensearch/action/ingest/GetPipelineResponse.java +++ b/server/src/main/java/org/opensearch/action/ingest/GetPipelineResponse.java @@ -38,7 +38,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.xcontent.StatusToXContentObject; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.XContentParser.Token; @@ -172,7 +172,7 @@ public boolean equals(Object other) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/action/ingest/PutPipelineRequestBuilder.java b/server/src/main/java/org/opensearch/action/ingest/PutPipelineRequestBuilder.java index d69165b280063..e734abb6d7969 100644 --- a/server/src/main/java/org/opensearch/action/ingest/PutPipelineRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/ingest/PutPipelineRequestBuilder.java @@ -36,7 +36,7 @@ import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.client.OpenSearchClient; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaType; /** * Transport request builder to put a pipeline @@ -54,8 +54,8 @@ public PutPipelineRequestBuilder( PutPipelineAction action, String id, BytesReference source, - XContentType xContentType + MediaType mediaType ) { - super(client, action, new PutPipelineRequest(id, source, xContentType)); + super(client, action, new PutPipelineRequest(id, source, mediaType)); } } diff --git a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequestBuilder.java b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequestBuilder.java index b2eda0e9485e4..55e6d95fde65c 100644 --- a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequestBuilder.java @@ -35,7 +35,7 @@ import org.opensearch.action.ActionRequestBuilder; import org.opensearch.client.OpenSearchClient; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaType; /** * Transport request builder to simulate a pipeline @@ -58,9 +58,9 @@ public SimulatePipelineRequestBuilder( OpenSearchClient client, SimulatePipelineAction action, BytesReference source, - XContentType xContentType + MediaType mediaType ) { - super(client, action, new SimulatePipelineRequest(source, xContentType)); + super(client, action, new SimulatePipelineRequest(source, mediaType)); } /** diff --git a/server/src/main/java/org/opensearch/action/search/GetSearchPipelineResponse.java b/server/src/main/java/org/opensearch/action/search/GetSearchPipelineResponse.java index cf8d9cec779c8..d25a084058fa0 100644 --- a/server/src/main/java/org/opensearch/action/search/GetSearchPipelineResponse.java +++ b/server/src/main/java/org/opensearch/action/search/GetSearchPipelineResponse.java @@ -14,7 +14,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.xcontent.StatusToXContentObject; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.rest.RestStatus; @@ -129,7 +129,7 @@ private static Map toMap(List updatedSourceAsMap; - private final XContentType updateSourceContentType; + private final MediaType updateSourceContentType; public Result( Writeable action, DocWriteResponse.Result result, Map updatedSourceAsMap, - XContentType updateSourceContentType + MediaType updateSourceContentType ) { this.action = action; this.result = result; @@ -428,7 +429,7 @@ public Map updatedSourceAsMap() { return updatedSourceAsMap; } - public XContentType updateSourceContentType() { + public MediaType updateSourceContentType() { return updateSourceContentType; } } diff --git a/server/src/main/java/org/opensearch/action/update/UpdateRequest.java b/server/src/main/java/org/opensearch/action/update/UpdateRequest.java index 86ebc0d9b69d6..adb42050556f3 100644 --- a/server/src/main/java/org/opensearch/action/update/UpdateRequest.java +++ b/server/src/main/java/org/opensearch/action/update/UpdateRequest.java @@ -56,7 +56,6 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.VersionType; import org.opensearch.index.mapper.MapperService; import org.opensearch.core.index.shard.ShardId; @@ -663,32 +662,32 @@ public UpdateRequest doc(Map source) { /** * Sets the doc to use for updates when a script is not specified. */ - public UpdateRequest doc(Map source, XContentType contentType) { - safeDoc().source(source, contentType); + public UpdateRequest doc(Map source, MediaType mediaType) { + safeDoc().source(source, mediaType); return this; } /** * Sets the doc to use for updates when a script is not specified. */ - public UpdateRequest doc(String source, XContentType xContentType) { - safeDoc().source(source, xContentType); + public UpdateRequest doc(String source, MediaType mediaType) { + safeDoc().source(source, mediaType); return this; } /** * Sets the doc to use for updates when a script is not specified. */ - public UpdateRequest doc(byte[] source, XContentType xContentType) { - safeDoc().source(source, xContentType); + public UpdateRequest doc(byte[] source, MediaType mediaType) { + safeDoc().source(source, mediaType); return this; } /** * Sets the doc to use for updates when a script is not specified. */ - public UpdateRequest doc(byte[] source, int offset, int length, XContentType xContentType) { - safeDoc().source(source, offset, length, xContentType); + public UpdateRequest doc(byte[] source, int offset, int length, MediaType mediaType) { + safeDoc().source(source, offset, length, mediaType); return this; } @@ -705,8 +704,8 @@ public UpdateRequest doc(Object... source) { * Sets the doc to use for updates when a script is not specified, the doc provided * is a field and value pairs. */ - public UpdateRequest doc(XContentType xContentType, Object... source) { - safeDoc().source(xContentType, source); + public UpdateRequest doc(MediaType mediaType, Object... source) { + safeDoc().source(mediaType, source); return this; } @@ -749,32 +748,32 @@ public UpdateRequest upsert(Map source) { /** * Sets the doc source of the update request to be used when the document does not exists. */ - public UpdateRequest upsert(Map source, XContentType contentType) { - safeUpsertRequest().source(source, contentType); + public UpdateRequest upsert(Map source, MediaType mediaType) { + safeUpsertRequest().source(source, mediaType); return this; } /** * Sets the doc source of the update request to be used when the document does not exists. */ - public UpdateRequest upsert(String source, XContentType xContentType) { - safeUpsertRequest().source(source, xContentType); + public UpdateRequest upsert(String source, MediaType mediaType) { + safeUpsertRequest().source(source, mediaType); return this; } /** * Sets the doc source of the update request to be used when the document does not exists. */ - public UpdateRequest upsert(byte[] source, XContentType xContentType) { - safeUpsertRequest().source(source, xContentType); + public UpdateRequest upsert(byte[] source, MediaType mediaType) { + safeUpsertRequest().source(source, mediaType); return this; } /** * Sets the doc source of the update request to be used when the document does not exists. */ - public UpdateRequest upsert(byte[] source, int offset, int length, XContentType xContentType) { - safeUpsertRequest().source(source, offset, length, xContentType); + public UpdateRequest upsert(byte[] source, int offset, int length, MediaType mediaType) { + safeUpsertRequest().source(source, offset, length, mediaType); return this; } @@ -791,8 +790,8 @@ public UpdateRequest upsert(Object... source) { * Sets the doc source of the update request to be used when the document does not exists. The doc * includes field and value pairs. */ - public UpdateRequest upsert(XContentType xContentType, Object... source) { - safeUpsertRequest().source(xContentType, source); + public UpdateRequest upsert(MediaType mediaType, Object... source) { + safeUpsertRequest().source(mediaType, source); return this; } diff --git a/server/src/main/java/org/opensearch/action/update/UpdateRequestBuilder.java b/server/src/main/java/org/opensearch/action/update/UpdateRequestBuilder.java index 4fdcac0f6927a..c97d0b4f5d13d 100644 --- a/server/src/main/java/org/opensearch/action/update/UpdateRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/update/UpdateRequestBuilder.java @@ -39,8 +39,8 @@ import org.opensearch.action.support.single.instance.InstanceShardOperationRequestBuilder; import org.opensearch.client.OpenSearchClient; import org.opensearch.common.Nullable; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.VersionType; import org.opensearch.script.Script; @@ -230,7 +230,7 @@ public UpdateRequestBuilder setDoc(Map source) { /** * Sets the doc to use for updates when a script is not specified. */ - public UpdateRequestBuilder setDoc(Map source, XContentType contentType) { + public UpdateRequestBuilder setDoc(Map source, MediaType contentType) { request.doc(source, contentType); return this; } @@ -238,24 +238,24 @@ public UpdateRequestBuilder setDoc(Map source, XContentType cont /** * Sets the doc to use for updates when a script is not specified. */ - public UpdateRequestBuilder setDoc(String source, XContentType xContentType) { - request.doc(source, xContentType); + public UpdateRequestBuilder setDoc(String source, MediaType mediaType) { + request.doc(source, mediaType); return this; } /** * Sets the doc to use for updates when a script is not specified. */ - public UpdateRequestBuilder setDoc(byte[] source, XContentType xContentType) { - request.doc(source, xContentType); + public UpdateRequestBuilder setDoc(byte[] source, MediaType mediaType) { + request.doc(source, mediaType); return this; } /** * Sets the doc to use for updates when a script is not specified. */ - public UpdateRequestBuilder setDoc(byte[] source, int offset, int length, XContentType xContentType) { - request.doc(source, offset, length, xContentType); + public UpdateRequestBuilder setDoc(byte[] source, int offset, int length, MediaType mediaType) { + request.doc(source, offset, length, mediaType); return this; } @@ -272,8 +272,8 @@ public UpdateRequestBuilder setDoc(Object... source) { * Sets the doc to use for updates when a script is not specified, the doc provided * is a field and value pairs. */ - public UpdateRequestBuilder setDoc(XContentType xContentType, Object... source) { - request.doc(xContentType, source); + public UpdateRequestBuilder setDoc(MediaType mediaType, Object... source) { + request.doc(mediaType, source); return this; } @@ -305,32 +305,32 @@ public UpdateRequestBuilder setUpsert(Map source) { /** * Sets the doc source of the update request to be used when the document does not exists. */ - public UpdateRequestBuilder setUpsert(Map source, XContentType contentType) { - request.upsert(source, contentType); + public UpdateRequestBuilder setUpsert(Map source, MediaType mediaType) { + request.upsert(source, mediaType); return this; } /** * Sets the doc source of the update request to be used when the document does not exists. */ - public UpdateRequestBuilder setUpsert(String source, XContentType xContentType) { - request.upsert(source, xContentType); + public UpdateRequestBuilder setUpsert(String source, MediaType mediaType) { + request.upsert(source, mediaType); return this; } /** * Sets the doc source of the update request to be used when the document does not exists. */ - public UpdateRequestBuilder setUpsert(byte[] source, XContentType xContentType) { - request.upsert(source, xContentType); + public UpdateRequestBuilder setUpsert(byte[] source, MediaType mediaType) { + request.upsert(source, mediaType); return this; } /** * Sets the doc source of the update request to be used when the document does not exists. */ - public UpdateRequestBuilder setUpsert(byte[] source, int offset, int length, XContentType xContentType) { - request.upsert(source, offset, length, xContentType); + public UpdateRequestBuilder setUpsert(byte[] source, int offset, int length, MediaType mediaType) { + request.upsert(source, offset, length, mediaType); return this; } @@ -347,8 +347,8 @@ public UpdateRequestBuilder setUpsert(Object... source) { * Sets the doc source of the update request to be used when the document does not exists. The doc * includes field and value pairs. */ - public UpdateRequestBuilder setUpsert(XContentType xContentType, Object... source) { - request.upsert(xContentType, source); + public UpdateRequestBuilder setUpsert(MediaType mediaType, Object... source) { + request.upsert(mediaType, source); return this; } diff --git a/server/src/main/java/org/opensearch/client/ClusterAdminClient.java b/server/src/main/java/org/opensearch/client/ClusterAdminClient.java index f3c04b23dfd54..b93bf0cdb4429 100644 --- a/server/src/main/java/org/opensearch/client/ClusterAdminClient.java +++ b/server/src/main/java/org/opensearch/client/ClusterAdminClient.java @@ -159,7 +159,7 @@ import org.opensearch.action.search.PutSearchPipelineRequest; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.tasks.TaskId; /** @@ -669,7 +669,7 @@ public interface ClusterAdminClient extends OpenSearchClient { /** * Stores an ingest pipeline */ - PutPipelineRequestBuilder preparePutPipeline(String id, BytesReference source, XContentType xContentType); + PutPipelineRequestBuilder preparePutPipeline(String id, BytesReference source, MediaType mediaType); /** * Deletes a stored ingest pipeline @@ -719,7 +719,7 @@ public interface ClusterAdminClient extends OpenSearchClient { /** * Simulates an ingest pipeline */ - SimulatePipelineRequestBuilder prepareSimulatePipeline(BytesReference source, XContentType xContentType); + SimulatePipelineRequestBuilder prepareSimulatePipeline(BytesReference source, MediaType mediaType); /** * Explain the allocation of a shard diff --git a/server/src/main/java/org/opensearch/client/Requests.java b/server/src/main/java/org/opensearch/client/Requests.java index cad5bac8acf0d..3f4a191fa76d5 100644 --- a/server/src/main/java/org/opensearch/client/Requests.java +++ b/server/src/main/java/org/opensearch/client/Requests.java @@ -82,6 +82,8 @@ import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchScrollRequest; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; /** * A handy one stop shop for creating requests (make sure to import static this class). @@ -98,7 +100,7 @@ public class Requests { /** * The default content type to use to generate source documents when indexing. */ - public static XContentType INDEX_CONTENT_TYPE = XContentType.JSON; + public static MediaType INDEX_CONTENT_TYPE = MediaTypeRegistry.JSON; public static IndexRequest indexRequest() { return new IndexRequest(); diff --git a/server/src/main/java/org/opensearch/client/support/AbstractClient.java b/server/src/main/java/org/opensearch/client/support/AbstractClient.java index 40489e29ed9b5..beedea1dd477e 100644 --- a/server/src/main/java/org/opensearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/opensearch/client/support/AbstractClient.java @@ -413,7 +413,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; @@ -1224,8 +1224,8 @@ public ActionFuture putPipeline(PutPipelineRequest request } @Override - public PutPipelineRequestBuilder preparePutPipeline(String id, BytesReference source, XContentType xContentType) { - return new PutPipelineRequestBuilder(this, PutPipelineAction.INSTANCE, id, source, xContentType); + public PutPipelineRequestBuilder preparePutPipeline(String id, BytesReference source, MediaType mediaType) { + return new PutPipelineRequestBuilder(this, PutPipelineAction.INSTANCE, id, source, mediaType); } @Override @@ -1274,8 +1274,8 @@ public ActionFuture simulatePipeline(SimulatePipelineR } @Override - public SimulatePipelineRequestBuilder prepareSimulatePipeline(BytesReference source, XContentType xContentType) { - return new SimulatePipelineRequestBuilder(this, SimulatePipelineAction.INSTANCE, source, xContentType); + public SimulatePipelineRequestBuilder prepareSimulatePipeline(BytesReference source, MediaType mediaType) { + return new SimulatePipelineRequestBuilder(this, SimulatePipelineAction.INSTANCE, source, mediaType); } @Override diff --git a/server/src/main/java/org/opensearch/cluster/RepositoryCleanupInProgress.java b/server/src/main/java/org/opensearch/cluster/RepositoryCleanupInProgress.java index be471ab6a68ec..72a3519aca6f8 100644 --- a/server/src/main/java/org/opensearch/cluster/RepositoryCleanupInProgress.java +++ b/server/src/main/java/org/opensearch/cluster/RepositoryCleanupInProgress.java @@ -37,7 +37,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.repositories.RepositoryOperation; @@ -110,7 +110,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/cluster/SnapshotsInProgress.java b/server/src/main/java/org/opensearch/cluster/SnapshotsInProgress.java index 5f9c93ff254c9..be660755ff052 100644 --- a/server/src/main/java/org/opensearch/cluster/SnapshotsInProgress.java +++ b/server/src/main/java/org/opensearch/cluster/SnapshotsInProgress.java @@ -40,7 +40,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.index.shard.ShardId; @@ -699,7 +699,7 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override 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 c589d9bfeeab2..46d0d7fcbed74 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 @@ -48,8 +48,8 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.RunOnce; import org.opensearch.common.util.concurrent.UncategorizedExecutionException; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.Index; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.mapper.Mapping; import java.util.concurrent.Semaphore; @@ -153,7 +153,7 @@ int blockedThreads() { protected void sendUpdateMapping(Index index, Mapping mappingUpdate, ActionListener listener) { PutMappingRequest putMappingRequest = new PutMappingRequest(); putMappingRequest.setConcreteIndex(index); - putMappingRequest.source(mappingUpdate.toString(), XContentType.JSON); + putMappingRequest.source(mappingUpdate.toString(), MediaTypeRegistry.JSON); putMappingRequest.clusterManagerNodeTimeout(dynamicMappingUpdateTimeout); putMappingRequest.timeout(TimeValue.ZERO); client.execute( diff --git a/server/src/main/java/org/opensearch/cluster/awarenesshealth/ClusterAwarenessAttributeValueHealth.java b/server/src/main/java/org/opensearch/cluster/awarenesshealth/ClusterAwarenessAttributeValueHealth.java index 1520a293d2741..eae79e2ac0986 100644 --- a/server/src/main/java/org/opensearch/cluster/awarenesshealth/ClusterAwarenessAttributeValueHealth.java +++ b/server/src/main/java/org/opensearch/cluster/awarenesshealth/ClusterAwarenessAttributeValueHealth.java @@ -18,7 +18,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -293,7 +293,7 @@ private void setWeightInfo(ClusterState clusterState) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/cluster/awarenesshealth/ClusterAwarenessAttributesHealth.java b/server/src/main/java/org/opensearch/cluster/awarenesshealth/ClusterAwarenessAttributesHealth.java index 08832cb1e8807..01d9cfc4438e3 100644 --- a/server/src/main/java/org/opensearch/cluster/awarenesshealth/ClusterAwarenessAttributesHealth.java +++ b/server/src/main/java/org/opensearch/cluster/awarenesshealth/ClusterAwarenessAttributesHealth.java @@ -15,7 +15,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -279,7 +279,7 @@ public static ClusterAwarenessAttributesHealth fromXContent(XContentParser parse @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java b/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java index 4429136525534..89f45129dcd22 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java @@ -72,9 +72,9 @@ import org.opensearch.common.util.concurrent.OpenSearchExecutors; import org.opensearch.common.util.concurrent.ListenableFuture; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.common.lease.Releasable; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.discovery.Discovery; import org.opensearch.discovery.DiscoveryModule; import org.opensearch.discovery.DiscoveryStats; @@ -1320,20 +1320,24 @@ assert getLocalNode().equals(clusterState.getNodes().get(getLocalNode().getId()) // deserialized from the resulting JSON private boolean assertPreviousStateConsistency(ClusterChangedEvent event) { assert event.previousState() == coordinationState.get().getLastAcceptedState() - || XContentHelper.convertToMap(JsonXContent.jsonXContent, Strings.toString(XContentType.JSON, event.previousState()), false) + || XContentHelper.convertToMap( + JsonXContent.jsonXContent, + Strings.toString(MediaTypeRegistry.JSON, event.previousState()), + false + ) .equals( XContentHelper.convertToMap( JsonXContent.jsonXContent, Strings.toString( - XContentType.JSON, + MediaTypeRegistry.JSON, clusterStateWithNoClusterManagerBlock(coordinationState.get().getLastAcceptedState()) ), false ) - ) : Strings.toString(XContentType.JSON, event.previousState()) + ) : Strings.toString(MediaTypeRegistry.JSON, event.previousState()) + " vs " + Strings.toString( - XContentType.JSON, + MediaTypeRegistry.JSON, clusterStateWithNoClusterManagerBlock(coordinationState.get().getLastAcceptedState()) ); return true; diff --git a/server/src/main/java/org/opensearch/cluster/decommission/DecommissionAttributeMetadata.java b/server/src/main/java/org/opensearch/cluster/decommission/DecommissionAttributeMetadata.java index 5a9c82a3849e9..3df807a4f94d3 100644 --- a/server/src/main/java/org/opensearch/cluster/decommission/DecommissionAttributeMetadata.java +++ b/server/src/main/java/org/opensearch/cluster/decommission/DecommissionAttributeMetadata.java @@ -17,7 +17,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -282,6 +282,6 @@ public static void toXContent( @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/cluster/health/ClusterShardHealth.java b/server/src/main/java/org/opensearch/cluster/health/ClusterShardHealth.java index 32b54ac947ebd..ae0abdf40ad5a 100644 --- a/server/src/main/java/org/opensearch/cluster/health/ClusterShardHealth.java +++ b/server/src/main/java/org/opensearch/cluster/health/ClusterShardHealth.java @@ -41,9 +41,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -275,7 +275,7 @@ public static ClusterShardHealth fromXContent(XContentParser parser) throws IOEx @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/cluster/metadata/AliasMetadata.java b/server/src/main/java/org/opensearch/cluster/metadata/AliasMetadata.java index 5e4de1be71214..5558756b56541 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/AliasMetadata.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/AliasMetadata.java @@ -43,7 +43,6 @@ import org.opensearch.common.util.set.Sets; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; @@ -260,7 +259,7 @@ public static Diff readDiffFrom(StreamInput in) throws IOExceptio @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } @Override diff --git a/server/src/main/java/org/opensearch/cluster/metadata/ComponentTemplate.java b/server/src/main/java/org/opensearch/cluster/metadata/ComponentTemplate.java index 7c5e0f664df4e..4cb25074e9353 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/ComponentTemplate.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/ComponentTemplate.java @@ -38,9 +38,9 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -152,7 +152,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/cluster/metadata/ComponentTemplateMetadata.java b/server/src/main/java/org/opensearch/cluster/metadata/ComponentTemplateMetadata.java index 2e700389e4fc9..874e9c496f4bc 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/ComponentTemplateMetadata.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/ComponentTemplateMetadata.java @@ -39,9 +39,9 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -155,7 +155,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** diff --git a/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java b/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java index b9b7c132ba2cf..3e1246724fb62 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java @@ -40,9 +40,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -278,7 +278,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** diff --git a/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplateMetadata.java b/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplateMetadata.java index b72c0fdf81e41..89098bb0a6466 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplateMetadata.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplateMetadata.java @@ -40,8 +40,8 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.ParseField; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -156,7 +156,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** diff --git a/server/src/main/java/org/opensearch/cluster/metadata/DataStreamMetadata.java b/server/src/main/java/org/opensearch/cluster/metadata/DataStreamMetadata.java index c7854355ea5cc..094e16c18aba8 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/DataStreamMetadata.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/DataStreamMetadata.java @@ -39,9 +39,9 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -160,7 +160,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java index 0779f61d97bf0..71237ad916ecc 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java @@ -60,8 +60,8 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.set.Sets; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.index.Index; @@ -1155,7 +1155,7 @@ public static List collectMappings(final ClusterState state, Optional.ofNullable(template.getDataStreamTemplate()) .map(ComposableIndexTemplate.DataStreamTemplate::getDataStreamMappingSnippet) .map(mapping -> { - try (XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent())) { + try (XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder()) { builder.value(mapping); return new CompressedXContent(BytesReference.bytes(builder)); } catch (IOException e) { diff --git a/server/src/main/java/org/opensearch/cluster/metadata/RepositoriesMetadata.java b/server/src/main/java/org/opensearch/cluster/metadata/RepositoriesMetadata.java index 9123e4a8d2de3..d7b8c12eb9120 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/RepositoriesMetadata.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/RepositoriesMetadata.java @@ -42,7 +42,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -292,6 +292,6 @@ public static void toXContent(RepositoryMetadata repository, XContentBuilder bui @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java b/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java index c8c28c5db67c5..eaa249d5cd341 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java @@ -49,9 +49,9 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.gateway.GatewayService; import org.opensearch.indices.IndexTemplateMissingException; import org.opensearch.plugins.Plugin; @@ -162,7 +162,10 @@ void upgradeTemplates(Map changes, Set deletions } for (Map.Entry change : changes.entrySet()) { - PutIndexTemplateRequest request = new PutIndexTemplateRequest(change.getKey()).source(change.getValue(), XContentType.JSON); + PutIndexTemplateRequest request = new PutIndexTemplateRequest(change.getKey()).source( + change.getValue(), + MediaTypeRegistry.JSON + ); request.clusterManagerNodeTimeout(TimeValue.timeValueMinutes(1)); client.admin().indices().putTemplate(request, new ActionListener() { @Override @@ -269,7 +272,7 @@ private BytesReference toBytesReference(IndexTemplateMetadata templateMetadata) return XContentHelper.toXContent((builder, params) -> { IndexTemplateMetadata.Builder.toInnerXContentWithTypes(templateMetadata, builder, params); return builder; - }, XContentType.JSON, PARAMS, false); + }, MediaTypeRegistry.JSON, PARAMS, false); } catch (IOException ex) { throw new IllegalStateException("Cannot serialize template [" + templateMetadata.getName() + "]", ex); } diff --git a/server/src/main/java/org/opensearch/cluster/metadata/WeightedRoutingMetadata.java b/server/src/main/java/org/opensearch/cluster/metadata/WeightedRoutingMetadata.java index f4602e357cdbb..cc56a0daf6db7 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/WeightedRoutingMetadata.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/WeightedRoutingMetadata.java @@ -18,7 +18,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -192,6 +192,6 @@ public static void toXContent(WeightedRouting weightedRouting, XContentBuilder b @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/cluster/routing/allocation/command/AllocationCommands.java b/server/src/main/java/org/opensearch/cluster/routing/allocation/command/AllocationCommands.java index 0bae1bb8ee913..ac804819443a5 100644 --- a/server/src/main/java/org/opensearch/cluster/routing/allocation/command/AllocationCommands.java +++ b/server/src/main/java/org/opensearch/cluster/routing/allocation/command/AllocationCommands.java @@ -39,7 +39,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -217,6 +217,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/common/geo/builders/ShapeBuilder.java b/server/src/main/java/org/opensearch/common/geo/builders/ShapeBuilder.java index 54d913b961f9a..54ddeda7e70aa 100644 --- a/server/src/main/java/org/opensearch/common/geo/builders/ShapeBuilder.java +++ b/server/src/main/java/org/opensearch/common/geo/builders/ShapeBuilder.java @@ -45,13 +45,13 @@ import org.opensearch.core.common.io.stream.NamedWriteable; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.locationtech.spatial4j.context.jts.JtsSpatialContext; import org.locationtech.spatial4j.exception.InvalidShapeException; import org.locationtech.spatial4j.shape.Shape; import org.locationtech.spatial4j.shape.jts.JtsGeometry; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.ArrayList; @@ -521,6 +521,6 @@ public String getWriteableName() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/common/settings/Setting.java b/server/src/main/java/org/opensearch/common/settings/Setting.java index adb3840bd7e00..6549a00ea1fdc 100644 --- a/server/src/main/java/org/opensearch/common/settings/Setting.java +++ b/server/src/main/java/org/opensearch/common/settings/Setting.java @@ -43,7 +43,6 @@ import org.opensearch.common.unit.MemorySizeValue; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.io.stream.StreamInput; @@ -51,6 +50,7 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -603,7 +603,7 @@ public final XContentBuilder toXContent(XContentBuilder builder, Params params) @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } /** @@ -2338,7 +2338,7 @@ public static Setting> listSetting( private static List parseableStringToList(String parsableString) { // fromXContent doesn't use named xcontent or deprecation. try ( - XContentParser xContentParser = XContentType.JSON.xContent() + XContentParser xContentParser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, parsableString) ) { XContentParser.Token token = xContentParser.nextToken(); @@ -2360,7 +2360,7 @@ private static List parseableStringToList(String parsableString) { private static String arrayToParsableString(List array) { try { - XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder builder = XContentBuilder.builder(MediaTypeRegistry.JSON.xContent()); builder.startArray(); for (String element : array) { builder.value(element); diff --git a/server/src/main/java/org/opensearch/common/settings/Settings.java b/server/src/main/java/org/opensearch/common/settings/Settings.java index da53e41ec4cb1..dec0dc2617a54 100644 --- a/server/src/main/java/org/opensearch/common/settings/Settings.java +++ b/server/src/main/java/org/opensearch/common/settings/Settings.java @@ -1081,7 +1081,7 @@ private void processLegacyLists(Map map) { */ public Builder loadFromMap(Map map) { // TODO: do this without a serialization round-trip - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.map(map); return loadFromSource(builder.toString(), builder.contentType()); } catch (IOException e) { @@ -1092,9 +1092,9 @@ public Builder loadFromMap(Map map) { /** * Loads settings from the actual string content that represents them using {@link #fromXContent(XContentParser)} */ - public Builder loadFromSource(String source, MediaType xContentType) { + public Builder loadFromSource(String source, MediaType mediaType) { try ( - XContentParser parser = xContentType.xContent() + XContentParser parser = mediaType.xContent() .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, source) ) { this.put(fromXContent(parser, true, true)); @@ -1117,17 +1117,17 @@ public Builder loadFromPath(Path path) throws IOException { * Loads settings from a stream that represents them using {@link #fromXContent(XContentParser)} */ public Builder loadFromStream(String resourceName, InputStream is, boolean acceptNullValues) throws IOException { - final XContentType xContentType; + final MediaType mediaType; if (resourceName.endsWith(".json")) { - xContentType = XContentType.JSON; + mediaType = MediaTypeRegistry.JSON; } else if (resourceName.endsWith(".yml") || resourceName.endsWith(".yaml")) { - xContentType = XContentType.YAML; + mediaType = XContentType.YAML; } else { throw new IllegalArgumentException("unable to detect content type from resource name [" + resourceName + "]"); } // fromXContent doesn't use named xcontent or deprecation. try ( - XContentParser parser = xContentType.xContent() + XContentParser parser = mediaType.xContent() .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, is) ) { if (parser.currentToken() == null) { @@ -1427,7 +1427,7 @@ public void close() throws IOException { @Override public String toString() { - try (XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent())) { + try (XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder()) { builder.startObject(); toXContent(builder, new MapParams(Collections.singletonMap("flat_settings", "true"))); builder.endObject(); diff --git a/server/src/main/java/org/opensearch/common/settings/SettingsModule.java b/server/src/main/java/org/opensearch/common/settings/SettingsModule.java index 82c56608e7b26..becf5944171c5 100644 --- a/server/src/main/java/org/opensearch/common/settings/SettingsModule.java +++ b/server/src/main/java/org/opensearch/common/settings/SettingsModule.java @@ -37,9 +37,9 @@ import org.opensearch.common.inject.Binder; import org.opensearch.common.inject.Module; import org.opensearch.common.util.FeatureFlags; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Arrays; @@ -156,7 +156,7 @@ public SettingsModule( builder.append(System.lineSeparator()); builder.append(System.lineSeparator()); builder.append("curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '"); - try (XContentBuilder xContentBuilder = XContentBuilder.builder(XContentType.JSON.xContent())) { + try (XContentBuilder xContentBuilder = MediaTypeRegistry.JSON.contentBuilder()) { xContentBuilder.prettyPrint(); xContentBuilder.startObject(); indexSettings.toXContent(xContentBuilder, new ToXContent.MapParams(Collections.singletonMap("flat_settings", "true"))); diff --git a/server/src/main/java/org/opensearch/common/xcontent/JsonToStringXContentParser.java b/server/src/main/java/org/opensearch/common/xcontent/JsonToStringXContentParser.java index 7510c712e3b4b..02ee911a2c400 100644 --- a/server/src/main/java/org/opensearch/common/xcontent/JsonToStringXContentParser.java +++ b/server/src/main/java/org/opensearch/common/xcontent/JsonToStringXContentParser.java @@ -12,6 +12,8 @@ import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.xcontent.AbstractXContentParser; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentLocation; @@ -70,7 +72,7 @@ public XContentParser parseObject() throws IOException { builder.field(this.fieldTypeName + VALUE_SUFFIX, valueList); builder.field(this.fieldTypeName + VALUE_AND_PATH_SUFFIX, valueAndPathList); builder.endObject(); - String jString = XContentHelper.convertToJson(BytesReference.bytes(builder), false, XContentType.JSON); + String jString = XContentHelper.convertToJson(BytesReference.bytes(builder), false, MediaTypeRegistry.JSON); return JsonXContent.jsonXContent.createParser(this.xContentRegistry, this.deprecationHandler, String.valueOf(jString)); } @@ -132,8 +134,8 @@ private void parseValue(StringBuilder parsedFields) throws IOException { } @Override - public XContentType contentType() { - return XContentType.JSON; + public MediaType contentType() { + return MediaTypeRegistry.JSON; } @Override diff --git a/server/src/main/java/org/opensearch/common/xcontent/XContentHelper.java b/server/src/main/java/org/opensearch/common/xcontent/XContentHelper.java index 9e5e1aa585d70..35d5188143450 100644 --- a/server/src/main/java/org/opensearch/common/xcontent/XContentHelper.java +++ b/server/src/main/java/org/opensearch/common/xcontent/XContentHelper.java @@ -158,11 +158,8 @@ public static Tuple> convertToMap(BytesReferen /** * Converts the given bytes into a map that is optionally ordered. The provided {@link XContentType} must be non-null. */ - public static Tuple> convertToMap( - BytesReference bytes, - boolean ordered, - MediaType xContentType - ) throws OpenSearchParseException { + public static Tuple> convertToMap(BytesReference bytes, boolean ordered, MediaType mediaType) + throws OpenSearchParseException { try { final MediaType contentType; InputStream input; @@ -178,13 +175,13 @@ public static Tuple> convertToMap( final byte[] raw = arr.array(); final int offset = arr.offset(); final int length = arr.length(); - contentType = xContentType != null ? xContentType : MediaTypeRegistry.mediaTypeFromBytes(raw, offset, length); + contentType = mediaType != null ? mediaType : MediaTypeRegistry.mediaTypeFromBytes(raw, offset, length); return new Tuple<>(Objects.requireNonNull(contentType), convertToMap(contentType.xContent(), raw, offset, length, ordered)); } else { input = bytes.streamInput(); } try (InputStream stream = input) { - contentType = xContentType != null ? xContentType : MediaTypeRegistry.xContentType(stream); + contentType = mediaType != null ? mediaType : MediaTypeRegistry.xContentType(stream); return new Tuple<>(Objects.requireNonNull(contentType), convertToMap(contentType.xContent(), stream, ordered)); } } catch (IOException e) { @@ -262,8 +259,8 @@ public static String convertToJson(BytesReference bytes, boolean reformatJson, b return convertToJson(bytes, reformatJson, prettyPrint, MediaTypeRegistry.xContent(bytes.toBytesRef().bytes)); } - public static String convertToJson(BytesReference bytes, boolean reformatJson, MediaType xContentType) throws IOException { - return convertToJson(bytes, reformatJson, false, xContentType); + public static String convertToJson(BytesReference bytes, boolean reformatJson, MediaType mediaType) throws IOException { + return convertToJson(bytes, reformatJson, false, mediaType); } /** @@ -276,7 +273,7 @@ public static String convertToJson(BytesReference bytes, boolean reformatJson, M * @throws IOException if the reformatting fails, e.g. because the JSON is not well-formed */ public static String stripWhitespace(String json) throws IOException { - return convertToJson(new BytesArray(json), true, XContentType.JSON); + return convertToJson(new BytesArray(json), true, MediaTypeRegistry.JSON); } /** @@ -296,7 +293,7 @@ public static String convertToJson(BytesReference bytes, boolean reformatJson, b public static String convertToJson(BytesReference bytes, boolean reformatJson, boolean prettyPrint, MediaType mediaType) throws IOException { Objects.requireNonNull(mediaType); - if (mediaType == XContentType.JSON && !reformatJson) { + if (mediaType == MediaTypeRegistry.JSON && !reformatJson) { return bytes.utf8ToString(); } @@ -492,19 +489,23 @@ public static void writeRawField(String field, BytesReference source, XContentTy */ @Deprecated public static BytesReference toXContent(ToXContent toXContent, XContentType xContentType, boolean humanReadable) throws IOException { - return toXContent(toXContent, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); + return org.opensearch.core.xcontent.XContentHelper.toXContent(toXContent, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); } /** - * Returns the bytes that represent the XContent output of the provided {@link ToXContent} object, using the provided - * {@link XContentType}. Wraps the output into a new anonymous object according to the value returned - * by the {@link ToXContent#isFragment()} method returns. - * - * @deprecated use {@link #toXContent(ToXContent, MediaType, Params, boolean)} instead - */ + * Returns the bytes that represent the XContent output of the provided {@link ToXContent} object, using the provided + * {@link XContentType}. Wraps the output into a new anonymous object according to the value returned + * by the {@link ToXContent#isFragment()} method returns. + * + * @deprecated use {@link org.opensearch.core.xcontent.XContentHelper#toXContent(ToXContent, MediaType, ToXContent.Params, boolean)} instead + */ @Deprecated - public static BytesReference toXContent(ToXContent toXContent, XContentType xContentType, Params params, boolean humanReadable) - throws IOException { + public static BytesReference toXContent( + ToXContent toXContent, + XContentType xContentType, + ToXContent.Params params, + boolean humanReadable + ) throws IOException { try (XContentBuilder builder = XContentBuilder.builder(xContentType.xContent())) { builder.humanReadable(humanReadable); if (toXContent.isFragment()) { @@ -518,26 +519,6 @@ public static BytesReference toXContent(ToXContent toXContent, XContentType xCon } } - /** - * Returns the bytes that represent the XContent output of the provided {@link ToXContent} object, using the provided - * {@link XContentType}. Wraps the output into a new anonymous object according to the value returned - * by the {@link ToXContent#isFragment()} method returns. - */ - public static BytesReference toXContent(ToXContent toXContent, MediaType mediaType, Params params, boolean humanReadable) - throws IOException { - try (XContentBuilder builder = XContentBuilder.builder(mediaType.xContent())) { - builder.humanReadable(humanReadable); - if (toXContent.isFragment()) { - builder.startObject(); - } - toXContent.toXContent(builder, params); - if (toXContent.isFragment()) { - builder.endObject(); - } - return BytesReference.bytes(builder); - } - } - /** * Returns the contents of an object as an unparsed BytesReference * diff --git a/server/src/main/java/org/opensearch/index/get/GetResult.java b/server/src/main/java/org/opensearch/index/get/GetResult.java index 66d74f6651073..6e069e0bd69bd 100644 --- a/server/src/main/java/org/opensearch/index/get/GetResult.java +++ b/server/src/main/java/org/opensearch/index/get/GetResult.java @@ -41,11 +41,11 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.IgnoredFieldMapper; import org.opensearch.index.mapper.MapperService; import org.opensearch.index.mapper.SourceFieldMapper; @@ -477,6 +477,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/index/mapper/AbstractGeometryFieldMapper.java b/server/src/main/java/org/opensearch/index/mapper/AbstractGeometryFieldMapper.java index e0798e74b4f2f..eafd40fa7283e 100644 --- a/server/src/main/java/org/opensearch/index/mapper/AbstractGeometryFieldMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/AbstractGeometryFieldMapper.java @@ -39,10 +39,10 @@ import org.opensearch.core.ParseField; import org.opensearch.common.geo.GeoJsonGeometryFormat; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.MapXContentParser; import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.index.query.QueryShardContext; @@ -141,7 +141,7 @@ public Object parseAndFormatObject(Object value, String format) { NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, Collections.singletonMap("dummy_field", value), - XContentType.JSON + MediaTypeRegistry.JSON ) ) { parser.nextToken(); // start object diff --git a/server/src/main/java/org/opensearch/index/mapper/DocumentMapper.java b/server/src/main/java/org/opensearch/index/mapper/DocumentMapper.java index 2461a72a2d041..632103a65ee72 100644 --- a/server/src/main/java/org/opensearch/index/mapper/DocumentMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/DocumentMapper.java @@ -44,10 +44,10 @@ import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.settings.Settings; import org.opensearch.core.common.text.Text; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.IndexSettings; import org.opensearch.index.analysis.IndexAnalyzers; import org.opensearch.index.mapper.MapperService.MergeReason; @@ -249,13 +249,13 @@ public ParsedDocument parse(SourceToParse source) throws MapperParsingException } public ParsedDocument createDeleteTombstoneDoc(String index, String id) throws MapperParsingException { - final SourceToParse emptySource = new SourceToParse(index, id, new BytesArray("{}"), XContentType.JSON); + final SourceToParse emptySource = new SourceToParse(index, id, new BytesArray("{}"), MediaTypeRegistry.JSON); return documentParser.parseDocument(emptySource, deleteTombstoneMetadataFieldMappers).toTombstone(); } public ParsedDocument createNoopTombstoneDoc(String index, String reason) throws MapperParsingException { final String id = ""; // _id won't be used. - final SourceToParse sourceToParse = new SourceToParse(index, id, new BytesArray("{}"), XContentType.JSON); + final SourceToParse sourceToParse = new SourceToParse(index, id, new BytesArray("{}"), MediaTypeRegistry.JSON); final ParsedDocument parsedDoc = documentParser.parseDocument(sourceToParse, noopTombstoneMetadataFieldMappers).toTombstone(); // Store the reason of a noop as a raw string in the _source field final BytesRef byteRef = new BytesRef(reason); diff --git a/server/src/main/java/org/opensearch/index/mapper/DocumentMapperParser.java b/server/src/main/java/org/opensearch/index/mapper/DocumentMapperParser.java index 69775481a3056..1e78b7cf73f9b 100644 --- a/server/src/main/java/org/opensearch/index/mapper/DocumentMapperParser.java +++ b/server/src/main/java/org/opensearch/index/mapper/DocumentMapperParser.java @@ -37,9 +37,9 @@ import org.opensearch.common.collect.Tuple; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.time.DateFormatter; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.IndexSettings; import org.opensearch.index.query.QueryShardContext; import org.opensearch.index.similarity.SimilarityService; @@ -119,7 +119,7 @@ public Mapper.TypeParser.ParserContext parserContext(DateFormatter dateFormatter public DocumentMapper parse(@Nullable String type, CompressedXContent source) throws MapperParsingException { Map mapping = null; if (source != null) { - Map root = XContentHelper.convertToMap(source.compressedReference(), true, XContentType.JSON).v2(); + Map root = XContentHelper.convertToMap(source.compressedReference(), true, MediaTypeRegistry.JSON).v2(); Tuple> t = extractMapping(type, root); type = t.v1(); mapping = t.v2(); diff --git a/server/src/main/java/org/opensearch/index/mapper/GeoShapeParser.java b/server/src/main/java/org/opensearch/index/mapper/GeoShapeParser.java index 128a7faf2791a..8d97469e49c8f 100644 --- a/server/src/main/java/org/opensearch/index/mapper/GeoShapeParser.java +++ b/server/src/main/java/org/opensearch/index/mapper/GeoShapeParser.java @@ -35,9 +35,9 @@ import org.opensearch.common.geo.GeometryFormat; import org.opensearch.common.geo.GeometryParser; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.MapXContentParser; import org.opensearch.geometry.Geometry; @@ -75,7 +75,7 @@ public Object parseAndFormatObject(Object value, String format) { NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, Collections.singletonMap("dummy_field", value), - XContentType.JSON + MediaTypeRegistry.JSON ) ) { parser.nextToken(); // start object diff --git a/server/src/main/java/org/opensearch/index/mapper/MapperService.java b/server/src/main/java/org/opensearch/index/mapper/MapperService.java index 6a44d4dcfd328..ca8da9bfeac01 100644 --- a/server/src/main/java/org/opensearch/index/mapper/MapperService.java +++ b/server/src/main/java/org/opensearch/index/mapper/MapperService.java @@ -48,8 +48,8 @@ import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.AbstractIndexComponent; @@ -253,7 +253,7 @@ public DocumentMapperParser documentMapperParser() { */ public static Map parseMapping(NamedXContentRegistry xContentRegistry, String mappingSource) throws IOException { try ( - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, mappingSource) ) { return parser.map(); @@ -348,7 +348,7 @@ private void assertMappingVersion( + "to be the same as new mapping [" + newSource + "]"; - final CompressedXContent mapperSource = new CompressedXContent(Strings.toString(XContentType.JSON, mapper)); + final CompressedXContent mapperSource = new CompressedXContent(Strings.toString(MediaTypeRegistry.JSON, mapper)); assert currentSource.equals(mapperSource) : "expected current mapping [" + currentSource + "] for type [" @@ -543,7 +543,7 @@ public static boolean isMappingSourceTyped(String type, Map mapp } public static boolean isMappingSourceTyped(String type, CompressedXContent mappingSource) { - Map root = XContentHelper.convertToMap(mappingSource.compressedReference(), true, XContentType.JSON).v2(); + Map root = XContentHelper.convertToMap(mappingSource.compressedReference(), true, MediaTypeRegistry.JSON).v2(); return isMappingSourceTyped(type, root); } diff --git a/server/src/main/java/org/opensearch/index/mapper/RootObjectMapper.java b/server/src/main/java/org/opensearch/index/mapper/RootObjectMapper.java index e6985010b140a..ce3d6eef19af2 100644 --- a/server/src/main/java/org/opensearch/index/mapper/RootObjectMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/RootObjectMapper.java @@ -37,8 +37,8 @@ import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.time.DateFormatter; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.mapper.DynamicTemplate.XContentFieldType; @@ -459,7 +459,7 @@ private static void validateDynamicTemplate(Mapper.TypeParser.ParserContext pars Locale.ROOT, "dynamic template [%s] has invalid content [%s]", dynamicTemplate.getName(), - Strings.toString(XContentType.JSON, dynamicTemplate) + Strings.toString(MediaTypeRegistry.JSON, dynamicTemplate) ); final String deprecationMessage; diff --git a/server/src/main/java/org/opensearch/index/query/AbstractQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/AbstractQueryBuilder.java index 99253afccb0d2..ef1eb858d11e2 100644 --- a/server/src/main/java/org/opensearch/index/query/AbstractQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/AbstractQueryBuilder.java @@ -42,9 +42,9 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.lucene.BytesRefs; import org.opensearch.common.xcontent.SuggestingErrorOnUnknown; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.AbstractObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedObjectNotFoundException; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentLocation; @@ -395,6 +395,6 @@ protected static void declareStandardFields(AbstractObjectParser fields = new ArrayList<>(); diff --git a/server/src/main/java/org/opensearch/index/query/SpanNearQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/SpanNearQueryBuilder.java index 320ee23d6b4af..6a22490a17011 100644 --- a/server/src/main/java/org/opensearch/index/query/SpanNearQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/SpanNearQueryBuilder.java @@ -39,8 +39,8 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentLocation; import org.opensearch.core.xcontent.XContentParser; @@ -445,7 +445,7 @@ public final int hashCode() { @Override public final String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } // copied from AbstractQueryBuilder diff --git a/server/src/main/java/org/opensearch/index/reindex/BulkByScrollTask.java b/server/src/main/java/org/opensearch/index/reindex/BulkByScrollTask.java index 6fbe30cc0bb74..e1a952d81ead3 100644 --- a/server/src/main/java/org/opensearch/index/reindex/BulkByScrollTask.java +++ b/server/src/main/java/org/opensearch/index/reindex/BulkByScrollTask.java @@ -41,8 +41,8 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -1048,9 +1048,9 @@ public static StatusOrException fromXContent(XContentParser parser) throws IOExc @Override public String toString() { if (exception != null) { - return "BulkByScrollTask{error=" + Strings.toString(XContentType.JSON, this) + "}"; + return "BulkByScrollTask{error=" + Strings.toString(MediaTypeRegistry.JSON, this) + "}"; } else { - return "BulkByScrollTask{status=" + Strings.toString(XContentType.JSON, this) + "}"; + return "BulkByScrollTask{status=" + Strings.toString(MediaTypeRegistry.JSON, this) + "}"; } } diff --git a/server/src/main/java/org/opensearch/index/reindex/ScrollableHitSource.java b/server/src/main/java/org/opensearch/index/reindex/ScrollableHitSource.java index b7a71da2fef9e..59426fd8cc0b8 100644 --- a/server/src/main/java/org/opensearch/index/reindex/ScrollableHitSource.java +++ b/server/src/main/java/org/opensearch/index/reindex/ScrollableHitSource.java @@ -47,9 +47,9 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.unit.TimeValue; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.seqno.SequenceNumbers; import org.opensearch.core.rest.RestStatus; import org.opensearch.search.SearchHit; @@ -499,7 +499,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } } diff --git a/server/src/main/java/org/opensearch/index/search/stats/SearchStats.java b/server/src/main/java/org/opensearch/index/search/stats/SearchStats.java index b5781de7cbd62..90dfe0a87f6d0 100644 --- a/server/src/main/java/org/opensearch/index/search/stats/SearchStats.java +++ b/server/src/main/java/org/opensearch/index/search/stats/SearchStats.java @@ -39,7 +39,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; @@ -414,7 +414,7 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params par @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } /** diff --git a/server/src/main/java/org/opensearch/index/shard/PrimaryReplicaSyncer.java b/server/src/main/java/org/opensearch/index/shard/PrimaryReplicaSyncer.java index 7c49c08bbc00f..a5d5e7dc545e1 100644 --- a/server/src/main/java/org/opensearch/index/shard/PrimaryReplicaSyncer.java +++ b/server/src/main/java/org/opensearch/index/shard/PrimaryReplicaSyncer.java @@ -47,8 +47,8 @@ import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.util.concurrent.AbstractRunnable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.util.io.IOUtils; import org.opensearch.index.seqno.SequenceNumbers; @@ -516,7 +516,7 @@ public void writeTo(StreamOutput out) throws IOException { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/index/shard/RemoveCorruptedShardDataCommand.java b/server/src/main/java/org/opensearch/index/shard/RemoveCorruptedShardDataCommand.java index 9a9733d0c5533..f33c56a114179 100644 --- a/server/src/main/java/org/opensearch/index/shard/RemoveCorruptedShardDataCommand.java +++ b/server/src/main/java/org/opensearch/index/shard/RemoveCorruptedShardDataCommand.java @@ -60,9 +60,9 @@ import org.opensearch.common.io.PathUtils; import org.opensearch.common.lucene.Lucene; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.env.Environment; import org.opensearch.env.NodeEnvironment; import org.opensearch.env.NodeMetadata; @@ -514,7 +514,7 @@ private void printRerouteCommand(ShardPath shardPath, Terminal terminal, boolean ); terminal.println(""); - terminal.println("POST /_cluster/reroute\n" + Strings.toString(XContentType.JSON, commands, true, true)); + terminal.println("POST /_cluster/reroute\n" + Strings.toString(MediaTypeRegistry.JSON, commands, true, true)); terminal.println(""); terminal.println("You must accept the possibility of data loss by changing the `accept_data_loss` parameter to `true`."); terminal.println(""); diff --git a/server/src/main/java/org/opensearch/index/translog/TranslogStats.java b/server/src/main/java/org/opensearch/index/translog/TranslogStats.java index 45a07b7125901..cf279334c7557 100644 --- a/server/src/main/java/org/opensearch/index/translog/TranslogStats.java +++ b/server/src/main/java/org/opensearch/index/translog/TranslogStats.java @@ -36,7 +36,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.common.unit.ByteSizeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; @@ -146,7 +146,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } @Override diff --git a/server/src/main/java/org/opensearch/indices/IndicesService.java b/server/src/main/java/org/opensearch/indices/IndicesService.java index 844f4fec706f3..f1cd0d1d1f291 100644 --- a/server/src/main/java/org/opensearch/indices/IndicesService.java +++ b/server/src/main/java/org/opensearch/indices/IndicesService.java @@ -82,7 +82,6 @@ import org.opensearch.common.util.iterable.Iterables; import org.opensearch.common.util.set.Sets; import org.opensearch.common.xcontent.LoggingDeprecationHandler; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; import org.opensearch.common.lease.Releasable; import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException; @@ -950,7 +949,7 @@ public IndexShard createShard( .indices() .preparePutMapping() .setConcreteIndex(shardRouting.index()) // concrete index - no name clash, it uses uuid - .setSource(mapping.source().string(), XContentType.JSON) + .setSource(mapping.source().string(), MediaTypeRegistry.JSON) .get(); }, this); return indexShard; diff --git a/server/src/main/java/org/opensearch/ingest/ConfigurationUtils.java b/server/src/main/java/org/opensearch/ingest/ConfigurationUtils.java index 894d699aee7f5..9fd9a866ee7e3 100644 --- a/server/src/main/java/org/opensearch/ingest/ConfigurationUtils.java +++ b/server/src/main/java/org/opensearch/ingest/ConfigurationUtils.java @@ -39,10 +39,10 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.script.Script; import org.opensearch.script.ScriptService; @@ -578,7 +578,7 @@ private static Script extractConditional(Map config) throws IOEx try ( XContentBuilder builder = XContentBuilder.builder(JsonXContent.jsonXContent).map(normalizeScript(scriptSource)); InputStream stream = BytesReference.bytes(builder).streamInput(); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, stream) ) { return Script.parse(parser); diff --git a/server/src/main/java/org/opensearch/ingest/PipelineConfiguration.java b/server/src/main/java/org/opensearch/ingest/PipelineConfiguration.java index 3603437d25fd2..f18050f211933 100644 --- a/server/src/main/java/org/opensearch/ingest/PipelineConfiguration.java +++ b/server/src/main/java/org/opensearch/ingest/PipelineConfiguration.java @@ -42,6 +42,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ContextParser; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -151,7 +152,7 @@ public static Diff readDiffFrom(StreamInput in) throws IO @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/persistent/PersistentTasksCustomMetadata.java b/server/src/main/java/org/opensearch/persistent/PersistentTasksCustomMetadata.java index bb751cccd7d9c..c83362ac2d5ab 100644 --- a/server/src/main/java/org/opensearch/persistent/PersistentTasksCustomMetadata.java +++ b/server/src/main/java/org/opensearch/persistent/PersistentTasksCustomMetadata.java @@ -45,8 +45,8 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ObjectParser.NamedObjectParser; import org.opensearch.core.xcontent.ToXContent; @@ -211,7 +211,7 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } public long getNumberOfTasksOnNode(String nodeId, String taskName) { @@ -429,7 +429,7 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } public String getId() { diff --git a/server/src/main/java/org/opensearch/persistent/PersistentTasksNodeService.java b/server/src/main/java/org/opensearch/persistent/PersistentTasksNodeService.java index a285874e4c116..9f6098e4fae8e 100644 --- a/server/src/main/java/org/opensearch/persistent/PersistentTasksNodeService.java +++ b/server/src/main/java/org/opensearch/persistent/PersistentTasksNodeService.java @@ -41,7 +41,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.gateway.GatewayService; import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask; @@ -364,7 +364,7 @@ public void writeTo(StreamOutput out) throws IOException { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/repositories/RepositoryCleanupResult.java b/server/src/main/java/org/opensearch/repositories/RepositoryCleanupResult.java index aaec824314068..4523a09769276 100644 --- a/server/src/main/java/org/opensearch/repositories/RepositoryCleanupResult.java +++ b/server/src/main/java/org/opensearch/repositories/RepositoryCleanupResult.java @@ -36,8 +36,8 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -105,6 +105,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/repositories/RepositoryInfo.java b/server/src/main/java/org/opensearch/repositories/RepositoryInfo.java index f61f6f6ca92bc..8aa86fc46d591 100644 --- a/server/src/main/java/org/opensearch/repositories/RepositoryInfo.java +++ b/server/src/main/java/org/opensearch/repositories/RepositoryInfo.java @@ -37,7 +37,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; @@ -144,6 +144,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/repositories/RepositoryStatsSnapshot.java b/server/src/main/java/org/opensearch/repositories/RepositoryStatsSnapshot.java index 2acb5e3fcf37f..43ef2393b5e1f 100644 --- a/server/src/main/java/org/opensearch/repositories/RepositoryStatsSnapshot.java +++ b/server/src/main/java/org/opensearch/repositories/RepositoryStatsSnapshot.java @@ -36,7 +36,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable;; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -125,6 +125,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java index f8745cf52327d..d66a8a3caa480 100644 --- a/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java @@ -96,9 +96,9 @@ import org.opensearch.common.util.concurrent.ConcurrentCollections; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.lease.Releasable; import org.opensearch.core.util.BytesRefUtils; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.mapper.MapperService; @@ -1987,7 +1987,7 @@ private void cacheRepositoryData(BytesReference updated, long generation) { private RepositoryData repositoryDataFromCachedEntry(Tuple cacheEntry) throws IOException { try (InputStream input = CompressorFactory.defaultCompressor().threadLocalInputStream(cacheEntry.v2().streamInput())) { return RepositoryData.snapshotsFromXContent( - XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, input), + MediaTypeRegistry.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, input), cacheEntry.v1() ); } @@ -2080,7 +2080,7 @@ private RepositoryData getRepositoryData(long indexGen) { // EMPTY is safe here because RepositoryData#fromXContent calls namedObject try ( InputStream blob = blobContainer().readBlob(snapshotsIndexBlobName); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, blob) ) { return RepositoryData.snapshotsFromXContent(parser, indexGen); diff --git a/server/src/main/java/org/opensearch/rest/RestController.java b/server/src/main/java/org/opensearch/rest/RestController.java index 1a8bddc094d26..134ec99023dd1 100644 --- a/server/src/main/java/org/opensearch/rest/RestController.java +++ b/server/src/main/java/org/opensearch/rest/RestController.java @@ -48,6 +48,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.util.FeatureFlags; import org.opensearch.common.xcontent.XContentType; @@ -288,7 +289,7 @@ private void dispatchRequest(RestRequest request, RestChannel channel, RestHandl sendContentTypeErrorMessage(request.getAllHeaderValues("Content-Type"), channel); return; } - if (handler.supportsContentStream() && mediaType != XContentType.JSON && mediaType != XContentType.SMILE) { + if (handler.supportsContentStream() && mediaType != MediaTypeRegistry.JSON && mediaType != XContentType.SMILE) { channel.sendResponse( BytesRestResponse.createSimpleErrorResponse( channel, diff --git a/server/src/main/java/org/opensearch/rest/RestRequest.java b/server/src/main/java/org/opensearch/rest/RestRequest.java index b61a998276532..66fcfbb5fee2e 100644 --- a/server/src/main/java/org/opensearch/rest/RestRequest.java +++ b/server/src/main/java/org/opensearch/rest/RestRequest.java @@ -117,14 +117,14 @@ private RestRequest( HttpChannel httpChannel, long requestId ) { - final MediaType xContentType; + final MediaType mediaType; try { - xContentType = parseContentType(headers.get("Content-Type")); + mediaType = parseContentType(headers.get("Content-Type")); } catch (final IllegalArgumentException e) { throw new ContentTypeHeaderException(e); } - if (xContentType != null) { - this.mediaType.set(xContentType); + if (mediaType != null) { + this.mediaType.set(mediaType); } this.xContentRegistry = xContentRegistry; this.httpRequest = httpRequest; diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestTable.java b/server/src/main/java/org/opensearch/rest/action/cat/RestTable.java index ec44b06318695..59838d3c0da02 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestTable.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestTable.java @@ -69,8 +69,8 @@ public class RestTable { public static RestResponse buildResponse(Table table, RestChannel channel) throws Exception { RestRequest request = channel.request(); - MediaType xContentType = getXContentType(request); - if (xContentType != null) { + MediaType mediaType = getXContentType(request); + if (mediaType != null) { return buildXContentBuilder(table, channel); } return buildTextPlainResponse(table, channel); diff --git a/server/src/main/java/org/opensearch/script/Script.java b/server/src/main/java/org/opensearch/script/Script.java index d02ddf0387c22..80f68362b5838 100644 --- a/server/src/main/java/org/opensearch/script/Script.java +++ b/server/src/main/java/org/opensearch/script/Script.java @@ -43,6 +43,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.xcontent.AbstractObjectParser; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ObjectParser.ValueType; @@ -181,7 +182,7 @@ private void setInline(XContentParser parser) { // this is really for search templates, that need to be converted to json format XContentBuilder builder = XContentFactory.jsonBuilder(); idOrCode = builder.copyCurrentStructure(parser).toString(); - options.put(CONTENT_TYPE_OPTION, XContentType.JSON.mediaType()); + options.put(CONTENT_TYPE_OPTION, MediaTypeRegistry.JSON.mediaType()); } else { idOrCode = parser.text(); } diff --git a/server/src/main/java/org/opensearch/script/StoredScriptSource.java b/server/src/main/java/org/opensearch/script/StoredScriptSource.java index 1f28e2d4810fd..2d181866c9518 100644 --- a/server/src/main/java/org/opensearch/script/StoredScriptSource.java +++ b/server/src/main/java/org/opensearch/script/StoredScriptSource.java @@ -44,6 +44,7 @@ import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ObjectParser.ValueType; @@ -52,7 +53,6 @@ import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.XContentParser.Token; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.io.InputStream; @@ -125,7 +125,7 @@ private void setSource(XContentParser parser) { // this is really for search templates, that need to be converted to json format XContentBuilder builder = XContentFactory.jsonBuilder(); source = builder.copyCurrentStructure(parser).toString(); - options.put(Script.CONTENT_TYPE_OPTION, XContentType.JSON.mediaType()); + options.put(Script.CONTENT_TYPE_OPTION, MediaTypeRegistry.JSON.mediaType()); } else { source = parser.text(); } diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index a75c50a27d7e5..d24e5a1aff6c4 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -47,9 +47,10 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.common.text.Text; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.index.shard.ShardId; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ObjectParser.ValueType; import org.opensearch.core.xcontent.ToXContentFragment; @@ -62,7 +63,6 @@ import org.opensearch.index.mapper.MapperService; import org.opensearch.index.mapper.SourceFieldMapper; import org.opensearch.index.seqno.SequenceNumbers; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.search.fetch.subphase.highlight.HighlightField; import org.opensearch.search.lookup.SourceLookup; import org.opensearch.transport.RemoteClusterAware; @@ -1113,6 +1113,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/AggregationBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/AggregationBuilder.java index 13faaef53e214..6270b8bd5bbbb 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/AggregationBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/AggregationBuilder.java @@ -33,8 +33,8 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.NamedWriteable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.query.QueryRewriteContext; @@ -193,6 +193,6 @@ public static final class CommonFields extends ParseField.CommonFields { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/AggregatorFactories.java b/server/src/main/java/org/opensearch/search/aggregations/AggregatorFactories.java index 0a07daebfe4a9..f04dba45a53c2 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/AggregatorFactories.java +++ b/server/src/main/java/org/opensearch/search/aggregations/AggregatorFactories.java @@ -38,7 +38,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.xcontent.SuggestingErrorOnUnknown; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedObjectNotFoundException; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -591,7 +591,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } @Override diff --git a/server/src/main/java/org/opensearch/search/aggregations/BucketOrder.java b/server/src/main/java/org/opensearch/search/aggregations/BucketOrder.java index a146e518c3f76..56f3820a60348 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/BucketOrder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/BucketOrder.java @@ -34,7 +34,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket; import org.opensearch.search.aggregations.support.AggregationPath; @@ -172,6 +172,6 @@ public void writeTo(StreamOutput out) throws IOException { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/search/aggregations/InternalAggregation.java b/server/src/main/java/org/opensearch/search/aggregations/InternalAggregation.java index d1de09cffd674..ee07a36b4a065 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/InternalAggregation.java +++ b/server/src/main/java/org/opensearch/search/aggregations/InternalAggregation.java @@ -36,7 +36,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.util.BigArrays; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.rest.action.search.RestSearchAction; import org.opensearch.script.ScriptService; @@ -394,7 +394,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** diff --git a/server/src/main/java/org/opensearch/search/aggregations/PipelineAggregationBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/PipelineAggregationBuilder.java index 536ba7c955311..9754498841159 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/PipelineAggregationBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/PipelineAggregationBuilder.java @@ -35,7 +35,7 @@ import org.opensearch.action.ValidateActions; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.NamedWriteable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.index.query.QueryRewriteContext; import org.opensearch.index.query.Rewriteable; @@ -288,7 +288,7 @@ public PipelineAggregationBuilder subAggregations(Builder subFactories) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } /** diff --git a/server/src/main/java/org/opensearch/search/aggregations/support/BaseMultiValuesSourceFieldConfig.java b/server/src/main/java/org/opensearch/search/aggregations/support/BaseMultiValuesSourceFieldConfig.java index d3fd401b6da16..6faec2399bbc1 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/support/BaseMultiValuesSourceFieldConfig.java +++ b/server/src/main/java/org/opensearch/search/aggregations/support/BaseMultiValuesSourceFieldConfig.java @@ -14,7 +14,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -147,7 +147,7 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } abstract void doXContentBody(XContentBuilder builder, Params params) throws IOException; diff --git a/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java index 78cb895a0a4c0..2cb369626ef70 100644 --- a/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java @@ -42,13 +42,13 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryRewriteContext; @@ -1803,7 +1803,7 @@ public String toString() { public String toString(Params params) { try { - return XContentHelper.toXContent(this, XContentType.JSON, params, true).utf8ToString(); + return XContentHelper.toXContent(this, MediaTypeRegistry.JSON, params, true).utf8ToString(); } catch (IOException e) { throw new OpenSearchException(e); } diff --git a/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/AbstractHighlighterBuilder.java b/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/AbstractHighlighterBuilder.java index ec0ef28714176..9f7900f95ea39 100644 --- a/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/AbstractHighlighterBuilder.java +++ b/server/src/main/java/org/opensearch/search/fetch/subphase/highlight/AbstractHighlighterBuilder.java @@ -40,8 +40,8 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -773,6 +773,6 @@ public final boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/search/pipeline/PipelineConfiguration.java b/server/src/main/java/org/opensearch/search/pipeline/PipelineConfiguration.java index c37856b628483..86b4e13df348b 100644 --- a/server/src/main/java/org/opensearch/search/pipeline/PipelineConfiguration.java +++ b/server/src/main/java/org/opensearch/search/pipeline/PipelineConfiguration.java @@ -20,6 +20,7 @@ import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ContextParser; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -130,7 +131,7 @@ public static Diff readDiffFrom(StreamInput in) throws IO @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } @Override diff --git a/server/src/main/java/org/opensearch/search/rescore/RescorerBuilder.java b/server/src/main/java/org/opensearch/search/rescore/RescorerBuilder.java index 0bfff5ae5cae0..6766e7c8e07a1 100644 --- a/server/src/main/java/org/opensearch/search/rescore/RescorerBuilder.java +++ b/server/src/main/java/org/opensearch/search/rescore/RescorerBuilder.java @@ -37,8 +37,8 @@ import org.opensearch.core.common.io.stream.NamedWriteable; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -170,6 +170,6 @@ public boolean equals(Object obj) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/search/slice/SliceBuilder.java b/server/src/main/java/org/opensearch/search/slice/SliceBuilder.java index 106f6e4222325..06c9a8f2f5cd0 100644 --- a/server/src/main/java/org/opensearch/search/slice/SliceBuilder.java +++ b/server/src/main/java/org/opensearch/search/slice/SliceBuilder.java @@ -46,8 +46,8 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.util.set.Sets; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -328,6 +328,6 @@ private GroupShardsIterator buildShardIterator(ClusterService clu @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/search/sort/SortBuilder.java b/server/src/main/java/org/opensearch/search/sort/SortBuilder.java index 8b4be04f5977a..008e797128bc1 100644 --- a/server/src/main/java/org/opensearch/search/sort/SortBuilder.java +++ b/server/src/main/java/org/opensearch/search/sort/SortBuilder.java @@ -40,8 +40,8 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.NamedWriteable; import org.opensearch.common.lucene.search.Queries; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedObjectNotFoundException; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentParser; @@ -283,6 +283,6 @@ protected static QueryBuilder parseNestedFilter(XContentParser parser) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/search/suggest/Suggest.java b/server/src/main/java/org/opensearch/search/suggest/Suggest.java index fdc74b58e318d..c81bd94b53736 100644 --- a/server/src/main/java/org/opensearch/search/suggest/Suggest.java +++ b/server/src/main/java/org/opensearch/search/suggest/Suggest.java @@ -42,12 +42,12 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.common.text.Text; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.XContentParserUtils; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.rest.action.search.RestSearchAction; import org.opensearch.search.aggregations.Aggregation; import org.opensearch.search.suggest.Suggest.Suggestion.Entry; @@ -740,6 +740,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/search/suggest/SuggestBuilder.java b/server/src/main/java/org/opensearch/search/suggest/SuggestBuilder.java index f294914e249c5..9fdece2b5b9a0 100644 --- a/server/src/main/java/org/opensearch/search/suggest/SuggestBuilder.java +++ b/server/src/main/java/org/opensearch/search/suggest/SuggestBuilder.java @@ -38,8 +38,8 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.lucene.BytesRefs; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -218,6 +218,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/main/java/org/opensearch/search/suggest/completion/CompletionSuggestionBuilder.java b/server/src/main/java/org/opensearch/search/suggest/completion/CompletionSuggestionBuilder.java index 1276bc824c05b..6724a48c26a63 100644 --- a/server/src/main/java/org/opensearch/search/suggest/completion/CompletionSuggestionBuilder.java +++ b/server/src/main/java/org/opensearch/search/suggest/completion/CompletionSuggestionBuilder.java @@ -32,20 +32,20 @@ package org.opensearch.search.suggest.completion; import org.opensearch.OpenSearchParseException; +import org.opensearch.common.unit.Fuzziness; +import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.ParseField; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.unit.Fuzziness; -import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.CompletionFieldMapper; import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.index.mapper.MapperService; @@ -72,7 +72,7 @@ */ public class CompletionSuggestionBuilder extends SuggestionBuilder { - private static final XContentType CONTEXT_BYTES_XCONTENT_TYPE = XContentType.JSON; + private static final MediaType CONTEXT_BYTES_XCONTENT_TYPE = MediaTypeRegistry.JSON; static final ParseField CONTEXTS_FIELD = new ParseField("contexts", "context"); static final ParseField SKIP_DUPLICATES_FIELD = new ParseField("skip_duplicates"); diff --git a/server/src/main/java/org/opensearch/snapshots/RestoreInfo.java b/server/src/main/java/org/opensearch/snapshots/RestoreInfo.java index f44cb222af9c6..f5a8a46b4e6ab 100644 --- a/server/src/main/java/org/opensearch/snapshots/RestoreInfo.java +++ b/server/src/main/java/org/opensearch/snapshots/RestoreInfo.java @@ -35,8 +35,8 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; @@ -215,6 +215,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } } diff --git a/server/src/main/java/org/opensearch/tasks/RawTaskStatus.java b/server/src/main/java/org/opensearch/tasks/RawTaskStatus.java index 71e113a22e9c3..28950f5a713fc 100644 --- a/server/src/main/java/org/opensearch/tasks/RawTaskStatus.java +++ b/server/src/main/java/org/opensearch/tasks/RawTaskStatus.java @@ -38,7 +38,6 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.io.InputStream; @@ -87,7 +86,7 @@ public String getWriteableName() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } /** diff --git a/server/src/main/java/org/opensearch/tasks/TaskInfo.java b/server/src/main/java/org/opensearch/tasks/TaskInfo.java index 2da461a93b871..3212ed7481b8d 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskInfo.java +++ b/server/src/main/java/org/opensearch/tasks/TaskInfo.java @@ -41,8 +41,8 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.core.xcontent.ConstructingObjectParser; import org.opensearch.common.xcontent.ObjectParserHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -398,7 +398,7 @@ public static TaskInfo fromXContent(XContentParser parser) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } // Implements equals and hashCode for testing diff --git a/server/src/main/java/org/opensearch/tasks/TaskResourceStats.java b/server/src/main/java/org/opensearch/tasks/TaskResourceStats.java index ce6c88a0c283f..7451c5b3bc148 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskResourceStats.java +++ b/server/src/main/java/org/opensearch/tasks/TaskResourceStats.java @@ -13,7 +13,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -117,7 +117,7 @@ public static TaskResourceStats fromXContent(XContentParser parser) throws IOExc @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } // Implements equals and hashcode for testing diff --git a/server/src/main/java/org/opensearch/tasks/TaskResourceUsage.java b/server/src/main/java/org/opensearch/tasks/TaskResourceUsage.java index 2c86d06613b6c..31a7cd3ac372b 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskResourceUsage.java +++ b/server/src/main/java/org/opensearch/tasks/TaskResourceUsage.java @@ -12,9 +12,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -88,7 +88,7 @@ public static TaskResourceUsage fromXContent(XContentParser parser) { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } // Implements equals and hashcode for testing diff --git a/server/src/main/java/org/opensearch/tasks/TaskResult.java b/server/src/main/java/org/opensearch/tasks/TaskResult.java index 607e7443f73fd..63e24b3175995 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskResult.java +++ b/server/src/main/java/org/opensearch/tasks/TaskResult.java @@ -47,7 +47,6 @@ import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Map; @@ -92,7 +91,7 @@ public TaskResult(TaskInfo task, Exception error) throws IOException { * Construct a {@linkplain TaskResult} for a task that completed successfully. */ public TaskResult(TaskInfo task, ToXContent response) throws IOException { - this(true, task, null, XContentHelper.toXContent(response, Requests.INDEX_CONTENT_TYPE, true)); + this(true, task, null, org.opensearch.core.xcontent.XContentHelper.toXContent(response, Requests.INDEX_CONTENT_TYPE, true)); } public TaskResult(boolean completed, TaskInfo task, @Nullable BytesReference error, @Nullable BytesReference result) { @@ -208,7 +207,7 @@ public XContentBuilder innerToXContent(XContentBuilder builder, Params params) t @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } // Implements equals and hashcode for testing diff --git a/server/src/main/java/org/opensearch/tasks/TaskResultsService.java b/server/src/main/java/org/opensearch/tasks/TaskResultsService.java index 01be4eaaaf732..3dc61635d9ba7 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskResultsService.java +++ b/server/src/main/java/org/opensearch/tasks/TaskResultsService.java @@ -57,7 +57,6 @@ import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.Streams; import org.opensearch.threadpool.ThreadPool; @@ -146,7 +145,7 @@ public void onFailure(Exception e) { client.admin() .indices() .preparePutMapping(TASK_INDEX) - .setSource(taskResultIndexMapping(), XContentType.JSON) + .setSource(taskResultIndexMapping(), MediaTypeRegistry.JSON) .execute(ActionListener.delegateFailure(listener, (l, r) -> doStoreResult(taskResult, listener))); } else { doStoreResult(taskResult, listener); diff --git a/server/src/main/java/org/opensearch/tasks/TaskThreadUsage.java b/server/src/main/java/org/opensearch/tasks/TaskThreadUsage.java index 9c0e2371e77de..85f01bd7f4676 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskThreadUsage.java +++ b/server/src/main/java/org/opensearch/tasks/TaskThreadUsage.java @@ -12,9 +12,9 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -104,6 +104,6 @@ public int hashCode() { @Override public String toString() { - return Strings.toString(XContentType.JSON, this, true, true); + return Strings.toString(MediaTypeRegistry.JSON, this, true, true); } } diff --git a/server/src/test/java/org/opensearch/ExceptionSerializationTests.java b/server/src/test/java/org/opensearch/ExceptionSerializationTests.java index f46d08798868f..da29d90ac3539 100644 --- a/server/src/test/java/org/opensearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/opensearch/ExceptionSerializationTests.java @@ -76,9 +76,9 @@ import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.util.CancellableThreadsTests; import org.opensearch.common.util.set.Sets; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.snapshots.IndexShardSnapshotException; import org.opensearch.core.index.snapshots.IndexShardSnapshotFailedException; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentLocation; import org.opensearch.discovery.MasterNotDiscoveredException; import org.opensearch.env.ShardLockObtainFailedException; @@ -545,12 +545,12 @@ public void testNotSerializableExceptionWrapper() throws IOException { NotSerializableExceptionWrapper ex = serialize(new NotSerializableExceptionWrapper(new NullPointerException())); assertEquals( "{\"type\":\"null_pointer_exception\",\"reason\":\"null_pointer_exception: null\"}", - Strings.toString(XContentType.JSON, ex) + Strings.toString(MediaTypeRegistry.JSON, ex) ); ex = serialize(new NotSerializableExceptionWrapper(new IllegalArgumentException("nono!"))); assertEquals( "{\"type\":\"illegal_argument_exception\",\"reason\":\"illegal_argument_exception: nono!\"}", - Strings.toString(XContentType.JSON, ex) + Strings.toString(MediaTypeRegistry.JSON, ex) ); class UnknownException extends Exception { diff --git a/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java b/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java index e27d376907caa..3df1bdbbc8731 100644 --- a/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java +++ b/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java @@ -46,7 +46,6 @@ import org.opensearch.common.UUIDs; import org.opensearch.common.collect.Tuple; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.ParsingException; import org.opensearch.core.common.Strings; @@ -978,7 +977,7 @@ public void testFailureToAndFromXContentWithDetails() throws IOException { * be rendered like the REST API does when the "error_trace" parameter is set to true. */ private static void assertToXContentAsJson(ToXContent e, String expectedJson) throws IOException { - BytesReference actual = XContentHelper.toXContent(e, XContentType.JSON, randomBoolean()); + BytesReference actual = org.opensearch.core.xcontent.XContentHelper.toXContent(e, MediaTypeRegistry.JSON, randomBoolean()); assertToXContentEquivalent(new BytesArray(expectedJson), actual, MediaTypeRegistry.JSON); } diff --git a/server/src/test/java/org/opensearch/action/RenamedTimeoutRequestParameterTests.java b/server/src/test/java/org/opensearch/action/RenamedTimeoutRequestParameterTests.java index 23b1a8d8462cb..af20c450186aa 100644 --- a/server/src/test/java/org/opensearch/action/RenamedTimeoutRequestParameterTests.java +++ b/server/src/test/java/org/opensearch/action/RenamedTimeoutRequestParameterTests.java @@ -16,8 +16,8 @@ import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.SettingsFilter; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.action.admin.cluster.RestClusterGetSettingsAction; import org.opensearch.rest.action.admin.cluster.RestClusterHealthAction; @@ -715,6 +715,6 @@ private FakeRestRequest getRestRequestWithBodyWithBothParams() { } private FakeRestRequest getFakeRestRequestWithBody() { - return new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY).withContent(new BytesArray("{}"), XContentType.JSON).build(); + return new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY).withContent(new BytesArray("{}"), MediaTypeRegistry.JSON).build(); } } diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java index 3fbac5590cff0..67792f2a62b2c 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java @@ -52,7 +52,6 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; @@ -343,7 +342,7 @@ public void onFailure(Exception e) { "local tasks [{}]", localTasks.values() .stream() - .map(t -> Strings.toString(XContentType.JSON, t.taskInfo(testNodes[0].getNodeId(), true))) + .map(t -> Strings.toString(MediaTypeRegistry.JSON, t.taskInfo(testNodes[0].getNodeId(), true))) .collect(Collectors.joining(",")) ); assertEquals(2, localTasks.size()); // all node tasks + 1 coordinating task @@ -761,7 +760,7 @@ public void testTasksToXContentGrouping() throws Exception { } private Map serialize(ListTasksResponse response, boolean byParents) throws IOException { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder(); builder.startObject(); if (byParents) { DiscoveryNodes nodes = testNodes[0].clusterService.state().nodes(); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequestTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequestTests.java index 2edfa23286658..c2e9336ccf1c4 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreRequestTests.java @@ -10,11 +10,11 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.test.AbstractWireSerializingTestCase; @@ -70,7 +70,7 @@ protected RestoreRemoteStoreRequest mutateInstance(RestoreRemoteStoreRequest ins public void testSource() throws IOException { RestoreRemoteStoreRequest original = createTestInstance(); XContentBuilder builder = original.toXContent(XContentFactory.jsonBuilder(), new ToXContent.MapParams(Collections.emptyMap())); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, null, BytesReference.bytes(builder).streamInput()); Map map = parser.mapOrdered(); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsRequestTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsRequestTests.java index 6df0563ee1b4e..505ed8fe9f600 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsRequestTests.java @@ -33,10 +33,11 @@ package org.opensearch.action.admin.cluster.settings; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParseException; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.XContentTestUtils; @@ -59,14 +60,14 @@ public void testFromXContentWithRandomFields() throws IOException { private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws IOException { final ClusterUpdateSettingsRequest request = createTestItem(); boolean humanReadable = randomBoolean(); - final XContentType xContentType = XContentType.JSON; - BytesReference originalBytes = toShuffledXContent(request, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); + final MediaType mediaType = MediaTypeRegistry.JSON; + BytesReference originalBytes = toShuffledXContent(request, mediaType, ToXContent.EMPTY_PARAMS, humanReadable); if (addRandomFields) { String unsupportedField = "unsupported_field"; BytesReference mutated = BytesReference.bytes( XContentTestUtils.insertIntoXContent( - xContentType.xContent(), + mediaType.xContent(), originalBytes, Collections.singletonList(""), () -> unsupportedField, @@ -75,11 +76,11 @@ private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws ); XContentParseException iae = expectThrows( XContentParseException.class, - () -> ClusterUpdateSettingsRequest.fromXContent(createParser(xContentType.xContent(), mutated)) + () -> ClusterUpdateSettingsRequest.fromXContent(createParser(mediaType.xContent(), mutated)) ); assertThat(iae.getMessage(), containsString("[cluster_update_settings_request] unknown field [" + unsupportedField + "]")); } else { - try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) { + try (XContentParser parser = createParser(mediaType.xContent(), originalBytes)) { ClusterUpdateSettingsRequest parsedRequest = ClusterUpdateSettingsRequest.fromXContent(parser); assertNull(parser.nextToken()); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingRequestTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingRequestTests.java index 3b50b0ff87428..21248b11e69e5 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingRequestTests.java @@ -11,7 +11,7 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.cluster.routing.WeightedRouting; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchTestCase; import java.util.Map; @@ -24,7 +24,7 @@ public void testSetWeightedRoutingWeight() { Map weights = Map.of("us-east-1a", 1.0, "us-east-1b", 1.0, "us-east-1c", 0.0); WeightedRouting weightedRouting = new WeightedRouting("zone", weights); - request.setWeightedRouting(new BytesArray(reqString), XContentType.JSON); + request.setWeightedRouting(new BytesArray(reqString), MediaTypeRegistry.JSON); assertEquals(weightedRouting, request.getWeightedRouting()); assertEquals(1, request.getVersion()); } @@ -32,7 +32,7 @@ public void testSetWeightedRoutingWeight() { public void testValidate_ValuesAreProper() { String reqString = "{\"weights\":{\"us-east-1c\":\"0\",\"us-east-1b\":\"1\",\"us-east-1a\":\"1\"},\"_version\":1}"; ClusterPutWeightedRoutingRequest request = new ClusterPutWeightedRoutingRequest("zone"); - request.setWeightedRouting(new BytesArray(reqString), XContentType.JSON); + request.setWeightedRouting(new BytesArray(reqString), MediaTypeRegistry.JSON); ActionRequestValidationException actionRequestValidationException = request.validate(); assertNull(actionRequestValidationException); } @@ -40,7 +40,7 @@ public void testValidate_ValuesAreProper() { public void testValidate_MissingWeights() { String reqString = "{}"; ClusterPutWeightedRoutingRequest request = new ClusterPutWeightedRoutingRequest("zone"); - request.setWeightedRouting(new BytesArray(reqString), XContentType.JSON); + request.setWeightedRouting(new BytesArray(reqString), MediaTypeRegistry.JSON); ActionRequestValidationException actionRequestValidationException = request.validate(); assertNotNull(actionRequestValidationException); assertTrue(actionRequestValidationException.getMessage().contains("Weights are missing")); @@ -49,7 +49,7 @@ public void testValidate_MissingWeights() { public void testValidate_AttributeMissing() { String reqString = "{\"weights\":{\"us-east-1c\":\"0\",\"us-east-1b\":\"1\",\"us-east-1a\": \"1\"},\"_version\":1}"; ClusterPutWeightedRoutingRequest request = new ClusterPutWeightedRoutingRequest(); - request.setWeightedRouting(new BytesArray(reqString), XContentType.JSON); + request.setWeightedRouting(new BytesArray(reqString), MediaTypeRegistry.JSON); ActionRequestValidationException actionRequestValidationException = request.validate(); assertNotNull(actionRequestValidationException); assertTrue(actionRequestValidationException.getMessage().contains("Attribute name is missing")); @@ -58,7 +58,7 @@ public void testValidate_AttributeMissing() { public void testValidate_MoreThanHalfWithZeroWeight() { String reqString = "{\"weights\":{\"us-east-1c\":\"0\",\"us-east-1b\":\"0\",\"us-east-1a\": \"1\"}," + "\"_version\":1}"; ClusterPutWeightedRoutingRequest request = new ClusterPutWeightedRoutingRequest("zone"); - request.setWeightedRouting(new BytesArray(reqString), XContentType.JSON); + request.setWeightedRouting(new BytesArray(reqString), MediaTypeRegistry.JSON); ActionRequestValidationException actionRequestValidationException = request.validate(); assertNotNull(actionRequestValidationException); assertTrue( @@ -69,7 +69,7 @@ public void testValidate_MoreThanHalfWithZeroWeight() { public void testValidate_VersionMissing() { String reqString = "{\"weights\":{\"us-east-1c\": \"0\",\"us-east-1b\": \"1\",\"us-east-1a\": \"1\"}}"; ClusterPutWeightedRoutingRequest request = new ClusterPutWeightedRoutingRequest("zone"); - request.setWeightedRouting(new BytesArray(reqString), XContentType.JSON); + request.setWeightedRouting(new BytesArray(reqString), MediaTypeRegistry.JSON); ActionRequestValidationException actionRequestValidationException = request.validate(); assertNotNull(actionRequestValidationException); assertTrue(actionRequestValidationException.getMessage().contains("Version is missing")); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotRequestTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotRequestTests.java index 7c9d913951d36..057f1af11df2c 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotRequestTests.java @@ -38,12 +38,12 @@ import org.opensearch.action.support.IndicesOptions.WildcardStates; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent.MapParams; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; @@ -124,7 +124,7 @@ public void testToXContent() throws IOException { } XContentBuilder builder = original.toXContent(XContentFactory.jsonBuilder(), new MapParams(Collections.emptyMap())); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, null, BytesReference.bytes(builder).streamInput()); Map map = parser.mapOrdered(); CreateSnapshotRequest processed = new CreateSnapshotRequest((String) map.get("repository"), (String) map.get("snapshot")); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequestTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequestTests.java index 82b2cfb2e3e51..ed541fdddb984 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequestTests.java @@ -35,12 +35,12 @@ import org.opensearch.action.support.IndicesOptions; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.test.AbstractWireSerializingTestCase; import java.io.IOException; @@ -145,7 +145,7 @@ public void testSource() throws IOException { RestoreSnapshotRequest original = createTestInstance(); original.snapshotUuid(null); // cannot be set via the REST API XContentBuilder builder = original.toXContent(XContentFactory.jsonBuilder(), new ToXContent.MapParams(Collections.emptyMap())); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, null, BytesReference.bytes(builder).streamInput()); Map map = parser.mapOrdered(); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodesTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodesTests.java index 627ada7092273..a0c45f95ef7c0 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodesTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodesTests.java @@ -38,7 +38,7 @@ import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.network.NetworkModule; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchTestCase; import java.util.Arrays; @@ -51,7 +51,7 @@ import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.hamcrest.Matchers.equalTo; public class ClusterStatsNodesTests extends OpenSearchTestCase { @@ -62,11 +62,17 @@ public class ClusterStatsNodesTests extends OpenSearchTestCase { */ public void testNetworkTypesToXContent() throws Exception { ClusterStatsNodes.NetworkTypes stats = new ClusterStatsNodes.NetworkTypes(emptyList()); - assertEquals("{\"transport_types\":{},\"http_types\":{}}", toXContent(stats, XContentType.JSON, randomBoolean()).utf8ToString()); + assertEquals( + "{\"transport_types\":{},\"http_types\":{}}", + toXContent(stats, MediaTypeRegistry.JSON, randomBoolean()).utf8ToString() + ); List nodeInfos = singletonList(createNodeInfo("node_0", null, null)); stats = new ClusterStatsNodes.NetworkTypes(nodeInfos); - assertEquals("{\"transport_types\":{},\"http_types\":{}}", toXContent(stats, XContentType.JSON, randomBoolean()).utf8ToString()); + assertEquals( + "{\"transport_types\":{},\"http_types\":{}}", + toXContent(stats, MediaTypeRegistry.JSON, randomBoolean()).utf8ToString() + ); nodeInfos = Arrays.asList( createNodeInfo("node_1", "", ""), @@ -76,7 +82,7 @@ public void testNetworkTypesToXContent() throws Exception { stats = new ClusterStatsNodes.NetworkTypes(nodeInfos); assertEquals( "{" + "\"transport_types\":{\"custom\":1}," + "\"http_types\":{\"custom\":2}" + "}", - toXContent(stats, XContentType.JSON, randomBoolean()).utf8ToString() + toXContent(stats, MediaTypeRegistry.JSON, randomBoolean()).utf8ToString() ); } @@ -132,7 +138,7 @@ public void testIngestStats() throws Exception { } processorStatsString += "}"; assertThat( - toXContent(stats, XContentType.JSON, false).utf8ToString(), + toXContent(stats, MediaTypeRegistry.JSON, false).utf8ToString(), equalTo( "{\"ingest\":{" + "\"number_of_pipelines\":" diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/storedscripts/GetStoredScriptResponseTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/storedscripts/GetStoredScriptResponseTests.java index 67358fade4b17..ebfd2a6761f46 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/storedscripts/GetStoredScriptResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/storedscripts/GetStoredScriptResponseTests.java @@ -33,8 +33,8 @@ package org.opensearch.action.admin.cluster.storedscripts; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.script.Script; import org.opensearch.script.StoredScriptSource; import org.opensearch.test.AbstractSerializingTestCase; @@ -70,7 +70,7 @@ private static StoredScriptSource randomScriptSource() { final String lang = randomFrom("lang", "painless", "mustache"); final String source = randomAlphaOfLengthBetween(1, 10); final Map options = randomBoolean() - ? Collections.singletonMap(Script.CONTENT_TYPE_OPTION, XContentType.JSON.mediaType()) + ? Collections.singletonMap(Script.CONTENT_TYPE_OPTION, MediaTypeRegistry.JSON.mediaType()) : Collections.emptyMap(); return new StoredScriptSource(lang, source, options); } diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequestTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequestTests.java index cfdd776e60832..a61386f2c3973 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequestTests.java @@ -36,6 +36,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; @@ -52,17 +53,17 @@ public void testSerialization() throws IOException { "bar", "context", new BytesArray("{}"), - XContentType.JSON, + MediaTypeRegistry.JSON, new StoredScriptSource("foo", "bar", Collections.emptyMap()) ); - assertEquals(XContentType.JSON, storedScriptRequest.mediaType()); + assertEquals(MediaTypeRegistry.JSON, storedScriptRequest.mediaType()); try (BytesStreamOutput output = new BytesStreamOutput()) { storedScriptRequest.writeTo(output); try (StreamInput in = output.bytes().streamInput()) { PutStoredScriptRequest serialized = new PutStoredScriptRequest(in); - assertEquals(XContentType.JSON, serialized.mediaType()); + assertEquals(MediaTypeRegistry.JSON, serialized.mediaType()); assertEquals(storedScriptRequest.id(), serialized.id()); assertEquals(storedScriptRequest.context(), serialized.context()); } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/alias/AliasActionsTests.java b/server/src/test/java/org/opensearch/action/admin/indices/alias/AliasActionsTests.java index 952404768a993..d578c3137fbdd 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/alias/AliasActionsTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/alias/AliasActionsTests.java @@ -194,7 +194,7 @@ public void testParseAdd() throws IOException { if (filter == null || filter.isEmpty()) { assertNull(action.filter()); } else { - assertEquals(MediaTypeRegistry.contentBuilder(XContentType.JSON).map(filter).toString(), action.filter()); + assertEquals(MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON).map(filter).toString(), action.filter()); } assertEquals(Objects.toString(searchRouting, null), action.searchRouting()); assertEquals(Objects.toString(indexRouting, null), action.indexRouting()); diff --git a/server/src/test/java/org/opensearch/action/admin/indices/close/CloseIndexResponseTests.java b/server/src/test/java/org/opensearch/action/admin/indices/close/CloseIndexResponseTests.java index 7e3b4f175d8ea..5b6c2d10bddfa 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/close/CloseIndexResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/close/CloseIndexResponseTests.java @@ -37,6 +37,7 @@ import org.opensearch.action.admin.indices.close.CloseIndexResponse.IndexResult; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; @@ -151,7 +152,7 @@ public void testToXContent() throws IOException { CloseIndexResponse closeIndexResponse = new CloseIndexResponse(true, true, Collections.singletonList(indexResult)); assertEquals( "{\"acknowledged\":true,\"shards_acknowledged\":true,\"indices\":{\"test\":{\"closed\":true}}}", - Strings.toString(XContentType.JSON, closeIndexResponse) + Strings.toString(MediaTypeRegistry.JSON, closeIndexResponse) ); CloseIndexResponse.ShardResult[] shards = new CloseIndexResponse.ShardResult[1]; @@ -168,7 +169,7 @@ public void testToXContent() throws IOException { + "\"failures\":[{\"node\":\"nodeId\",\"shard\":0,\"index\":\"test\",\"status\":\"INTERNAL_SERVER_ERROR\"," + "\"reason\":{\"type\":\"action_not_found_transport_exception\"," + "\"reason\":\"No handler for action [test]\"}}]}}}}}", - Strings.toString(XContentType.JSON, closeIndexResponse) + Strings.toString(MediaTypeRegistry.JSON, closeIndexResponse) ); } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java b/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java index 8ecd60803b52d..2d71495b2dc19 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilderTests.java @@ -34,9 +34,9 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.client.NoOpClient; import org.junit.After; @@ -75,11 +75,11 @@ public void testSetSource() throws IOException { CreateIndexRequestBuilder builder = new CreateIndexRequestBuilder(this.testClient, CreateIndexAction.INSTANCE); OpenSearchParseException e = expectThrows(OpenSearchParseException.class, () -> { - builder.setSource("{\"" + KEY + "\" : \"" + VALUE + "\"}", XContentType.JSON); + builder.setSource("{\"" + KEY + "\" : \"" + VALUE + "\"}", MediaTypeRegistry.JSON); }); assertEquals(String.format(Locale.ROOT, "unknown key [%s] for create index", KEY), e.getMessage()); - builder.setSource("{\"settings\" : {\"" + KEY + "\" : \"" + VALUE + "\"}}", XContentType.JSON); + builder.setSource("{\"settings\" : {\"" + KEY + "\" : \"" + VALUE + "\"}}", MediaTypeRegistry.JSON); assertEquals(VALUE, builder.request().settings().get(KEY)); XContentBuilder xContent = XContentFactory.jsonBuilder() @@ -100,7 +100,7 @@ public void testSetSource() throws IOException { .endObject() .endObject(); doc.close(); - builder.setSource(docOut.toByteArray(), XContentType.JSON); + builder.setSource(docOut.toByteArray(), MediaTypeRegistry.JSON); assertEquals(VALUE, builder.request().settings().get(KEY)); Map settingsMap = new HashMap<>(); @@ -117,7 +117,7 @@ public void testSetSettings() throws IOException { builder.setSettings(Settings.builder().put(KEY, VALUE)); assertEquals(VALUE, builder.request().settings().get(KEY)); - builder.setSettings("{\"" + KEY + "\" : \"" + VALUE + "\"}", XContentType.JSON); + builder.setSettings("{\"" + KEY + "\" : \"" + VALUE + "\"}", MediaTypeRegistry.JSON); assertEquals(VALUE, builder.request().settings().get(KEY)); builder.setSettings(Settings.builder().put(KEY, VALUE)); diff --git a/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestTests.java index 2a2efbd027ac0..26f904e6da31b 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestTests.java @@ -94,7 +94,7 @@ public void testTopLevelKeys() { CreateIndexRequest request = new CreateIndexRequest(); OpenSearchParseException e = expectThrows( OpenSearchParseException.class, - () -> { request.source(createIndex, XContentType.JSON); } + () -> { request.source(createIndex, MediaTypeRegistry.JSON); } ); assertEquals("unknown key [FOO_SHOULD_BE_ILLEGAL_HERE] for create index", e.getMessage()); } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexResponseTests.java b/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexResponseTests.java index 022c372802f9e..dc35bd76897df 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexResponseTests.java @@ -34,8 +34,8 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.test.AbstractSerializingTestCase; @@ -84,13 +84,13 @@ protected CreateIndexResponse doParseInstance(XContentParser parser) { public void testToXContent() { CreateIndexResponse response = new CreateIndexResponse(true, false, "index_name"); - String output = Strings.toString(XContentType.JSON, response); + String output = Strings.toString(MediaTypeRegistry.JSON, response); assertEquals("{\"acknowledged\":true,\"shards_acknowledged\":false,\"index\":\"index_name\"}", output); } public void testToAndFromXContentIndexNull() throws IOException { CreateIndexResponse response = new CreateIndexResponse(true, false, null); - String output = Strings.toString(XContentType.JSON, response); + String output = Strings.toString(MediaTypeRegistry.JSON, response); assertEquals("{\"acknowledged\":true,\"shards_acknowledged\":false,\"index\":null}", output); try (XContentParser parser = createParser(JsonXContent.jsonXContent, output)) { CreateIndexResponse parsedResponse = CreateIndexResponse.fromXContent(parser); diff --git a/server/src/test/java/org/opensearch/action/admin/indices/forcemerge/RestForceMergeActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/forcemerge/RestForceMergeActionTests.java index 821fb60c82a25..c6def72ca460c 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/forcemerge/RestForceMergeActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/forcemerge/RestForceMergeActionTests.java @@ -34,8 +34,8 @@ import org.opensearch.client.node.NodeClient; import org.opensearch.core.common.bytes.BytesArray; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.rest.RestRequest; import org.opensearch.rest.action.admin.indices.RestForceMergeAction; @@ -62,7 +62,7 @@ public void testBodyRejection() throws Exception { String json = JsonXContent.contentBuilder().startObject().field("max_num_segments", 1).endObject().toString(); final FakeRestRequest request = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY).withContent( new BytesArray(json), - XContentType.JSON + MediaTypeRegistry.JSON ).withPath("/_forcemerge").build(); IllegalArgumentException e = expectThrows( IllegalArgumentException.class, diff --git a/server/src/test/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponseTests.java b/server/src/test/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponseTests.java index 21f301674761f..00e07dae23c5a 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponseTests.java @@ -38,7 +38,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.AbstractWireSerializingTestCase; import java.io.IOException; @@ -69,7 +69,7 @@ public void testNullFieldMappingToXContent() { Map> mappings = new HashMap<>(); mappings.put("index", Collections.emptyMap()); GetFieldMappingsResponse response = new GetFieldMappingsResponse(mappings); - assertEquals("{\"index\":{\"mappings\":{}}}", Strings.toString(XContentType.JSON, response)); + assertEquals("{\"index\":{\"mappings\":{}}}", Strings.toString(MediaTypeRegistry.JSON, response)); } @Override diff --git a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java index 0827f7e114bdb..552f0ee4b2410 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java @@ -45,6 +45,7 @@ import org.opensearch.common.collect.Tuple; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -72,12 +73,12 @@ public void testValidation() { assertNotNull("source validation should fail", ex); assertTrue(ex.getMessage().contains("source is missing")); - r.source("", XContentType.JSON); + r.source("", MediaTypeRegistry.JSON); ex = r.validate(); assertNotNull("source validation should fail", ex); assertTrue(ex.getMessage().contains("source is empty")); - r.source("somevalidmapping", XContentType.JSON); + r.source("somevalidmapping", MediaTypeRegistry.JSON); ex = r.validate(); assertNull("validation should succeed", ex); @@ -113,7 +114,7 @@ public void testToXContent() throws IOException { mapping.endObject(); request.source(mapping); - String actualRequestBody = Strings.toString(XContentType.JSON, request); + String actualRequestBody = Strings.toString(MediaTypeRegistry.JSON, request); String expectedRequestBody = "{\"properties\":{\"email\":{\"type\":\"text\"}}}"; assertEquals(expectedRequestBody, actualRequestBody); } @@ -121,7 +122,7 @@ public void testToXContent() throws IOException { public void testToXContentWithEmptySource() throws IOException { PutMappingRequest request = new PutMappingRequest("foo"); - String actualRequestBody = Strings.toString(XContentType.JSON, request); + String actualRequestBody = Strings.toString(MediaTypeRegistry.JSON, request); String expectedRequestBody = "{}"; assertEquals(expectedRequestBody, actualRequestBody); } @@ -143,8 +144,8 @@ public void testToAndFromXContent() throws IOException { private void assertMappingsEqual(String expected, String actual) throws IOException { try ( - XContentParser expectedJson = createParser(XContentType.JSON.xContent(), expected); - XContentParser actualJson = createParser(XContentType.JSON.xContent(), actual) + XContentParser expectedJson = createParser(MediaTypeRegistry.JSON.xContent(), expected); + XContentParser actualJson = createParser(MediaTypeRegistry.JSON.xContent(), actual) ) { assertEquals(expectedJson.mapOrdered(), actualJson.mapOrdered()); } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java index f65d39583336b..3a52c20b324b5 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java @@ -147,7 +147,7 @@ public void testTypelessMappingParsing() throws Exception { String mapping = createIndexRequest.mappings(); assertNotNull(mapping); - Map parsedMapping = XContentHelper.convertToMap(new BytesArray(mapping), false, XContentType.JSON).v2(); + Map parsedMapping = XContentHelper.convertToMap(new BytesArray(mapping), false, MediaTypeRegistry.JSON).v2(); @SuppressWarnings("unchecked") Map properties = (Map) parsedMapping.get(MapperService.SINGLE_MAPPING_NAME); diff --git a/server/src/test/java/org/opensearch/action/admin/indices/shrink/ResizeRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/shrink/ResizeRequestTests.java index e189c3e24423a..a67faa8a45f12 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/shrink/ResizeRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/shrink/ResizeRequestTests.java @@ -41,6 +41,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.RandomCreateIndexGenerator; import org.opensearch.test.OpenSearchTestCase; @@ -78,7 +79,7 @@ private void runTestCopySettingsValidation(final Boolean copySettings, final Con public void testToXContent() throws IOException { { ResizeRequest request = new ResizeRequest("target", "source"); - String actualRequestBody = Strings.toString(XContentType.JSON, request); + String actualRequestBody = Strings.toString(MediaTypeRegistry.JSON, request); assertEquals("{\"settings\":{},\"aliases\":{}}", actualRequestBody); } { @@ -93,7 +94,7 @@ public void testToXContent() throws IOException { settings.put(SETTING_NUMBER_OF_SHARDS, 10); target.settings(settings); request.setTargetIndex(target); - String actualRequestBody = Strings.toString(XContentType.JSON, request); + String actualRequestBody = Strings.toString(MediaTypeRegistry.JSON, request); String expectedRequestBody = "{\"settings\":{\"index\":{\"number_of_shards\":\"10\"}}," + "\"aliases\":{\"test_alias\":{\"filter\":{\"term\":{\"year\":2016}},\"routing\":\"1\",\"is_write_index\":true}}}"; assertEquals(expectedRequestBody, actualRequestBody); diff --git a/server/src/test/java/org/opensearch/action/admin/indices/shrink/ResizeResponseTests.java b/server/src/test/java/org/opensearch/action/admin/indices/shrink/ResizeResponseTests.java index 7d97a4285f5da..f984c969e4b70 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/shrink/ResizeResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/shrink/ResizeResponseTests.java @@ -34,7 +34,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.test.AbstractSerializingTestCase; @@ -42,7 +42,7 @@ public class ResizeResponseTests extends AbstractSerializingTestCase()); - String output = Strings.toString(XContentType.JSON, response); + String output = Strings.toString(MediaTypeRegistry.JSON, response); assertEquals("{\"_shards\":{\"total\":10,\"successful\":10,\"failed\":0},\"valid\":true}", output); } } diff --git a/server/src/test/java/org/opensearch/action/bulk/BulkProcessorTests.java b/server/src/test/java/org/opensearch/action/bulk/BulkProcessorTests.java index 0111c8d6e3132..c8a171df6cadc 100644 --- a/server/src/test/java/org/opensearch/action/bulk/BulkProcessorTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/BulkProcessorTests.java @@ -42,7 +42,7 @@ import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.Scheduler; import org.opensearch.threadpool.TestThreadPool; @@ -208,7 +208,7 @@ public void testConcurrentExecutions() throws Exception { if (randomBoolean()) { bulkProcessor.add(indexRequest); } else { - bulkProcessor.add(bytesReference, null, null, XContentType.JSON); + bulkProcessor.add(bytesReference, null, null, MediaTypeRegistry.JSON); } } catch (Exception e) { throw ExceptionsHelper.convertToRuntime(e); @@ -334,7 +334,7 @@ public void testConcurrentExecutionsWithFlush() throws Exception { if (randomBoolean()) { bulkProcessor.add(indexRequest); } else { - bulkProcessor.add(bytesReference, null, null, XContentType.JSON); + bulkProcessor.add(bytesReference, null, null, MediaTypeRegistry.JSON); } } catch (Exception e) { throw ExceptionsHelper.convertToRuntime(e); diff --git a/server/src/test/java/org/opensearch/action/bulk/BulkRequestModifierTests.java b/server/src/test/java/org/opensearch/action/bulk/BulkRequestModifierTests.java index e68d7d7d0d447..31c6472ad46b3 100644 --- a/server/src/test/java/org/opensearch/action/bulk/BulkRequestModifierTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/BulkRequestModifierTests.java @@ -36,8 +36,8 @@ import org.opensearch.action.DocWriteRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchTestCase; import org.hamcrest.Matchers; @@ -58,7 +58,7 @@ public void testBulkRequestModifier() { int numRequests = scaledRandomIntBetween(8, 64); BulkRequest bulkRequest = new BulkRequest(); for (int i = 0; i < numRequests; i++) { - bulkRequest.add(new IndexRequest("_index").id(String.valueOf(i)).source("{}", XContentType.JSON)); + bulkRequest.add(new IndexRequest("_index").id(String.valueOf(i)).source("{}", MediaTypeRegistry.JSON)); } CaptureActionListener actionListener = new CaptureActionListener(); TransportBulkAction.BulkRequestModifier bulkRequestModifier = new TransportBulkAction.BulkRequestModifier(bulkRequest); diff --git a/server/src/test/java/org/opensearch/action/bulk/BulkRequestParserTests.java b/server/src/test/java/org/opensearch/action/bulk/BulkRequestParserTests.java index e0e9ea73d9291..4f07c098b0869 100644 --- a/server/src/test/java/org/opensearch/action/bulk/BulkRequestParserTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/BulkRequestParserTests.java @@ -34,7 +34,7 @@ import org.opensearch.action.index.IndexRequest; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchTestCase; import org.hamcrest.Matchers; @@ -49,7 +49,7 @@ public void testIndexRequest() throws IOException { BytesArray request = new BytesArray("{ \"index\":{ \"_id\": \"bar\" } }\n{}\n"); BulkRequestParser parser = new BulkRequestParser(); final AtomicBoolean parsed = new AtomicBoolean(); - parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, indexRequest -> { + parser.parse(request, "foo", null, null, null, null, false, MediaTypeRegistry.JSON, indexRequest -> { assertFalse(parsed.get()); assertEquals("foo", indexRequest.index()); assertEquals("bar", indexRequest.id()); @@ -58,17 +58,17 @@ public void testIndexRequest() throws IOException { }, req -> fail(), req -> fail()); assertTrue(parsed.get()); - parser.parse(request, "foo", null, null, null, true, false, XContentType.JSON, indexRequest -> { + parser.parse(request, "foo", null, null, null, true, false, MediaTypeRegistry.JSON, indexRequest -> { assertTrue(indexRequest.isRequireAlias()); }, req -> fail(), req -> fail()); request = new BytesArray("{ \"index\":{ \"_id\": \"bar\", \"require_alias\": true } }\n{}\n"); - parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, indexRequest -> { + parser.parse(request, "foo", null, null, null, null, false, MediaTypeRegistry.JSON, indexRequest -> { assertTrue(indexRequest.isRequireAlias()); }, req -> fail(), req -> fail()); request = new BytesArray("{ \"index\":{ \"_id\": \"bar\", \"require_alias\": false } }\n{}\n"); - parser.parse(request, "foo", null, null, null, true, false, XContentType.JSON, indexRequest -> { + parser.parse(request, "foo", null, null, null, true, false, MediaTypeRegistry.JSON, indexRequest -> { assertFalse(indexRequest.isRequireAlias()); }, req -> fail(), req -> fail()); } @@ -77,7 +77,7 @@ public void testDeleteRequest() throws IOException { BytesArray request = new BytesArray("{ \"delete\":{ \"_id\": \"bar\" } }\n"); BulkRequestParser parser = new BulkRequestParser(); final AtomicBoolean parsed = new AtomicBoolean(); - parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, req -> fail(), req -> fail(), deleteRequest -> { + parser.parse(request, "foo", null, null, null, null, false, MediaTypeRegistry.JSON, req -> fail(), req -> fail(), deleteRequest -> { assertFalse(parsed.get()); assertEquals("foo", deleteRequest.index()); assertEquals("bar", deleteRequest.id()); @@ -90,7 +90,7 @@ public void testUpdateRequest() throws IOException { BytesArray request = new BytesArray("{ \"update\":{ \"_id\": \"bar\" } }\n{}\n"); BulkRequestParser parser = new BulkRequestParser(); final AtomicBoolean parsed = new AtomicBoolean(); - parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, req -> fail(), updateRequest -> { + parser.parse(request, "foo", null, null, null, null, false, MediaTypeRegistry.JSON, req -> fail(), updateRequest -> { assertFalse(parsed.get()); assertEquals("foo", updateRequest.index()); assertEquals("bar", updateRequest.id()); @@ -99,17 +99,17 @@ public void testUpdateRequest() throws IOException { }, req -> fail()); assertTrue(parsed.get()); - parser.parse(request, "foo", null, null, null, true, false, XContentType.JSON, req -> fail(), updateRequest -> { + parser.parse(request, "foo", null, null, null, true, false, MediaTypeRegistry.JSON, req -> fail(), updateRequest -> { assertTrue(updateRequest.isRequireAlias()); }, req -> fail()); request = new BytesArray("{ \"update\":{ \"_id\": \"bar\", \"require_alias\": true } }\n{}\n"); - parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, req -> fail(), updateRequest -> { + parser.parse(request, "foo", null, null, null, null, false, MediaTypeRegistry.JSON, req -> fail(), updateRequest -> { assertTrue(updateRequest.isRequireAlias()); }, req -> fail()); request = new BytesArray("{ \"update\":{ \"_id\": \"bar\", \"require_alias\": false } }\n{}\n"); - parser.parse(request, "foo", null, null, null, true, false, XContentType.JSON, req -> fail(), updateRequest -> { + parser.parse(request, "foo", null, null, null, true, false, MediaTypeRegistry.JSON, req -> fail(), updateRequest -> { assertFalse(updateRequest.isRequireAlias()); }, req -> fail()); } @@ -127,7 +127,7 @@ public void testBarfOnLackOfTrailingNewline() { null, null, false, - XContentType.JSON, + MediaTypeRegistry.JSON, indexRequest -> fail(), req -> fail(), req -> fail() @@ -142,7 +142,19 @@ public void testFailOnExplicitIndex() { IllegalArgumentException ex = expectThrows( IllegalArgumentException.class, - () -> parser.parse(request, null, null, null, null, null, false, XContentType.JSON, req -> fail(), req -> fail(), req -> fail()) + () -> parser.parse( + request, + null, + null, + null, + null, + null, + false, + MediaTypeRegistry.JSON, + req -> fail(), + req -> fail(), + req -> fail() + ) ); assertEquals("explicit index in bulk is not allowed", ex.getMessage()); } @@ -162,7 +174,7 @@ public void testParseDeduplicatesParameterStrings() throws IOException { null, null, true, - XContentType.JSON, + MediaTypeRegistry.JSON, indexRequest -> indexRequests.add(indexRequest), req -> fail(), req -> fail() @@ -189,7 +201,7 @@ public void testFailOnUnsupportedAction() { null, true, false, - XContentType.JSON, + MediaTypeRegistry.JSON, req -> fail(), req -> fail(), req -> fail() diff --git a/server/src/test/java/org/opensearch/action/bulk/BulkRequestTests.java b/server/src/test/java/org/opensearch/action/bulk/BulkRequestTests.java index 2f2c9b2be9e50..b3a5cff0041a7 100644 --- a/server/src/test/java/org/opensearch/action/bulk/BulkRequestTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/BulkRequestTests.java @@ -71,7 +71,7 @@ public class BulkRequestTests extends OpenSearchTestCase { public void testSimpleBulk1() throws Exception { String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk.json"); BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); + bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON); assertThat(bulkRequest.numberOfActions(), equalTo(3)); assertThat(((IndexRequest) bulkRequest.requests().get(0)).source(), equalTo(new BytesArray("{ \"field1\" : \"value1\" }"))); assertThat(bulkRequest.requests().get(1), instanceOf(DeleteRequest.class)); @@ -81,13 +81,13 @@ public void testSimpleBulk1() throws Exception { public void testSimpleBulkWithCarriageReturn() throws Exception { String bulkAction = "{ \"index\":{\"_index\":\"test\",\"_id\":\"1\"} }\r\n{ \"field1\" : \"value1\" }\r\n"; BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); + bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON); assertThat(bulkRequest.numberOfActions(), equalTo(1)); assertThat(((IndexRequest) bulkRequest.requests().get(0)).source(), equalTo(new BytesArray("{ \"field1\" : \"value1\" }"))); Map sourceMap = XContentHelper.convertToMap( ((IndexRequest) bulkRequest.requests().get(0)).source(), false, - XContentType.JSON + MediaTypeRegistry.JSON ).v2(); assertEquals("value1", sourceMap.get("field1")); } @@ -95,21 +95,21 @@ public void testSimpleBulkWithCarriageReturn() throws Exception { public void testSimpleBulk2() throws Exception { String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk2.json"); BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); + bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON); assertThat(bulkRequest.numberOfActions(), equalTo(3)); } public void testSimpleBulk3() throws Exception { String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk3.json"); BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); + bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON); assertThat(bulkRequest.numberOfActions(), equalTo(3)); } public void testSimpleBulk4() throws Exception { String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk4.json"); BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); + bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON); assertThat(bulkRequest.numberOfActions(), equalTo(4)); assertThat(bulkRequest.requests().get(0).id(), equalTo("1")); assertThat(((UpdateRequest) bulkRequest.requests().get(0)).retryOnConflict(), equalTo(2)); @@ -131,12 +131,12 @@ public void testBulkAllowExplicitIndex() throws Exception { String bulkAction1 = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk.json"); Exception ex = expectThrows( Exception.class, - () -> new BulkRequest().add(new BytesArray(bulkAction1.getBytes(StandardCharsets.UTF_8)), null, false, XContentType.JSON) + () -> new BulkRequest().add(new BytesArray(bulkAction1.getBytes(StandardCharsets.UTF_8)), null, false, MediaTypeRegistry.JSON) ); assertEquals("explicit index in bulk is not allowed", ex.getMessage()); String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk5.json"); - new BulkRequest().add(new BytesArray(bulkAction.getBytes(StandardCharsets.UTF_8)), "test", false, XContentType.JSON); + new BulkRequest().add(new BytesArray(bulkAction.getBytes(StandardCharsets.UTF_8)), "test", false, MediaTypeRegistry.JSON); } public void testBulkAddIterable() { @@ -157,7 +157,7 @@ public void testSimpleBulk6() throws Exception { BulkRequest bulkRequest = new BulkRequest(); ParsingException exc = expectThrows( ParsingException.class, - () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON) + () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON) ); assertThat(exc.getMessage(), containsString("Unknown key for a VALUE_STRING in [hello]")); } @@ -167,7 +167,7 @@ public void testSimpleBulk7() throws Exception { BulkRequest bulkRequest = new BulkRequest(); IllegalArgumentException exc = expectThrows( IllegalArgumentException.class, - () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON) + () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON) ); assertThat( exc.getMessage(), @@ -180,7 +180,7 @@ public void testSimpleBulk8() throws Exception { BulkRequest bulkRequest = new BulkRequest(); IllegalArgumentException exc = expectThrows( IllegalArgumentException.class, - () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON) + () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON) ); assertThat(exc.getMessage(), containsString("Action/metadata line [3] contains an unknown parameter [_foo]")); } @@ -190,7 +190,7 @@ public void testSimpleBulk9() throws Exception { BulkRequest bulkRequest = new BulkRequest(); IllegalArgumentException exc = expectThrows( IllegalArgumentException.class, - () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON) + () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON) ); assertThat( exc.getMessage(), @@ -201,7 +201,7 @@ public void testSimpleBulk9() throws Exception { public void testSimpleBulk10() throws Exception { String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk10.json"); BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); + bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON); assertThat(bulkRequest.numberOfActions(), equalTo(9)); } @@ -210,7 +210,7 @@ public void testBulkActionShouldNotContainArray() throws Exception { BulkRequest bulkRequest = new BulkRequest(); IllegalArgumentException exc = expectThrows( IllegalArgumentException.class, - () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON) + () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON) ); assertEquals( exc.getMessage(), @@ -240,7 +240,7 @@ public void testBulkEmptyObject() throws Exception { BulkRequest bulkRequest = new BulkRequest(); IllegalArgumentException exc = expectThrows( IllegalArgumentException.class, - () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON) + () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON) ); assertThat( exc.getMessage(), @@ -256,8 +256,8 @@ public void testBulkRequestWithRefresh() throws Exception { // We force here a "type is missing" validation error bulkRequest.add(new DeleteRequest("index", "id")); bulkRequest.add(new DeleteRequest("index", "id").setRefreshPolicy(RefreshPolicy.IMMEDIATE)); - bulkRequest.add(new UpdateRequest("index", "id").doc("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)); - bulkRequest.add(new IndexRequest("index").id("id").source("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)); + bulkRequest.add(new UpdateRequest("index", "id").doc("{}", MediaTypeRegistry.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)); + bulkRequest.add(new IndexRequest("index").id("id").source("{}", MediaTypeRegistry.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)); ActionRequestValidationException validate = bulkRequest.validate(); assertThat(validate, notNullValue()); assertThat(validate.validationErrors(), not(empty())); @@ -408,7 +408,7 @@ public void testBulkTerminatedByNewline() throws Exception { String bulkAction = copyToStringFromClasspath("/org/opensearch/action/bulk/simple-bulk11.json"); IllegalArgumentException expectThrows = expectThrows( IllegalArgumentException.class, - () -> new BulkRequest().add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON) + () -> new BulkRequest().add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON) ); assertEquals("The bulk request must be terminated by a newline [\\n]", expectThrows.getMessage()); @@ -419,7 +419,7 @@ public void testBulkTerminatedByNewline() throws Exception { 0, bulkActionWithNewLine.length(), null, - XContentType.JSON + MediaTypeRegistry.JSON ); assertEquals(3, bulkRequestWithNewLine.numberOfActions()); } diff --git a/server/src/test/java/org/opensearch/action/bulk/BulkResponseTests.java b/server/src/test/java/org/opensearch/action/bulk/BulkResponseTests.java index 7c758fb25ce85..6b8857c956348 100644 --- a/server/src/test/java/org/opensearch/action/bulk/BulkResponseTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/BulkResponseTests.java @@ -51,7 +51,7 @@ import static org.opensearch.OpenSearchExceptionTests.randomExceptions; import static org.opensearch.action.bulk.BulkItemResponseTests.assertBulkItemResponse; import static org.opensearch.action.bulk.BulkResponse.NO_INGEST_TOOK; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; public class BulkResponseTests extends OpenSearchTestCase { diff --git a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTookTests.java b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTookTests.java index 2361b69e9b82c..e10b848a39431 100644 --- a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTookTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTookTests.java @@ -51,8 +51,8 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.AtomicArray; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexNotFoundException; import org.opensearch.index.IndexingPressureService; import org.opensearch.indices.SystemIndices; @@ -217,7 +217,7 @@ private void runTestTook(boolean controlled) throws Exception { bulkAction = Strings.replace(bulkAction, "\r\n", "\n"); } BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); + bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, MediaTypeRegistry.JSON); AtomicLong expected = new AtomicLong(); TransportBulkAction action = createAction(controlled, expected); action.doExecute(null, bulkRequest, new ActionListener() { diff --git a/server/src/test/java/org/opensearch/action/delete/DeleteResponseTests.java b/server/src/test/java/org/opensearch/action/delete/DeleteResponseTests.java index 58dca0bebc0f1..c6ecb8608ff5e 100644 --- a/server/src/test/java/org/opensearch/action/delete/DeleteResponseTests.java +++ b/server/src/test/java/org/opensearch/action/delete/DeleteResponseTests.java @@ -36,6 +36,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -56,7 +57,7 @@ public class DeleteResponseTests extends OpenSearchTestCase { public void testToXContent() { { DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "id", 3, 17, 5, true); - String output = Strings.toString(XContentType.JSON, response); + String output = Strings.toString(MediaTypeRegistry.JSON, response); assertEquals( "{\"_index\":\"index\",\"_id\":\"id\",\"_version\":5,\"result\":\"deleted\"," + "\"_shards\":null,\"_seq_no\":3,\"_primary_term\":17}", @@ -67,7 +68,7 @@ public void testToXContent() { DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "id", -1, 0, 7, true); response.setForcedRefresh(true); response.setShardInfo(new ReplicationResponse.ShardInfo(10, 5)); - String output = Strings.toString(XContentType.JSON, response); + String output = Strings.toString(MediaTypeRegistry.JSON, response); assertEquals( "{\"_index\":\"index\",\"_id\":\"id\",\"_version\":7,\"result\":\"deleted\"," + "\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0}}", diff --git a/server/src/test/java/org/opensearch/action/explain/ExplainResponseTests.java b/server/src/test/java/org/opensearch/action/explain/ExplainResponseTests.java index 14f2a5c94bcd0..b34702e0a5b4d 100644 --- a/server/src/test/java/org/opensearch/action/explain/ExplainResponseTests.java +++ b/server/src/test/java/org/opensearch/action/explain/ExplainResponseTests.java @@ -41,7 +41,6 @@ import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.get.GetResult; import org.opensearch.test.AbstractSerializingTestCase; import org.opensearch.test.RandomObjects; @@ -114,7 +113,7 @@ public void testToXContent() throws IOException { ); ExplainResponse response = new ExplainResponse(index, id, exist, explanation, getResult); - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); response.toXContent(builder, ToXContent.EMPTY_PARAMS); String generatedResponse = BytesReference.bytes(builder).utf8ToString().replaceAll("\\s+", ""); diff --git a/server/src/test/java/org/opensearch/action/fieldcaps/MergedFieldCapabilitiesResponseTests.java b/server/src/test/java/org/opensearch/action/fieldcaps/MergedFieldCapabilitiesResponseTests.java index d76ed86ed490e..f196ba16a2584 100644 --- a/server/src/test/java/org/opensearch/action/fieldcaps/MergedFieldCapabilitiesResponseTests.java +++ b/server/src/test/java/org/opensearch/action/fieldcaps/MergedFieldCapabilitiesResponseTests.java @@ -38,7 +38,6 @@ import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.test.AbstractSerializingTestCase; import java.io.IOException; @@ -125,7 +124,7 @@ protected Predicate getRandomFieldsExcludeFilter() { public void testToXContent() throws IOException { FieldCapabilitiesResponse response = createSimpleResponse(); - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); response.toXContent(builder, ToXContent.EMPTY_PARAMS); String generatedResponse = BytesReference.bytes(builder).utf8ToString(); diff --git a/server/src/test/java/org/opensearch/action/get/GetResponseTests.java b/server/src/test/java/org/opensearch/action/get/GetResponseTests.java index 4299c330ad3ec..adf280a29380e 100644 --- a/server/src/test/java/org/opensearch/action/get/GetResponseTests.java +++ b/server/src/test/java/org/opensearch/action/get/GetResponseTests.java @@ -38,6 +38,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.document.DocumentField; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -48,7 +49,7 @@ import java.util.Collections; import java.util.function.Predicate; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.index.get.GetResultTests.copyGetResult; import static org.opensearch.index.get.GetResultTests.mutateGetResult; import static org.opensearch.index.get.GetResultTests.randomGetResult; @@ -118,7 +119,7 @@ public void testToXContent() { null ) ); - String output = Strings.toString(XContentType.JSON, getResponse); + String output = Strings.toString(MediaTypeRegistry.JSON, getResponse); assertEquals( "{\"_index\":\"index\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + "\"found\":true,\"_source\":{ \"field1\" : \"value1\", \"field2\":\"value2\"},\"fields\":{\"field1\":[\"value1\"]}}", @@ -127,7 +128,7 @@ public void testToXContent() { } { GetResponse getResponse = new GetResponse(new GetResult("index", "id", UNASSIGNED_SEQ_NO, 0, 1, false, null, null, null)); - String output = Strings.toString(XContentType.JSON, getResponse); + String output = Strings.toString(MediaTypeRegistry.JSON, getResponse); assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"found\":false}", output); } } @@ -155,7 +156,7 @@ public void testToString() { public void testEqualsAndHashcode() { checkEqualsAndHashCode( - new GetResponse(randomGetResult(XContentType.JSON).v1()), + new GetResponse(randomGetResult(MediaTypeRegistry.JSON).v1()), GetResponseTests::copyGetResponse, GetResponseTests::mutateGetResponse ); diff --git a/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java b/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java index 9e467aff710df..39e8f1af8c331 100644 --- a/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java +++ b/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java @@ -53,9 +53,9 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.Index; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.indices.IndicesService; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskId; @@ -139,7 +139,7 @@ public TaskManager getTaskManager() { .endObject() ), true, - XContentType.JSON + MediaTypeRegistry.JSON ) ) ) @@ -164,7 +164,7 @@ public TaskManager getTaskManager() { .endObject() ), true, - XContentType.JSON + MediaTypeRegistry.JSON ) ) ) diff --git a/server/src/test/java/org/opensearch/action/index/IndexRequestBuilderTests.java b/server/src/test/java/org/opensearch/action/index/IndexRequestBuilderTests.java index 5c3fba48d6215..5665040bb5e7f 100644 --- a/server/src/test/java/org/opensearch/action/index/IndexRequestBuilderTests.java +++ b/server/src/test/java/org/opensearch/action/index/IndexRequestBuilderTests.java @@ -32,10 +32,10 @@ package org.opensearch.action.index; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.client.NoOpClient; import org.junit.After; @@ -74,7 +74,7 @@ public void testSetSource() throws Exception { indexRequestBuilder.setSource(source); assertEquals(EXPECTED_SOURCE, XContentHelper.convertToJson(indexRequestBuilder.request().source(), true)); - indexRequestBuilder.setSource(source, XContentType.JSON); + indexRequestBuilder.setSource(source, MediaTypeRegistry.JSON); assertEquals(EXPECTED_SOURCE, XContentHelper.convertToJson(indexRequestBuilder.request().source(), true)); indexRequestBuilder.setSource("SomeKey", "SomeValue"); @@ -87,7 +87,7 @@ public void testSetSource() throws Exception { ByteArrayOutputStream docOut = new ByteArrayOutputStream(); XContentBuilder doc = XContentFactory.jsonBuilder(docOut).startObject().field("SomeKey", "SomeValue").endObject(); doc.close(); - indexRequestBuilder.setSource(docOut.toByteArray(), XContentType.JSON); + indexRequestBuilder.setSource(docOut.toByteArray(), MediaTypeRegistry.JSON); assertEquals( EXPECTED_SOURCE, XContentHelper.convertToJson(indexRequestBuilder.request().source(), true, indexRequestBuilder.request().getContentType()) diff --git a/server/src/test/java/org/opensearch/action/index/IndexRequestTests.java b/server/src/test/java/org/opensearch/action/index/IndexRequestTests.java index c4d3b17de1a5a..66c371db025a3 100644 --- a/server/src/test/java/org/opensearch/action/index/IndexRequestTests.java +++ b/server/src/test/java/org/opensearch/action/index/IndexRequestTests.java @@ -40,7 +40,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.unit.ByteSizeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.VersionType; import org.opensearch.index.seqno.SequenceNumbers; import org.opensearch.core.index.shard.ShardId; @@ -99,19 +99,19 @@ public void testCreateOperationRejectsVersions() { public void testIndexingRejectsLongIds() { String id = randomAlphaOfLength(511); IndexRequest request = new IndexRequest("index").id(id); - request.source("{}", XContentType.JSON); + request.source("{}", MediaTypeRegistry.JSON); ActionRequestValidationException validate = request.validate(); assertNull(validate); id = randomAlphaOfLength(512); request = new IndexRequest("index").id(id); - request.source("{}", XContentType.JSON); + request.source("{}", MediaTypeRegistry.JSON); validate = request.validate(); assertNull(validate); id = randomAlphaOfLength(513); request = new IndexRequest("index").id(id); - request.source("{}", XContentType.JSON); + request.source("{}", MediaTypeRegistry.JSON); validate = request.validate(); assertThat(validate, notNullValue()); assertThat(validate.getMessage(), containsString("id [" + id + "] is too long, must be no longer than 512 bytes but was: 513")); @@ -182,15 +182,15 @@ public void testIndexResponse() { public void testIndexRequestXContentSerialization() throws IOException { IndexRequest indexRequest = new IndexRequest("foo").id("1"); boolean isRequireAlias = randomBoolean(); - indexRequest.source("{}", XContentType.JSON); + indexRequest.source("{}", MediaTypeRegistry.JSON); indexRequest.setRequireAlias(isRequireAlias); - assertEquals(XContentType.JSON, indexRequest.getContentType()); + assertEquals(MediaTypeRegistry.JSON, indexRequest.getContentType()); BytesStreamOutput out = new BytesStreamOutput(); indexRequest.writeTo(out); StreamInput in = StreamInput.wrap(out.bytes().toBytesRef().bytes); IndexRequest serialized = new IndexRequest(in); - assertEquals(XContentType.JSON, serialized.getContentType()); + assertEquals(MediaTypeRegistry.JSON, serialized.getContentType()); assertEquals(new BytesArray("{}"), serialized.source()); assertEquals(isRequireAlias, serialized.isRequireAlias()); } @@ -215,11 +215,11 @@ public void testToStringSizeLimit() throws UnsupportedEncodingException { IndexRequest request = new IndexRequest("index"); String source = "{\"name\":\"value\"}"; - request.source(source, XContentType.JSON); + request.source(source, MediaTypeRegistry.JSON); assertEquals("index {[index][null], source[" + source + "]}", request.toString()); source = "{\"name\":\"" + randomUnicodeOfLength(IndexRequest.MAX_SOURCE_LENGTH_IN_TOSTRING) + "\"}"; - request.source(source, XContentType.JSON); + request.source(source, MediaTypeRegistry.JSON); int actualBytes = source.getBytes("UTF-8").length; assertEquals( "index {[index][null], source[n/a, actual length: [" @@ -233,7 +233,7 @@ public void testToStringSizeLimit() throws UnsupportedEncodingException { public void testRejectsEmptyStringPipeline() { IndexRequest request = new IndexRequest("index"); - request.source("{}", XContentType.JSON); + request.source("{}", MediaTypeRegistry.JSON); request.setPipeline(""); ActionRequestValidationException validate = request.validate(); assertThat(validate, notNullValue()); diff --git a/server/src/test/java/org/opensearch/action/index/IndexResponseTests.java b/server/src/test/java/org/opensearch/action/index/IndexResponseTests.java index ba729d0d3593c..6d268f282f6a0 100644 --- a/server/src/test/java/org/opensearch/action/index/IndexResponseTests.java +++ b/server/src/test/java/org/opensearch/action/index/IndexResponseTests.java @@ -37,6 +37,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -57,7 +58,7 @@ public class IndexResponseTests extends OpenSearchTestCase { public void testToXContent() { { IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "id", 3, 17, 5, true); - String output = Strings.toString(XContentType.JSON, indexResponse); + String output = Strings.toString(MediaTypeRegistry.JSON, indexResponse); assertEquals( "{\"_index\":\"index\",\"_id\":\"id\",\"_version\":5,\"result\":\"created\",\"_shards\":null," + "\"_seq_no\":3,\"_primary_term\":17}", @@ -68,7 +69,7 @@ public void testToXContent() { IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "id", -1, 17, 7, true); indexResponse.setForcedRefresh(true); indexResponse.setShardInfo(new ReplicationResponse.ShardInfo(10, 5)); - String output = Strings.toString(XContentType.JSON, indexResponse); + String output = Strings.toString(MediaTypeRegistry.JSON, indexResponse); assertEquals( "{\"_index\":\"index\",\"_id\":\"id\",\"_version\":7,\"result\":\"created\"," + "\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0}}", diff --git a/server/src/test/java/org/opensearch/action/ingest/PutPipelineRequestTests.java b/server/src/test/java/org/opensearch/action/ingest/PutPipelineRequestTests.java index 336ec67546dc5..e024f6b598ab6 100644 --- a/server/src/test/java/org/opensearch/action/ingest/PutPipelineRequestTests.java +++ b/server/src/test/java/org/opensearch/action/ingest/PutPipelineRequestTests.java @@ -36,6 +36,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; @@ -48,15 +49,19 @@ public class PutPipelineRequestTests extends OpenSearchTestCase { public void testSerializationWithXContent() throws IOException { - PutPipelineRequest request = new PutPipelineRequest("1", new BytesArray("{}".getBytes(StandardCharsets.UTF_8)), XContentType.JSON); - assertEquals(XContentType.JSON, request.getMediaType()); + PutPipelineRequest request = new PutPipelineRequest( + "1", + new BytesArray("{}".getBytes(StandardCharsets.UTF_8)), + MediaTypeRegistry.JSON + ); + assertEquals(MediaTypeRegistry.JSON, request.getMediaType()); BytesStreamOutput output = new BytesStreamOutput(); request.writeTo(output); StreamInput in = StreamInput.wrap(output.bytes().toBytesRef().bytes); PutPipelineRequest serialized = new PutPipelineRequest(in); - assertEquals(XContentType.JSON, serialized.getMediaType()); + assertEquals(MediaTypeRegistry.JSON, serialized.getMediaType()); assertEquals("{}", serialized.getSource().utf8ToString()); } diff --git a/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestTests.java b/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestTests.java index 35cbc83661c8e..20710155b48cc 100644 --- a/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestTests.java +++ b/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestTests.java @@ -35,7 +35,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; @@ -46,7 +46,7 @@ public class SimulatePipelineRequestTests extends OpenSearchTestCase { public void testSerialization() throws IOException { - SimulatePipelineRequest request = new SimulatePipelineRequest(new BytesArray(""), XContentType.JSON); + SimulatePipelineRequest request = new SimulatePipelineRequest(new BytesArray(""), MediaTypeRegistry.JSON); // Sometimes we set an id if (randomBoolean()) { request.setId(randomAlphaOfLengthBetween(1, 10)); @@ -69,16 +69,16 @@ public void testSerialization() throws IOException { public void testSerializationWithXContent() throws IOException { SimulatePipelineRequest request = new SimulatePipelineRequest( new BytesArray("{}".getBytes(StandardCharsets.UTF_8)), - XContentType.JSON + MediaTypeRegistry.JSON ); - assertEquals(XContentType.JSON, request.getXContentType()); + assertEquals(MediaTypeRegistry.JSON, request.getXContentType()); BytesStreamOutput output = new BytesStreamOutput(); request.writeTo(output); StreamInput in = StreamInput.wrap(output.bytes().toBytesRef().bytes); SimulatePipelineRequest serialized = new SimulatePipelineRequest(in); - assertEquals(XContentType.JSON, serialized.getXContentType()); + assertEquals(MediaTypeRegistry.JSON, serialized.getXContentType()); assertEquals("{}", serialized.getSource().utf8ToString()); } } diff --git a/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java b/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java index d4b792a0ca6af..e14c7c39084f2 100644 --- a/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java +++ b/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java @@ -43,6 +43,8 @@ import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; @@ -120,7 +122,7 @@ public void testFailWithUnknownKey() { + "{\"query\" : {\"match_all\" :{}}}\r\n"; FakeRestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray(requestContent), - XContentType.JSON + MediaTypeRegistry.JSON ).build(); IllegalArgumentException ex = expectThrows( IllegalArgumentException.class, @@ -134,7 +136,7 @@ public void testSimpleAddWithCarriageReturn() throws Exception { + "{\"query\" : {\"match_all\" :{}}}\r\n"; FakeRestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray(requestContent), - XContentType.JSON + MediaTypeRegistry.JSON ).build(); MultiSearchRequest request = RestMultiSearchAction.parseRequest(restRequest, null, true); assertThat(request.requests().size(), equalTo(1)); @@ -152,7 +154,7 @@ public void testCancelAfterIntervalAtParentAndFewChildRequest() throws Exception + "{\"query\" : {\"match_all\" :{}}}\r\n"; FakeRestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray(requestContent), - XContentType.JSON + MediaTypeRegistry.JSON ).withParams(Collections.singletonMap("cancel_after_time_interval", "20s")).build(); MultiSearchRequest request = RestMultiSearchAction.parseRequest(restRequest, null, true); assertThat(request.requests().size(), equalTo(2)); @@ -169,7 +171,7 @@ public void testOnlyParentMSearchRequestWithCancelAfterTimeIntervalParameter() t + "{\"query\" : {\"match_all\" :{}}}\r\n"; FakeRestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray(requestContent), - XContentType.JSON + MediaTypeRegistry.JSON ).withParams(Collections.singletonMap("cancel_after_time_interval", "20s")).build(); MultiSearchRequest request = RestMultiSearchAction.parseRequest(restRequest, null, true); assertThat(request.requests().size(), equalTo(1)); @@ -182,7 +184,7 @@ public void testDefaultIndicesOptions() throws IOException { + "{\"query\" : {\"match_all\" :{}}}\r\n"; FakeRestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray(requestContent), - XContentType.JSON + MediaTypeRegistry.JSON ).withParams(Collections.singletonMap("ignore_unavailable", "true")).build(); MultiSearchRequest request = RestMultiSearchAction.parseRequest(restRequest, null, true); assertThat(request.requests().size(), equalTo(1)); @@ -301,7 +303,7 @@ public void testResponseErrorToXContent() { + "\"type\":\"illegal_state_exception\",\"reason\":\"baaaaaazzzz\"},\"status\":500" + "}" + "]}", - Strings.toString(XContentType.JSON, response) + Strings.toString(MediaTypeRegistry.JSON, response) ); } @@ -315,7 +317,7 @@ public void testMsearchTerminatedByNewline() throws Exception { String mserchAction = StreamsUtils.copyToStringFromClasspath("/org/opensearch/action/search/simple-msearch5.json"); RestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray(mserchAction.getBytes(StandardCharsets.UTF_8)), - XContentType.JSON + MediaTypeRegistry.JSON ).build(); IllegalArgumentException expectThrows = expectThrows( IllegalArgumentException.class, @@ -326,7 +328,7 @@ public void testMsearchTerminatedByNewline() throws Exception { String mserchActionWithNewLine = mserchAction + "\n"; RestRequest restRequestWithNewLine = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray(mserchActionWithNewLine.getBytes(StandardCharsets.UTF_8)), - XContentType.JSON + MediaTypeRegistry.JSON ).build(); MultiSearchRequest msearchRequest = RestMultiSearchAction.parseRequest(restRequestWithNewLine, null, true); assertEquals(3, msearchRequest.requests().size()); @@ -334,14 +336,14 @@ public void testMsearchTerminatedByNewline() throws Exception { private MultiSearchRequest parseMultiSearchRequestFromString(String request) throws IOException { return parseMultiSearchRequest( - new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(request), XContentType.JSON).build() + new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(request), MediaTypeRegistry.JSON).build() ); } private MultiSearchRequest parseMultiSearchRequestFromFile(String sample) throws IOException { byte[] data = StreamsUtils.copyToBytesFromClasspath(sample); return parseMultiSearchRequest( - new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(data), XContentType.JSON).build() + new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(data), MediaTypeRegistry.JSON).build() ); } @@ -379,10 +381,10 @@ public void testMultiLineSerialization() throws IOException { int iters = 16; for (int i = 0; i < iters; i++) { // The only formats that support stream separator - XContentType xContentType = randomFrom(XContentType.JSON, XContentType.SMILE); + MediaType mediaType = randomFrom(MediaTypeRegistry.JSON, XContentType.SMILE); MultiSearchRequest originalRequest = createMultiSearchRequest(); - byte[] originalBytes = MultiSearchRequest.writeMultiLineFormat(originalRequest, xContentType.xContent()); + byte[] originalBytes = MultiSearchRequest.writeMultiLineFormat(originalRequest, mediaType.xContent()); MultiSearchRequest parsedRequest = new MultiSearchRequest(); CheckedBiConsumer consumer = (r, p) -> { SearchSourceBuilder searchSourceBuilder = SearchSourceBuilder.fromXContent(p, false); @@ -393,7 +395,7 @@ public void testMultiLineSerialization() throws IOException { }; MultiSearchRequest.readMultiLineFormat( new BytesArray(originalBytes), - xContentType.xContent(), + mediaType.xContent(), consumer, null, null, @@ -413,7 +415,7 @@ public void testSerDeWithCancelAfterTimeIntervalParameterAndRandomVersion() thro + "\"cancel_after_time_interval\" : \"10s\"}\r\n{\"query\" : {\"match_all\" :{}}}\r\n"; FakeRestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray(requestContent), - XContentType.JSON + MediaTypeRegistry.JSON ).build(); Version version = VersionUtils.randomVersion(random()); MultiSearchRequest originalRequest = RestMultiSearchAction.parseRequest(restRequest, null, true); @@ -545,7 +547,7 @@ private void assertExpandWildcardsValue(IndicesOptions options, String expectedV try (XContentBuilder builder = JsonXContent.contentBuilder()) { MultiSearchRequest.writeSearchRequestParams(request, builder); Map map = XContentHelper.convertToMap( - XContentType.JSON.xContent(), + MediaTypeRegistry.JSON.xContent(), BytesReference.bytes(builder).streamInput(), false ); diff --git a/server/src/test/java/org/opensearch/action/search/SearchPhaseExecutionExceptionTests.java b/server/src/test/java/org/opensearch/action/search/SearchPhaseExecutionExceptionTests.java index 8056206a661a5..d5ffde60686c9 100644 --- a/server/src/test/java/org/opensearch/action/search/SearchPhaseExecutionExceptionTests.java +++ b/server/src/test/java/org/opensearch/action/search/SearchPhaseExecutionExceptionTests.java @@ -39,6 +39,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContent; import org.opensearch.common.xcontent.XContentHelper; @@ -111,7 +112,7 @@ public void testToXContent() throws IOException { + " ]" + "}" ); - assertEquals(expectedJson, Strings.toString(XContentType.JSON, exception)); + assertEquals(expectedJson, Strings.toString(MediaTypeRegistry.JSON, exception)); } public void testToAndFromXContent() throws IOException { diff --git a/server/src/test/java/org/opensearch/action/search/SearchResponseTests.java b/server/src/test/java/org/opensearch/action/search/SearchResponseTests.java index 145f1238a08fc..5358420433bbc 100644 --- a/server/src/test/java/org/opensearch/action/search/SearchResponseTests.java +++ b/server/src/test/java/org/opensearch/action/search/SearchResponseTests.java @@ -36,15 +36,16 @@ import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.rest.action.search.RestSearchAction; import org.opensearch.search.SearchHit; @@ -182,7 +183,7 @@ public void testFromXContentWithRandomFields() throws IOException { } private void doFromXContentTestWithRandomFields(SearchResponse response, boolean addRandomFields) throws IOException { - XContentType xcontentType = randomFrom(XContentType.values()); + MediaType xcontentType = randomFrom(XContentType.values()); boolean humanReadable = randomBoolean(); final ToXContent.Params params = new ToXContent.MapParams(singletonMap(RestSearchAction.TYPED_KEYS_PARAM, "true")); BytesReference originalBytes = toShuffledXContent(response, xcontentType, params, humanReadable); @@ -330,7 +331,7 @@ public void testToXContent() { } } expectedString.append("}"); - assertEquals(expectedString.toString(), Strings.toString(XContentType.JSON, response)); + assertEquals(expectedString.toString(), Strings.toString(MediaTypeRegistry.JSON, response)); } } @@ -363,7 +364,7 @@ public void testToXContentEmptyClusters() throws IOException { SearchResponse.Clusters.EMPTY ); SearchResponse deserialized = copyWriteable(searchResponse, namedWriteableRegistry, SearchResponse::new, Version.CURRENT); - XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder builder = XContentBuilder.builder(MediaTypeRegistry.JSON.xContent()); deserialized.getClusters().toXContent(builder, ToXContent.EMPTY_PARAMS); assertEquals(0, builder.toString().length()); } diff --git a/server/src/test/java/org/opensearch/action/search/ShardSearchFailureTests.java b/server/src/test/java/org/opensearch/action/search/ShardSearchFailureTests.java index 4fa555f0edddc..4a5a2aba9eb5a 100644 --- a/server/src/test/java/org/opensearch/action/search/ShardSearchFailureTests.java +++ b/server/src/test/java/org/opensearch/action/search/ShardSearchFailureTests.java @@ -36,6 +36,7 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.core.common.ParsingException; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -47,7 +48,7 @@ import java.io.IOException; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.test.XContentTestUtils.insertRandomFields; public class ShardSearchFailureTests extends OpenSearchTestCase { @@ -124,7 +125,7 @@ public void testToXContent() throws IOException { new ParsingException(0, 0, "some message", null), new SearchShardTarget("nodeId", new ShardId(new Index("indexName", "indexUuid"), 123), null, OriginalIndices.NONE) ); - BytesReference xContent = toXContent(failure, XContentType.JSON, randomBoolean()); + BytesReference xContent = toXContent(failure, MediaTypeRegistry.JSON, randomBoolean()); assertEquals( "{\"shard\":123," + "\"index\":\"indexName\"," @@ -145,7 +146,7 @@ public void testToXContentWithClusterAlias() throws IOException { new ParsingException(0, 0, "some message", null), new SearchShardTarget("nodeId", new ShardId(new Index("indexName", "indexUuid"), 123), "cluster1", OriginalIndices.NONE) ); - BytesReference xContent = toXContent(failure, XContentType.JSON, randomBoolean()); + BytesReference xContent = toXContent(failure, MediaTypeRegistry.JSON, randomBoolean()); assertEquals( "{\"shard\":123," + "\"index\":\"cluster1:indexName\"," diff --git a/server/src/test/java/org/opensearch/action/support/replication/ReplicationResponseTests.java b/server/src/test/java/org/opensearch/action/support/replication/ReplicationResponseTests.java index 35d7134b5dcc4..dc5a06b40209d 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/ReplicationResponseTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/ReplicationResponseTests.java @@ -39,6 +39,7 @@ import org.opensearch.core.common.breaker.CircuitBreakingException; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -51,7 +52,7 @@ import java.util.Locale; import static org.opensearch.OpenSearchExceptionTests.assertDeepEquals; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; public class ReplicationResponseTests extends OpenSearchTestCase { @@ -66,7 +67,7 @@ public void testShardInfoToString() { public void testShardInfoToXContent() throws IOException { { ShardInfo shardInfo = new ShardInfo(5, 3); - String output = Strings.toString(XContentType.JSON, shardInfo); + String output = Strings.toString(MediaTypeRegistry.JSON, shardInfo); assertEquals("{\"total\":5,\"successful\":3,\"failed\":0}", output); } { @@ -88,7 +89,7 @@ public void testShardInfoToXContent() throws IOException { true ) ); - String output = Strings.toString(XContentType.JSON, shardInfo); + String output = Strings.toString(MediaTypeRegistry.JSON, shardInfo); assertEquals( "{\"total\":6,\"successful\":4,\"failed\":2,\"failures\":[{\"_index\":\"index\",\"_shard\":3," + "\"_node\":\"_node_id\",\"reason\":{\"type\":\"illegal_argument_exception\",\"reason\":\"Wrong\"}," diff --git a/server/src/test/java/org/opensearch/action/termvectors/TermVectorsUnitTests.java b/server/src/test/java/org/opensearch/action/termvectors/TermVectorsUnitTests.java index c7f14f7a22805..90efa3341eb73 100644 --- a/server/src/test/java/org/opensearch/action/termvectors/TermVectorsUnitTests.java +++ b/server/src/test/java/org/opensearch/action/termvectors/TermVectorsUnitTests.java @@ -55,8 +55,8 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.InputStreamStreamInput; import org.opensearch.core.common.io.stream.OutputStreamStreamOutput; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.index.shard.ShardId; import org.opensearch.rest.action.document.RestTermVectorsAction; @@ -247,7 +247,7 @@ public void testStreamRequest() throws IOException { request.termStatistics(random().nextBoolean()); String pref = random().nextBoolean() ? "somePreference" : null; request.preference(pref); - request.doc(new BytesArray("{}"), randomBoolean(), XContentType.JSON); + request.doc(new BytesArray("{}"), randomBoolean(), MediaTypeRegistry.JSON); // write ByteArrayOutputStream outBuffer = new ByteArrayOutputStream(); @@ -267,7 +267,7 @@ public void testStreamRequest() throws IOException { assertThat(request.preference(), equalTo(pref)); assertThat(request.routing(), equalTo(null)); assertEquals(new BytesArray("{}"), request.doc()); - assertEquals(XContentType.JSON, request.xContentType()); + assertEquals(MediaTypeRegistry.JSON, request.xContentType()); } } @@ -281,7 +281,7 @@ public void testStreamRequestLegacyVersion() throws IOException { request.termStatistics(random().nextBoolean()); String pref = random().nextBoolean() ? "somePreference" : null; request.preference(pref); - request.doc(new BytesArray("{}"), randomBoolean(), XContentType.JSON); + request.doc(new BytesArray("{}"), randomBoolean(), MediaTypeRegistry.JSON); // write using older version which contains types ByteArrayOutputStream outBuffer = new ByteArrayOutputStream(); @@ -313,7 +313,7 @@ public void testStreamRequestLegacyVersion() throws IOException { assertThat(request.preference(), equalTo(pref)); assertThat(request.routing(), equalTo(null)); assertEquals(new BytesArray("{}"), request.doc()); - assertEquals(XContentType.JSON, request.xContentType()); + assertEquals(MediaTypeRegistry.JSON, request.xContentType()); } } diff --git a/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java b/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java index cc4abc5343959..0b0827d704c74 100644 --- a/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java +++ b/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java @@ -54,9 +54,9 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.Index; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.indices.IndicesService; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskId; @@ -140,7 +140,7 @@ public TaskManager getTaskManager() { .endObject() ), true, - XContentType.JSON + MediaTypeRegistry.JSON ) ) ) @@ -165,7 +165,7 @@ public TaskManager getTaskManager() { .endObject() ), true, - XContentType.JSON + MediaTypeRegistry.JSON ) ) ) diff --git a/server/src/test/java/org/opensearch/action/update/UpdateRequestTests.java b/server/src/test/java/org/opensearch/action/update/UpdateRequestTests.java index e0ee034f53821..b74221b4fc59a 100644 --- a/server/src/test/java/org/opensearch/action/update/UpdateRequestTests.java +++ b/server/src/test/java/org/opensearch/action/update/UpdateRequestTests.java @@ -42,6 +42,7 @@ import org.opensearch.common.document.DocumentField; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; @@ -71,7 +72,7 @@ import static java.util.Collections.emptyMap; import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; import static org.opensearch.script.MockScriptEngine.mockInlineScript; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; @@ -514,7 +515,7 @@ public void testToValidateUpsertRequestAndCAS() { UpdateRequest updateRequest = new UpdateRequest("index", "id"); updateRequest.setIfSeqNo(1L); updateRequest.setIfPrimaryTerm(1L); - updateRequest.doc("{}", XContentType.JSON); + updateRequest.doc("{}", MediaTypeRegistry.JSON); updateRequest.upsert(new IndexRequest("index").id("id")); assertThat( updateRequest.validate().validationErrors(), @@ -524,7 +525,7 @@ public void testToValidateUpsertRequestAndCAS() { public void testToValidateUpsertRequestWithVersion() { UpdateRequest updateRequest = new UpdateRequest("index", "id"); - updateRequest.doc("{}", XContentType.JSON); + updateRequest.doc("{}", MediaTypeRegistry.JSON); updateRequest.upsert(new IndexRequest("index").id("1").version(1L)); assertThat(updateRequest.validate().validationErrors(), contains("can't provide version in upsert request")); } @@ -532,7 +533,7 @@ public void testToValidateUpsertRequestWithVersion() { public void testValidate() { { UpdateRequest request = new UpdateRequest("index", "id"); - request.doc("{}", XContentType.JSON); + request.doc("{}", MediaTypeRegistry.JSON); ActionRequestValidationException validate = request.validate(); assertThat(validate, nullValue()); @@ -540,7 +541,7 @@ public void testValidate() { { // Null types are defaulted to "_doc" UpdateRequest request = new UpdateRequest("index", null); - request.doc("{}", XContentType.JSON); + request.doc("{}", MediaTypeRegistry.JSON); ActionRequestValidationException validate = request.validate(); assertThat(validate, not(nullValue())); diff --git a/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java b/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java index 187b7f259ed63..b49b5a582304a 100644 --- a/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java +++ b/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java @@ -40,9 +40,10 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.document.DocumentField; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.get.GetResult; import org.opensearch.index.get.GetResultTests; import org.opensearch.index.seqno.SequenceNumbers; @@ -60,7 +61,7 @@ import static org.opensearch.action.DocWriteResponse.Result.NOT_FOUND; import static org.opensearch.action.DocWriteResponse.Result.UPDATED; import static org.opensearch.cluster.metadata.IndexMetadata.INDEX_UUID_NA_VALUE; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.test.XContentTestUtils.insertRandomFields; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; @@ -69,7 +70,7 @@ public class UpdateResponseTests extends OpenSearchTestCase { public void testToXContent() throws IOException { { UpdateResponse updateResponse = new UpdateResponse(new ShardId("index", "index_uuid", 0), "id", -2, 0, 0, NOT_FOUND); - String output = Strings.toString(XContentType.JSON, updateResponse); + String output = Strings.toString(MediaTypeRegistry.JSON, updateResponse); assertEquals( "{\"_index\":\"index\",\"_id\":\"id\",\"_version\":0,\"result\":\"not_found\"," + "\"_shards\":{\"total\":0,\"successful\":0,\"failed\":0}}", @@ -86,7 +87,7 @@ public void testToXContent() throws IOException { 1, DELETED ); - String output = Strings.toString(XContentType.JSON, updateResponse); + String output = Strings.toString(MediaTypeRegistry.JSON, updateResponse); assertEquals( "{\"_index\":\"index\",\"_id\":\"id\",\"_version\":1,\"result\":\"deleted\"," + "\"_shards\":{\"total\":10,\"successful\":6,\"failed\":0},\"_seq_no\":3,\"_primary_term\":17}", @@ -110,7 +111,7 @@ public void testToXContent() throws IOException { ); updateResponse.setGetResult(new GetResult("books", "1", 0, 1, 2, true, source, fields, null)); - String output = Strings.toString(XContentType.JSON, updateResponse); + String output = Strings.toString(MediaTypeRegistry.JSON, updateResponse); assertEquals( "{\"_index\":\"books\",\"_id\":\"1\",\"_version\":2,\"result\":\"updated\"," + "\"_shards\":{\"total\":3,\"successful\":2,\"failed\":0},\"_seq_no\":7,\"_primary_term\":17,\"get\":{" @@ -136,13 +137,13 @@ public void testFromXContentWithRandomFields() throws IOException { } private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws IOException { - final XContentType xContentType = randomFrom(XContentType.JSON); - final Tuple tuple = randomUpdateResponse(xContentType); + final MediaType mediaType = randomFrom(MediaTypeRegistry.JSON); + final Tuple tuple = randomUpdateResponse(mediaType); UpdateResponse updateResponse = tuple.v1(); UpdateResponse expectedUpdateResponse = tuple.v2(); boolean humanReadable = randomBoolean(); - BytesReference originalBytes = toShuffledXContent(updateResponse, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); + BytesReference originalBytes = toShuffledXContent(updateResponse, mediaType, ToXContent.EMPTY_PARAMS, humanReadable); BytesReference mutated; if (addRandomFields) { @@ -155,12 +156,12 @@ private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws // object since this is where GetResult's metadata fields are rendered out and they would be parsed back as // extra metadata fields. Predicate excludeFilter = path -> path.contains("reason") || path.contains("get"); - mutated = insertRandomFields(xContentType, originalBytes, excludeFilter, random()); + mutated = insertRandomFields(mediaType, originalBytes, excludeFilter, random()); } else { mutated = originalBytes; } UpdateResponse parsedUpdateResponse; - try (XContentParser parser = createParser(xContentType.xContent(), mutated)) { + try (XContentParser parser = createParser(mediaType.xContent(), mutated)) { parsedUpdateResponse = UpdateResponse.fromXContent(parser); assertNull(parser.nextToken()); } @@ -173,9 +174,9 @@ private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws // Prints out the parsed UpdateResponse object to verify that it is the same as the expected output. // If random fields have been inserted, it checks that they have been filtered out and that they do // not alter the final output of the parsed object. - BytesReference parsedBytes = toXContent(parsedUpdateResponse, xContentType, humanReadable); - BytesReference expectedBytes = toXContent(expectedUpdateResponse, xContentType, humanReadable); - assertToXContentEquivalent(expectedBytes, parsedBytes, xContentType); + BytesReference parsedBytes = toXContent(parsedUpdateResponse, mediaType, humanReadable); + BytesReference expectedBytes = toXContent(expectedUpdateResponse, mediaType, humanReadable); + assertToXContentEquivalent(expectedBytes, parsedBytes, mediaType); } /** @@ -184,8 +185,8 @@ private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws * The left element is the actual {@link UpdateResponse} to serialize while the right element is the * expected {@link UpdateResponse} after parsing. */ - public static Tuple randomUpdateResponse(XContentType xContentType) { - Tuple getResults = GetResultTests.randomGetResult(xContentType); + public static Tuple randomUpdateResponse(MediaType mediaType) { + Tuple getResults = GetResultTests.randomGetResult(mediaType); GetResult actualGetResult = getResults.v1(); GetResult expectedGetResult = getResults.v2(); diff --git a/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java b/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java index 92a88aa7940ee..0d324a0da7ee6 100644 --- a/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java +++ b/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java @@ -49,7 +49,7 @@ import org.opensearch.action.search.SearchAction; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.env.Environment; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.ThreadPool; @@ -130,7 +130,7 @@ public void testActions() { .execute(new AssertingActionListener<>(DeleteStoredScriptAction.NAME, client.threadPool())); client.prepareIndex("idx") .setId("id") - .setSource("source", XContentType.JSON) + .setSource("source", MediaTypeRegistry.JSON) .execute(new AssertingActionListener<>(IndexAction.NAME, client.threadPool())); // choosing arbitrary cluster admin actions to test diff --git a/server/src/test/java/org/opensearch/cluster/metadata/IndexGraveyardTests.java b/server/src/test/java/org/opensearch/cluster/metadata/IndexGraveyardTests.java index dd570a33d9c58..97d73fff4f834 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/IndexGraveyardTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/IndexGraveyardTests.java @@ -38,7 +38,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentOpenSearchExtension; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -87,7 +87,7 @@ public void testXContent() throws IOException { if (graveyard.getTombstones().size() > 0) { // check that date properly printed assertThat( - Strings.toString(XContentType.JSON, graveyard, false, true), + Strings.toString(MediaTypeRegistry.JSON, graveyard, false, true), containsString( XContentOpenSearchExtension.DEFAULT_DATE_PRINTER.print(graveyard.getTombstones().get(0).getDeleteDateInMillis()) ) diff --git a/server/src/test/java/org/opensearch/cluster/metadata/IndexMetadataTests.java b/server/src/test/java/org/opensearch/cluster/metadata/IndexMetadataTests.java index 6ace70864ba47..3cd36c24755c3 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/IndexMetadataTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/IndexMetadataTests.java @@ -46,8 +46,8 @@ import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.set.Sets; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -129,9 +129,9 @@ public void testIndexMetadataSerialization() throws IOException { final IndexMetadata fromXContentMeta = IndexMetadata.fromXContent(parser); assertEquals( "expected: " - + Strings.toString(XContentType.JSON, metadata) + + Strings.toString(MediaTypeRegistry.JSON, metadata) + "\nactual : " - + Strings.toString(XContentType.JSON, fromXContentMeta), + + Strings.toString(MediaTypeRegistry.JSON, fromXContentMeta), metadata, fromXContentMeta ); diff --git a/server/src/test/java/org/opensearch/cluster/metadata/IndexTemplateMetadataTests.java b/server/src/test/java/org/opensearch/cluster/metadata/IndexTemplateMetadataTests.java index 4648eaa6e3852..4610bc1c0c5a1 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/IndexTemplateMetadataTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/IndexTemplateMetadataTests.java @@ -35,12 +35,12 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.test.OpenSearchTestCase; @@ -73,7 +73,7 @@ public void testIndexTemplateMetadataXContentRoundTrip() throws Exception { NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, templateBytes, - XContentType.JSON + MediaTypeRegistry.JSON ) ) { indexTemplateMetadata = IndexTemplateMetadata.Builder.fromXContent(parser, "test"); @@ -93,7 +93,7 @@ public void testIndexTemplateMetadataXContentRoundTrip() throws Exception { NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, templateBytesRoundTrip, - XContentType.JSON + MediaTypeRegistry.JSON ) ) { indexTemplateMetadataRoundTrip = IndexTemplateMetadata.Builder.fromXContent(parser, "test"); @@ -142,7 +142,7 @@ public void testValidateInvalidIndexPatterns() throws Exception { NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, new BytesArray(templateWithEmptyPattern), - XContentType.JSON + MediaTypeRegistry.JSON ) ) { final IllegalArgumentException ex = expectThrows( @@ -166,7 +166,7 @@ public void testValidateInvalidIndexPatterns() throws Exception { NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, new BytesArray(templateWithoutPattern), - XContentType.JSON + MediaTypeRegistry.JSON ) ) { final IllegalArgumentException ex = expectThrows( @@ -184,7 +184,7 @@ public void testParseTemplateWithAliases() throws Exception { NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, new BytesArray(templateInJSON), - XContentType.JSON + MediaTypeRegistry.JSON ) ) { IndexTemplateMetadata template = IndexTemplateMetadata.Builder.fromXContent(parser, randomAlphaOfLengthBetween(1, 100)); @@ -222,7 +222,7 @@ public void testFromToXContent() throws Exception { templateBuilder.putMapping("doc", "{\"doc\":{\"properties\":{\"type\":\"text\"}}}"); } IndexTemplateMetadata template = templateBuilder.build(); - XContentBuilder builder = XContentBuilder.builder(randomFrom(XContentType.JSON.xContent())); + XContentBuilder builder = XContentBuilder.builder(randomFrom(MediaTypeRegistry.JSON.xContent())); builder.startObject(); IndexTemplateMetadata.Builder.toXContentWithTypes(template, builder, ToXContent.EMPTY_PARAMS); builder.endObject(); diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java index 2f92ee8e0abdd..dc8f0ea26dccc 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java @@ -47,10 +47,10 @@ import org.opensearch.common.settings.SettingsException; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.env.Environment; import org.opensearch.core.index.Index; import org.opensearch.index.mapper.MapperParsingException; @@ -2146,7 +2146,7 @@ public static void assertTemplatesEqual(ComposableIndexTemplate actual, Composab Map actualMappings; Map expectedMappings; try ( - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser( new NamedXContentRegistry(Collections.emptyList()), LoggingDeprecationHandler.INSTANCE, @@ -2158,7 +2158,7 @@ public static void assertTemplatesEqual(ComposableIndexTemplate actual, Composab throw new AssertionError(e); } try ( - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser( new NamedXContentRegistry(Collections.emptyList()), LoggingDeprecationHandler.INSTANCE, diff --git a/server/src/test/java/org/opensearch/cluster/serialization/ClusterStateToStringTests.java b/server/src/test/java/org/opensearch/cluster/serialization/ClusterStateToStringTests.java index 6f81db2f0ef92..c978325917fe9 100644 --- a/server/src/test/java/org/opensearch/cluster/serialization/ClusterStateToStringTests.java +++ b/server/src/test/java/org/opensearch/cluster/serialization/ClusterStateToStringTests.java @@ -43,8 +43,8 @@ import org.opensearch.cluster.routing.RoutingTable; import org.opensearch.cluster.routing.allocation.AllocationService; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import java.util.Arrays; @@ -80,7 +80,7 @@ public void testClusterStateSerialization() throws Exception { AllocationService strategy = createAllocationService(); clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState, "reroute").routingTable()).build(); - String clusterStateString = Strings.toString(XContentType.JSON, clusterState); + String clusterStateString = Strings.toString(MediaTypeRegistry.JSON, clusterState); assertNotNull(clusterStateString); assertThat(clusterStateString, containsString("test_idx")); diff --git a/server/src/test/java/org/opensearch/common/geo/GeoJsonSerializationTests.java b/server/src/test/java/org/opensearch/common/geo/GeoJsonSerializationTests.java index 23855c8f8dc91..45c9c79b7174f 100644 --- a/server/src/test/java/org/opensearch/common/geo/GeoJsonSerializationTests.java +++ b/server/src/test/java/org/opensearch/common/geo/GeoJsonSerializationTests.java @@ -35,13 +35,13 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.geo.GeometryTestUtils; import org.opensearch.geometry.Geometry; import org.opensearch.geometry.utils.GeographyValidator; @@ -153,7 +153,7 @@ public void testToMap() throws IOException { StreamInput input = BytesReference.bytes(builder).streamInput(); try ( - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, input) ) { Map map = GeoJson.toMap(geometry); diff --git a/server/src/test/java/org/opensearch/common/settings/SettingsTests.java b/server/src/test/java/org/opensearch/common/settings/SettingsTests.java index 83fb74bb185c2..d627fe7c80477 100644 --- a/server/src/test/java/org/opensearch/common/settings/SettingsTests.java +++ b/server/src/test/java/org/opensearch/common/settings/SettingsTests.java @@ -41,6 +41,7 @@ import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; import org.opensearch.core.common.settings.SecureString; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -514,7 +515,7 @@ public void testToAndFromXContent() throws IOException { .putNull("foo.null.baz") .build(); final boolean flatSettings = randomBoolean(); - XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder(); builder.startObject(); settings.toXContent(builder, new ToXContent.MapParams(Collections.singletonMap("flat_settings", "" + flatSettings))); builder.endObject(); @@ -547,20 +548,20 @@ public void testSimpleJsonSettings() throws Exception { public void testToXContent() throws IOException { // this is just terrible but it's the existing behavior! Settings test = Settings.builder().putList("foo.bar", "1", "2", "3").put("foo.bar.baz", "test").build(); - XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder builder = XContentBuilder.builder(MediaTypeRegistry.JSON.xContent()); builder.startObject(); test.toXContent(builder, new ToXContent.MapParams(Collections.emptyMap())); builder.endObject(); assertEquals("{\"foo\":{\"bar.baz\":\"test\",\"bar\":[\"1\",\"2\",\"3\"]}}", builder.toString()); test = Settings.builder().putList("foo.bar", "1", "2", "3").build(); - builder = XContentBuilder.builder(XContentType.JSON.xContent()); + builder = XContentBuilder.builder(MediaTypeRegistry.JSON.xContent()); builder.startObject(); test.toXContent(builder, new ToXContent.MapParams(Collections.emptyMap())); builder.endObject(); assertEquals("{\"foo\":{\"bar\":[\"1\",\"2\",\"3\"]}}", builder.toString()); - builder = XContentBuilder.builder(XContentType.JSON.xContent()); + builder = XContentBuilder.builder(MediaTypeRegistry.JSON.xContent()); builder.startObject(); test.toXContent(builder, new ToXContent.MapParams(Collections.singletonMap("flat_settings", "true"))); builder.endObject(); @@ -707,14 +708,14 @@ public void testSetByTimeUnit() { public void testProcessSetting() throws IOException { Settings test = Settings.builder().put("ant", "value1").put("ant.bee.cat", "value2").put("bee.cat", "value3").build(); - XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder builder = XContentBuilder.builder(MediaTypeRegistry.JSON.xContent()); builder.startObject(); test.toXContent(builder, new ToXContent.MapParams(Collections.emptyMap())); builder.endObject(); assertEquals("{\"ant.bee\":{\"cat\":\"value2\"},\"ant\":\"value1\",\"bee\":{\"cat\":\"value3\"}}", builder.toString()); test = Settings.builder().put("ant", "value1").put("ant.bee.cat", "value2").put("ant.bee.cat.dog.ewe", "value3").build(); - builder = XContentBuilder.builder(XContentType.JSON.xContent()); + builder = XContentBuilder.builder(MediaTypeRegistry.JSON.xContent()); builder.startObject(); test.toXContent(builder, new ToXContent.MapParams(Collections.emptyMap())); builder.endObject(); diff --git a/server/src/test/java/org/opensearch/common/xcontent/XContentFactoryTests.java b/server/src/test/java/org/opensearch/common/xcontent/XContentFactoryTests.java index 41e63f3f6d825..3ba727a8edf2a 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/XContentFactoryTests.java +++ b/server/src/test/java/org/opensearch/common/xcontent/XContentFactoryTests.java @@ -36,6 +36,7 @@ import com.fasterxml.jackson.dataformat.smile.SmileConstants; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.test.OpenSearchTestCase; @@ -48,7 +49,7 @@ public class XContentFactoryTests extends OpenSearchTestCase { public void testGuessJson() throws IOException { - testGuessType(XContentType.JSON); + testGuessType(MediaTypeRegistry.JSON); } public void testGuessSmile() throws IOException { @@ -63,14 +64,14 @@ public void testGuessCbor() throws IOException { testGuessType(XContentType.CBOR); } - private void testGuessType(XContentType type) throws IOException { + private void testGuessType(MediaType type) throws IOException { XContentBuilder builder = MediaTypeRegistry.contentBuilder(type); builder.startObject(); builder.field("field1", "value1"); builder.endObject(); final BytesReference bytes; - if (type == XContentType.JSON && randomBoolean()) { + if (type == MediaTypeRegistry.JSON && randomBoolean()) { final int length = randomIntBetween(0, 8 * MediaTypeRegistry.GUESS_HEADER_LENGTH); final String content = builder.toString(); final StringBuilder sb = new StringBuilder(length + content.length()); @@ -132,15 +133,15 @@ public void testInvalidStream() throws Exception { public void testJsonFromBytesOptionallyPrecededByUtf8Bom() throws Exception { byte[] bytes = new byte[] { (byte) '{', (byte) '}' }; - assertThat(MediaTypeRegistry.xContent(bytes), equalTo(XContentType.JSON)); + assertThat(MediaTypeRegistry.xContent(bytes), equalTo(MediaTypeRegistry.JSON)); bytes = new byte[] { (byte) 0x20, (byte) '{', (byte) '}' }; - assertThat(MediaTypeRegistry.xContent(bytes), equalTo(XContentType.JSON)); + assertThat(MediaTypeRegistry.xContent(bytes), equalTo(MediaTypeRegistry.JSON)); bytes = new byte[] { (byte) 0xef, (byte) 0xbb, (byte) 0xbf, (byte) '{', (byte) '}' }; - assertThat(MediaTypeRegistry.xContent(bytes), equalTo(XContentType.JSON)); + assertThat(MediaTypeRegistry.xContent(bytes), equalTo(MediaTypeRegistry.JSON)); bytes = new byte[] { (byte) 0xef, (byte) 0xbb, (byte) 0xbf, (byte) 0x20, (byte) '{', (byte) '}' }; - assertThat(MediaTypeRegistry.xContent(bytes), equalTo(XContentType.JSON)); + assertThat(MediaTypeRegistry.xContent(bytes), equalTo(MediaTypeRegistry.JSON)); } } diff --git a/server/src/test/java/org/opensearch/common/xcontent/XContentParserUtilsTests.java b/server/src/test/java/org/opensearch/common/xcontent/XContentParserUtilsTests.java index 4f0d4b7cb63dc..b9feb10c51fff 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/XContentParserUtilsTests.java +++ b/server/src/test/java/org/opensearch/common/xcontent/XContentParserUtilsTests.java @@ -40,6 +40,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParserUtils; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.NamedObjectNotFoundException; @@ -55,7 +56,7 @@ import java.util.List; import java.util.Map; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; import static org.opensearch.core.xcontent.XContentParserUtils.ensureFieldName; import static org.opensearch.core.xcontent.XContentParserUtils.parseTypedKeysObject; @@ -113,7 +114,7 @@ public void testStoredFieldsValueBoolean() throws IOException { public void testStoredFieldsValueBinary() throws IOException { final byte[] value = randomUnicodeOfLength(scaledRandomIntBetween(10, 1000)).getBytes("UTF-8"); assertParseFieldsSimpleValue(value, (xcontentType, result) -> { - if (xcontentType == XContentType.JSON) { + if (xcontentType == MediaTypeRegistry.JSON) { // binary values will be parsed back and returned as base64 strings when reading from json assertArrayEquals(value, Base64.getDecoder().decode((String) result)); } else { diff --git a/server/src/test/java/org/opensearch/common/xcontent/XContentTypeTests.java b/server/src/test/java/org/opensearch/common/xcontent/XContentTypeTests.java index 8c53d7edebca8..53fbcb4659f72 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/XContentTypeTests.java +++ b/server/src/test/java/org/opensearch/common/xcontent/XContentTypeTests.java @@ -32,6 +32,7 @@ package org.opensearch.common.xcontent; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchTestCase; import java.util.Locale; @@ -43,7 +44,7 @@ public class XContentTypeTests extends OpenSearchTestCase { public void testFromJson() throws Exception { String mediaType = "application/json"; - XContentType expectedXContentType = XContentType.JSON; + MediaType expectedXContentType = MediaTypeRegistry.JSON; assertThat(MediaType.fromMediaType(mediaType), equalTo(expectedXContentType)); assertThat(MediaType.fromMediaType(mediaType + ";"), equalTo(expectedXContentType)); assertThat(MediaType.fromMediaType(mediaType + "; charset=UTF-8"), equalTo(expectedXContentType)); @@ -51,7 +52,7 @@ public void testFromJson() throws Exception { public void testFromNdJson() throws Exception { String mediaType = "application/x-ndjson"; - XContentType expectedXContentType = XContentType.JSON; + MediaType expectedXContentType = MediaTypeRegistry.JSON; assertThat(MediaType.fromMediaType(mediaType), equalTo(expectedXContentType)); assertThat(MediaType.fromMediaType(mediaType + ";"), equalTo(expectedXContentType)); assertThat(MediaType.fromMediaType(mediaType + "; charset=UTF-8"), equalTo(expectedXContentType)); @@ -59,7 +60,7 @@ public void testFromNdJson() throws Exception { public void testFromJsonUppercase() throws Exception { String mediaType = "application/json".toUpperCase(Locale.ROOT); - XContentType expectedXContentType = XContentType.JSON; + MediaType expectedXContentType = MediaTypeRegistry.JSON; assertThat(MediaType.fromMediaType(mediaType), equalTo(expectedXContentType)); assertThat(MediaType.fromMediaType(mediaType + ";"), equalTo(expectedXContentType)); assertThat(MediaType.fromMediaType(mediaType + "; charset=UTF-8"), equalTo(expectedXContentType)); @@ -89,14 +90,14 @@ public void testFromCbor() throws Exception { public void testFromWildcard() throws Exception { String mediaType = "application/*"; - XContentType expectedXContentType = XContentType.JSON; + MediaType expectedXContentType = MediaTypeRegistry.JSON; assertThat(MediaType.fromMediaType(mediaType), equalTo(expectedXContentType)); assertThat(MediaType.fromMediaType(mediaType + ";"), equalTo(expectedXContentType)); } public void testFromWildcardUppercase() throws Exception { String mediaType = "APPLICATION/*"; - XContentType expectedXContentType = XContentType.JSON; + MediaType expectedXContentType = MediaTypeRegistry.JSON; assertThat(MediaType.fromMediaType(mediaType), equalTo(expectedXContentType)); assertThat(MediaType.fromMediaType(mediaType + ";"), equalTo(expectedXContentType)); } @@ -109,15 +110,15 @@ public void testFromRubbish() throws Exception { } public void testVersionedMediaType() throws Exception { - assertThat(MediaType.fromMediaType("application/vnd.opensearch+json;compatible-with=7"), equalTo(XContentType.JSON)); + assertThat(MediaType.fromMediaType("application/vnd.opensearch+json;compatible-with=7"), equalTo(MediaTypeRegistry.JSON)); assertThat(MediaType.fromMediaType("application/vnd.opensearch+yaml;compatible-with=7"), equalTo(XContentType.YAML)); assertThat(MediaType.fromMediaType("application/vnd.opensearch+cbor;compatible-with=7"), equalTo(XContentType.CBOR)); assertThat(MediaType.fromMediaType("application/vnd.opensearch+smile;compatible-with=7"), equalTo(XContentType.SMILE)); - assertThat(MediaType.fromMediaType("application/vnd.opensearch+json ;compatible-with=7"), equalTo(XContentType.JSON)); + assertThat(MediaType.fromMediaType("application/vnd.opensearch+json ;compatible-with=7"), equalTo(MediaTypeRegistry.JSON)); String mthv = "application/vnd.opensearch+json ;compatible-with=7;charset=utf-8"; - assertThat(MediaType.fromMediaType(mthv), equalTo(XContentType.JSON)); - assertThat(MediaType.fromMediaType(mthv.toUpperCase(Locale.ROOT)), equalTo(XContentType.JSON)); + assertThat(MediaType.fromMediaType(mthv), equalTo(MediaTypeRegistry.JSON)); + assertThat(MediaType.fromMediaType(mthv.toUpperCase(Locale.ROOT)), equalTo(MediaTypeRegistry.JSON)); } } diff --git a/server/src/test/java/org/opensearch/common/xcontent/builder/XContentBuilderTests.java b/server/src/test/java/org/opensearch/common/xcontent/builder/XContentBuilderTests.java index 9ffe9915808e3..167fddef8fa59 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/builder/XContentBuilderTests.java +++ b/server/src/test/java/org/opensearch/common/xcontent/builder/XContentBuilderTests.java @@ -67,7 +67,7 @@ public class XContentBuilderTests extends OpenSearchTestCase { public void testPrettyWithLfAtEnd() throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); - XContentGenerator generator = XContentType.JSON.xContent().createGenerator(os); + XContentGenerator generator = MediaTypeRegistry.JSON.xContent().createGenerator(os); generator.usePrettyPrint(); generator.usePrintLineFeedAtEnd(); @@ -86,7 +86,7 @@ public void testPrettyWithLfAtEnd() throws Exception { public void testReuseJsonGenerator() throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); - XContentGenerator generator = XContentType.JSON.xContent().createGenerator(os); + XContentGenerator generator = MediaTypeRegistry.JSON.xContent().createGenerator(os); generator.writeStartObject(); generator.writeStringField("test", "value"); generator.writeEndObject(); @@ -106,14 +106,14 @@ public void testReuseJsonGenerator() throws Exception { public void testRaw() throws IOException { { - XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); xContentBuilder.startObject(); xContentBuilder.rawField("foo", new BytesArray("{\"test\":\"value\"}").streamInput()); xContentBuilder.endObject(); assertThat(xContentBuilder.toString(), equalTo("{\"foo\":{\"test\":\"value\"}}")); } { - XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); xContentBuilder.startObject(); xContentBuilder.rawField("foo", new BytesArray("{\"test\":\"value\"}").streamInput()); xContentBuilder.rawField("foo1", new BytesArray("{\"test\":\"value\"}").streamInput()); @@ -121,7 +121,7 @@ public void testRaw() throws IOException { assertThat(xContentBuilder.toString(), equalTo("{\"foo\":{\"test\":\"value\"},\"foo1\":{\"test\":\"value\"}}")); } { - XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); xContentBuilder.startObject(); xContentBuilder.field("test", "value"); xContentBuilder.rawField("foo", new BytesArray("{\"test\":\"value\"}").streamInput()); @@ -129,7 +129,7 @@ public void testRaw() throws IOException { assertThat(xContentBuilder.toString(), equalTo("{\"test\":\"value\",\"foo\":{\"test\":\"value\"}}")); } { - XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); xContentBuilder.startObject(); xContentBuilder.field("test", "value"); xContentBuilder.rawField("foo", new BytesArray("{\"test\":\"value\"}").streamInput()); @@ -138,7 +138,7 @@ public void testRaw() throws IOException { assertThat(xContentBuilder.toString(), equalTo("{\"test\":\"value\",\"foo\":{\"test\":\"value\"},\"test1\":\"value1\"}")); } { - XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); xContentBuilder.startObject(); xContentBuilder.field("test", "value"); xContentBuilder.rawField("foo", new BytesArray("{\"test\":\"value\"}").streamInput()); @@ -153,17 +153,17 @@ public void testRaw() throws IOException { } public void testSimpleGenerator() throws Exception { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.startObject().field("test", "value").endObject(); assertThat(builder.toString(), equalTo("{\"test\":\"value\"}")); - builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.startObject().field("test", "value").endObject(); assertThat(builder.toString(), equalTo("{\"test\":\"value\"}")); } public void testOverloadedList() throws Exception { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.startObject().field("test", Arrays.asList("1", "2")).endObject(); assertThat(builder.toString(), equalTo("{\"test\":[\"1\",\"2\"]}")); } @@ -171,7 +171,7 @@ public void testOverloadedList() throws Exception { public void testWritingBinaryToStream() throws Exception { BytesStreamOutput bos = new BytesStreamOutput(); - XContentGenerator gen = XContentType.JSON.xContent().createGenerator(bos); + XContentGenerator gen = MediaTypeRegistry.JSON.xContent().createGenerator(bos); gen.writeStartObject(); gen.writeStringField("name", "something"); gen.flush(); @@ -185,7 +185,7 @@ public void testWritingBinaryToStream() throws Exception { } public void testByteConversion() throws Exception { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.startObject().field("test_name", (Byte) (byte) 120).endObject(); assertThat(BytesReference.bytes(builder).utf8ToString(), equalTo("{\"test_name\":120}")); } @@ -195,21 +195,21 @@ public void testDateTypesConversion() throws Exception { String expectedDate = XContentOpenSearchExtension.DEFAULT_DATE_PRINTER.print(date.getTime()); Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"), Locale.ROOT); String expectedCalendar = XContentOpenSearchExtension.DEFAULT_DATE_PRINTER.print(calendar.getTimeInMillis()); - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.startObject().timeField("date", date).endObject(); assertThat(builder.toString(), equalTo("{\"date\":\"" + expectedDate + "\"}")); - builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.startObject().field("calendar", calendar).endObject(); assertThat(builder.toString(), equalTo("{\"calendar\":\"" + expectedCalendar + "\"}")); - builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); Map map = new HashMap<>(); map.put("date", date); builder.map(map); assertThat(builder.toString(), equalTo("{\"date\":\"" + expectedDate + "\"}")); - builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); map = new HashMap<>(); map.put("calendar", calendar); builder.map(map); @@ -217,7 +217,7 @@ public void testDateTypesConversion() throws Exception { } public void testCopyCurrentStructure() throws Exception { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.startObject().field("test", "test field").startObject("filter").startObject("terms"); // up to 20k random terms @@ -284,10 +284,10 @@ public void testHandlingOfPath_absolute() throws IOException { } private void checkPathSerialization(Path path) throws IOException { - XContentBuilder pathBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder pathBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); pathBuilder.startObject().field("file", path).endObject(); - XContentBuilder stringBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder stringBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); stringBuilder.startObject().field("file", path.toString()).endObject(); assertThat(pathBuilder.toString(), equalTo(stringBuilder.toString())); @@ -297,10 +297,10 @@ public void testHandlingOfPath_StringName() throws IOException { Path path = PathUtils.get("path"); String name = new String("file"); - XContentBuilder pathBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder pathBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); pathBuilder.startObject().field(name, path).endObject(); - XContentBuilder stringBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder stringBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); stringBuilder.startObject().field(name, path.toString()).endObject(); assertThat(pathBuilder.toString(), equalTo(stringBuilder.toString())); @@ -309,17 +309,17 @@ public void testHandlingOfPath_StringName() throws IOException { public void testHandlingOfCollectionOfPaths() throws IOException { Path path = PathUtils.get("path"); - XContentBuilder pathBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder pathBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); pathBuilder.startObject().field("file", Arrays.asList(path)).endObject(); - XContentBuilder stringBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder stringBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); stringBuilder.startObject().field("file", Arrays.asList(path.toString())).endObject(); assertThat(pathBuilder.toString(), equalTo(stringBuilder.toString())); } public void testIndentIsPlatformIndependent() throws IOException { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON).prettyPrint(); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON).prettyPrint(); builder.startObject().field("test", "foo").startObject("foo").field("foobar", "boom").endObject().endObject(); String string = builder.toString(); assertEquals("{\n" + " \"test\" : \"foo\",\n" + " \"foo\" : {\n" + " \"foobar\" : \"boom\"\n" + " }\n" + "}", string); @@ -331,7 +331,7 @@ public void testIndentIsPlatformIndependent() throws IOException { } public void testRenderGeoPoint() throws IOException { - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON).prettyPrint(); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON).prettyPrint(); builder.startObject().field("foo").value(new GeoPoint(1, 2)).endObject(); String string = builder.toString(); assertEquals("{\n" + " \"foo\" : {\n" + " \"lat\" : 1.0,\n" + " \"lon\" : 2.0\n" + " }\n" + "}", string.trim()); diff --git a/server/src/test/java/org/opensearch/common/xcontent/cbor/JsonVsCborTests.java b/server/src/test/java/org/opensearch/common/xcontent/cbor/JsonVsCborTests.java index 89add6ea78722..ccf9b5804dcfa 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/cbor/JsonVsCborTests.java +++ b/server/src/test/java/org/opensearch/common/xcontent/cbor/JsonVsCborTests.java @@ -33,6 +33,7 @@ package org.opensearch.common.xcontent.cbor; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentGenerator; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -50,7 +51,7 @@ public void testCompareParsingTokens() throws IOException { XContentGenerator xsonGen = XContentType.CBOR.xContent().createGenerator(xsonOs); BytesStreamOutput jsonOs = new BytesStreamOutput(); - XContentGenerator jsonGen = XContentType.JSON.xContent().createGenerator(jsonOs); + XContentGenerator jsonGen = MediaTypeRegistry.JSON.xContent().createGenerator(jsonOs); xsonGen.writeStartObject(); jsonGen.writeStartObject(); diff --git a/server/src/test/java/org/opensearch/common/xcontent/smile/JsonVsSmileTests.java b/server/src/test/java/org/opensearch/common/xcontent/smile/JsonVsSmileTests.java index a96031f2a1dad..ed036c0e5771c 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/smile/JsonVsSmileTests.java +++ b/server/src/test/java/org/opensearch/common/xcontent/smile/JsonVsSmileTests.java @@ -33,6 +33,7 @@ package org.opensearch.common.xcontent.smile; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentGenerator; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -50,7 +51,7 @@ public void testCompareParsingTokens() throws IOException { XContentGenerator xsonGen = XContentType.SMILE.xContent().createGenerator(xsonOs); BytesStreamOutput jsonOs = new BytesStreamOutput(); - XContentGenerator jsonGen = XContentType.JSON.xContent().createGenerator(jsonOs); + XContentGenerator jsonGen = MediaTypeRegistry.JSON.xContent().createGenerator(jsonOs); xsonGen.writeStartObject(); jsonGen.writeStartObject(); diff --git a/server/src/test/java/org/opensearch/common/xcontent/support/XContentHelperTests.java b/server/src/test/java/org/opensearch/common/xcontent/support/XContentHelperTests.java index 652e11c2fd99f..eaa20e9e73b91 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/support/XContentHelperTests.java +++ b/server/src/test/java/org/opensearch/common/xcontent/support/XContentHelperTests.java @@ -35,6 +35,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentObject; @@ -211,7 +212,7 @@ public void testChildBytes() throws IOException { } public void testEmbeddedObject() throws IOException { - // Need to test this separately as XContentType.JSON never produces VALUE_EMBEDDED_OBJECT + // Need to test this separately as MediaTypeRegistry.JSON never produces VALUE_EMBEDDED_OBJECT XContentBuilder builder = XContentBuilder.builder(XContentType.CBOR.xContent()); builder.startObject().startObject("root"); CompressedXContent embedded = new CompressedXContent("{\"field\":\"value\"}"); @@ -252,7 +253,7 @@ public void testEmptyChildBytes() throws IOException { String inputJson = "{ \"mappings\" : {} }"; try ( - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, inputJson) ) { diff --git a/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java b/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java index 5b3ba777449eb..72f0101925ff5 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java +++ b/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java @@ -55,7 +55,7 @@ import static java.util.Collections.emptySet; import static java.util.Collections.singleton; import static org.opensearch.common.xcontent.XContentHelper.convertToMap; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.hasSize; diff --git a/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestRequestTests.java b/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestRequestTests.java index e12549b93ab53..2f8cec957e42e 100644 --- a/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestRequestTests.java +++ b/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestRequestTests.java @@ -15,9 +15,10 @@ import org.opensearch.core.common.io.stream.BytesStreamInput; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.io.stream.NamedWriteableAwareStreamInput; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestRequest.Method; @@ -39,7 +40,7 @@ public class ExtensionRestRequestTests extends OpenSearchTestCase { private String expectedUri; Map expectedParams; Map> expectedHeaders; - XContentType expectedContentType; + MediaType expectedContentType; BytesReference expectedContent; String extensionUniqueId1; Principal userPrincipal; @@ -59,7 +60,7 @@ public void setUp() throws Exception { entry("Content-Type", Arrays.asList("application/json")), entry("foo", Arrays.asList("hello", "world")) ); - expectedContentType = XContentType.JSON; + expectedContentType = MediaTypeRegistry.JSON; expectedContent = new BytesArray("{\"key\": \"value\"}".getBytes(StandardCharsets.UTF_8)); extensionUniqueId1 = "ext_1"; userPrincipal = () -> "user1"; diff --git a/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestResponseTests.java b/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestResponseTests.java index e76e6b98811f7..0be23e22fdaff 100644 --- a/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestResponseTests.java +++ b/server/src/test/java/org/opensearch/extensions/rest/ExtensionRestResponseTests.java @@ -16,10 +16,10 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.http.HttpRequest; import org.opensearch.http.HttpResponse; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.rest.RestRequest; import org.opensearch.core.rest.RestStatus; import org.opensearch.rest.RestRequest.Method; @@ -110,7 +110,7 @@ public HttpRequest releaseAndCopy() { } public void testConstructorWithBuilder() throws IOException { - XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder(); builder.startObject(); builder.field("status", ACCEPTED); builder.endObject(); diff --git a/server/src/test/java/org/opensearch/extensions/rest/RestInitializeExtensionActionTests.java b/server/src/test/java/org/opensearch/extensions/rest/RestInitializeExtensionActionTests.java index 1faa3bd9aec55..dbb1f45f55d9a 100644 --- a/server/src/test/java/org/opensearch/extensions/rest/RestInitializeExtensionActionTests.java +++ b/server/src/test/java/org/opensearch/extensions/rest/RestInitializeExtensionActionTests.java @@ -31,7 +31,7 @@ import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.PageCacheRecycler; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.extensions.ExtensionsManager; import org.opensearch.extensions.ExtensionsSettings; import org.opensearch.core.indices.breaker.NoneCircuitBreakerService; @@ -103,7 +103,7 @@ public void testRestInitializeExtensionActionResponse() throws Exception { + "\"minimumCompatibleVersion\":\"" + Version.CURRENT.minimumCompatibilityVersion().toString() + "\"}"; - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(content), XContentType.JSON) + RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(content), MediaTypeRegistry.JSON) .withMethod(RestRequest.Method.POST) .build(); @@ -125,7 +125,7 @@ public void testRestInitializeExtensionActionFailure() throws Exception { + "\"minimumCompatibleVersion\":\"" + Version.CURRENT.minimumCompatibilityVersion().toString() + "\"}"; - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(content), XContentType.JSON) + RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(content), MediaTypeRegistry.JSON) .withMethod(RestRequest.Method.POST) .build(); @@ -163,7 +163,7 @@ public void testRestInitializeExtensionActionResponseWithAdditionalSettings() th + "\"minimumCompatibleVersion\":\"" + Version.CURRENT.minimumCompatibilityVersion().toString() + "\",\"boolSetting\":true,\"stringSetting\":\"customSetting\",\"intSetting\":5,\"listSetting\":[\"one\",\"two\",\"three\"]}"; - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(content), XContentType.JSON) + RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(content), MediaTypeRegistry.JSON) .withMethod(RestRequest.Method.POST) .build(); @@ -210,7 +210,7 @@ public void testRestInitializeExtensionActionResponseWithAdditionalSettingsUsing + "\"minimumCompatibleVersion\":\"" + Version.CURRENT.minimumCompatibilityVersion().toString() + "\"}"; - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(content), XContentType.JSON) + RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent(new BytesArray(content), MediaTypeRegistry.JSON) .withMethod(RestRequest.Method.POST) .build(); diff --git a/server/src/test/java/org/opensearch/index/IndexServiceTests.java b/server/src/test/java/org/opensearch/index/IndexServiceTests.java index ac572c4fa8440..f36cce90f1a7a 100644 --- a/server/src/test/java/org/opensearch/index/IndexServiceTests.java +++ b/server/src/test/java/org/opensearch/index/IndexServiceTests.java @@ -40,10 +40,10 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.core.index.Index; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.engine.Engine; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.shard.IndexShard; @@ -300,7 +300,7 @@ public void testRefreshActuallyWorks() throws Exception { assertEquals(1000, refreshTask.getInterval().millis()); assertTrue(indexService.getRefreshTask().mustReschedule()); IndexShard shard = indexService.getShard(0); - client().prepareIndex("test").setId("0").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("0").setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON).get(); // now disable the refresh client().admin() .indices() @@ -321,7 +321,7 @@ public void testRefreshActuallyWorks() throws Exception { }); assertFalse(refreshTask.isClosed()); // refresh every millisecond - client().prepareIndex("test").setId("1").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON).get(); client().admin() .indices() .prepareUpdateSettings("test") @@ -335,7 +335,7 @@ public void testRefreshActuallyWorks() throws Exception { assertEquals(2, search.totalHits.value); } }); - client().prepareIndex("test").setId("2").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("2").setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON).get(); assertBusy(() -> { // this one becomes visible due to the scheduled refresh try (Engine.Searcher searcher = shard.acquireSearcher("test")) { @@ -353,7 +353,7 @@ public void testAsyncFsyncActuallyWorks() throws Exception { IndexService indexService = createIndex("test", settings); ensureGreen("test"); assertTrue(indexService.getRefreshTask().mustReschedule()); - client().prepareIndex("test").setId("1").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON).get(); IndexShard shard = indexService.getShard(0); assertBusy(() -> assertFalse(shard.isSyncNeeded())); } @@ -375,7 +375,7 @@ public void testRescheduleAsyncFsync() throws Exception { assertNotNull(indexService.getFsyncTask()); assertTrue(indexService.getFsyncTask().mustReschedule()); - client().prepareIndex("test").setId("1").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON).get(); assertNotNull(indexService.getFsyncTask()); final IndexShard shard = indexService.getShard(0); assertBusy(() -> assertFalse(shard.isSyncNeeded())); @@ -402,7 +402,7 @@ public void testAsyncTranslogTrimActuallyWorks() throws Exception { IndexService indexService = createIndex("test", settings); ensureGreen("test"); assertTrue(indexService.getTrimTranslogTask().mustReschedule()); - client().prepareIndex("test").setId("1").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get(); + client().prepareIndex("test").setId("1").setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON).get(); client().admin().indices().prepareFlush("test").get(); client().admin() .indices() @@ -429,7 +429,11 @@ public void testAsyncTranslogTrimTaskOnClosedIndex() throws Exception { int translogOps = 0; final int numDocs = scaledRandomIntBetween(10, 100); for (int i = 0; i < numDocs; i++) { - client().prepareIndex().setIndex(indexName).setId(String.valueOf(i)).setSource("{\"foo\": \"bar\"}", XContentType.JSON).get(); + client().prepareIndex() + .setIndex(indexName) + .setId(String.valueOf(i)) + .setSource("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON) + .get(); translogOps++; if (randomBoolean()) { client().admin().indices().prepareFlush(indexName).get(); diff --git a/server/src/test/java/org/opensearch/index/IndexingSlowLogTests.java b/server/src/test/java/org/opensearch/index/IndexingSlowLogTests.java index 6823bb5a8225f..6d8f7f9b5a3a1 100644 --- a/server/src/test/java/org/opensearch/index/IndexingSlowLogTests.java +++ b/server/src/test/java/org/opensearch/index/IndexingSlowLogTests.java @@ -47,9 +47,9 @@ import org.opensearch.common.logging.MockAppender; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.index.Index; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexingSlowLog.IndexingSlowLogMessage; import org.opensearch.index.engine.Engine; import org.opensearch.index.engine.InternalEngineTests; @@ -227,7 +227,7 @@ public void testSlowLogMessageHasJsonFields() throws IOException { "routingValue", null, source, - XContentType.JSON, + MediaTypeRegistry.JSON, null ); Index index = new Index("foo", "123"); @@ -255,7 +255,7 @@ public void testSlowLogParsedDocumentPrinterSourceToLog() throws IOException { null, null, source, - XContentType.JSON, + MediaTypeRegistry.JSON, null ); Index index = new Index("foo", "123"); @@ -285,7 +285,7 @@ public void testSlowLogParsedDocumentPrinterSourceToLog() throws IOException { null, null, source, - XContentType.JSON, + MediaTypeRegistry.JSON, null ); diff --git a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java index d58d166415446..e2dc545388412 100644 --- a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java @@ -117,9 +117,9 @@ import org.opensearch.common.util.concurrent.AbstractRunnable; import org.opensearch.common.util.concurrent.ConcurrentCollections; import org.opensearch.common.util.concurrent.ReleasableLock; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.VersionType; import org.opensearch.index.codec.CodecService; @@ -5712,7 +5712,7 @@ public void testSeqNoGenerator() throws IOException { "routing", Collections.singletonList(document), source, - XContentType.JSON, + MediaTypeRegistry.JSON, null ); diff --git a/server/src/test/java/org/opensearch/index/fielddata/BinaryDVFieldDataTests.java b/server/src/test/java/org/opensearch/index/fielddata/BinaryDVFieldDataTests.java index 06bdd2f80d762..0470840bcff5d 100644 --- a/server/src/test/java/org/opensearch/index/fielddata/BinaryDVFieldDataTests.java +++ b/server/src/test/java/org/opensearch/index/fielddata/BinaryDVFieldDataTests.java @@ -36,9 +36,9 @@ import org.apache.lucene.util.BytesRef; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.DocumentMapper; import org.opensearch.index.mapper.ParsedDocument; import org.opensearch.index.mapper.SourceToParse; @@ -79,16 +79,16 @@ public void testDocValue() throws Exception { doc.endArray(); } doc.endObject(); - ParsedDocument d = mapper.parse(new SourceToParse("test", "1", BytesReference.bytes(doc), XContentType.JSON)); + ParsedDocument d = mapper.parse(new SourceToParse("test", "1", BytesReference.bytes(doc), MediaTypeRegistry.JSON)); writer.addDocument(d.rootDoc()); BytesRef bytes1 = randomBytes(); doc = XContentFactory.jsonBuilder().startObject().field("field", bytes1.bytes, bytes1.offset, bytes1.length).endObject(); - d = mapper.parse(new SourceToParse("test", "2", BytesReference.bytes(doc), XContentType.JSON)); + d = mapper.parse(new SourceToParse("test", "2", BytesReference.bytes(doc), MediaTypeRegistry.JSON)); writer.addDocument(d.rootDoc()); doc = XContentFactory.jsonBuilder().startObject().endObject(); - d = mapper.parse(new SourceToParse("test", "3", BytesReference.bytes(doc), XContentType.JSON)); + d = mapper.parse(new SourceToParse("test", "3", BytesReference.bytes(doc), MediaTypeRegistry.JSON)); writer.addDocument(d.rootDoc()); // test remove duplicate value @@ -104,7 +104,7 @@ public void testDocValue() throws Exception { doc.endArray(); } doc.endObject(); - d = mapper.parse(new SourceToParse("test", "4", BytesReference.bytes(doc), XContentType.JSON)); + d = mapper.parse(new SourceToParse("test", "4", BytesReference.bytes(doc), MediaTypeRegistry.JSON)); writer.addDocument(d.rootDoc()); IndexFieldData indexFieldData = getForField("field"); diff --git a/server/src/test/java/org/opensearch/index/get/DocumentFieldTests.java b/server/src/test/java/org/opensearch/index/get/DocumentFieldTests.java index 46f315141ef30..1c898fd07f0b8 100644 --- a/server/src/test/java/org/opensearch/index/get/DocumentFieldTests.java +++ b/server/src/test/java/org/opensearch/index/get/DocumentFieldTests.java @@ -36,6 +36,8 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.document.DocumentField; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -52,7 +54,7 @@ import java.util.function.Predicate; import java.util.function.Supplier; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; @@ -60,13 +62,13 @@ public class DocumentFieldTests extends OpenSearchTestCase { public void testToXContent() { DocumentField documentField = new DocumentField("field", Arrays.asList("value1", "value2")); - String output = Strings.toString(XContentType.JSON, documentField); + String output = Strings.toString(MediaTypeRegistry.JSON, documentField); assertEquals("{\"field\":[\"value1\",\"value2\"]}", output); } public void testEqualsAndHashcode() { checkEqualsAndHashCode( - randomDocumentField(XContentType.JSON).v1(), + randomDocumentField(MediaTypeRegistry.JSON).v1(), DocumentFieldTests::copyDocumentField, DocumentFieldTests::mutateDocumentField ); @@ -102,7 +104,7 @@ private static DocumentField copyDocumentField(DocumentField documentField) { private static DocumentField mutateDocumentField(DocumentField documentField) { List> mutations = new ArrayList<>(); mutations.add(() -> new DocumentField(randomUnicodeOfCodepointLength(15), documentField.getValues())); - mutations.add(() -> new DocumentField(documentField.getName(), randomDocumentField(XContentType.JSON).v1().getValues())); + mutations.add(() -> new DocumentField(documentField.getName(), randomDocumentField(MediaTypeRegistry.JSON).v1().getValues())); final int index = randomFrom(0, 1); final DocumentField randomCandidate = mutations.get(index).get(); if (!documentField.equals(randomCandidate)) { @@ -115,12 +117,12 @@ private static DocumentField mutateDocumentField(DocumentField documentField) { } } - public static Tuple randomDocumentField(XContentType xContentType) { - return randomDocumentField(xContentType, randomBoolean(), fieldName -> false); // don't exclude any meta-fields + public static Tuple randomDocumentField(MediaType mediaType) { + return randomDocumentField(mediaType, randomBoolean(), fieldName -> false); // don't exclude any meta-fields } public static Tuple randomDocumentField( - XContentType xContentType, + MediaType mediaType, boolean isMetafield, Predicate excludeMetaFieldFilter ) { @@ -143,7 +145,7 @@ public static Tuple randomDocumentField( switch (randomIntBetween(0, 2)) { case 0: String fieldName = randomAlphaOfLengthBetween(3, 10); - Tuple, List> tuple = RandomObjects.randomStoredFieldValues(random(), xContentType); + Tuple, List> tuple = RandomObjects.randomStoredFieldValues(random(), mediaType); DocumentField input = new DocumentField(fieldName, tuple.v1()); DocumentField expected = new DocumentField(fieldName, tuple.v2()); return Tuple.tuple(input, expected); diff --git a/server/src/test/java/org/opensearch/index/get/GetResultTests.java b/server/src/test/java/org/opensearch/index/get/GetResultTests.java index fc07f238e0633..7aa50452845d7 100644 --- a/server/src/test/java/org/opensearch/index/get/GetResultTests.java +++ b/server/src/test/java/org/opensearch/index/get/GetResultTests.java @@ -38,8 +38,9 @@ import org.opensearch.common.collect.Tuple; import org.opensearch.common.document.DocumentField; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; -import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.IdFieldMapper; @@ -61,7 +62,7 @@ import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; import static org.opensearch.index.get.DocumentFieldTests.randomDocumentField; import static org.opensearch.index.seqno.SequenceNumbers.UNASSIGNED_PRIMARY_TERM; @@ -105,7 +106,7 @@ public void testToXContent() throws IOException { singletonMap("field1", new DocumentField("field1", singletonList("value1"))), singletonMap("field1", new DocumentField("metafield", singletonList("metavalue"))) ); - String output = Strings.toString(XContentType.JSON, getResult); + String output = Strings.toString(MediaTypeRegistry.JSON, getResult); assertEquals( "{\"_index\":\"index\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + "\"metafield\":\"metavalue\",\"found\":true,\"_source\":{ \"field1\" : \"value1\", \"field2\":\"value2\"}," @@ -115,7 +116,7 @@ public void testToXContent() throws IOException { } { GetResult getResult = new GetResult("index", "id", UNASSIGNED_SEQ_NO, 0, 1, false, null, null, null); - String output = Strings.toString(XContentType.JSON, getResult); + String output = Strings.toString(MediaTypeRegistry.JSON, getResult); assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"found\":false}", output); } } @@ -173,7 +174,7 @@ public void testToXContentEmbedded() throws IOException { null ); - BytesReference originalBytes = toXContentEmbedded(getResult, XContentType.JSON, false); + BytesReference originalBytes = toXContentEmbedded(getResult, MediaTypeRegistry.JSON, false); assertEquals( "{\"_seq_no\":0,\"_primary_term\":1,\"found\":true,\"_source\":{\"foo\":\"bar\",\"baz\":[\"baz_0\",\"baz_1\"]}," + "\"fields\":{\"foo\":[\"bar\"],\"baz\":[\"baz_0\",\"baz_1\"]}}", @@ -184,7 +185,7 @@ public void testToXContentEmbedded() throws IOException { public void testToXContentEmbeddedNotFound() throws IOException { GetResult getResult = new GetResult("index", "id", UNASSIGNED_SEQ_NO, 0, 1, false, null, null, null); - BytesReference originalBytes = toXContentEmbedded(getResult, XContentType.JSON, false); + BytesReference originalBytes = toXContentEmbedded(getResult, MediaTypeRegistry.JSON, false); assertEquals("{\"found\":false}", originalBytes.utf8ToString()); } @@ -196,7 +197,7 @@ public void testSerializationNotFound() throws IOException { getResult.writeTo(out); getResult = new GetResult(out.bytes().streamInput()); - BytesReference originalBytes = toXContentEmbedded(getResult, XContentType.JSON, false); + BytesReference originalBytes = toXContentEmbedded(getResult, MediaTypeRegistry.JSON, false); assertEquals("{\"found\":false}", originalBytes.utf8ToString()); } @@ -212,7 +213,11 @@ public void testGetSourceAsBytes() { } public void testEqualsAndHashcode() { - checkEqualsAndHashCode(randomGetResult(XContentType.JSON).v1(), GetResultTests::copyGetResult, GetResultTests::mutateGetResult); + checkEqualsAndHashCode( + randomGetResult(MediaTypeRegistry.JSON).v1(), + GetResultTests::copyGetResult, + GetResultTests::mutateGetResult + ); } public static GetResult copyGetResult(GetResult getResult) { @@ -305,14 +310,14 @@ public static GetResult mutateGetResult(GetResult getResult) { getResult.getVersion(), getResult.isExists(), getResult.internalSourceRef(), - randomDocumentFields(XContentType.JSON, randomBoolean()).v1(), + randomDocumentFields(MediaTypeRegistry.JSON, randomBoolean()).v1(), null ) ); return randomFrom(mutations).get(); } - public static Tuple randomGetResult(XContentType xContentType) { + public static Tuple randomGetResult(MediaType mediaType) { final String index = randomAlphaOfLengthBetween(3, 10); final String type = randomAlphaOfLengthBetween(3, 10); final String id = randomAlphaOfLengthBetween(3, 10); @@ -334,11 +339,11 @@ public static Tuple randomGetResult(XContentType xContentT source = RandomObjects.randomSource(random()); } if (randomBoolean()) { - Tuple, Map> tuple = randomDocumentFields(xContentType, false); + Tuple, Map> tuple = randomDocumentFields(mediaType, false); docFields = tuple.v1(); expectedDocFields = tuple.v2(); - tuple = randomDocumentFields(xContentType, true); + tuple = randomDocumentFields(mediaType, true); metaFields = tuple.v1(); expectedMetaFields = tuple.v2(); } @@ -364,7 +369,7 @@ public static Tuple randomGetResult(XContentType xContentT } public static Tuple, Map> randomDocumentFields( - XContentType xContentType, + MediaType mediaType, boolean isMetaFields ) { int numFields = isMetaFields ? randomIntBetween(1, 3) : randomIntBetween(2, 10); @@ -378,7 +383,7 @@ public static Tuple, Map> rand || field.equals(SourceFieldMapper.NAME) || field.equals(SeqNoFieldMapper.NAME); while (fields.size() < numFields) { - Tuple tuple = randomDocumentField(xContentType, isMetaFields, excludeMetaFieldFilter); + Tuple tuple = randomDocumentField(mediaType, isMetaFields, excludeMetaFieldFilter); DocumentField getField = tuple.v1(); DocumentField expectedGetField = tuple.v2(); if (fields.putIfAbsent(getField.getName(), getField) == null) { @@ -388,8 +393,7 @@ public static Tuple, Map> rand return Tuple.tuple(fields, expectedFields); } - private static BytesReference toXContentEmbedded(GetResult getResult, XContentType xContentType, boolean humanReadable) - throws IOException { - return XContentHelper.toXContent(getResult::toXContentEmbedded, xContentType, humanReadable); + private static BytesReference toXContentEmbedded(GetResult getResult, MediaType mediaType, boolean humanReadable) throws IOException { + return org.opensearch.core.xcontent.XContentHelper.toXContent(getResult::toXContentEmbedded, mediaType, humanReadable); } } diff --git a/server/src/test/java/org/opensearch/index/mapper/CompletionFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/CompletionFieldMapperTests.java index 7b7db2ced0ab2..32b9f6ab13a4e 100644 --- a/server/src/test/java/org/opensearch/index/mapper/CompletionFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/CompletionFieldMapperTests.java @@ -49,8 +49,8 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.unit.Fuzziness; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.IndexSettings; @@ -187,7 +187,7 @@ public void testCompletionAnalyzerSettings() throws Exception { assertEquals( "{\"field\":{\"type\":\"completion\",\"analyzer\":\"simple\",\"search_analyzer\":\"standard\"," + "\"preserve_separators\":false,\"preserve_position_increments\":true,\"max_input_length\":50}}", - Strings.toString(XContentType.JSON, fieldMapper) + Strings.toString(MediaTypeRegistry.JSON, fieldMapper) ); } diff --git a/server/src/test/java/org/opensearch/index/mapper/DataStreamFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/DataStreamFieldMapperTests.java index 0c8dd94dc0a07..285a1a472565f 100644 --- a/server/src/test/java/org/opensearch/index/mapper/DataStreamFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/DataStreamFieldMapperTests.java @@ -11,7 +11,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchSingleNodeTestCase; import static org.hamcrest.Matchers.containsString; @@ -83,7 +83,7 @@ public void testDeeplyNestedCustomTimestampField() throws Exception { .endObject() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); assertThat(doc.rootDoc().getFields("event.meta.created_at").length, equalTo(2)); @@ -103,7 +103,7 @@ public void testDeeplyNestedCustomTimestampField() throws Exception { .endObject() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); }); @@ -125,7 +125,7 @@ private void assertDataStreamFieldMapper(String mapping, String timestampFieldNa BytesReference.bytes( XContentFactory.jsonBuilder().startObject().field(timestampFieldName, "2020-12-06T11:04:05.000Z").endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -143,7 +143,7 @@ private void assertDataStreamFieldMapper(String mapping, String timestampFieldNa BytesReference.bytes( XContentFactory.jsonBuilder().startObject().field("invalid-field-name", "2020-12-06T11:04:05.000Z").endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); }); @@ -164,7 +164,7 @@ private void assertDataStreamFieldMapper(String mapping, String timestampFieldNa .array(timestampFieldName, "2020-12-06T11:04:05.000Z", "2020-12-07T11:04:05.000Z") .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); }); diff --git a/server/src/test/java/org/opensearch/index/mapper/DocumentParserTests.java b/server/src/test/java/org/opensearch/index/mapper/DocumentParserTests.java index 0d800cf34501c..59a521668b4ea 100644 --- a/server/src/test/java/org/opensearch/index/mapper/DocumentParserTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/DocumentParserTests.java @@ -40,7 +40,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.mapper.ParseContext.Document; import org.opensearch.plugins.Plugin; @@ -1062,7 +1062,7 @@ public void testParseToJsonAndParse() throws Exception { // reparse it DocumentMapper builtDocMapper = createDocumentMapper(MapperService.SINGLE_MAPPING_NAME, builtMapping); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/opensearch/index/mapper/simple/test1.json")); - Document doc = builtDocMapper.parse(new SourceToParse("test", "1", json, XContentType.JSON)).rootDoc(); + Document doc = builtDocMapper.parse(new SourceToParse("test", "1", json, MediaTypeRegistry.JSON)).rootDoc(); assertThat(doc.getBinaryValue(builtDocMapper.idFieldMapper().name()), equalTo(Uid.encodeId("1"))); assertThat(doc.get(builtDocMapper.mappers().getMapper("name.first").name()), equalTo("fred")); } @@ -1074,7 +1074,7 @@ public void testSimpleParser() throws Exception { assertThat((String) docMapper.meta().get("param1"), equalTo("value1")); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/opensearch/index/mapper/simple/test1.json")); - Document doc = docMapper.parse(new SourceToParse("test", "1", json, XContentType.JSON)).rootDoc(); + Document doc = docMapper.parse(new SourceToParse("test", "1", json, MediaTypeRegistry.JSON)).rootDoc(); assertThat(doc.getBinaryValue(docMapper.idFieldMapper().name()), equalTo(Uid.encodeId("1"))); assertThat(doc.get(docMapper.mappers().getMapper("name.first").name()), equalTo("fred")); } @@ -1083,7 +1083,7 @@ public void testSimpleParserNoTypeNoId() throws Exception { String mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/simple/test-mapping.json"); DocumentMapper docMapper = createDocumentMapper(MapperService.SINGLE_MAPPING_NAME, mapping); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/opensearch/index/mapper/simple/test1-notype-noid.json")); - Document doc = docMapper.parse(new SourceToParse("test", "1", json, XContentType.JSON)).rootDoc(); + Document doc = docMapper.parse(new SourceToParse("test", "1", json, MediaTypeRegistry.JSON)).rootDoc(); assertThat(doc.getBinaryValue(docMapper.idFieldMapper().name()), equalTo(Uid.encodeId("1"))); assertThat(doc.get(docMapper.mappers().getMapper("name.first").name()), equalTo("fred")); } @@ -1105,7 +1105,7 @@ public void testNoDocumentSent() throws Exception { BytesReference json = new BytesArray("".getBytes(StandardCharsets.UTF_8)); MapperParsingException e = expectThrows( MapperParsingException.class, - () -> docMapper.parse(new SourceToParse("test", "1", json, XContentType.JSON)) + () -> docMapper.parse(new SourceToParse("test", "1", json, MediaTypeRegistry.JSON)) ); assertThat(e.getMessage(), equalTo("failed to parse, document is empty")); } diff --git a/server/src/test/java/org/opensearch/index/mapper/DynamicMappingTests.java b/server/src/test/java/org/opensearch/index/mapper/DynamicMappingTests.java index fa70e29836779..5cc3a875c81f0 100644 --- a/server/src/test/java/org/opensearch/index/mapper/DynamicMappingTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/DynamicMappingTests.java @@ -34,7 +34,7 @@ import org.opensearch.common.CheckedConsumer; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; @@ -184,7 +184,7 @@ public void testField() throws Exception { assertEquals( "{\"_doc\":{\"properties\":{\"foo\":{\"type\":\"text\",\"fields\":" + "{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}}}}}", - Strings.toString(XContentType.JSON, doc.dynamicMappingsUpdate()) + Strings.toString(MediaTypeRegistry.JSON, doc.dynamicMappingsUpdate()) ); } @@ -200,9 +200,9 @@ public void testIncremental() throws Exception { })); assertNotNull(doc.dynamicMappingsUpdate()); - assertThat(Strings.toString(XContentType.JSON, doc.dynamicMappingsUpdate()), containsString("{\"bar\":")); + assertThat(Strings.toString(MediaTypeRegistry.JSON, doc.dynamicMappingsUpdate()), containsString("{\"bar\":")); // field is NOT in the update - assertThat(Strings.toString(XContentType.JSON, doc.dynamicMappingsUpdate()), not(containsString("{\"field\":"))); + assertThat(Strings.toString(MediaTypeRegistry.JSON, doc.dynamicMappingsUpdate()), not(containsString("{\"field\":"))); } public void testIntroduceTwoFields() throws Exception { @@ -214,8 +214,8 @@ public void testIntroduceTwoFields() throws Exception { })); assertNotNull(doc.dynamicMappingsUpdate()); - assertThat(Strings.toString(XContentType.JSON, doc.dynamicMappingsUpdate()), containsString("\"foo\":{")); - assertThat(Strings.toString(XContentType.JSON, doc.dynamicMappingsUpdate()), containsString("\"bar\":{")); + assertThat(Strings.toString(MediaTypeRegistry.JSON, doc.dynamicMappingsUpdate()), containsString("\"foo\":{")); + assertThat(Strings.toString(MediaTypeRegistry.JSON, doc.dynamicMappingsUpdate()), containsString("\"bar\":{")); } public void testObject() throws Exception { @@ -230,7 +230,7 @@ public void testObject() throws Exception { assertNotNull(doc.dynamicMappingsUpdate()); assertThat( - Strings.toString(XContentType.JSON, doc.dynamicMappingsUpdate()), + Strings.toString(MediaTypeRegistry.JSON, doc.dynamicMappingsUpdate()), containsString("{\"foo\":{\"properties\":{\"bar\":{\"properties\":{\"baz\":{\"type\":\"text\"") ); } @@ -241,7 +241,7 @@ public void testArray() throws Exception { ParsedDocument doc = mapper.parse(source(b -> b.startArray("foo").value("bar").value("baz").endArray())); assertNotNull(doc.dynamicMappingsUpdate()); - assertThat(Strings.toString(XContentType.JSON, doc.dynamicMappingsUpdate()), containsString("{\"foo\":{\"type\":\"text\"")); + assertThat(Strings.toString(MediaTypeRegistry.JSON, doc.dynamicMappingsUpdate()), containsString("{\"foo\":{\"type\":\"text\"")); } public void testInnerDynamicMapping() throws Exception { @@ -257,7 +257,7 @@ public void testInnerDynamicMapping() throws Exception { assertNotNull(doc.dynamicMappingsUpdate()); assertThat( - Strings.toString(XContentType.JSON, doc.dynamicMappingsUpdate()), + Strings.toString(MediaTypeRegistry.JSON, doc.dynamicMappingsUpdate()), containsString("{\"field\":{\"properties\":{\"bar\":{\"properties\":{\"baz\":{\"type\":\"text\"") ); } @@ -277,7 +277,7 @@ public void testComplexArray() throws Exception { assertEquals( "{\"_doc\":{\"properties\":{\"foo\":{\"properties\":{\"bar\":{\"type\":\"text\",\"fields\":{" + "\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}},\"baz\":{\"type\":\"long\"}}}}}}", - Strings.toString(XContentType.JSON, doc.dynamicMappingsUpdate()) + Strings.toString(MediaTypeRegistry.JSON, doc.dynamicMappingsUpdate()) ); } diff --git a/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java b/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java index 2c825401ab94a..be5fc84a2bfc7 100644 --- a/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java @@ -40,7 +40,7 @@ import org.opensearch.action.fieldcaps.FieldCapabilitiesRequest; import org.opensearch.action.fieldcaps.FieldCapabilitiesResponse; import org.opensearch.cluster.metadata.MappingMetadata; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.indices.IndicesModule; import org.opensearch.plugins.MapperPlugin; import org.opensearch.plugins.Plugin; @@ -73,7 +73,7 @@ protected Collection> getPlugins() { public void putMappings() { assertAcked(client().admin().indices().prepareCreate("index1")); assertAcked(client().admin().indices().prepareCreate("filtered")); - assertAcked(client().admin().indices().preparePutMapping("index1", "filtered").setSource(TEST_ITEM, XContentType.JSON)); + assertAcked(client().admin().indices().preparePutMapping("index1", "filtered").setSource(TEST_ITEM, MediaTypeRegistry.JSON)); } public void testGetMappings() { diff --git a/server/src/test/java/org/opensearch/index/mapper/FieldNamesFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/FieldNamesFieldMapperTests.java index 829a7aa9cf6db..1049cb3b9fb51 100644 --- a/server/src/test/java/org/opensearch/index/mapper/FieldNamesFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/FieldNamesFieldMapperTests.java @@ -37,7 +37,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchSingleNodeTestCase; import java.util.ArrayList; @@ -118,7 +118,7 @@ public void testInjectIntoDocDuringParsing() throws Exception { BytesReference.bytes( XContentFactory.jsonBuilder().startObject().field("a", "100").startObject("b").field("c", 42).endObject().endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -152,7 +152,7 @@ public void testExplicitEnabled() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -181,7 +181,7 @@ public void testDisabled() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); diff --git a/server/src/test/java/org/opensearch/index/mapper/FlatObjectFieldDataTests.java b/server/src/test/java/org/opensearch/index/mapper/FlatObjectFieldDataTests.java index e7c446750d15d..76c30387ea3a2 100644 --- a/server/src/test/java/org/opensearch/index/mapper/FlatObjectFieldDataTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/FlatObjectFieldDataTests.java @@ -11,7 +11,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.fielddata.AbstractFieldDataTestCase; import org.opensearch.index.fielddata.IndexFieldData; @@ -41,7 +41,7 @@ public void testDocValue() throws Exception { final DocumentMapper mapper = mapperService.documentMapperParser().parse("test", new CompressedXContent(mapping)); XContentBuilder json = XContentFactory.jsonBuilder().startObject().startObject("field").field("foo", "bar").endObject().endObject(); - ParsedDocument d = mapper.parse(new SourceToParse("test", "1", BytesReference.bytes(json), XContentType.JSON)); + ParsedDocument d = mapper.parse(new SourceToParse("test", "1", BytesReference.bytes(json), MediaTypeRegistry.JSON)); writer.addDocument(d.rootDoc()); writer.commit(); diff --git a/server/src/test/java/org/opensearch/index/mapper/GenericStoreDynamicTemplateTests.java b/server/src/test/java/org/opensearch/index/mapper/GenericStoreDynamicTemplateTests.java index 1834b087e3bdd..6d816c6aab69c 100644 --- a/server/src/test/java/org/opensearch/index/mapper/GenericStoreDynamicTemplateTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/GenericStoreDynamicTemplateTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.index.IndexableField; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.ParseContext.Document; import org.opensearch.test.OpenSearchSingleNodeTestCase; @@ -47,17 +47,17 @@ public class GenericStoreDynamicTemplateTests extends OpenSearchSingleNodeTestCa public void testSimple() throws Exception { String mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/dynamictemplate/genericstore/test-mapping.json"); IndexService index = createIndex("test"); - client().admin().indices().preparePutMapping("test").setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping("test").setSource(mapping, MediaTypeRegistry.JSON).get(); MapperService mapperService = index.mapperService(); byte[] json = copyToBytesFromClasspath("/org/opensearch/index/mapper/dynamictemplate/genericstore/test-data.json"); ParsedDocument parsedDoc = mapperService.documentMapper() - .parse(new SourceToParse("test", "1", new BytesArray(json), XContentType.JSON)); + .parse(new SourceToParse("test", "1", new BytesArray(json), MediaTypeRegistry.JSON)); client().admin() .indices() .preparePutMapping("test") - .setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON) + .setSource(parsedDoc.dynamicMappingsUpdate().toString(), MediaTypeRegistry.JSON) .get(); Document doc = parsedDoc.rootDoc(); diff --git a/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldMapperTests.java index dc5e724f68094..016862e3ffabc 100644 --- a/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldMapperTests.java @@ -33,8 +33,8 @@ import org.opensearch.common.Explicit; import org.opensearch.common.geo.builders.ShapeBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.plugins.Plugin; @@ -229,7 +229,7 @@ public void testSerializeDefaults() throws Exception { DocumentMapper mapper = createDocumentMapper(fieldMapping(this::minimalMapping)); assertThat( Strings.toString( - XContentType.JSON, + MediaTypeRegistry.JSON, mapper.mappers().getMapper("field"), new ToXContent.MapParams(Collections.singletonMap("include_defaults", "true")) ), diff --git a/server/src/test/java/org/opensearch/index/mapper/IdFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/IdFieldMapperTests.java index 5188fb8ae2b6b..d9a8e213ea5cb 100644 --- a/server/src/test/java/org/opensearch/index/mapper/IdFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/IdFieldMapperTests.java @@ -39,7 +39,7 @@ import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.MapperService.MergeReason; import org.opensearch.indices.IndicesService; @@ -73,7 +73,7 @@ public void testIncludeInObjectNotAllowed() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("_id", "1").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); fail("Expected failure to parse metadata field"); @@ -89,7 +89,7 @@ public void testDefaults() throws IOException { Settings indexSettings = Settings.EMPTY; MapperService mapperService = createIndex("test", indexSettings).mapperService(); DocumentMapper mapper = mapperService.merge("type", new CompressedXContent("{\"type\":{}}"), MergeReason.MAPPING_UPDATE); - ParsedDocument document = mapper.parse(new SourceToParse("index", "id", new BytesArray("{}"), XContentType.JSON)); + ParsedDocument document = mapper.parse(new SourceToParse("index", "id", new BytesArray("{}"), MediaTypeRegistry.JSON)); IndexableField[] fields = document.rootDoc().getFields(IdFieldMapper.NAME); assertEquals(1, fields.length); assertEquals(IndexOptions.DOCS, fields[0].fieldType().indexOptions()); diff --git a/server/src/test/java/org/opensearch/index/mapper/IndexFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/IndexFieldMapperTests.java index e6f84bea08a96..ee0197ca3f6e9 100644 --- a/server/src/test/java/org/opensearch/index/mapper/IndexFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/IndexFieldMapperTests.java @@ -35,7 +35,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchSingleNodeTestCase; import org.opensearch.test.InternalSettingsPlugin; @@ -64,7 +64,7 @@ public void testDefaultDisabledIndexMapper() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); diff --git a/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldMapperTests.java index 9eb05c9ab1b15..421ef5bab0764 100644 --- a/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldMapperTests.java @@ -37,9 +37,9 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.network.InetAddresses; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.IndexService; import org.opensearch.index.termvectors.TermVectorsService; @@ -173,6 +173,6 @@ private final SourceToParse source(CheckedConsumer XContentBuilder builder = JsonXContent.contentBuilder().startObject(); build.accept(builder); builder.endObject(); - return new SourceToParse("test", "1", BytesReference.bytes(builder), XContentType.JSON); + return new SourceToParse("test", "1", BytesReference.bytes(builder), MediaTypeRegistry.JSON); } } diff --git a/server/src/test/java/org/opensearch/index/mapper/JavaMultiFieldMergeTests.java b/server/src/test/java/org/opensearch/index/mapper/JavaMultiFieldMergeTests.java index f0bc7c9f8c616..646ba48b19552 100644 --- a/server/src/test/java/org/opensearch/index/mapper/JavaMultiFieldMergeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/JavaMultiFieldMergeTests.java @@ -36,7 +36,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.mapper.ParseContext.Document; import org.opensearch.test.OpenSearchSingleNodeTestCase; @@ -56,7 +56,7 @@ public void testMergeMultiField() throws Exception { assertThat(mapperService.fieldType("name.indexed"), nullValue()); BytesReference json = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("name", "some name").endObject()); - Document doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", json, XContentType.JSON)).rootDoc(); + Document doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", json, MediaTypeRegistry.JSON)).rootDoc(); IndexableField f = doc.getField("name"); assertThat(f, notNullValue()); f = doc.getField("name.indexed"); @@ -72,7 +72,7 @@ public void testMergeMultiField() throws Exception { assertThat(mapperService.fieldType("name.not_indexed2"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed3"), nullValue()); - doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", json, XContentType.JSON)).rootDoc(); + doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", json, MediaTypeRegistry.JSON)).rootDoc(); f = doc.getField("name"); assertThat(f, notNullValue()); f = doc.getField("name.indexed"); @@ -109,7 +109,7 @@ public void testUpgradeFromMultiFieldTypeToMultiFields() throws Exception { assertThat(mapperService.fieldType("name.indexed"), nullValue()); BytesReference json = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("name", "some name").endObject()); - Document doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", json, XContentType.JSON)).rootDoc(); + Document doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", json, MediaTypeRegistry.JSON)).rootDoc(); IndexableField f = doc.getField("name"); assertThat(f, notNullValue()); f = doc.getField("name.indexed"); @@ -125,7 +125,7 @@ public void testUpgradeFromMultiFieldTypeToMultiFields() throws Exception { assertThat(mapperService.fieldType("name.not_indexed2"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed3"), nullValue()); - doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", json, XContentType.JSON)).rootDoc(); + doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", json, MediaTypeRegistry.JSON)).rootDoc(); f = doc.getField("name"); assertThat(f, notNullValue()); f = doc.getField("name.indexed"); diff --git a/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldMapperTests.java index 3e8dbe5b9d600..048b51d39ca6c 100644 --- a/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldMapperTests.java @@ -42,8 +42,8 @@ import org.opensearch.common.geo.ShapeRelation; import org.opensearch.common.geo.SpatialStrategy; import org.opensearch.common.geo.builders.ShapeBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.geometry.Point; @@ -539,13 +539,13 @@ public void testSerializeDefaults() throws Exception { ToXContent.Params includeDefaults = new ToXContent.MapParams(singletonMap("include_defaults", "true")); { DocumentMapper mapper = createDocumentMapper(fieldMapping(b -> b.field("type", "geo_shape").field("tree", "quadtree"))); - String serialized = Strings.toString(XContentType.JSON, mapper.mappers().getMapper("field"), includeDefaults); + String serialized = Strings.toString(MediaTypeRegistry.JSON, mapper.mappers().getMapper("field"), includeDefaults); assertTrue(serialized, serialized.contains("\"precision\":\"50.0m\"")); assertTrue(serialized, serialized.contains("\"tree_levels\":21")); } { DocumentMapper mapper = createDocumentMapper(fieldMapping(b -> b.field("type", "geo_shape").field("tree", "geohash"))); - String serialized = Strings.toString(XContentType.JSON, mapper.mappers().getMapper("field"), includeDefaults); + String serialized = Strings.toString(MediaTypeRegistry.JSON, mapper.mappers().getMapper("field"), includeDefaults); assertTrue(serialized, serialized.contains("\"precision\":\"50.0m\"")); assertTrue(serialized, serialized.contains("\"tree_levels\":9")); } @@ -553,7 +553,7 @@ public void testSerializeDefaults() throws Exception { DocumentMapper mapper = createDocumentMapper( fieldMapping(b -> b.field("type", "geo_shape").field("tree", "quadtree").field("tree_levels", "6")) ); - String serialized = Strings.toString(XContentType.JSON, mapper.mappers().getMapper("field"), includeDefaults); + String serialized = Strings.toString(MediaTypeRegistry.JSON, mapper.mappers().getMapper("field"), includeDefaults); assertFalse(serialized, serialized.contains("\"precision\":")); assertTrue(serialized, serialized.contains("\"tree_levels\":6")); } @@ -561,7 +561,7 @@ public void testSerializeDefaults() throws Exception { DocumentMapper mapper = createDocumentMapper( fieldMapping(b -> b.field("type", "geo_shape").field("tree", "quadtree").field("precision", "6")) ); - String serialized = Strings.toString(XContentType.JSON, mapper.mappers().getMapper("field"), includeDefaults); + String serialized = Strings.toString(MediaTypeRegistry.JSON, mapper.mappers().getMapper("field"), includeDefaults); assertTrue(serialized, serialized.contains("\"precision\":\"6.0m\"")); assertFalse(serialized, serialized.contains("\"tree_levels\":")); } @@ -569,7 +569,7 @@ public void testSerializeDefaults() throws Exception { DocumentMapper mapper = createDocumentMapper( fieldMapping(b -> b.field("type", "geo_shape").field("tree", "quadtree").field("precision", "6m").field("tree_levels", "5")) ); - String serialized = Strings.toString(XContentType.JSON, mapper.mappers().getMapper("field"), includeDefaults); + String serialized = Strings.toString(MediaTypeRegistry.JSON, mapper.mappers().getMapper("field"), includeDefaults); assertTrue(serialized, serialized.contains("\"precision\":\"6.0m\"")); assertTrue(serialized, serialized.contains("\"tree_levels\":5")); } @@ -591,7 +591,7 @@ public void testPointsOnlyDefaultsWithTermStrategy() throws IOException { assertThat(strategy.getGrid().getMaxLevels(), equalTo(23)); assertThat(strategy.isPointsOnly(), equalTo(true)); // term strategy changes the default for points_only, check that we handle it correctly - assertThat(Strings.toString(XContentType.JSON, geoShapeFieldMapper), not(containsString("points_only"))); + assertThat(Strings.toString(MediaTypeRegistry.JSON, geoShapeFieldMapper), not(containsString("points_only"))); assertFieldWarnings("tree", "precision", "strategy"); } diff --git a/server/src/test/java/org/opensearch/index/mapper/MultiFieldTests.java b/server/src/test/java/org/opensearch/index/mapper/MultiFieldTests.java index 6d483959289f4..dc7f9d1f96f92 100644 --- a/server/src/test/java/org/opensearch/index/mapper/MultiFieldTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/MultiFieldTests.java @@ -38,9 +38,9 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.ParseContext.Document; @@ -75,7 +75,7 @@ private void testMultiField(String mapping) throws Exception { .merge(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/opensearch/index/mapper/multifield/test-data.json")); - Document doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", json, XContentType.JSON)).rootDoc(); + Document doc = mapperService.documentMapper().parse(new SourceToParse("test", "1", json, MediaTypeRegistry.JSON)).rootDoc(); IndexableField f = doc.getField("name"); assertThat(f.name(), equalTo("name")); @@ -154,7 +154,7 @@ public void testBuildThenParse() throws Exception { .parse(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(builtMapping)); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/opensearch/index/mapper/multifield/test-data.json")); - Document doc = docMapper.parse(new SourceToParse("test", "1", json, XContentType.JSON)).rootDoc(); + Document doc = docMapper.parse(new SourceToParse("test", "1", json, MediaTypeRegistry.JSON)).rootDoc(); IndexableField f = doc.getField("name"); assertThat(f.name(), equalTo("name")); diff --git a/server/src/test/java/org/opensearch/index/mapper/NestedObjectMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/NestedObjectMapperTests.java index 4d9bef87ddc41..20a2204f123fc 100644 --- a/server/src/test/java/org/opensearch/index/mapper/NestedObjectMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/NestedObjectMapperTests.java @@ -36,9 +36,9 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.MapperService.MergeReason; import org.opensearch.index.mapper.ObjectMapper.Dynamic; import org.opensearch.plugins.Plugin; @@ -86,7 +86,7 @@ public void testEmptyNested() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").nullField("nested1").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -99,7 +99,7 @@ public void testEmptyNested() throws Exception { BytesReference.bytes( XContentFactory.jsonBuilder().startObject().field("field", "value").startArray("nested").endArray().endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -141,7 +141,7 @@ public void testSingleNested() throws Exception { .endObject() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -172,7 +172,7 @@ public void testSingleNested() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -253,7 +253,7 @@ public void testMultiNested() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -346,7 +346,7 @@ public void testMultiObjectAndNested1() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -440,7 +440,7 @@ public void testMultiObjectAndNested2() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -533,7 +533,7 @@ public void testMultiRootAndNested1() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -610,7 +610,7 @@ public void testMultipleLevelsIncludeRoot1() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -682,7 +682,7 @@ public void testMultipleLevelsIncludeRoot2() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -760,7 +760,7 @@ public void testMultipleLevelsIncludeRootWithMerge() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -814,7 +814,7 @@ public void testNestedArrayStrict() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -949,7 +949,7 @@ public void testLimitNestedDocsDefaultSettings() throws Exception { docBuilder.endArray(); } docBuilder.endObject(); - SourceToParse source1 = new SourceToParse("test1", "1", BytesReference.bytes(docBuilder), XContentType.JSON); + SourceToParse source1 = new SourceToParse("test1", "1", BytesReference.bytes(docBuilder), MediaTypeRegistry.JSON); MapperParsingException e = expectThrows(MapperParsingException.class, () -> docMapper.parse(source1)); assertEquals( "The number of nested documents has exceeded the allowed limit of [" @@ -993,7 +993,7 @@ public void testLimitNestedDocs() throws Exception { docBuilder.endArray(); } docBuilder.endObject(); - SourceToParse source1 = new SourceToParse("test1", "1", BytesReference.bytes(docBuilder), XContentType.JSON); + SourceToParse source1 = new SourceToParse("test1", "1", BytesReference.bytes(docBuilder), MediaTypeRegistry.JSON); ParsedDocument doc = docMapper.parse(source1); assertThat(doc.docs().size(), equalTo(3)); @@ -1010,7 +1010,7 @@ public void testLimitNestedDocs() throws Exception { docBuilder2.endArray(); } docBuilder2.endObject(); - SourceToParse source2 = new SourceToParse("test1", "2", BytesReference.bytes(docBuilder2), XContentType.JSON); + SourceToParse source2 = new SourceToParse("test1", "2", BytesReference.bytes(docBuilder2), MediaTypeRegistry.JSON); MapperParsingException e = expectThrows(MapperParsingException.class, () -> docMapper.parse(source2)); assertEquals( "The number of nested documents has exceeded the allowed limit of [" @@ -1061,7 +1061,7 @@ public void testLimitNestedDocsMultipleNestedFields() throws Exception { docBuilder.endArray(); } docBuilder.endObject(); - SourceToParse source1 = new SourceToParse("test1", "1", BytesReference.bytes(docBuilder), XContentType.JSON); + SourceToParse source1 = new SourceToParse("test1", "1", BytesReference.bytes(docBuilder), MediaTypeRegistry.JSON); ParsedDocument doc = docMapper.parse(source1); assertThat(doc.docs().size(), equalTo(3)); @@ -1083,7 +1083,7 @@ public void testLimitNestedDocsMultipleNestedFields() throws Exception { } docBuilder2.endObject(); - SourceToParse source2 = new SourceToParse("test1", "2", BytesReference.bytes(docBuilder2), XContentType.JSON); + SourceToParse source2 = new SourceToParse("test1", "2", BytesReference.bytes(docBuilder2), MediaTypeRegistry.JSON); MapperParsingException e = expectThrows(MapperParsingException.class, () -> docMapper.parse(source2)); assertEquals( "The number of nested documents has exceeded the allowed limit of [" diff --git a/server/src/test/java/org/opensearch/index/mapper/NestedPathFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/NestedPathFieldMapperTests.java index 9823c54b4ab13..c27134e283e9d 100644 --- a/server/src/test/java/org/opensearch/index/mapper/NestedPathFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/NestedPathFieldMapperTests.java @@ -12,7 +12,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchSingleNodeTestCase; import java.io.IOException; @@ -30,7 +30,7 @@ public void testDefaultConfig() throws IOException { new CompressedXContent("{\"" + MapperService.SINGLE_MAPPING_NAME + "\":{}}"), MapperService.MergeReason.MAPPING_UPDATE ); - ParsedDocument document = mapper.parse(new SourceToParse("index", "id", new BytesArray("{}"), XContentType.JSON)); + ParsedDocument document = mapper.parse(new SourceToParse("index", "id", new BytesArray("{}"), MediaTypeRegistry.JSON)); assertEquals(Collections.emptyList(), Arrays.asList(document.rootDoc().getFields(NestedPathFieldMapper.NAME))); } diff --git a/server/src/test/java/org/opensearch/index/mapper/NullValueObjectMappingTests.java b/server/src/test/java/org/opensearch/index/mapper/NullValueObjectMappingTests.java index 565031a603360..c9b5e8292d78b 100644 --- a/server/src/test/java/org/opensearch/index/mapper/NullValueObjectMappingTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/NullValueObjectMappingTests.java @@ -35,7 +35,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchSingleNodeTestCase; import java.io.IOException; @@ -67,7 +67,7 @@ public void testNullValueObject() throws IOException { BytesReference.bytes( XContentFactory.jsonBuilder().startObject().startObject("obj1").endObject().field("value1", "test1").endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -78,7 +78,7 @@ public void testNullValueObject() throws IOException { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().nullField("obj1").field("value1", "test1").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -97,7 +97,7 @@ public void testNullValueObject() throws IOException { .field("value1", "test1") .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); diff --git a/server/src/test/java/org/opensearch/index/mapper/NumberFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/NumberFieldMapperTests.java index e2524808409b0..610b69a7fdf88 100644 --- a/server/src/test/java/org/opensearch/index/mapper/NumberFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/NumberFieldMapperTests.java @@ -35,8 +35,8 @@ import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.IndexableField; import org.opensearch.core.common.bytes.BytesArray; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.NumberFieldMapper.NumberType; import org.opensearch.index.mapper.NumberFieldTypeTests.OutOfRangeSpec; import org.opensearch.index.termvectors.TermVectorsService; @@ -315,7 +315,7 @@ public void testOutOfRangeValues() throws IOException { public void testLongIndexingOutOfRange() throws Exception { DocumentMapper mapper = createDocumentMapper(fieldMapping(b -> b.field("type", "long").field("ignore_malformed", true))); ParsedDocument doc = mapper.parse( - source(b -> b.rawField("field", new BytesArray("9223372036854775808").streamInput(), XContentType.JSON)) + source(b -> b.rawField("field", new BytesArray("9223372036854775808").streamInput(), MediaTypeRegistry.JSON)) ); assertEquals(0, doc.rootDoc().getFields("field").length); } diff --git a/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java b/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java index 547c4696ce3ed..8776cfac918c2 100644 --- a/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java @@ -60,8 +60,8 @@ import org.opensearch.common.Numbers; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.BigArrays; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; import org.opensearch.index.IndexSettings; import org.opensearch.index.document.SortedUnsignedLongDocValuesRangeQuery; @@ -798,7 +798,7 @@ static OutOfRangeSpec of(NumberType t, Object v, String m) { public void write(XContentBuilder b) throws IOException { if (value instanceof BigInteger) { - b.rawField("field", new ByteArrayInputStream(value.toString().getBytes("UTF-8")), XContentType.JSON); + b.rawField("field", new ByteArrayInputStream(value.toString().getBytes("UTF-8")), MediaTypeRegistry.JSON); } else { b.field("field", value); } diff --git a/server/src/test/java/org/opensearch/index/mapper/ObjectMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/ObjectMapperTests.java index 61d64431abdbb..4892e5c2524a7 100644 --- a/server/src/test/java/org/opensearch/index/mapper/ObjectMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/ObjectMapperTests.java @@ -35,7 +35,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.mapper.MapperService.MergeReason; import org.opensearch.index.mapper.ObjectMapper.Dynamic; import org.opensearch.plugins.Plugin; @@ -74,7 +74,7 @@ public void testDifferentInnerObjectTokenFailure() throws Exception { + " \"value\":\"value\"\n" + " }" ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); }); diff --git a/server/src/test/java/org/opensearch/index/mapper/PathMatchDynamicTemplateTests.java b/server/src/test/java/org/opensearch/index/mapper/PathMatchDynamicTemplateTests.java index 36f63f9d90ab0..1fed040a449e8 100644 --- a/server/src/test/java/org/opensearch/index/mapper/PathMatchDynamicTemplateTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/PathMatchDynamicTemplateTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.index.IndexableField; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.mapper.ParseContext.Document; import org.opensearch.test.OpenSearchSingleNodeTestCase; @@ -47,17 +47,17 @@ public class PathMatchDynamicTemplateTests extends OpenSearchSingleNodeTestCase public void testSimple() throws Exception { String mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json"); IndexService index = createIndex("test"); - client().admin().indices().preparePutMapping("test").setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping("test").setSource(mapping, MediaTypeRegistry.JSON).get(); MapperService mapperService = index.mapperService(); byte[] json = copyToBytesFromClasspath("/org/opensearch/index/mapper/dynamictemplate/pathmatch/test-data.json"); ParsedDocument parsedDoc = mapperService.documentMapper() - .parse(new SourceToParse("test", "1", new BytesArray(json), XContentType.JSON)); + .parse(new SourceToParse("test", "1", new BytesArray(json), MediaTypeRegistry.JSON)); client().admin() .indices() .preparePutMapping("test") - .setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON) + .setSource(parsedDoc.dynamicMappingsUpdate().toString(), MediaTypeRegistry.JSON) .get(); Document doc = parsedDoc.rootDoc(); diff --git a/server/src/test/java/org/opensearch/index/mapper/RoutingFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/RoutingFieldMapperTests.java index 8c0c5e2eaa7e6..9182efaf59ecf 100644 --- a/server/src/test/java/org/opensearch/index/mapper/RoutingFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/RoutingFieldMapperTests.java @@ -35,7 +35,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchSingleNodeTestCase; import static org.hamcrest.Matchers.containsString; @@ -54,7 +54,7 @@ public void testRoutingMapper() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject()), - XContentType.JSON, + MediaTypeRegistry.JSON, "routing_value" ) ); @@ -75,7 +75,7 @@ public void testIncludeInObjectNotAllowed() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("_routing", "foo").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); fail("Expected failure to parse metadata field"); diff --git a/server/src/test/java/org/opensearch/index/mapper/SourceFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/SourceFieldMapperTests.java index 425a0fd1f1bdd..c7a1ea57d12d8 100644 --- a/server/src/test/java/org/opensearch/index/mapper/SourceFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/SourceFieldMapperTests.java @@ -75,11 +75,11 @@ public void testNoFormat() throws Exception { "test", "1", BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", "value").endObject()), - XContentType.JSON + MediaTypeRegistry.JSON ) ); - assertThat(MediaTypeRegistry.xContent(doc.source().toBytesRef().bytes), equalTo(XContentType.JSON)); + assertThat(MediaTypeRegistry.xContent(doc.source().toBytesRef().bytes), equalTo(MediaTypeRegistry.JSON)); documentMapper = parser.parse("type", new CompressedXContent(mapping)); doc = documentMapper.parse( @@ -124,7 +124,7 @@ public void testIncludes() throws Exception { .endObject() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -167,7 +167,7 @@ public void testExcludes() throws Exception { .endObject() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); @@ -314,8 +314,8 @@ public void testSourceObjectContainsExtraTokens() throws Exception { .parse("type", new CompressedXContent(mapping)); try { - documentMapper.parse(new SourceToParse("test", "1", new BytesArray("{}}"), XContentType.JSON)); // extra end object - // (invalid JSON) + documentMapper.parse(new SourceToParse("test", "1", new BytesArray("{}}"), MediaTypeRegistry.JSON)); // extra end object + // (invalid JSON) fail("Expected parse exception"); } catch (MapperParsingException e) { assertNotNull(e.getRootCause()); diff --git a/server/src/test/java/org/opensearch/index/mapper/StoredNumericValuesTests.java b/server/src/test/java/org/opensearch/index/mapper/StoredNumericValuesTests.java index 055f41b157205..4e7482c0557d1 100644 --- a/server/src/test/java/org/opensearch/index/mapper/StoredNumericValuesTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/StoredNumericValuesTests.java @@ -42,7 +42,7 @@ import org.opensearch.common.lucene.Lucene; import org.opensearch.common.util.set.Sets; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.fieldvisitor.CustomFieldsVisitor; import org.opensearch.index.mapper.MapperService.MergeReason; import org.opensearch.test.OpenSearchSingleNodeTestCase; @@ -135,7 +135,7 @@ public void testBytesAndNumericRepresentation() throws Exception { .field("field11", "1") .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); diff --git a/server/src/test/java/org/opensearch/index/query/WrapperQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/WrapperQueryBuilderTests.java index 09605bcd0a8dd..4135f6e0ef049 100644 --- a/server/src/test/java/org/opensearch/index/query/WrapperQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/WrapperQueryBuilderTests.java @@ -40,8 +40,7 @@ import org.opensearch.core.common.ParsingException; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.AbstractQueryTestCase; import java.io.IOException; @@ -70,7 +69,7 @@ protected WrapperQueryBuilder doCreateTestQueryBuilder() { QueryBuilder wrappedQuery = RandomQueryBuilder.createQuery(random()); BytesReference bytes; try { - bytes = XContentHelper.toXContent(wrappedQuery, XContentType.JSON, false); + bytes = org.opensearch.core.xcontent.XContentHelper.toXContent(wrappedQuery, MediaTypeRegistry.JSON, false); } catch (IOException e) { throw new UncheckedIOException(e); } diff --git a/server/src/test/java/org/opensearch/index/replication/IndexLevelReplicationTests.java b/server/src/test/java/org/opensearch/index/replication/IndexLevelReplicationTests.java index d262b5abec0f3..9465f73394e40 100644 --- a/server/src/test/java/org/opensearch/index/replication/IndexLevelReplicationTests.java +++ b/server/src/test/java/org/opensearch/index/replication/IndexLevelReplicationTests.java @@ -48,7 +48,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.iterable.Iterables; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.engine.Engine; import org.opensearch.index.engine.EngineFactory; @@ -173,7 +173,7 @@ public void cleanFiles( public void testRetryAppendOnlyAfterRecovering() throws Exception { try (ReplicationGroup shards = createGroup(0)) { shards.startAll(); - final IndexRequest originalRequest = new IndexRequest(index.getName()).source("{}", XContentType.JSON); + final IndexRequest originalRequest = new IndexRequest(index.getName()).source("{}", MediaTypeRegistry.JSON); originalRequest.process(Version.CURRENT, null, index.getName()); final IndexRequest retryRequest = copyIndexRequest(originalRequest); retryRequest.onRetry(); @@ -214,7 +214,7 @@ public IndexResult index(Index op) throws IOException { }) { shards.startAll(); Thread thread = new Thread(() -> { - IndexRequest indexRequest = new IndexRequest(index.getName()).source("{}", XContentType.JSON); + IndexRequest indexRequest = new IndexRequest(index.getName()).source("{}", MediaTypeRegistry.JSON); try { shards.index(indexRequest); } catch (Exception e) { @@ -244,7 +244,7 @@ public void prepareForTranslogOperations(int totalTranslogOps, ActionListener replicas = shards.getReplicas(); IndexShard replica1 = replicas.get(0); - IndexRequest indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"1\"}", XContentType.JSON); + IndexRequest indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"1\"}", MediaTypeRegistry.JSON); logger.info("--> isolated replica " + replica1.routingEntry()); BulkShardRequest replicationRequest = indexOnPrimary(indexRequest, shards.getPrimary()); for (int i = 1; i < replicas.size(); i++) { @@ -329,7 +329,7 @@ public void testConflictingOpsOnReplica() throws Exception { logger.info("--> promoting replica to primary " + replica1.routingEntry()); shards.promoteReplicaToPrimary(replica1).get(); - indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"2\"}", XContentType.JSON); + indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"2\"}", MediaTypeRegistry.JSON); shards.index(indexRequest); shards.refresh("test"); for (IndexShard shard : shards) { @@ -356,7 +356,7 @@ public void testReplicaTermIncrementWithConcurrentPrimaryPromotion() throws Exce assertEquals(primaryPrimaryTerm, replica2.getPendingPrimaryTerm()); - IndexRequest indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"1\"}", XContentType.JSON); + IndexRequest indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"1\"}", MediaTypeRegistry.JSON); BulkShardRequest replicationRequest = indexOnPrimary(indexRequest, replica1); CyclicBarrier barrier = new CyclicBarrier(2); @@ -396,7 +396,7 @@ public void testReplicaOperationWithConcurrentPrimaryPromotion() throws Exceptio try (ReplicationGroup shards = new ReplicationGroup(buildIndexMetadata(1, mappings))) { shards.startAll(); long primaryPrimaryTerm = shards.getPrimary().getPendingPrimaryTerm(); - IndexRequest indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"1\"}", XContentType.JSON); + IndexRequest indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"1\"}", MediaTypeRegistry.JSON); BulkShardRequest replicationRequest = indexOnPrimary(indexRequest, shards.getPrimary()); List replicas = shards.getReplicas(); @@ -476,7 +476,7 @@ protected EngineFactory getEngineFactory(ShardRouting routing) { shards.startPrimary(); long primaryTerm = shards.getPrimary().getPendingPrimaryTerm(); List expectedTranslogOps = new ArrayList<>(); - BulkItemResponse indexResp = shards.index(new IndexRequest(index.getName()).id("1").source("{}", XContentType.JSON)); + BulkItemResponse indexResp = shards.index(new IndexRequest(index.getName()).id("1").source("{}", MediaTypeRegistry.JSON)); assertThat(indexResp.isFailed(), equalTo(true)); assertThat(indexResp.getFailure().getCause(), equalTo(indexException)); expectedTranslogOps.add(new Translog.NoOp(0, primaryTerm, indexException.toString())); @@ -504,7 +504,7 @@ protected EngineFactory getEngineFactory(ShardRouting routing) { } } // the failure replicated directly from the replication channel. - indexResp = shards.index(new IndexRequest(index.getName()).id("any").source("{}", XContentType.JSON)); + indexResp = shards.index(new IndexRequest(index.getName()).id("any").source("{}", MediaTypeRegistry.JSON)); assertThat(indexResp.getFailure().getCause(), equalTo(indexException)); Translog.NoOp noop2 = new Translog.NoOp(1, primaryTerm, indexException.toString()); expectedTranslogOps.add(noop2); @@ -531,7 +531,9 @@ protected EngineFactory getEngineFactory(ShardRouting routing) { public void testRequestFailureReplication() throws Exception { try (ReplicationGroup shards = createGroup(0)) { shards.startAll(); - BulkItemResponse response = shards.index(new IndexRequest(index.getName()).id("1").source("{}", XContentType.JSON).version(2)); + BulkItemResponse response = shards.index( + new IndexRequest(index.getName()).id("1").source("{}", MediaTypeRegistry.JSON).version(2) + ); assertTrue(response.isFailed()); assertThat(response.getFailure().getCause(), instanceOf(VersionConflictEngineException.class)); shards.assertAllEqual(0); @@ -549,7 +551,7 @@ public void testRequestFailureReplication() throws Exception { shards.addReplica(); } shards.startReplicas(nReplica); - response = shards.index(new IndexRequest(index.getName()).id("1").source("{}", XContentType.JSON).version(2)); + response = shards.index(new IndexRequest(index.getName()).id("1").source("{}", MediaTypeRegistry.JSON).version(2)); assertTrue(response.isFailed()); assertThat(response.getFailure().getCause(), instanceOf(VersionConflictEngineException.class)); shards.assertAllEqual(0); @@ -582,7 +584,7 @@ public void testSeqNoCollision() throws Exception { shards.syncGlobalCheckpoint(); logger.info("--> Isolate replica1"); - IndexRequest indexDoc1 = new IndexRequest(index.getName()).id("d1").source("{}", XContentType.JSON); + IndexRequest indexDoc1 = new IndexRequest(index.getName()).id("d1").source("{}", MediaTypeRegistry.JSON); BulkShardRequest replicationRequest = indexOnPrimary(indexDoc1, shards.getPrimary()); indexOnReplica(replicationRequest, shards, replica2); @@ -602,7 +604,7 @@ public void testSeqNoCollision() throws Exception { } logger.info("--> Promote replica1 as the primary"); shards.promoteReplicaToPrimary(replica1).get(); // wait until resync completed. - shards.index(new IndexRequest(index.getName()).id("d2").source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id("d2").source("{}", MediaTypeRegistry.JSON)); final Translog.Operation op2; try (Translog.Snapshot snapshot = getTranslog(replica2).newSnapshot()) { assertThat(snapshot.totalOperations(), equalTo(1)); @@ -652,7 +654,7 @@ public void testLateDeliveryAfterGCTriggeredOnReplica() throws Exception { updateGCDeleteCycle(replica, gcInterval); final BulkShardRequest indexRequest = indexOnPrimary( - new IndexRequest(index.getName()).id("d1").source("{}", XContentType.JSON), + new IndexRequest(index.getName()).id("d1").source("{}", MediaTypeRegistry.JSON), primary ); final BulkShardRequest deleteRequest = deleteOnPrimary(new DeleteRequest(index.getName()).id("d1"), primary); @@ -689,7 +691,7 @@ public void testOutOfOrderDeliveryForAppendOnlyOperations() throws Exception { final IndexShard replica = shards.getReplicas().get(0); // Append-only request - without id final BulkShardRequest indexRequest = indexOnPrimary( - new IndexRequest(index.getName()).id(null).source("{}", XContentType.JSON), + new IndexRequest(index.getName()).id(null).source("{}", MediaTypeRegistry.JSON), primary ); final String docId = Iterables.get(getShardDocUIDs(primary), 0); @@ -709,7 +711,7 @@ public void testIndexingOptimizationUsingSequenceNumbers() throws Exception { for (int i = 0; i < numDocs; i++) { String id = Integer.toString(randomIntBetween(1, 100)); if (randomBoolean()) { - group.index(new IndexRequest(index.getName()).id(id).source("{}", XContentType.JSON)); + group.index(new IndexRequest(index.getName()).id(id).source("{}", MediaTypeRegistry.JSON)); if (liveDocs.add(id) == false) { versionLookups++; } diff --git a/server/src/test/java/org/opensearch/index/replication/RecoveryDuringReplicationTests.java b/server/src/test/java/org/opensearch/index/replication/RecoveryDuringReplicationTests.java index b61150a9a81e2..13566a66034bd 100644 --- a/server/src/test/java/org/opensearch/index/replication/RecoveryDuringReplicationTests.java +++ b/server/src/test/java/org/opensearch/index/replication/RecoveryDuringReplicationTests.java @@ -49,8 +49,8 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.lucene.uid.Versions; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.lease.Releasable; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.VersionType; import org.opensearch.index.engine.DocIdSeqNoAndSource; @@ -141,7 +141,7 @@ public void testRecoveryToReplicaThatReceivedExtraDocument() throws Exception { shards.startAll(); final int docs = randomIntBetween(0, 16); for (int i = 0; i < docs; i++) { - shards.index(new IndexRequest("index").id(Integer.toString(i)).source("{}", XContentType.JSON)); + shards.index(new IndexRequest("index").id(Integer.toString(i)).source("{}", MediaTypeRegistry.JSON)); } shards.flush(); @@ -158,7 +158,7 @@ public void testRecoveryToReplicaThatReceivedExtraDocument() throws Exception { 1, randomNonNegativeLong(), false, - new SourceToParse("index", "replica", new BytesArray("{}"), XContentType.JSON) + new SourceToParse("index", "replica", new BytesArray("{}"), MediaTypeRegistry.JSON) ); shards.promoteReplicaToPrimary(promotedReplica).get(); oldPrimary.close("demoted", randomBoolean(), false); @@ -172,7 +172,7 @@ public void testRecoveryToReplicaThatReceivedExtraDocument() throws Exception { promotedReplica.applyIndexOperationOnPrimary( Versions.MATCH_ANY, VersionType.INTERNAL, - new SourceToParse("index", "primary", new BytesArray("{}"), XContentType.JSON), + new SourceToParse("index", "primary", new BytesArray("{}"), MediaTypeRegistry.JSON), SequenceNumbers.UNASSIGNED_SEQ_NO, 0, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, @@ -209,7 +209,8 @@ public void testRecoveryAfterPrimaryPromotion() throws Exception { final int rollbackDocs = randomIntBetween(1, 5); logger.info("--> indexing {} rollback docs", rollbackDocs); for (int i = 0; i < rollbackDocs; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName()).id("rollback_" + i).source("{}", XContentType.JSON); + final IndexRequest indexRequest = new IndexRequest(index.getName()).id("rollback_" + i) + .source("{}", MediaTypeRegistry.JSON); final BulkShardRequest bulkShardRequest = indexOnPrimary(indexRequest, oldPrimary); indexOnReplica(bulkShardRequest, shards, replica); } @@ -327,7 +328,7 @@ public void testReplicaRollbackStaleDocumentsInPeerRecovery() throws Exception { int staleDocs = scaledRandomIntBetween(1, 10); logger.info("--> indexing {} stale docs", staleDocs); for (int i = 0; i < staleDocs; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName()).id("stale_" + i).source("{}", XContentType.JSON); + final IndexRequest indexRequest = new IndexRequest(index.getName()).id("stale_" + i).source("{}", MediaTypeRegistry.JSON); final BulkShardRequest bulkShardRequest = indexOnPrimary(indexRequest, oldPrimary); indexOnReplica(bulkShardRequest, shards, replica); } @@ -364,7 +365,7 @@ public void testResyncAfterPrimaryPromotion() throws Exception { for (int i = 0; i < initialDocs; i++) { final IndexRequest indexRequest = new IndexRequest(index.getName()).id("initial_doc_" + i) - .source("{ \"f\": \"normal\"}", XContentType.JSON); + .source("{ \"f\": \"normal\"}", MediaTypeRegistry.JSON); shards.index(indexRequest); } @@ -382,7 +383,7 @@ public void testResyncAfterPrimaryPromotion() throws Exception { logger.info("--> indexing {} extra docs", extraDocs); for (int i = 0; i < extraDocs; i++) { final IndexRequest indexRequest = new IndexRequest(index.getName()).id("extra_doc_" + i) - .source("{ \"f\": \"normal\"}", XContentType.JSON); + .source("{ \"f\": \"normal\"}", MediaTypeRegistry.JSON); final BulkShardRequest bulkShardRequest = indexOnPrimary(indexRequest, oldPrimary); indexOnReplica(bulkShardRequest, shards, newPrimary); } @@ -391,7 +392,7 @@ public void testResyncAfterPrimaryPromotion() throws Exception { logger.info("--> indexing {} extra docs to be trimmed", extraDocsToBeTrimmed); for (int i = 0; i < extraDocsToBeTrimmed; i++) { final IndexRequest indexRequest = new IndexRequest(index.getName()).id("extra_trimmed_" + i) - .source("{ \"f\": \"trimmed\"}", XContentType.JSON); + .source("{ \"f\": \"trimmed\"}", MediaTypeRegistry.JSON); final BulkShardRequest bulkShardRequest = indexOnPrimary(indexRequest, oldPrimary); // have to replicate to another replica != newPrimary one - the subject to trim indexOnReplica(bulkShardRequest, shards, justReplica); @@ -459,7 +460,7 @@ protected EngineFactory getEngineFactory(ShardRouting routing) { final String id = "pending_" + i; threadPool.generic().submit(() -> { try { - shards.index(new IndexRequest(index.getName()).id(id).source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(id).source("{}", MediaTypeRegistry.JSON)); } catch (Exception e) { throw new AssertionError(e); } finally { @@ -550,7 +551,7 @@ public void indexTranslogOperations( replicaEngineFactory.latchIndexers(1); threadPool.generic().submit(() -> { try { - shards.index(new IndexRequest(index.getName()).id("pending").source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id("pending").source("{}", MediaTypeRegistry.JSON)); } catch (final Exception e) { throw new RuntimeException(e); } finally { @@ -562,7 +563,7 @@ public void indexTranslogOperations( replicaEngineFactory.awaitIndexersLatch(); // unblock indexing for the next doc replicaEngineFactory.allowIndexing(); - shards.index(new IndexRequest(index.getName()).id("completed").source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id("completed").source("{}", MediaTypeRegistry.JSON)); pendingDocActiveWithExtraDocIndexed.countDown(); } catch (final Exception e) { throw new AssertionError(e); @@ -602,7 +603,7 @@ public void indexTranslogOperations( // wait for the translog phase to complete and the recovery to block global checkpoint advancement assertBusy(() -> assertTrue(shards.getPrimary().pendingInSync())); { - shards.index(new IndexRequest(index.getName()).id("last").source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id("last").source("{}", MediaTypeRegistry.JSON)); final long expectedDocs = docs + 3L; assertThat(shards.getPrimary().getLocalCheckpoint(), equalTo(expectedDocs - 1)); // recovery is now in the process of being completed, therefore the global checkpoint can not have advanced on the primary @@ -637,7 +638,7 @@ public void testTransferMaxSeenAutoIdTimestampOnResync() throws Exception { long maxTimestampOnReplica2 = -1; List replicationRequests = new ArrayList<>(); for (int numDocs = between(1, 10), i = 0; i < numDocs; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName()).source("{}", XContentType.JSON); + final IndexRequest indexRequest = new IndexRequest(index.getName()).source("{}", MediaTypeRegistry.JSON); indexRequest.process(Version.CURRENT, null, index.getName()); final IndexRequest copyRequest; if (randomBoolean()) { @@ -695,10 +696,10 @@ public void testAddNewReplicas() throws Exception { int nextId = docId.incrementAndGet(); if (appendOnly) { String id = randomBoolean() ? Integer.toString(nextId) : null; - shards.index(new IndexRequest(index.getName()).id(id).source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(id).source("{}", MediaTypeRegistry.JSON)); } else if (frequently()) { String id = Integer.toString(frequently() ? nextId : between(0, nextId)); - shards.index(new IndexRequest(index.getName()).id(id).source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(id).source("{}", MediaTypeRegistry.JSON)); } else { String id = Integer.toString(between(0, nextId)); shards.delete(new DeleteRequest(index.getName()).id(id)); @@ -736,7 +737,7 @@ public void testRollbackOnPromotion() throws Exception { int inFlightOps = scaledRandomIntBetween(10, 200); for (int i = 0; i < inFlightOps; i++) { String id = "extra-" + i; - IndexRequest primaryRequest = new IndexRequest(index.getName()).id(id).source("{}", XContentType.JSON); + IndexRequest primaryRequest = new IndexRequest(index.getName()).id(id).source("{}", MediaTypeRegistry.JSON); BulkShardRequest replicationRequest = indexOnPrimary(primaryRequest, shards.getPrimary()); for (IndexShard replica : shards.getReplicas()) { if (randomBoolean()) { diff --git a/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java index 061e5431f66c4..a42d5ddf5d610 100644 --- a/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java @@ -87,11 +87,11 @@ import org.opensearch.common.util.concurrent.AtomicArray; import org.opensearch.common.util.concurrent.ConcurrentCollections; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.Assertions; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.env.NodeEnvironment; @@ -2309,7 +2309,7 @@ public void testRecoverFromStoreWithOutOfOrderDelete() throws IOException { 1, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(shard.shardId().getIndexName(), "id", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(shard.shardId().getIndexName(), "id", new BytesArray("{}"), MediaTypeRegistry.JSON) ); shard.applyIndexOperationOnReplica( UUID.randomUUID().toString(), @@ -2318,7 +2318,7 @@ public void testRecoverFromStoreWithOutOfOrderDelete() throws IOException { 3, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(shard.shardId().getIndexName(), "id-3", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(shard.shardId().getIndexName(), "id-3", new BytesArray("{}"), MediaTypeRegistry.JSON) ); // Flushing a new commit with local checkpoint=1 allows to skip the translog gen #1 in recovery. shard.flush(new FlushRequest().force(true).waitIfOngoing(true)); @@ -2329,7 +2329,7 @@ public void testRecoverFromStoreWithOutOfOrderDelete() throws IOException { 3, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(shard.shardId().getIndexName(), "id-2", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(shard.shardId().getIndexName(), "id-2", new BytesArray("{}"), MediaTypeRegistry.JSON) ); shard.applyIndexOperationOnReplica( UUID.randomUUID().toString(), @@ -2338,7 +2338,7 @@ public void testRecoverFromStoreWithOutOfOrderDelete() throws IOException { 1, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(shard.shardId().getIndexName(), "id-5", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(shard.shardId().getIndexName(), "id-5", new BytesArray("{}"), MediaTypeRegistry.JSON) ); shard.sync(); // advance local checkpoint @@ -2478,7 +2478,7 @@ public void testRecoverFromStoreWithNoOps() throws IOException { // start a replica shard and index the second doc final IndexShard otherShard = newStartedShard(false); updateMappings(otherShard, shard.indexSettings().getIndexMetadata()); - SourceToParse sourceToParse = new SourceToParse(shard.shardId().getIndexName(), "1", new BytesArray("{}"), XContentType.JSON); + SourceToParse sourceToParse = new SourceToParse(shard.shardId().getIndexName(), "1", new BytesArray("{}"), MediaTypeRegistry.JSON); otherShard.applyIndexOperationOnReplica( UUID.randomUUID().toString(), 1, @@ -2614,7 +2614,7 @@ public void testRecoverFromStoreRemoveStaleOperations() throws Exception { 1, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(indexName, "doc-0", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(indexName, "doc-0", new BytesArray("{}"), MediaTypeRegistry.JSON) ); flushShard(shard); shard.updateGlobalCheckpointOnReplica(0, "test"); // stick the global checkpoint here. @@ -2625,7 +2625,7 @@ public void testRecoverFromStoreRemoveStaleOperations() throws Exception { 1, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(indexName, "doc-1", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(indexName, "doc-1", new BytesArray("{}"), MediaTypeRegistry.JSON) ); flushShard(shard); assertThat(getShardDocUIDs(shard), containsInAnyOrder("doc-0", "doc-1")); @@ -2638,7 +2638,7 @@ public void testRecoverFromStoreRemoveStaleOperations() throws Exception { 1, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(indexName, "doc-2", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(indexName, "doc-2", new BytesArray("{}"), MediaTypeRegistry.JSON) ); flushShard(shard); assertThat(getShardDocUIDs(shard), containsInAnyOrder("doc-0", "doc-1", "doc-2")); @@ -4051,7 +4051,7 @@ private Result indexOnReplicaWithGaps(final IndexShard indexShard, final int ope indexShard.shardId().getIndexName(), id, new BytesArray("{}"), - XContentType.JSON + MediaTypeRegistry.JSON ); indexShard.applyIndexOperationOnReplica( UUID.randomUUID().toString(), @@ -4685,7 +4685,7 @@ public void testDoNotTrimCommitsWhenOpenReadOnlyEngine() throws Exception { 1, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(shard.shardId.getIndexName(), Long.toString(i), new BytesArray("{}"), XContentType.JSON) + new SourceToParse(shard.shardId.getIndexName(), Long.toString(i), new BytesArray("{}"), MediaTypeRegistry.JSON) ); shard.updateGlobalCheckpointOnReplica(shard.getLocalCheckpoint(), "test"); if (randomInt(100) < 10) { diff --git a/server/src/test/java/org/opensearch/index/shard/PrimaryReplicaSyncerTests.java b/server/src/test/java/org/opensearch/index/shard/PrimaryReplicaSyncerTests.java index f7991a3c42db8..65b823c643f8f 100644 --- a/server/src/test/java/org/opensearch/index/shard/PrimaryReplicaSyncerTests.java +++ b/server/src/test/java/org/opensearch/index/shard/PrimaryReplicaSyncerTests.java @@ -47,10 +47,10 @@ import org.opensearch.common.network.NetworkModule; import org.opensearch.common.settings.Settings; import org.opensearch.core.common.unit.ByteSizeValue; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.VersionType; import org.opensearch.index.mapper.SourceToParse; import org.opensearch.index.seqno.SequenceNumbers; @@ -93,7 +93,7 @@ public void testSyncerSendsOffCorrectDocuments() throws Exception { shard.applyIndexOperationOnPrimary( Versions.MATCH_ANY, VersionType.INTERNAL, - new SourceToParse(shard.shardId().getIndexName(), Integer.toString(i), new BytesArray("{}"), XContentType.JSON), + new SourceToParse(shard.shardId().getIndexName(), Integer.toString(i), new BytesArray("{}"), MediaTypeRegistry.JSON), SequenceNumbers.UNASSIGNED_SEQ_NO, 0, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, @@ -175,7 +175,7 @@ public void testSyncerOnClosingShard() throws Exception { shard.applyIndexOperationOnPrimary( Versions.MATCH_ANY, VersionType.INTERNAL, - new SourceToParse(shard.shardId().getIndexName(), Integer.toString(i), new BytesArray("{}"), XContentType.JSON), + new SourceToParse(shard.shardId().getIndexName(), Integer.toString(i), new BytesArray("{}"), MediaTypeRegistry.JSON), SequenceNumbers.UNASSIGNED_SEQ_NO, 0, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, diff --git a/server/src/test/java/org/opensearch/index/shard/RefreshListenersTests.java b/server/src/test/java/org/opensearch/index/shard/RefreshListenersTests.java index f3cffa4721ee5..c649ca13e3f5f 100644 --- a/server/src/test/java/org/opensearch/index/shard/RefreshListenersTests.java +++ b/server/src/test/java/org/opensearch/index/shard/RefreshListenersTests.java @@ -51,11 +51,11 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.BigArrays; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; import org.opensearch.common.lease.Releasable; import org.opensearch.core.index.shard.ShardId; import org.opensearch.core.index.Index; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.codec.CodecService; import org.opensearch.index.engine.Engine; @@ -438,7 +438,16 @@ private Engine.IndexResult index(String id, String testFieldValue) throws IOExce document.add(seqID.seqNoDocValue); document.add(seqID.primaryTerm); BytesReference source = new BytesArray(new byte[] { 1 }); - ParsedDocument doc = new ParsedDocument(versionField, seqID, id, null, Arrays.asList(document), source, XContentType.JSON, null); + ParsedDocument doc = new ParsedDocument( + versionField, + seqID, + id, + null, + Arrays.asList(document), + source, + MediaTypeRegistry.JSON, + null + ); Engine.Index index = new Engine.Index(new Term("_id", doc.id()), engine.config().getPrimaryTermSupplier().getAsLong(), doc); return engine.index(index); } diff --git a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java index 58ae4b404e69c..549909dfc55e6 100644 --- a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java @@ -29,7 +29,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.CancellableThreads; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.engine.Engine; import org.opensearch.index.engine.InternalEngineFactory; @@ -274,7 +274,7 @@ public void testSegmentReplication_With_ReaderClosedConcurrently() throws Except final int numDocs = randomIntBetween(10, 20); logger.info("--> Inserting documents {}", numDocs); for (int i = 0; i < numDocs; i++) { - shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON)); } assertEqualTranslogOperations(shards, primaryShard); primaryShard.refresh("Test"); @@ -288,7 +288,7 @@ public void testSegmentReplication_With_ReaderClosedConcurrently() throws Except // Step 2. Ingest numDocs documents again & replicate to replica shard logger.info("--> Ingest {} docs again", numDocs); for (int i = 0; i < numDocs; i++) { - shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON)); } assertEqualTranslogOperations(shards, primaryShard); primaryShard.flush(new FlushRequest().waitIfOngoing(true).force(true)); @@ -323,7 +323,7 @@ public void testSegmentReplication_With_EngineClosedConcurrently() throws Except final int numDocs = randomIntBetween(10, 20); logger.info("--> Inserting documents {}", numDocs); for (int i = 0; i < numDocs; i++) { - shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON)); } assertEqualTranslogOperations(shards, primaryShard); primaryShard.refresh("Test"); @@ -334,7 +334,7 @@ public void testSegmentReplication_With_EngineClosedConcurrently() throws Except // Step 2. Ingest numDocs documents again to create a new commit logger.info("--> Ingest {} docs again", numDocs); for (int i = 0; i < numDocs; i++) { - shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON)); } assertEqualTranslogOperations(shards, primaryShard); primaryShard.flush(new FlushRequest().waitIfOngoing(true).force(true)); diff --git a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java index a6634c0741cd4..b7b9d15457755 100644 --- a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java @@ -20,7 +20,7 @@ import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.CancellableThreads; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.engine.DocIdSeqNoAndSource; import org.opensearch.index.engine.InternalEngine; import org.opensearch.index.engine.NRTReplicationEngine; @@ -366,7 +366,7 @@ public void testTemporaryFilesNotCleanup() throws Exception { final int numDocs = randomIntBetween(100, 200); logger.info("--> Inserting documents {}", numDocs); for (int i = 0; i < numDocs; i++) { - shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON)); } assertEqualTranslogOperations(shards, primaryShard); primaryShard.flush(new FlushRequest().waitIfOngoing(true).force(true)); @@ -376,7 +376,7 @@ public void testTemporaryFilesNotCleanup() throws Exception { // Step 2. Ingest numDocs documents again to create a new commit on primary logger.info("--> Ingest {} docs again", numDocs); for (int i = 0; i < numDocs; i++) { - shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON)); } assertEqualTranslogOperations(shards, primaryShard); primaryShard.flush(new FlushRequest().waitIfOngoing(true).force(true)); @@ -656,7 +656,7 @@ public void testSegmentReplication_Index_Update_Delete() throws Exception { final int numDocs = randomIntBetween(100, 200); for (int i = 0; i < numDocs; i++) { - shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(String.valueOf(i)).source("{\"foo\": \"bar\"}", MediaTypeRegistry.JSON)); } assertEqualTranslogOperations(shards, primaryShard); @@ -669,7 +669,7 @@ public void testSegmentReplication_Index_Update_Delete() throws Exception { // randomly update docs. if (randomBoolean()) { shards.index( - new IndexRequest(index.getName()).id(String.valueOf(i)).source("{ \"foo\" : \"baz\" }", XContentType.JSON) + new IndexRequest(index.getName()).id(String.valueOf(i)).source("{ \"foo\" : \"baz\" }", MediaTypeRegistry.JSON) ); } } diff --git a/server/src/test/java/org/opensearch/index/shard/ShardGetServiceTests.java b/server/src/test/java/org/opensearch/index/shard/ShardGetServiceTests.java index 34d6233c8202f..0f27bc2bd126b 100644 --- a/server/src/test/java/org/opensearch/index/shard/ShardGetServiceTests.java +++ b/server/src/test/java/org/opensearch/index/shard/ShardGetServiceTests.java @@ -34,8 +34,8 @@ import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.VersionType; import org.opensearch.index.engine.Engine; import org.opensearch.index.engine.VersionConflictEngineException; @@ -74,7 +74,7 @@ public void testGetForUpdate() throws IOException { assertEquals(searcher.getIndexReader().maxDoc(), 1); // we refreshed } - Engine.IndexResult test1 = indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar"); + Engine.IndexResult test1 = indexDoc(primary, "1", "{\"foo\" : \"baz\"}", MediaTypeRegistry.JSON, "foobar"); assertTrue(primary.getEngine().refreshNeeded()); GetResult testGet1 = primary.getService().getForUpdate("1", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); assertEquals(new String(testGet1.source(), StandardCharsets.UTF_8), "{\"foo\" : \"baz\"}"); @@ -89,7 +89,7 @@ public void testGetForUpdate() throws IOException { } // now again from the reader - Engine.IndexResult test2 = indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar"); + Engine.IndexResult test2 = indexDoc(primary, "1", "{\"foo\" : \"baz\"}", MediaTypeRegistry.JSON, "foobar"); assertTrue(primary.getEngine().refreshNeeded()); testGet1 = primary.getService().getForUpdate("1", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); assertEquals(new String(testGet1.source(), StandardCharsets.UTF_8), "{\"foo\" : \"baz\"}"); @@ -157,7 +157,7 @@ private void runGetFromTranslogWithOptions( assertEquals(searcher.getIndexReader().maxDoc(), 1); // we refreshed } - Engine.IndexResult test1 = indexDoc(primary, "1", docToIndex, XContentType.JSON, "foobar"); + Engine.IndexResult test1 = indexDoc(primary, "1", docToIndex, MediaTypeRegistry.JSON, "foobar"); assertTrue(primary.getEngine().refreshNeeded()); GetResult testGet1 = primary.getService().getForUpdate("1", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); assertEquals(new String(testGet1.source() == null ? new byte[0] : testGet1.source(), StandardCharsets.UTF_8), expectedResult); @@ -171,7 +171,7 @@ private void runGetFromTranslogWithOptions( assertEquals(searcher.getIndexReader().maxDoc(), 2); } - Engine.IndexResult test2 = indexDoc(primary, "2", docToIndex, XContentType.JSON, "foobar"); + Engine.IndexResult test2 = indexDoc(primary, "2", docToIndex, MediaTypeRegistry.JSON, "foobar"); assertTrue(primary.getEngine().refreshNeeded()); GetResult testGet2 = primary.getService() .get("2", new String[] { "foo" }, true, 1, VersionType.INTERNAL, FetchSourceContext.FETCH_SOURCE); diff --git a/server/src/test/java/org/opensearch/index/snapshots/blobstore/FileInfoTests.java b/server/src/test/java/org/opensearch/index/snapshots/blobstore/FileInfoTests.java index 566a53c2508c8..057cffe94eace 100644 --- a/server/src/test/java/org/opensearch/index/snapshots/blobstore/FileInfoTests.java +++ b/server/src/test/java/org/opensearch/index/snapshots/blobstore/FileInfoTests.java @@ -40,7 +40,6 @@ import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo; import org.opensearch.index.store.StoreFileMetadata; @@ -73,7 +72,7 @@ public void testToFromXContent() throws IOException { ); ByteSizeValue size = new ByteSizeValue(Math.abs(randomLong())); BlobStoreIndexShardSnapshot.FileInfo info = new BlobStoreIndexShardSnapshot.FileInfo("_foobar", meta, size); - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON).prettyPrint(); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON).prettyPrint(); BlobStoreIndexShardSnapshot.FileInfo.toXContent(info, builder, ToXContent.EMPTY_PARAMS); byte[] xcontent = BytesReference.toBytes(BytesReference.bytes(shuffleXContent(builder))); @@ -126,7 +125,7 @@ public void testInvalidFieldsInFromXContent() throws IOException { fail("shouldn't be here"); } - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.startObject(); builder.field(FileInfo.NAME, name); builder.field(FileInfo.PHYSICAL_NAME, physicalName); diff --git a/server/src/test/java/org/opensearch/index/snapshots/blobstore/RemoteStoreShardShallowCopySnapshotTests.java b/server/src/test/java/org/opensearch/index/snapshots/blobstore/RemoteStoreShardShallowCopySnapshotTests.java index 6dc5cc23d2ff2..5dd4bf35cb422 100644 --- a/server/src/test/java/org/opensearch/index/snapshots/blobstore/RemoteStoreShardShallowCopySnapshotTests.java +++ b/server/src/test/java/org/opensearch/index/snapshots/blobstore/RemoteStoreShardShallowCopySnapshotTests.java @@ -9,7 +9,6 @@ package org.opensearch.index.snapshots.blobstore; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; @@ -56,7 +55,7 @@ public void testToXContent() throws IOException { fileNames ); String actual; - try (XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent())) { + try (XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder()) { builder.startObject(); shardShallowCopySnapshot.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); @@ -176,7 +175,7 @@ public void testFromXContentInvalid() throws IOException { fail("shouldn't be here"); } - XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); builder.startObject(); builder.field(RemoteStoreShardShallowCopySnapshot.VERSION, version); builder.field(RemoteStoreShardShallowCopySnapshot.NAME, snapshot); diff --git a/server/src/test/java/org/opensearch/index/translog/LocalTranslogTests.java b/server/src/test/java/org/opensearch/index/translog/LocalTranslogTests.java index 2433a33ebc7f2..7d681b3d57a4f 100644 --- a/server/src/test/java/org/opensearch/index/translog/LocalTranslogTests.java +++ b/server/src/test/java/org/opensearch/index/translog/LocalTranslogTests.java @@ -67,10 +67,10 @@ import org.opensearch.common.util.concurrent.AbstractRunnable; import org.opensearch.common.util.concurrent.ConcurrentCollections; import org.opensearch.common.util.concurrent.ReleasableLock; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; import org.opensearch.index.IndexSettings; import org.opensearch.index.VersionType; @@ -3505,7 +3505,7 @@ public void testTranslogOpSerialization() throws Exception { document.add(seqID.seqNo); document.add(seqID.seqNoDocValue); document.add(seqID.primaryTerm); - ParsedDocument doc = new ParsedDocument(versionField, seqID, "1", null, Arrays.asList(document), B_1, XContentType.JSON, null); + ParsedDocument doc = new ParsedDocument(versionField, seqID, "1", null, Arrays.asList(document), B_1, MediaTypeRegistry.JSON, null); Engine.Index eIndex = new Engine.Index( newUid(doc), diff --git a/server/src/test/java/org/opensearch/index/translog/TranslogManagerTestCase.java b/server/src/test/java/org/opensearch/index/translog/TranslogManagerTestCase.java index 91694060617ab..6975f101c72f7 100644 --- a/server/src/test/java/org/opensearch/index/translog/TranslogManagerTestCase.java +++ b/server/src/test/java/org/opensearch/index/translog/TranslogManagerTestCase.java @@ -23,9 +23,9 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.BigArrays; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.index.Index; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.engine.Engine; import org.opensearch.index.engine.EngineConfig; @@ -182,7 +182,7 @@ protected static ParsedDocument testParsedDocument( } else { document.add(new StoredField(SourceFieldMapper.NAME, ref.bytes, ref.offset, ref.length)); } - return new ParsedDocument(versionField, seqID, id, routing, List.of(document), source, XContentType.JSON, mappingUpdate); + return new ParsedDocument(versionField, seqID, id, routing, List.of(document), source, MediaTypeRegistry.JSON, mappingUpdate); } protected static ParseContext.Document testDocumentWithTextField() { diff --git a/server/src/test/java/org/opensearch/indices/IndexingMemoryControllerTests.java b/server/src/test/java/org/opensearch/indices/IndexingMemoryControllerTests.java index 19ed7122741aa..c91ed00547bff 100644 --- a/server/src/test/java/org/opensearch/indices/IndexingMemoryControllerTests.java +++ b/server/src/test/java/org/opensearch/indices/IndexingMemoryControllerTests.java @@ -38,7 +38,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.unit.ByteSizeValue; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.codec.CodecService; import org.opensearch.index.engine.EngineConfig; import org.opensearch.index.engine.InternalEngine; @@ -367,7 +367,7 @@ public void testThrottling() throws Exception { public void testTranslogRecoveryWorksWithIMC() throws IOException { IndexShard shard = newStartedShard(true); for (int i = 0; i < 100; i++) { - indexDoc(shard, Integer.toString(i), "{\"foo\" : \"bar\"}", XContentType.JSON, null); + indexDoc(shard, Integer.toString(i), "{\"foo\" : \"bar\"}", MediaTypeRegistry.JSON, null); } shard.close("simon says", false, false); AtomicReference shardRef = new AtomicReference<>(); diff --git a/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java b/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java index 2a03ddc6f46e4..9ebab1a9022a7 100644 --- a/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java +++ b/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java @@ -52,9 +52,9 @@ import org.opensearch.common.lucene.index.OpenSearchDirectoryReader; import org.opensearch.common.settings.Settings; import org.opensearch.core.common.unit.ByteSizeValue; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.common.util.io.IOUtils; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.cache.request.ShardRequestCache; import org.opensearch.index.query.TermQueryBuilder; import org.opensearch.core.index.shard.ShardId; @@ -75,7 +75,7 @@ public void testBasicOperationsCache() throws Exception { writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = OpenSearchDirectoryReader.wrap(DirectoryReader.open(writer), new ShardId("foo", "bar", 1)); TermQueryBuilder termQuery = new TermQueryBuilder("id", "0"); - BytesReference termBytes = XContentHelper.toXContent(termQuery, XContentType.JSON, false); + BytesReference termBytes = XContentHelper.toXContent(termQuery, MediaTypeRegistry.JSON, false); AtomicBoolean indexShard = new AtomicBoolean(true); // initial cache @@ -131,7 +131,7 @@ public void testCacheDifferentReaders() throws Exception { writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = OpenSearchDirectoryReader.wrap(DirectoryReader.open(writer), new ShardId("foo", "bar", 1)); TermQueryBuilder termQuery = new TermQueryBuilder("id", "0"); - BytesReference termBytes = XContentHelper.toXContent(termQuery, XContentType.JSON, false); + BytesReference termBytes = XContentHelper.toXContent(termQuery, MediaTypeRegistry.JSON, false); if (randomBoolean()) { writer.flush(); IOUtils.close(writer); @@ -227,7 +227,7 @@ public void testEviction() throws Exception { writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = OpenSearchDirectoryReader.wrap(DirectoryReader.open(writer), new ShardId("foo", "bar", 1)); TermQueryBuilder termQuery = new TermQueryBuilder("id", "0"); - BytesReference termBytes = XContentHelper.toXContent(termQuery, XContentType.JSON, false); + BytesReference termBytes = XContentHelper.toXContent(termQuery, MediaTypeRegistry.JSON, false); TestEntity entity = new TestEntity(requestCacheStats, indexShard); Loader loader = new Loader(reader, 0); @@ -254,7 +254,7 @@ public void testEviction() throws Exception { writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = OpenSearchDirectoryReader.wrap(DirectoryReader.open(writer), new ShardId("foo", "bar", 1)); TermQueryBuilder termQuery = new TermQueryBuilder("id", "0"); - BytesReference termBytes = XContentHelper.toXContent(termQuery, XContentType.JSON, false); + BytesReference termBytes = XContentHelper.toXContent(termQuery, MediaTypeRegistry.JSON, false); TestEntity entity = new TestEntity(requestCacheStats, indexShard); Loader loader = new Loader(reader, 0); @@ -291,7 +291,7 @@ public void testClearAllEntityIdentity() throws Exception { writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = OpenSearchDirectoryReader.wrap(DirectoryReader.open(writer), new ShardId("foo", "bar", 1)); TermQueryBuilder termQuery = new TermQueryBuilder("id", "0"); - BytesReference termBytes = XContentHelper.toXContent(termQuery, XContentType.JSON, false); + BytesReference termBytes = XContentHelper.toXContent(termQuery, MediaTypeRegistry.JSON, false); TestEntity entity = new TestEntity(requestCacheStats, indexShard); Loader loader = new Loader(reader, 0); @@ -373,7 +373,7 @@ public void testInvalidate() throws Exception { writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = OpenSearchDirectoryReader.wrap(DirectoryReader.open(writer), new ShardId("foo", "bar", 1)); TermQueryBuilder termQuery = new TermQueryBuilder("id", "0"); - BytesReference termBytes = XContentHelper.toXContent(termQuery, XContentType.JSON, false); + BytesReference termBytes = XContentHelper.toXContent(termQuery, MediaTypeRegistry.JSON, false); AtomicBoolean indexShard = new AtomicBoolean(true); // initial cache diff --git a/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java b/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java index 0b2de2acbb1d0..0eacb2c6c5b22 100644 --- a/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java +++ b/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java @@ -70,9 +70,9 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.CancellableThreads; import org.opensearch.common.util.concurrent.ConcurrentCollections; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; import org.opensearch.common.lease.Releasable; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.engine.Engine; import org.opensearch.index.engine.RecoveryEngineException; @@ -487,7 +487,7 @@ private Engine.Index getIndex(final String id) { null, Arrays.asList(document), source, - XContentType.JSON, + MediaTypeRegistry.JSON, null ); return new Engine.Index(new Term("_id", Uid.encodeId(doc.id())), randomNonNegativeLong(), doc); diff --git a/server/src/test/java/org/opensearch/indices/recovery/PeerRecoveryTargetServiceTests.java b/server/src/test/java/org/opensearch/indices/recovery/PeerRecoveryTargetServiceTests.java index 67811e24b03c4..cde2c4d5a677f 100644 --- a/server/src/test/java/org/opensearch/indices/recovery/PeerRecoveryTargetServiceTests.java +++ b/server/src/test/java/org/opensearch/indices/recovery/PeerRecoveryTargetServiceTests.java @@ -47,8 +47,8 @@ import org.opensearch.common.UUIDs; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.engine.EngineConfigFactory; import org.opensearch.index.engine.NoOpEngine; import org.opensearch.index.mapper.SourceToParse; @@ -189,7 +189,7 @@ private SeqNoStats populateRandomData(IndexShard shard) throws IOException { shard.getOperationPrimaryTerm(), IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(shard.shardId().getIndexName(), UUIDs.randomBase64UUID(), new BytesArray("{}"), XContentType.JSON) + new SourceToParse(shard.shardId().getIndexName(), UUIDs.randomBase64UUID(), new BytesArray("{}"), MediaTypeRegistry.JSON) ); if (randomInt(100) < 5) { shard.flush(new FlushRequest().waitIfOngoing(true)); diff --git a/server/src/test/java/org/opensearch/indices/recovery/RecoveryTests.java b/server/src/test/java/org/opensearch/indices/recovery/RecoveryTests.java index 2c45c9e177c52..de25d7cf527ee 100644 --- a/server/src/test/java/org/opensearch/indices/recovery/RecoveryTests.java +++ b/server/src/test/java/org/opensearch/indices/recovery/RecoveryTests.java @@ -51,7 +51,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.lucene.uid.Versions; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.MergePolicyConfig; import org.opensearch.index.VersionType; @@ -188,7 +188,7 @@ public void testRecoveryWithOutOfOrderDeleteWithSoftDeletes() throws Exception { 1, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(indexName, "id", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(indexName, "id", new BytesArray("{}"), MediaTypeRegistry.JSON) ); // index #3 orgReplica.applyIndexOperationOnReplica( @@ -198,7 +198,7 @@ public void testRecoveryWithOutOfOrderDeleteWithSoftDeletes() throws Exception { 1, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(indexName, "id-3", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(indexName, "id-3", new BytesArray("{}"), MediaTypeRegistry.JSON) ); // Flushing a new commit with local checkpoint=1 allows to delete the translog gen #1. orgReplica.flush(new FlushRequest().force(true).waitIfOngoing(true)); @@ -210,7 +210,7 @@ public void testRecoveryWithOutOfOrderDeleteWithSoftDeletes() throws Exception { 1, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(indexName, "id-2", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(indexName, "id-2", new BytesArray("{}"), MediaTypeRegistry.JSON) ); orgReplica.sync(); // advance local checkpoint orgReplica.updateGlobalCheckpointOnReplica(3L, "test"); @@ -222,7 +222,7 @@ public void testRecoveryWithOutOfOrderDeleteWithSoftDeletes() throws Exception { 1, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false, - new SourceToParse(indexName, "id-5", new BytesArray("{}"), XContentType.JSON) + new SourceToParse(indexName, "id-5", new BytesArray("{}"), MediaTypeRegistry.JSON) ); if (randomBoolean()) { @@ -331,7 +331,7 @@ public void testPeerRecoverySendSafeCommitInFileBased() throws Exception { Engine.IndexResult result = primaryShard.applyIndexOperationOnPrimary( Versions.MATCH_ANY, VersionType.INTERNAL, - new SourceToParse(primaryShard.shardId().getIndexName(), Integer.toString(i), new BytesArray("{}"), XContentType.JSON), + new SourceToParse(primaryShard.shardId().getIndexName(), Integer.toString(i), new BytesArray("{}"), MediaTypeRegistry.JSON), SequenceNumbers.UNASSIGNED_SEQ_NO, 0, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, @@ -498,7 +498,7 @@ public void testRecoveryTrimsLocalTranslog() throws Exception { } int inflightDocs = scaledRandomIntBetween(1, 100); for (int i = 0; i < inflightDocs; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName()).id("extra_" + i).source("{}", XContentType.JSON); + final IndexRequest indexRequest = new IndexRequest(index.getName()).id("extra_" + i).source("{}", MediaTypeRegistry.JSON); final BulkShardRequest bulkShardRequest = indexOnPrimary(indexRequest, oldPrimary); for (IndexShard replica : randomSubsetOf(shards.getReplicas())) { indexOnReplica(bulkShardRequest, shards, replica); diff --git a/server/src/test/java/org/opensearch/indices/replication/OngoingSegmentReplicationsTests.java b/server/src/test/java/org/opensearch/indices/replication/OngoingSegmentReplicationsTests.java index 84a53ae22a6bc..84f781b08e5f3 100644 --- a/server/src/test/java/org/opensearch/indices/replication/OngoingSegmentReplicationsTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/OngoingSegmentReplicationsTests.java @@ -15,7 +15,7 @@ import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.CancellableThreads; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.index.codec.CodecService; import org.opensearch.index.engine.NRTReplicationEngineFactory; @@ -94,7 +94,7 @@ public void tearDown() throws Exception { } public void testPrepareAndSendSegments() throws IOException { - indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar"); + indexDoc(primary, "1", "{\"foo\" : \"baz\"}", MediaTypeRegistry.JSON, "foobar"); primary.refresh("Test"); OngoingSegmentReplications replications = spy(new OngoingSegmentReplications(mockIndicesService, recoverySettings)); final CheckpointInfoRequest request = new CheckpointInfoRequest( @@ -162,7 +162,7 @@ public void testCancelReplication_AfterSendFilesStarts() throws IOException, Int CountDownLatch latch = new CountDownLatch(1); OngoingSegmentReplications replications = new OngoingSegmentReplications(mockIndicesService, recoverySettings); // add a doc and refresh so primary has more than one segment. - indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar"); + indexDoc(primary, "1", "{\"foo\" : \"baz\"}", MediaTypeRegistry.JSON, "foobar"); primary.refresh("Test"); final CheckpointInfoRequest request = new CheckpointInfoRequest( 1L, diff --git a/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceHandlerTests.java b/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceHandlerTests.java index b4e9166f377ec..ba993feb13362 100644 --- a/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceHandlerTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceHandlerTests.java @@ -19,7 +19,7 @@ import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.CancellableThreads; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.engine.NRTReplicationEngineFactory; import org.opensearch.index.shard.IndexShard; import org.opensearch.index.shard.IndexShardTestCase; @@ -140,7 +140,7 @@ public void onFailure(Exception e) { public void testSendFileFails() throws IOException { // index some docs on the primary so a segment is created. - indexDoc(primary, "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar"); + indexDoc(primary, "1", "{\"foo\" : \"baz\"}", MediaTypeRegistry.JSON, "foobar"); primary.refresh("Test"); chunkWriter = (fileMetadata, position, content, lastChunk, totalTranslogOps, listener) -> listener.onFailure( new OpenSearchException("Test") diff --git a/server/src/test/java/org/opensearch/ingest/IngestMetadataTests.java b/server/src/test/java/org/opensearch/ingest/IngestMetadataTests.java index 82e6e1c9ff450..dff9aaef81b53 100644 --- a/server/src/test/java/org/opensearch/ingest/IngestMetadataTests.java +++ b/server/src/test/java/org/opensearch/ingest/IngestMetadataTests.java @@ -57,12 +57,12 @@ public void testFromXContent() throws IOException { PipelineConfiguration pipeline = new PipelineConfiguration( "1", new BytesArray("{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\"}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); PipelineConfiguration pipeline2 = new PipelineConfiguration( "2", new BytesArray("{\"processors\": [{\"set\" : {\"field\": \"_field1\", \"value\": \"_value1\"}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); Map map = new HashMap<>(); map.put(pipeline.getId(), pipeline); @@ -90,14 +90,14 @@ public void testDiff() throws Exception { BytesReference pipelineConfig = new BytesArray("{}"); Map pipelines = new HashMap<>(); - pipelines.put("1", new PipelineConfiguration("1", pipelineConfig, XContentType.JSON)); - pipelines.put("2", new PipelineConfiguration("2", pipelineConfig, XContentType.JSON)); + pipelines.put("1", new PipelineConfiguration("1", pipelineConfig, MediaTypeRegistry.JSON)); + pipelines.put("2", new PipelineConfiguration("2", pipelineConfig, MediaTypeRegistry.JSON)); IngestMetadata ingestMetadata1 = new IngestMetadata(pipelines); pipelines = new HashMap<>(); - pipelines.put("1", new PipelineConfiguration("1", pipelineConfig, XContentType.JSON)); - pipelines.put("3", new PipelineConfiguration("3", pipelineConfig, XContentType.JSON)); - pipelines.put("4", new PipelineConfiguration("4", pipelineConfig, XContentType.JSON)); + pipelines.put("1", new PipelineConfiguration("1", pipelineConfig, MediaTypeRegistry.JSON)); + pipelines.put("3", new PipelineConfiguration("3", pipelineConfig, MediaTypeRegistry.JSON)); + pipelines.put("4", new PipelineConfiguration("4", pipelineConfig, MediaTypeRegistry.JSON)); IngestMetadata ingestMetadata2 = new IngestMetadata(pipelines); IngestMetadata.IngestMetadataDiff diff = (IngestMetadata.IngestMetadataDiff) ingestMetadata2.diff(ingestMetadata1); @@ -110,13 +110,13 @@ public void testDiff() throws Exception { IngestMetadata endResult = (IngestMetadata) diff.apply(ingestMetadata2); assertThat(endResult, not(equalTo(ingestMetadata1))); assertThat(endResult.getPipelines().size(), equalTo(3)); - assertThat(endResult.getPipelines().get("1"), equalTo(new PipelineConfiguration("1", pipelineConfig, XContentType.JSON))); - assertThat(endResult.getPipelines().get("3"), equalTo(new PipelineConfiguration("3", pipelineConfig, XContentType.JSON))); - assertThat(endResult.getPipelines().get("4"), equalTo(new PipelineConfiguration("4", pipelineConfig, XContentType.JSON))); + assertThat(endResult.getPipelines().get("1"), equalTo(new PipelineConfiguration("1", pipelineConfig, MediaTypeRegistry.JSON))); + assertThat(endResult.getPipelines().get("3"), equalTo(new PipelineConfiguration("3", pipelineConfig, MediaTypeRegistry.JSON))); + assertThat(endResult.getPipelines().get("4"), equalTo(new PipelineConfiguration("4", pipelineConfig, MediaTypeRegistry.JSON))); pipelines = new HashMap<>(); - pipelines.put("1", new PipelineConfiguration("1", new BytesArray("{}"), XContentType.JSON)); - pipelines.put("2", new PipelineConfiguration("2", new BytesArray("{}"), XContentType.JSON)); + pipelines.put("1", new PipelineConfiguration("1", new BytesArray("{}"), MediaTypeRegistry.JSON)); + pipelines.put("2", new PipelineConfiguration("2", new BytesArray("{}"), MediaTypeRegistry.JSON)); IngestMetadata ingestMetadata3 = new IngestMetadata(pipelines); diff = (IngestMetadata.IngestMetadataDiff) ingestMetadata3.diff(ingestMetadata1); @@ -126,12 +126,12 @@ public void testDiff() throws Exception { endResult = (IngestMetadata) diff.apply(ingestMetadata3); assertThat(endResult, equalTo(ingestMetadata1)); assertThat(endResult.getPipelines().size(), equalTo(2)); - assertThat(endResult.getPipelines().get("1"), equalTo(new PipelineConfiguration("1", pipelineConfig, XContentType.JSON))); - assertThat(endResult.getPipelines().get("2"), equalTo(new PipelineConfiguration("2", pipelineConfig, XContentType.JSON))); + assertThat(endResult.getPipelines().get("1"), equalTo(new PipelineConfiguration("1", pipelineConfig, MediaTypeRegistry.JSON))); + assertThat(endResult.getPipelines().get("2"), equalTo(new PipelineConfiguration("2", pipelineConfig, MediaTypeRegistry.JSON))); pipelines = new HashMap<>(); - pipelines.put("1", new PipelineConfiguration("1", new BytesArray("{}"), XContentType.JSON)); - pipelines.put("2", new PipelineConfiguration("2", new BytesArray("{\"key\" : \"value\"}"), XContentType.JSON)); + pipelines.put("1", new PipelineConfiguration("1", new BytesArray("{}"), MediaTypeRegistry.JSON)); + pipelines.put("2", new PipelineConfiguration("2", new BytesArray("{\"key\" : \"value\"}"), MediaTypeRegistry.JSON)); IngestMetadata ingestMetadata4 = new IngestMetadata(pipelines); diff = (IngestMetadata.IngestMetadataDiff) ingestMetadata4.diff(ingestMetadata1); @@ -141,10 +141,10 @@ public void testDiff() throws Exception { endResult = (IngestMetadata) diff.apply(ingestMetadata4); assertThat(endResult, not(equalTo(ingestMetadata1))); assertThat(endResult.getPipelines().size(), equalTo(2)); - assertThat(endResult.getPipelines().get("1"), equalTo(new PipelineConfiguration("1", pipelineConfig, XContentType.JSON))); + assertThat(endResult.getPipelines().get("1"), equalTo(new PipelineConfiguration("1", pipelineConfig, MediaTypeRegistry.JSON))); assertThat( endResult.getPipelines().get("2"), - equalTo(new PipelineConfiguration("2", new BytesArray("{\"key\" : \"value\"}"), XContentType.JSON)) + equalTo(new PipelineConfiguration("2", new BytesArray("{\"key\" : \"value\"}"), MediaTypeRegistry.JSON)) ); } } diff --git a/server/src/test/java/org/opensearch/ingest/IngestServiceTests.java b/server/src/test/java/org/opensearch/ingest/IngestServiceTests.java index 7f5ec52c3620c..ddc27f15ff18b 100644 --- a/server/src/test/java/org/opensearch/ingest/IngestServiceTests.java +++ b/server/src/test/java/org/opensearch/ingest/IngestServiceTests.java @@ -61,6 +61,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.OpenSearchExecutors; import org.opensearch.core.common.bytes.BytesArray; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.cbor.CborXContent; @@ -221,7 +222,7 @@ public void testUpdatePipelines() { PipelineConfiguration pipeline = new PipelineConfiguration( "_id", new BytesArray("{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\"}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); IngestMetadata ingestMetadata = new IngestMetadata(Collections.singletonMap("_id", pipeline)); clusterState = ClusterState.builder(clusterState) @@ -239,7 +240,7 @@ public void testInnerUpdatePipelines() { IngestService ingestService = createWithProcessors(); assertThat(ingestService.pipelines().size(), is(0)); - PipelineConfiguration pipeline1 = new PipelineConfiguration("_id1", new BytesArray("{\"processors\": []}"), XContentType.JSON); + PipelineConfiguration pipeline1 = new PipelineConfiguration("_id1", new BytesArray("{\"processors\": []}"), MediaTypeRegistry.JSON); IngestMetadata ingestMetadata = new IngestMetadata(mapOf("_id1", pipeline1)); ingestService.innerUpdatePipelines(ingestMetadata); @@ -247,7 +248,7 @@ public void testInnerUpdatePipelines() { assertThat(ingestService.pipelines().get("_id1").pipeline.getId(), equalTo("_id1")); assertThat(ingestService.pipelines().get("_id1").pipeline.getProcessors().size(), equalTo(0)); - PipelineConfiguration pipeline2 = new PipelineConfiguration("_id2", new BytesArray("{\"processors\": []}"), XContentType.JSON); + PipelineConfiguration pipeline2 = new PipelineConfiguration("_id2", new BytesArray("{\"processors\": []}"), MediaTypeRegistry.JSON); ingestMetadata = new IngestMetadata(mapOf("_id1", pipeline1, "_id2", pipeline2)); ingestService.innerUpdatePipelines(ingestMetadata); @@ -257,7 +258,7 @@ public void testInnerUpdatePipelines() { assertThat(ingestService.pipelines().get("_id2").pipeline.getId(), equalTo("_id2")); assertThat(ingestService.pipelines().get("_id2").pipeline.getProcessors().size(), equalTo(0)); - PipelineConfiguration pipeline3 = new PipelineConfiguration("_id3", new BytesArray("{\"processors\": []}"), XContentType.JSON); + PipelineConfiguration pipeline3 = new PipelineConfiguration("_id3", new BytesArray("{\"processors\": []}"), MediaTypeRegistry.JSON); ingestMetadata = new IngestMetadata(mapOf("_id1", pipeline1, "_id2", pipeline2, "_id3", pipeline3)); ingestService.innerUpdatePipelines(ingestMetadata); @@ -281,7 +282,7 @@ public void testInnerUpdatePipelines() { pipeline3 = new PipelineConfiguration( "_id3", new BytesArray("{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\"}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ingestMetadata = new IngestMetadata(mapOf("_id1", pipeline1, "_id3", pipeline3)); @@ -323,7 +324,7 @@ public void testDelete() { PipelineConfiguration config = new PipelineConfiguration( "_id", new BytesArray("{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\"}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); IngestMetadata ingestMetadata = new IngestMetadata(Collections.singletonMap("_id", config)); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); @@ -355,7 +356,7 @@ public void testValidateNoIngestInfo() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\"}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); Exception e = expectThrows(IllegalStateException.class, () -> ingestService.validatePipeline(emptyMap(), putRequest)); assertEquals("Ingest info is empty", e.getMessage()); @@ -384,7 +385,7 @@ public void testGetProcessorsInPipeline() throws Exception { "{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\", \"tag\": \"tag1\"}}," + "{\"remove\" : {\"field\": \"_field\", \"tag\": \"tag2\"}}]}" ), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); @@ -450,7 +451,7 @@ public void testGetProcessorsInPipelineComplexConditional() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( id, new BytesArray("{\"processors\": [{\"complexSet\" : {\"field\": \"_field\", \"value\": \"_value\"}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); @@ -476,7 +477,7 @@ public void testCrud() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( id, new BytesArray("{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\"}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); @@ -504,7 +505,7 @@ public void testPut() { ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // add a new pipeline: - PutPipelineRequest putRequest = new PutPipelineRequest(id, new BytesArray("{\"processors\": []}"), XContentType.JSON); + PutPipelineRequest putRequest = new PutPipelineRequest(id, new BytesArray("{\"processors\": []}"), MediaTypeRegistry.JSON); ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); @@ -518,7 +519,7 @@ public void testPut() { putRequest = new PutPipelineRequest( id, new BytesArray("{\"processors\": [], \"description\": \"_description\"}"), - XContentType.JSON + MediaTypeRegistry.JSON ); previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); @@ -540,7 +541,7 @@ public void testPutWithErrorResponse() throws IllegalAccessException { PutPipelineRequest putRequest = new PutPipelineRequest( id, new BytesArray("{\"description\": \"empty processors\"}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); @@ -572,9 +573,9 @@ public void testDeleteUsingWildcard() { IngestService ingestService = createWithProcessors(); HashMap pipelines = new HashMap<>(); BytesArray definition = new BytesArray("{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\"}}]}"); - pipelines.put("p1", new PipelineConfiguration("p1", definition, XContentType.JSON)); - pipelines.put("p2", new PipelineConfiguration("p2", definition, XContentType.JSON)); - pipelines.put("q1", new PipelineConfiguration("q1", definition, XContentType.JSON)); + pipelines.put("p1", new PipelineConfiguration("p1", definition, MediaTypeRegistry.JSON)); + pipelines.put("p2", new PipelineConfiguration("p2", definition, MediaTypeRegistry.JSON)); + pipelines.put("q1", new PipelineConfiguration("q1", definition, MediaTypeRegistry.JSON)); IngestMetadata ingestMetadata = new IngestMetadata(pipelines); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); ClusterState previousClusterState = clusterState; @@ -620,7 +621,7 @@ public void testDeleteWithExistingUnmatchedPipelines() { IngestService ingestService = createWithProcessors(); HashMap pipelines = new HashMap<>(); BytesArray definition = new BytesArray("{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\"}}]}"); - pipelines.put("p1", new PipelineConfiguration("p1", definition, XContentType.JSON)); + pipelines.put("p1", new PipelineConfiguration("p1", definition, MediaTypeRegistry.JSON)); IngestMetadata ingestMetadata = new IngestMetadata(pipelines); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); ClusterState previousClusterState = clusterState; @@ -641,8 +642,8 @@ public void testDeleteWithExistingUnmatchedPipelines() { public void testGetPipelines() { Map configs = new HashMap<>(); - configs.put("_id1", new PipelineConfiguration("_id1", new BytesArray("{\"processors\": []}"), XContentType.JSON)); - configs.put("_id2", new PipelineConfiguration("_id2", new BytesArray("{\"processors\": []}"), XContentType.JSON)); + configs.put("_id1", new PipelineConfiguration("_id1", new BytesArray("{\"processors\": []}"), MediaTypeRegistry.JSON)); + configs.put("_id2", new PipelineConfiguration("_id2", new BytesArray("{\"processors\": []}"), MediaTypeRegistry.JSON)); assertThat(IngestService.innerGetPipelines(null, "_id1").isEmpty(), is(true)); @@ -684,7 +685,7 @@ public void testValidate() throws Exception { "{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\", \"tag\": \"tag1\"}}," + "{\"remove\" : {\"field\": \"_field\", \"tag\": \"tag2\"}}]}" ), - XContentType.JSON + MediaTypeRegistry.JSON ); DiscoveryNode node1 = new DiscoveryNode("_node_id1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT); @@ -724,7 +725,7 @@ public String getType() { PutPipelineRequest putRequest = new PutPipelineRequest( id, new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); @@ -770,7 +771,7 @@ public void testExecuteBulkPipelineDoesNotExist() { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; @@ -817,7 +818,7 @@ public void testExecuteSuccess() { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; @@ -848,7 +849,7 @@ public void testExecuteEmptyPipeline() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [], \"description\": \"_description\"}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; @@ -882,7 +883,7 @@ public void testExecutePropagateAllMetadataUpdates() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; @@ -949,7 +950,7 @@ public void testExecuteFailure() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; @@ -1009,7 +1010,7 @@ public void testExecuteSuccessWithOnFailure() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; @@ -1052,7 +1053,7 @@ public void testExecuteFailureWithNestedOnFailure() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; @@ -1123,7 +1124,7 @@ public void testBulkRequestExecutionWithFailures() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; @@ -1181,7 +1182,7 @@ public void testBulkRequestExecution() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"mock\": {}}], \"description\": \"_description\"}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); ClusterState previousClusterState = clusterState; @@ -1241,13 +1242,13 @@ public void testStats() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( "_id1", new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); - putRequest = new PutPipelineRequest("_id2", new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), XContentType.JSON); + putRequest = new PutPipelineRequest("_id2", new BytesArray("{\"processors\": [{\"mock\" : {}}]}"), MediaTypeRegistry.JSON); previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); @@ -1307,7 +1308,7 @@ public void testStats() throws Exception { putRequest = new PutPipelineRequest( "_id1", new BytesArray("{\"processors\": [{\"mock\" : {}}, {\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); @@ -1340,7 +1341,7 @@ public void testStats() throws Exception { putRequest = new PutPipelineRequest( "_id1", new BytesArray("{\"processors\": [{\"failure-mock\" : { \"on_failure\": [{\"mock\" : {}}]}}, {\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); @@ -1418,7 +1419,7 @@ public String getDescription() { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"drop\" : {}}, {\"mock\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; @@ -1491,7 +1492,7 @@ public Map getProcessors(Processor.Parameters paramet PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"test\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); // Start empty ClusterState previousClusterState = clusterState; @@ -1514,7 +1515,7 @@ public void testCBORParsing() throws Exception { PutPipelineRequest putRequest = new PutPipelineRequest( "_id", new BytesArray("{\"processors\": [{\"foo\" : {}}]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); diff --git a/server/src/test/java/org/opensearch/ingest/PipelineConfigurationTests.java b/server/src/test/java/org/opensearch/ingest/PipelineConfigurationTests.java index aed08c2d1875a..c3ff0f19aafa5 100644 --- a/server/src/test/java/org/opensearch/ingest/PipelineConfigurationTests.java +++ b/server/src/test/java/org/opensearch/ingest/PipelineConfigurationTests.java @@ -38,6 +38,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.xcontent.ContextParser; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -56,15 +57,15 @@ public void testSerialization() throws IOException { PipelineConfiguration configuration = new PipelineConfiguration( "1", new BytesArray("{}".getBytes(StandardCharsets.UTF_8)), - XContentType.JSON + MediaTypeRegistry.JSON ); - assertEquals(XContentType.JSON, configuration.getMediaType()); + assertEquals(MediaTypeRegistry.JSON, configuration.getMediaType()); BytesStreamOutput out = new BytesStreamOutput(); configuration.writeTo(out); StreamInput in = StreamInput.wrap(out.bytes().toBytesRef().bytes); PipelineConfiguration serialized = PipelineConfiguration.readFrom(in); - assertEquals(XContentType.JSON, serialized.getMediaType()); + assertEquals(MediaTypeRegistry.JSON, serialized.getMediaType()); assertEquals("{}", serialized.getConfig().utf8ToString()); } @@ -73,7 +74,7 @@ public void testParser() throws IOException { XContentType xContentType = randomFrom(XContentType.values()); final BytesReference bytes; try (XContentBuilder builder = XContentBuilder.builder(xContentType.xContent())) { - new PipelineConfiguration("1", new BytesArray("{}".getBytes(StandardCharsets.UTF_8)), XContentType.JSON).toXContent( + new PipelineConfiguration("1", new BytesArray("{}".getBytes(StandardCharsets.UTF_8)), MediaTypeRegistry.JSON).toXContent( builder, ToXContent.EMPTY_PARAMS ); @@ -96,7 +97,7 @@ protected PipelineConfiguration createTestInstance() { } else { config = new BytesArray("{\"foo\": \"bar\"}".getBytes(StandardCharsets.UTF_8)); } - return new PipelineConfiguration(randomAlphaOfLength(4), config, XContentType.JSON); + return new PipelineConfiguration(randomAlphaOfLength(4), config, MediaTypeRegistry.JSON); } @Override diff --git a/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java b/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java index a0f58e68fcbb4..217fa7cf2d56c 100644 --- a/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java +++ b/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java @@ -60,9 +60,9 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.settings.SettingsModule; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -300,7 +300,7 @@ public void writeTo(StreamOutput out) throws IOException { @Override public String toString() { - return Strings.toString(XContentType.JSON, this); + return Strings.toString(MediaTypeRegistry.JSON, this); } // Implements equals and hashcode for testing diff --git a/server/src/test/java/org/opensearch/repositories/RepositoryDataTests.java b/server/src/test/java/org/opensearch/repositories/RepositoryDataTests.java index 26e4a2844a4ce..5bd366d7cea9d 100644 --- a/server/src/test/java/org/opensearch/repositories/RepositoryDataTests.java +++ b/server/src/test/java/org/opensearch/repositories/RepositoryDataTests.java @@ -36,6 +36,7 @@ import org.opensearch.Version; import org.opensearch.common.UUIDs; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -296,7 +297,7 @@ public void testIndexThatReferencesAnUnknownSnapshot() throws IOException { } public void testIndexThatReferenceANullSnapshot() throws IOException { - final XContentBuilder builder = XContentBuilder.builder(randomFrom(XContentType.JSON).xContent()); + final XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder(); builder.startObject(); { builder.startArray("snapshots"); diff --git a/server/src/test/java/org/opensearch/rest/BaseRestHandlerTests.java b/server/src/test/java/org/opensearch/rest/BaseRestHandlerTests.java index 1f5e0cda883c5..efc6645ed83d4 100644 --- a/server/src/test/java/org/opensearch/rest/BaseRestHandlerTests.java +++ b/server/src/test/java/org/opensearch/rest/BaseRestHandlerTests.java @@ -36,8 +36,8 @@ import org.opensearch.common.Table; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.rest.action.cat.AbstractCatAction; import org.opensearch.test.OpenSearchTestCase; @@ -299,7 +299,7 @@ public String getName() { try (XContentBuilder builder = JsonXContent.contentBuilder().startObject().endObject()) { final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray(builder.toString()), - XContentType.JSON + MediaTypeRegistry.JSON ).build(); final RestChannel channel = new FakeRestChannel(request, randomBoolean(), 1); handler.handleRequest(request, channel, mockClient); @@ -344,7 +344,7 @@ public String getName() { try (XContentBuilder builder = JsonXContent.contentBuilder().startObject().endObject()) { final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray(builder.toString()), - XContentType.JSON + MediaTypeRegistry.JSON ).build(); final RestChannel channel = new FakeRestChannel(request, randomBoolean(), 1); final IllegalArgumentException e = expectThrows( diff --git a/server/src/test/java/org/opensearch/rest/RestControllerTests.java b/server/src/test/java/org/opensearch/rest/RestControllerTests.java index b4fa7574f0ff0..77883491ce5d8 100644 --- a/server/src/test/java/org/opensearch/rest/RestControllerTests.java +++ b/server/src/test/java/org/opensearch/rest/RestControllerTests.java @@ -44,6 +44,8 @@ import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.core.rest.RestStatus; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.yaml.YamlXContent; @@ -290,7 +292,7 @@ public void testRestHandlerWrapper() throws Exception { return (RestRequest request, RestChannel channel, NodeClient client) -> wrapperCalled.set(true); }, client, circuitBreakerService, usageService, identityService); restController.registerHandler(RestRequest.Method.GET, "/wrapped", handler); - RestRequest request = testRestRequest("/wrapped", "{}", XContentType.JSON); + RestRequest request = testRestRequest("/wrapped", "{}", MediaTypeRegistry.JSON); AssertingChannel channel = new AssertingChannel(request, true, RestStatus.BAD_REQUEST); restController.dispatchRequest(request, channel, client.threadPool().getThreadContext()); httpServerTransport.start(); @@ -301,7 +303,7 @@ public void testRestHandlerWrapper() throws Exception { public void testDispatchRequestAddsAndFreesBytesOnSuccess() { int contentLength = BREAKER_LIMIT.bytesAsInt(); String content = randomAlphaOfLength((int) Math.round(contentLength / inFlightRequestsBreaker.getOverhead())); - RestRequest request = testRestRequest("/", content, XContentType.JSON); + RestRequest request = testRestRequest("/", content, MediaTypeRegistry.JSON); AssertingChannel channel = new AssertingChannel(request, true, RestStatus.OK); restController.dispatchRequest(request, channel, client.threadPool().getThreadContext()); @@ -313,7 +315,7 @@ public void testDispatchRequestAddsAndFreesBytesOnSuccess() { public void testDispatchRequestAddsAndFreesBytesOnError() { int contentLength = BREAKER_LIMIT.bytesAsInt(); String content = randomAlphaOfLength((int) Math.round(contentLength / inFlightRequestsBreaker.getOverhead())); - RestRequest request = testRestRequest("/error", content, XContentType.JSON); + RestRequest request = testRestRequest("/error", content, MediaTypeRegistry.JSON); AssertingChannel channel = new AssertingChannel(request, true, RestStatus.BAD_REQUEST); restController.dispatchRequest(request, channel, client.threadPool().getThreadContext()); @@ -326,7 +328,7 @@ public void testDispatchRequestAddsAndFreesBytesOnlyOnceOnError() { int contentLength = BREAKER_LIMIT.bytesAsInt(); String content = randomAlphaOfLength((int) Math.round(contentLength / inFlightRequestsBreaker.getOverhead())); // we will produce an error in the rest handler and one more when sending the error response - RestRequest request = testRestRequest("/error", content, XContentType.JSON); + RestRequest request = testRestRequest("/error", content, MediaTypeRegistry.JSON); ExceptionThrowingChannel channel = new ExceptionThrowingChannel(request, true); restController.dispatchRequest(request, channel, client.threadPool().getThreadContext()); @@ -338,7 +340,7 @@ public void testDispatchRequestAddsAndFreesBytesOnlyOnceOnError() { public void testDispatchRequestLimitsBytes() { int contentLength = BREAKER_LIMIT.bytesAsInt() + 1; String content = randomAlphaOfLength((int) Math.round(contentLength / inFlightRequestsBreaker.getOverhead())); - RestRequest request = testRestRequest("/", content, XContentType.JSON); + RestRequest request = testRestRequest("/", content, MediaTypeRegistry.JSON); AssertingChannel channel = new AssertingChannel(request, true, RestStatus.TOO_MANY_REQUESTS); restController.dispatchRequest(request, channel, client.threadPool().getThreadContext()); @@ -576,7 +578,7 @@ public void testHandleBadRequestWithHtmlSpecialCharsInUri() { public void testHandleBadInputWithCreateIndex() { final FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY).withPath("/foo") .withMethod(RestRequest.Method.PUT) - .withContent(new BytesArray("ddd"), XContentType.JSON) + .withContent(new BytesArray("ddd"), MediaTypeRegistry.JSON) .build(); final AssertingChannel channel = new AssertingChannel(fakeRestRequest, true, RestStatus.BAD_REQUEST); restController.registerHandler(RestRequest.Method.PUT, "/foo", new RestCreateIndexAction()); @@ -731,10 +733,10 @@ public void sendResponse(RestResponse response) { } } - private static RestRequest testRestRequest(String path, String content, XContentType xContentType) { + private static RestRequest testRestRequest(String path, String content, MediaType mediaType) { FakeRestRequest.Builder builder = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY); builder.withPath(path); - builder.withContent(new BytesArray(content), xContentType); + builder.withContent(new BytesArray(content), mediaType); return builder.build(); } } diff --git a/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterAddWeightedRoutingActionTests.java b/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterAddWeightedRoutingActionTests.java index 4d61ccad10b45..13dc418d07296 100644 --- a/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterAddWeightedRoutingActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterAddWeightedRoutingActionTests.java @@ -13,7 +13,7 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterPutWeightedRoutingRequest; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.rest.RestRequest; import org.opensearch.test.rest.FakeRestRequest; import org.opensearch.test.rest.RestActionTestCase; @@ -70,7 +70,7 @@ private RestRequest buildRestRequest(String content) { return new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.PUT) .withPath("/_cluster/routing/awareness/zone/weights") .withParams(singletonMap("attribute", "zone")) - .withContent(new BytesArray(content), XContentType.JSON) + .withContent(new BytesArray(content), MediaTypeRegistry.JSON) .build(); } diff --git a/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterDeleteWeightedRoutingActionTests.java b/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterDeleteWeightedRoutingActionTests.java index b11103a9cab11..1214accf91961 100644 --- a/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterDeleteWeightedRoutingActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterDeleteWeightedRoutingActionTests.java @@ -12,7 +12,7 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.action.admin.cluster.shards.routing.weighted.delete.ClusterDeleteWeightedRoutingRequest; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.rest.RestRequest; import org.opensearch.test.rest.FakeRestRequest; import org.opensearch.test.rest.RestActionTestCase; @@ -57,14 +57,14 @@ private RestRequest buildRestRequestWithAwarenessAttribute(String content) { return new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.DELETE) .withPath("/_cluster/routing/awareness/zone/weights") .withParams(singletonMap("attribute", "zone")) - .withContent(new BytesArray(content), XContentType.JSON) + .withContent(new BytesArray(content), MediaTypeRegistry.JSON) .build(); } private RestRequest buildRestRequest(String content) { return new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.DELETE) .withPath("/_cluster/routing/awareness/weights") - .withContent(new BytesArray(content), XContentType.JSON) + .withContent(new BytesArray(content), MediaTypeRegistry.JSON) .build(); } diff --git a/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestReloadSecureSettingsActionTests.java b/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestReloadSecureSettingsActionTests.java index d8f460dccbf4e..e976886458f05 100644 --- a/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestReloadSecureSettingsActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestReloadSecureSettingsActionTests.java @@ -34,9 +34,9 @@ import org.opensearch.action.admin.cluster.node.reload.NodesReloadSecureSettingsRequest; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.test.OpenSearchTestCase; import static org.hamcrest.Matchers.nullValue; @@ -46,7 +46,7 @@ public class RestReloadSecureSettingsActionTests extends OpenSearchTestCase { public void testParserWithPassword() throws Exception { final String request = "{" + "\"secure_settings_password\": \"secure_settings_password_string\"" + "}"; try ( - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, request) ) { NodesReloadSecureSettingsRequest reloadSecureSettingsRequest = RestReloadSecureSettingsAction.PARSER.parse(parser, null); @@ -57,7 +57,7 @@ public void testParserWithPassword() throws Exception { public void testParserWithoutPassword() throws Exception { final String request = "{" + "}"; try ( - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, request) ) { NodesReloadSecureSettingsRequest reloadSecureSettingsRequest = RestReloadSecureSettingsAction.PARSER.parse(parser, null); diff --git a/server/src/test/java/org/opensearch/rest/action/admin/indices/RestAnalyzeActionTests.java b/server/src/test/java/org/opensearch/rest/action/admin/indices/RestAnalyzeActionTests.java index 1c6c4eca6ca0d..ed16f3c681ae6 100644 --- a/server/src/test/java/org/opensearch/rest/action/admin/indices/RestAnalyzeActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/admin/indices/RestAnalyzeActionTests.java @@ -35,8 +35,8 @@ import org.opensearch.client.node.NodeClient; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.analysis.NameOrDefinition; import org.opensearch.rest.RestRequest; import org.opensearch.test.OpenSearchTestCase; @@ -118,7 +118,7 @@ public void testParseXContentForAnalyzeRequestWithInvalidJsonThrowsException() { RestAnalyzeAction action = new RestAnalyzeAction(); RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray("{invalid_json}"), - XContentType.JSON + MediaTypeRegistry.JSON ).build(); try (NodeClient client = new NoOpNodeClient(this.getClass().getSimpleName())) { IOException e = expectThrows(IOException.class, () -> action.handleRequest(request, null, client)); diff --git a/server/src/test/java/org/opensearch/rest/action/admin/indices/RestGetAliasesActionTests.java b/server/src/test/java/org/opensearch/rest/action/admin/indices/RestGetAliasesActionTests.java index 1fbc628ed7f2c..3d60f6029e564 100644 --- a/server/src/test/java/org/opensearch/rest/action/admin/indices/RestGetAliasesActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/admin/indices/RestGetAliasesActionTests.java @@ -35,7 +35,6 @@ import org.opensearch.cluster.metadata.AliasMetadata; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.rest.RestResponse; import org.opensearch.test.OpenSearchTestCase; @@ -60,7 +59,7 @@ public class RestGetAliasesActionTests extends OpenSearchTestCase { // }' public void testBareRequest() throws Exception { - final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); final Map> openMapBuilder = new HashMap<>(); final AliasMetadata foobarAliasMetadata = AliasMetadata.builder("foobar").build(); final AliasMetadata fooAliasMetadata = AliasMetadata.builder("foo").build(); @@ -72,7 +71,7 @@ public void testBareRequest() throws Exception { } public void testSimpleAliasWildcardMatchingNothing() throws Exception { - final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); final Map> openMapBuilder = new HashMap<>(); final RestResponse restResponse = RestGetAliasesAction.buildRestResponse( true, @@ -86,7 +85,7 @@ public void testSimpleAliasWildcardMatchingNothing() throws Exception { } public void testMultipleAliasWildcardsSomeMatching() throws Exception { - final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); final Map> openMapBuilder = new HashMap<>(); final AliasMetadata aliasMetadata = AliasMetadata.builder("foobar").build(); openMapBuilder.put("index", Arrays.asList(aliasMetadata)); @@ -102,7 +101,7 @@ public void testMultipleAliasWildcardsSomeMatching() throws Exception { } public void testAliasWildcardsIncludeAndExcludeAll() throws Exception { - final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); final Map> openMapBuilder = new HashMap<>(); final RestResponse restResponse = RestGetAliasesAction.buildRestResponse( true, @@ -116,7 +115,7 @@ public void testAliasWildcardsIncludeAndExcludeAll() throws Exception { } public void testAliasWildcardsIncludeAndExcludeSome() throws Exception { - final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); final Map> openMapBuilder = new HashMap<>(); final AliasMetadata aliasMetadata = AliasMetadata.builder("foo").build(); openMapBuilder.put("index", Arrays.asList(aliasMetadata)); @@ -132,7 +131,7 @@ public void testAliasWildcardsIncludeAndExcludeSome() throws Exception { } public void testAliasWildcardsIncludeAndExcludeSomeAndExplicitMissing() throws Exception { - final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); final Map> openMapBuilder = new HashMap<>(); final AliasMetadata aliasMetadata = AliasMetadata.builder("foo").build(); openMapBuilder.put("index", Arrays.asList(aliasMetadata)); @@ -153,7 +152,7 @@ public void testAliasWildcardsIncludeAndExcludeSomeAndExplicitMissing() throws E } public void testAliasWildcardsExcludeExplicitMissing() throws Exception { - final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(XContentType.JSON); + final XContentBuilder xContentBuilder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON); final Map> openMapBuilder = new HashMap<>(); final RestResponse restResponse = RestGetAliasesAction.buildRestResponse( true, diff --git a/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java b/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java index 2f15090e49f75..6b463c3697162 100644 --- a/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java @@ -43,7 +43,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.identity.IdentityService; import org.opensearch.core.indices.breaker.NoneCircuitBreakerService; import org.opensearch.rest.RestController; @@ -182,7 +182,7 @@ public void testRestValidateQueryAction_malformedQuery() throws Exception { private RestRequest createRestRequest(String content) { return new FakeRestRequest.Builder(xContentRegistry()).withPath("index1/type1/_validate/query") .withParams(emptyMap()) - .withContent(new BytesArray(content), XContentType.JSON) + .withContent(new BytesArray(content), MediaTypeRegistry.JSON) .build(); } } diff --git a/server/src/test/java/org/opensearch/rest/action/cat/RestTableTests.java b/server/src/test/java/org/opensearch/rest/action/cat/RestTableTests.java index 89fbcf6a3506d..8183cb1d3b910 100644 --- a/server/src/test/java/org/opensearch/rest/action/cat/RestTableTests.java +++ b/server/src/test/java/org/opensearch/rest/action/cat/RestTableTests.java @@ -34,6 +34,7 @@ import org.opensearch.common.Table; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.rest.AbstractRestChannel; import org.opensearch.rest.RestResponse; import org.opensearch.test.OpenSearchTestCase; @@ -55,7 +56,7 @@ public class RestTableTests extends OpenSearchTestCase { - private static final String APPLICATION_JSON = XContentType.JSON.mediaType(); + private static final String APPLICATION_JSON = MediaTypeRegistry.JSON.mediaType(); private static final String APPLICATION_YAML = XContentType.YAML.mediaType(); private static final String APPLICATION_SMILE = XContentType.SMILE.mediaType(); private static final String APPLICATION_CBOR = XContentType.CBOR.mediaType(); diff --git a/server/src/test/java/org/opensearch/rest/action/document/RestBulkActionTests.java b/server/src/test/java/org/opensearch/rest/action/document/RestBulkActionTests.java index f795d340778cf..9462a8f419bbf 100644 --- a/server/src/test/java/org/opensearch/rest/action/document/RestBulkActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/document/RestBulkActionTests.java @@ -40,7 +40,7 @@ import org.opensearch.client.node.NodeClient; import org.opensearch.common.SetOnce; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; import org.opensearch.test.OpenSearchTestCase; @@ -82,7 +82,7 @@ public void bulk(BulkRequest request, ActionListener listener) { + "{\"update\":{\"_id\":\"2\"}}\n" + "{\"script\":{\"source\":\"ctx._source.counter++;\"},\"upsert\":{\"field1\":\"upserted_val\"}}\n" ), - XContentType.JSON + MediaTypeRegistry.JSON ) .withMethod(RestRequest.Method.POST) .build(), diff --git a/server/src/test/java/org/opensearch/rest/action/document/RestIndexActionTests.java b/server/src/test/java/org/opensearch/rest/action/document/RestIndexActionTests.java index 4131e8d9a55c6..4bb11965a46e9 100644 --- a/server/src/test/java/org/opensearch/rest/action/document/RestIndexActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/document/RestIndexActionTests.java @@ -41,7 +41,7 @@ import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.common.SetOnce; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.rest.RestRequest; import org.opensearch.rest.action.document.RestIndexAction.AutoIdHandler; import org.opensearch.rest.action.document.RestIndexAction.CreateHandler; @@ -104,7 +104,7 @@ private void checkAutoIdOpType(Version minClusterVersion, DocWriteRequest.OpType }); RestRequest autoIdRequest = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.POST) .withPath("/some_index/_doc") - .withContent(new BytesArray("{}"), XContentType.JSON) + .withContent(new BytesArray("{}"), MediaTypeRegistry.JSON) .build(); clusterStateSupplier.set( ClusterState.builder(ClusterName.DEFAULT) diff --git a/server/src/test/java/org/opensearch/rest/action/document/RestUpdateActionTests.java b/server/src/test/java/org/opensearch/rest/action/document/RestUpdateActionTests.java index f66f07a22e660..67f45467d0052 100644 --- a/server/src/test/java/org/opensearch/rest/action/document/RestUpdateActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/document/RestUpdateActionTests.java @@ -35,7 +35,7 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.client.node.NodeClient; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.VersionType; import org.opensearch.rest.RestRequest; import org.opensearch.test.rest.FakeRestRequest; @@ -72,7 +72,7 @@ public void testUpdateDocVersion() { FakeRestRequest updateRequest = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.POST) .withPath("test/_update/1") .withParams(params) - .withContent(new BytesArray(content), XContentType.JSON) + .withContent(new BytesArray(content), MediaTypeRegistry.JSON) .build(); ActionRequestValidationException e = expectThrows( ActionRequestValidationException.class, diff --git a/server/src/test/java/org/opensearch/script/ScriptContextInfoTests.java b/server/src/test/java/org/opensearch/script/ScriptContextInfoTests.java index e10e199c4415c..e4118401711d6 100644 --- a/server/src/test/java/org/opensearch/script/ScriptContextInfoTests.java +++ b/server/src/test/java/org/opensearch/script/ScriptContextInfoTests.java @@ -35,11 +35,11 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.collect.Tuple; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.script.ScriptContextInfo.ScriptMethodInfo; import org.opensearch.script.ScriptContextInfo.ScriptMethodInfo.ParameterInfo; import org.opensearch.test.OpenSearchTestCase; @@ -317,7 +317,7 @@ public void testGetterConditional() { public void testParameterInfoParser() throws IOException { XContentBuilder builder = XContentFactory.jsonBuilder(); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, @@ -330,7 +330,7 @@ public void testParameterInfoParser() throws IOException { public void testScriptMethodInfoParser() throws IOException { String json = "{\"name\": \"fooFunc\", \"return_type\": \"int\", \"params\": [{\"type\": \"int\", \"name\": \"fooParam\"}, " + "{\"type\": \"java.util.Map\", \"name\": \"barParam\"}]}"; - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, new BytesArray(json).streamInput()); ScriptContextInfo.ScriptMethodInfo info = ScriptContextInfo.ScriptMethodInfo.fromXContent(parser); assertEquals( @@ -395,7 +395,7 @@ public void testScriptContextInfoParser() throws IOException { + " }" + " ]" + "}"; - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, new BytesArray(json).streamInput()); ScriptContextInfo parsed = ScriptContextInfo.fromXContent(parser); ScriptContextInfo expected = new ScriptContextInfo( diff --git a/server/src/test/java/org/opensearch/script/ScriptMetadataTests.java b/server/src/test/java/org/opensearch/script/ScriptMetadataTests.java index 83e7a3712a9ad..0ac530e6d14f9 100644 --- a/server/src/test/java/org/opensearch/script/ScriptMetadataTests.java +++ b/server/src/test/java/org/opensearch/script/ScriptMetadataTests.java @@ -37,6 +37,7 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; @@ -54,7 +55,7 @@ public void testFromXContentLoading() throws Exception { // failure to load to old namespace scripts with the same id but different langs XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject().field("lang0#id0", "script0").field("lang1#id0", "script1").endObject(); - XContentParser parser0 = XContentType.JSON.xContent() + XContentParser parser0 = MediaTypeRegistry.JSON.xContent() .createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, @@ -71,7 +72,7 @@ public void testFromXContentLoading() throws Exception { .field("source", "script1") .endObject() .endObject(); - XContentParser parser1 = XContentType.JSON.xContent() + XContentParser parser1 = MediaTypeRegistry.JSON.xContent() .createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, @@ -93,7 +94,7 @@ public void testFromXContentLoading() throws Exception { .field("source", "script1") .endObject() .endObject(); - XContentParser parser2 = XContentType.JSON.xContent() + XContentParser parser2 = MediaTypeRegistry.JSON.xContent() .createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, @@ -110,7 +111,7 @@ public void testFromXContentLoading() throws Exception { .field("source", "script1") .endObject() .endObject(); - XContentParser parser3 = XContentType.JSON.xContent() + XContentParser parser3 = MediaTypeRegistry.JSON.xContent() .createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, @@ -148,15 +149,24 @@ public void testDiff() throws Exception { ScriptMetadata.Builder builder = new ScriptMetadata.Builder(null); builder.storeScript( "1", - StoredScriptSource.parse(new BytesArray("{\"script\":{\"lang\":\"mustache\",\"source\":{\"foo\":\"abc\"}}}"), XContentType.JSON) + StoredScriptSource.parse( + new BytesArray("{\"script\":{\"lang\":\"mustache\",\"source\":{\"foo\":\"abc\"}}}"), + MediaTypeRegistry.JSON + ) ); builder.storeScript( "2", - StoredScriptSource.parse(new BytesArray("{\"script\":{\"lang\":\"mustache\",\"source\":{\"foo\":\"def\"}}}"), XContentType.JSON) + StoredScriptSource.parse( + new BytesArray("{\"script\":{\"lang\":\"mustache\",\"source\":{\"foo\":\"def\"}}}"), + MediaTypeRegistry.JSON + ) ); builder.storeScript( "3", - StoredScriptSource.parse(new BytesArray("{\"script\":{\"lang\":\"mustache\",\"source\":{\"foo\":\"ghi\"}}}"), XContentType.JSON) + StoredScriptSource.parse( + new BytesArray("{\"script\":{\"lang\":\"mustache\",\"source\":{\"foo\":\"ghi\"}}}"), + MediaTypeRegistry.JSON + ) ); ScriptMetadata scriptMetadata1 = builder.build(); @@ -165,13 +175,16 @@ public void testDiff() throws Exception { "2", StoredScriptSource.parse( new BytesArray("{\"script\":{\"lang\":\"mustache\",\"source\":{\"foo\":\"changed\"}}}"), - XContentType.JSON + MediaTypeRegistry.JSON ) ); builder.deleteScript("3"); builder.storeScript( "4", - StoredScriptSource.parse(new BytesArray("{\"script\":{\"lang\":\"mustache\",\"source\":{\"foo\":\"jkl\"}}}"), XContentType.JSON) + StoredScriptSource.parse( + new BytesArray("{\"script\":{\"lang\":\"mustache\",\"source\":{\"foo\":\"jkl\"}}}"), + MediaTypeRegistry.JSON + ) ); ScriptMetadata scriptMetadata2 = builder.build(); @@ -193,7 +206,10 @@ public void testBuilder() { ScriptMetadata.Builder builder = new ScriptMetadata.Builder(null); builder.storeScript( "_id", - StoredScriptSource.parse(new BytesArray("{\"script\": {\"lang\": \"painless\", \"source\": \"1 + 1\"} }"), XContentType.JSON) + StoredScriptSource.parse( + new BytesArray("{\"script\": {\"lang\": \"painless\", \"source\": \"1 + 1\"} }"), + MediaTypeRegistry.JSON + ) ); ScriptMetadata result = builder.build(); @@ -203,7 +219,7 @@ public void testBuilder() { public void testLoadEmptyScripts() throws IOException { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject().field("mustache#empty", "").endObject(); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, @@ -214,7 +230,7 @@ public void testLoadEmptyScripts() throws IOException { builder = XContentFactory.jsonBuilder(); builder.startObject().field("lang#empty", "").endObject(); - parser = XContentType.JSON.xContent() + parser = MediaTypeRegistry.JSON.xContent() .createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, @@ -225,7 +241,7 @@ public void testLoadEmptyScripts() throws IOException { builder = XContentFactory.jsonBuilder(); builder.startObject().startObject("script").field("lang", "lang").field("source", "").endObject().endObject(); - parser = XContentType.JSON.xContent() + parser = MediaTypeRegistry.JSON.xContent() .createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, @@ -236,7 +252,7 @@ public void testLoadEmptyScripts() throws IOException { builder = XContentFactory.jsonBuilder(); builder.startObject().startObject("script").field("lang", "mustache").field("source", "").endObject().endObject(); - parser = XContentType.JSON.xContent() + parser = MediaTypeRegistry.JSON.xContent() .createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, @@ -247,7 +263,7 @@ public void testLoadEmptyScripts() throws IOException { } public void testOldStyleDropped() throws IOException { - XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); + XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder(); builder.startObject(); { @@ -272,7 +288,7 @@ public void testOldStyleDropped() throws IOException { } builder.endObject(); - XContentParser parser = XContentType.JSON.xContent() + XContentParser parser = MediaTypeRegistry.JSON.xContent() .createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, diff --git a/server/src/test/java/org/opensearch/script/ScriptServiceTests.java b/server/src/test/java/org/opensearch/script/ScriptServiceTests.java index a4288eeab4524..2c9e32acd0d91 100644 --- a/server/src/test/java/org/opensearch/script/ScriptServiceTests.java +++ b/server/src/test/java/org/opensearch/script/ScriptServiceTests.java @@ -44,7 +44,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.env.Environment; import org.opensearch.test.OpenSearchTestCase; import org.junit.Before; @@ -375,7 +375,11 @@ public void testStoreScript() throws Exception { .endObject() .endObject() ); - ScriptMetadata scriptMetadata = ScriptMetadata.putStoredScript(null, "_id", StoredScriptSource.parse(script, XContentType.JSON)); + ScriptMetadata scriptMetadata = ScriptMetadata.putStoredScript( + null, + "_id", + StoredScriptSource.parse(script, MediaTypeRegistry.JSON) + ); assertNotNull(scriptMetadata); assertEquals("abc", scriptMetadata.getStoredScript("_id").getSource()); } @@ -384,7 +388,7 @@ public void testDeleteScript() throws Exception { ScriptMetadata scriptMetadata = ScriptMetadata.putStoredScript( null, "_id", - StoredScriptSource.parse(new BytesArray("{\"script\": {\"lang\": \"_lang\", \"source\": \"abc\"} }"), XContentType.JSON) + StoredScriptSource.parse(new BytesArray("{\"script\": {\"lang\": \"_lang\", \"source\": \"abc\"} }"), MediaTypeRegistry.JSON) ); scriptMetadata = ScriptMetadata.deleteStoredScript(scriptMetadata, "_id"); assertNotNull(scriptMetadata); @@ -408,7 +412,7 @@ public void testGetStoredScript() throws Exception { "_id", StoredScriptSource.parse( new BytesArray("{\"script\": {\"lang\": \"_lang\", \"source\": \"abc\"} }"), - XContentType.JSON + MediaTypeRegistry.JSON ) ).build() ) diff --git a/server/src/test/java/org/opensearch/script/ScriptTests.java b/server/src/test/java/org/opensearch/script/ScriptTests.java index a884226ab300c..0b871ee4847cc 100644 --- a/server/src/test/java/org/opensearch/script/ScriptTests.java +++ b/server/src/test/java/org/opensearch/script/ScriptTests.java @@ -97,7 +97,9 @@ private Script createScript() throws IOException { scriptType, scriptType == ScriptType.STORED ? null : randomFrom("_lang1", "_lang2", "_lang3"), script, - scriptType == ScriptType.INLINE ? Collections.singletonMap(Script.CONTENT_TYPE_OPTION, XContentType.JSON.mediaType()) : null, + scriptType == ScriptType.INLINE + ? Collections.singletonMap(Script.CONTENT_TYPE_OPTION, MediaTypeRegistry.JSON.mediaType()) + : null, params ); } @@ -168,8 +170,8 @@ public void testParseFromObjectFromScript() { } Script script = new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "doc['field']", options, params); Map scriptObject = XContentHelper.convertToMap( - XContentType.JSON.xContent(), - Strings.toString(XContentType.JSON, script), + MediaTypeRegistry.JSON.xContent(), + Strings.toString(MediaTypeRegistry.JSON, script), false ); Script parsedScript = Script.parse(scriptObject); diff --git a/server/src/test/java/org/opensearch/script/StoredScriptSourceTests.java b/server/src/test/java/org/opensearch/script/StoredScriptSourceTests.java index f926c84596310..78cf9f632ae37 100644 --- a/server/src/test/java/org/opensearch/script/StoredScriptSourceTests.java +++ b/server/src/test/java/org/opensearch/script/StoredScriptSourceTests.java @@ -34,6 +34,8 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.Writeable.Reader; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -47,9 +49,9 @@ public class StoredScriptSourceTests extends AbstractSerializingTestCase options = new HashMap<>(); if (randomBoolean()) { - options.put(Script.CONTENT_TYPE_OPTION, xContentType.mediaType()); + options.put(Script.CONTENT_TYPE_OPTION, mediaType.mediaType()); } - return StoredScriptSource.parse(BytesReference.bytes(template), xContentType); + return StoredScriptSource.parse(BytesReference.bytes(template), mediaType); } catch (IOException e) { throw new AssertionError("Failed to create test instance", e); } @@ -87,7 +89,7 @@ protected StoredScriptSource mutateInstance(StoredScriptSource instance) throws String lang = instance.getLang(); Map options = instance.getOptions(); - XContentType newXContentType = randomFrom(XContentType.JSON, XContentType.YAML); + MediaType newXContentType = randomFrom(MediaTypeRegistry.JSON, XContentType.YAML); XContentBuilder newTemplate = XContentBuilder.builder(newXContentType.xContent()); newTemplate.startObject(); newTemplate.startObject("query"); diff --git a/server/src/test/java/org/opensearch/script/StoredScriptTests.java b/server/src/test/java/org/opensearch/script/StoredScriptTests.java index 09b4cce6bd19b..36d9f4dc6e601 100644 --- a/server/src/test/java/org/opensearch/script/StoredScriptTests.java +++ b/server/src/test/java/org/opensearch/script/StoredScriptTests.java @@ -39,7 +39,6 @@ import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.test.AbstractSerializingTestCase; import java.io.IOException; @@ -72,17 +71,17 @@ public void testInvalidDelete() { public void testSourceParsing() throws Exception { // simple script value string - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject().startObject("script").field("lang", "lang").field("source", "code").endObject().endObject(); - StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON); + StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON); StoredScriptSource source = new StoredScriptSource("lang", "code", Collections.emptyMap()); assertThat(parsed, equalTo(source)); } // complex template using script as the field name - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject() .startObject("script") .field("lang", "mustache") @@ -97,7 +96,7 @@ public void testSourceParsing() throws Exception { code = cb.startObject().field("query", "code").endObject().toString(); } - StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON); + StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON); StoredScriptSource source = new StoredScriptSource( "mustache", code, @@ -108,20 +107,20 @@ public void testSourceParsing() throws Exception { } // complex script with script object - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject().field("script").startObject().field("lang", "lang").field("source", "code").endObject().endObject(); - StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON); + StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON); StoredScriptSource source = new StoredScriptSource("lang", "code", Collections.emptyMap()); assertThat(parsed, equalTo(source)); } // complex script using "code" backcompat - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject().field("script").startObject().field("lang", "lang").field("code", "code").endObject().endObject(); - StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON); + StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON); StoredScriptSource source = new StoredScriptSource("lang", "code", Collections.emptyMap()); assertThat(parsed, equalTo(source)); @@ -129,7 +128,7 @@ public void testSourceParsing() throws Exception { assertWarnings("Deprecated field [code] used, expected [source] instead"); // complex script with script object and empty options - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject() .field("script") .startObject() @@ -141,14 +140,14 @@ public void testSourceParsing() throws Exception { .endObject() .endObject(); - StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON); + StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON); StoredScriptSource source = new StoredScriptSource("lang", "code", Collections.emptyMap()); assertThat(parsed, equalTo(source)); } // complex script with embedded template - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject() .field("script") .startObject() @@ -167,7 +166,7 @@ public void testSourceParsing() throws Exception { code = cb.startObject().field("query", "code").endObject().toString(); } - StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON); + StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON); StoredScriptSource source = new StoredScriptSource( "lang", code, @@ -180,29 +179,29 @@ public void testSourceParsing() throws Exception { public void testSourceParsingErrors() throws Exception { // check for missing lang parameter when parsing a script - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject().field("script").startObject().field("source", "code").endObject().endObject(); IllegalArgumentException iae = expectThrows( IllegalArgumentException.class, - () -> StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON) + () -> StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON) ); assertThat(iae.getMessage(), equalTo("must specify lang for stored script")); } // check for missing source parameter when parsing a script - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject().field("script").startObject().field("lang", "lang").endObject().endObject(); IllegalArgumentException iae = expectThrows( IllegalArgumentException.class, - () -> StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON) + () -> StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON) ); assertThat(iae.getMessage(), equalTo("must specify source for stored script")); } // check for illegal options parameter when parsing a script - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject() .field("script") .startObject() @@ -216,17 +215,17 @@ public void testSourceParsingErrors() throws Exception { IllegalArgumentException iae = expectThrows( IllegalArgumentException.class, - () -> StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON) + () -> StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON) ); assertThat(iae.getMessage(), equalTo("illegal compiler options [{option=option}] specified")); } // check for unsupported template context - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject().field("template", "code").endObject(); ParsingException pEx = expectThrows( ParsingException.class, - () -> StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON) + () -> StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON) ); assertThat( pEx.getMessage(), @@ -236,20 +235,20 @@ public void testSourceParsingErrors() throws Exception { } public void testEmptyTemplateDeprecations() throws IOException { - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject().endObject(); - StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON); + StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON); StoredScriptSource source = new StoredScriptSource(Script.DEFAULT_TEMPLATE_LANG, "", Collections.emptyMap()); assertThat(parsed, equalTo(source)); assertWarnings("empty templates should no longer be used"); } - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON)) { + try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(MediaTypeRegistry.JSON)) { builder.startObject().field("script").startObject().field("lang", "mustache").field("source", "").endObject().endObject(); - StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), XContentType.JSON); + StoredScriptSource parsed = StoredScriptSource.parse(BytesReference.bytes(builder), MediaTypeRegistry.JSON); StoredScriptSource source = new StoredScriptSource(Script.DEFAULT_TEMPLATE_LANG, "", Collections.emptyMap()); assertThat(parsed, equalTo(source)); diff --git a/server/src/test/java/org/opensearch/search/SearchHitTests.java b/server/src/test/java/org/opensearch/search/SearchHitTests.java index af52bdb83916c..18bc3cac93eca 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitTests.java @@ -40,6 +40,8 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.document.DocumentField; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -63,7 +65,7 @@ import java.util.Map; import java.util.function.Predicate; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.test.XContentTestUtils.insertRandomFields; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; import static org.hamcrest.Matchers.containsString; @@ -78,7 +80,7 @@ public static SearchHit createTestItem(boolean withOptionalInnerHits, boolean wi return createTestItem(randomFrom(XContentType.values()), withOptionalInnerHits, withShardTarget); } - public static SearchHit createTestItem(XContentType xContentType, boolean withOptionalInnerHits, boolean transportSerialization) { + public static SearchHit createTestItem(final MediaType mediaType, boolean withOptionalInnerHits, boolean transportSerialization) { int internalId = randomInt(); String uid = randomAlphaOfLength(10); NestedIdentity nestedIdentity = null; @@ -89,8 +91,8 @@ public static SearchHit createTestItem(XContentType xContentType, boolean withOp Map documentFields = new HashMap<>(); if (frequently()) { if (randomBoolean()) { - metaFields = GetResultTests.randomDocumentFields(xContentType, true).v2(); - documentFields = GetResultTests.randomDocumentFields(xContentType, false).v2(); + metaFields = GetResultTests.randomDocumentFields(mediaType, true).v2(); + documentFields = GetResultTests.randomDocumentFields(mediaType, false).v2(); } } @@ -103,7 +105,7 @@ public static SearchHit createTestItem(XContentType xContentType, boolean withOp } } if (frequently()) { - hit.sourceRef(RandomObjects.randomSource(random(), xContentType)); + hit.sourceRef(RandomObjects.randomSource(random(), mediaType)); } if (randomBoolean()) { hit.version(randomLong()); @@ -114,7 +116,7 @@ public static SearchHit createTestItem(XContentType xContentType, boolean withOp hit.version(randomLongBetween(1, Long.MAX_VALUE)); } if (randomBoolean()) { - hit.sortValues(SearchSortValuesTests.createTestItem(xContentType, transportSerialization)); + hit.sortValues(SearchSortValuesTests.createTestItem(mediaType, transportSerialization)); } if (randomBoolean()) { int size = randomIntBetween(0, 5); @@ -141,7 +143,7 @@ public static SearchHit createTestItem(XContentType xContentType, boolean withOp if (innerHitsSize > 0) { Map innerHits = new HashMap<>(innerHitsSize); for (int i = 0; i < innerHitsSize; i++) { - innerHits.put(randomAlphaOfLength(5), SearchHitsTests.createTestItem(xContentType, false, transportSerialization)); + innerHits.put(randomAlphaOfLength(5), SearchHitsTests.createTestItem(mediaType, false, transportSerialization)); } hit.setInnerHits(innerHits); } @@ -318,7 +320,7 @@ public void testHasSource() { public void testWeirdScriptFields() throws Exception { { XContentParser parser = createParser( - XContentType.JSON.xContent(), + MediaTypeRegistry.JSON.xContent(), "{\n" + " \"_index\": \"twitter\",\n" + " \"_id\": \"1\",\n" @@ -338,7 +340,7 @@ public void testWeirdScriptFields() throws Exception { } { XContentParser parser = createParser( - XContentType.JSON.xContent(), + MediaTypeRegistry.JSON.xContent(), "{\n" + " \"_index\": \"twitter\",\n" + " \"_id\": \"1\",\n" @@ -394,11 +396,11 @@ public void testToXContentEmptyFields() throws IOException { fields.put("bar", new DocumentField("bar", Collections.emptyList())); SearchHit hit = new SearchHit(0, "_id", null, fields, Collections.emptyMap()); { - BytesReference originalBytes = toShuffledXContent(hit, XContentType.JSON, ToXContent.EMPTY_PARAMS, randomBoolean()); + BytesReference originalBytes = toShuffledXContent(hit, MediaTypeRegistry.JSON, ToXContent.EMPTY_PARAMS, randomBoolean()); // checks that the fields section is completely omitted in the rendering. assertThat(originalBytes.utf8ToString(), not(containsString("fields"))); final SearchHit parsed; - try (XContentParser parser = createParser(XContentType.JSON.xContent(), originalBytes)) { + try (XContentParser parser = createParser(MediaTypeRegistry.JSON.xContent(), originalBytes)) { parser.nextToken(); // jump to first START_OBJECT parsed = SearchHit.fromXContent(parser); assertEquals(XContentParser.Token.END_OBJECT, parser.currentToken()); @@ -412,9 +414,9 @@ public void testToXContentEmptyFields() throws IOException { fields.put("bar", new DocumentField("bar", Collections.singletonList("value"))); hit = new SearchHit(0, "_id", null, fields, Collections.emptyMap()); { - BytesReference originalBytes = toShuffledXContent(hit, XContentType.JSON, ToXContent.EMPTY_PARAMS, randomBoolean()); + BytesReference originalBytes = toShuffledXContent(hit, MediaTypeRegistry.JSON, ToXContent.EMPTY_PARAMS, randomBoolean()); final SearchHit parsed; - try (XContentParser parser = createParser(XContentType.JSON.xContent(), originalBytes)) { + try (XContentParser parser = createParser(MediaTypeRegistry.JSON.xContent(), originalBytes)) { parser.nextToken(); // jump to first START_OBJECT parsed = SearchHit.fromXContent(parser); assertEquals(XContentParser.Token.END_OBJECT, parser.currentToken()); @@ -428,9 +430,9 @@ public void testToXContentEmptyFields() throws IOException { metadata.put("_routing", new DocumentField("_routing", Collections.emptyList())); hit = new SearchHit(0, "_id", null, fields, Collections.emptyMap()); { - BytesReference originalBytes = toShuffledXContent(hit, XContentType.JSON, ToXContent.EMPTY_PARAMS, randomBoolean()); + BytesReference originalBytes = toShuffledXContent(hit, MediaTypeRegistry.JSON, ToXContent.EMPTY_PARAMS, randomBoolean()); final SearchHit parsed; - try (XContentParser parser = createParser(XContentType.JSON.xContent(), originalBytes)) { + try (XContentParser parser = createParser(MediaTypeRegistry.JSON.xContent(), originalBytes)) { parser.nextToken(); // jump to first START_OBJECT parsed = SearchHit.fromXContent(parser); assertEquals(XContentParser.Token.END_OBJECT, parser.currentToken()); diff --git a/server/src/test/java/org/opensearch/search/SearchHitsTests.java b/server/src/test/java/org/opensearch/search/SearchHitsTests.java index 442dd4e8fc51b..ec0369602b537 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsTests.java @@ -40,6 +40,7 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.lucene.LuceneTests; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -61,13 +62,13 @@ public static SearchHits createTestItem(boolean withOptionalInnerHits, boolean w private static SearchHit[] createSearchHitArray( int size, - XContentType xContentType, + final MediaType mediaType, boolean withOptionalInnerHits, boolean transportSerialization ) { SearchHit[] hits = new SearchHit[size]; for (int i = 0; i < hits.length; i++) { - hits[i] = SearchHitTests.createTestItem(xContentType, withOptionalInnerHits, transportSerialization); + hits[i] = SearchHitTests.createTestItem(mediaType, withOptionalInnerHits, transportSerialization); } return hits; } @@ -77,18 +78,18 @@ private static TotalHits randomTotalHits(TotalHits.Relation relation) { return new TotalHits(totalHits, relation); } - public static SearchHits createTestItem(XContentType xContentType, boolean withOptionalInnerHits, boolean transportSerialization) { - return createTestItem(xContentType, withOptionalInnerHits, transportSerialization, randomFrom(TotalHits.Relation.values())); + public static SearchHits createTestItem(final MediaType mediaType, boolean withOptionalInnerHits, boolean transportSerialization) { + return createTestItem(mediaType, withOptionalInnerHits, transportSerialization, randomFrom(TotalHits.Relation.values())); } private static SearchHits createTestItem( - XContentType xContentType, + final MediaType mediaType, boolean withOptionalInnerHits, boolean transportSerialization, TotalHits.Relation totalHitsRelation ) { int searchHits = randomIntBetween(0, 5); - SearchHit[] hits = createSearchHitArray(searchHits, xContentType, withOptionalInnerHits, transportSerialization); + SearchHit[] hits = createSearchHitArray(searchHits, mediaType, withOptionalInnerHits, transportSerialization); TotalHits totalHits = frequently() ? randomTotalHits(totalHitsRelation) : null; float maxScore = frequently() ? randomFloat() : Float.NaN; SortField[] sortFields = null; @@ -223,13 +224,13 @@ protected SearchHits createTestInstance() { } @Override - protected SearchHits createXContextTestInstance(XContentType xContentType) { + protected SearchHits createXContextTestInstance(final MediaType mediaType) { // We don't set SearchHit#shard (withShardTarget is false) in this test // because the rest serialization does not render this information so the // deserialized hit cannot be equal to the original instance. // There is another test (#testFromXContentWithShards) that checks the // rest serialization with shard targets. - return createTestItem(xContentType, true, false); + return createTestItem(mediaType, true, false); } @Override diff --git a/server/src/test/java/org/opensearch/search/SearchSortValuesTests.java b/server/src/test/java/org/opensearch/search/SearchSortValuesTests.java index 7efe157f88bf0..8fb39339bc6e2 100644 --- a/server/src/test/java/org/opensearch/search/SearchSortValuesTests.java +++ b/server/src/test/java/org/opensearch/search/SearchSortValuesTests.java @@ -35,6 +35,7 @@ import org.apache.lucene.util.BytesRef; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.lucene.LuceneTests; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -48,13 +49,13 @@ public class SearchSortValuesTests extends AbstractSerializingTestCase { - public static SearchSortValues createTestItem(XContentType xContentType, boolean transportSerialization) { + public static SearchSortValues createTestItem(final MediaType mediaType, boolean transportSerialization) { int size = randomIntBetween(1, 20); Object[] values = new Object[size]; if (transportSerialization) { DocValueFormat[] sortValueFormats = new DocValueFormat[size]; for (int i = 0; i < size; i++) { - Object sortValue = randomSortValue(xContentType, transportSerialization); + Object sortValue = randomSortValue(mediaType, transportSerialization); values[i] = sortValue; // make sure that for BytesRef, we provide a specific doc value format that overrides format(BytesRef) sortValueFormats[i] = sortValue instanceof BytesRef ? DocValueFormat.RAW : randomDocValueFormat(); @@ -63,7 +64,7 @@ public static SearchSortValues createTestItem(XContentType xContentType, boolean } else { // xcontent serialization doesn't write/parse the raw sort values, only the formatted ones for (int i = 0; i < size; i++) { - Object sortValue = randomSortValue(xContentType, transportSerialization); + Object sortValue = randomSortValue(mediaType, transportSerialization); // make sure that BytesRef are not provided as formatted values sortValue = sortValue instanceof BytesRef ? DocValueFormat.RAW.format((BytesRef) sortValue) : sortValue; values[i] = sortValue; @@ -72,10 +73,10 @@ public static SearchSortValues createTestItem(XContentType xContentType, boolean } } - private static Object randomSortValue(XContentType xContentType, boolean transportSerialization) { + private static Object randomSortValue(final MediaType mediaType, boolean transportSerialization) { Object randomSortValue = LuceneTests.randomSortValue(); // to simplify things, we directly serialize what we expect we would parse back when testing xcontent serialization - return transportSerialization ? randomSortValue : RandomObjects.getExpectedParsedValue(xContentType, randomSortValue); + return transportSerialization ? randomSortValue : RandomObjects.getExpectedParsedValue(mediaType, randomSortValue); } private static DocValueFormat randomDocValueFormat() { @@ -102,8 +103,8 @@ protected SearchSortValues doParseInstance(XContentParser parser) throws IOExcep } @Override - protected SearchSortValues createXContextTestInstance(XContentType xContentType) { - return createTestItem(xContentType, false); + protected SearchSortValues createXContextTestInstance(final MediaType mediaType) { + return createTestItem(mediaType, false); } @Override diff --git a/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java b/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java index 8af50bc498d90..03c5548071bda 100644 --- a/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java +++ b/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java @@ -42,9 +42,9 @@ import org.opensearch.common.geo.builders.GeometryCollectionBuilder; import org.opensearch.common.geo.builders.MultiPolygonBuilder; import org.opensearch.common.geo.builders.PolygonBuilder; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.geometry.Geometry; import org.opensearch.geometry.Rectangle; import org.opensearch.index.query.GeoShapeQueryBuilder; @@ -87,7 +87,7 @@ public void testNullShape() throws Exception { client().prepareIndex(defaultIndexName) .setId("aNullshape") - .setSource("{\"geo\": null}", XContentType.JSON) + .setSource("{\"geo\": null}", MediaTypeRegistry.JSON) .setRefreshPolicy(IMMEDIATE) .get(); GetResponse result = client().prepareGet(defaultIndexName, "aNullshape").get(); diff --git a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java index ace4861b5c682..8e22acf8d1861 100644 --- a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java +++ b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java @@ -50,10 +50,10 @@ import org.opensearch.common.geo.builders.ShapeBuilder; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.DistanceUnit; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.LegacyGeoShapeFieldMapper; import org.opensearch.index.mapper.MapperParsingException; import org.opensearch.index.query.ExistsQueryBuilder; @@ -155,7 +155,7 @@ public void testShapeFetchingPath() throws Exception { .setId("1") .setSource( String.format(Locale.ROOT, "{ %s, \"1\" : { %s, \"2\" : { %s, \"3\" : { %s } }} }", location, location, location, location), - XContentType.JSON + MediaTypeRegistry.JSON ) .setRefreshPolicy(IMMEDIATE) .get(); @@ -291,7 +291,7 @@ public void testEnvelopeSpanningDateline() throws Exception { + "],\r\n" + "\"type\": \"Point\"\r\n" + "}}"; - client().index(new IndexRequest("test").id("1").source(doc1, XContentType.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); + client().index(new IndexRequest("test").id("1").source(doc1, MediaTypeRegistry.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); String doc2 = "{\"geo\": {\r\n" + "\"coordinates\": [\r\n" @@ -300,7 +300,7 @@ public void testEnvelopeSpanningDateline() throws Exception { + "],\r\n" + "\"type\": \"Point\"\r\n" + "}}"; - client().index(new IndexRequest("test").id("2").source(doc2, XContentType.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); + client().index(new IndexRequest("test").id("2").source(doc2, MediaTypeRegistry.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); String doc3 = "{\"geo\": {\r\n" + "\"coordinates\": [\r\n" @@ -309,7 +309,7 @@ public void testEnvelopeSpanningDateline() throws Exception { + "],\r\n" + "\"type\": \"Point\"\r\n" + "}}"; - client().index(new IndexRequest("test").id("3").source(doc3, XContentType.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); + client().index(new IndexRequest("test").id("3").source(doc3, MediaTypeRegistry.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); @SuppressWarnings("unchecked") CheckedSupplier querySupplier = randomFrom( diff --git a/server/src/test/java/org/opensearch/search/pipeline/SearchPipelineServiceTests.java b/server/src/test/java/org/opensearch/search/pipeline/SearchPipelineServiceTests.java index 9fc0be38d66a5..a7711d54ec8a9 100644 --- a/server/src/test/java/org/opensearch/search/pipeline/SearchPipelineServiceTests.java +++ b/server/src/test/java/org/opensearch/search/pipeline/SearchPipelineServiceTests.java @@ -44,9 +44,9 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.AtomicArray; import org.opensearch.common.util.concurrent.OpenSearchExecutors; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexSettings; import org.opensearch.index.query.TermQueryBuilder; import org.opensearch.plugins.SearchPipelinePlugin; @@ -173,7 +173,7 @@ public void testResolveIndexDefaultPipeline() throws Exception { new PipelineConfiguration( "p1", new BytesArray("{\"request_processors\" : [ { \"scale_request_size\": { \"scale\" : 2 } } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ); @@ -403,7 +403,7 @@ public void testUpdatePipelines() { + "\"phase_results_processors\" : [ { \"max_score\" : { \"score\": 100 } } ]" + "}" ), - XContentType.JSON + MediaTypeRegistry.JSON ); SearchPipelineMetadata pipelineMetadata = new SearchPipelineMetadata(Map.of("_id", pipeline)); clusterState = ClusterState.builder(clusterState) @@ -438,7 +438,7 @@ public void testPutPipeline() { ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); - PutSearchPipelineRequest putRequest = new PutSearchPipelineRequest(id, new BytesArray("{}"), XContentType.JSON); + PutSearchPipelineRequest putRequest = new PutSearchPipelineRequest(id, new BytesArray("{}"), MediaTypeRegistry.JSON); ClusterState previousClusterState = clusterState; clusterState = SearchPipelineService.innerPut(putRequest, clusterState); searchPipelineService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); @@ -450,7 +450,7 @@ public void testPutPipeline() { assertEquals(0, pipeline.pipeline.getSearchResponseProcessors().size()); // Overwrite pipeline - putRequest = new PutSearchPipelineRequest(id, new BytesArray("{ \"description\": \"empty pipeline\"}"), XContentType.JSON); + putRequest = new PutSearchPipelineRequest(id, new BytesArray("{ \"description\": \"empty pipeline\"}"), MediaTypeRegistry.JSON); previousClusterState = clusterState; clusterState = SearchPipelineService.innerPut(putRequest, clusterState); searchPipelineService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); @@ -473,7 +473,7 @@ public void testPutInvalidPipeline() throws IllegalAccessException { PutSearchPipelineRequest putRequest = new PutSearchPipelineRequest( id, new BytesArray("{\"request_processors\" : [ { \"scale_request_size\": { \"scale\" : \"foo\" } } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ); clusterState = SearchPipelineService.innerPut(putRequest, clusterState); try (MockLogAppender mockAppender = MockLogAppender.createForLoggers(LogManager.getLogger(SearchPipelineService.class))) { @@ -496,7 +496,7 @@ public void testDeletePipeline() { PipelineConfiguration config = new PipelineConfiguration( "_id", new BytesArray("{\"request_processors\" : [ { \"scale_request_size\": { \"scale\" : 2 } } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ); SearchPipelineMetadata searchPipelineMetadata = new SearchPipelineMetadata(Map.of("_id", config)); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); @@ -529,11 +529,11 @@ public void testDeletePipelinesWithWildcard() { SearchPipelineMetadata metadata = new SearchPipelineMetadata( Map.of( "p1", - new PipelineConfiguration("p1", definition, XContentType.JSON), + new PipelineConfiguration("p1", definition, MediaTypeRegistry.JSON), "p2", - new PipelineConfiguration("p2", definition, XContentType.JSON), + new PipelineConfiguration("p2", definition, MediaTypeRegistry.JSON), "q1", - new PipelineConfiguration("q1", definition, XContentType.JSON) + new PipelineConfiguration("q1", definition, MediaTypeRegistry.JSON) ) ); ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build(); @@ -582,7 +582,7 @@ public void testTransformRequest() throws Exception { new PipelineConfiguration( "p1", new BytesArray("{\"request_processors\" : [ { \"scale_request_size\": { \"scale\" : 2 } } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ); @@ -617,7 +617,7 @@ public void testTransformResponse() throws Exception { new PipelineConfiguration( "p1", new BytesArray("{\"response_processors\" : [ { \"fixed_score\": { \"score\" : 2 } } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ); @@ -662,7 +662,7 @@ public void testTransformSearchPhase() { new PipelineConfiguration( "p1", new BytesArray("{\"phase_results_processors\" : [ { \"max_score\" : { } } ]}"), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ); @@ -747,19 +747,19 @@ public void testGetPipelines() { new PipelineConfiguration( "p1", new BytesArray("{\"request_processors\" : [ { \"scale_request_size\": { \"scale\" : 2 } } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ), "p2", new PipelineConfiguration( "p2", new BytesArray("{\"response_processors\" : [ { \"fixed_score\": { \"score\" : 2 } } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ), "p3", new PipelineConfiguration( "p3", new BytesArray("{\"phase_results_processors\" : [ { \"max_score\" : { } } ]}"), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ); @@ -818,7 +818,7 @@ public void testValidatePipeline() throws Exception { + "\"phase_results_processors\" : [ { \"max_score\" : { } } ]" + "}" ), - XContentType.JSON + MediaTypeRegistry.JSON ); SearchPipelineInfo completePipelineInfo = new SearchPipelineInfo( @@ -843,7 +843,7 @@ public void testValidatePipeline() throws Exception { + "\"response_processors\": [{ \"fixed_score\": { \"score\" : 2 } }]" + "}" ), - XContentType.JSON + MediaTypeRegistry.JSON ); expectThrows( ClassCastException.class, @@ -1241,25 +1241,25 @@ private SearchPipelineService getSearchPipelineService( new PipelineConfiguration( "good_response_pipeline", new BytesArray("{\"response_processors\" : [ { \"successful_response\": {} } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ), "bad_response_pipeline", new PipelineConfiguration( "bad_response_pipeline", new BytesArray("{\"response_processors\" : [ { \"throwing_response\": {} } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ), "good_request_pipeline", new PipelineConfiguration( "good_request_pipeline", new BytesArray("{\"request_processors\" : [ { \"successful_request\": {} } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ), "bad_request_pipeline", new PipelineConfiguration( "bad_request_pipeline", new BytesArray("{\"request_processors\" : [ { \"throwing_request\": {} } ] }"), - XContentType.JSON + MediaTypeRegistry.JSON ) ) ); @@ -1299,7 +1299,7 @@ public void testAdHocRejectingProcessor() { PutSearchPipelineRequest putRequest = new PutSearchPipelineRequest( id, new BytesArray("{\"request_processors\":[" + " { \"" + processorType + "\": {}}" + "]}"), - XContentType.JSON + MediaTypeRegistry.JSON ); ClusterState previousClusterState = clusterState; clusterState = SearchPipelineService.innerPut(putRequest, clusterState); diff --git a/server/src/test/java/org/opensearch/search/pipeline/SearchPipelineStatsTests.java b/server/src/test/java/org/opensearch/search/pipeline/SearchPipelineStatsTests.java index 90a6e99057b0e..2b904b5bc627f 100644 --- a/server/src/test/java/org/opensearch/search/pipeline/SearchPipelineStatsTests.java +++ b/server/src/test/java/org/opensearch/search/pipeline/SearchPipelineStatsTests.java @@ -11,12 +11,12 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.metrics.OperationStats; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.test.OpenSearchTestCase; @@ -178,8 +178,8 @@ public void testToXContent() throws IOException { expectedBuilder.generator().copyCurrentStructure(expectedParser); assertEquals( - XContentHelper.convertToMap(BytesReference.bytes(expectedBuilder), false, (MediaType) XContentType.JSON), - XContentHelper.convertToMap(BytesReference.bytes(actualBuilder), false, (MediaType) XContentType.JSON) + XContentHelper.convertToMap(BytesReference.bytes(expectedBuilder), false, (MediaType) MediaTypeRegistry.JSON), + XContentHelper.convertToMap(BytesReference.bytes(actualBuilder), false, (MediaType) MediaTypeRegistry.JSON) ); } } diff --git a/server/src/test/java/org/opensearch/search/pit/RestDeletePitActionTests.java b/server/src/test/java/org/opensearch/search/pit/RestDeletePitActionTests.java index 4880afb896a40..d8e04519ed865 100644 --- a/server/src/test/java/org/opensearch/search/pit/RestDeletePitActionTests.java +++ b/server/src/test/java/org/opensearch/search/pit/RestDeletePitActionTests.java @@ -14,7 +14,7 @@ import org.opensearch.client.node.NodeClient; import org.opensearch.common.SetOnce; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.rest.RestRequest; import org.opensearch.rest.action.search.RestDeletePitAction; import org.opensearch.test.OpenSearchTestCase; @@ -35,7 +35,7 @@ public void testParseDeletePitRequestWithInvalidJsonThrowsException() throws Exc RestDeletePitAction action = new RestDeletePitAction(); RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withContent( new BytesArray("{invalid_json}"), - XContentType.JSON + MediaTypeRegistry.JSON ).build(); Exception e = expectThrows(IllegalArgumentException.class, () -> action.prepareRequest(request, null)); assertThat(e.getMessage(), equalTo("Failed to parse request body")); @@ -54,7 +54,7 @@ public void deletePits(DeletePitRequest request, ActionListener action.prepareRequest(request, null)); assertThat(e.getMessage(), equalTo("Failed to parse request body")); @@ -76,7 +76,7 @@ public void clearScroll(ClearScrollRequest request, ActionListener action.prepareRequest(request, null)); assertThat(e.getMessage(), equalTo("Failed to parse request body")); @@ -78,7 +78,7 @@ public void searchScroll(SearchScrollRequest request, ActionListener> contexts = Collections.singletonMap("key", Collections.singleton("value")); CompletionSuggestion.Entry.Option option = new CompletionSuggestion.Entry.Option(1, new Text("someText"), 1.3f, contexts); - BytesReference xContent = toXContent(option, XContentType.JSON, randomBoolean()); + BytesReference xContent = toXContent(option, MediaTypeRegistry.JSON, randomBoolean()); assertEquals("{\"text\":\"someText\",\"score\":1.3,\"contexts\":{\"key\":[\"value\"]}}", xContent.utf8ToString()); } } diff --git a/server/src/test/java/org/opensearch/search/suggest/SuggestTests.java b/server/src/test/java/org/opensearch/search/suggest/SuggestTests.java index e046b415dbcf3..606bf8d9d280d 100644 --- a/server/src/test/java/org/opensearch/search/suggest/SuggestTests.java +++ b/server/src/test/java/org/opensearch/search/suggest/SuggestTests.java @@ -41,6 +41,7 @@ import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.settings.Settings; import org.opensearch.core.common.text.Text; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -66,7 +67,7 @@ import static java.util.Collections.emptyList; import static org.opensearch.common.xcontent.XContentHelper.stripWhitespace; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; import static org.opensearch.core.xcontent.XContentParserUtils.ensureFieldName; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; @@ -162,7 +163,7 @@ public void testToXContent() throws IOException { PhraseSuggestion suggestion = new PhraseSuggestion("suggestionName", 5); suggestion.addTerm(entry); Suggest suggest = new Suggest(Collections.singletonList(suggestion)); - BytesReference xContent = toXContent(suggest, XContentType.JSON, randomBoolean()); + BytesReference xContent = toXContent(suggest, MediaTypeRegistry.JSON, randomBoolean()); assertEquals( stripWhitespace( "{" diff --git a/server/src/test/java/org/opensearch/search/suggest/SuggestionEntryTests.java b/server/src/test/java/org/opensearch/search/suggest/SuggestionEntryTests.java index f8cc6bb5c9f2e..09bdfde4e7fa6 100644 --- a/server/src/test/java/org/opensearch/search/suggest/SuggestionEntryTests.java +++ b/server/src/test/java/org/opensearch/search/suggest/SuggestionEntryTests.java @@ -34,6 +34,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.text.Text; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -52,7 +53,7 @@ import java.util.function.Predicate; import java.util.function.Supplier; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; import static org.opensearch.test.XContentTestUtils.insertRandomFields; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; @@ -156,7 +157,7 @@ public void testToXContent() throws IOException { ); PhraseSuggestion.Entry phraseEntry = new PhraseSuggestion.Entry(new Text("entryText"), 42, 313); phraseEntry.addOption(phraseOption); - BytesReference xContent = toXContent(phraseEntry, XContentType.JSON, randomBoolean()); + BytesReference xContent = toXContent(phraseEntry, MediaTypeRegistry.JSON, randomBoolean()); assertEquals( "{\"text\":\"entryText\"," + "\"offset\":42," @@ -173,7 +174,7 @@ public void testToXContent() throws IOException { TermSuggestion.Entry.Option termOption = new TermSuggestion.Entry.Option(new Text("termSuggestOption"), 42, 3.13f); TermSuggestion.Entry termEntry = new TermSuggestion.Entry(new Text("entryText"), 42, 313); termEntry.addOption(termOption); - xContent = toXContent(termEntry, XContentType.JSON, randomBoolean()); + xContent = toXContent(termEntry, MediaTypeRegistry.JSON, randomBoolean()); assertEquals( "{\"text\":\"entryText\"," + "\"offset\":42," @@ -194,7 +195,7 @@ public void testToXContent() throws IOException { ); CompletionSuggestion.Entry completionEntry = new CompletionSuggestion.Entry(new Text("entryText"), 42, 313); completionEntry.addOption(completionOption); - xContent = toXContent(completionEntry, XContentType.JSON, randomBoolean()); + xContent = toXContent(completionEntry, MediaTypeRegistry.JSON, randomBoolean()); assertEquals( "{\"text\":\"entryText\"," + "\"offset\":42," diff --git a/server/src/test/java/org/opensearch/search/suggest/SuggestionOptionTests.java b/server/src/test/java/org/opensearch/search/suggest/SuggestionOptionTests.java index 76d8301d6260d..d8a94aefa0c90 100644 --- a/server/src/test/java/org/opensearch/search/suggest/SuggestionOptionTests.java +++ b/server/src/test/java/org/opensearch/search/suggest/SuggestionOptionTests.java @@ -34,6 +34,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.text.Text; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -43,7 +44,7 @@ import java.io.IOException; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; import static org.opensearch.test.XContentTestUtils.insertRandomFields; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; @@ -93,7 +94,7 @@ private void doTestFromXContent(boolean addRandomFields) throws IOException { public void testToXContent() throws IOException { Option option = new PhraseSuggestion.Entry.Option(new Text("someText"), new Text("somethingHighlighted"), 1.3f, true); - BytesReference xContent = toXContent(option, XContentType.JSON, randomBoolean()); + BytesReference xContent = toXContent(option, MediaTypeRegistry.JSON, randomBoolean()); assertEquals( ("{" + " \"text\": \"someText\"," diff --git a/server/src/test/java/org/opensearch/search/suggest/SuggestionTests.java b/server/src/test/java/org/opensearch/search/suggest/SuggestionTests.java index f1933ca43f2f9..ea55cf4f29771 100644 --- a/server/src/test/java/org/opensearch/search/suggest/SuggestionTests.java +++ b/server/src/test/java/org/opensearch/search/suggest/SuggestionTests.java @@ -35,6 +35,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.text.Text; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedObjectNotFoundException; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; @@ -58,7 +59,7 @@ import java.util.function.Predicate; import java.util.function.Supplier; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; import static org.opensearch.test.XContentTestUtils.insertRandomFields; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; @@ -229,7 +230,7 @@ public void testToXContent() throws IOException { entry.addOption(option); PhraseSuggestion suggestion = new PhraseSuggestion("suggestionName", 5); suggestion.addTerm(entry); - BytesReference xContent = toXContent(suggestion, XContentType.JSON, params, randomBoolean()); + BytesReference xContent = toXContent(suggestion, MediaTypeRegistry.JSON, params, randomBoolean()); assertEquals( ("{" + " \"phrase#suggestionName\": [" @@ -262,7 +263,7 @@ public void testToXContent() throws IOException { entry.addOption(option); PhraseSuggestion suggestion = new PhraseSuggestion("suggestionName", 5); suggestion.addTerm(entry); - BytesReference xContent = toXContent(suggestion, XContentType.JSON, params, randomBoolean()); + BytesReference xContent = toXContent(suggestion, MediaTypeRegistry.JSON, params, randomBoolean()); assertEquals( ("{" + " \"phrase#suggestionName\": [" @@ -290,7 +291,7 @@ public void testToXContent() throws IOException { entry.addOption(option); TermSuggestion suggestion = new TermSuggestion("suggestionName", 5, SortBy.SCORE); suggestion.addTerm(entry); - BytesReference xContent = toXContent(suggestion, XContentType.JSON, params, randomBoolean()); + BytesReference xContent = toXContent(suggestion, MediaTypeRegistry.JSON, params, randomBoolean()); assertEquals( ("{" + " \"term#suggestionName\": [" @@ -318,7 +319,7 @@ public void testToXContent() throws IOException { entry.addOption(option); CompletionSuggestion suggestion = new CompletionSuggestion("suggestionName", 5, randomBoolean()); suggestion.addTerm(entry); - BytesReference xContent = toXContent(suggestion, XContentType.JSON, params, randomBoolean()); + BytesReference xContent = toXContent(suggestion, MediaTypeRegistry.JSON, params, randomBoolean()); assertEquals( ("{" + " \"completion#suggestionName\": [" diff --git a/server/src/test/java/org/opensearch/search/suggest/TermSuggestionOptionTests.java b/server/src/test/java/org/opensearch/search/suggest/TermSuggestionOptionTests.java index b032f7729cb1d..9371801c35d58 100644 --- a/server/src/test/java/org/opensearch/search/suggest/TermSuggestionOptionTests.java +++ b/server/src/test/java/org/opensearch/search/suggest/TermSuggestionOptionTests.java @@ -34,6 +34,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.text.Text; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -42,7 +43,7 @@ import java.io.IOException; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; import static org.opensearch.test.XContentTestUtils.insertRandomFields; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertToXContentEquivalent; @@ -90,7 +91,7 @@ private void doTestFromXContent(boolean addRandomFields) throws IOException { public void testToXContent() throws IOException { Option option = new Option(new Text("someText"), 100, 1.3f); - BytesReference xContent = toXContent(option, XContentType.JSON, randomBoolean()); + BytesReference xContent = toXContent(option, MediaTypeRegistry.JSON, randomBoolean()); assertEquals("{\"text\":\"someText\",\"score\":1.3,\"freq\":100}", xContent.utf8ToString()); } diff --git a/server/src/test/java/org/opensearch/search/suggest/completion/CategoryContextMappingTests.java b/server/src/test/java/org/opensearch/search/suggest/completion/CategoryContextMappingTests.java index b617d83372e53..be8a94251df22 100644 --- a/server/src/test/java/org/opensearch/search/suggest/completion/CategoryContextMappingTests.java +++ b/server/src/test/java/org/opensearch/search/suggest/completion/CategoryContextMappingTests.java @@ -44,10 +44,10 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParseException; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.mapper.CompletionFieldMapper.CompletionFieldType; import org.opensearch.index.mapper.DocumentMapper; @@ -115,7 +115,7 @@ public void testIndexingWithNoContexts() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = parsedDocument.rootDoc().getFields(fieldMapper.name()); @@ -159,7 +159,7 @@ public void testIndexingWithSimpleContexts() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = parsedDocument.rootDoc().getFields(fieldMapper.name()); @@ -203,7 +203,7 @@ public void testIndexingWithSimpleNumberContexts() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = parsedDocument.rootDoc().getFields(fieldMapper.name()); @@ -247,7 +247,7 @@ public void testIndexingWithSimpleBooleanContexts() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = parsedDocument.rootDoc().getFields(fieldMapper.name()); @@ -287,7 +287,7 @@ public void testIndexingWithSimpleNULLContexts() throws Exception { Exception e = expectThrows( MapperParsingException.class, - () -> defaultMapper.parse(new SourceToParse("test", "1", BytesReference.bytes(builder), XContentType.JSON)) + () -> defaultMapper.parse(new SourceToParse("test", "1", BytesReference.bytes(builder), MediaTypeRegistry.JSON)) ); assertEquals( "contexts must be a string, number or boolean or a list of string, number or boolean, but was [VALUE_NULL]", @@ -330,7 +330,7 @@ public void testIndexingWithContextList() throws Exception { .endObject() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = parsedDocument.rootDoc().getFields(fieldMapper.name()); @@ -372,7 +372,7 @@ public void testIndexingWithMixedTypeContextList() throws Exception { .endObject() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = parsedDocument.rootDoc().getFields(fieldMapper.name()); @@ -410,7 +410,7 @@ public void testIndexingWithMixedTypeContextListHavingNULL() throws Exception { Exception e = expectThrows( MapperParsingException.class, - () -> defaultMapper.parse(new SourceToParse("test", "1", BytesReference.bytes(builder), XContentType.JSON)) + () -> defaultMapper.parse(new SourceToParse("test", "1", BytesReference.bytes(builder), MediaTypeRegistry.JSON)) ); assertEquals("context array must have string, number or boolean values, but was [VALUE_NULL]", e.getCause().getMessage()); } @@ -452,7 +452,7 @@ public void testIndexingWithMultipleContexts() throws Exception { .endArray() .endObject(); ParsedDocument parsedDocument = defaultMapper.parse( - new SourceToParse("test", "1", BytesReference.bytes(builder), XContentType.JSON) + new SourceToParse("test", "1", BytesReference.bytes(builder), MediaTypeRegistry.JSON) ); IndexableField[] fields = parsedDocument.rootDoc().getFields(fieldMapper.name()); assertContextSuggestFields(fields, 3); diff --git a/server/src/test/java/org/opensearch/search/suggest/completion/GeoContextMappingTests.java b/server/src/test/java/org/opensearch/search/suggest/completion/GeoContextMappingTests.java index d641090f1a5aa..d6df208e3d1d9 100644 --- a/server/src/test/java/org/opensearch/search/suggest/completion/GeoContextMappingTests.java +++ b/server/src/test/java/org/opensearch/search/suggest/completion/GeoContextMappingTests.java @@ -36,9 +36,9 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.index.mapper.MapperService; @@ -102,7 +102,7 @@ public void testIndexingWithNoContexts() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); @@ -147,7 +147,7 @@ public void testIndexingWithSimpleContexts() throws Exception { .endArray() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); @@ -196,7 +196,7 @@ public void testIndexingWithContextList() throws Exception { .endObject() .endObject() ), - XContentType.JSON + MediaTypeRegistry.JSON ) ); IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); @@ -237,7 +237,7 @@ public void testIndexingWithMultipleContexts() throws Exception { .endArray() .endObject(); ParsedDocument parsedDocument = mapperService.documentMapper() - .parse(new SourceToParse("test", "1", BytesReference.bytes(builder), XContentType.JSON)); + .parse(new SourceToParse("test", "1", BytesReference.bytes(builder), MediaTypeRegistry.JSON)); IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertContextSuggestFields(fields, 3); } diff --git a/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java b/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java index 34774758dcd0e..402f2002a0564 100644 --- a/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java +++ b/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java @@ -34,7 +34,7 @@ import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchResponse; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.search.aggregations.Aggregation; import org.opensearch.search.aggregations.bucket.terms.SignificantTerms; import org.opensearch.search.aggregations.bucket.terms.StringTerms; @@ -99,7 +99,7 @@ public static void index01Docs(String type, String settings, OpenSearchIntegTest } assertAcked( testCase.prepareCreate(INDEX_NAME) - .setSettings(settings, XContentType.JSON) + .setSettings(settings, MediaTypeRegistry.JSON) .setMapping("text", textMappings, CLASS_FIELD, "type=keyword") ); String[] gb = { "0", "1" }; @@ -122,7 +122,7 @@ public static void index01DocsWithRouting(String type, String settings, OpenSear } assertAcked( testCase.prepareCreate(INDEX_NAME) - .setSettings(settings, XContentType.JSON) + .setSettings(settings, MediaTypeRegistry.JSON) .setMapping("text", textMappings, CLASS_FIELD, "type=keyword") ); String[] gb = { "0", "1" }; diff --git a/server/src/test/java/org/opensearch/threadpool/ThreadPoolStatsTests.java b/server/src/test/java/org/opensearch/threadpool/ThreadPoolStatsTests.java index e99a7aa462cbb..7b66fd276d573 100644 --- a/server/src/test/java/org/opensearch/threadpool/ThreadPoolStatsTests.java +++ b/server/src/test/java/org/opensearch/threadpool/ThreadPoolStatsTests.java @@ -33,10 +33,10 @@ package org.opensearch.threadpool; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.test.OpenSearchTestCase; @@ -86,7 +86,7 @@ public void testThreadPoolStatsToXContent() throws IOException { stats.add(new ThreadPoolStats.Stats(ThreadPool.Names.SAME, -1, 0, 0, 0, 0, 0L)); ThreadPoolStats threadPoolStats = new ThreadPoolStats(stats); - try (XContentBuilder builder = new XContentBuilder(XContentType.JSON.xContent(), os)) { + try (XContentBuilder builder = new XContentBuilder(MediaTypeRegistry.JSON.xContent(), os)) { builder.startObject(); threadPoolStats.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); diff --git a/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java b/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java index 39d7edf8c4956..3e74a335e5af9 100644 --- a/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java @@ -83,10 +83,10 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.BigArrays; import org.opensearch.common.util.set.Sets; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.index.Index; import org.opensearch.index.IndexSettings; @@ -422,7 +422,7 @@ protected static ParsedDocument testParsedDocument( } else { document.add(new StoredField(SourceFieldMapper.NAME, ref.bytes, ref.offset, ref.length)); } - return new ParsedDocument(versionField, seqID, id, routing, Arrays.asList(document), source, XContentType.JSON, mappingUpdate); + return new ParsedDocument(versionField, seqID, id, routing, Arrays.asList(document), source, MediaTypeRegistry.JSON, mappingUpdate); } public static CheckedBiFunction nestedParsedDocFactory() throws Exception { @@ -449,7 +449,7 @@ public static CheckedBiFunction ne source.endObject(); } source.endObject(); - return nestedMapper.parse(new SourceToParse("test", docId, BytesReference.bytes(source), XContentType.JSON)); + return nestedMapper.parse(new SourceToParse("test", docId, BytesReference.bytes(source), MediaTypeRegistry.JSON)); }; } @@ -478,7 +478,7 @@ public ParsedDocument newDeleteTombstoneDoc(String id) { null, Collections.singletonList(doc), new BytesArray("{}"), - XContentType.JSON, + MediaTypeRegistry.JSON, null ); } @@ -496,7 +496,16 @@ public ParsedDocument newNoopTombstoneDoc(String reason) { doc.add(versionField); BytesRef byteRef = new BytesRef(reason); doc.add(new StoredField(SourceFieldMapper.NAME, byteRef.bytes, byteRef.offset, byteRef.length)); - return new ParsedDocument(versionField, seqID, null, null, Collections.singletonList(doc), null, XContentType.JSON, null); + return new ParsedDocument( + versionField, + seqID, + null, + null, + Collections.singletonList(doc), + null, + MediaTypeRegistry.JSON, + null + ); } }; } diff --git a/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java b/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java index 9d39b488070be..2e01d73344043 100644 --- a/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java @@ -44,10 +44,10 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.settings.Settings; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.IndexSettings; import org.opensearch.index.analysis.AnalyzerScope; @@ -185,11 +185,11 @@ protected final SourceToParse source(CheckedConsumer extends diff --git a/test/framework/src/main/java/org/opensearch/test/AbstractBroadcastResponseTestCase.java b/test/framework/src/main/java/org/opensearch/test/AbstractBroadcastResponseTestCase.java index 1ecec0b9c9552..575765668abce 100644 --- a/test/framework/src/main/java/org/opensearch/test/AbstractBroadcastResponseTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/AbstractBroadcastResponseTestCase.java @@ -37,6 +37,7 @@ import org.opensearch.action.support.broadcast.BroadcastResponse; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -150,7 +151,7 @@ public void testFailuresDeduplication() throws IOException { public void testToXContent() { T response = createTestInstance(10, 10, 0, null); - String output = Strings.toString(XContentType.JSON, response); + String output = Strings.toString(MediaTypeRegistry.JSON, response); assertEquals("{\"_shards\":{\"total\":10,\"successful\":10,\"failed\":0}}", output); } } diff --git a/test/framework/src/main/java/org/opensearch/test/AbstractQueryTestCase.java b/test/framework/src/main/java/org/opensearch/test/AbstractQueryTestCase.java index aa43dac288cbd..3de1287ae2f10 100644 --- a/test/framework/src/main/java/org/opensearch/test/AbstractQueryTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/AbstractQueryTestCase.java @@ -51,12 +51,13 @@ import org.opensearch.core.common.io.stream.Writeable.Reader; import org.opensearch.common.unit.Fuzziness; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentGenerator; -import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParseException; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; @@ -262,7 +263,7 @@ static List> alterateQueries(Set queries, Set builder) throws IOException { - BytesReference bytes = XContentHelper.toXContent(builder, XContentType.JSON, false); + BytesReference bytes = org.opensearch.core.xcontent.XContentHelper.toXContent(builder, MediaTypeRegistry.JSON, false); return parseQuery(createParser(JsonXContent.jsonXContent, bytes)); } @@ -633,11 +634,11 @@ public QB mutateInstance(QB instance) throws IOException { public void testValidOutput() throws IOException { for (int runs = 0; runs < NUMBER_OF_TESTQUERIES; runs++) { QB testQuery = createTestQueryBuilder(); - XContentType xContentType = XContentType.JSON; - String toString = Strings.toString(XContentType.JSON, testQuery); - assertParsedQuery(createParser(xContentType.xContent(), toString), testQuery); - BytesReference bytes = XContentHelper.toXContent(testQuery, xContentType, false); - assertParsedQuery(createParser(xContentType.xContent(), bytes), testQuery); + MediaType mediaType = MediaTypeRegistry.JSON; + String toString = Strings.toString(MediaTypeRegistry.JSON, testQuery); + assertParsedQuery(createParser(mediaType.xContent(), toString), testQuery); + BytesReference bytes = org.opensearch.core.xcontent.XContentHelper.toXContent(testQuery, mediaType, false); + assertParsedQuery(createParser(mediaType.xContent(), bytes), testQuery); } } diff --git a/test/framework/src/main/java/org/opensearch/test/AbstractSerializingTestCase.java b/test/framework/src/main/java/org/opensearch/test/AbstractSerializingTestCase.java index f3496aabcb292..9eb7e164e41ec 100644 --- a/test/framework/src/main/java/org/opensearch/test/AbstractSerializingTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/AbstractSerializingTestCase.java @@ -34,6 +34,7 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -75,7 +76,7 @@ public final void testFromXContent() throws IOException { * Override this method if the random instance that you build * should be aware of the {@link XContentType} used in the test. */ - protected T createXContextTestInstance(XContentType xContentType) { + protected T createXContextTestInstance(final MediaType mediaType) { return createTestInstance(); } diff --git a/test/framework/src/main/java/org/opensearch/test/AbstractXContentTestCase.java b/test/framework/src/main/java/org/opensearch/test/AbstractXContentTestCase.java index 00a20d4ff5b9c..01e96a345b32f 100644 --- a/test/framework/src/main/java/org/opensearch/test/AbstractXContentTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/AbstractXContentTestCase.java @@ -35,14 +35,15 @@ import org.opensearch.common.CheckedBiConsumer; import org.opensearch.common.CheckedBiFunction; import org.opensearch.common.CheckedFunction; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.Strings; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContent; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentHelper; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import java.io.IOException; import java.util.function.BiConsumer; @@ -93,7 +94,7 @@ public static XContentTester xContentTester( public static XContentTester xContentTester( CheckedBiFunction createParser, - Function instanceSupplier, + Function instanceSupplier, ToXContent.Params toXContentParams, CheckedFunction fromXContent ) { @@ -110,8 +111,8 @@ public static XContentTester xContentTester( */ public static class XContentTester { private final CheckedBiFunction createParser; - private final Function instanceSupplier; - private final CheckedBiFunction toXContent; + private final Function instanceSupplier; + private final CheckedBiFunction toXContent; private final CheckedFunction fromXContent; private int numberOfTestRuns = NUMBER_OF_TEST_RUNS; @@ -127,8 +128,8 @@ public static class XContentTester { private XContentTester( CheckedBiFunction createParser, - Function instanceSupplier, - CheckedBiFunction toXContent, + Function instanceSupplier, + CheckedBiFunction toXContent, CheckedFunction fromXContent ) { this.createParser = createParser; @@ -291,7 +292,7 @@ protected ToXContent.Params getToXContentParams() { static BytesReference insertRandomFieldsAndShuffle( BytesReference xContent, - XContentType xContentType, + MediaType mediaType, boolean supportsUnknownFields, String[] shuffleFieldsExceptions, Predicate randomFieldsExcludeFilter, @@ -300,11 +301,11 @@ static BytesReference insertRandomFieldsAndShuffle( BytesReference withRandomFields; if (supportsUnknownFields) { // add a few random fields to check that the parser is lenient on new fields - withRandomFields = XContentTestUtils.insertRandomFields(xContentType, xContent, randomFieldsExcludeFilter, random()); + withRandomFields = XContentTestUtils.insertRandomFields(mediaType, xContent, randomFieldsExcludeFilter, random()); } else { withRandomFields = xContent; } - XContentParser parserWithRandonFields = createParserFunction.apply(xContentType.xContent(), withRandomFields); + XContentParser parserWithRandonFields = createParserFunction.apply(mediaType.xContent(), withRandomFields); return BytesReference.bytes(shuffleXContent(parserWithRandonFields, false, shuffleFieldsExceptions)); } diff --git a/test/framework/src/main/java/org/opensearch/test/InternalAggregationTestCase.java b/test/framework/src/main/java/org/opensearch/test/InternalAggregationTestCase.java index a9e7b7d500cf1..56aa05b5a261f 100644 --- a/test/framework/src/main/java/org/opensearch/test/InternalAggregationTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/InternalAggregationTestCase.java @@ -175,7 +175,7 @@ import static java.util.Collections.emptyList; import static java.util.Collections.singletonMap; -import static org.opensearch.common.xcontent.XContentHelper.toXContent; +import static org.opensearch.core.xcontent.XContentHelper.toXContent; import static org.opensearch.search.aggregations.InternalMultiBucketAggregation.countInnerBucket; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java index 0d81008686093..58c71b1c792df 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java @@ -118,6 +118,7 @@ import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.common.Strings; import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -1405,7 +1406,7 @@ protected final IndexResponse index(String index, String type, String id, Object */ @Deprecated protected final IndexResponse index(String index, String type, String id, String source) { - return client().prepareIndex(index).setId(id).setSource(source, XContentType.JSON).execute().actionGet(); + return client().prepareIndex(index).setId(id).setSource(source, MediaTypeRegistry.JSON).execute().actionGet(); } /** @@ -1577,7 +1578,7 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma String index = RandomPicks.randomFrom(random, indices); bogusIds.add(Arrays.asList(index, id)); // We configure a routing key in case the mapping requires it - builders.add(client().prepareIndex().setIndex(index).setId(id).setSource("{}", XContentType.JSON).setRouting(id)); + builders.add(client().prepareIndex().setIndex(index).setId(id).setSource("{}", MediaTypeRegistry.JSON).setRouting(id)); } } Collections.shuffle(builders, random()); diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java index f0453ab11f2ac..e15ce3530cde9 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java @@ -95,7 +95,6 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.util.set.Sets; import org.opensearch.common.xcontent.LoggingDeprecationHandler; -import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.MediaType; @@ -103,6 +102,7 @@ import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContent; import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.XContentParser.Token; import org.opensearch.env.Environment; @@ -364,7 +364,7 @@ public static void setContentType() throws Exception { @AfterClass public static void restoreContentType() { Requests.CONTENT_TYPE = XContentType.SMILE; - Requests.INDEX_CONTENT_TYPE = XContentType.JSON; + Requests.INDEX_CONTENT_TYPE = MediaTypeRegistry.JSON; } @BeforeClass @@ -1311,7 +1311,7 @@ protected final BytesReference toShuffledXContent( boolean humanReadable, String... exceptFieldNames ) throws IOException { - BytesReference bytes = XContentHelper.toXContent(toXContent, mediaType, params, humanReadable); + BytesReference bytes = org.opensearch.core.xcontent.XContentHelper.toXContent(toXContent, mediaType, params, humanReadable); try (XContentParser parser = createParser(mediaType.xContent(), bytes)) { try (XContentBuilder builder = shuffleXContent(parser, rarely(), exceptFieldNames)) { return BytesReference.bytes(builder); diff --git a/test/framework/src/main/java/org/opensearch/test/RandomObjects.java b/test/framework/src/main/java/org/opensearch/test/RandomObjects.java index 3711e39720835..a8704fa5b6051 100644 --- a/test/framework/src/main/java/org/opensearch/test/RandomObjects.java +++ b/test/framework/src/main/java/org/opensearch/test/RandomObjects.java @@ -156,7 +156,7 @@ private static List randomStoredFieldValues(Random random, int numValues */ public static Object getExpectedParsedValue(MediaType mediaType, Object value) { if (value instanceof BytesArray) { - if (mediaType == XContentType.JSON) { + if (mediaType == MediaTypeRegistry.JSON) { // JSON writes base64 format return Base64.getEncoder().encodeToString(((BytesArray) value).toBytesRef().bytes); } @@ -194,8 +194,8 @@ public static BytesReference randomSource(Random random) { * * @param random Random generator */ - public static BytesReference randomSource(Random random, XContentType xContentType) { - return randomSource(random, xContentType, 1); + public static BytesReference randomSource(Random random, final MediaType mediaType) { + return randomSource(random, mediaType, 1); } /** @@ -204,8 +204,8 @@ public static BytesReference randomSource(Random random, XContentType xContentTy * * @param random Random generator */ - public static BytesReference randomSource(Random random, XContentType xContentType, int minNumFields) { - try (XContentBuilder builder = MediaTypeRegistry.contentBuilder(xContentType)) { + public static BytesReference randomSource(Random random, final MediaType mediaType, int minNumFields) { + try (XContentBuilder builder = mediaType.contentBuilder()) { builder.startObject(); addFields(random, builder, minNumFields, 0); builder.endObject(); diff --git a/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java b/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java index 230cc50f427f9..808d9766dc49b 100644 --- a/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java +++ b/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java @@ -687,8 +687,7 @@ public static void assertFileNotExists(Path file) { * The comparison is done by parsing both into a map and comparing those two, so that keys ordering doesn't matter. * Also binary values (byte[]) are properly compared through arrays comparisons. */ - public static void assertToXContentEquivalent(BytesReference expected, BytesReference actual, MediaType xContentType) - throws IOException { + public static void assertToXContentEquivalent(BytesReference expected, BytesReference actual, MediaType mediaType) throws IOException { // we tried comparing byte per byte, but that didn't fly for a couple of reasons: // 1) whenever anything goes through a map while parsing, ordering is not preserved, which is perfectly ok // 2) Jackson SMILE parser parses floats as double, which then get printed out as double (with double precision) @@ -696,12 +695,12 @@ public static void assertToXContentEquivalent(BytesReference expected, BytesRefe Map actualMap = null; Map expectedMap = null; try ( - XContentParser actualParser = xContentType.xContent() + XContentParser actualParser = mediaType.xContent() .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, actual.streamInput()) ) { actualMap = actualParser.map(); try ( - XContentParser expectedParser = xContentType.xContent() + XContentParser expectedParser = mediaType.xContent() .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, expected.streamInput()) ) { expectedMap = expectedParser.map(); 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 762f43adbb3db..7a6400518fa5f 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 @@ -65,13 +65,13 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -607,7 +607,7 @@ protected static void wipeAllIndices() throws IOException { deleteRequest.setOptions(allowSystemIndexAccessWarningOptions); final Response response = adminClient().performRequest(deleteRequest); try (InputStream is = response.getEntity().getContent()) { - assertTrue((boolean) XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true).get("acknowledged")); + assertTrue((boolean) XContentHelper.convertToMap(MediaTypeRegistry.JSON.xContent(), is, true).get("acknowledged")); } } catch (ResponseException e) { // 404 here just means we had no indexes @@ -974,7 +974,7 @@ protected static void createIndex(String name, Settings settings, String mapping protected static void createIndex(String name, Settings settings, String mapping, String aliases) throws IOException { Request request = new Request("PUT", "/" + name); - String entity = "{\"settings\": " + Strings.toString(XContentType.JSON, settings); + String entity = "{\"settings\": " + Strings.toString(MediaTypeRegistry.JSON, settings); if (mapping != null) { entity += ",\"mappings\" : {" + mapping + "}"; } @@ -1000,7 +1000,7 @@ protected static void updateIndexSettings(String index, Settings.Builder setting private static void updateIndexSettings(String index, Settings settings) throws IOException { Request request = new Request("PUT", "/" + index + "/_settings"); - request.setJsonEntity(Strings.toString(XContentType.JSON, settings)); + request.setJsonEntity(Strings.toString(MediaTypeRegistry.JSON, settings)); client().performRequest(request); } @@ -1021,7 +1021,7 @@ protected static Map getIndexSettings(String index) throws IOExc request.addParameter("flat_settings", "true"); Response response = client().performRequest(request); try (InputStream is = response.getEntity().getContent()) { - return XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true); + return XContentHelper.convertToMap(MediaTypeRegistry.JSON.xContent(), is, true); } } @@ -1088,7 +1088,7 @@ protected static Map responseAsMap(Response response) throws IOE protected static void registerRepository(String repository, String type, boolean verify, Settings settings) throws IOException { final Request request = new Request(HttpPut.METHOD_NAME, "_snapshot/" + repository); request.addParameter("verify", Boolean.toString(verify)); - request.setJsonEntity(Strings.toString(XContentType.JSON, new PutRepositoryRequest(repository).type(type).settings(settings))); + request.setJsonEntity(Strings.toString(MediaTypeRegistry.JSON, new PutRepositoryRequest(repository).type(type).settings(settings))); final Response response = client().performRequest(request); assertAcked("Failed to create repository [" + repository + "] of type [" + type + "]: " + response, response); diff --git a/test/framework/src/main/java/org/opensearch/test/rest/yaml/ClientYamlTestExecutionContext.java b/test/framework/src/main/java/org/opensearch/test/rest/yaml/ClientYamlTestExecutionContext.java index 3045b3fe66edc..f7585ae6f5799 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/yaml/ClientYamlTestExecutionContext.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/yaml/ClientYamlTestExecutionContext.java @@ -64,7 +64,7 @@ public class ClientYamlTestExecutionContext { private static final Logger logger = LogManager.getLogger(ClientYamlTestExecutionContext.class); - private static final XContentType[] STREAMING_CONTENT_TYPES = new XContentType[] { XContentType.JSON, XContentType.SMILE }; + private static final MediaType[] STREAMING_CONTENT_TYPES = new MediaType[] { MediaTypeRegistry.JSON, XContentType.SMILE }; private final Stash stash = new Stash(); private final ClientYamlTestClient clientYamlTestClient; @@ -168,7 +168,7 @@ private HttpEntity createEntity(List> bodies, Map headers, XContentType[] supportedContentTypes) { + private MediaType getContentType(Map headers, MediaType[] supportedContentTypes) { MediaType mediaType = null; String contentType = headers.get("Content-Type"); if (contentType != null) { @@ -180,7 +180,7 @@ private MediaType getContentType(Map headers, XContentType[] sup if (randomizeContentType) { return RandomizedTest.randomFrom(supportedContentTypes); } - return XContentType.JSON; + return MediaTypeRegistry.JSON; } private BytesRef bodyAsBytesRef(Map bodyAsMap, MediaType mediaType) throws IOException { diff --git a/test/framework/src/main/java/org/opensearch/test/rest/yaml/ClientYamlTestResponse.java b/test/framework/src/main/java/org/opensearch/test/rest/yaml/ClientYamlTestResponse.java index bba72c7ad758e..24506f207f219 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/yaml/ClientYamlTestResponse.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/yaml/ClientYamlTestResponse.java @@ -38,6 +38,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; @@ -124,7 +125,7 @@ public Object getBody() throws IOException { public String getBodyAsString() { if (bodyAsString == null && body != null) { // content-type null means that text was returned - if (bodyContentType == null || bodyContentType == XContentType.JSON || bodyContentType == XContentType.YAML) { + if (bodyContentType == null || bodyContentType == MediaTypeRegistry.JSON || bodyContentType == XContentType.YAML) { bodyAsString = new String(body, StandardCharsets.UTF_8); } else { // if the body is in a binary format and gets requested as a string (e.g. to log a test failure), we convert it to json diff --git a/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java b/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java index 14c0f2a5a9206..094af1efa208a 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java @@ -49,7 +49,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.common.collect.Tuple; import org.opensearch.common.io.PathUtils; -import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.common.util.io.IOUtils; import org.opensearch.test.rest.OpenSearchRestTestCase; @@ -451,7 +451,7 @@ private void executeSection(ExecutableSection executableSection) { // Dump the stash on failure. Instead of dumping it in true json we escape `\n`s so stack traces are easier to read logger.info( "Stash dump on test failure [{}]", - Strings.toString(XContentType.JSON, restTestExecutionContext.stash(), true, true) + Strings.toString(MediaTypeRegistry.JSON, restTestExecutionContext.stash(), true, true) .replace("\\n", "\n") .replace("\\r", "\r") .replace("\\t", "\t") diff --git a/test/framework/src/test/java/org/opensearch/test/AbstractXContentTestCaseTests.java b/test/framework/src/test/java/org/opensearch/test/AbstractXContentTestCaseTests.java index f47e0f9ea75b5..d880967c4452a 100644 --- a/test/framework/src/test/java/org/opensearch/test/AbstractXContentTestCaseTests.java +++ b/test/framework/src/test/java/org/opensearch/test/AbstractXContentTestCaseTests.java @@ -35,10 +35,10 @@ import com.carrotsearch.randomizedtesting.RandomizedContext; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import java.util.Map; @@ -59,14 +59,14 @@ public void testInsertRandomFieldsAndShuffle() throws Exception { 1, () -> AbstractXContentTestCase.insertRandomFieldsAndShuffle( BytesReference.bytes(builder), - XContentType.JSON, + MediaTypeRegistry.JSON, true, new String[] {}, null, this::createParser ) ); - try (XContentParser parser = createParser(XContentType.JSON.xContent(), insertRandomFieldsAndShuffle)) { + try (XContentParser parser = createParser(MediaTypeRegistry.JSON.xContent(), insertRandomFieldsAndShuffle)) { Map mapOrdered = parser.mapOrdered(); assertThat(mapOrdered.size(), equalTo(2)); assertThat(mapOrdered.keySet().iterator().next(), not(equalTo("field"))); diff --git a/test/framework/src/test/java/org/opensearch/test/XContentTestUtilsTests.java b/test/framework/src/test/java/org/opensearch/test/XContentTestUtilsTests.java index 4e1cb8debb4fc..cc5c9230e6f39 100644 --- a/test/framework/src/test/java/org/opensearch/test/XContentTestUtilsTests.java +++ b/test/framework/src/test/java/org/opensearch/test/XContentTestUtilsTests.java @@ -34,12 +34,12 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import java.io.IOException; @@ -111,28 +111,28 @@ public void testInsertIntoXContent() throws IOException { builder.startObject(); builder.endObject(); builder = XContentTestUtils.insertIntoXContent( - XContentType.JSON.xContent(), + MediaTypeRegistry.JSON.xContent(), BytesReference.bytes(builder), Collections.singletonList(""), () -> "inn.er1", () -> new HashMap<>() ); builder = XContentTestUtils.insertIntoXContent( - XContentType.JSON.xContent(), + MediaTypeRegistry.JSON.xContent(), BytesReference.bytes(builder), Collections.singletonList(""), () -> "field1", () -> "value1" ); builder = XContentTestUtils.insertIntoXContent( - XContentType.JSON.xContent(), + MediaTypeRegistry.JSON.xContent(), BytesReference.bytes(builder), Collections.singletonList("inn\\.er1"), () -> "inner2", () -> new HashMap<>() ); builder = XContentTestUtils.insertIntoXContent( - XContentType.JSON.xContent(), + MediaTypeRegistry.JSON.xContent(), BytesReference.bytes(builder), Collections.singletonList("inn\\.er1"), () -> "field2", @@ -194,7 +194,7 @@ public void testInsertRandomXContent() throws IOException { try ( XContentParser parser = createParser( - XContentType.JSON.xContent(), + MediaTypeRegistry.JSON.xContent(), insertRandomFields(builder.contentType(), BytesReference.bytes(builder), null, random()) ) ) { @@ -212,7 +212,7 @@ public void testInsertRandomXContent() throws IOException { Predicate pathsToExclude = path -> path.endsWith("foo1"); try ( XContentParser parser = createParser( - XContentType.JSON.xContent(), + MediaTypeRegistry.JSON.xContent(), insertRandomFields(builder.contentType(), BytesReference.bytes(builder), pathsToExclude, random()) ) ) { @@ -230,7 +230,7 @@ public void testInsertRandomXContent() throws IOException { pathsToExclude = path -> path.contains("foo1"); try ( XContentParser parser = createParser( - XContentType.JSON.xContent(), + MediaTypeRegistry.JSON.xContent(), insertRandomFields(builder.contentType(), BytesReference.bytes(builder), pathsToExclude, random()) ) ) { From d014c4d280108db78427f330c7ea1c677c22603e Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Thu, 10 Aug 2023 07:26:47 -0400 Subject: [PATCH 10/26] [BUG] org.opensearch.client.RestClientSingleHostIntegTests.testRequestResetAndAbort is flaky (#9206) Signed-off-by: Andriy Redko --- .../RestClientSingleHostIntegTests.java | 86 ++++++++++++++----- 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java b/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java index beee1c5ca21a0..3d6700118ea57 100644 --- a/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java +++ b/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java @@ -48,6 +48,7 @@ import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.io.entity.StringEntity; import org.apache.hc.core5.http.message.BasicHeader; @@ -73,6 +74,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Future; +import java.util.concurrent.Phaser; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; @@ -298,37 +300,70 @@ public void testRequestResetAndAbort() throws Exception { httpGet.reset(); assertFalse(httpGet.isAborted()); - Future future = client.execute(getRequestProducer(httpGet, httpHost), getResponseConsumer(), null); - httpGet.setDependency((org.apache.hc.core5.concurrent.Cancellable) future); - httpGet.abort(); + final Phaser phaser = new Phaser(2); + phaser.register(); try { - future.get(); - fail("expected cancellation exception"); - } catch (CancellationException e) { - // expected + Future future = client.execute( + getRequestProducer(httpGet, httpHost), + getResponseConsumer(phaser), + null + ); + httpGet.setDependency((org.apache.hc.core5.concurrent.Cancellable) future); + httpGet.abort(); + + try { + phaser.arriveAndDeregister(); + future.get(); + fail("expected cancellation exception"); + } catch (CancellationException e) { + // expected + } + assertTrue(future.isCancelled()); + } finally { + // Forcing termination since the AsyncResponseConsumer may not be reached, + // the request is aborted right before + phaser.forceTermination(); } - assertTrue(future.isCancelled()); } { - httpGet.reset(); - Future future = client.execute(getRequestProducer(httpGet, httpHost), getResponseConsumer(), null); - assertFalse(httpGet.isAborted()); - httpGet.setDependency((org.apache.hc.core5.concurrent.Cancellable) future); - httpGet.abort(); - assertTrue(httpGet.isAborted()); + final Phaser phaser = new Phaser(2); + phaser.register(); + try { - assertTrue(future.isCancelled()); - future.get(); - throw new AssertionError("exception should have been thrown"); - } catch (CancellationException e) { - // expected + httpGet.reset(); + Future future = client.execute( + getRequestProducer(httpGet, httpHost), + getResponseConsumer(phaser), + null + ); + assertFalse(httpGet.isAborted()); + httpGet.setDependency((org.apache.hc.core5.concurrent.Cancellable) future); + httpGet.abort(); + assertTrue(httpGet.isAborted()); + try { + phaser.arriveAndDeregister(); + assertTrue(future.isCancelled()); + future.get(); + throw new AssertionError("exception should have been thrown"); + } catch (CancellationException e) { + // expected + } + } finally { + // Forcing termination since the AsyncResponseConsumer may not be reached, + // the request is aborted right before + phaser.forceTermination(); } } { httpGet.reset(); assertFalse(httpGet.isAborted()); - Future future = client.execute(getRequestProducer(httpGet, httpHost), getResponseConsumer(), null); + final Phaser phaser = new Phaser(0); + Future future = client.execute( + getRequestProducer(httpGet, httpHost), + getResponseConsumer(phaser), + null + ); assertFalse(httpGet.isAborted()); assertEquals(200, future.get().getCode()); assertFalse(future.isCancelled()); @@ -554,8 +589,15 @@ private Response bodyTest(RestClient restClient, String method, int statusCode, return esResponse; } - private AsyncResponseConsumer getResponseConsumer() { - return new HeapBufferedAsyncResponseConsumer(1024); + private AsyncResponseConsumer getResponseConsumer(Phaser phaser) { + phaser.register(); + return new HeapBufferedAsyncResponseConsumer(1024) { + @Override + protected ClassicHttpResponse buildResult(HttpResponse response, byte[] entity, ContentType contentType) { + phaser.arriveAndAwaitAdvance(); + return super.buildResult(response, entity, contentType); + } + }; } private HttpUriRequestProducer getRequestProducer(HttpUriRequestBase request, HttpHost host) { From 61f865db1d4622df9aed603f75565679154f0c9b Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 11 Aug 2023 03:43:37 +1200 Subject: [PATCH 11/26] Add release notes for 1.3.12 (#9214) Signed-off-by: Thomas Farr --- release-notes/opensearch.release-notes-1.3.12.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 release-notes/opensearch.release-notes-1.3.12.md diff --git a/release-notes/opensearch.release-notes-1.3.12.md b/release-notes/opensearch.release-notes-1.3.12.md new file mode 100644 index 0000000000000..88551642e3c6d --- /dev/null +++ b/release-notes/opensearch.release-notes-1.3.12.md @@ -0,0 +1,8 @@ +## 2023-08-09 Version 1.3.12 Release Notes + +### Upgrades +- Upgrade `org.bouncycastle:bcprov-jdk15on` to `org.bouncycastle:bcprov-jdk15to18` version 1.75 ([#8247](https://github.com/opensearch-project/OpenSearch/pull/8247)) +- Upgrade `org.bouncycastle:bcmail-jdk15on` to `org.bouncycastle:bcmail-jdk15to18` version 1.75 ([#8247](https://github.com/opensearch-project/OpenSearch/pull/8247)) +- Upgrade `org.bouncycastle:bcpkix-jdk15on` to `org.bouncycastle:bcpkix-jdk15to18` version 1.75 ([#8247](https://github.com/opensearch-project/OpenSearch/pull/8247)) +- Upgrade `netty` from 4.1.94.Final to 4.1.96.Final ([#9030](https://github.com/opensearch-project/OpenSearch/pull/9030)) +- Upgrade bundled OpenJDK (July 2023 Patch releases) ([#8872](https://github.com/opensearch-project/OpenSearch/pull/8872)) From d06926c863c4a1ad0caf9e87f43fc7c8d6369b8c Mon Sep 17 00:00:00 2001 From: Gaurav Bafna <85113518+gbbafna@users.noreply.github.com> Date: Thu, 10 Aug 2023 21:25:42 +0530 Subject: [PATCH 12/26] [Remote Store] Fix couple of Remote Store flaky test and use bulk api for ingestion (#9190) --------- Signed-off-by: Gaurav Bafna --- .../RemoteStoreBaseIntegTestCase.java | 40 ++++++++++++++----- .../opensearch/remotestore/RemoteStoreIT.java | 26 ++++++------ .../ReplicaToPrimaryPromotionIT.java | 3 +- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBaseIntegTestCase.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBaseIntegTestCase.java index a890bdb8f4963..617510bf8222c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBaseIntegTestCase.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBaseIntegTestCase.java @@ -9,6 +9,10 @@ package org.opensearch.remotestore; import org.junit.After; +import org.opensearch.action.bulk.BulkItemResponse; +import org.opensearch.action.bulk.BulkRequest; +import org.opensearch.action.bulk.BulkResponse; +import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.UUIDs; @@ -31,10 +35,10 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import static org.opensearch.indices.IndicesService.CLUSTER_REPLICATION_TYPE_SETTING; -import static org.opensearch.indices.IndicesService.CLUSTER_REMOTE_STORE_ENABLED_SETTING; import static org.opensearch.indices.IndicesService.CLUSTER_REMOTE_SEGMENT_STORE_REPOSITORY_SETTING; +import static org.opensearch.indices.IndicesService.CLUSTER_REMOTE_STORE_ENABLED_SETTING; import static org.opensearch.indices.IndicesService.CLUSTER_REMOTE_TRANSLOG_REPOSITORY_SETTING; +import static org.opensearch.indices.IndicesService.CLUSTER_REPLICATION_TYPE_SETTING; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; public class RemoteStoreBaseIntegTestCase extends OpenSearchIntegTestCase { @@ -74,13 +78,18 @@ protected Map indexData(int numberOfIterations, boolean invokeFlus indexingStats.put(MAX_SEQ_NO_REFRESHED_OR_FLUSHED + "-shard-" + shardId, maxSeqNoRefreshedOrFlushed); refreshedOrFlushedOperations = totalOperations; int numberOfOperations = randomIntBetween(20, 50); - for (int j = 0; j < numberOfOperations; j++) { - IndexResponse response = indexSingleDoc(index); - maxSeqNo = response.getSeqNo(); - shardId = response.getShardId().id(); - indexingStats.put(MAX_SEQ_NO_TOTAL + "-shard-" + shardId, maxSeqNo); + int numberOfBulk = randomIntBetween(1, 5); + for (int j = 0; j < numberOfBulk; j++) { + BulkResponse res = indexBulk(index, numberOfOperations); + for (BulkItemResponse singleResp : res.getItems()) { + indexingStats.put( + MAX_SEQ_NO_TOTAL + "-shard-" + singleResp.getResponse().getShardId().id(), + singleResp.getResponse().getSeqNo() + ); + maxSeqNo = singleResp.getResponse().getSeqNo(); + } + totalOperations += numberOfOperations; } - totalOperations += numberOfOperations; } indexingStats.put(TOTAL_OPERATIONS, totalOperations); @@ -123,6 +132,18 @@ protected IndexResponse indexSingleDoc(String indexName) { .get(); } + protected BulkResponse indexBulk(String indexName, int numDocs) { + BulkRequest bulkRequest = new BulkRequest(); + for (int i = 0; i < numDocs; i++) { + final IndexRequest request = client().prepareIndex(indexName) + .setId(UUIDs.randomBase64UUID()) + .setSource(documentKeys.get(randomIntBetween(0, documentKeys.size() - 1)), randomAlphaOfLength(5)) + .request(); + bulkRequest.add(request); + } + return client().bulk(bulkRequest).actionGet(); + } + public static Settings remoteStoreClusterSettings(String segmentRepoName) { return remoteStoreClusterSettings(segmentRepoName, segmentRepoName); } @@ -170,10 +191,11 @@ protected Settings remoteStoreIndexSettings(int numberOfReplicas) { return remoteStoreIndexSettings(numberOfReplicas, 1); } - protected Settings remoteStoreIndexSettings(int numberOfReplicas, long totalFieldLimit) { + protected Settings remoteStoreIndexSettings(int numberOfReplicas, long totalFieldLimit, int refresh) { return Settings.builder() .put(remoteStoreIndexSettings(numberOfReplicas)) .put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), totalFieldLimit) + .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), String.valueOf(refresh)) .build(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java index 1bd0915a45048..b7bb0cc6608d0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreIT.java @@ -16,7 +16,6 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.routing.RecoverySource; import org.opensearch.common.settings.Settings; -import org.opensearch.index.shard.RemoteStoreRefreshListener; import org.opensearch.indices.recovery.RecoveryState; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -29,12 +28,10 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.oneOf; -import static org.hamcrest.Matchers.comparesEqualTo; import static org.hamcrest.Matchers.comparesEqualTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.oneOf; +import static org.opensearch.index.shard.RemoteStoreRefreshListener.LAST_N_METADATA_FILES_TO_KEEP; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount; @@ -148,10 +145,9 @@ public void testRemoteTranslogCleanup() throws Exception { verifyRemoteStoreCleanup(); } - @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/8658") public void testStaleCommitDeletionWithInvokeFlush() throws Exception { - internalCluster().startDataOnlyNodes(3); - createIndex(INDEX_NAME, remoteStoreIndexSettings(1, 10000l)); + internalCluster().startDataOnlyNodes(1); + createIndex(INDEX_NAME, remoteStoreIndexSettings(1, 10000l, -1)); int numberOfIterations = randomIntBetween(5, 15); indexData(numberOfIterations, true, INDEX_NAME); String indexUUID = client().admin() @@ -163,20 +159,22 @@ public void testStaleCommitDeletionWithInvokeFlush() throws Exception { // Delete is async. assertBusy(() -> { int actualFileCount = getFileCount(indexPath); - if (numberOfIterations <= RemoteStoreRefreshListener.LAST_N_METADATA_FILES_TO_KEEP) { - MatcherAssert.assertThat(actualFileCount, is(oneOf(numberOfIterations, numberOfIterations + 1))); + if (numberOfIterations <= LAST_N_METADATA_FILES_TO_KEEP) { + MatcherAssert.assertThat(actualFileCount, is(oneOf(numberOfIterations - 1, numberOfIterations, numberOfIterations + 1))); } else { // As delete is async its possible that the file gets created before the deletion or after // deletion. - MatcherAssert.assertThat(actualFileCount, is(oneOf(10, 11))); + MatcherAssert.assertThat( + actualFileCount, + is(oneOf(LAST_N_METADATA_FILES_TO_KEEP - 1, LAST_N_METADATA_FILES_TO_KEEP, LAST_N_METADATA_FILES_TO_KEEP + 1)) + ); } }, 30, TimeUnit.SECONDS); } - @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/8658") public void testStaleCommitDeletionWithoutInvokeFlush() throws Exception { - internalCluster().startDataOnlyNodes(3); - createIndex(INDEX_NAME, remoteStoreIndexSettings(1, 10000l)); + internalCluster().startDataOnlyNodes(1); + createIndex(INDEX_NAME, remoteStoreIndexSettings(1, 10000l, -1)); int numberOfIterations = randomIntBetween(5, 15); indexData(numberOfIterations, false, INDEX_NAME); String indexUUID = client().admin() @@ -187,6 +185,6 @@ public void testStaleCommitDeletionWithoutInvokeFlush() throws Exception { Path indexPath = Path.of(String.valueOf(absolutePath), indexUUID, "/0/segments/metadata"); int actualFileCount = getFileCount(indexPath); // We also allow (numberOfIterations + 1) as index creation also triggers refresh. - MatcherAssert.assertThat(actualFileCount, is(oneOf(numberOfIterations, numberOfIterations + 1))); + MatcherAssert.assertThat(actualFileCount, is(oneOf(numberOfIterations - 1, numberOfIterations, numberOfIterations + 1))); } } diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/ReplicaToPrimaryPromotionIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/ReplicaToPrimaryPromotionIT.java index b68fd1f764a63..275197ec831d3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/ReplicaToPrimaryPromotionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/ReplicaToPrimaryPromotionIT.java @@ -122,7 +122,6 @@ public void testPromoteReplicaToPrimary() throws Exception { assertHitCount(client().prepareSearch(indexName).setSize(0).get(), numOfDocs); } - @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/9130") public void testFailoverWhileIndexing() throws Exception { internalCluster().startNode(); internalCluster().startNode(); @@ -143,7 +142,7 @@ public void testFailoverWhileIndexing() throws Exception { .setSource("field", numAutoGenDocs.get()) .get(); - if (indexResponse.status() == RestStatus.CREATED || indexResponse.status() == RestStatus.ACCEPTED) { + if (indexResponse.status() == RestStatus.CREATED || indexResponse.status() == RestStatus.OK) { numAutoGenDocs.incrementAndGet(); if (numAutoGenDocs.get() == docCount / 2) { if (random().nextInt(3) == 0) { From de2b6b7a6b7cafea204f1d9b3ff0830780bafc08 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Thu, 10 Aug 2023 13:50:07 -0500 Subject: [PATCH 13/26] [Refactor] Task foundation classes to core library - pt 1 (#9082) This is the first round refactor of the foundation Task classes from the server module to core and common library. This is split into separate commits due to control the surface area impacted by the change. This commit refactors the following classes: * o.o.action.ActionFuture -> :libs:opensearch-common * o.o.action.ActionListener -> :libs:opensearch-core * o.o.action.ActionResponse -> :libs:opensearch-core * o.o.action.NotifyOnceListener -> :libs:opensearch-core * o.o.common.compress.Compressor -> :libs:opensearch-core * o.o.node.ReportingService -> o.o.core.service in :libs:opensearch-core * o.o.tasks.TaskCancelledExceptoin -> :libs:opensearch-core * o.o.tasks.TaskId -> :libs:opensearch-core * o.o.common.xcontent.ObjectParserHelper -> :libs:opensearch-core The following task resource tracking classes are refactored into a new resourcetracker namespace under the o.o.core.tasks packed in :libs:opensearch-core * o.o.tasks.ResourceStats * o.o.tasks.ResourceStatsType * o.o.tasks.ResourceUsageMetric * o.o.tasks.TaskResourceStats * o.o.tasks.TaskResourceUsage * o.o.tasks.TaskThreadUsage * o.o.tasks.ThreadResourceInfo These refactors are part of the effort to split foundation classes into core libraries in support of modularity for serverless and cloud native implementations. Signed-off-by: Nicholas Walter Knize --- .../opensearch/plugin/noop/NoopPlugin.java | 2 +- .../action/bulk/TransportNoopBulkAction.java | 2 +- .../search/TransportNoopSearchAction.java | 2 +- .../org/opensearch/client/ClusterClient.java | 2 +- .../org/opensearch/client/IndicesClient.java | 2 +- .../org/opensearch/client/IngestClient.java | 2 +- .../opensearch/client/RequestConverters.java | 4 +-- .../client/RestHighLevelClient.java | 2 +- .../opensearch/client/RethrottleRequest.java | 2 +- .../client/SearchPipelineClient.java | 2 +- .../org/opensearch/client/SnapshotClient.java | 2 +- .../org/opensearch/client/TasksClient.java | 2 +- .../org/opensearch/client/tasks/TaskId.java | 2 +- .../CustomRestHighLevelClientTests.java | 2 +- ...OpenSearchRestHighLevelClientTestCase.java | 4 +-- .../java/org/opensearch/client/PitIT.java | 2 +- .../java/org/opensearch/client/ReindexIT.java | 4 +-- .../client/RequestConvertersTests.java | 2 +- .../client/RestHighLevelClientTests.java | 2 +- .../java/org/opensearch/client/SearchIT.java | 4 +-- .../client/TasksRequestConvertersTests.java | 2 +- .../opensearch/client/UpdateByQueryIT.java | 4 +-- .../core/tasks/GetTaskResponseTests.java | 8 ++--- .../documentation/CRUDDocumentationIT.java | 12 ++++---- .../ClusterClientDocumentationIT.java | 2 +- .../IndicesClientDocumentationIT.java | 2 +- .../IngestClientDocumentationIT.java | 2 +- .../documentation/SearchDocumentationIT.java | 2 +- .../SnapshotClientDocumentationIT.java | 2 +- .../StoredScriptsDocumentationIT.java | 2 +- .../TasksClientDocumentationIT.java | 4 +-- .../tasks/CancelTasksResponseTests.java | 2 +- .../opensearch/test/rest/NodeRestUsageIT.java | 1 - .../test/rest/WaitForRefreshAndCloseIT.java | 2 +- .../common}/action/ActionFuture.java | 2 +- .../common/action/package-info.java | 10 +++++++ .../org/opensearch/OpenSearchException.java | 8 +++++ .../core}/action/ActionListener.java | 2 +- .../core}/action/ActionResponse.java | 2 +- .../core}/action/NotifyOnceListener.java | 2 +- .../core}/common/compress/Compressor.java | 2 +- .../core/service}/ReportingService.java | 2 +- .../opensearch/core/service/package-info.java | 10 +++++++ .../core}/tasks/TaskCancelledException.java | 2 +- .../org/opensearch/core}/tasks/TaskId.java | 2 +- .../opensearch/core/tasks/package-info.java | 10 +++++++ .../tasks/resourcetracker}/ResourceStats.java | 2 +- .../resourcetracker}/ResourceStatsType.java | 2 +- .../resourcetracker}/ResourceUsageInfo.java | 4 +-- .../resourcetracker}/ResourceUsageMetric.java | 2 +- .../resourcetracker}/TaskResourceStats.java | 6 ++-- .../resourcetracker}/TaskResourceUsage.java | 2 +- .../resourcetracker}/TaskThreadUsage.java | 2 +- .../resourcetracker}/ThreadResourceInfo.java | 2 +- .../tasks/resourcetracker/package-info.java | 9 ++++++ .../core}/xcontent/ObjectParserHelper.java | 9 ++---- .../core}/action/ActionListenerTests.java | 2 +- .../core}/action/NotifyOnceListenerTests.java | 2 +- ...ultShardOperationFailedExceptionTests.java | 4 +-- .../common/xcontent/XContentParserTests.java | 2 +- .../ingest/common/GrokProcessorGetAction.java | 4 +-- .../common/IngestCommonModulePlugin.java | 2 +- .../common/GrokProcessorGetActionTests.java | 2 +- .../mustache/MultiSearchTemplateResponse.java | 2 +- .../script/mustache/MustacheModulePlugin.java | 2 +- .../mustache/SearchTemplateResponse.java | 2 +- .../TransportMultiSearchTemplateAction.java | 2 +- .../TransportSearchTemplateAction.java | 2 +- .../painless/PainlessModulePlugin.java | 2 +- .../action/PainlessContextAction.java | 4 +-- .../action/PainlessExecuteAction.java | 2 +- .../RankFeatureMetaFieldMapperTests.java | 2 +- .../percolator/PercolatorQuerySearchIT.java | 8 ++--- .../percolator/PercolateQueryBuilder.java | 2 +- .../index/rankeval/RankEvalModulePlugin.java | 2 +- .../index/rankeval/RankEvalResponse.java | 2 +- .../rankeval/TransportRankEvalAction.java | 2 +- .../TransportRankEvalActionTests.java | 2 +- .../documentation/ReindexDocumentationIT.java | 4 +-- .../AbstractAsyncBulkByScrollAction.java | 2 +- .../reindex/AsyncDeleteByQueryAction.java | 2 +- .../BulkByScrollParallelizationHelper.java | 4 +-- .../index/reindex/ReindexModulePlugin.java | 2 +- .../opensearch/index/reindex/Reindexer.java | 2 +- .../index/reindex/RestRethrottleAction.java | 2 +- .../reindex/TransportDeleteByQueryAction.java | 2 +- .../index/reindex/TransportReindexAction.java | 2 +- .../reindex/TransportRethrottleAction.java | 4 +-- .../reindex/TransportUpdateByQueryAction.java | 2 +- .../reindex/spi/RemoteReindexExtension.java | 2 +- .../reindex/AsyncBulkByScrollActionTests.java | 6 ++-- .../opensearch/index/reindex/CancelTests.java | 4 +-- .../ClientScrollableHitSourceTests.java | 6 ++-- .../ReindexFromRemoteWithAuthTests.java | 4 +-- .../index/reindex/RethrottleTests.java | 4 +-- .../opensearch/index/reindex/RetryTests.java | 2 +- .../index/reindex/RoundTripTests.java | 2 +- .../TransportRethrottleActionTests.java | 4 +-- .../http/netty4/Netty4HttpChannel.java | 2 +- .../http/netty4/Netty4HttpServerChannel.java | 2 +- .../transport/netty4/Netty4TcpChannel.java | 2 +- .../netty4/Netty4TcpServerChannel.java | 2 +- .../netty4/SimpleNetty4TransportTests.java | 2 +- .../correlation/EventsCorrelationPlugin.java | 2 +- .../action/IndexCorrelationRuleResponse.java | 2 +- .../TransportIndexCorrelationRuleAction.java | 2 +- .../utils/CorrelationRuleIndices.java | 2 +- .../plugin/correlation/utils/IndexUtils.java | 2 +- .../azure/AzureBlobContainer.java | 2 +- .../repositories/s3/S3BlobContainer.java | 2 +- .../repositories/s3/S3Repository.java | 2 +- .../s3/S3BlobContainerMockClientTests.java | 2 +- .../s3/S3BlobContainerRetriesTests.java | 2 +- .../s3/S3BlobStoreContainerTests.java | 2 +- .../opensearch/http/nio/NioHttpChannel.java | 2 +- .../http/nio/NioHttpServerChannel.java | 2 +- .../http/nio/NioHttpServerTransport.java | 2 +- .../transport/nio/NioTcpChannel.java | 2 +- .../transport/nio/NioTcpServerChannel.java | 2 +- .../transport/nio/NioTransport.java | 2 +- .../opensearch/http/nio/NioHttpClient.java | 2 +- .../nio/SimpleNioTransportTests.java | 2 +- ...rossClusterSearchUnavailableClusterIT.java | 1 + .../org/opensearch/backwards/IndexingIT.java | 1 + .../java/org/opensearch/search/CCSDuelIT.java | 2 +- .../http/SearchRestCancellationIT.java | 2 +- .../opensearch/action/ListenerActionIT.java | 1 + .../opensearch/action/RejectionActionIT.java | 1 + .../opensearch/action/admin/HotThreadsIT.java | 2 +- .../action/admin/ReloadSecureSettingsIT.java | 2 +- .../cluster/node/tasks/AbstractTasksIT.java | 4 +-- .../node/tasks/CancellableTasksIT.java | 10 +++---- .../node/tasks/ConcurrentSearchTasksIT.java | 2 +- .../node/tasks/TaskStorageRetryIT.java | 2 +- .../admin/cluster/node/tasks/TasksIT.java | 6 ++-- .../admin/indices/create/CreateIndexIT.java | 2 +- .../action/bulk/BulkRejectionIT.java | 2 +- .../SearchProgressActionListenerIT.java | 2 +- .../action/search/TransportSearchIT.java | 2 +- .../support/ActiveShardsObserverIT.java | 2 +- ...tReplicationActionRetryOnClosedNodeIT.java | 4 +-- .../action/termvectors/GetTermVectorsIT.java | 2 +- .../opensearch/cluster/ClusterHealthIT.java | 2 +- .../cluster/ClusterInfoServiceIT.java | 2 +- .../action/shard/ShardStateActionIT.java | 2 +- .../coordination/RareClusterStateIT.java | 4 +-- .../ClusterManagerTaskThrottlingIT.java | 2 +- .../discovery/ClusterDisruptionIT.java | 2 +- .../discovery/SnapshotDisruptionIT.java | 2 +- .../java/org/opensearch/get/GetActionIT.java | 4 +-- .../opensearch/index/IndexingPressureIT.java | 2 +- .../index/ShardIndexingPressureIT.java | 2 +- .../ShardIndexingPressureSettingsIT.java | 2 +- .../opensearch/index/WaitUntilRefreshIT.java | 2 +- .../index/seqno/RetentionLeaseIT.java | 2 +- .../opensearch/index/shard/IndexShardIT.java | 2 +- .../opensearch/index/shard/SearchIdleIT.java | 2 +- .../mapping/ConcurrentDynamicTemplateIT.java | 2 +- .../replication/SegmentReplicationIT.java | 2 +- .../SegmentReplicationRelocationIT.java | 2 +- .../indices/state/ReopenWhileClosingIT.java | 2 +- .../persistent/PersistentTasksExecutorIT.java | 2 +- .../decider/EnableAssignmentDeciderIT.java | 2 +- .../org/opensearch/recovery/RelocationIT.java | 2 +- .../mocks/MockFsVerifyingBlobContainer.java | 2 +- .../search/SearchCancellationIT.java | 4 +-- .../backpressure/SearchBackpressureIT.java | 8 ++--- .../functionscore/DecayFunctionScoreIT.java | 2 +- .../functionscore/FunctionScorePluginIT.java | 2 +- .../search/pit/DeletePitMultiNodeIT.java | 4 +-- .../opensearch/search/pit/PitMultiNodeIT.java | 4 +-- .../search/searchafter/SearchAfterIT.java | 2 +- .../search/slice/SearchSliceIT.java | 2 +- .../snapshots/AbortedRestoreIT.java | 2 +- .../opensearch/snapshots/CloneSnapshotIT.java | 2 +- .../snapshots/ConcurrentSnapshotsIT.java | 4 +-- .../DedicatedClusterSnapshotRestoreIT.java | 2 +- .../snapshots/DeleteSnapshotIT.java | 2 +- .../RemoteIndexSnapshotStatusApiIT.java | 2 +- .../RepositoryFilterUserMetadataIT.java | 2 +- .../snapshots/RestoreSnapshotIT.java | 2 +- .../SharedClusterSnapshotRestoreIT.java | 2 +- .../snapshots/SnapshotStatusApisIT.java | 2 +- .../java/org/opensearch/update/UpdateIT.java | 2 +- .../ConcurrentDocumentOperationIT.java | 2 +- .../versioning/SimpleVersioningIT.java | 2 +- .../opensearch/OpenSearchServerException.java | 8 ----- .../action/ActionListenerResponseHandler.java | 1 + .../org/opensearch/action/ActionModule.java | 1 + .../action/ActionRequestBuilder.java | 3 ++ .../org/opensearch/action/ActionRunnable.java | 1 + .../org/opensearch/action/ActionType.java | 1 + .../action/LatchedActionListener.java | 2 ++ .../action/ListenableActionFuture.java | 3 ++ .../org/opensearch/action/StepListener.java | 2 ++ .../action/TransportActionNodeProxy.java | 2 ++ .../ClusterAllocationExplainResponse.java | 2 +- ...ansportClusterAllocationExplainAction.java | 2 +- .../AddVotingConfigExclusionsResponse.java | 2 +- .../ClearVotingConfigExclusionsResponse.java | 2 +- ...nsportAddVotingConfigExclusionsAction.java | 2 +- ...portClearVotingConfigExclusionsAction.java | 2 +- ...ransportDeleteDecommissionStateAction.java | 2 +- .../get/GetDecommissionStateResponse.java | 2 +- .../TransportGetDecommissionStateAction.java | 2 +- .../put/TransportDecommissionAction.java | 2 +- .../cluster/health/ClusterHealthResponse.java | 2 +- .../health/TransportClusterHealthAction.java | 2 +- .../admin/cluster/node/info/NodeInfo.java | 2 +- .../cluster/node/info/PluginsAndModules.java | 2 +- .../node/liveness/LivenessResponse.java | 2 +- ...nsportNodesReloadSecureSettingsAction.java | 2 +- .../cancel/TransportCancelTasksAction.java | 2 +- .../node/tasks/get/GetTaskRequest.java | 2 +- .../node/tasks/get/GetTaskRequestBuilder.java | 2 +- .../node/tasks/get/GetTaskResponse.java | 2 +- .../tasks/get/TransportGetTaskAction.java | 4 +-- .../node/tasks/list/ListTasksResponse.java | 2 +- .../tasks/list/TransportListTasksAction.java | 2 +- .../cluster/remote/RemoteInfoResponse.java | 2 +- .../remote/TransportRemoteInfoAction.java | 2 +- .../restore/RestoreRemoteStoreResponse.java | 2 +- .../TransportRestoreRemoteStoreAction.java | 2 +- .../cleanup/CleanupRepositoryResponse.java | 2 +- .../TransportCleanupRepositoryAction.java | 2 +- .../TransportDeleteRepositoryAction.java | 2 +- .../get/GetRepositoriesResponse.java | 2 +- .../get/TransportGetRepositoriesAction.java | 2 +- .../put/TransportPutRepositoryAction.java | 2 +- .../TransportVerifyRepositoryAction.java | 2 +- .../verify/VerifyRepositoryResponse.java | 2 +- .../TransportClusterRerouteAction.java | 2 +- .../settings/ClusterGetSettingsResponse.java | 2 +- .../TransportClusterUpdateSettingsAction.java | 2 +- .../shards/ClusterSearchShardsResponse.java | 2 +- .../TransportClusterSearchShardsAction.java | 2 +- .../TransportDeleteWeightedRoutingAction.java | 2 +- .../ClusterGetWeightedRoutingResponse.java | 2 +- .../TransportGetWeightedRoutingAction.java | 2 +- .../TransportAddWeightedRoutingAction.java | 2 +- .../clone/TransportCloneSnapshotAction.java | 2 +- .../create/CreateSnapshotResponse.java | 2 +- .../create/TransportCreateSnapshotAction.java | 2 +- .../delete/TransportDeleteSnapshotAction.java | 2 +- .../snapshots/get/GetSnapshotsResponse.java | 2 +- .../get/TransportGetSnapshotsAction.java | 2 +- .../restore/RestoreClusterStateListener.java | 4 +-- .../restore/RestoreSnapshotResponse.java | 2 +- .../TransportRestoreSnapshotAction.java | 2 +- .../status/SnapshotsStatusResponse.java | 2 +- .../TransportSnapshotsStatusAction.java | 2 +- .../cluster/state/ClusterStateResponse.java | 2 +- .../state/TransportClusterStateAction.java | 2 +- .../GetScriptContextResponse.java | 2 +- .../GetScriptLanguageResponse.java | 2 +- .../GetStoredScriptResponse.java | 2 +- .../TransportDeleteStoredScriptAction.java | 2 +- .../TransportGetScriptContextAction.java | 2 +- .../TransportGetScriptLanguageAction.java | 2 +- .../TransportGetStoredScriptAction.java | 2 +- .../TransportPutStoredScriptAction.java | 2 +- .../tasks/PendingClusterTasksResponse.java | 2 +- .../TransportPendingClusterTasksAction.java | 2 +- .../alias/TransportIndicesAliasesAction.java | 2 +- .../alias/get/BaseAliasesRequestBuilder.java | 2 +- .../indices/alias/get/GetAliasesResponse.java | 2 +- .../alias/get/TransportGetAliasesAction.java | 2 +- .../admin/indices/analyze/AnalyzeAction.java | 2 +- .../close/TransportCloseIndexAction.java | 2 +- ...TransportVerifyShardBeforeCloseAction.java | 4 +-- .../indices/create/AutoCreateAction.java | 2 +- .../create/TransportCreateIndexAction.java | 2 +- .../TransportDeleteDanglingIndexAction.java | 2 +- .../TransportImportDanglingIndexAction.java | 2 +- .../datastream/CreateDataStreamAction.java | 2 +- .../datastream/DeleteDataStreamAction.java | 2 +- .../datastream/GetDataStreamAction.java | 4 +-- .../delete/TransportDeleteIndexAction.java | 2 +- .../exists/indices/IndicesExistsResponse.java | 2 +- .../indices/TransportIndicesExistsAction.java | 2 +- .../flush/TransportShardFlushAction.java | 2 +- .../admin/indices/get/GetIndexResponse.java | 2 +- .../indices/get/TransportGetIndexAction.java | 2 +- .../mapping/get/GetFieldMappingsResponse.java | 2 +- .../mapping/get/GetMappingsResponse.java | 2 +- .../get/TransportGetFieldMappingsAction.java | 2 +- .../get/TransportGetMappingsAction.java | 2 +- .../put/TransportAutoPutMappingAction.java | 2 +- .../put/TransportPutMappingAction.java | 2 +- .../open/TransportOpenIndexAction.java | 2 +- .../TransportAddIndexBlockAction.java | 2 +- .../TransportVerifyShardIndexBlockAction.java | 4 +-- .../refresh/TransportShardRefreshAction.java | 2 +- .../indices/resolve/ResolveIndexAction.java | 4 +-- .../rollover/TransportRolloverAction.java | 2 +- .../segments/TransportPitSegmentsAction.java | 2 +- .../settings/get/GetSettingsResponse.java | 6 ++-- .../get/TransportGetSettingsAction.java | 2 +- .../put/TransportUpdateSettingsAction.java | 2 +- .../shards/IndicesShardStoresResponse.java | 2 +- .../TransportIndicesShardStoresAction.java | 2 +- .../indices/shrink/TransportResizeAction.java | 2 +- ...ransportDeleteComponentTemplateAction.java | 2 +- ...rtDeleteComposableIndexTemplateAction.java | 2 +- .../TransportDeleteIndexTemplateAction.java | 2 +- .../get/GetComponentTemplateAction.java | 2 +- .../get/GetComposableIndexTemplateAction.java | 2 +- .../get/GetIndexTemplatesResponse.java | 2 +- .../TransportGetComponentTemplateAction.java | 2 +- ...sportGetComposableIndexTemplateAction.java | 2 +- .../get/TransportGetIndexTemplatesAction.java | 2 +- .../post/SimulateIndexTemplateResponse.java | 2 +- .../TransportSimulateIndexTemplateAction.java | 2 +- .../post/TransportSimulateTemplateAction.java | 2 +- .../TransportPutComponentTemplateAction.java | 2 +- ...sportPutComposableIndexTemplateAction.java | 2 +- .../put/TransportPutIndexTemplateAction.java | 2 +- .../upgrade/post/TransportUpgradeAction.java | 2 +- .../post/TransportUpgradeSettingsAction.java | 2 +- .../query/TransportValidateQueryAction.java | 2 +- .../opensearch/action/bulk/BulkProcessor.java | 2 +- .../action/bulk/BulkRequestHandler.java | 2 +- .../opensearch/action/bulk/BulkResponse.java | 2 +- .../action/bulk/MappingUpdatePerformer.java | 2 +- .../org/opensearch/action/bulk/Retry.java | 2 +- .../action/bulk/TransportBulkAction.java | 2 +- .../action/bulk/TransportShardBulkAction.java | 4 +-- .../TransportSingleItemBulkWriteAction.java | 2 +- .../action/explain/ExplainResponse.java | 2 +- .../explain/TransportExplainAction.java | 2 +- .../FieldCapabilitiesIndexResponse.java | 2 +- .../fieldcaps/FieldCapabilitiesResponse.java | 4 +-- .../TransportFieldCapabilitiesAction.java | 2 +- ...TransportFieldCapabilitiesIndexAction.java | 2 +- .../opensearch/action/get/GetResponse.java | 2 +- .../action/get/MultiGetRequest.java | 2 +- .../action/get/MultiGetResponse.java | 2 +- .../action/get/MultiGetShardResponse.java | 2 +- .../action/get/TransportGetAction.java | 2 +- .../action/get/TransportMultiGetAction.java | 2 +- .../get/TransportShardMultiGetAction.java | 2 +- .../ingest/DeletePipelineTransportAction.java | 2 +- .../action/ingest/GetPipelineResponse.java | 2 +- .../ingest/GetPipelineTransportAction.java | 2 +- .../action/ingest/IngestActionForwarder.java | 2 +- .../ingest/PutPipelineTransportAction.java | 2 +- .../ingest/SimulateExecutionService.java | 2 +- .../ingest/SimulatePipelineResponse.java | 2 +- .../SimulatePipelineTransportAction.java | 2 +- .../opensearch/action/main/MainResponse.java | 2 +- .../action/main/TransportMainAction.java | 2 +- .../TransportResyncReplicationAction.java | 2 +- .../search/AbstractSearchAsyncAction.java | 2 +- .../search/CanMatchPreFilterSearchPhase.java | 2 +- .../action/search/ClearScrollController.java | 2 +- .../action/search/ClearScrollResponse.java | 2 +- .../action/search/CreatePitController.java | 2 +- .../action/search/CreatePitRequest.java | 2 +- .../action/search/CreatePitResponse.java | 2 +- .../action/search/DeletePitResponse.java | 2 +- .../DeleteSearchPipelineTransportAction.java | 2 +- .../action/search/ExpandSearchPhase.java | 2 +- .../search/GetSearchPipelineResponse.java | 2 +- .../GetSearchPipelineTransportAction.java | 2 +- .../action/search/MultiSearchRequest.java | 2 +- .../action/search/MultiSearchResponse.java | 2 +- .../opensearch/action/search/PitService.java | 2 +- .../PutSearchPipelineTransportAction.java | 2 +- .../action/search/SearchActionListener.java | 2 +- .../SearchDfsQueryThenFetchAsyncAction.java | 2 +- .../search/SearchExecutionStatsCollector.java | 2 +- .../search/SearchProgressActionListener.java | 2 +- .../SearchQueryThenFetchAsyncAction.java | 2 +- .../action/search/SearchRequest.java | 2 +- .../action/search/SearchResponse.java | 2 +- .../search/SearchScrollAsyncAction.java | 2 +- .../SearchScrollQueryAndFetchAsyncAction.java | 2 +- ...SearchScrollQueryThenFetchAsyncAction.java | 2 +- .../action/search/SearchScrollRequest.java | 2 +- .../action/search/SearchShardTask.java | 2 +- .../opensearch/action/search/SearchTask.java | 2 +- .../action/search/SearchTransportService.java | 2 +- .../opensearch/action/search/SearchUtils.java | 2 +- .../search/TransportClearScrollAction.java | 2 +- .../search/TransportCreatePitAction.java | 2 +- .../search/TransportDeletePitAction.java | 2 +- .../search/TransportMultiSearchAction.java | 2 +- .../action/search/TransportSearchAction.java | 4 +-- .../search/TransportSearchScrollAction.java | 2 +- .../action/support/ActionFilter.java | 4 +-- .../action/support/ActionFilterChain.java | 4 +-- .../action/support/ActiveShardsObserver.java | 2 +- .../action/support/AdapterActionFuture.java | 4 +-- .../action/support/ChannelActionListener.java | 2 +- .../ContextPreservingActionListener.java | 2 +- .../action/support/GroupedActionListener.java | 2 +- .../support/HandledTransportAction.java | 2 +- .../action/support/ListenerTimeouts.java | 2 +- .../support/PlainListenableActionFuture.java | 2 +- .../action/support/RetryableAction.java | 2 +- .../support/ThreadedActionListener.java | 2 +- .../TimeoutTaskCancellationUtility.java | 4 +-- .../action/support/TransportAction.java | 8 ++--- .../support/broadcast/BroadcastResponse.java | 2 +- .../broadcast/TransportBroadcastAction.java | 2 +- .../node/TransportBroadcastByNodeAction.java | 2 +- ...terManagerNodeOperationRequestBuilder.java | 2 +- ...anagerNodeReadOperationRequestBuilder.java | 2 +- .../TransportClusterManagerNodeAction.java | 4 +-- ...TransportClusterManagerNodeReadAction.java | 2 +- .../info/ClusterInfoRequestBuilder.java | 2 +- .../info/TransportClusterInfoAction.java | 4 +-- .../support/master/AcknowledgedResponse.java | 2 +- .../MasterNodeOperationRequestBuilder.java | 2 +- ...MasterNodeReadOperationRequestBuilder.java | 2 +- .../master/TransportMasterNodeAction.java | 2 +- .../master/TransportMasterNodeReadAction.java | 2 +- .../info/ClusterInfoRequestBuilder.java | 2 +- .../info/TransportClusterInfoAction.java | 2 +- .../support/nodes/BaseNodesResponse.java | 2 +- .../support/nodes/TransportNodesAction.java | 2 +- .../replication/FanoutReplicationProxy.java | 2 +- .../ReplicationModeAwareProxy.java | 2 +- .../replication/ReplicationOperation.java | 2 +- .../support/replication/ReplicationProxy.java | 2 +- .../replication/ReplicationRequest.java | 2 +- .../ReplicationRequestBuilder.java | 2 +- .../replication/ReplicationResponse.java | 2 +- .../support/replication/ReplicationTask.java | 2 +- .../TransportBroadcastReplicationAction.java | 2 +- .../TransportReplicationAction.java | 6 ++-- .../replication/TransportWriteAction.java | 2 +- .../InstanceShardOperationRequestBuilder.java | 2 +- ...ransportInstanceSingleOperationAction.java | 4 +-- .../SingleShardOperationRequestBuilder.java | 2 +- .../shard/TransportSingleShardAction.java | 4 +-- .../support/tasks/BaseTasksRequest.java | 2 +- .../support/tasks/BaseTasksResponse.java | 4 +-- .../support/tasks/TasksRequestBuilder.java | 2 +- .../support/tasks/TransportTasksAction.java | 2 +- .../termvectors/MultiTermVectorsResponse.java | 2 +- .../MultiTermVectorsShardResponse.java | 2 +- .../termvectors/TermVectorsResponse.java | 2 +- .../TransportMultiTermVectorsAction.java | 2 +- .../TransportTermVectorsAction.java | 2 +- .../action/update/TransportUpdateAction.java | 2 +- .../java/org/opensearch/client/Client.java | 6 ++-- .../opensearch/client/ClusterAdminClient.java | 6 ++-- .../org/opensearch/client/FilterClient.java | 4 +-- .../opensearch/client/IndicesAdminClient.java | 4 +-- .../opensearch/client/OpenSearchClient.java | 6 ++-- .../client/OriginSettingClient.java | 4 +-- .../client/ParentTaskAssigningClient.java | 6 ++-- .../opensearch/client/node/NodeClient.java | 4 +-- .../client/support/AbstractClient.java | 10 +++---- .../cluster/AckedClusterStateUpdateTask.java | 2 +- .../cluster/InternalClusterInfoService.java | 2 +- .../cluster/NodeConnectionsService.java | 2 +- .../action/index/MappingUpdatedAction.java | 2 +- .../action/shard/ShardStateAction.java | 2 +- .../coordination/ClusterStatePublisher.java | 2 +- .../coordination/CompressedStreamUtils.java | 2 +- .../cluster/coordination/Coordinator.java | 2 +- .../cluster/coordination/JoinHelper.java | 2 +- .../coordination/JoinTaskExecutor.java | 2 +- .../cluster/coordination/Publication.java | 2 +- .../PublicationTransportHandler.java | 2 +- .../decommission/DecommissionController.java | 2 +- .../decommission/DecommissionService.java | 2 +- .../MetadataCreateDataStreamService.java | 2 +- .../metadata/MetadataCreateIndexService.java | 2 +- .../metadata/MetadataDeleteIndexService.java | 2 +- .../metadata/MetadataIndexAliasesService.java | 2 +- .../metadata/MetadataIndexStateService.java | 6 ++-- .../MetadataIndexTemplateService.java | 2 +- .../metadata/MetadataMappingService.java | 2 +- .../MetadataUpdateSettingsService.java | 2 +- .../metadata/TemplateUpgradeService.java | 2 +- .../routing/BatchedRerouteService.java | 2 +- .../cluster/routing/RerouteService.java | 2 +- .../routing/WeightedRoutingService.java | 2 +- .../allocation/DiskThresholdMonitor.java | 2 +- .../opensearch/common/AsyncBiFunction.java | 2 +- .../common/blobstore/BlobContainer.java | 2 +- .../VerifyingMultiStreamBlobContainer.java | 2 +- .../common/compress/CompressedXContent.java | 1 + .../common/compress/CompressorFactory.java | 1 + .../common/compress/CompressorType.java | 2 ++ .../common/compress/DeflateCompressor.java | 3 +- .../common/compress/NoneCompressor.java | 1 + .../common/compress/ZstdCompressor.java | 1 + .../common/network/CloseableChannel.java | 4 +-- .../util/concurrent/ListenableFuture.java | 2 +- .../common/xcontent/XContentHelper.java | 29 +------------------ .../HandshakingTransportAddressConnector.java | 4 +-- .../org/opensearch/discovery/PeerFinder.java | 2 +- .../action/ExtensionActionResponse.java | 2 +- .../action/ExtensionProxyTransportAction.java | 2 +- .../action/ExtensionTransportAction.java | 2 +- .../ExtensionTransportActionsHandler.java | 2 +- .../action/RemoteExtensionActionResponse.java | 2 +- .../opensearch/gateway/AsyncShardFetch.java | 2 +- .../gateway/DanglingIndicesState.java | 2 +- .../opensearch/gateway/GatewayAllocator.java | 2 +- .../gateway/LocalAllocateDangledIndices.java | 2 +- .../TransportNodesListGatewayMetaState.java | 2 +- ...ransportNodesListGatewayStartedShards.java | 2 +- .../http/AbstractHttpServerTransport.java | 2 +- .../opensearch/http/DefaultRestChannel.java | 2 +- .../java/org/opensearch/http/HttpChannel.java | 2 +- .../java/org/opensearch/http/HttpInfo.java | 2 +- .../opensearch/http/HttpServerTransport.java | 2 +- .../SegmentReplicationPressureService.java | 2 +- .../index/engine/CompletionStatsCache.java | 2 +- .../query/AbstractGeometryQueryBuilder.java | 2 +- .../index/query/MoreLikeThisQueryBuilder.java | 10 +++---- .../index/query/QueryRewriteContext.java | 2 +- .../index/query/QueryShardContext.java | 2 +- .../opensearch/index/query/Rewriteable.java | 2 +- .../index/query/TermsQueryBuilder.java | 2 +- .../reindex/AbstractBulkByScrollRequest.java | 2 +- .../AbstractBulkIndexByScrollRequest.java | 2 +- .../index/reindex/BulkByScrollResponse.java | 2 +- .../index/reindex/BulkByScrollTask.java | 2 +- .../reindex/ClientScrollableHitSource.java | 2 +- .../index/reindex/DeleteByQueryRequest.java | 2 +- .../reindex/LeaderBulkByScrollTaskState.java | 2 +- .../index/reindex/ReindexRequest.java | 2 +- .../reindex/RejectAwareActionListener.java | 2 +- .../index/reindex/RetryListener.java | 2 +- .../index/reindex/ScrollableHitSource.java | 2 +- .../index/reindex/UpdateByQueryRequest.java | 2 +- .../seqno/GlobalCheckpointSyncAction.java | 2 +- .../index/seqno/ReplicationTracker.java | 2 +- .../index/seqno/RetentionLeaseActions.java | 4 +-- .../RetentionLeaseBackgroundSyncAction.java | 4 +-- .../index/seqno/RetentionLeaseSyncAction.java | 4 +-- .../index/seqno/RetentionLeaseSyncer.java | 2 +- .../opensearch/index/shard/IndexShard.java | 2 +- .../shard/IndexShardOperationPermits.java | 2 +- .../index/shard/PrimaryReplicaSyncer.java | 4 +-- .../shard/RemoteStoreRefreshListener.java | 2 +- .../opensearch/index/shard/StoreRecovery.java | 2 +- .../index/store/RemoteDirectory.java | 2 +- .../store/RemoteSegmentStoreDirectory.java | 2 +- .../transfer/BlobStoreTransferService.java | 2 +- .../translog/transfer/TransferService.java | 2 +- .../transfer/TranslogTransferManager.java | 2 +- .../indices/RunUnderPrimaryPermit.java | 2 +- .../cluster/IndicesClusterStateService.java | 2 +- .../indices/recovery/FileChunkWriter.java | 2 +- .../LocalStorePeerRecoverySourceHandler.java | 2 +- .../indices/recovery/MultiChunkTransfer.java | 2 +- .../recovery/PeerRecoverySourceService.java | 2 +- .../recovery/PeerRecoveryTargetService.java | 2 +- .../recovery/RecoverySourceHandler.java | 2 +- .../indices/recovery/RecoveryTarget.java | 2 +- .../recovery/RecoveryTargetHandler.java | 2 +- .../recovery/RemoteRecoveryTargetHandler.java | 2 +- .../RemoteStorePeerRecoverySourceHandler.java | 2 +- .../recovery/RetryableTransportClient.java | 2 +- .../OngoingSegmentReplications.java | 2 +- .../PrimaryShardReplicationSource.java | 2 +- .../RemoteSegmentFileChunkWriter.java | 2 +- .../RemoteStoreReplicationSource.java | 2 +- .../SegmentFileTransferHandler.java | 2 +- .../replication/SegmentReplicationSource.java | 2 +- .../SegmentReplicationSourceHandler.java | 2 +- .../replication/SegmentReplicationTarget.java | 2 +- .../SegmentReplicationTargetService.java | 2 +- .../checkpoint/PublishCheckpointAction.java | 2 +- .../common/ReplicationRequestTracker.java | 2 +- .../replication/common/ReplicationTarget.java | 2 +- .../TransportNodesListShardStoreMetadata.java | 2 +- .../org/opensearch/ingest/IngestInfo.java | 2 +- .../org/opensearch/ingest/IngestService.java | 4 +-- .../org/opensearch/monitor/jvm/JvmInfo.java | 2 +- .../opensearch/monitor/jvm/JvmService.java | 2 +- .../org/opensearch/monitor/os/OsInfo.java | 2 +- .../org/opensearch/monitor/os/OsService.java | 2 +- .../monitor/process/ProcessInfo.java | 2 +- .../monitor/process/ProcessService.java | 2 +- .../persistent/AllocatedPersistentTask.java | 4 +-- .../CompletionPersistentTaskAction.java | 2 +- .../persistent/PersistentTaskResponse.java | 2 +- .../PersistentTasksClusterService.java | 2 +- .../persistent/PersistentTasksExecutor.java | 2 +- .../PersistentTasksNodeService.java | 4 +-- .../persistent/PersistentTasksService.java | 4 +-- .../RemovePersistentTaskAction.java | 2 +- .../persistent/StartPersistentTaskAction.java | 2 +- .../UpdatePersistentTaskStatusAction.java | 2 +- .../org/opensearch/plugins/ActionPlugin.java | 2 +- .../opensearch/plugins/PluginsService.java | 2 +- .../repositories/FilterRepository.java | 2 +- .../repositories/RepositoriesService.java | 2 +- .../opensearch/repositories/Repository.java | 2 +- .../VerifyNodeRepositoryAction.java | 2 +- .../blobstore/BlobStoreRepository.java | 4 +-- .../blobstore/ChecksumBlobStoreFormat.java | 2 +- .../blobstore/FileRestoreContext.java | 2 +- .../rest/action/RestActionListener.java | 2 +- .../action/RestCancellableNodeClient.java | 6 ++-- .../admin/cluster/RestCancelTasksAction.java | 2 +- .../admin/cluster/RestGetTaskAction.java | 2 +- .../admin/cluster/RestListTasksAction.java | 4 +-- .../rest/action/cat/RestIndicesAction.java | 4 +-- .../org/opensearch/script/ScriptService.java | 2 +- .../opensearch/script/StoredScriptSource.java | 7 ++--- .../java/org/opensearch/search/SearchHit.java | 8 ++--- .../org/opensearch/search/SearchService.java | 2 +- .../aggregations/support/AggregationInfo.java | 2 +- .../support/AggregationUsageService.java | 2 +- .../org/opensearch/search/dfs/DfsPhase.java | 2 +- .../opensearch/search/fetch/FetchPhase.java | 2 +- .../search/fetch/ShardFetchRequest.java | 2 +- .../internal/InternalScrollSearchRequest.java | 2 +- .../search/internal/ShardSearchRequest.java | 2 +- .../search/pipeline/SearchPipelineInfo.java | 2 +- .../pipeline/SearchPipelineService.java | 4 +-- .../opensearch/search/query/QueryPhase.java | 2 +- .../search/query/QuerySearchRequest.java | 2 +- .../InternalSnapshotsInfoService.java | 2 +- .../opensearch/snapshots/RestoreService.java | 4 +-- .../snapshots/SnapshotShardsService.java | 2 +- .../snapshots/SnapshotsService.java | 2 +- ...pdateIndexShardSnapshotStatusResponse.java | 2 +- .../org/opensearch/tasks/CancellableTask.java | 1 + .../main/java/org/opensearch/tasks/Task.java | 24 +++++++++------ .../opensearch/tasks/TaskAwareRequest.java | 2 ++ .../opensearch/tasks/TaskCancellation.java | 2 +- .../tasks/TaskCancellationService.java | 3 +- .../java/org/opensearch/tasks/TaskInfo.java | 8 +++-- .../org/opensearch/tasks/TaskManager.java | 12 ++++---- .../tasks/TaskResourceTrackingService.java | 5 +++- .../java/org/opensearch/tasks/TaskResult.java | 13 +++++---- .../opensearch/tasks/TaskResultsService.java | 2 +- .../tasks/consumer/TopNSearchTasksLogger.java | 2 +- .../org/opensearch/threadpool/ThreadPool.java | 2 +- .../opensearch/threadpool/ThreadPoolInfo.java | 2 +- .../transport/CloseableConnection.java | 2 +- .../transport/ClusterConnectionManager.java | 2 +- .../transport/ConnectionManager.java | 2 +- .../opensearch/transport/OutboundHandler.java | 4 +-- .../transport/ProxyConnectionStrategy.java | 2 +- .../transport/RemoteClusterAwareClient.java | 4 +-- .../transport/RemoteClusterConnection.java | 2 +- .../transport/RemoteClusterService.java | 2 +- .../transport/RemoteConnectionManager.java | 2 +- .../transport/RemoteConnectionStrategy.java | 2 +- .../transport/SniffConnectionStrategy.java | 2 +- .../org/opensearch/transport/TcpChannel.java | 2 +- .../opensearch/transport/TcpTransport.java | 2 +- .../org/opensearch/transport/Transport.java | 2 +- .../transport/TransportDecompressor.java | 2 +- .../transport/TransportHandshaker.java | 2 +- .../opensearch/transport/TransportInfo.java | 2 +- .../transport/TransportKeepAlive.java | 2 +- .../transport/TransportRequest.java | 2 +- .../TransportRequestDeduplicator.java | 2 +- .../transport/TransportService.java | 4 +-- .../ExceptionSerializationTests.java | 12 ++++---- .../opensearch/action/ActionModuleTests.java | 2 ++ .../org/opensearch/action/ActionTests.java | 1 + .../action/DynamicActionRegistryTests.java | 2 ++ .../node/tasks/CancellableTasksTests.java | 6 ++-- .../tasks/RecordingTaskManagerListener.java | 4 +-- .../node/tasks/ResourceAwareTasksTests.java | 10 +++---- .../admin/cluster/node/tasks/TaskTests.java | 8 ++--- .../cluster/node/tasks/TestTaskPlugin.java | 6 ++-- .../node/tasks/TransportTasksActionTests.java | 6 ++-- .../tasks/cancel/CancelTasksRequestTests.java | 2 +- .../cluster/reroute/ClusterRerouteTests.java | 2 +- .../cluster/state/ClusterStateApiTests.java | 2 +- .../indices/close/CloseIndexRequestTests.java | 2 +- ...portVerifyShardBeforeCloseActionTests.java | 4 +-- .../indices/get/GetIndexActionTests.java | 2 +- .../TransportRolloverActionTests.java | 2 +- .../settings/get/GetSettingsActionTests.java | 2 +- .../indices/stats/IndicesStatsTests.java | 2 +- .../TransportValidateQueryActionTests.java | 2 +- .../action/bulk/BulkProcessorTests.java | 2 +- .../action/bulk/BulkRequestModifierTests.java | 2 +- .../opensearch/action/bulk/RetryTests.java | 4 +-- ...ActionIndicesThatCannotBeCreatedTests.java | 2 +- .../bulk/TransportBulkActionIngestTests.java | 2 +- .../action/bulk/TransportBulkActionTests.java | 2 +- .../bulk/TransportBulkActionTookTests.java | 4 +-- .../bulk/TransportShardBulkActionTests.java | 2 +- .../get/TransportMultiGetActionTests.java | 4 +-- .../ingest/SimulateExecutionServiceTests.java | 2 +- .../action/main/MainActionTests.java | 2 +- ...TransportResyncReplicationActionTests.java | 2 +- .../AbstractSearchAsyncActionTests.java | 2 +- .../CanMatchPreFilterSearchPhaseTests.java | 2 +- .../search/ClearScrollControllerTests.java | 2 +- .../search/ClearScrollRequestTests.java | 8 ++--- .../search/CreatePitControllerTests.java | 4 +-- .../action/search/ExpandSearchPhaseTests.java | 2 +- .../search/MultiSearchActionTookTests.java | 2 +- .../search/MultiSearchRequestTests.java | 10 +++---- .../action/search/PitTestsUtil.java | 2 +- .../action/search/SearchAsyncActionTests.java | 2 +- .../action/search/SearchRequestTests.java | 2 +- .../search/SearchScrollAsyncActionTests.java | 2 +- .../search/SearchScrollRequestTests.java | 12 ++++---- .../search/TransportDeletePitActionTests.java | 4 +-- .../TransportMultiSearchActionTests.java | 2 +- .../search/TransportSearchActionTests.java | 2 +- .../ContextPreservingActionListenerTests.java | 2 +- .../support/GroupedActionListenerTests.java | 2 +- .../support/ListenableActionFutureTests.java | 2 +- .../action/support/ListenerTimeoutsTests.java | 2 +- .../action/support/RetryableActionTests.java | 2 +- .../TransportActionFilterChainTests.java | 4 +-- ...ransportClusterManagerNodeActionTests.java | 6 ++-- .../TransportMasterNodeActionUtils.java | 4 +-- .../BroadcastReplicationTests.java | 2 +- .../PendingReplicationActionsTests.java | 2 +- .../ReplicationOperationTests.java | 2 +- .../TransportReplicationActionTests.java | 2 +- ...ReplicationAllPermitsAcquisitionTests.java | 2 +- ...rtWriteActionForIndexingPressureTests.java | 2 +- .../TransportWriteActionTests.java | 2 +- ...ortInstanceSingleOperationActionTests.java | 4 +-- .../termvectors/TermVectorsUnitTests.java | 2 +- .../TransportMultiTermVectorsActionTests.java | 4 +-- .../client/AbstractClientHeadersTestCase.java | 2 +- .../client/OriginSettingClientTests.java | 4 +-- .../ParentTaskAssigningClientTests.java | 6 ++-- .../client/node/NodeClientHeadersTests.java | 2 +- ...rnalClusterInfoServiceSchedulingTests.java | 4 +-- .../cluster/NodeConnectionsServiceTests.java | 2 +- .../index/MappingUpdatedActionTests.java | 2 +- ...dStartedClusterStateTaskExecutorTests.java | 2 +- .../action/shard/ShardStateActionTests.java | 2 +- .../cluster/coordination/JoinHelperTests.java | 2 +- .../cluster/coordination/NodeJoinTests.java | 2 +- .../coordination/PublicationTests.java | 2 +- .../DecommissionControllerTests.java | 2 +- .../DecommissionServiceTests.java | 2 +- .../MetadataIndexTemplateServiceTests.java | 2 +- .../cluster/metadata/MetadataTests.java | 12 ++++---- .../metadata/TemplateUpgradeServiceTests.java | 2 +- .../routing/BatchedRerouteServiceTests.java | 2 +- .../routing/WeightedRoutingServiceTests.java | 2 +- .../allocation/DiskThresholdMonitorTests.java | 2 +- .../blobstore/fs/FsBlobContainerTests.java | 2 +- .../compress/AbstractCompressorTests.java | 1 + .../common/compress/DeflateCompressTests.java | 2 ++ .../DeflateCompressedXContentTests.java | 1 + .../common/compress/ZstdCompressTests.java | 2 ++ .../concurrent/ListenableFutureTests.java | 2 +- .../common/xcontent/BaseXContentTestCase.java | 6 ++-- .../support/XContentMapValuesTests.java | 4 +-- ...shakingTransportAddressConnectorTests.java | 2 +- .../opensearch/discovery/PeerFinderTests.java | 2 +- .../http/DefaultRestChannelTests.java | 2 +- .../index/engine/InternalEngineTests.java | 2 +- .../opensearch/index/get/GetResultTests.java | 2 +- .../mapper/DataStreamFieldMapperTests.java | 2 +- .../FunctionScoreQueryBuilderTests.java | 13 +++++---- .../AbstractBulkByScrollRequestTestCase.java | 2 +- .../LeaderBulkByScrollTaskStateTests.java | 4 +-- .../WorkerBulkByScrollTaskStateTests.java | 2 +- .../IndexLevelReplicationTests.java | 2 +- .../RecoveryDuringReplicationTests.java | 2 +- .../RetentionLeasesReplicationTests.java | 2 +- ...PeerRecoveryRetentionLeaseExpiryTests.java | 2 +- ...ReplicationTrackerRetentionLeaseTests.java | 2 +- .../index/seqno/ReplicationTrackerTests.java | 2 +- .../seqno/RetentionLeaseActionsTests.java | 2 +- ...tentionLeaseBackgroundSyncActionTests.java | 2 +- .../index/seqno/RetentionLeaseStatsTests.java | 2 +- .../seqno/RetentionLeaseSyncActionTests.java | 2 +- .../IndexShardOperationPermitsTests.java | 2 +- .../shard/IndexShardRetentionLeaseTests.java | 2 +- .../index/shard/IndexShardTests.java | 3 +- .../RemoteStoreRefreshListenerTests.java | 2 +- .../SegmentReplicationIndexShardTests.java | 3 +- ...licationWithNodeToNodeIndexShardTests.java | 3 +- .../index/store/RemoteDirectoryTests.java | 2 +- ...moteSegmentStoreDirectoryFactoryTests.java | 2 +- .../RemoteSegmentStoreDirectoryTests.java | 2 +- ...oreTransferServiceMockRepositoryTests.java | 2 +- .../BlobStoreTransferServiceTests.java | 2 +- .../TranslogTransferManagerTests.java | 2 +- .../indices/IndicesServiceTests.java | 2 +- ...actIndicesClusterStateServiceTestCase.java | 2 +- .../indices/cluster/ClusterStateChanges.java | 2 +- ...alStorePeerRecoverySourceHandlerTests.java | 2 +- .../PeerRecoveryTargetServiceTests.java | 2 +- .../indices/recovery/RecoveryTests.java | 2 +- .../ReplicationRequestTrackerTests.java | 2 +- .../OngoingSegmentReplicationsTests.java | 2 +- .../PrimaryShardReplicationSourceTests.java | 2 +- .../SegmentFileTransferHandlerTests.java | 2 +- .../SegmentReplicationSourceHandlerTests.java | 2 +- .../SegmentReplicationSourceServiceTests.java | 2 +- .../SegmentReplicationTargetServiceTests.java | 2 +- .../SegmentReplicationTargetTests.java | 2 +- .../PublishCheckpointActionTests.java | 2 +- .../InternalOrPrivateSettingsPlugin.java | 4 +-- .../PersistentTasksClusterServiceTests.java | 2 +- .../PersistentTasksNodeServiceTests.java | 4 +-- .../persistent/TestPersistentTasksPlugin.java | 8 ++--- .../RepositoriesServiceTests.java | 2 +- .../RestCancellableNodeClientTests.java | 6 ++-- .../indices/RestValidateQueryActionTests.java | 2 +- .../rest/action/cat/RestTasksActionTests.java | 4 +-- .../action/document/RestBulkActionTests.java | 2 +- .../search/ClearScrollResponseTests.java | 15 +++++----- .../search/CreatePitSingleNodeTests.java | 2 +- .../search/DeletePitResponseTests.java | 6 ++-- .../search/SearchCancellationTests.java | 2 +- .../opensearch/search/SearchServiceTests.java | 2 +- .../aggregations/AggregationsTests.java | 19 ++++++------ .../AggregatorFactoriesTests.java | 2 +- .../internal/ShardSearchRequestTests.java | 6 ++-- .../search/pit/RestCreatePitActionTests.java | 2 +- .../search/pit/RestDeletePitActionTests.java | 2 +- .../search/query/QueryPhaseTests.java | 2 +- .../scroll/RestClearScrollActionTests.java | 2 +- .../scroll/RestSearchScrollActionTests.java | 2 +- .../snapshots/BlobStoreFormatTests.java | 2 +- .../snapshots/SnapshotResiliencyTests.java | 2 +- .../tasks/ListTasksResponseTests.java | 4 +++ ...askCancellationMonitoringServiceTests.java | 1 + .../org/opensearch/tasks/TaskIdTests.java | 1 + .../org/opensearch/tasks/TaskInfoTests.java | 4 +++ .../opensearch/tasks/TaskManagerTests.java | 3 +- .../TaskResourceTrackingServiceTests.java | 6 ++-- ...SearchShardTaskDetailsLogMessageTests.java | 6 ++-- .../consumer/TopNSearchTasksLoggerTests.java | 6 ++-- .../org/opensearch/test/NoopDiscovery.java | 2 +- .../ClusterConnectionManagerTests.java | 2 +- .../transport/InboundHandlerTests.java | 4 +-- .../transport/OutboundHandlerTests.java | 2 +- .../RemoteClusterAwareClientTests.java | 2 +- .../RemoteClusterConnectionTests.java | 2 +- .../transport/RemoteClusterServiceTests.java | 2 +- .../RemoteConnectionManagerTests.java | 2 +- .../RemoteConnectionStrategyTests.java | 2 +- .../transport/TransportHandshakerTests.java | 2 +- .../TransportRequestDeduplicatorTests.java | 4 +-- ...ortServiceDeserializationFailureTests.java | 2 +- .../TransportServiceHandshakeTests.java | 2 +- .../action/support/ActionTestUtils.java | 4 +-- .../FakeThreadPoolClusterManagerService.java | 2 +- .../store/OpenSearchIndexInputTestCase.java | 2 +- ...stractAsyncBulkByScrollActionTestCase.java | 2 +- ...enSearchIndexLevelReplicationTestCase.java | 2 +- .../replication/TestReplicationSource.java | 2 +- .../index/shard/IndexShardTestCase.java | 2 +- .../index/shard/RestoreOnlyRepository.java | 2 +- .../indices/recovery/AsyncRecoveryTarget.java | 2 +- .../SearchBackpressureTestHelpers.java | 2 +- .../AbstractSnapshotIntegTestCase.java | 10 +++---- .../test/AbstractBuilderTestCase.java | 2 +- .../test/AbstractQueryTestCase.java | 8 ++--- .../test/OpenSearchIntegTestCase.java | 2 +- .../opensearch/test/client/NoOpClient.java | 4 +-- .../test/client/NoOpNodeClient.java | 4 +-- .../disruption/DisruptableMockTransport.java | 2 +- .../test/hamcrest/OpenSearchAssertions.java | 2 +- .../opensearch/test/rest/FakeRestRequest.java | 2 +- .../test/rest/OpenSearchRestTestCase.java | 2 +- .../test/rest/RestActionTestCase.java | 4 +-- .../OpenSearchClientYamlSuiteTestCase.java | 4 +-- .../test/transport/FakeTransport.java | 2 +- .../test/transport/MockTransportService.java | 2 +- .../transport/StubbableConnectionManager.java | 2 +- .../test/transport/StubbableTransport.java | 2 +- .../AbstractSimpleTransportTestCase.java | 2 +- .../opensearch/transport/FakeTcpChannel.java | 2 +- .../transport/TestTransportChannel.java | 2 +- .../transport/nio/MockNioTransport.java | 2 +- ...eThreadPoolClusterManagerServiceTests.java | 2 +- .../nio/SimpleMockNioTransportTests.java | 2 +- 879 files changed, 1210 insertions(+), 1134 deletions(-) rename {server/src/main/java/org/opensearch => libs/common/src/main/java/org/opensearch/common}/action/ActionFuture.java (98%) create mode 100644 libs/common/src/main/java/org/opensearch/common/action/package-info.java rename {server/src/main/java/org/opensearch => libs/core/src/main/java/org/opensearch/core}/action/ActionListener.java (99%) rename {server/src/main/java/org/opensearch => libs/core/src/main/java/org/opensearch/core}/action/ActionResponse.java (97%) rename {server/src/main/java/org/opensearch => libs/core/src/main/java/org/opensearch/core}/action/NotifyOnceListener.java (98%) rename {server/src/main/java/org/opensearch => libs/core/src/main/java/org/opensearch/core}/common/compress/Compressor.java (98%) rename {server/src/main/java/org/opensearch/node => libs/core/src/main/java/org/opensearch/core/service}/ReportingService.java (97%) create mode 100644 libs/core/src/main/java/org/opensearch/core/service/package-info.java rename {server/src/main/java/org/opensearch => libs/core/src/main/java/org/opensearch/core}/tasks/TaskCancelledException.java (97%) rename {server/src/main/java/org/opensearch => libs/core/src/main/java/org/opensearch/core}/tasks/TaskId.java (99%) create mode 100644 libs/core/src/main/java/org/opensearch/core/tasks/package-info.java rename {server/src/main/java/org/opensearch/tasks => libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker}/ResourceStats.java (91%) rename {server/src/main/java/org/opensearch/tasks => libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker}/ResourceStatsType.java (94%) rename {server/src/main/java/org/opensearch/tasks => libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker}/ResourceUsageInfo.java (97%) rename {server/src/main/java/org/opensearch/tasks => libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker}/ResourceUsageMetric.java (92%) rename {server/src/main/java/org/opensearch/tasks => libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker}/TaskResourceStats.java (97%) rename {server/src/main/java/org/opensearch/tasks => libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker}/TaskResourceUsage.java (98%) rename {server/src/main/java/org/opensearch/tasks => libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker}/TaskThreadUsage.java (98%) rename {server/src/main/java/org/opensearch/tasks => libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker}/ThreadResourceInfo.java (97%) create mode 100644 libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/package-info.java rename {server/src/main/java/org/opensearch/common => libs/core/src/main/java/org/opensearch/core}/xcontent/ObjectParserHelper.java (84%) rename {server/src/test/java/org/opensearch => libs/core/src/test/java/org/opensearch/core}/action/ActionListenerTests.java (99%) rename {server/src/test/java/org/opensearch => libs/core/src/test/java/org/opensearch/core}/action/NotifyOnceListenerTests.java (98%) diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/NoopPlugin.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/NoopPlugin.java index e9d0fff2a9dc9..bd851d1831a03 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/NoopPlugin.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/NoopPlugin.java @@ -35,7 +35,7 @@ import org.opensearch.plugin.noop.action.bulk.RestNoopBulkAction; import org.opensearch.plugin.noop.action.bulk.TransportNoopBulkAction; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.common.settings.ClusterSettings; diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/bulk/TransportNoopBulkAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/bulk/TransportNoopBulkAction.java index 4df9a0465b1a6..5e6462307183a 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/bulk/TransportNoopBulkAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/bulk/TransportNoopBulkAction.java @@ -31,7 +31,7 @@ package org.opensearch.plugin.noop.action.bulk; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.bulk.BulkItemResponse; diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/search/TransportNoopSearchAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/search/TransportNoopSearchAction.java index 1b35787d226e7..3bf02383a7204 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/search/TransportNoopSearchAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/opensearch/plugin/noop/action/search/TransportNoopSearchAction.java @@ -32,7 +32,7 @@ package org.opensearch.plugin.noop.action.search; import org.apache.lucene.search.TotalHits; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; import org.opensearch.action.search.ShardSearchFailure; diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/ClusterClient.java b/client/rest-high-level/src/main/java/org/opensearch/client/ClusterClient.java index 45511f2bc2a47..e2156bf4efed7 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/ClusterClient.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/ClusterClient.java @@ -32,7 +32,7 @@ package org.opensearch.client; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest; diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/opensearch/client/IndicesClient.java index f20a6f627a680..fe563e8a55d22 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/IndicesClient.java @@ -32,7 +32,7 @@ package org.opensearch.client; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.get.GetAliasesRequest; import org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest; diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/IngestClient.java b/client/rest-high-level/src/main/java/org/opensearch/client/IngestClient.java index cd304019e771c..527f117289097 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/IngestClient.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/IngestClient.java @@ -32,7 +32,7 @@ package org.opensearch.client; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ingest.DeletePipelineRequest; import org.opensearch.action.ingest.GetPipelineRequest; import org.opensearch.action.ingest.GetPipelineResponse; diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java index 6bc691a74a2c4..702e407154611 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java @@ -1185,14 +1185,14 @@ Params withActions(List actions) { return this; } - Params withTaskId(org.opensearch.tasks.TaskId taskId) { + Params withTaskId(org.opensearch.core.tasks.TaskId taskId) { if (taskId != null && taskId.isSet()) { return putParam("task_id", taskId.toString()); } return this; } - Params withParentTaskId(org.opensearch.tasks.TaskId parentTaskId) { + Params withParentTaskId(org.opensearch.core.tasks.TaskId parentTaskId) { if (parentTaskId != null && parentTaskId.isSet()) { return putParam("parent_task_id", parentTaskId.toString()); } diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/RestHighLevelClient.java b/client/rest-high-level/src/main/java/org/opensearch/client/RestHighLevelClient.java index 1ff5c81c4a0e3..c8ee609ee0045 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/RestHighLevelClient.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/RestHighLevelClient.java @@ -35,7 +35,7 @@ import org.apache.hc.core5.http.HttpEntity; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchStatusException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/RethrottleRequest.java b/client/rest-high-level/src/main/java/org/opensearch/client/RethrottleRequest.java index 958e6ce4cda1c..6e453a5c7f343 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/RethrottleRequest.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/RethrottleRequest.java @@ -32,7 +32,7 @@ package org.opensearch.client; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.util.Objects; diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/SearchPipelineClient.java b/client/rest-high-level/src/main/java/org/opensearch/client/SearchPipelineClient.java index b6c28f57d6bd9..51d167ddcf5d8 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/SearchPipelineClient.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/SearchPipelineClient.java @@ -8,7 +8,7 @@ package org.opensearch.client; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.DeleteSearchPipelineRequest; import org.opensearch.action.search.GetSearchPipelineRequest; import org.opensearch.action.search.GetSearchPipelineResponse; diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/SnapshotClient.java b/client/rest-high-level/src/main/java/org/opensearch/client/SnapshotClient.java index 85a793dec24ce..67fac1d5a9dff 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/SnapshotClient.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/SnapshotClient.java @@ -32,7 +32,7 @@ package org.opensearch.client; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequest; import org.opensearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryResponse; import org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest; diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/TasksClient.java b/client/rest-high-level/src/main/java/org/opensearch/client/TasksClient.java index 51764e3339394..e5ce1e2d7b7e9 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/TasksClient.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/TasksClient.java @@ -32,7 +32,7 @@ package org.opensearch.client; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.client.tasks.CancelTasksRequest; diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/tasks/TaskId.java b/client/rest-high-level/src/main/java/org/opensearch/client/tasks/TaskId.java index cd036a732957b..c2cf2c826b8bd 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/tasks/TaskId.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/tasks/TaskId.java @@ -34,7 +34,7 @@ import java.util.Objects; /** - * client side version of a {@link org.opensearch.tasks.TaskId} + * client side version of a {@link org.opensearch.core.tasks.TaskId} */ public class TaskId { diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/CustomRestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/CustomRestHighLevelClientTests.java index 93eeee349db14..39d47d93d3cd5 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/CustomRestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/CustomRestHighLevelClientTests.java @@ -43,7 +43,7 @@ import org.apache.lucene.util.BytesRef; import org.opensearch.Build; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.main.MainRequest; import org.opensearch.action.main.MainResponse; import org.opensearch.action.support.PlainActionFuture; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/OpenSearchRestHighLevelClientTestCase.java b/client/rest-high-level/src/test/java/org/opensearch/client/OpenSearchRestHighLevelClientTestCase.java index 97eee0353dd63..d3c88651fe134 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/OpenSearchRestHighLevelClientTestCase.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/OpenSearchRestHighLevelClientTestCase.java @@ -33,7 +33,7 @@ package org.opensearch.client; import org.opensearch.OpenSearchParseException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.action.admin.cluster.node.tasks.list.TaskGroup; @@ -60,7 +60,7 @@ import org.opensearch.ingest.Pipeline; import org.opensearch.search.SearchHit; import org.opensearch.search.SearchModule; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.rest.OpenSearchRestTestCase; import org.apache.hc.core5.http.ParseException; import org.apache.hc.core5.http.io.entity.EntityUtils; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java index 1f10deb400ecc..053d632af9058 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java @@ -12,7 +12,7 @@ import org.apache.hc.client5.http.classic.methods.HttpPut; import org.junit.Before; import org.opensearch.OpenSearchStatusException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.CreatePitRequest; import org.opensearch.action.search.CreatePitResponse; import org.opensearch.action.search.DeletePitInfo; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/ReindexIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/ReindexIT.java index be4fd71c6f5e8..0b10446edfdbc 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/ReindexIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/ReindexIT.java @@ -33,7 +33,7 @@ package org.opensearch.client; import org.opensearch.OpenSearchStatusException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.action.bulk.BulkItemResponse; import org.opensearch.action.bulk.BulkRequest; @@ -50,7 +50,7 @@ import org.opensearch.index.reindex.ReindexRequest; import org.opensearch.core.rest.RestStatus; import org.opensearch.tasks.RawTaskStatus; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.Collections; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java index 239749e13b08b..3eec972119afc 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java @@ -110,7 +110,7 @@ import org.opensearch.search.rescore.QueryRescorerBuilder; import org.opensearch.search.suggest.SuggestBuilder; import org.opensearch.search.suggest.completion.CompletionSuggestionBuilder; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.RandomObjects; import org.apache.hc.client5.http.classic.methods.HttpDelete; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/RestHighLevelClientTests.java index 0b3d395fcd118..161dcc3c7fa22 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/RestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/RestHighLevelClientTests.java @@ -34,7 +34,7 @@ import com.fasterxml.jackson.core.JsonParseException; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.search.ClearScrollRequest; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java index 53a20aa58e5f8..22e7926adf3ac 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/SearchIT.java @@ -52,11 +52,11 @@ import org.opensearch.action.search.SearchScrollRequest; import org.opensearch.client.core.CountRequest; import org.opensearch.client.core.CountResponse; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.unit.TimeValue; +import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.index.query.MatchQueryBuilder; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/TasksRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/TasksRequestConvertersTests.java index a777bbc5d1868..e4c6feb1f6bb1 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/TasksRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/TasksRequestConvertersTests.java @@ -36,7 +36,7 @@ import org.apache.hc.client5.http.classic.methods.HttpPost; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.opensearch.client.tasks.CancelTasksRequest; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import java.util.HashMap; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/UpdateByQueryIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/UpdateByQueryIT.java index c0447b30b73d6..4878b130b795b 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/UpdateByQueryIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/UpdateByQueryIT.java @@ -32,7 +32,7 @@ package org.opensearch.client; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.action.bulk.BulkItemResponse; import org.opensearch.action.bulk.BulkRequest; @@ -49,7 +49,7 @@ import org.opensearch.core.rest.RestStatus; import org.opensearch.script.Script; import org.opensearch.tasks.RawTaskStatus; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.Collections; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/core/tasks/GetTaskResponseTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/core/tasks/GetTaskResponseTests.java index 63e016fea1da7..9c97f1f133284 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/core/tasks/GetTaskResponseTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/core/tasks/GetTaskResponseTests.java @@ -38,12 +38,12 @@ import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.tasks.RawTaskStatus; -import org.opensearch.tasks.TaskResourceStats; -import org.opensearch.tasks.TaskResourceUsage; +import org.opensearch.core.tasks.resourcetracker.TaskResourceStats; +import org.opensearch.core.tasks.resourcetracker.TaskResourceUsage; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; -import org.opensearch.tasks.TaskThreadUsage; +import org.opensearch.core.tasks.resourcetracker.TaskThreadUsage; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java index 58be005b94a8a..2ba7fa4b55f54 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java @@ -34,7 +34,6 @@ import org.apache.hc.core5.http.HttpHost; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.LatchedActionListener; @@ -74,16 +73,18 @@ import org.opensearch.client.core.TermVectorsResponse; import org.opensearch.client.indices.CreateIndexRequest; import org.opensearch.client.indices.CreateIndexResponse; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.unit.TimeValue; +import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.settings.Settings; import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.unit.ByteSizeValue; -import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.tasks.TaskId; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.VersionType; import org.opensearch.index.get.GetResult; import org.opensearch.index.query.MatchAllQueryBuilder; @@ -98,7 +99,6 @@ import org.opensearch.script.Script; import org.opensearch.script.ScriptType; import org.opensearch.search.fetch.subphase.FetchSourceContext; -import org.opensearch.tasks.TaskId; import java.util.Collections; import java.util.Date; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java index 07062c4796bcb..6f58646953771 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java @@ -32,7 +32,7 @@ package org.opensearch.client.documentation; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java index 5cad389d32c87..2b24009048863 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java @@ -33,7 +33,7 @@ package org.opensearch.client.documentation; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.admin.indices.alias.Alias; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IngestClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IngestClientDocumentationIT.java index 61b004b5ff733..72aa496237382 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IngestClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IngestClientDocumentationIT.java @@ -32,7 +32,7 @@ package org.opensearch.client.documentation; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.ingest.DeletePipelineRequest; import org.opensearch.action.ingest.GetPipelineRequest; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SearchDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SearchDocumentationIT.java index 24aae6d66d8bf..e244591a8ad27 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SearchDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SearchDocumentationIT.java @@ -34,7 +34,7 @@ import org.apache.lucene.search.Explanation; import org.apache.lucene.search.TotalHits; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.bulk.BulkRequest; import org.opensearch.action.bulk.BulkResponse; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SnapshotClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SnapshotClientDocumentationIT.java index dcd1335e242b0..ce184395aef55 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SnapshotClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/SnapshotClientDocumentationIT.java @@ -32,7 +32,7 @@ package org.opensearch.client.documentation; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest; import org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/StoredScriptsDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/StoredScriptsDocumentationIT.java index 551973a3912ce..3b48d9b8b280e 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/StoredScriptsDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/StoredScriptsDocumentationIT.java @@ -32,7 +32,7 @@ package org.opensearch.client.documentation; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest; import org.opensearch.action.admin.cluster.storedscripts.GetStoredScriptRequest; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/TasksClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/TasksClientDocumentationIT.java index 05479e2e3e81c..b39004eaf6594 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/TasksClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/TasksClientDocumentationIT.java @@ -33,7 +33,7 @@ package org.opensearch.client.documentation; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.TaskOperationFailure; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksRequest; @@ -45,7 +45,7 @@ import org.opensearch.client.tasks.CancelTasksRequest; import org.opensearch.client.tasks.CancelTasksResponse; import org.opensearch.common.unit.TimeValue; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import java.io.IOException; diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/tasks/CancelTasksResponseTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/tasks/CancelTasksResponseTests.java index 0e9bce7ce0b58..d88cd9a2a3531 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/tasks/CancelTasksResponseTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/tasks/CancelTasksResponseTests.java @@ -45,7 +45,7 @@ import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import java.io.IOException; diff --git a/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/NodeRestUsageIT.java b/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/NodeRestUsageIT.java index c95cad310f126..59df4122713d5 100644 --- a/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/NodeRestUsageIT.java +++ b/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/NodeRestUsageIT.java @@ -35,7 +35,6 @@ import org.opensearch.client.Request; import org.opensearch.client.Response; import org.opensearch.client.ResponseException; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.search.aggregations.AggregationBuilders; diff --git a/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/WaitForRefreshAndCloseIT.java b/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/WaitForRefreshAndCloseIT.java index 07576dacffb03..b98941874ec6c 100644 --- a/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/WaitForRefreshAndCloseIT.java +++ b/distribution/archives/integ-test-zip/src/test/java/org/opensearch/test/rest/WaitForRefreshAndCloseIT.java @@ -32,7 +32,7 @@ package org.opensearch.test.rest; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.client.Request; import org.opensearch.client.Response; diff --git a/server/src/main/java/org/opensearch/action/ActionFuture.java b/libs/common/src/main/java/org/opensearch/common/action/ActionFuture.java similarity index 98% rename from server/src/main/java/org/opensearch/action/ActionFuture.java rename to libs/common/src/main/java/org/opensearch/common/action/ActionFuture.java index d796180eda021..5bb8111ef089f 100644 --- a/server/src/main/java/org/opensearch/action/ActionFuture.java +++ b/libs/common/src/main/java/org/opensearch/common/action/ActionFuture.java @@ -30,7 +30,7 @@ * GitHub history for details. */ -package org.opensearch.action; +package org.opensearch.common.action; import org.opensearch.common.unit.TimeValue; diff --git a/libs/common/src/main/java/org/opensearch/common/action/package-info.java b/libs/common/src/main/java/org/opensearch/common/action/package-info.java new file mode 100644 index 0000000000000..4ed2687c80cc9 --- /dev/null +++ b/libs/common/src/main/java/org/opensearch/common/action/package-info.java @@ -0,0 +1,10 @@ +/* + * 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. + */ + +/** foundation action classes used across the code base */ +package org.opensearch.common.action; diff --git a/libs/core/src/main/java/org/opensearch/OpenSearchException.java b/libs/core/src/main/java/org/opensearch/OpenSearchException.java index 1a1273ad8963c..b5a71738f7d7e 100644 --- a/libs/core/src/main/java/org/opensearch/OpenSearchException.java +++ b/libs/core/src/main/java/org/opensearch/OpenSearchException.java @@ -150,6 +150,14 @@ public class OpenSearchException extends RuntimeException implements Writeable, UNKNOWN_VERSION_ADDED ) ); + registerExceptionHandle( + new OpenSearchExceptionHandle( + org.opensearch.core.tasks.TaskCancelledException.class, + org.opensearch.core.tasks.TaskCancelledException::new, + 146, + UNKNOWN_VERSION_ADDED + ) + ); } /** diff --git a/server/src/main/java/org/opensearch/action/ActionListener.java b/libs/core/src/main/java/org/opensearch/core/action/ActionListener.java similarity index 99% rename from server/src/main/java/org/opensearch/action/ActionListener.java rename to libs/core/src/main/java/org/opensearch/core/action/ActionListener.java index 645ed4deec006..1127e0151145a 100644 --- a/server/src/main/java/org/opensearch/action/ActionListener.java +++ b/libs/core/src/main/java/org/opensearch/core/action/ActionListener.java @@ -30,7 +30,7 @@ * GitHub history for details. */ -package org.opensearch.action; +package org.opensearch.core.action; import org.opensearch.ExceptionsHelper; import org.opensearch.common.CheckedConsumer; diff --git a/server/src/main/java/org/opensearch/action/ActionResponse.java b/libs/core/src/main/java/org/opensearch/core/action/ActionResponse.java similarity index 97% rename from server/src/main/java/org/opensearch/action/ActionResponse.java rename to libs/core/src/main/java/org/opensearch/core/action/ActionResponse.java index e1d4da760b35b..041d8b1bffb4a 100644 --- a/server/src/main/java/org/opensearch/action/ActionResponse.java +++ b/libs/core/src/main/java/org/opensearch/core/action/ActionResponse.java @@ -30,7 +30,7 @@ * GitHub history for details. */ -package org.opensearch.action; +package org.opensearch.core.action; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.transport.TransportResponse; diff --git a/server/src/main/java/org/opensearch/action/NotifyOnceListener.java b/libs/core/src/main/java/org/opensearch/core/action/NotifyOnceListener.java similarity index 98% rename from server/src/main/java/org/opensearch/action/NotifyOnceListener.java rename to libs/core/src/main/java/org/opensearch/core/action/NotifyOnceListener.java index cc625962e54f6..6af9ca005d171 100644 --- a/server/src/main/java/org/opensearch/action/NotifyOnceListener.java +++ b/libs/core/src/main/java/org/opensearch/core/action/NotifyOnceListener.java @@ -30,7 +30,7 @@ * GitHub history for details. */ -package org.opensearch.action; +package org.opensearch.core.action; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/server/src/main/java/org/opensearch/common/compress/Compressor.java b/libs/core/src/main/java/org/opensearch/core/common/compress/Compressor.java similarity index 98% rename from server/src/main/java/org/opensearch/common/compress/Compressor.java rename to libs/core/src/main/java/org/opensearch/core/common/compress/Compressor.java index 1034e3a1da5da..88b6c9f85f225 100644 --- a/server/src/main/java/org/opensearch/common/compress/Compressor.java +++ b/libs/core/src/main/java/org/opensearch/core/common/compress/Compressor.java @@ -30,7 +30,7 @@ * GitHub history for details. */ -package org.opensearch.common.compress; +package org.opensearch.core.common.compress; import org.opensearch.core.common.bytes.BytesReference; diff --git a/server/src/main/java/org/opensearch/node/ReportingService.java b/libs/core/src/main/java/org/opensearch/core/service/ReportingService.java similarity index 97% rename from server/src/main/java/org/opensearch/node/ReportingService.java rename to libs/core/src/main/java/org/opensearch/core/service/ReportingService.java index 969652e215e5e..3c88169f1e3b0 100644 --- a/server/src/main/java/org/opensearch/node/ReportingService.java +++ b/libs/core/src/main/java/org/opensearch/core/service/ReportingService.java @@ -30,7 +30,7 @@ * GitHub history for details. */ -package org.opensearch.node; +package org.opensearch.core.service; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.xcontent.ToXContent; diff --git a/libs/core/src/main/java/org/opensearch/core/service/package-info.java b/libs/core/src/main/java/org/opensearch/core/service/package-info.java new file mode 100644 index 0000000000000..d427c6e5934c9 --- /dev/null +++ b/libs/core/src/main/java/org/opensearch/core/service/package-info.java @@ -0,0 +1,10 @@ +/* + * 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. + */ + +/** OpenSearch Core Service Interfaces */ +package org.opensearch.core.service; diff --git a/server/src/main/java/org/opensearch/tasks/TaskCancelledException.java b/libs/core/src/main/java/org/opensearch/core/tasks/TaskCancelledException.java similarity index 97% rename from server/src/main/java/org/opensearch/tasks/TaskCancelledException.java rename to libs/core/src/main/java/org/opensearch/core/tasks/TaskCancelledException.java index 38e50f56b24b2..6bdc1e42f351a 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskCancelledException.java +++ b/libs/core/src/main/java/org/opensearch/core/tasks/TaskCancelledException.java @@ -29,7 +29,7 @@ * GitHub history for details. */ -package org.opensearch.tasks; +package org.opensearch.core.tasks; import org.opensearch.OpenSearchException; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/tasks/TaskId.java b/libs/core/src/main/java/org/opensearch/core/tasks/TaskId.java similarity index 99% rename from server/src/main/java/org/opensearch/tasks/TaskId.java rename to libs/core/src/main/java/org/opensearch/core/tasks/TaskId.java index 0328b8626e60e..97b0231613c73 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskId.java +++ b/libs/core/src/main/java/org/opensearch/core/tasks/TaskId.java @@ -30,7 +30,7 @@ * GitHub history for details. */ -package org.opensearch.tasks; +package org.opensearch.core.tasks; import org.opensearch.OpenSearchParseException; import org.opensearch.core.common.Strings; diff --git a/libs/core/src/main/java/org/opensearch/core/tasks/package-info.java b/libs/core/src/main/java/org/opensearch/core/tasks/package-info.java new file mode 100644 index 0000000000000..e421816c6b541 --- /dev/null +++ b/libs/core/src/main/java/org/opensearch/core/tasks/package-info.java @@ -0,0 +1,10 @@ +/* + * 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. + */ + +/** Core Tasks Foundation classes used across the opensearch code base */ +package org.opensearch.core.tasks; diff --git a/server/src/main/java/org/opensearch/tasks/ResourceStats.java b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceStats.java similarity index 91% rename from server/src/main/java/org/opensearch/tasks/ResourceStats.java rename to libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceStats.java index 31c129b7b2ff9..d65f75581dd1b 100644 --- a/server/src/main/java/org/opensearch/tasks/ResourceStats.java +++ b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceStats.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.tasks; +package org.opensearch.core.tasks.resourcetracker; /** * Different resource stats are defined. diff --git a/server/src/main/java/org/opensearch/tasks/ResourceStatsType.java b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceStatsType.java similarity index 94% rename from server/src/main/java/org/opensearch/tasks/ResourceStatsType.java rename to libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceStatsType.java index 138c74e128d70..fce8cc65e9bc5 100644 --- a/server/src/main/java/org/opensearch/tasks/ResourceStatsType.java +++ b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceStatsType.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.tasks; +package org.opensearch.core.tasks.resourcetracker; /** * Defines the different types of resource stats. diff --git a/server/src/main/java/org/opensearch/tasks/ResourceUsageInfo.java b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceUsageInfo.java similarity index 97% rename from server/src/main/java/org/opensearch/tasks/ResourceUsageInfo.java rename to libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceUsageInfo.java index 652562e3f9e7a..2cbc3d4b2f5c3 100644 --- a/server/src/main/java/org/opensearch/tasks/ResourceUsageInfo.java +++ b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceUsageInfo.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.tasks; +package org.opensearch.core.tasks.resourcetracker; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -89,7 +89,7 @@ public String toString() { /** * Defines resource stats information. */ - static class ResourceStatsInfo { + public static class ResourceStatsInfo { private final long startValue; private final AtomicLong endValue; diff --git a/server/src/main/java/org/opensearch/tasks/ResourceUsageMetric.java b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceUsageMetric.java similarity index 92% rename from server/src/main/java/org/opensearch/tasks/ResourceUsageMetric.java rename to libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceUsageMetric.java index 931e3aa00d736..262dbe20dabda 100644 --- a/server/src/main/java/org/opensearch/tasks/ResourceUsageMetric.java +++ b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ResourceUsageMetric.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.tasks; +package org.opensearch.core.tasks.resourcetracker; /** * Information about resource usage diff --git a/server/src/main/java/org/opensearch/tasks/TaskResourceStats.java b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/TaskResourceStats.java similarity index 97% rename from server/src/main/java/org/opensearch/tasks/TaskResourceStats.java rename to libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/TaskResourceStats.java index 7451c5b3bc148..d0d26550a4742 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskResourceStats.java +++ b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/TaskResourceStats.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.tasks; +package org.opensearch.core.tasks.resourcetracker; import org.opensearch.Version; import org.opensearch.core.common.Strings; @@ -23,8 +23,6 @@ import java.util.Map; import java.util.Objects; -import static org.opensearch.tasks.Task.THREAD_INFO; - /** * Resource information about a currently running task. *

@@ -37,6 +35,8 @@ public class TaskResourceStats implements Writeable, ToXContentFragment { private final Map resourceUsage; private final TaskThreadUsage threadUsage; + public static final String THREAD_INFO = "thread_info"; + public TaskResourceStats(Map resourceUsage, TaskThreadUsage threadUsage) { this.resourceUsage = Objects.requireNonNull(resourceUsage, "resource usage is required"); this.threadUsage = Objects.requireNonNull(threadUsage, "thread usage is required"); diff --git a/server/src/main/java/org/opensearch/tasks/TaskResourceUsage.java b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/TaskResourceUsage.java similarity index 98% rename from server/src/main/java/org/opensearch/tasks/TaskResourceUsage.java rename to libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/TaskResourceUsage.java index 31a7cd3ac372b..7ab6b347f54f5 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskResourceUsage.java +++ b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/TaskResourceUsage.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.tasks; +package org.opensearch.core.tasks.resourcetracker; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/tasks/TaskThreadUsage.java b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/TaskThreadUsage.java similarity index 98% rename from server/src/main/java/org/opensearch/tasks/TaskThreadUsage.java rename to libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/TaskThreadUsage.java index 85f01bd7f4676..c599f57cd57b8 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskThreadUsage.java +++ b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/TaskThreadUsage.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.tasks; +package org.opensearch.core.tasks.resourcetracker; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/tasks/ThreadResourceInfo.java b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ThreadResourceInfo.java similarity index 97% rename from server/src/main/java/org/opensearch/tasks/ThreadResourceInfo.java rename to libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ThreadResourceInfo.java index de49d86d1d5c4..4b341a94256c4 100644 --- a/server/src/main/java/org/opensearch/tasks/ThreadResourceInfo.java +++ b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/ThreadResourceInfo.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.tasks; +package org.opensearch.core.tasks.resourcetracker; /** * Resource consumption information about a particular execution of thread. diff --git a/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/package-info.java b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/package-info.java new file mode 100644 index 0000000000000..b46b685ffaaf0 --- /dev/null +++ b/libs/core/src/main/java/org/opensearch/core/tasks/resourcetracker/package-info.java @@ -0,0 +1,9 @@ +/* + * 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. + */ +/** Resource tracking classes for tracking task resource consumption (e.g., memory, cpu) */ +package org.opensearch.core.tasks.resourcetracker; diff --git a/server/src/main/java/org/opensearch/common/xcontent/ObjectParserHelper.java b/libs/core/src/main/java/org/opensearch/core/xcontent/ObjectParserHelper.java similarity index 84% rename from server/src/main/java/org/opensearch/common/xcontent/ObjectParserHelper.java rename to libs/core/src/main/java/org/opensearch/core/xcontent/ObjectParserHelper.java index 77c13dc5de60e..b29ca9dea56c0 100644 --- a/server/src/main/java/org/opensearch/common/xcontent/ObjectParserHelper.java +++ b/libs/core/src/main/java/org/opensearch/core/xcontent/ObjectParserHelper.java @@ -30,17 +30,12 @@ * GitHub history for details. */ -package org.opensearch.common.xcontent; +package org.opensearch.core.xcontent; import org.opensearch.common.CheckedFunction; import org.opensearch.core.ParseField; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.core.xcontent.AbstractObjectParser; -import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.core.xcontent.ObjectParser.ValueType; -import org.opensearch.common.xcontent.json.JsonXContent; -import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.core.xcontent.XContentParser; import java.io.IOException; import java.util.function.BiConsumer; @@ -62,7 +57,7 @@ public void declareRawObject( final ParseField field ) { final CheckedFunction bytesParser = p -> { - try (XContentBuilder builder = JsonXContent.contentBuilder()) { + try (XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder()) { builder.copyCurrentStructure(p); return BytesReference.bytes(builder); } diff --git a/server/src/test/java/org/opensearch/action/ActionListenerTests.java b/libs/core/src/test/java/org/opensearch/core/action/ActionListenerTests.java similarity index 99% rename from server/src/test/java/org/opensearch/action/ActionListenerTests.java rename to libs/core/src/test/java/org/opensearch/core/action/ActionListenerTests.java index e56deb6088722..8d2bef3db68ea 100644 --- a/server/src/test/java/org/opensearch/action/ActionListenerTests.java +++ b/libs/core/src/test/java/org/opensearch/core/action/ActionListenerTests.java @@ -29,7 +29,7 @@ * GitHub history for details. */ -package org.opensearch.action; +package org.opensearch.core.action; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.common.CheckedConsumer; diff --git a/server/src/test/java/org/opensearch/action/NotifyOnceListenerTests.java b/libs/core/src/test/java/org/opensearch/core/action/NotifyOnceListenerTests.java similarity index 98% rename from server/src/test/java/org/opensearch/action/NotifyOnceListenerTests.java rename to libs/core/src/test/java/org/opensearch/core/action/NotifyOnceListenerTests.java index 79593f85c2890..948cd752a27c3 100644 --- a/server/src/test/java/org/opensearch/action/NotifyOnceListenerTests.java +++ b/libs/core/src/test/java/org/opensearch/core/action/NotifyOnceListenerTests.java @@ -30,7 +30,7 @@ * GitHub history for details. */ -package org.opensearch.action; +package org.opensearch.core.action; import org.opensearch.test.OpenSearchTestCase; diff --git a/libs/core/src/test/java/org/opensearch/core/action/support/DefaultShardOperationFailedExceptionTests.java b/libs/core/src/test/java/org/opensearch/core/action/support/DefaultShardOperationFailedExceptionTests.java index 985a7fdf3614b..6ac47bb12bbba 100644 --- a/libs/core/src/test/java/org/opensearch/core/action/support/DefaultShardOperationFailedExceptionTests.java +++ b/libs/core/src/test/java/org/opensearch/core/action/support/DefaultShardOperationFailedExceptionTests.java @@ -39,16 +39,16 @@ import org.apache.lucene.store.LockObtainFailedException; import org.opensearch.OpenSearchException; import org.opensearch.action.support.broadcast.BroadcastShardOperationFailedException; +import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.index.Index; import org.opensearch.core.index.shard.ShardId; import org.opensearch.core.rest.RestStatus; diff --git a/libs/x-content/src/test/java/org/opensearch/common/xcontent/XContentParserTests.java b/libs/x-content/src/test/java/org/opensearch/common/xcontent/XContentParserTests.java index fab61753eb739..3b857a2c690b9 100644 --- a/libs/x-content/src/test/java/org/opensearch/common/xcontent/XContentParserTests.java +++ b/libs/x-content/src/test/java/org/opensearch/common/xcontent/XContentParserTests.java @@ -37,10 +37,10 @@ import com.fasterxml.jackson.dataformat.yaml.JacksonYAMLParseException; import org.opensearch.common.CheckedSupplier; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.xcontent.cbor.CborXContent; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.common.xcontent.smile.SmileXContent; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParseException; import org.opensearch.core.xcontent.XContentParser; diff --git a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java index 300106e435114..1f05c2d7b0724 100644 --- a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java +++ b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java @@ -31,10 +31,10 @@ package org.opensearch.ingest.common; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; diff --git a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/IngestCommonModulePlugin.java b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/IngestCommonModulePlugin.java index c786785a008d7..3618b41a55581 100644 --- a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/IngestCommonModulePlugin.java +++ b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/IngestCommonModulePlugin.java @@ -33,7 +33,7 @@ package org.opensearch.ingest.common; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.common.settings.ClusterSettings; diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java index a76c194037224..45ff528b83697 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.ingest.common; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java index 9587b9583aeb2..6e754e00a4e0c 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java @@ -33,7 +33,7 @@ package org.opensearch.script.mustache; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.search.MultiSearchResponse; import org.opensearch.common.Nullable; import org.opensearch.core.common.Strings; diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MustacheModulePlugin.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MustacheModulePlugin.java index 03be9d7efb2db..cb09eb746d59b 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MustacheModulePlugin.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MustacheModulePlugin.java @@ -33,7 +33,7 @@ package org.opensearch.script.mustache; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.common.settings.ClusterSettings; diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/SearchTemplateResponse.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/SearchTemplateResponse.java index 66dcc89261229..35edb77f773f9 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/SearchTemplateResponse.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/SearchTemplateResponse.java @@ -32,7 +32,7 @@ package org.opensearch.script.mustache; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.search.SearchResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.bytes.BytesReference; diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportMultiSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportMultiSearchTemplateAction.java index 529af483497e1..fbafd95ac36bf 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportMultiSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportMultiSearchTemplateAction.java @@ -32,7 +32,7 @@ package org.opensearch.script.mustache; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.MultiSearchRequest; import org.opensearch.action.search.MultiSearchResponse; import org.opensearch.action.search.SearchRequest; diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java index 6ec5dc8f7f9ca..553dc9325725e 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/TransportSearchTemplateAction.java @@ -32,7 +32,7 @@ package org.opensearch.script.mustache; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; import org.opensearch.action.support.ActionFilters; diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessModulePlugin.java b/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessModulePlugin.java index c7b9c75570899..f8591bcbd8eed 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessModulePlugin.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessModulePlugin.java @@ -33,7 +33,7 @@ package org.opensearch.painless; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.node.DiscoveryNodes; diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessContextAction.java b/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessContextAction.java index db1ef8f7a30fb..93558a9a1eb0a 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessContextAction.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessContextAction.java @@ -32,10 +32,10 @@ package org.opensearch.painless.action; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java b/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java index 9a2c8c1f0aa55..acf1fed1ef092 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java @@ -45,7 +45,7 @@ import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.Directory; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.IndicesOptions; diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureMetaFieldMapperTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureMetaFieldMapperTests.java index c0b4b44b7935f..6cfdbcc581aad 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureMetaFieldMapperTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureMetaFieldMapperTests.java @@ -32,8 +32,8 @@ package org.opensearch.index.mapper; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.IndexService; import org.opensearch.plugins.Plugin; diff --git a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java index 8c091bd8de439..4afe757917a89 100644 --- a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java @@ -36,15 +36,15 @@ import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.opensearch.action.search.MultiSearchResponse; import org.opensearch.action.search.SearchResponse; -import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.geo.GeoPoint; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.DistanceUnit; -import org.opensearch.core.xcontent.MediaTypeRegistry; -import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.bytes.BytesArray; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaTypeRegistry; +import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.geo.GeoModulePlugin; import org.opensearch.index.mapper.MapperParsingException; import org.opensearch.index.query.MatchPhraseQueryBuilder; diff --git a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java index 3882cbbfd4b35..79fdb40331b7f 100644 --- a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java +++ b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java @@ -57,7 +57,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.ResourceNotFoundException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.get.GetRequest; import org.opensearch.common.SetOnce; import org.opensearch.core.common.bytes.BytesReference; diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalModulePlugin.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalModulePlugin.java index 3dbc07e5cf342..1cfc04248d524 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalModulePlugin.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalModulePlugin.java @@ -33,7 +33,7 @@ package org.opensearch.index.rankeval; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalResponse.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalResponse.java index 496320dabe650..a6e491c4fb68a 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalResponse.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalResponse.java @@ -33,7 +33,7 @@ package org.opensearch.index.rankeval; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.common.collect.Tuple; import org.opensearch.core.common.Strings; diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java index cc34be0485150..34614c21206f4 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/TransportRankEvalAction.java @@ -32,7 +32,7 @@ package org.opensearch.index.rankeval; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.MultiSearchRequest; import org.opensearch.action.search.MultiSearchResponse; import org.opensearch.action.search.MultiSearchResponse.Item; diff --git a/modules/rank-eval/src/test/java/org/opensearch/index/rankeval/TransportRankEvalActionTests.java b/modules/rank-eval/src/test/java/org/opensearch/index/rankeval/TransportRankEvalActionTests.java index 6fc491058af86..069e18ca364d0 100644 --- a/modules/rank-eval/src/test/java/org/opensearch/index/rankeval/TransportRankEvalActionTests.java +++ b/modules/rank-eval/src/test/java/org/opensearch/index/rankeval/TransportRankEvalActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.rankeval; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.MultiSearchRequest; import org.opensearch.action.search.MultiSearchResponse; import org.opensearch.action.search.SearchType; diff --git a/modules/reindex/src/internalClusterTest/java/org/opensearch/client/documentation/ReindexDocumentationIT.java b/modules/reindex/src/internalClusterTest/java/org/opensearch/client/documentation/ReindexDocumentationIT.java index 3a19be57cf731..4e3274f05f87a 100644 --- a/modules/reindex/src/internalClusterTest/java/org/opensearch/client/documentation/ReindexDocumentationIT.java +++ b/modules/reindex/src/internalClusterTest/java/org/opensearch/client/documentation/ReindexDocumentationIT.java @@ -32,7 +32,7 @@ package org.opensearch.client.documentation; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.get.GetTaskResponse; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.client.Client; @@ -58,7 +58,7 @@ import org.opensearch.script.Script; import org.opensearch.script.ScriptType; import org.opensearch.search.sort.SortOrder; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import org.opensearch.test.OpenSearchIntegTestCase; import org.hamcrest.Matcher; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/AbstractAsyncBulkByScrollAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/AbstractAsyncBulkByScrollAction.java index a0ad02899ea27..9cae97236d5a3 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/AbstractAsyncBulkByScrollAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/AbstractAsyncBulkByScrollAction.java @@ -37,7 +37,7 @@ import org.apache.hc.core5.http.HttpRequestInterceptor; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.admin.indices.refresh.RefreshRequest; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/AsyncDeleteByQueryAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/AsyncDeleteByQueryAction.java index 1a9ce16acc255..1edbce78c95c9 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/AsyncDeleteByQueryAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/AsyncDeleteByQueryAction.java @@ -33,7 +33,7 @@ package org.opensearch.index.reindex; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.delete.DeleteRequest; import org.opensearch.client.ParentTaskAssigningClient; import org.opensearch.script.ScriptService; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/BulkByScrollParallelizationHelper.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/BulkByScrollParallelizationHelper.java index fcdee900b4ca7..903bbd68599d7 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/BulkByScrollParallelizationHelper.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/BulkByScrollParallelizationHelper.java @@ -32,7 +32,7 @@ package org.opensearch.index.reindex; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionType; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsRequest; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsResponse; @@ -43,7 +43,7 @@ import org.opensearch.index.mapper.IdFieldMapper; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.search.slice.SliceBuilder; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.util.Arrays; import java.util.Collections; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/ReindexModulePlugin.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/ReindexModulePlugin.java index d89e3d677a2a5..40d2eae5a5dc7 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/ReindexModulePlugin.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/ReindexModulePlugin.java @@ -39,7 +39,7 @@ import org.opensearch.plugins.ExtensiblePlugin; import org.opensearch.watcher.ResourceWatcherService; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.node.DiscoveryNodes; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/Reindexer.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/Reindexer.java index cb07e593f8155..8e0b33c4476d5 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/Reindexer.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/Reindexer.java @@ -47,7 +47,7 @@ import org.apache.hc.core5.util.Timeout; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.bulk.BackoffPolicy; import org.opensearch.action.bulk.BulkItemResponse; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/RestRethrottleAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/RestRethrottleAction.java index 89864cf56c71d..2e4fc5bfc4f82 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/RestRethrottleAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/RestRethrottleAction.java @@ -36,7 +36,7 @@ import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestRequest; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.util.List; import java.util.function.Supplier; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportDeleteByQueryAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportDeleteByQueryAction.java index 50dbc972061a5..8c351062221e5 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportDeleteByQueryAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportDeleteByQueryAction.java @@ -32,7 +32,7 @@ package org.opensearch.index.reindex; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.client.Client; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java index c84d103a2ef6f..12ad1db299566 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java @@ -33,7 +33,7 @@ package org.opensearch.index.reindex; import java.util.Optional; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.AutoCreateIndex; import org.opensearch.action.support.HandledTransportAction; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportRethrottleAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportRethrottleAction.java index 2ee869ce2b465..43ad59f15629a 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportRethrottleAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportRethrottleAction.java @@ -33,7 +33,7 @@ package org.opensearch.index.reindex; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.TaskOperationFailure; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; @@ -42,7 +42,7 @@ import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java index 1ea9ec5fb7beb..8c7a4817df5c5 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java @@ -33,7 +33,7 @@ package org.opensearch.index.reindex; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/spi/RemoteReindexExtension.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/spi/RemoteReindexExtension.java index 22d560b19c699..f98fd00eeb85a 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/spi/RemoteReindexExtension.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/spi/RemoteReindexExtension.java @@ -5,7 +5,7 @@ package org.opensearch.index.reindex.spi; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.index.reindex.BulkByScrollResponse; import org.opensearch.index.reindex.ReindexModulePlugin; import org.opensearch.index.reindex.ReindexRequest; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java index b6e1260788578..d37a3972b35d7 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java @@ -37,9 +37,9 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.Version; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.DocWriteResponse.Result; @@ -87,7 +87,7 @@ import org.opensearch.search.SearchHits; import org.opensearch.search.internal.InternalSearchResponse; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskManager; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.client.NoOpClient; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/CancelTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/CancelTests.java index 6dd168c07a8ea..4999e1a91499c 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/CancelTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/CancelTests.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.action.ingest.DeletePipelineRequest; @@ -50,7 +50,7 @@ import org.opensearch.core.index.shard.ShardId; import org.opensearch.ingest.IngestTestPlugin; import org.opensearch.plugins.Plugin; -import org.opensearch.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskCancelledException; import org.opensearch.tasks.TaskInfo; import org.hamcrest.Matcher; import org.junit.Before; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/ClientScrollableHitSourceTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/ClientScrollableHitSourceTests.java index 46113971d537a..c8122bcb1a86d 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/ClientScrollableHitSourceTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/ClientScrollableHitSourceTests.java @@ -33,9 +33,9 @@ package org.opensearch.index.reindex; import org.apache.lucene.search.TotalHits; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.bulk.BackoffPolicy; import org.opensearch.action.search.SearchAction; @@ -52,7 +52,7 @@ import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; import org.opensearch.search.internal.InternalSearchResponse; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexFromRemoteWithAuthTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexFromRemoteWithAuthTests.java index 03d6fafccfea3..37bde69dcc081 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexFromRemoteWithAuthTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexFromRemoteWithAuthTests.java @@ -34,9 +34,9 @@ import org.opensearch.OpenSearchSecurityException; import org.opensearch.OpenSearchStatusException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.admin.cluster.node.info.NodeInfo; import org.opensearch.action.search.SearchAction; import org.opensearch.action.support.ActionFilter; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/RethrottleTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/RethrottleTests.java index 6bedd59515e45..47395c52b3c09 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/RethrottleTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/RethrottleTests.java @@ -34,12 +34,12 @@ import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.action.admin.cluster.node.tasks.list.TaskGroup; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.index.query.QueryBuilders; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.util.ArrayList; import java.util.List; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/RetryTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/RetryTests.java index 89eb8fc7e15a3..6ee6f302af48b 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/RetryTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/RetryTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.reindex; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.node.info.NodeInfo; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.action.bulk.BackoffPolicy; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java index 4508bf59d6879..3d0eb7704f343 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java @@ -42,7 +42,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.script.Script; import org.opensearch.script.ScriptType; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/TransportRethrottleActionTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/TransportRethrottleActionTests.java index 6456aa0af9aac..83286b774f09e 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/TransportRethrottleActionTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/TransportRethrottleActionTests.java @@ -32,12 +32,12 @@ package org.opensearch.index.reindex; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.TaskOperationFailure; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.client.Client; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import org.opensearch.test.OpenSearchTestCase; import org.hamcrest.Matcher; diff --git a/modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpChannel.java b/modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpChannel.java index 2dd7aaf41986f..251bcb25e8c32 100644 --- a/modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpChannel.java +++ b/modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpChannel.java @@ -35,7 +35,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelPipeline; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.Nullable; import org.opensearch.common.concurrent.CompletableContext; import org.opensearch.http.HttpChannel; diff --git a/modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerChannel.java b/modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerChannel.java index 560b7b565fa40..1fe26e58a8e8c 100644 --- a/modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerChannel.java +++ b/modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerChannel.java @@ -33,7 +33,7 @@ package org.opensearch.http.netty4; import io.netty.channel.Channel; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.concurrent.CompletableContext; import org.opensearch.http.HttpServerChannel; import org.opensearch.transport.netty4.Netty4TcpChannel; diff --git a/modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4TcpChannel.java b/modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4TcpChannel.java index 46cbf60d45116..ae9fa7daf5661 100644 --- a/modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4TcpChannel.java +++ b/modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4TcpChannel.java @@ -36,7 +36,7 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelPromise; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.Nullable; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.concurrent.CompletableContext; diff --git a/modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4TcpServerChannel.java b/modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4TcpServerChannel.java index 6131d7fe2acb9..149f8086e1e2c 100644 --- a/modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4TcpServerChannel.java +++ b/modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4TcpServerChannel.java @@ -33,7 +33,7 @@ package org.opensearch.transport.netty4; import io.netty.channel.Channel; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.concurrent.CompletableContext; import org.opensearch.transport.TcpServerChannel; diff --git a/modules/transport-netty4/src/test/java/org/opensearch/transport/netty4/SimpleNetty4TransportTests.java b/modules/transport-netty4/src/test/java/org/opensearch/transport/netty4/SimpleNetty4TransportTests.java index 27bfaef15ca86..bb5ed5dca417d 100644 --- a/modules/transport-netty4/src/test/java/org/opensearch/transport/netty4/SimpleNetty4TransportTests.java +++ b/modules/transport-netty4/src/test/java/org/opensearch/transport/netty4/SimpleNetty4TransportTests.java @@ -33,7 +33,7 @@ package org.opensearch.transport.netty4; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.network.NetworkService; diff --git a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/EventsCorrelationPlugin.java b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/EventsCorrelationPlugin.java index ea05302733ff1..d712136160225 100644 --- a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/EventsCorrelationPlugin.java +++ b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/EventsCorrelationPlugin.java @@ -9,7 +9,7 @@ package org.opensearch.plugin.correlation; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.node.DiscoveryNodes; diff --git a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/action/IndexCorrelationRuleResponse.java b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/action/IndexCorrelationRuleResponse.java index 8ba975a6b9b35..ccd2aaf7215d1 100644 --- a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/action/IndexCorrelationRuleResponse.java +++ b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/action/IndexCorrelationRuleResponse.java @@ -8,7 +8,7 @@ package org.opensearch.plugin.correlation.rules.action; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.ParseField; diff --git a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/transport/TransportIndexCorrelationRuleAction.java b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/transport/TransportIndexCorrelationRuleAction.java index 5fb31f1f352cb..54c3aebd744b3 100644 --- a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/transport/TransportIndexCorrelationRuleAction.java +++ b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/rules/transport/TransportIndexCorrelationRuleAction.java @@ -11,7 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchStatusException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; diff --git a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/CorrelationRuleIndices.java b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/CorrelationRuleIndices.java index a38ebd58cb655..3b6819bb3f78f 100644 --- a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/CorrelationRuleIndices.java +++ b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/CorrelationRuleIndices.java @@ -10,7 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.client.Client; diff --git a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/IndexUtils.java b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/IndexUtils.java index d40e986e4b0d1..4b1ea5a2e1622 100644 --- a/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/IndexUtils.java +++ b/plugins/events-correlation-engine/src/main/java/org/opensearch/plugin/correlation/utils/IndexUtils.java @@ -8,7 +8,7 @@ package org.opensearch.plugin.correlation.utils; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.client.IndicesAdminClient; diff --git a/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobContainer.java b/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobContainer.java index d6fa72221f408..3977d5589d80f 100644 --- a/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobContainer.java +++ b/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobContainer.java @@ -38,7 +38,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.support.GroupedActionListener; import org.opensearch.action.support.PlainActionFuture; diff --git a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java index 1a644934245cb..19486c56a7e15 100644 --- a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java +++ b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.Nullable; import org.opensearch.common.SetOnce; import org.opensearch.common.StreamContext; diff --git a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java index f98b775d9ce4b..58077971660f5 100644 --- a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java +++ b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.Metadata; import org.opensearch.cluster.metadata.RepositoryMetadata; diff --git a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobContainerMockClientTests.java b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobContainerMockClientTests.java index 8bb446fff0b61..a7dd3a7b87b58 100644 --- a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobContainerMockClientTests.java +++ b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobContainerMockClientTests.java @@ -12,7 +12,7 @@ import org.junit.After; import org.junit.Before; import org.mockito.invocation.InvocationOnMock; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.metadata.RepositoryMetadata; import org.opensearch.common.CheckedTriFunction; import org.opensearch.common.StreamContext; diff --git a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobContainerRetriesTests.java b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobContainerRetriesTests.java index 016be07e5d533..f19d2fd57d5b1 100644 --- a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobContainerRetriesTests.java +++ b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobContainerRetriesTests.java @@ -35,7 +35,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.metadata.RepositoryMetadata; import org.opensearch.common.CheckedTriFunction; import org.opensearch.common.Nullable; diff --git a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobStoreContainerTests.java b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobStoreContainerTests.java index f88b3616d2f0a..fe38eb42b43d0 100644 --- a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobStoreContainerTests.java +++ b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/S3BlobStoreContainerTests.java @@ -33,7 +33,7 @@ package org.opensearch.repositories.s3; import org.mockito.ArgumentCaptor; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.blobstore.BlobContainer; import org.opensearch.common.blobstore.BlobMetadata; import org.opensearch.common.blobstore.BlobPath; diff --git a/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpChannel.java b/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpChannel.java index a20bb55458951..6c341b07f433d 100644 --- a/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpChannel.java +++ b/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpChannel.java @@ -32,7 +32,7 @@ package org.opensearch.http.nio; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.http.HttpChannel; import org.opensearch.http.HttpResponse; import org.opensearch.nio.NioSocketChannel; diff --git a/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpServerChannel.java b/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpServerChannel.java index 781a4f03da952..2c47bf009f2a3 100644 --- a/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpServerChannel.java +++ b/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpServerChannel.java @@ -32,7 +32,7 @@ package org.opensearch.http.nio; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.http.HttpServerChannel; import org.opensearch.nio.NioServerSocketChannel; diff --git a/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpServerTransport.java b/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpServerTransport.java index 9dd13144bc454..739a9a25bd165 100644 --- a/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpServerTransport.java +++ b/plugins/transport-nio/src/main/java/org/opensearch/http/nio/NioHttpServerTransport.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.ClusterSettings; diff --git a/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTcpChannel.java b/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTcpChannel.java index 48b797840f5ff..3aa02d11dfd75 100644 --- a/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTcpChannel.java +++ b/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTcpChannel.java @@ -32,7 +32,7 @@ package org.opensearch.transport.nio; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.nio.NioSocketChannel; import org.opensearch.transport.TcpChannel; diff --git a/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTcpServerChannel.java b/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTcpServerChannel.java index 69218f2f1fcf5..a0fb2ef4cfdf2 100644 --- a/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTcpServerChannel.java +++ b/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTcpServerChannel.java @@ -32,7 +32,7 @@ package org.opensearch.transport.nio; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.nio.NioServerSocketChannel; import org.opensearch.transport.TcpServerChannel; diff --git a/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTransport.java b/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTransport.java index 0990f97124e53..533697e0119fe 100644 --- a/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTransport.java +++ b/plugins/transport-nio/src/main/java/org/opensearch/transport/nio/NioTransport.java @@ -37,7 +37,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; diff --git a/plugins/transport-nio/src/test/java/org/opensearch/http/nio/NioHttpClient.java b/plugins/transport-nio/src/test/java/org/opensearch/http/nio/NioHttpClient.java index 2922f28e3be18..004e7f6785540 100644 --- a/plugins/transport-nio/src/test/java/org/opensearch/http/nio/NioHttpClient.java +++ b/plugins/transport-nio/src/test/java/org/opensearch/http/nio/NioHttpClient.java @@ -47,7 +47,7 @@ import io.netty.handler.codec.http.HttpResponseDecoder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.common.network.NetworkService; import org.opensearch.common.settings.Settings; diff --git a/plugins/transport-nio/src/test/java/org/opensearch/transport/nio/SimpleNioTransportTests.java b/plugins/transport-nio/src/test/java/org/opensearch/transport/nio/SimpleNioTransportTests.java index d7f603031ac17..4e099218e5b55 100644 --- a/plugins/transport-nio/src/test/java/org/opensearch/transport/nio/SimpleNioTransportTests.java +++ b/plugins/transport-nio/src/test/java/org/opensearch/transport/nio/SimpleNioTransportTests.java @@ -33,7 +33,7 @@ package org.opensearch.transport.nio; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.network.NetworkService; diff --git a/qa/ccs-unavailable-clusters/src/test/java/org/opensearch/search/CrossClusterSearchUnavailableClusterIT.java b/qa/ccs-unavailable-clusters/src/test/java/org/opensearch/search/CrossClusterSearchUnavailableClusterIT.java index 6b09d5477e8d2..5d2f835aff4b0 100644 --- a/qa/ccs-unavailable-clusters/src/test/java/org/opensearch/search/CrossClusterSearchUnavailableClusterIT.java +++ b/qa/ccs-unavailable-clusters/src/test/java/org/opensearch/search/CrossClusterSearchUnavailableClusterIT.java @@ -62,6 +62,7 @@ import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.common.settings.Settings; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.search.aggregations.InternalAggregations; diff --git a/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java b/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java index 75f7e00f499c6..686fc78dcec8a 100644 --- a/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java +++ b/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java @@ -45,6 +45,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.common.xcontent.support.XContentMapValues; +import org.opensearch.core.common.Strings; import org.opensearch.index.seqno.SeqNoStats; import org.opensearch.indices.replication.common.ReplicationType; import org.opensearch.core.rest.RestStatus; diff --git a/qa/multi-cluster-search/src/test/java/org/opensearch/search/CCSDuelIT.java b/qa/multi-cluster-search/src/test/java/org/opensearch/search/CCSDuelIT.java index 218254a8cdba4..3dc2444d8a16e 100644 --- a/qa/multi-cluster-search/src/test/java/org/opensearch/search/CCSDuelIT.java +++ b/qa/multi-cluster-search/src/test/java/org/opensearch/search/CCSDuelIT.java @@ -36,7 +36,7 @@ import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; import org.apache.lucene.search.join.ScoreMode; import org.apache.lucene.tests.util.TimeUnits; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.admin.indices.refresh.RefreshRequest; import org.opensearch.action.admin.indices.refresh.RefreshResponse; diff --git a/qa/smoke-test-http/src/test/java/org/opensearch/http/SearchRestCancellationIT.java b/qa/smoke-test-http/src/test/java/org/opensearch/http/SearchRestCancellationIT.java index 29e3d8bdcd41b..8e7fee1e4f523 100644 --- a/qa/smoke-test-http/src/test/java/org/opensearch/http/SearchRestCancellationIT.java +++ b/qa/smoke-test-http/src/test/java/org/opensearch/http/SearchRestCancellationIT.java @@ -60,7 +60,7 @@ import org.opensearch.search.lookup.LeafFieldsLookup; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import org.opensearch.tasks.TaskManager; import org.opensearch.transport.TransportService; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/ListenerActionIT.java b/server/src/internalClusterTest/java/org/opensearch/action/ListenerActionIT.java index 1512fa4934ca1..c82ca0a06f4a1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/ListenerActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/ListenerActionIT.java @@ -36,6 +36,7 @@ import org.opensearch.action.index.IndexResponse; import org.opensearch.client.Client; import org.opensearch.client.Requests; +import org.opensearch.core.action.ActionListener; import org.opensearch.test.OpenSearchIntegTestCase; import java.util.concurrent.CountDownLatch; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/RejectionActionIT.java b/server/src/internalClusterTest/java/org/opensearch/action/RejectionActionIT.java index bda24b48b7f10..e52df4476241b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/RejectionActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/RejectionActionIT.java @@ -38,6 +38,7 @@ import org.opensearch.action.search.SearchType; import org.opensearch.action.search.ShardSearchFailure; import org.opensearch.common.settings.Settings; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException; import org.opensearch.index.query.QueryBuilders; import org.opensearch.test.OpenSearchIntegTestCase; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/HotThreadsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/HotThreadsIT.java index ab44c95b4f5a6..e5cffff6992b7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/HotThreadsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/HotThreadsIT.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin; import org.apache.lucene.util.Constants; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.hotthreads.NodeHotThreads; import org.opensearch.action.admin.cluster.node.hotthreads.NodesHotThreadsRequestBuilder; import org.opensearch.action.admin.cluster.node.hotthreads.NodesHotThreadsResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/ReloadSecureSettingsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/ReloadSecureSettingsIT.java index e095927efdd01..29f0dd7df0fe2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/ReloadSecureSettingsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/ReloadSecureSettingsIT.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.reload.NodesReloadSecureSettingsResponse; import org.opensearch.common.settings.KeyStoreWrapper; import org.opensearch.common.settings.SecureSettings; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/AbstractTasksIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/AbstractTasksIT.java index 8ba566aaa69b2..8219e3a9ef0da 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/AbstractTasksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/AbstractTasksIT.java @@ -19,9 +19,9 @@ import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.plugins.Plugin; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; -import org.opensearch.tasks.ThreadResourceInfo; +import org.opensearch.core.tasks.resourcetracker.ThreadResourceInfo; import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.tasks.MockTaskManager; import org.opensearch.test.transport.MockTransportService; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksIT.java index 161dee1a96e3c..b81aeb1c7407f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksIT.java @@ -33,11 +33,11 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionRunnable; import org.opensearch.action.ActionType; import org.opensearch.action.LatchedActionListener; @@ -60,8 +60,8 @@ import org.opensearch.plugins.Plugin; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskCancelledException; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import org.opensearch.tasks.TaskManager; import org.opensearch.test.OpenSearchIntegTestCase; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/ConcurrentSearchTasksIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/ConcurrentSearchTasksIT.java index 2b2421072e03b..8876b374191e9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/ConcurrentSearchTasksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/ConcurrentSearchTasksIT.java @@ -19,7 +19,7 @@ import org.opensearch.common.util.FeatureFlags; import org.opensearch.index.query.QueryBuilders; import org.opensearch.tasks.TaskInfo; -import org.opensearch.tasks.ThreadResourceInfo; +import org.opensearch.core.tasks.resourcetracker.ThreadResourceInfo; import java.util.List; import java.util.Map; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TaskStorageRetryIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TaskStorageRetryIT.java index e710d3a8438d8..97c799a9e948a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TaskStorageRetryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TaskStorageRetryIT.java @@ -38,7 +38,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.plugins.Plugin; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchSingleNodeTestCase; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TasksIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TasksIT.java index e6b578f41e4cf..86d3ebed13f35 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TasksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/node/tasks/TasksIT.java @@ -35,8 +35,8 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.TaskOperationFailure; import org.opensearch.action.admin.cluster.health.ClusterHealthAction; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse; @@ -63,7 +63,7 @@ import org.opensearch.index.query.QueryBuilders; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import org.opensearch.tasks.TaskResult; import org.opensearch.tasks.TaskResultsService; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java index e969e06ec56e0..750a87cb61241 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.create; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.UnavailableShardsException; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; import org.opensearch.action.admin.indices.alias.Alias; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkRejectionIT.java b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkRejectionIT.java index 7dde67791a2ec..b48d478fd98a8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkRejectionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkRejectionIT.java @@ -31,7 +31,7 @@ package org.opensearch.action.bulk; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.WriteRequest; import org.opensearch.common.settings.Settings; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/search/SearchProgressActionListenerIT.java b/server/src/internalClusterTest/java/org/opensearch/action/search/SearchProgressActionListenerIT.java index eb69eaaa9c2e1..4203f47e19fb5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/search/SearchProgressActionListenerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/search/SearchProgressActionListenerIT.java @@ -44,7 +44,7 @@ import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.search.sort.FieldSortBuilder; import org.opensearch.search.sort.SortOrder; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchSingleNodeTestCase; import java.util.ArrayList; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java index 24a66083d85ff..bb6382b9d3e7e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java @@ -37,7 +37,7 @@ import org.apache.lucene.search.ScoreMode; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.stats.NodeStats; import org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/support/ActiveShardsObserverIT.java b/server/src/internalClusterTest/java/org/opensearch/action/support/ActiveShardsObserverIT.java index 30f5c21ba6cd7..af7794a4b2641 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/support/ActiveShardsObserverIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/support/ActiveShardsObserverIT.java @@ -32,7 +32,7 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.common.Priority; import org.opensearch.common.settings.Settings; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/support/replication/TransportReplicationActionRetryOnClosedNodeIT.java b/server/src/internalClusterTest/java/org/opensearch/action/support/replication/TransportReplicationActionRetryOnClosedNodeIT.java index 7d663dd70edd6..041e249d231fa 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/support/replication/TransportReplicationActionRetryOnClosedNodeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/support/replication/TransportReplicationActionRetryOnClosedNodeIT.java @@ -32,9 +32,9 @@ package org.opensearch.action.support.replication; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; import org.opensearch.cluster.action.shard.ShardStateAction; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java index e84f40b3813eb..1adcb6f323acb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java @@ -39,7 +39,7 @@ import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.util.BytesRef; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsResponse; import org.opensearch.action.admin.indices.alias.Alias; import org.opensearch.action.index.IndexRequestBuilder; diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/ClusterHealthIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/ClusterHealthIT.java index 56f290ef4b50c..b9e8f5f76ffb9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/ClusterHealthIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/ClusterHealthIT.java @@ -32,7 +32,7 @@ package org.opensearch.cluster; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequest; import org.opensearch.action.support.IndicesOptions; diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/ClusterInfoServiceIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/ClusterInfoServiceIT.java index 508b8e21e42c1..377834564ab46 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/ClusterInfoServiceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/ClusterInfoServiceIT.java @@ -33,7 +33,7 @@ package org.opensearch.cluster; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.admin.cluster.node.stats.NodesStatsAction; import org.opensearch.action.admin.indices.stats.IndicesStatsAction; diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/action/shard/ShardStateActionIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/action/shard/ShardStateActionIT.java index e0d070c385def..ee4195d0fcb48 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/action/shard/ShardStateActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/action/shard/ShardStateActionIT.java @@ -32,7 +32,7 @@ package org.opensearch.cluster.action.shard; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; import org.opensearch.cluster.ClusterState; diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java index 9c8cb9f15e79c..f26246f274e06 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java @@ -35,10 +35,10 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.Version; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestBuilder; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.index.IndexResponse; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.cluster.ClusterState; diff --git a/server/src/internalClusterTest/java/org/opensearch/clustermanager/ClusterManagerTaskThrottlingIT.java b/server/src/internalClusterTest/java/org/opensearch/clustermanager/ClusterManagerTaskThrottlingIT.java index 9817861c88e9a..7422d0b82d250 100644 --- a/server/src/internalClusterTest/java/org/opensearch/clustermanager/ClusterManagerTaskThrottlingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/clustermanager/ClusterManagerTaskThrottlingIT.java @@ -8,7 +8,7 @@ package org.opensearch.clustermanager; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; import org.opensearch.cluster.metadata.ProcessClusterEventTimeoutException; diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java index 7535762fe7d1a..6f3e2ced0b63f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java @@ -36,7 +36,7 @@ import org.apache.lucene.index.CorruptIndexException; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.NoShardAvailableActionException; import org.opensearch.action.get.GetResponse; import org.opensearch.action.index.IndexRequestBuilder; diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/SnapshotDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/SnapshotDisruptionIT.java index 691e3ca51eb8c..116934f7a4697 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/SnapshotDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/SnapshotDisruptionIT.java @@ -33,7 +33,7 @@ package org.opensearch.discovery; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; import org.opensearch.action.index.IndexRequestBuilder; diff --git a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java index dd162e5b1f3b2..e548d10a39e08 100644 --- a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java @@ -43,17 +43,17 @@ import org.opensearch.action.get.MultiGetRequestBuilder; import org.opensearch.action.get.MultiGetResponse; import org.opensearch.action.index.IndexResponse; -import org.opensearch.core.action.support.DefaultShardOperationFailedException; import org.opensearch.common.Nullable; import org.opensearch.common.lucene.uid.Versions; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.core.action.support.DefaultShardOperationFailedException; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.index.engine.VersionConflictEngineException; import org.opensearch.plugins.Plugin; -import org.opensearch.core.rest.RestStatus; import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.InternalSettingsPlugin; diff --git a/server/src/internalClusterTest/java/org/opensearch/index/IndexingPressureIT.java b/server/src/internalClusterTest/java/org/opensearch/index/IndexingPressureIT.java index b3040f832f5fd..8e9364c9e1a84 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/IndexingPressureIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/IndexingPressureIT.java @@ -31,7 +31,7 @@ package org.opensearch.index; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; import org.opensearch.action.admin.indices.stats.ShardStats; import org.opensearch.action.bulk.BulkRequest; diff --git a/server/src/internalClusterTest/java/org/opensearch/index/ShardIndexingPressureIT.java b/server/src/internalClusterTest/java/org/opensearch/index/ShardIndexingPressureIT.java index 43d8173103656..73054dbc0e6ed 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/ShardIndexingPressureIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/ShardIndexingPressureIT.java @@ -6,7 +6,7 @@ package org.opensearch.index; import org.apache.lucene.util.RamUsageEstimator; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; import org.opensearch.action.admin.indices.stats.ShardStats; import org.opensearch.action.bulk.BulkItemRequest; diff --git a/server/src/internalClusterTest/java/org/opensearch/index/ShardIndexingPressureSettingsIT.java b/server/src/internalClusterTest/java/org/opensearch/index/ShardIndexingPressureSettingsIT.java index 707a0f6ab8818..671d432130a74 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/ShardIndexingPressureSettingsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/ShardIndexingPressureSettingsIT.java @@ -6,7 +6,7 @@ package org.opensearch.index; import org.apache.lucene.util.RamUsageEstimator; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; import org.opensearch.action.admin.indices.stats.ShardStats; diff --git a/server/src/internalClusterTest/java/org/opensearch/index/WaitUntilRefreshIT.java b/server/src/internalClusterTest/java/org/opensearch/index/WaitUntilRefreshIT.java index 0927d274b1265..8cfe228780478 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/WaitUntilRefreshIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/WaitUntilRefreshIT.java @@ -32,7 +32,7 @@ package org.opensearch.index; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.bulk.BulkItemResponse; import org.opensearch.action.bulk.BulkRequestBuilder; diff --git a/server/src/internalClusterTest/java/org/opensearch/index/seqno/RetentionLeaseIT.java b/server/src/internalClusterTest/java/org/opensearch/index/seqno/RetentionLeaseIT.java index e12c5d44df69b..5a76328f032a4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/seqno/RetentionLeaseIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/seqno/RetentionLeaseIT.java @@ -33,7 +33,7 @@ package org.opensearch.index.seqno; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.replication.ReplicationResponse; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java b/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java index 6702690c2f671..f1c0e17ed61b0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java @@ -35,7 +35,7 @@ import org.apache.lucene.store.LockObtainFailedException; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/index/shard/SearchIdleIT.java b/server/src/internalClusterTest/java/org/opensearch/index/shard/SearchIdleIT.java index 7a02f7831fb59..c0cf0dc7a23b6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/shard/SearchIdleIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/shard/SearchIdleIT.java @@ -32,7 +32,7 @@ package org.opensearch.index.shard; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.MultiGetRequest; import org.opensearch.action.index.IndexResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/ConcurrentDynamicTemplateIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/ConcurrentDynamicTemplateIT.java index e731b0074f04d..fc13310673bf2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/ConcurrentDynamicTemplateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/ConcurrentDynamicTemplateIT.java @@ -32,7 +32,7 @@ package org.opensearch.indices.mapping; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.index.IndexResponse; import org.opensearch.index.query.QueryBuilders; import org.opensearch.test.OpenSearchIntegTestCase; diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java index 4b314ef1ae27b..66469241b83d8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java @@ -21,7 +21,7 @@ import org.apache.lucene.tests.util.TestUtil; import org.apache.lucene.util.BytesRef; import org.junit.Before; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationRelocationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationRelocationIT.java index 3024eeb798b48..1cbb6c736f9ee 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationRelocationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationRelocationIT.java @@ -9,7 +9,7 @@ package org.opensearch.indices.replication; import org.opensearch.OpenSearchCorruptionException; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.reroute.ClusterRerouteResponse; import org.opensearch.action.admin.indices.replication.SegmentReplicationStatsResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/state/ReopenWhileClosingIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/state/ReopenWhileClosingIT.java index 92eefefab7867..3645b966bd77e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/state/ReopenWhileClosingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/state/ReopenWhileClosingIT.java @@ -32,7 +32,7 @@ package org.opensearch.indices.state; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.indices.close.CloseIndexResponse; import org.opensearch.action.admin.indices.close.TransportVerifyShardBeforeCloseAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/internalClusterTest/java/org/opensearch/persistent/PersistentTasksExecutorIT.java b/server/src/internalClusterTest/java/org/opensearch/persistent/PersistentTasksExecutorIT.java index 13d7e838b920a..7a1bbca07fbc4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/persistent/PersistentTasksExecutorIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/persistent/PersistentTasksExecutorIT.java @@ -45,7 +45,7 @@ import org.opensearch.persistent.TestPersistentTasksPlugin.TestPersistentTasksExecutor; import org.opensearch.persistent.TestPersistentTasksPlugin.TestTasksRequestBuilder; import org.opensearch.plugins.Plugin; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import org.opensearch.test.OpenSearchIntegTestCase; import org.junit.After; diff --git a/server/src/internalClusterTest/java/org/opensearch/persistent/decider/EnableAssignmentDeciderIT.java b/server/src/internalClusterTest/java/org/opensearch/persistent/decider/EnableAssignmentDeciderIT.java index aa1eeacbadd9d..fcfa7df9deac1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/persistent/decider/EnableAssignmentDeciderIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/persistent/decider/EnableAssignmentDeciderIT.java @@ -32,7 +32,7 @@ package org.opensearch.persistent.decider; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java b/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java index 796f253990bcb..86c0a1b6ac313 100644 --- a/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java @@ -34,7 +34,7 @@ import org.apache.lucene.index.IndexFileNames; import org.apache.lucene.tests.util.English; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.reroute.ClusterRerouteResponse; import org.opensearch.action.admin.indices.stats.ShardStats; diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/multipart/mocks/MockFsVerifyingBlobContainer.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/multipart/mocks/MockFsVerifyingBlobContainer.java index 8f2814eb7c4c4..f77a300fe1bf5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/multipart/mocks/MockFsVerifyingBlobContainer.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/multipart/mocks/MockFsVerifyingBlobContainer.java @@ -9,7 +9,7 @@ package org.opensearch.remotestore.multipart.mocks; import org.apache.lucene.index.CorruptIndexException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.blobstore.VerifyingMultiStreamBlobContainer; import org.opensearch.common.io.InputStreamContainer; import org.opensearch.common.StreamContext; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/SearchCancellationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/SearchCancellationIT.java index 7fb0bc45fb084..b186da7f92a26 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/SearchCancellationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/SearchCancellationIT.java @@ -36,7 +36,7 @@ import org.junit.After; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.action.bulk.BulkRequestBuilder; @@ -58,7 +58,7 @@ import org.opensearch.script.Script; import org.opensearch.script.ScriptType; import org.opensearch.search.lookup.LeafFieldsLookup; -import org.opensearch.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskCancelledException; import org.opensearch.tasks.TaskInfo; import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.transport.TransportException; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/backpressure/SearchBackpressureIT.java b/server/src/internalClusterTest/java/org/opensearch/search/backpressure/SearchBackpressureIT.java index 070a2bd7d6b7c..b6734f3f447dc 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/backpressure/SearchBackpressureIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/backpressure/SearchBackpressureIT.java @@ -11,10 +11,10 @@ import org.hamcrest.MatcherAssert; import org.junit.After; import org.junit.Before; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; import org.opensearch.action.search.SearchShardTask; @@ -34,8 +34,8 @@ import org.opensearch.search.backpressure.settings.SearchTaskSettings; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskCancelledException; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java index 0a03fb6404742..bb26c133e8cbd 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java @@ -33,7 +33,7 @@ package org.opensearch.search.functionscore; import org.opensearch.Version; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchPhaseExecutionException; import org.opensearch.action.search.SearchResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScorePluginIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScorePluginIT.java index a1d3d9f22af04..3d601d0c12760 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScorePluginIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScorePluginIT.java @@ -33,7 +33,7 @@ package org.opensearch.search.functionscore; import org.apache.lucene.search.Explanation; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.search.SearchResponse; import org.opensearch.action.search.SearchType; import org.opensearch.common.Priority; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/pit/DeletePitMultiNodeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/pit/DeletePitMultiNodeIT.java index 6fea62a416818..ef051a589de92 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/pit/DeletePitMultiNodeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/pit/DeletePitMultiNodeIT.java @@ -10,10 +10,10 @@ import org.junit.After; import org.junit.Before; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.indices.stats.IndicesStatsRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.search.CreatePitAction; import org.opensearch.action.search.CreatePitRequest; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/pit/PitMultiNodeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/pit/PitMultiNodeIT.java index 117165bf1e4d6..e88eca49132ec 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/pit/PitMultiNodeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/pit/PitMultiNodeIT.java @@ -11,8 +11,8 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.admin.cluster.state.ClusterStateRequest; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; 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 2a662c9dda088..44c7195628284 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java @@ -32,7 +32,7 @@ package org.opensearch.search.searchafter; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.CreatePitAction; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/slice/SearchSliceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/slice/SearchSliceIT.java index dcc1136a6d267..0b7e48e597d82 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/slice/SearchSliceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/slice/SearchSliceIT.java @@ -32,7 +32,7 @@ package org.opensearch.search.slice; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.index.IndexRequestBuilder; diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/AbortedRestoreIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/AbortedRestoreIT.java index 97faacb38bc50..16a0720b43992 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/AbortedRestoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/AbortedRestoreIT.java @@ -32,7 +32,7 @@ package org.opensearch.snapshots; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse; import org.opensearch.action.admin.indices.recovery.RecoveryResponse; import org.opensearch.action.support.IndicesOptions; diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/CloneSnapshotIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/CloneSnapshotIT.java index d19cb513ed38d..0d3712618beaa 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/CloneSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/CloneSnapshotIT.java @@ -31,7 +31,7 @@ package org.opensearch.snapshots; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.opensearch.action.admin.cluster.snapshots.status.SnapshotIndexStatus; import org.opensearch.action.admin.cluster.snapshots.status.SnapshotStatus; diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/ConcurrentSnapshotsIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/ConcurrentSnapshotsIT.java index e2c2c1dfe62d8..06a39ba695326 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/ConcurrentSnapshotsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/ConcurrentSnapshotsIT.java @@ -32,8 +32,8 @@ package org.opensearch.snapshots; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest; diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/DedicatedClusterSnapshotRestoreIT.java index 85c1a7251d143..2187ccc133bc4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/DedicatedClusterSnapshotRestoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/DedicatedClusterSnapshotRestoreIT.java @@ -33,7 +33,7 @@ package org.opensearch.snapshots; import org.opensearch.Version; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/DeleteSnapshotIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/DeleteSnapshotIT.java index d38620723a8f4..65e3d2ad3760c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/DeleteSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/DeleteSnapshotIT.java @@ -8,7 +8,7 @@ package org.opensearch.snapshots; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.client.Client; diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/RemoteIndexSnapshotStatusApiIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/RemoteIndexSnapshotStatusApiIT.java index d17410d8921ed..02f69f89b8833 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/RemoteIndexSnapshotStatusApiIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/RemoteIndexSnapshotStatusApiIT.java @@ -32,7 +32,7 @@ package org.opensearch.snapshots; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.opensearch.action.admin.cluster.snapshots.status.SnapshotIndexShardStage; import org.opensearch.action.admin.cluster.snapshots.status.SnapshotIndexShardStatus; diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/RepositoryFilterUserMetadataIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/RepositoryFilterUserMetadataIT.java index cae0f59dab36e..380a0a0427bee 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/RepositoryFilterUserMetadataIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/RepositoryFilterUserMetadataIT.java @@ -34,7 +34,7 @@ import org.apache.lucene.index.IndexCommit; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.Metadata; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java index 0274ca874c7b9..0fda69c2d77e7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java @@ -32,7 +32,7 @@ package org.opensearch.snapshots; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse; import org.opensearch.action.admin.indices.settings.get.GetSettingsResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/SharedClusterSnapshotRestoreIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/SharedClusterSnapshotRestoreIT.java index 420df6b4c34c8..b5ad68081da46 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/SharedClusterSnapshotRestoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/SharedClusterSnapshotRestoreIT.java @@ -37,7 +37,7 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java index e02a5b95da400..cd032a8a08c77 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java @@ -33,7 +33,7 @@ package org.opensearch.snapshots; import org.opensearch.Version; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest; import org.opensearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java index 437b6c25ef4b6..4a944ca50b23c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java @@ -33,7 +33,7 @@ package org.opensearch.update; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.admin.indices.alias.Alias; diff --git a/server/src/internalClusterTest/java/org/opensearch/versioning/ConcurrentDocumentOperationIT.java b/server/src/internalClusterTest/java/org/opensearch/versioning/ConcurrentDocumentOperationIT.java index 661efbaf9cd01..67b373be478d2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/versioning/ConcurrentDocumentOperationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/versioning/ConcurrentDocumentOperationIT.java @@ -32,7 +32,7 @@ package org.opensearch.versioning; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.index.IndexResponse; import org.opensearch.common.settings.Settings; import org.opensearch.test.OpenSearchIntegTestCase; diff --git a/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java b/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java index 5898bba9762ad..669dbe270ad94 100644 --- a/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java @@ -32,7 +32,7 @@ package org.opensearch.versioning; import org.apache.lucene.tests.util.TestUtil; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.bulk.BulkResponse; diff --git a/server/src/main/java/org/opensearch/OpenSearchServerException.java b/server/src/main/java/org/opensearch/OpenSearchServerException.java index b8c6d1e78d25a..11d30178e0930 100644 --- a/server/src/main/java/org/opensearch/OpenSearchServerException.java +++ b/server/src/main/java/org/opensearch/OpenSearchServerException.java @@ -987,14 +987,6 @@ public static void registerExceptions() { UNKNOWN_VERSION_ADDED ) ); - registerExceptionHandle( - new OpenSearchExceptionHandle( - org.opensearch.tasks.TaskCancelledException.class, - org.opensearch.tasks.TaskCancelledException::new, - 146, - UNKNOWN_VERSION_ADDED - ) - ); registerExceptionHandle( new OpenSearchExceptionHandle( org.opensearch.env.ShardLockObtainFailedException.class, diff --git a/server/src/main/java/org/opensearch/action/ActionListenerResponseHandler.java b/server/src/main/java/org/opensearch/action/ActionListenerResponseHandler.java index 2f376d81fa202..9222a5d2fedc0 100644 --- a/server/src/main/java/org/opensearch/action/ActionListenerResponseHandler.java +++ b/server/src/main/java/org/opensearch/action/ActionListenerResponseHandler.java @@ -32,6 +32,7 @@ package org.opensearch.action; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/main/java/org/opensearch/action/ActionModule.java b/server/src/main/java/org/opensearch/action/ActionModule.java index b775095861150..b68c2b59e481b 100644 --- a/server/src/main/java/org/opensearch/action/ActionModule.java +++ b/server/src/main/java/org/opensearch/action/ActionModule.java @@ -294,6 +294,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.SettingsFilter; import org.opensearch.common.util.FeatureFlags; +import org.opensearch.core.action.ActionResponse; import org.opensearch.extensions.ExtensionsManager; import org.opensearch.extensions.action.ExtensionProxyAction; import org.opensearch.extensions.action.ExtensionProxyTransportAction; diff --git a/server/src/main/java/org/opensearch/action/ActionRequestBuilder.java b/server/src/main/java/org/opensearch/action/ActionRequestBuilder.java index 27358a0412468..1e0af8c9f9a73 100644 --- a/server/src/main/java/org/opensearch/action/ActionRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/ActionRequestBuilder.java @@ -33,7 +33,10 @@ package org.opensearch.action; import org.opensearch.client.OpenSearchClient; +import org.opensearch.common.action.ActionFuture; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import java.util.Objects; diff --git a/server/src/main/java/org/opensearch/action/ActionRunnable.java b/server/src/main/java/org/opensearch/action/ActionRunnable.java index 2c3f70afda75d..073c2e784a404 100644 --- a/server/src/main/java/org/opensearch/action/ActionRunnable.java +++ b/server/src/main/java/org/opensearch/action/ActionRunnable.java @@ -36,6 +36,7 @@ import org.opensearch.common.CheckedRunnable; import org.opensearch.common.CheckedSupplier; import org.opensearch.common.util.concurrent.AbstractRunnable; +import org.opensearch.core.action.ActionListener; /** * Base class for {@link Runnable}s that need to call {@link ActionListener#onFailure(Exception)} in case an uncaught diff --git a/server/src/main/java/org/opensearch/action/ActionType.java b/server/src/main/java/org/opensearch/action/ActionType.java index 3fad07ca6fce1..11a712bb7759f 100644 --- a/server/src/main/java/org/opensearch/action/ActionType.java +++ b/server/src/main/java/org/opensearch/action/ActionType.java @@ -32,6 +32,7 @@ package org.opensearch.action; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.common.settings.Settings; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/LatchedActionListener.java b/server/src/main/java/org/opensearch/action/LatchedActionListener.java index 57d5c9282465f..c2400d3b59850 100644 --- a/server/src/main/java/org/opensearch/action/LatchedActionListener.java +++ b/server/src/main/java/org/opensearch/action/LatchedActionListener.java @@ -32,6 +32,8 @@ package org.opensearch.action; +import org.opensearch.core.action.ActionListener; + import java.util.concurrent.CountDownLatch; /** diff --git a/server/src/main/java/org/opensearch/action/ListenableActionFuture.java b/server/src/main/java/org/opensearch/action/ListenableActionFuture.java index 95bf3a2ae1384..1679ec804643e 100644 --- a/server/src/main/java/org/opensearch/action/ListenableActionFuture.java +++ b/server/src/main/java/org/opensearch/action/ListenableActionFuture.java @@ -32,6 +32,9 @@ package org.opensearch.action; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; + /** * An {@link ActionFuture} that listeners can be added to. * diff --git a/server/src/main/java/org/opensearch/action/StepListener.java b/server/src/main/java/org/opensearch/action/StepListener.java index b99fe20a46ed8..0cc8107e1089a 100644 --- a/server/src/main/java/org/opensearch/action/StepListener.java +++ b/server/src/main/java/org/opensearch/action/StepListener.java @@ -36,6 +36,8 @@ import org.opensearch.common.util.concurrent.OpenSearchExecutors; import org.opensearch.common.util.concurrent.FutureUtils; import org.opensearch.common.util.concurrent.ListenableFuture; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.NotifyOnceListener; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; diff --git a/server/src/main/java/org/opensearch/action/TransportActionNodeProxy.java b/server/src/main/java/org/opensearch/action/TransportActionNodeProxy.java index a04e89d9a1f8f..1088a3a4f8679 100644 --- a/server/src/main/java/org/opensearch/action/TransportActionNodeProxy.java +++ b/server/src/main/java/org/opensearch/action/TransportActionNodeProxy.java @@ -34,6 +34,8 @@ import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.settings.Settings; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.transport.TransportRequestOptions; import org.opensearch.transport.TransportService; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/allocation/ClusterAllocationExplainResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/allocation/ClusterAllocationExplainResponse.java index 5987d718a20ba..0eeedb9af0ab7 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/allocation/ClusterAllocationExplainResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/allocation/ClusterAllocationExplainResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.allocation; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java index 30d1e617258c5..3b0ddc1aa23cb 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterInfo; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsResponse.java index 3c511afe1cbff..7855f9643c4ce 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsResponse.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.cluster.configuration; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ToXContentObject; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsResponse.java index afbf7af81363f..eb2ccaa7f5390 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsResponse.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.cluster.configuration; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ToXContentObject; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java index 727458e8c0971..b872b53f18d34 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java index 83b08626a2fcd..d543740abe5bc 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/delete/TransportDeleteDecommissionStateAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/delete/TransportDeleteDecommissionStateAction.java index 6d52934a8ba3f..e9a6cf9cac0b0 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/delete/TransportDeleteDecommissionStateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/delete/TransportDeleteDecommissionStateAction.java @@ -10,7 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/GetDecommissionStateResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/GetDecommissionStateResponse.java index 41344abf7b153..34498bf7d5ed8 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/GetDecommissionStateResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/GetDecommissionStateResponse.java @@ -9,7 +9,7 @@ package org.opensearch.action.admin.cluster.decommission.awareness.get; import org.opensearch.OpenSearchParseException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.decommission.DecommissionStatus; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/TransportGetDecommissionStateAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/TransportGetDecommissionStateAction.java index 64744a24b4afd..04f456f8a464c 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/TransportGetDecommissionStateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/get/TransportGetDecommissionStateAction.java @@ -8,7 +8,7 @@ package org.opensearch.action.admin.cluster.decommission.awareness.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/put/TransportDecommissionAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/put/TransportDecommissionAction.java index f8a145c9063b9..c4648b5cab637 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/put/TransportDecommissionAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/decommission/awareness/put/TransportDecommissionAction.java @@ -10,7 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java index f5bfa5b256069..c109c067f2226 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.cluster.health; import org.opensearch.Version; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.awarenesshealth.ClusterAwarenessHealth; import org.opensearch.cluster.health.ClusterHealthStatus; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java index 09f6b7cd06cda..e773d2485430b 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.ActiveShardCount; import org.opensearch.action.support.IndicesOptions; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java index 1d2dbf66920f8..924eda2a5abd8 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java @@ -46,7 +46,7 @@ import org.opensearch.monitor.jvm.JvmInfo; import org.opensearch.monitor.os.OsInfo; import org.opensearch.monitor.process.ProcessInfo; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import org.opensearch.search.aggregations.support.AggregationInfo; import org.opensearch.search.pipeline.SearchPipelineInfo; import org.opensearch.threadpool.ThreadPoolInfo; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/PluginsAndModules.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/PluginsAndModules.java index 961fa6dac810f..df876057aa5fd 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/PluginsAndModules.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/PluginsAndModules.java @@ -35,7 +35,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import org.opensearch.plugins.PluginInfo; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/liveness/LivenessResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/liveness/LivenessResponse.java index 95b4d0d918578..690d8feed2f53 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/liveness/LivenessResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/liveness/LivenessResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.node.liveness; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java index f0582daee7261..2663a6c95c61c 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.util.Supplier; import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.nodes.TransportNodesAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/TransportCancelTasksAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/TransportCancelTasksAction.java index 909fb009aa100..3e81e2f6274e0 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/TransportCancelTasksAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/TransportCancelTasksAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.cluster.node.tasks.cancel; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.TaskOperationFailure; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskRequest.java index b504c7e6a39b0..20f06e7c39454 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskRequest.java @@ -37,7 +37,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.unit.TimeValue; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskRequestBuilder.java index 17b2a21b2863b..dd429da82ebf8 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskRequestBuilder.java @@ -35,7 +35,7 @@ import org.opensearch.action.ActionRequestBuilder; import org.opensearch.client.OpenSearchClient; import org.opensearch.common.unit.TimeValue; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; /** * Builder for the request to retrieve the list of tasks running on the specified nodes diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskResponse.java index 96fb65a9a1391..9d4e6da8c7e62 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/GetTaskResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.node.tasks.get; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java index 886c8a6671dd0..72d886ce32c48 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java @@ -35,7 +35,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.GetResponse; @@ -53,7 +53,7 @@ import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.IndexNotFoundException; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import org.opensearch.tasks.TaskResult; import org.opensearch.tasks.TaskResultsService; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java index 99b4d3dd006c8..564dbe53d775a 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java @@ -48,7 +48,7 @@ import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/TransportListTasksAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/TransportListTasksAction.java index aede3fe5b1cc0..6f4d5de2c1550 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/TransportListTasksAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/list/TransportListTasksAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.node.tasks.list; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.TaskOperationFailure; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/remote/RemoteInfoResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/remote/RemoteInfoResponse.java index 8173da8455434..9670aaa047cac 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/remote/RemoteInfoResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/remote/RemoteInfoResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.remote; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.transport.RemoteConnectionInfo; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/remote/TransportRemoteInfoAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/remote/TransportRemoteInfoAction.java index 794d21f1cbc7c..815f368b4d196 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/remote/TransportRemoteInfoAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/remote/TransportRemoteInfoAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.remote; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.SearchTransportService; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreResponse.java index 4ff03cb880cf3..962c786a88997 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/RestoreRemoteStoreResponse.java @@ -8,7 +8,7 @@ package org.opensearch.action.admin.cluster.remotestore.restore; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.common.Nullable; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/TransportRestoreRemoteStoreAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/TransportRestoreRemoteStoreAction.java index 613bf078b2c96..36c8038ba2d67 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/TransportRestoreRemoteStoreAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/TransportRestoreRemoteStoreAction.java @@ -8,7 +8,7 @@ package org.opensearch.action.admin.cluster.remotestore.restore; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreClusterStateListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/CleanupRepositoryResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/CleanupRepositoryResponse.java index 7d9dcd25aca8c..fd4779357a3f7 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/CleanupRepositoryResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/CleanupRepositoryResponse.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.cluster.repositories.cleanup; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java index 2b91c6641211d..59ef50049987e 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.StepListener; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java index 05a95b926f576..f0ad22b225a47 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.repositories.delete; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java index 53a94a8a56773..c370d866c8d59 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/get/GetRepositoriesResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.repositories.get; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.RepositoriesMetadata; import org.opensearch.cluster.metadata.RepositoryMetadata; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java index d367f75607d36..330e2caa04a57 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.repositories.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java index 16f7d6d5700bf..061dd4b000bd6 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.repositories.put; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/TransportVerifyRepositoryAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/TransportVerifyRepositoryAction.java index ec54d7640c1d3..81ab7a62db939 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/TransportVerifyRepositoryAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/TransportVerifyRepositoryAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.repositories.verify; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java index f01854fc5d29d..e0c527c5eafb7 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/verify/VerifyRepositoryResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.repositories.verify; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.ParseField; import org.opensearch.core.common.Strings; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java index 61f2a6301a2dd..8d9ec254b5c7c 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.admin.indices.shards.IndicesShardStoresAction; import org.opensearch.action.admin.indices.shards.IndicesShardStoresRequest; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterGetSettingsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterGetSettingsResponse.java index 521ba824e6e57..30db176383a10 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterGetSettingsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterGetSettingsResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.settings; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java index 542ca612d2b6c..a8f1600e5f04c 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.AckedClusterStateUpdateTask; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/ClusterSearchShardsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/ClusterSearchShardsResponse.java index d43ef8a0c9c61..460c65979f7e4 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/ClusterSearchShardsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/ClusterSearchShardsResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.shards; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java index 7e20e6a1b31d5..c35cf679c7c32 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.shards; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/delete/TransportDeleteWeightedRoutingAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/delete/TransportDeleteWeightedRoutingAction.java index 903fbb13d9f45..159a69e58bbfc 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/delete/TransportDeleteWeightedRoutingAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/delete/TransportDeleteWeightedRoutingAction.java @@ -10,7 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/get/ClusterGetWeightedRoutingResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/get/ClusterGetWeightedRoutingResponse.java index 91bd9ac2f00d1..6acf1af818811 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/get/ClusterGetWeightedRoutingResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/get/ClusterGetWeightedRoutingResponse.java @@ -9,7 +9,7 @@ package org.opensearch.action.admin.cluster.shards.routing.weighted.get; import org.opensearch.OpenSearchParseException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.WeightedRoutingMetadata; import org.opensearch.cluster.routing.WeightedRouting; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/get/TransportGetWeightedRoutingAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/get/TransportGetWeightedRoutingAction.java index e73e662314378..70483975404fa 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/get/TransportGetWeightedRoutingAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/get/TransportGetWeightedRoutingAction.java @@ -8,7 +8,7 @@ package org.opensearch.action.admin.cluster.shards.routing.weighted.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/TransportAddWeightedRoutingAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/TransportAddWeightedRoutingAction.java index ed178884faf54..e09b838d54dea 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/TransportAddWeightedRoutingAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/TransportAddWeightedRoutingAction.java @@ -8,7 +8,7 @@ package org.opensearch.action.admin.cluster.shards.routing.weighted.put; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/clone/TransportCloneSnapshotAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/clone/TransportCloneSnapshotAction.java index 05b3a5d676c5b..4bc9f8da8c86b 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/clone/TransportCloneSnapshotAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/clone/TransportCloneSnapshotAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.clone; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotResponse.java index bef95c417c038..90cacda31ff8e 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/CreateSnapshotResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.create; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.common.Nullable; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/TransportCreateSnapshotAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/TransportCreateSnapshotAction.java index 79f365bd3a951..56cd7a684070f 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/TransportCreateSnapshotAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/create/TransportCreateSnapshotAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.create; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java index 04b2c0b1be1b1..aeda2ab27d013 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.delete; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java index 12f441960ccaf..c502244a4b026 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.get; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java index dbf47f2b121e3..1ad3c9d32120e 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/get/TransportGetSnapshotsAction.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.lucene.util.CollectionUtil; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreClusterStateListener.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreClusterStateListener.java index 6fd593fdd3e08..1bde853a4eab6 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreClusterStateListener.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreClusterStateListener.java @@ -34,8 +34,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterStateListener; import org.opensearch.cluster.RestoreInProgress; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotResponse.java index 2cf1b40b92761..1c37a84786bbd 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.restore; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.common.Nullable; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/TransportRestoreSnapshotAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/TransportRestoreSnapshotAction.java index ec4d6b8412318..ebc9e029c41cf 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/TransportRestoreSnapshotAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/TransportRestoreSnapshotAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.restore; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java index bb7bb7eb70b68..e5e4e510c0b9f 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotsStatusResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.status; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java index b49c18082d0dc..1002971364608 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.StepListener; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java index ce3b020280b16..67f9608126c99 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.state; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.node.DiscoveryNodes; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/state/TransportClusterStateAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/state/TransportClusterStateAction.java index e57d2cf1b9803..aa7957d6d06da 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/state/TransportClusterStateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/state/TransportClusterStateAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetScriptContextResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetScriptContextResponse.java index f269a813dbaa4..d4106e4f9b225 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetScriptContextResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetScriptContextResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetScriptLanguageResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetScriptLanguageResponse.java index 192e89e08f25d..18ce8d8c5efbd 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetScriptLanguageResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetScriptLanguageResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java index 02bee957e6216..3891403cdaac5 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java index f126a8474a456..b45900cc2bcd5 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetScriptContextAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetScriptContextAction.java index 88184d59932ea..fd6f33df768ba 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetScriptContextAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetScriptContextAction.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.common.inject.Inject; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetScriptLanguageAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetScriptLanguageAction.java index 0ecd6e8cf35d7..2de8348449a4d 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetScriptLanguageAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetScriptLanguageAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.common.inject.Inject; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetStoredScriptAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetStoredScriptAction.java index 7b8a2805bf1a6..e40dd27665f5f 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetStoredScriptAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportGetStoredScriptAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java index ac518291bd930..39d6253ebd00d 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/tasks/PendingClusterTasksResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/tasks/PendingClusterTasksResponse.java index f0d75ce77cd8a..0d6c2635bb7eb 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/tasks/PendingClusterTasksResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/tasks/PendingClusterTasksResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.tasks; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.service.PendingClusterTask; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java index 0bd761ca811f3..1bee630a9cd75 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/alias/TransportIndicesAliasesAction.java b/server/src/main/java/org/opensearch/action/admin/indices/alias/TransportIndicesAliasesAction.java index bc8cafce98ff3..3fa8d98d1a0fa 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/alias/TransportIndicesAliasesAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/alias/TransportIndicesAliasesAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.RequestValidators; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/alias/get/BaseAliasesRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/alias/get/BaseAliasesRequestBuilder.java index a21b8e97a6d6e..0e9c8382f8a90 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/alias/get/BaseAliasesRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/alias/get/BaseAliasesRequestBuilder.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.alias.get; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.IndicesOptions; import org.opensearch.action.support.clustermanager.ClusterManagerNodeReadOperationRequestBuilder; import org.opensearch.client.OpenSearchClient; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/alias/get/GetAliasesResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/alias/get/GetAliasesResponse.java index 7408500f4f2a0..475fad01c4046 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/alias/get/GetAliasesResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/alias/get/GetAliasesResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.alias.get; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.AliasMetadata; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/alias/get/TransportGetAliasesAction.java b/server/src/main/java/org/opensearch/action/admin/indices/alias/get/TransportGetAliasesAction.java index 92301e962a55f..f2ce20db68823 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/alias/get/TransportGetAliasesAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/alias/get/TransportGetAliasesAction.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.indices.alias.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/analyze/AnalyzeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/analyze/AnalyzeAction.java index b4499f9cd71f8..e28433de87b45 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/analyze/AnalyzeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/analyze/AnalyzeAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.analyze; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.support.single.shard.SingleShardRequest; import org.opensearch.core.common.Strings; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/close/TransportCloseIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/close/TransportCloseIndexAction.java index b4c9ad30e4e84..405fdaaf4cfd6 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/close/TransportCloseIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/close/TransportCloseIndexAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.DestructiveOperations; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java b/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java index b1f3fb913b250..2324742b85f1c 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.replication.ReplicationOperation; @@ -52,7 +52,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.core.index.shard.ShardId; import org.opensearch.indices.IndicesService; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/AutoCreateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/create/AutoCreateAction.java index 22e0c8aedf4f5..8efd65d07c01e 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/AutoCreateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/AutoCreateAction.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.indices.create; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.ActiveShardCount; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/TransportCreateIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/create/TransportCreateIndexAction.java index c8a51da38662f..f3ab92a4041ae 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/TransportCreateIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/TransportCreateIndexAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.create; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java index d5801223855d2..46eb2a497d3fa 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/dangling/delete/TransportDeleteDanglingIndexAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.admin.indices.dangling.DanglingIndexInfo; import org.opensearch.action.admin.indices.dangling.list.ListDanglingIndicesAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java index 2010515249371..1d0341ab58c49 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/dangling/import_index/TransportImportDanglingIndexAction.java @@ -42,7 +42,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.admin.indices.dangling.find.FindDanglingIndexAction; import org.opensearch.action.admin.indices.dangling.find.FindDanglingIndexRequest; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/datastream/CreateDataStreamAction.java b/server/src/main/java/org/opensearch/action/admin/indices/datastream/CreateDataStreamAction.java index 2a53eb38d672c..eb049b1dff791 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/datastream/CreateDataStreamAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/datastream/CreateDataStreamAction.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.indices.datastream; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionType; import org.opensearch.action.IndicesRequest; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamAction.java b/server/src/main/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamAction.java index 5f5be3c166dbc..5cfae4a571388 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamAction.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionType; import org.opensearch.action.IndicesRequest; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/datastream/GetDataStreamAction.java b/server/src/main/java/org/opensearch/action/admin/indices/datastream/GetDataStreamAction.java index 543783b3de367..272629eb7f313 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/datastream/GetDataStreamAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/datastream/GetDataStreamAction.java @@ -33,9 +33,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/delete/TransportDeleteIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/delete/TransportDeleteIndexAction.java index a91ca1a7b714c..d38d1e907ce03 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/delete/TransportDeleteIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/delete/TransportDeleteIndexAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.DestructiveOperations; import org.opensearch.action.support.master.AcknowledgedResponse; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/IndicesExistsResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/IndicesExistsResponse.java index db1a8620be5aa..4ac85492229f0 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/IndicesExistsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/IndicesExistsResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.exists.indices; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/TransportIndicesExistsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/TransportIndicesExistsAction.java index 1469b48d04fc7..61a4cf00cace9 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/TransportIndicesExistsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/exists/indices/TransportIndicesExistsAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.exists.indices; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.IndicesOptions; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportShardFlushAction.java b/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportShardFlushAction.java index c96a55a32aee7..d92e7572e1d11 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportShardFlushAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/flush/TransportShardFlushAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.flush; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.replication.ReplicationResponse; import org.opensearch.action.support.replication.TransportReplicationAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java index edfc7b1bf4fc9..74376cbf3b227 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.get; import org.opensearch.Version; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.AliasMetadata; import org.opensearch.cluster.metadata.MappingMetadata; import org.opensearch.core.common.Strings; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/get/TransportGetIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/get/TransportGetIndexAction.java index 66d810b091c4c..746c84c984bba 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/get/TransportGetIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/get/TransportGetIndexAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.info.TransportClusterInfoAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java index 2c6e1814f57d3..16a7bc7842476 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.mapping.get; import org.opensearch.Version; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetMappingsResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetMappingsResponse.java index e5ac85b713ed9..2fff9f1938210 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetMappingsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/GetMappingsResponse.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.mapping.get; import org.opensearch.Version; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.MappingMetadata; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java index 93f76f42b2f05..687bb99e7ecc7 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.mapping.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java index 61b6f67ebdabb..5567e71a559de 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.info.TransportClusterInfoAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportAutoPutMappingAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportAutoPutMappingAction.java index 0b66689b869f1..f6f282a8cac5c 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportAutoPutMappingAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportAutoPutMappingAction.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.indices.mapping.put; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java index 6c3482da3cac0..12edd62d9c68e 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.RequestValidators; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/open/TransportOpenIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/open/TransportOpenIndexAction.java index 018c527f3d759..a11aab13cb02a 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/open/TransportOpenIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/open/TransportOpenIndexAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.DestructiveOperations; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportAddIndexBlockAction.java b/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportAddIndexBlockAction.java index ca1ca2c5f33b9..614b849de2cd7 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportAddIndexBlockAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportAddIndexBlockAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.DestructiveOperations; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockAction.java b/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockAction.java index 3dc459a380bfd..15b44d4132216 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockAction.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.replication.ReplicationOperation; @@ -52,7 +52,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.core.index.shard.ShardId; import org.opensearch.indices.IndicesService; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshAction.java b/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshAction.java index 1541753581c95..13403cdd07fbb 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/refresh/TransportShardRefreshAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.refresh; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.replication.BasicReplicationRequest; import org.opensearch.action.support.replication.ReplicationResponse; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/resolve/ResolveIndexAction.java b/server/src/main/java/org/opensearch/action/admin/indices/resolve/ResolveIndexAction.java index eb85268961571..fe44d46286d38 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/resolve/ResolveIndexAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/resolve/ResolveIndexAction.java @@ -32,10 +32,10 @@ package org.opensearch.action.admin.indices.resolve; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.IndicesRequest; import org.opensearch.action.OriginalIndices; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/TransportRolloverAction.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/TransportRolloverAction.java index ca2921ceb70c8..9bbafdb618c25 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/TransportRolloverAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/TransportRolloverAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.rollover; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.stats.IndicesStatsAction; import org.opensearch.action.admin.indices.stats.IndicesStatsRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportPitSegmentsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportPitSegmentsAction.java index 276551372339f..4220f6653a070 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportPitSegmentsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/segments/TransportPitSegmentsAction.java @@ -7,7 +7,7 @@ */ package org.opensearch.action.admin.indices.segments; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.ListPitInfo; import org.opensearch.action.search.PitService; import org.opensearch.action.search.SearchContextId; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsResponse.java index a1178fbe21f3c..61c9b68629194 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsResponse.java @@ -32,16 +32,16 @@ package org.opensearch.action.admin.indices.settings.get; -import org.opensearch.action.ActionResponse; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.settings.Settings; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.XContentParserUtils; -import org.opensearch.common.xcontent.json.JsonXContent; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java index d3bf275823278..3a74443f2dcfe 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.settings.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java index 465c1dd573567..d3fdc2efa6737 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java index fed9ee01b385d..ece7633f7a094 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.shards; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.action.support.DefaultShardOperationFailedException; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java index c1e6a64efbf2f..d30329d213824 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.util.CollectionUtil; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java index 328768bc9ae0e..abf6980f5dac1 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.shrink; import org.apache.lucene.index.IndexWriter; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.stats.IndexShardStats; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComponentTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComponentTemplateAction.java index 326f1c8ec059c..d07d263339003 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComponentTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComponentTemplateAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComposableIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComposableIndexTemplateAction.java index 3f071c4074074..6e92e61dbd99f 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComposableIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteComposableIndexTemplateAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java index 8503d7fea6e51..7a8b3432b7e91 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetComponentTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetComponentTemplateAction.java index ff038bd89a597..e04881a5c4773 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetComponentTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetComponentTemplateAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.template.get; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.support.clustermanager.ClusterManagerNodeReadRequest; import org.opensearch.cluster.metadata.ComponentTemplate; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetComposableIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetComposableIndexTemplateAction.java index 2902bd5b81eba..7b3ab00514476 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetComposableIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetComposableIndexTemplateAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.template.get; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.support.clustermanager.ClusterManagerNodeReadRequest; import org.opensearch.cluster.metadata.ComposableIndexTemplate; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetIndexTemplatesResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetIndexTemplatesResponse.java index d3be5de84d758..7fc3b0b3f8329 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetIndexTemplatesResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/get/GetIndexTemplatesResponse.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.indices.template.get; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.IndexTemplateMetadata; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComponentTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComponentTemplateAction.java index 1ad2dc1636d40..a9cc2018144a9 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComponentTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComponentTemplateAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.template.get; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComposableIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComposableIndexTemplateAction.java index 0bf5d64905a98..d585e93bda5c8 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComposableIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetComposableIndexTemplateAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.template.get; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java index c99e7aac09b98..6f914de2570de 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.indices.template.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/post/SimulateIndexTemplateResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/template/post/SimulateIndexTemplateResponse.java index 76c5a4cbd669c..90b02cc93fcd4 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/post/SimulateIndexTemplateResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/post/SimulateIndexTemplateResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.template.post; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.metadata.Template; import org.opensearch.common.Nullable; import org.opensearch.core.ParseField; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java index 70af69bc77760..42f3a097bf2c9 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.template.post; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java index d50a8b199230a..21d687c2e7f9a 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/post/TransportSimulateTemplateAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.template.post; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComponentTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComponentTemplateAction.java index e67062123ae16..1e8b2b3a597bf 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComponentTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComponentTemplateAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.template.put; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComposableIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComposableIndexTemplateAction.java index 2cc8dfbefed82..314601b8bdd08 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComposableIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutComposableIndexTemplateAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.template.put; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java index 826aa888dbacf..1c7d994ab2a81 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java index 5b6bd7414b154..01a4c0418f2ac 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.upgrade.post; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.PrimaryMissingActionException; import org.opensearch.action.support.ActionFilters; import org.opensearch.core.action.support.DefaultShardOperationFailedException; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java index a73110c781ba7..d16b01822cf5f 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryAction.java b/server/src/main/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryAction.java index 7919b16aa3af3..dc51734785894 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryAction.java @@ -34,7 +34,7 @@ import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.core.action.support.DefaultShardOperationFailedException; import org.opensearch.action.support.broadcast.BroadcastShardOperationFailedException; diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkProcessor.java b/server/src/main/java/org/opensearch/action/bulk/BulkProcessor.java index e99d09de89b74..d69bedfe4289c 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkProcessor.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkProcessor.java @@ -32,7 +32,7 @@ package org.opensearch.action.bulk; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.delete.DeleteRequest; import org.opensearch.action.index.IndexRequest; diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkRequestHandler.java b/server/src/main/java/org/opensearch/action/bulk/BulkRequestHandler.java index 541d29102ecd2..ff40a12cb9087 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkRequestHandler.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkRequestHandler.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.threadpool.Scheduler; import java.util.concurrent.CountDownLatch; diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkResponse.java b/server/src/main/java/org/opensearch/action/bulk/BulkResponse.java index f013749e380f0..168d7e31f34af 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkResponse.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.bulk; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/main/java/org/opensearch/action/bulk/MappingUpdatePerformer.java b/server/src/main/java/org/opensearch/action/bulk/MappingUpdatePerformer.java index 0f2e4f1b00763..1e66eac88714e 100644 --- a/server/src/main/java/org/opensearch/action/bulk/MappingUpdatePerformer.java +++ b/server/src/main/java/org/opensearch/action/bulk/MappingUpdatePerformer.java @@ -32,7 +32,7 @@ package org.opensearch.action.bulk; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.index.mapper.Mapping; import org.opensearch.core.index.shard.ShardId; diff --git a/server/src/main/java/org/opensearch/action/bulk/Retry.java b/server/src/main/java/org/opensearch/action/bulk/Retry.java index 754ee9ba4dddc..c9720313e128d 100644 --- a/server/src/main/java/org/opensearch/action/bulk/Retry.java +++ b/server/src/main/java/org/opensearch/action/bulk/Retry.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.common.unit.TimeValue; import org.opensearch.core.rest.RestStatus; diff --git a/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java b/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java index f6ca9022a5bff..da8b4814165e2 100644 --- a/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java @@ -40,7 +40,7 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.ResourceAlreadyExistsException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.DocWriteResponse; diff --git a/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java b/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java index 140c1320daa91..aee8819606e93 100644 --- a/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java +++ b/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.logging.log4j.util.MessageSupplier; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.ActionRunnable; import org.opensearch.action.DocWriteRequest; @@ -99,7 +99,7 @@ import org.opensearch.indices.SystemIndices; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.threadpool.ThreadPool.Names; import org.opensearch.transport.TransportChannel; diff --git a/server/src/main/java/org/opensearch/action/bulk/TransportSingleItemBulkWriteAction.java b/server/src/main/java/org/opensearch/action/bulk/TransportSingleItemBulkWriteAction.java index 707cf62d87beb..62008de614b33 100644 --- a/server/src/main/java/org/opensearch/action/bulk/TransportSingleItemBulkWriteAction.java +++ b/server/src/main/java/org/opensearch/action/bulk/TransportSingleItemBulkWriteAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.bulk; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/explain/ExplainResponse.java b/server/src/main/java/org/opensearch/action/explain/ExplainResponse.java index 6d0fbfd15bee6..ffdc2276ac8bf 100644 --- a/server/src/main/java/org/opensearch/action/explain/ExplainResponse.java +++ b/server/src/main/java/org/opensearch/action/explain/ExplainResponse.java @@ -34,7 +34,7 @@ import org.apache.lucene.search.Explanation; import org.opensearch.Version; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java b/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java index 4fd3ab8dcf389..ee53f19cb6ce8 100644 --- a/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java +++ b/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java @@ -35,7 +35,7 @@ import org.apache.lucene.index.Term; import org.apache.lucene.search.Explanation; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.RoutingMissingException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.single.shard.TransportSingleShardAction; diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java index f3ca0c4b192ed..8e39984afdc33 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java index 641cb4ae20e3e..357bfc09a7bd4 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java @@ -32,10 +32,10 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.action.ActionResponse; +import org.opensearch.common.collect.Tuple; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.Strings; -import org.opensearch.common.collect.Tuple; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ConstructingObjectParser; diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesAction.java b/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesAction.java index 84f13b7d22c92..63a1efdc91962 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesAction.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesIndexAction.java b/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesIndexAction.java index acabc12af0e56..f9f20d74b8f37 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesIndexAction.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/TransportFieldCapabilitiesIndexAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.ActionType; import org.opensearch.action.NoShardAvailableActionException; diff --git a/server/src/main/java/org/opensearch/action/get/GetResponse.java b/server/src/main/java/org/opensearch/action/get/GetResponse.java index c3ae5d9cf2007..99e398fbdda60 100644 --- a/server/src/main/java/org/opensearch/action/get/GetResponse.java +++ b/server/src/main/java/org/opensearch/action/get/GetResponse.java @@ -33,7 +33,7 @@ package org.opensearch.action.get; import org.opensearch.OpenSearchParseException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.ParsingException; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; diff --git a/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java b/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java index 5549d44c1e7ac..4700e54e7367b 100644 --- a/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java @@ -42,12 +42,12 @@ import org.opensearch.action.ValidateActions; import org.opensearch.action.support.IndicesOptions; import org.opensearch.common.Nullable; +import org.opensearch.common.lucene.uid.Versions; import org.opensearch.core.common.ParsingException; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.lucene.uid.Versions; import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; diff --git a/server/src/main/java/org/opensearch/action/get/MultiGetResponse.java b/server/src/main/java/org/opensearch/action/get/MultiGetResponse.java index 563345caaf1f8..09cea492aa921 100644 --- a/server/src/main/java/org/opensearch/action/get/MultiGetResponse.java +++ b/server/src/main/java/org/opensearch/action/get/MultiGetResponse.java @@ -34,7 +34,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; diff --git a/server/src/main/java/org/opensearch/action/get/MultiGetShardResponse.java b/server/src/main/java/org/opensearch/action/get/MultiGetShardResponse.java index 2425282c727a6..ca020e74c7d93 100644 --- a/server/src/main/java/org/opensearch/action/get/MultiGetShardResponse.java +++ b/server/src/main/java/org/opensearch/action/get/MultiGetShardResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.get; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/get/TransportGetAction.java b/server/src/main/java/org/opensearch/action/get/TransportGetAction.java index 07546034665b3..965a1c7af5c6b 100644 --- a/server/src/main/java/org/opensearch/action/get/TransportGetAction.java +++ b/server/src/main/java/org/opensearch/action/get/TransportGetAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.RoutingMissingException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.single.shard.TransportSingleShardAction; diff --git a/server/src/main/java/org/opensearch/action/get/TransportMultiGetAction.java b/server/src/main/java/org/opensearch/action/get/TransportMultiGetAction.java index 6fe73fddc27a6..9a40605ffc438 100644 --- a/server/src/main/java/org/opensearch/action/get/TransportMultiGetAction.java +++ b/server/src/main/java/org/opensearch/action/get/TransportMultiGetAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.RoutingMissingException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; diff --git a/server/src/main/java/org/opensearch/action/get/TransportShardMultiGetAction.java b/server/src/main/java/org/opensearch/action/get/TransportShardMultiGetAction.java index b0596ac2fb448..7e7d5f37522df 100644 --- a/server/src/main/java/org/opensearch/action/get/TransportShardMultiGetAction.java +++ b/server/src/main/java/org/opensearch/action/get/TransportShardMultiGetAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.get; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.TransportActions; import org.opensearch.action.support.single.shard.TransportSingleShardAction; diff --git a/server/src/main/java/org/opensearch/action/ingest/DeletePipelineTransportAction.java b/server/src/main/java/org/opensearch/action/ingest/DeletePipelineTransportAction.java index 86c4c09303c15..48df0f8ef1eda 100644 --- a/server/src/main/java/org/opensearch/action/ingest/DeletePipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/ingest/DeletePipelineTransportAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.ingest; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; diff --git a/server/src/main/java/org/opensearch/action/ingest/GetPipelineResponse.java b/server/src/main/java/org/opensearch/action/ingest/GetPipelineResponse.java index cd87bbf02f75a..eb74548cbc1da 100644 --- a/server/src/main/java/org/opensearch/action/ingest/GetPipelineResponse.java +++ b/server/src/main/java/org/opensearch/action/ingest/GetPipelineResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.ingest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/ingest/GetPipelineTransportAction.java b/server/src/main/java/org/opensearch/action/ingest/GetPipelineTransportAction.java index 1283a68a3ea5f..0bdad03f114e8 100644 --- a/server/src/main/java/org/opensearch/action/ingest/GetPipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/ingest/GetPipelineTransportAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.ingest; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/ingest/IngestActionForwarder.java b/server/src/main/java/org/opensearch/action/ingest/IngestActionForwarder.java index 830cb8d6fac42..19c13adfe64d1 100644 --- a/server/src/main/java/org/opensearch/action/ingest/IngestActionForwarder.java +++ b/server/src/main/java/org/opensearch/action/ingest/IngestActionForwarder.java @@ -33,7 +33,7 @@ package org.opensearch.action.ingest; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.ActionRequest; import org.opensearch.cluster.ClusterChangedEvent; diff --git a/server/src/main/java/org/opensearch/action/ingest/PutPipelineTransportAction.java b/server/src/main/java/org/opensearch/action/ingest/PutPipelineTransportAction.java index f87d832078661..9966a3423f13a 100644 --- a/server/src/main/java/org/opensearch/action/ingest/PutPipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/ingest/PutPipelineTransportAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.ingest; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.info.NodeInfo; import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/ingest/SimulateExecutionService.java b/server/src/main/java/org/opensearch/action/ingest/SimulateExecutionService.java index 82db29c950161..a97514445bd8c 100644 --- a/server/src/main/java/org/opensearch/action/ingest/SimulateExecutionService.java +++ b/server/src/main/java/org/opensearch/action/ingest/SimulateExecutionService.java @@ -32,7 +32,7 @@ package org.opensearch.action.ingest; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.ingest.CompoundProcessor; import org.opensearch.ingest.IngestDocument; diff --git a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineResponse.java b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineResponse.java index 9e67f791dc141..f1b6763b11794 100644 --- a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineResponse.java +++ b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineResponse.java @@ -33,7 +33,7 @@ package org.opensearch.action.ingest; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineTransportAction.java b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineTransportAction.java index c1dc1be97455e..b4d0c9035cc29 100644 --- a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineTransportAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.ingest; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.common.inject.Inject; diff --git a/server/src/main/java/org/opensearch/action/main/MainResponse.java b/server/src/main/java/org/opensearch/action/main/MainResponse.java index 30994c5cfcbd2..15ef6b6d7ca58 100644 --- a/server/src/main/java/org/opensearch/action/main/MainResponse.java +++ b/server/src/main/java/org/opensearch/action/main/MainResponse.java @@ -34,7 +34,7 @@ import org.opensearch.Build; import org.opensearch.Version; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.ClusterName; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/main/TransportMainAction.java b/server/src/main/java/org/opensearch/action/main/TransportMainAction.java index 2916c3dd88d49..77d21f01f1f36 100644 --- a/server/src/main/java/org/opensearch/action/main/TransportMainAction.java +++ b/server/src/main/java/org/opensearch/action/main/TransportMainAction.java @@ -34,7 +34,7 @@ import org.opensearch.Build; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/resync/TransportResyncReplicationAction.java b/server/src/main/java/org/opensearch/action/resync/TransportResyncReplicationAction.java index 879250218405c..9bbb4fa69c545 100644 --- a/server/src/main/java/org/opensearch/action/resync/TransportResyncReplicationAction.java +++ b/server/src/main/java/org/opensearch/action/resync/TransportResyncReplicationAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.resync; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.replication.ReplicationOperation; import org.opensearch.action.support.replication.ReplicationResponse; diff --git a/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java b/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java index 152e6f56668f2..b707c3bbe680e 100644 --- a/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java +++ b/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java @@ -37,7 +37,7 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.NoShardAvailableActionException; import org.opensearch.core.action.ShardOperationFailedException; import org.opensearch.action.support.TransportActions; diff --git a/server/src/main/java/org/opensearch/action/search/CanMatchPreFilterSearchPhase.java b/server/src/main/java/org/opensearch/action/search/CanMatchPreFilterSearchPhase.java index c026c72f77f00..ef1e448be0043 100644 --- a/server/src/main/java/org/opensearch/action/search/CanMatchPreFilterSearchPhase.java +++ b/server/src/main/java/org/opensearch/action/search/CanMatchPreFilterSearchPhase.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.Logger; import org.apache.lucene.util.FixedBitSet; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.routing.GroupShardsIterator; import org.opensearch.common.lease.Releasable; diff --git a/server/src/main/java/org/opensearch/action/search/ClearScrollController.java b/server/src/main/java/org/opensearch/action/search/ClearScrollController.java index c258b111fa1c6..dfb24e03d0655 100644 --- a/server/src/main/java/org/opensearch/action/search/ClearScrollController.java +++ b/server/src/main/java/org/opensearch/action/search/ClearScrollController.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.support.GroupedActionListener; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/main/java/org/opensearch/action/search/ClearScrollResponse.java b/server/src/main/java/org/opensearch/action/search/ClearScrollResponse.java index b6cd5d5bb7c0e..be87963f2146e 100644 --- a/server/src/main/java/org/opensearch/action/search/ClearScrollResponse.java +++ b/server/src/main/java/org/opensearch/action/search/ClearScrollResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/search/CreatePitController.java b/server/src/main/java/org/opensearch/action/search/CreatePitController.java index 8d2ea3a03266c..b6469de4c3a7c 100644 --- a/server/src/main/java/org/opensearch/action/search/CreatePitController.java +++ b/server/src/main/java/org/opensearch/action/search/CreatePitController.java @@ -12,7 +12,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.support.GroupedActionListener; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/search/CreatePitRequest.java b/server/src/main/java/org/opensearch/action/search/CreatePitRequest.java index f496a22caff6d..12784c4c07004 100644 --- a/server/src/main/java/org/opensearch/action/search/CreatePitRequest.java +++ b/server/src/main/java/org/opensearch/action/search/CreatePitRequest.java @@ -20,7 +20,7 @@ import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.Map; diff --git a/server/src/main/java/org/opensearch/action/search/CreatePitResponse.java b/server/src/main/java/org/opensearch/action/search/CreatePitResponse.java index 2fb10cfeb727c..080e97c635d13 100644 --- a/server/src/main/java/org/opensearch/action/search/CreatePitResponse.java +++ b/server/src/main/java/org/opensearch/action/search/CreatePitResponse.java @@ -8,7 +8,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/search/DeletePitResponse.java b/server/src/main/java/org/opensearch/action/search/DeletePitResponse.java index 0aabd838171ba..fac49f1170399 100644 --- a/server/src/main/java/org/opensearch/action/search/DeletePitResponse.java +++ b/server/src/main/java/org/opensearch/action/search/DeletePitResponse.java @@ -8,7 +8,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/search/DeleteSearchPipelineTransportAction.java b/server/src/main/java/org/opensearch/action/search/DeleteSearchPipelineTransportAction.java index 918583b3d510b..0955f24bc787d 100644 --- a/server/src/main/java/org/opensearch/action/search/DeleteSearchPipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/search/DeleteSearchPipelineTransportAction.java @@ -8,7 +8,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.action.support.master.AcknowledgedResponse; diff --git a/server/src/main/java/org/opensearch/action/search/ExpandSearchPhase.java b/server/src/main/java/org/opensearch/action/search/ExpandSearchPhase.java index 618a5620ce093..6a26b07ae5be2 100644 --- a/server/src/main/java/org/opensearch/action/search/ExpandSearchPhase.java +++ b/server/src/main/java/org/opensearch/action/search/ExpandSearchPhase.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.util.concurrent.AtomicArray; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.index.query.InnerHitBuilder; diff --git a/server/src/main/java/org/opensearch/action/search/GetSearchPipelineResponse.java b/server/src/main/java/org/opensearch/action/search/GetSearchPipelineResponse.java index d25a084058fa0..0a17547bd4727 100644 --- a/server/src/main/java/org/opensearch/action/search/GetSearchPipelineResponse.java +++ b/server/src/main/java/org/opensearch/action/search/GetSearchPipelineResponse.java @@ -8,7 +8,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/search/GetSearchPipelineTransportAction.java b/server/src/main/java/org/opensearch/action/search/GetSearchPipelineTransportAction.java index 3b8c872e7a2f5..060e0087571f4 100644 --- a/server/src/main/java/org/opensearch/action/search/GetSearchPipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/search/GetSearchPipelineTransportAction.java @@ -8,7 +8,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/search/MultiSearchRequest.java b/server/src/main/java/org/opensearch/action/search/MultiSearchRequest.java index fa8b5b9470723..b6b1267e37f75 100644 --- a/server/src/main/java/org/opensearch/action/search/MultiSearchRequest.java +++ b/server/src/main/java/org/opensearch/action/search/MultiSearchRequest.java @@ -50,7 +50,7 @@ import org.opensearch.core.xcontent.XContentParser; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/action/search/MultiSearchResponse.java b/server/src/main/java/org/opensearch/action/search/MultiSearchResponse.java index b40d9946743ec..2b6121f2bda99 100644 --- a/server/src/main/java/org/opensearch/action/search/MultiSearchResponse.java +++ b/server/src/main/java/org/opensearch/action/search/MultiSearchResponse.java @@ -34,7 +34,7 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.common.Nullable; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/search/PitService.java b/server/src/main/java/org/opensearch/action/search/PitService.java index 336c0f2c49793..c29e03ade6130 100644 --- a/server/src/main/java/org/opensearch/action/search/PitService.java +++ b/server/src/main/java/org/opensearch/action/search/PitService.java @@ -11,7 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.support.GroupedActionListener; import org.opensearch.client.node.NodeClient; diff --git a/server/src/main/java/org/opensearch/action/search/PutSearchPipelineTransportAction.java b/server/src/main/java/org/opensearch/action/search/PutSearchPipelineTransportAction.java index da4a405c84555..2ce9990d25306 100644 --- a/server/src/main/java/org/opensearch/action/search/PutSearchPipelineTransportAction.java +++ b/server/src/main/java/org/opensearch/action/search/PutSearchPipelineTransportAction.java @@ -8,7 +8,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.info.NodeInfo; import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/search/SearchActionListener.java b/server/src/main/java/org/opensearch/action/search/SearchActionListener.java index 6983eed18b7b3..c032012b0b45d 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchActionListener.java +++ b/server/src/main/java/org/opensearch/action/search/SearchActionListener.java @@ -31,7 +31,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.search.SearchPhaseResult; import org.opensearch.search.SearchShardTarget; diff --git a/server/src/main/java/org/opensearch/action/search/SearchDfsQueryThenFetchAsyncAction.java b/server/src/main/java/org/opensearch/action/search/SearchDfsQueryThenFetchAsyncAction.java index 71a986c0e15f7..631dda8db393f 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchDfsQueryThenFetchAsyncAction.java +++ b/server/src/main/java/org/opensearch/action/search/SearchDfsQueryThenFetchAsyncAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.search; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.routing.GroupShardsIterator; import org.opensearch.search.SearchShardTarget; diff --git a/server/src/main/java/org/opensearch/action/search/SearchExecutionStatsCollector.java b/server/src/main/java/org/opensearch/action/search/SearchExecutionStatsCollector.java index 7082e33dfd5c5..842e87b3eb635 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchExecutionStatsCollector.java +++ b/server/src/main/java/org/opensearch/action/search/SearchExecutionStatsCollector.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.node.ResponseCollectorService; import org.opensearch.search.SearchPhaseResult; import org.opensearch.search.fetch.QueryFetchSearchResult; diff --git a/server/src/main/java/org/opensearch/action/search/SearchProgressActionListener.java b/server/src/main/java/org/opensearch/action/search/SearchProgressActionListener.java index 3f24eea0bfe1e..320bebfa6a9f4 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchProgressActionListener.java +++ b/server/src/main/java/org/opensearch/action/search/SearchProgressActionListener.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; /** * An {@link ActionListener} for search requests that allows to track progress of the {@link SearchAction}. diff --git a/server/src/main/java/org/opensearch/action/search/SearchQueryThenFetchAsyncAction.java b/server/src/main/java/org/opensearch/action/search/SearchQueryThenFetchAsyncAction.java index 1ead14aac6b51..549ec0983b395 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchQueryThenFetchAsyncAction.java +++ b/server/src/main/java/org/opensearch/action/search/SearchQueryThenFetchAsyncAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.Logger; import org.apache.lucene.search.TopFieldDocs; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.routing.GroupShardsIterator; import org.opensearch.search.SearchPhaseResult; diff --git a/server/src/main/java/org/opensearch/action/search/SearchRequest.java b/server/src/main/java/org/opensearch/action/search/SearchRequest.java index 43fec9e70ab88..690b1d781ffcf 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchRequest.java +++ b/server/src/main/java/org/opensearch/action/search/SearchRequest.java @@ -47,7 +47,7 @@ import org.opensearch.search.builder.PointInTimeBuilder; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.search.internal.SearchContext; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.Arrays; diff --git a/server/src/main/java/org/opensearch/action/search/SearchResponse.java b/server/src/main/java/org/opensearch/action/search/SearchResponse.java index 13a449f3d3f79..66ec4d49bf686 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchResponse.java +++ b/server/src/main/java/org/opensearch/action/search/SearchResponse.java @@ -33,7 +33,7 @@ package org.opensearch.action.search; import org.apache.lucene.search.TotalHits; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.common.Nullable; import org.opensearch.core.common.Strings; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/search/SearchScrollAsyncAction.java b/server/src/main/java/org/opensearch/action/search/SearchScrollAsyncAction.java index 899c7a3c1dabd..5c11d98dd04e3 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchScrollAsyncAction.java +++ b/server/src/main/java/org/opensearch/action/search/SearchScrollAsyncAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.common.Nullable; diff --git a/server/src/main/java/org/opensearch/action/search/SearchScrollQueryAndFetchAsyncAction.java b/server/src/main/java/org/opensearch/action/search/SearchScrollQueryAndFetchAsyncAction.java index c1b4f56f7adc3..08c5124f6b0a3 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchScrollQueryAndFetchAsyncAction.java +++ b/server/src/main/java/org/opensearch/action/search/SearchScrollQueryAndFetchAsyncAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.search; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.util.concurrent.AtomicArray; diff --git a/server/src/main/java/org/opensearch/action/search/SearchScrollQueryThenFetchAsyncAction.java b/server/src/main/java/org/opensearch/action/search/SearchScrollQueryThenFetchAsyncAction.java index 1fa6460a212f7..58ab87f7bd025 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchScrollQueryThenFetchAsyncAction.java +++ b/server/src/main/java/org/opensearch/action/search/SearchScrollQueryThenFetchAsyncAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.Logger; import org.apache.lucene.search.ScoreDoc; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.util.concurrent.AtomicArray; diff --git a/server/src/main/java/org/opensearch/action/search/SearchScrollRequest.java b/server/src/main/java/org/opensearch/action/search/SearchScrollRequest.java index ddefb165f00b6..8459828cb0d15 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchScrollRequest.java +++ b/server/src/main/java/org/opensearch/action/search/SearchScrollRequest.java @@ -42,7 +42,7 @@ import org.opensearch.core.xcontent.XContentParser; import org.opensearch.search.Scroll; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.Map; diff --git a/server/src/main/java/org/opensearch/action/search/SearchShardTask.java b/server/src/main/java/org/opensearch/action/search/SearchShardTask.java index c94f02395cf38..37ca89fa5dd23 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchShardTask.java +++ b/server/src/main/java/org/opensearch/action/search/SearchShardTask.java @@ -37,7 +37,7 @@ import org.opensearch.search.internal.ShardSearchRequest; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.SearchBackpressureTask; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.util.Map; import java.util.function.Supplier; diff --git a/server/src/main/java/org/opensearch/action/search/SearchTask.java b/server/src/main/java/org/opensearch/action/search/SearchTask.java index dad6c44da4f10..9f0c69c0fffc3 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchTask.java +++ b/server/src/main/java/org/opensearch/action/search/SearchTask.java @@ -35,7 +35,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.SearchBackpressureTask; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.util.Map; import java.util.function.Supplier; diff --git a/server/src/main/java/org/opensearch/action/search/SearchTransportService.java b/server/src/main/java/org/opensearch/action/search/SearchTransportService.java index 37ffca6cac5f2..3067cf963cc48 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchTransportService.java +++ b/server/src/main/java/org/opensearch/action/search/SearchTransportService.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.IndicesRequest; import org.opensearch.action.OriginalIndices; diff --git a/server/src/main/java/org/opensearch/action/search/SearchUtils.java b/server/src/main/java/org/opensearch/action/search/SearchUtils.java index 96fcda0d491c9..4ecf1eef9d5d2 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchUtils.java +++ b/server/src/main/java/org/opensearch/action/search/SearchUtils.java @@ -8,7 +8,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/main/java/org/opensearch/action/search/TransportClearScrollAction.java b/server/src/main/java/org/opensearch/action/search/TransportClearScrollAction.java index a44b80f13975c..9be449c5f919f 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportClearScrollAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportClearScrollAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/main/java/org/opensearch/action/search/TransportCreatePitAction.java b/server/src/main/java/org/opensearch/action/search/TransportCreatePitAction.java index c664eb9629216..01646c8bf7762 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportCreatePitAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportCreatePitAction.java @@ -9,7 +9,7 @@ package org.opensearch.action.search; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; diff --git a/server/src/main/java/org/opensearch/action/search/TransportDeletePitAction.java b/server/src/main/java/org/opensearch/action/search/TransportDeletePitAction.java index 6ad11aa4c6d59..28ab76f74eebc 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportDeletePitAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportDeletePitAction.java @@ -8,7 +8,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.common.inject.Inject; diff --git a/server/src/main/java/org/opensearch/action/search/TransportMultiSearchAction.java b/server/src/main/java/org/opensearch/action/search/TransportMultiSearchAction.java index a3ee6e0a37e23..ce29920fff08a 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportMultiSearchAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportMultiSearchAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.client.node.NodeClient; diff --git a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java index 1011f17c98dd6..f132f54877adb 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsGroup; @@ -86,7 +86,7 @@ import org.opensearch.search.profile.SearchProfileShardResults; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.RemoteClusterAware; import org.opensearch.transport.RemoteClusterService; diff --git a/server/src/main/java/org/opensearch/action/search/TransportSearchScrollAction.java b/server/src/main/java/org/opensearch/action/search/TransportSearchScrollAction.java index ea29449582e7c..beb506a290d4d 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportSearchScrollAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportSearchScrollAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/main/java/org/opensearch/action/support/ActionFilter.java b/server/src/main/java/org/opensearch/action/support/ActionFilter.java index 2fe32b120d4a9..b4e4d10f217aa 100644 --- a/server/src/main/java/org/opensearch/action/support/ActionFilter.java +++ b/server/src/main/java/org/opensearch/action/support/ActionFilter.java @@ -32,9 +32,9 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.tasks.Task; /** diff --git a/server/src/main/java/org/opensearch/action/support/ActionFilterChain.java b/server/src/main/java/org/opensearch/action/support/ActionFilterChain.java index 1eb5682343ffa..741ab9dff59fd 100644 --- a/server/src/main/java/org/opensearch/action/support/ActionFilterChain.java +++ b/server/src/main/java/org/opensearch/action/support/ActionFilterChain.java @@ -32,9 +32,9 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.tasks.Task; /** diff --git a/server/src/main/java/org/opensearch/action/support/ActiveShardsObserver.java b/server/src/main/java/org/opensearch/action/support/ActiveShardsObserver.java index 7a4ae0e31cf55..07aca93313026 100644 --- a/server/src/main/java/org/opensearch/action/support/ActiveShardsObserver.java +++ b/server/src/main/java/org/opensearch/action/support/ActiveShardsObserver.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateObserver; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/main/java/org/opensearch/action/support/AdapterActionFuture.java b/server/src/main/java/org/opensearch/action/support/AdapterActionFuture.java index 93430a049d3a9..a39593ede4e4a 100644 --- a/server/src/main/java/org/opensearch/action/support/AdapterActionFuture.java +++ b/server/src/main/java/org/opensearch/action/support/AdapterActionFuture.java @@ -33,8 +33,8 @@ package org.opensearch.action.support; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.BaseFuture; import org.opensearch.common.util.concurrent.FutureUtils; diff --git a/server/src/main/java/org/opensearch/action/support/ChannelActionListener.java b/server/src/main/java/org/opensearch/action/support/ChannelActionListener.java index 07851345241bd..791131f8ce3d0 100644 --- a/server/src/main/java/org/opensearch/action/support/ChannelActionListener.java +++ b/server/src/main/java/org/opensearch/action/support/ChannelActionListener.java @@ -32,7 +32,7 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.transport.TransportChannel; import org.opensearch.transport.TransportRequest; import org.opensearch.core.transport.TransportResponse; diff --git a/server/src/main/java/org/opensearch/action/support/ContextPreservingActionListener.java b/server/src/main/java/org/opensearch/action/support/ContextPreservingActionListener.java index 6eadc0b67ffbd..943e2f8785062 100644 --- a/server/src/main/java/org/opensearch/action/support/ContextPreservingActionListener.java +++ b/server/src/main/java/org/opensearch/action/support/ContextPreservingActionListener.java @@ -31,7 +31,7 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.util.concurrent.ThreadContext; import java.util.function.Supplier; diff --git a/server/src/main/java/org/opensearch/action/support/GroupedActionListener.java b/server/src/main/java/org/opensearch/action/support/GroupedActionListener.java index 3d15d63289d9e..e45fe66b317e4 100644 --- a/server/src/main/java/org/opensearch/action/support/GroupedActionListener.java +++ b/server/src/main/java/org/opensearch/action/support/GroupedActionListener.java @@ -31,7 +31,7 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.util.concurrent.AtomicArray; import org.opensearch.common.util.concurrent.CountDown; diff --git a/server/src/main/java/org/opensearch/action/support/HandledTransportAction.java b/server/src/main/java/org/opensearch/action/support/HandledTransportAction.java index 7e030a34cdd91..786d8cfb6fa1d 100644 --- a/server/src/main/java/org/opensearch/action/support/HandledTransportAction.java +++ b/server/src/main/java/org/opensearch/action/support/HandledTransportAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.support; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/main/java/org/opensearch/action/support/ListenerTimeouts.java b/server/src/main/java/org/opensearch/action/support/ListenerTimeouts.java index b01320369af6a..a54f59f97f89c 100644 --- a/server/src/main/java/org/opensearch/action/support/ListenerTimeouts.java +++ b/server/src/main/java/org/opensearch/action/support/ListenerTimeouts.java @@ -33,7 +33,7 @@ package org.opensearch.action.support; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.unit.TimeValue; import org.opensearch.threadpool.Scheduler; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/main/java/org/opensearch/action/support/PlainListenableActionFuture.java b/server/src/main/java/org/opensearch/action/support/PlainListenableActionFuture.java index ac5f7d25efb18..a6ebaa46c1fcc 100644 --- a/server/src/main/java/org/opensearch/action/support/PlainListenableActionFuture.java +++ b/server/src/main/java/org/opensearch/action/support/PlainListenableActionFuture.java @@ -32,7 +32,7 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ListenableActionFuture; import java.util.ArrayList; diff --git a/server/src/main/java/org/opensearch/action/support/RetryableAction.java b/server/src/main/java/org/opensearch/action/support/RetryableAction.java index cf9c140a54bc8..8d2553710c154 100644 --- a/server/src/main/java/org/opensearch/action/support/RetryableAction.java +++ b/server/src/main/java/org/opensearch/action/support/RetryableAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.bulk.BackoffPolicy; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/main/java/org/opensearch/action/support/ThreadedActionListener.java b/server/src/main/java/org/opensearch/action/support/ThreadedActionListener.java index 17ef64aa901c0..41ba2aed1e16b 100644 --- a/server/src/main/java/org/opensearch/action/support/ThreadedActionListener.java +++ b/server/src/main/java/org/opensearch/action/support/ThreadedActionListener.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.common.util.concurrent.AbstractRunnable; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/main/java/org/opensearch/action/support/TimeoutTaskCancellationUtility.java b/server/src/main/java/org/opensearch/action/support/TimeoutTaskCancellationUtility.java index a98df5b832bf5..4bcfa3160197f 100644 --- a/server/src/main/java/org/opensearch/action/support/TimeoutTaskCancellationUtility.java +++ b/server/src/main/java/org/opensearch/action/support/TimeoutTaskCancellationUtility.java @@ -11,7 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; import org.opensearch.client.OriginSettingClient; import org.opensearch.client.node.NodeClient; @@ -19,7 +19,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.search.SearchService; import org.opensearch.tasks.CancellableTask; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.Scheduler; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/main/java/org/opensearch/action/support/TransportAction.java b/server/src/main/java/org/opensearch/action/support/TransportAction.java index e2f5ecda101b8..32330afd5583f 100644 --- a/server/src/main/java/org/opensearch/action/support/TransportAction.java +++ b/server/src/main/java/org/opensearch/action/support/TransportAction.java @@ -34,16 +34,16 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.lease.Releasable; import org.opensearch.common.lease.Releasables; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskCancelledException; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskListener; import org.opensearch.tasks.TaskManager; diff --git a/server/src/main/java/org/opensearch/action/support/broadcast/BroadcastResponse.java b/server/src/main/java/org/opensearch/action/support/broadcast/BroadcastResponse.java index 96f7efd05b8ba..b8f66e28c8f38 100644 --- a/server/src/main/java/org/opensearch/action/support/broadcast/BroadcastResponse.java +++ b/server/src/main/java/org/opensearch/action/support/broadcast/BroadcastResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.support.broadcast; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.action.support.DefaultShardOperationFailedException; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/support/broadcast/TransportBroadcastAction.java b/server/src/main/java/org/opensearch/action/support/broadcast/TransportBroadcastAction.java index cb77fa7c3ac57..a010a30015577 100644 --- a/server/src/main/java/org/opensearch/action/support/broadcast/TransportBroadcastAction.java +++ b/server/src/main/java/org/opensearch/action/support/broadcast/TransportBroadcastAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.support.broadcast; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.NoShardAvailableActionException; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java b/server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java index 1b7822ee5a440..481d944e1f02b 100644 --- a/server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java +++ b/server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.support.broadcast.node; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.NoShardAvailableActionException; diff --git a/server/src/main/java/org/opensearch/action/support/clustermanager/ClusterManagerNodeOperationRequestBuilder.java b/server/src/main/java/org/opensearch/action/support/clustermanager/ClusterManagerNodeOperationRequestBuilder.java index 4f60a75c5dd22..7cd79ad586f11 100644 --- a/server/src/main/java/org/opensearch/action/support/clustermanager/ClusterManagerNodeOperationRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/support/clustermanager/ClusterManagerNodeOperationRequestBuilder.java @@ -34,7 +34,7 @@ import org.opensearch.action.ActionType; import org.opensearch.action.ActionRequestBuilder; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.client.OpenSearchClient; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/main/java/org/opensearch/action/support/clustermanager/ClusterManagerNodeReadOperationRequestBuilder.java b/server/src/main/java/org/opensearch/action/support/clustermanager/ClusterManagerNodeReadOperationRequestBuilder.java index b0ac743e6a1dc..52b57a946a5b3 100644 --- a/server/src/main/java/org/opensearch/action/support/clustermanager/ClusterManagerNodeReadOperationRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/support/clustermanager/ClusterManagerNodeReadOperationRequestBuilder.java @@ -33,7 +33,7 @@ package org.opensearch.action.support.clustermanager; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.client.OpenSearchClient; /** diff --git a/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java b/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java index 13c576bd120c7..0d441331b18bf 100644 --- a/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java +++ b/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java @@ -35,9 +35,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionRunnable; import org.opensearch.action.bulk.BackoffPolicy; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeReadAction.java b/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeReadAction.java index e957142afd884..34dd513a5a34b 100644 --- a/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeReadAction.java +++ b/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeReadAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.support.clustermanager; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.ActionFilters; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/main/java/org/opensearch/action/support/clustermanager/info/ClusterInfoRequestBuilder.java b/server/src/main/java/org/opensearch/action/support/clustermanager/info/ClusterInfoRequestBuilder.java index 77c1c3656ce59..87427163bf42c 100644 --- a/server/src/main/java/org/opensearch/action/support/clustermanager/info/ClusterInfoRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/support/clustermanager/info/ClusterInfoRequestBuilder.java @@ -32,7 +32,7 @@ package org.opensearch.action.support.clustermanager.info; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.IndicesOptions; import org.opensearch.action.support.clustermanager.ClusterManagerNodeReadOperationRequestBuilder; import org.opensearch.client.OpenSearchClient; diff --git a/server/src/main/java/org/opensearch/action/support/clustermanager/info/TransportClusterInfoAction.java b/server/src/main/java/org/opensearch/action/support/clustermanager/info/TransportClusterInfoAction.java index 7390a87de1f85..f9f87e2e40a51 100644 --- a/server/src/main/java/org/opensearch/action/support/clustermanager/info/TransportClusterInfoAction.java +++ b/server/src/main/java/org/opensearch/action/support/clustermanager/info/TransportClusterInfoAction.java @@ -31,8 +31,8 @@ package org.opensearch.action.support.clustermanager.info; -import org.opensearch.action.ActionListener; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/action/support/master/AcknowledgedResponse.java b/server/src/main/java/org/opensearch/action/support/master/AcknowledgedResponse.java index 71695269396e1..af444a3e84765 100644 --- a/server/src/main/java/org/opensearch/action/support/master/AcknowledgedResponse.java +++ b/server/src/main/java/org/opensearch/action/support/master/AcknowledgedResponse.java @@ -31,7 +31,7 @@ package org.opensearch.action.support.master; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/support/master/MasterNodeOperationRequestBuilder.java b/server/src/main/java/org/opensearch/action/support/master/MasterNodeOperationRequestBuilder.java index f6d475fc06171..2f0e6e54545e9 100644 --- a/server/src/main/java/org/opensearch/action/support/master/MasterNodeOperationRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/support/master/MasterNodeOperationRequestBuilder.java @@ -33,7 +33,7 @@ package org.opensearch.action.support.master; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.clustermanager.ClusterManagerNodeOperationRequestBuilder; import org.opensearch.client.OpenSearchClient; diff --git a/server/src/main/java/org/opensearch/action/support/master/MasterNodeReadOperationRequestBuilder.java b/server/src/main/java/org/opensearch/action/support/master/MasterNodeReadOperationRequestBuilder.java index ae134bdeca3c2..2b39c1be346aa 100644 --- a/server/src/main/java/org/opensearch/action/support/master/MasterNodeReadOperationRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/support/master/MasterNodeReadOperationRequestBuilder.java @@ -33,7 +33,7 @@ package org.opensearch.action.support.master; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.clustermanager.ClusterManagerNodeReadOperationRequestBuilder; import org.opensearch.client.OpenSearchClient; diff --git a/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java b/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java index 53a597214256d..091c442ff220e 100644 --- a/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java +++ b/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.support.master; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; diff --git a/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeReadAction.java b/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeReadAction.java index 8adfba6c8ee02..33b5991e5f7f2 100644 --- a/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeReadAction.java +++ b/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeReadAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.support.master; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeReadAction; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; diff --git a/server/src/main/java/org/opensearch/action/support/master/info/ClusterInfoRequestBuilder.java b/server/src/main/java/org/opensearch/action/support/master/info/ClusterInfoRequestBuilder.java index 7052e13625f97..320164004ed76 100644 --- a/server/src/main/java/org/opensearch/action/support/master/info/ClusterInfoRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/support/master/info/ClusterInfoRequestBuilder.java @@ -32,7 +32,7 @@ package org.opensearch.action.support.master.info; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.client.OpenSearchClient; /** diff --git a/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java b/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java index 8ba6653892f88..a0760e0b494d0 100644 --- a/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java +++ b/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java @@ -31,7 +31,7 @@ package org.opensearch.action.support.master.info; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.ActionFilters; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/main/java/org/opensearch/action/support/nodes/BaseNodesResponse.java b/server/src/main/java/org/opensearch/action/support/nodes/BaseNodesResponse.java index bf68b5201c3f8..371d32ad14281 100644 --- a/server/src/main/java/org/opensearch/action/support/nodes/BaseNodesResponse.java +++ b/server/src/main/java/org/opensearch/action/support/nodes/BaseNodesResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.support.nodes; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.FailedNodeException; import org.opensearch.cluster.ClusterName; import org.opensearch.core.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/support/nodes/TransportNodesAction.java b/server/src/main/java/org/opensearch/action/support/nodes/TransportNodesAction.java index 3f39d7b786ccb..85ccbfba81bf2 100644 --- a/server/src/main/java/org/opensearch/action/support/nodes/TransportNodesAction.java +++ b/server/src/main/java/org/opensearch/action/support/nodes/TransportNodesAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.support.nodes; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/support/replication/FanoutReplicationProxy.java b/server/src/main/java/org/opensearch/action/support/replication/FanoutReplicationProxy.java index 51b95468d6b25..f404f5c6cd417 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/FanoutReplicationProxy.java +++ b/server/src/main/java/org/opensearch/action/support/replication/FanoutReplicationProxy.java @@ -8,7 +8,7 @@ package org.opensearch.action.support.replication; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.replication.ReplicationOperation.ReplicaResponse; import org.opensearch.action.support.replication.ReplicationOperation.Replicas; import org.opensearch.cluster.routing.ShardRouting; diff --git a/server/src/main/java/org/opensearch/action/support/replication/ReplicationModeAwareProxy.java b/server/src/main/java/org/opensearch/action/support/replication/ReplicationModeAwareProxy.java index 26d3b3c2f64ef..4b1eea9951080 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/ReplicationModeAwareProxy.java +++ b/server/src/main/java/org/opensearch/action/support/replication/ReplicationModeAwareProxy.java @@ -8,7 +8,7 @@ package org.opensearch.action.support.replication; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.replication.ReplicationOperation.ReplicaResponse; import org.opensearch.cluster.routing.ShardRouting; diff --git a/server/src/main/java/org/opensearch/action/support/replication/ReplicationOperation.java b/server/src/main/java/org/opensearch/action/support/replication/ReplicationOperation.java index d3a617853b019..1ca01770533a0 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/ReplicationOperation.java +++ b/server/src/main/java/org/opensearch/action/support/replication/ReplicationOperation.java @@ -37,7 +37,7 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.core.Assertions; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.UnavailableShardsException; import org.opensearch.action.support.ActiveShardCount; import org.opensearch.action.support.RetryableAction; diff --git a/server/src/main/java/org/opensearch/action/support/replication/ReplicationProxy.java b/server/src/main/java/org/opensearch/action/support/replication/ReplicationProxy.java index 20f7b5fc6a586..a9b6e2699007a 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/ReplicationProxy.java +++ b/server/src/main/java/org/opensearch/action/support/replication/ReplicationProxy.java @@ -8,7 +8,7 @@ package org.opensearch.action.support.replication; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.replication.ReplicationOperation.ReplicaResponse; import org.opensearch.action.support.replication.ReplicationOperation.Replicas; import org.opensearch.cluster.routing.ShardRouting; diff --git a/server/src/main/java/org/opensearch/action/support/replication/ReplicationRequest.java b/server/src/main/java/org/opensearch/action/support/replication/ReplicationRequest.java index d5a2d37daa504..8bf6aae1fa0f7 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/ReplicationRequest.java +++ b/server/src/main/java/org/opensearch/action/support/replication/ReplicationRequest.java @@ -45,7 +45,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.core.index.shard.ShardId; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.Map; diff --git a/server/src/main/java/org/opensearch/action/support/replication/ReplicationRequestBuilder.java b/server/src/main/java/org/opensearch/action/support/replication/ReplicationRequestBuilder.java index df60e585e7272..27b0afe6d5f0f 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/ReplicationRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/support/replication/ReplicationRequestBuilder.java @@ -34,7 +34,7 @@ import org.opensearch.action.ActionType; import org.opensearch.action.ActionRequestBuilder; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.ActiveShardCount; import org.opensearch.client.OpenSearchClient; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/main/java/org/opensearch/action/support/replication/ReplicationResponse.java b/server/src/main/java/org/opensearch/action/support/replication/ReplicationResponse.java index 1f0e61a134eb2..cff1857e52452 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/ReplicationResponse.java +++ b/server/src/main/java/org/opensearch/action/support/replication/ReplicationResponse.java @@ -34,7 +34,7 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.action.ShardOperationFailedException; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.Nullable; diff --git a/server/src/main/java/org/opensearch/action/support/replication/ReplicationTask.java b/server/src/main/java/org/opensearch/action/support/replication/ReplicationTask.java index 9dd2e1dba1478..674df3a30ea33 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/ReplicationTask.java +++ b/server/src/main/java/org/opensearch/action/support/replication/ReplicationTask.java @@ -38,7 +38,7 @@ import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.Map; diff --git a/server/src/main/java/org/opensearch/action/support/replication/TransportBroadcastReplicationAction.java b/server/src/main/java/org/opensearch/action/support/replication/TransportBroadcastReplicationAction.java index 116b46469df21..f65a794f997c1 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/TransportBroadcastReplicationAction.java +++ b/server/src/main/java/org/opensearch/action/support/replication/TransportBroadcastReplicationAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.support.replication; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.core.action.support.DefaultShardOperationFailedException; import org.opensearch.action.support.HandledTransportAction; diff --git a/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java b/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java index 5b3be4d077f3c..724181363b238 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java +++ b/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java @@ -37,9 +37,9 @@ import org.opensearch.core.Assertions; import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.UnavailableShardsException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.ActiveShardCount; @@ -82,7 +82,7 @@ import org.opensearch.indices.IndicesService; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.ConnectTransportException; import org.opensearch.transport.TransportChannel; diff --git a/server/src/main/java/org/opensearch/action/support/replication/TransportWriteAction.java b/server/src/main/java/org/opensearch/action/support/replication/TransportWriteAction.java index a47d986c74c1e..886c9efe1c5b3 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/TransportWriteAction.java +++ b/server/src/main/java/org/opensearch/action/support/replication/TransportWriteAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.TransportActions; diff --git a/server/src/main/java/org/opensearch/action/support/single/instance/InstanceShardOperationRequestBuilder.java b/server/src/main/java/org/opensearch/action/support/single/instance/InstanceShardOperationRequestBuilder.java index 6fe7b503e4602..99dd93372173c 100644 --- a/server/src/main/java/org/opensearch/action/support/single/instance/InstanceShardOperationRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/support/single/instance/InstanceShardOperationRequestBuilder.java @@ -34,7 +34,7 @@ import org.opensearch.action.ActionType; import org.opensearch.action.ActionRequestBuilder; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.client.OpenSearchClient; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/main/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationAction.java b/server/src/main/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationAction.java index 8014f1b280bf2..c8ca0b047ef7b 100644 --- a/server/src/main/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationAction.java +++ b/server/src/main/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationAction.java @@ -32,8 +32,8 @@ package org.opensearch.action.support.single.instance; -import org.opensearch.action.ActionListener; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.UnavailableShardsException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; diff --git a/server/src/main/java/org/opensearch/action/support/single/shard/SingleShardOperationRequestBuilder.java b/server/src/main/java/org/opensearch/action/support/single/shard/SingleShardOperationRequestBuilder.java index cf93947cd4afe..e8129bda2a3b0 100644 --- a/server/src/main/java/org/opensearch/action/support/single/shard/SingleShardOperationRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/support/single/shard/SingleShardOperationRequestBuilder.java @@ -34,7 +34,7 @@ import org.opensearch.action.ActionType; import org.opensearch.action.ActionRequestBuilder; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.client.OpenSearchClient; /** diff --git a/server/src/main/java/org/opensearch/action/support/single/shard/TransportSingleShardAction.java b/server/src/main/java/org/opensearch/action/support/single/shard/TransportSingleShardAction.java index 9a5ce608da472..1e1b24291ca86 100644 --- a/server/src/main/java/org/opensearch/action/support/single/shard/TransportSingleShardAction.java +++ b/server/src/main/java/org/opensearch/action/support/single/shard/TransportSingleShardAction.java @@ -33,8 +33,8 @@ package org.opensearch.action.support.single.shard; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionRunnable; import org.opensearch.action.NoShardAvailableActionException; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/action/support/tasks/BaseTasksRequest.java b/server/src/main/java/org/opensearch/action/support/tasks/BaseTasksRequest.java index f8d96d57b341b..d52197efd5875 100644 --- a/server/src/main/java/org/opensearch/action/support/tasks/BaseTasksRequest.java +++ b/server/src/main/java/org/opensearch/action/support/tasks/BaseTasksRequest.java @@ -41,7 +41,7 @@ import org.opensearch.core.common.util.CollectionUtils; import org.opensearch.core.common.Strings; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/action/support/tasks/BaseTasksResponse.java b/server/src/main/java/org/opensearch/action/support/tasks/BaseTasksResponse.java index 3bd126b452f5c..542462a9dcf8c 100644 --- a/server/src/main/java/org/opensearch/action/support/tasks/BaseTasksResponse.java +++ b/server/src/main/java/org/opensearch/action/support/tasks/BaseTasksResponse.java @@ -33,14 +33,14 @@ package org.opensearch.action.support.tasks; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.FailedNodeException; import org.opensearch.action.TaskOperationFailure; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.ArrayList; diff --git a/server/src/main/java/org/opensearch/action/support/tasks/TasksRequestBuilder.java b/server/src/main/java/org/opensearch/action/support/tasks/TasksRequestBuilder.java index a15d008fea475..53b418f58ca2d 100644 --- a/server/src/main/java/org/opensearch/action/support/tasks/TasksRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/support/tasks/TasksRequestBuilder.java @@ -35,7 +35,7 @@ import org.opensearch.action.ActionRequestBuilder; import org.opensearch.client.OpenSearchClient; import org.opensearch.common.unit.TimeValue; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; /** * Builder for task-based requests diff --git a/server/src/main/java/org/opensearch/action/support/tasks/TransportTasksAction.java b/server/src/main/java/org/opensearch/action/support/tasks/TransportTasksAction.java index e06858ab1a201..d22a6d0d80be2 100644 --- a/server/src/main/java/org/opensearch/action/support/tasks/TransportTasksAction.java +++ b/server/src/main/java/org/opensearch/action/support/tasks/TransportTasksAction.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.NoSuchNodeException; import org.opensearch.action.TaskOperationFailure; diff --git a/server/src/main/java/org/opensearch/action/termvectors/MultiTermVectorsResponse.java b/server/src/main/java/org/opensearch/action/termvectors/MultiTermVectorsResponse.java index cc482b5190e32..5d40e64df1e3e 100644 --- a/server/src/main/java/org/opensearch/action/termvectors/MultiTermVectorsResponse.java +++ b/server/src/main/java/org/opensearch/action/termvectors/MultiTermVectorsResponse.java @@ -34,7 +34,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; diff --git a/server/src/main/java/org/opensearch/action/termvectors/MultiTermVectorsShardResponse.java b/server/src/main/java/org/opensearch/action/termvectors/MultiTermVectorsShardResponse.java index 05d949df8db00..674b285a7b3ce 100644 --- a/server/src/main/java/org/opensearch/action/termvectors/MultiTermVectorsShardResponse.java +++ b/server/src/main/java/org/opensearch/action/termvectors/MultiTermVectorsShardResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.termvectors; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/action/termvectors/TermVectorsResponse.java b/server/src/main/java/org/opensearch/action/termvectors/TermVectorsResponse.java index 8889d72086f47..44d020616519f 100644 --- a/server/src/main/java/org/opensearch/action/termvectors/TermVectorsResponse.java +++ b/server/src/main/java/org/opensearch/action/termvectors/TermVectorsResponse.java @@ -41,7 +41,7 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.CharsRefBuilder; import org.opensearch.Version; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; diff --git a/server/src/main/java/org/opensearch/action/termvectors/TransportMultiTermVectorsAction.java b/server/src/main/java/org/opensearch/action/termvectors/TransportMultiTermVectorsAction.java index 4f3d0f2a095df..06cd414f06ccc 100644 --- a/server/src/main/java/org/opensearch/action/termvectors/TransportMultiTermVectorsAction.java +++ b/server/src/main/java/org/opensearch/action/termvectors/TransportMultiTermVectorsAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.termvectors; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.RoutingMissingException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; diff --git a/server/src/main/java/org/opensearch/action/termvectors/TransportTermVectorsAction.java b/server/src/main/java/org/opensearch/action/termvectors/TransportTermVectorsAction.java index af6b0e6b8e251..3a78c48ae289a 100644 --- a/server/src/main/java/org/opensearch/action/termvectors/TransportTermVectorsAction.java +++ b/server/src/main/java/org/opensearch/action/termvectors/TransportTermVectorsAction.java @@ -32,7 +32,7 @@ package org.opensearch.action.termvectors; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.RoutingMissingException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.single.shard.TransportSingleShardAction; diff --git a/server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java b/server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java index 95433bc42c2d3..766c2dd4869c4 100644 --- a/server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java +++ b/server/src/main/java/org/opensearch/action/update/TransportUpdateAction.java @@ -33,7 +33,7 @@ package org.opensearch.action.update; import org.opensearch.ResourceAlreadyExistsException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.RoutingMissingException; diff --git a/server/src/main/java/org/opensearch/client/Client.java b/server/src/main/java/org/opensearch/client/Client.java index 6d9b1f7adb64e..fcf72754b6a68 100644 --- a/server/src/main/java/org/opensearch/client/Client.java +++ b/server/src/main/java/org/opensearch/client/Client.java @@ -32,8 +32,8 @@ package org.opensearch.client; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.segments.IndicesSegmentResponse; import org.opensearch.action.admin.indices.segments.PitSegmentsRequest; import org.opensearch.action.bulk.BulkRequest; @@ -95,7 +95,7 @@ * A client provides a one stop interface for performing actions/operations against the cluster. *

* All operations performed are asynchronous by nature. Each action/operation has two flavors, the first - * simply returns an {@link org.opensearch.action.ActionFuture}, while the second accepts an + * simply returns an {@link ActionFuture}, while the second accepts an * {@link ActionListener}. *

* A client can be retrieved from a started {@link org.opensearch.node.Node}. diff --git a/server/src/main/java/org/opensearch/client/ClusterAdminClient.java b/server/src/main/java/org/opensearch/client/ClusterAdminClient.java index b93bf0cdb4429..9c45567d3e6be 100644 --- a/server/src/main/java/org/opensearch/client/ClusterAdminClient.java +++ b/server/src/main/java/org/opensearch/client/ClusterAdminClient.java @@ -32,8 +32,6 @@ package org.opensearch.client; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest; import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainRequestBuilder; import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainResponse; @@ -158,9 +156,11 @@ import org.opensearch.action.search.GetSearchPipelineResponse; import org.opensearch.action.search.PutSearchPipelineRequest; import org.opensearch.action.support.master.AcknowledgedResponse; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.MediaType; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; /** * Administrative actions/operations against indices. diff --git a/server/src/main/java/org/opensearch/client/FilterClient.java b/server/src/main/java/org/opensearch/client/FilterClient.java index d121fdd77dfeb..f0399dbd628d7 100644 --- a/server/src/main/java/org/opensearch/client/FilterClient.java +++ b/server/src/main/java/org/opensearch/client/FilterClient.java @@ -32,9 +32,9 @@ package org.opensearch.client; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.client.support.AbstractClient; import org.opensearch.common.settings.Settings; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/main/java/org/opensearch/client/IndicesAdminClient.java b/server/src/main/java/org/opensearch/client/IndicesAdminClient.java index 217902a2600e8..f9e1333a98c71 100644 --- a/server/src/main/java/org/opensearch/client/IndicesAdminClient.java +++ b/server/src/main/java/org/opensearch/client/IndicesAdminClient.java @@ -32,8 +32,8 @@ package org.opensearch.client; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; import org.opensearch.action.admin.indices.alias.get.GetAliasesRequest; diff --git a/server/src/main/java/org/opensearch/client/OpenSearchClient.java b/server/src/main/java/org/opensearch/client/OpenSearchClient.java index 755aca1f573e0..b69e63052e614 100644 --- a/server/src/main/java/org/opensearch/client/OpenSearchClient.java +++ b/server/src/main/java/org/opensearch/client/OpenSearchClient.java @@ -33,10 +33,10 @@ package org.opensearch.client; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.threadpool.ThreadPool; /** diff --git a/server/src/main/java/org/opensearch/client/OriginSettingClient.java b/server/src/main/java/org/opensearch/client/OriginSettingClient.java index 41fe9741cc4e7..97d426a69dde6 100644 --- a/server/src/main/java/org/opensearch/client/OriginSettingClient.java +++ b/server/src/main/java/org/opensearch/client/OriginSettingClient.java @@ -33,9 +33,9 @@ package org.opensearch.client; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.ContextPreservingActionListener; import org.opensearch.common.util.concurrent.ThreadContext; diff --git a/server/src/main/java/org/opensearch/client/ParentTaskAssigningClient.java b/server/src/main/java/org/opensearch/client/ParentTaskAssigningClient.java index 58ea99fa96bc3..999197121cbea 100644 --- a/server/src/main/java/org/opensearch/client/ParentTaskAssigningClient.java +++ b/server/src/main/java/org/opensearch/client/ParentTaskAssigningClient.java @@ -33,12 +33,12 @@ package org.opensearch.client; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; /** * A {@linkplain Client} that sets the parent task on all requests that it makes. Use this to conveniently implement actions that cause diff --git a/server/src/main/java/org/opensearch/client/node/NodeClient.java b/server/src/main/java/org/opensearch/client/node/NodeClient.java index 60551ade09416..7ddec3dfa17ac 100644 --- a/server/src/main/java/org/opensearch/client/node/NodeClient.java +++ b/server/src/main/java/org/opensearch/client/node/NodeClient.java @@ -33,10 +33,10 @@ package org.opensearch.client.node; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionModule.DynamicActionRegistry; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.TransportAction; import org.opensearch.client.Client; import org.opensearch.client.support.AbstractClient; diff --git a/server/src/main/java/org/opensearch/client/support/AbstractClient.java b/server/src/main/java/org/opensearch/client/support/AbstractClient.java index beedea1dd477e..7bdbcd566a5f1 100644 --- a/server/src/main/java/org/opensearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/opensearch/client/support/AbstractClient.java @@ -34,10 +34,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainAction; import org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest; @@ -410,11 +410,11 @@ import org.opensearch.client.OpenSearchClient; import org.opensearch.cluster.metadata.IndexMetadata.APIBlock; import org.opensearch.common.Nullable; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.tasks.TaskId; import org.opensearch.core.xcontent.MediaType; -import org.opensearch.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import java.util.Map; diff --git a/server/src/main/java/org/opensearch/cluster/AckedClusterStateUpdateTask.java b/server/src/main/java/org/opensearch/cluster/AckedClusterStateUpdateTask.java index 21c4460964067..b06f55667841e 100644 --- a/server/src/main/java/org/opensearch/cluster/AckedClusterStateUpdateTask.java +++ b/server/src/main/java/org/opensearch/cluster/AckedClusterStateUpdateTask.java @@ -31,7 +31,7 @@ package org.opensearch.cluster; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ack.AckedRequest; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.Nullable; diff --git a/server/src/main/java/org/opensearch/cluster/InternalClusterInfoService.java b/server/src/main/java/org/opensearch/cluster/InternalClusterInfoService.java index 9c12d6bb3e7ea..7db01b27a88de 100644 --- a/server/src/main/java/org/opensearch/cluster/InternalClusterInfoService.java +++ b/server/src/main/java/org/opensearch/cluster/InternalClusterInfoService.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.admin.cluster.node.stats.NodeStats; import org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest; diff --git a/server/src/main/java/org/opensearch/cluster/NodeConnectionsService.java b/server/src/main/java/org/opensearch/cluster/NodeConnectionsService.java index b5a9e4e7b30a0..72c874c9d85ef 100644 --- a/server/src/main/java/org/opensearch/cluster/NodeConnectionsService.java +++ b/server/src/main/java/org/opensearch/cluster/NodeConnectionsService.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.GroupedActionListener; import org.opensearch.action.support.PlainListenableActionFuture; import org.opensearch.cluster.coordination.FollowersChecker; 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 46d0d7fcbed74..9ce2554298309 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 @@ -33,7 +33,7 @@ package org.opensearch.cluster.action.index; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; 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; diff --git a/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java b/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java index 30dcb5fd08954..011a8d940dd1e 100644 --- a/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java +++ b/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterManagerNodeChangePredicate; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterStatePublisher.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterStatePublisher.java index 3900155ffc12e..c6c9baac28169 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterStatePublisher.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterStatePublisher.java @@ -31,7 +31,7 @@ package org.opensearch.cluster.coordination; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.Nullable; diff --git a/server/src/main/java/org/opensearch/cluster/coordination/CompressedStreamUtils.java b/server/src/main/java/org/opensearch/cluster/coordination/CompressedStreamUtils.java index ab3cb51683c8f..1bed7c7759317 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/CompressedStreamUtils.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/CompressedStreamUtils.java @@ -13,7 +13,7 @@ import org.opensearch.Version; import org.opensearch.common.CheckedConsumer; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.compress.Compressor; +import org.opensearch.core.common.compress.Compressor; import org.opensearch.common.compress.CompressorFactory; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.InputStreamStreamInput; diff --git a/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java b/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java index 89f45129dcd22..e62425d4a119e 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/cluster/coordination/JoinHelper.java b/server/src/main/java/org/opensearch/cluster/coordination/JoinHelper.java index f923176efa5e5..2a7c0318a856f 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/JoinHelper.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/JoinHelper.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateTaskConfig; diff --git a/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java b/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java index 626e47108cc63..6486a7b3cb412 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateTaskExecutor; import org.opensearch.cluster.NotClusterManagerException; diff --git a/server/src/main/java/org/opensearch/cluster/coordination/Publication.java b/server/src/main/java/org/opensearch/cluster/coordination/Publication.java index 6ffca828ecb06..1f02a85ce57e4 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/Publication.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/Publication.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.coordination.ClusterStatePublisher.AckListener; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/main/java/org/opensearch/cluster/coordination/PublicationTransportHandler.java b/server/src/main/java/org/opensearch/cluster/coordination/PublicationTransportHandler.java index 64c3b93e0e0be..1ee41fdfcb679 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/PublicationTransportHandler.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/PublicationTransportHandler.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.Diff; diff --git a/server/src/main/java/org/opensearch/cluster/decommission/DecommissionController.java b/server/src/main/java/org/opensearch/cluster/decommission/DecommissionController.java index 7a21dae35af94..10ab68c6cd201 100644 --- a/server/src/main/java/org/opensearch/cluster/decommission/DecommissionController.java +++ b/server/src/main/java/org/opensearch/cluster/decommission/DecommissionController.java @@ -11,7 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.stats.NodeStats; import org.opensearch.action.admin.cluster.node.stats.NodesStatsAction; import org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest; diff --git a/server/src/main/java/org/opensearch/cluster/decommission/DecommissionService.java b/server/src/main/java/org/opensearch/cluster/decommission/DecommissionService.java index 2e27898dd413c..4173a57a77108 100644 --- a/server/src/main/java/org/opensearch/cluster/decommission/DecommissionService.java +++ b/server/src/main/java/org/opensearch/cluster/decommission/DecommissionService.java @@ -12,7 +12,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateResponse; import org.opensearch.action.admin.cluster.decommission.awareness.put.DecommissionResponse; import org.opensearch.action.admin.cluster.decommission.awareness.put.DecommissionRequest; diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateDataStreamService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateDataStreamService.java index 91ff4f7652879..566aa30907cfb 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateDataStreamService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateDataStreamService.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchStatusException; import org.opensearch.ResourceAlreadyExistsException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest; import org.opensearch.action.support.ActiveShardCount; import org.opensearch.action.support.ActiveShardsObserver; diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java index fd38763023532..9386ff3f0296c 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java @@ -39,7 +39,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.ResourceAlreadyExistsException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.alias.Alias; import org.opensearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest; import org.opensearch.action.admin.indices.shrink.ResizeType; diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataDeleteIndexService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataDeleteIndexService.java index 4ee66a9920898..f0b62214fe3bc 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataDeleteIndexService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataDeleteIndexService.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.delete.DeleteIndexClusterStateUpdateRequest; import org.opensearch.cluster.AckedClusterStateUpdateTask; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexAliasesService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexAliasesService.java index 19d2f4eccd7b0..72ce894a88a02 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexAliasesService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexAliasesService.java @@ -33,7 +33,7 @@ package org.opensearch.cluster.metadata; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.alias.IndicesAliasesClusterStateUpdateRequest; import org.opensearch.cluster.AckedClusterStateUpdateTask; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexStateService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexStateService.java index dc985f5842224..44ce1cba753e9 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexStateService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexStateService.java @@ -37,9 +37,9 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; -import org.opensearch.action.NotifyOnceListener; +import org.opensearch.core.action.NotifyOnceListener; import org.opensearch.action.admin.indices.close.CloseIndexClusterStateUpdateRequest; import org.opensearch.action.admin.indices.close.CloseIndexResponse; import org.opensearch.action.admin.indices.close.CloseIndexResponse.IndexResult; @@ -87,7 +87,7 @@ import org.opensearch.snapshots.RestoreService; import org.opensearch.snapshots.SnapshotInProgressException; import org.opensearch.snapshots.SnapshotsService; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import java.util.ArrayList; diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java index 71237ad916ecc..83a46ed9cc37b 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java @@ -37,7 +37,7 @@ import org.apache.lucene.util.automaton.Automaton; import org.apache.lucene.util.automaton.Operations; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.alias.Alias; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest; diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataMappingService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataMappingService.java index 845438b2363c3..bc54da6133f5c 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataMappingService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataMappingService.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.mapping.put.PutMappingClusterStateUpdateRequest; import org.opensearch.cluster.AckedClusterStateTaskListener; import org.opensearch.cluster.ClusterState; diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataUpdateSettingsService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataUpdateSettingsService.java index a5caf3269ef26..c913877669983 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataUpdateSettingsService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataUpdateSettingsService.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.settings.put.UpdateSettingsClusterStateUpdateRequest; import org.opensearch.action.admin.indices.upgrade.post.UpgradeSettingsClusterStateUpdateRequest; import org.opensearch.cluster.AckedClusterStateUpdateTask; diff --git a/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java b/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java index eaa249d5cd341..03f0ae8213928 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest; import org.opensearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.opensearch.action.support.master.AcknowledgedResponse; diff --git a/server/src/main/java/org/opensearch/cluster/routing/BatchedRerouteService.java b/server/src/main/java/org/opensearch/cluster/routing/BatchedRerouteService.java index 641fb9abf73e0..fd5484ef6dfb7 100644 --- a/server/src/main/java/org/opensearch/cluster/routing/BatchedRerouteService.java +++ b/server/src/main/java/org/opensearch/cluster/routing/BatchedRerouteService.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateUpdateTask; import org.opensearch.cluster.NotClusterManagerException; diff --git a/server/src/main/java/org/opensearch/cluster/routing/RerouteService.java b/server/src/main/java/org/opensearch/cluster/routing/RerouteService.java index 407c3bd760c03..307439824da7d 100644 --- a/server/src/main/java/org/opensearch/cluster/routing/RerouteService.java +++ b/server/src/main/java/org/opensearch/cluster/routing/RerouteService.java @@ -31,7 +31,7 @@ package org.opensearch.cluster.routing; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.common.Priority; diff --git a/server/src/main/java/org/opensearch/cluster/routing/WeightedRoutingService.java b/server/src/main/java/org/opensearch/cluster/routing/WeightedRoutingService.java index 419d2343f65cd..0c7ef93e8a803 100644 --- a/server/src/main/java/org/opensearch/cluster/routing/WeightedRoutingService.java +++ b/server/src/main/java/org/opensearch/cluster/routing/WeightedRoutingService.java @@ -12,7 +12,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.shards.routing.weighted.delete.ClusterDeleteWeightedRoutingRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.admin.cluster.shards.routing.weighted.delete.ClusterDeleteWeightedRoutingResponse; diff --git a/server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitor.java b/server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitor.java index 87cc62b2fd481..908459e493c1b 100644 --- a/server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitor.java +++ b/server/src/main/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitor.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.GroupedActionListener; import org.opensearch.client.Client; import org.opensearch.cluster.ClusterInfo; diff --git a/server/src/main/java/org/opensearch/common/AsyncBiFunction.java b/server/src/main/java/org/opensearch/common/AsyncBiFunction.java index 12e6377682723..575e357665964 100644 --- a/server/src/main/java/org/opensearch/common/AsyncBiFunction.java +++ b/server/src/main/java/org/opensearch/common/AsyncBiFunction.java @@ -31,7 +31,7 @@ package org.opensearch.common; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; /** * A {@link java.util.function.BiFunction}-like interface designed to be used with asynchronous executions. diff --git a/server/src/main/java/org/opensearch/common/blobstore/BlobContainer.java b/server/src/main/java/org/opensearch/common/blobstore/BlobContainer.java index e626824e7e271..cba6579190c26 100644 --- a/server/src/main/java/org/opensearch/common/blobstore/BlobContainer.java +++ b/server/src/main/java/org/opensearch/common/blobstore/BlobContainer.java @@ -32,7 +32,7 @@ package org.opensearch.common.blobstore; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import java.io.IOException; import java.io.InputStream; diff --git a/server/src/main/java/org/opensearch/common/blobstore/VerifyingMultiStreamBlobContainer.java b/server/src/main/java/org/opensearch/common/blobstore/VerifyingMultiStreamBlobContainer.java index 0dfcc5c50e4b1..df11e94620c25 100644 --- a/server/src/main/java/org/opensearch/common/blobstore/VerifyingMultiStreamBlobContainer.java +++ b/server/src/main/java/org/opensearch/common/blobstore/VerifyingMultiStreamBlobContainer.java @@ -8,7 +8,7 @@ package org.opensearch.common.blobstore; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.blobstore.stream.write.WriteContext; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/common/compress/CompressedXContent.java b/server/src/main/java/org/opensearch/common/compress/CompressedXContent.java index 2873e0d39c6ef..953f7d2340898 100644 --- a/server/src/main/java/org/opensearch/common/compress/CompressedXContent.java +++ b/server/src/main/java/org/opensearch/common/compress/CompressedXContent.java @@ -36,6 +36,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.Streams; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.core.common.compress.Compressor; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ToXContent; diff --git a/server/src/main/java/org/opensearch/common/compress/CompressorFactory.java b/server/src/main/java/org/opensearch/common/compress/CompressorFactory.java index ee2d5a650fc70..e40dd89abab54 100644 --- a/server/src/main/java/org/opensearch/common/compress/CompressorFactory.java +++ b/server/src/main/java/org/opensearch/common/compress/CompressorFactory.java @@ -34,6 +34,7 @@ import org.opensearch.common.Nullable; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.compress.Compressor; import org.opensearch.core.common.compress.NotXContentException; import org.opensearch.core.xcontent.MediaTypeRegistry; diff --git a/server/src/main/java/org/opensearch/common/compress/CompressorType.java b/server/src/main/java/org/opensearch/common/compress/CompressorType.java index 65453cd51848e..bc688bab57c37 100644 --- a/server/src/main/java/org/opensearch/common/compress/CompressorType.java +++ b/server/src/main/java/org/opensearch/common/compress/CompressorType.java @@ -8,6 +8,8 @@ package org.opensearch.common.compress; +import org.opensearch.core.common.compress.Compressor; + /** * Supported compression types * diff --git a/server/src/main/java/org/opensearch/common/compress/DeflateCompressor.java b/server/src/main/java/org/opensearch/common/compress/DeflateCompressor.java index 54cc3ad9d420e..07d96dd2c0846 100644 --- a/server/src/main/java/org/opensearch/common/compress/DeflateCompressor.java +++ b/server/src/main/java/org/opensearch/common/compress/DeflateCompressor.java @@ -34,8 +34,9 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; -import org.opensearch.core.Assertions; import org.opensearch.common.lease.Releasable; +import org.opensearch.core.Assertions; +import org.opensearch.core.common.compress.Compressor; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; diff --git a/server/src/main/java/org/opensearch/common/compress/NoneCompressor.java b/server/src/main/java/org/opensearch/common/compress/NoneCompressor.java index 775152b0e9388..f820a3351bc80 100644 --- a/server/src/main/java/org/opensearch/common/compress/NoneCompressor.java +++ b/server/src/main/java/org/opensearch/common/compress/NoneCompressor.java @@ -9,6 +9,7 @@ package org.opensearch.common.compress; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.compress.Compressor; import java.io.IOException; import java.io.InputStream; diff --git a/server/src/main/java/org/opensearch/common/compress/ZstdCompressor.java b/server/src/main/java/org/opensearch/common/compress/ZstdCompressor.java index cc3ab57e604b7..922e8f6f39668 100644 --- a/server/src/main/java/org/opensearch/common/compress/ZstdCompressor.java +++ b/server/src/main/java/org/opensearch/common/compress/ZstdCompressor.java @@ -12,6 +12,7 @@ import com.github.luben.zstd.ZstdInputStreamNoFinalizer; import com.github.luben.zstd.ZstdOutputStreamNoFinalizer; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.compress.Compressor; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; diff --git a/server/src/main/java/org/opensearch/common/network/CloseableChannel.java b/server/src/main/java/org/opensearch/common/network/CloseableChannel.java index 704b616bcabc9..4c2f18a200d09 100644 --- a/server/src/main/java/org/opensearch/common/network/CloseableChannel.java +++ b/server/src/main/java/org/opensearch/common/network/CloseableChannel.java @@ -32,8 +32,8 @@ package org.opensearch.common.network; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.common.util.io.IOUtils; diff --git a/server/src/main/java/org/opensearch/common/util/concurrent/ListenableFuture.java b/server/src/main/java/org/opensearch/common/util/concurrent/ListenableFuture.java index cc865022e1e8a..708d72c027c4e 100644 --- a/server/src/main/java/org/opensearch/common/util/concurrent/ListenableFuture.java +++ b/server/src/main/java/org/opensearch/common/util/concurrent/ListenableFuture.java @@ -32,7 +32,7 @@ package org.opensearch.common.util.concurrent; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.support.ContextPreservingActionListener; import org.opensearch.common.collect.Tuple; diff --git a/server/src/main/java/org/opensearch/common/xcontent/XContentHelper.java b/server/src/main/java/org/opensearch/common/xcontent/XContentHelper.java index 35d5188143450..ecd5ec1e15943 100644 --- a/server/src/main/java/org/opensearch/common/xcontent/XContentHelper.java +++ b/server/src/main/java/org/opensearch/common/xcontent/XContentHelper.java @@ -36,8 +36,8 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; -import org.opensearch.common.compress.Compressor; import org.opensearch.common.compress.CompressorFactory; +import org.opensearch.core.common.compress.Compressor; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; @@ -492,33 +492,6 @@ public static BytesReference toXContent(ToXContent toXContent, XContentType xCon return org.opensearch.core.xcontent.XContentHelper.toXContent(toXContent, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); } - /** - * Returns the bytes that represent the XContent output of the provided {@link ToXContent} object, using the provided - * {@link XContentType}. Wraps the output into a new anonymous object according to the value returned - * by the {@link ToXContent#isFragment()} method returns. - * - * @deprecated use {@link org.opensearch.core.xcontent.XContentHelper#toXContent(ToXContent, MediaType, ToXContent.Params, boolean)} instead - */ - @Deprecated - public static BytesReference toXContent( - ToXContent toXContent, - XContentType xContentType, - ToXContent.Params params, - boolean humanReadable - ) throws IOException { - try (XContentBuilder builder = XContentBuilder.builder(xContentType.xContent())) { - builder.humanReadable(humanReadable); - if (toXContent.isFragment()) { - builder.startObject(); - } - toXContent.toXContent(builder, params); - if (toXContent.isFragment()) { - builder.endObject(); - } - return BytesReference.bytes(builder); - } - } - /** * Returns the contents of an object as an unparsed BytesReference * diff --git a/server/src/main/java/org/opensearch/discovery/HandshakingTransportAddressConnector.java b/server/src/main/java/org/opensearch/discovery/HandshakingTransportAddressConnector.java index 80ce094785755..94d2272195369 100644 --- a/server/src/main/java/org/opensearch/discovery/HandshakingTransportAddressConnector.java +++ b/server/src/main/java/org/opensearch/discovery/HandshakingTransportAddressConnector.java @@ -36,8 +36,8 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.Version; -import org.opensearch.action.ActionListener; -import org.opensearch.action.NotifyOnceListener; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.NotifyOnceListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.Randomness; import org.opensearch.common.UUIDs; diff --git a/server/src/main/java/org/opensearch/discovery/PeerFinder.java b/server/src/main/java/org/opensearch/discovery/PeerFinder.java index f470342d826f8..9de3dfd93a008 100644 --- a/server/src/main/java/org/opensearch/discovery/PeerFinder.java +++ b/server/src/main/java/org/opensearch/discovery/PeerFinder.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.coordination.PeersResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; diff --git a/server/src/main/java/org/opensearch/extensions/action/ExtensionActionResponse.java b/server/src/main/java/org/opensearch/extensions/action/ExtensionActionResponse.java index 6b026b51ed2aa..5f0ba572b2ea6 100644 --- a/server/src/main/java/org/opensearch/extensions/action/ExtensionActionResponse.java +++ b/server/src/main/java/org/opensearch/extensions/action/ExtensionActionResponse.java @@ -8,7 +8,7 @@ package org.opensearch.extensions.action; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/extensions/action/ExtensionProxyTransportAction.java b/server/src/main/java/org/opensearch/extensions/action/ExtensionProxyTransportAction.java index 364965dc582e6..95de3c7929eab 100644 --- a/server/src/main/java/org/opensearch/extensions/action/ExtensionProxyTransportAction.java +++ b/server/src/main/java/org/opensearch/extensions/action/ExtensionProxyTransportAction.java @@ -8,7 +8,7 @@ package org.opensearch.extensions.action; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportAction.java b/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportAction.java index 4b0b9725e50ae..5218f8f8280a6 100644 --- a/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportAction.java +++ b/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportAction.java @@ -8,7 +8,7 @@ package org.opensearch.extensions.action; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.TransportAction; import org.opensearch.extensions.ExtensionsManager; diff --git a/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportActionsHandler.java b/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportActionsHandler.java index 19fe43e9a6d61..77c2cd8ba6ce5 100644 --- a/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportActionsHandler.java +++ b/server/src/main/java/org/opensearch/extensions/action/ExtensionTransportActionsHandler.java @@ -10,7 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionModule; import org.opensearch.action.ActionModule.DynamicActionRegistry; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/extensions/action/RemoteExtensionActionResponse.java b/server/src/main/java/org/opensearch/extensions/action/RemoteExtensionActionResponse.java index 7a6b053eb7480..d092bee714941 100644 --- a/server/src/main/java/org/opensearch/extensions/action/RemoteExtensionActionResponse.java +++ b/server/src/main/java/org/opensearch/extensions/action/RemoteExtensionActionResponse.java @@ -8,7 +8,7 @@ package org.opensearch.extensions.action; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; diff --git a/server/src/main/java/org/opensearch/gateway/AsyncShardFetch.java b/server/src/main/java/org/opensearch/gateway/AsyncShardFetch.java index 937432096817e..86e96b3bc921b 100644 --- a/server/src/main/java/org/opensearch/gateway/AsyncShardFetch.java +++ b/server/src/main/java/org/opensearch/gateway/AsyncShardFetch.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.nodes.BaseNodeResponse; import org.opensearch.action.support.nodes.BaseNodesResponse; diff --git a/server/src/main/java/org/opensearch/gateway/DanglingIndicesState.java b/server/src/main/java/org/opensearch/gateway/DanglingIndicesState.java index dba081f1b50c2..129d110fd6bbd 100644 --- a/server/src/main/java/org/opensearch/gateway/DanglingIndicesState.java +++ b/server/src/main/java/org/opensearch/gateway/DanglingIndicesState.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterStateListener; import org.opensearch.cluster.metadata.IndexGraveyard; diff --git a/server/src/main/java/org/opensearch/gateway/GatewayAllocator.java b/server/src/main/java/org/opensearch/gateway/GatewayAllocator.java index 5a20112b19219..723664ca2488d 100644 --- a/server/src/main/java/org/opensearch/gateway/GatewayAllocator.java +++ b/server/src/main/java/org/opensearch/gateway/GatewayAllocator.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.nodes.BaseNodeResponse; import org.opensearch.action.support.nodes.BaseNodesResponse; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/server/src/main/java/org/opensearch/gateway/LocalAllocateDangledIndices.java b/server/src/main/java/org/opensearch/gateway/LocalAllocateDangledIndices.java index 5d6843a9684e1..54d220b41589d 100644 --- a/server/src/main/java/org/opensearch/gateway/LocalAllocateDangledIndices.java +++ b/server/src/main/java/org/opensearch/gateway/LocalAllocateDangledIndices.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateUpdateTask; diff --git a/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayMetaState.java b/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayMetaState.java index 3be8ac9784960..a634755376024 100644 --- a/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayMetaState.java +++ b/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayMetaState.java @@ -32,7 +32,7 @@ package org.opensearch.gateway; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.ActionType; import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayStartedShards.java b/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayStartedShards.java index e2a3f08bb02c6..fd554d39ad01a 100644 --- a/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayStartedShards.java +++ b/server/src/main/java/org/opensearch/gateway/TransportNodesListGatewayStartedShards.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionType; import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/http/AbstractHttpServerTransport.java b/server/src/main/java/org/opensearch/http/AbstractHttpServerTransport.java index bedeedb9c5c6f..c0e1ea0b426c8 100644 --- a/server/src/main/java/org/opensearch/http/AbstractHttpServerTransport.java +++ b/server/src/main/java/org/opensearch/http/AbstractHttpServerTransport.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.lifecycle.AbstractLifecycleComponent; import org.opensearch.common.network.CloseableChannel; import org.opensearch.common.network.NetworkAddress; diff --git a/server/src/main/java/org/opensearch/http/DefaultRestChannel.java b/server/src/main/java/org/opensearch/http/DefaultRestChannel.java index 523a89e05caa3..84c18af812d4b 100644 --- a/server/src/main/java/org/opensearch/http/DefaultRestChannel.java +++ b/server/src/main/java/org/opensearch/http/DefaultRestChannel.java @@ -33,7 +33,7 @@ package org.opensearch.http; import org.opensearch.Build; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.Nullable; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; diff --git a/server/src/main/java/org/opensearch/http/HttpChannel.java b/server/src/main/java/org/opensearch/http/HttpChannel.java index a3a3d46f629ce..b829123f79bcb 100644 --- a/server/src/main/java/org/opensearch/http/HttpChannel.java +++ b/server/src/main/java/org/opensearch/http/HttpChannel.java @@ -32,7 +32,7 @@ package org.opensearch.http; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.network.CloseableChannel; import java.net.InetSocketAddress; diff --git a/server/src/main/java/org/opensearch/http/HttpInfo.java b/server/src/main/java/org/opensearch/http/HttpInfo.java index 35eadc5a5de9e..1bcd84f5837ec 100644 --- a/server/src/main/java/org/opensearch/http/HttpInfo.java +++ b/server/src/main/java/org/opensearch/http/HttpInfo.java @@ -40,7 +40,7 @@ import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/http/HttpServerTransport.java b/server/src/main/java/org/opensearch/http/HttpServerTransport.java index 7bd16a286e33b..adce8da8f7417 100644 --- a/server/src/main/java/org/opensearch/http/HttpServerTransport.java +++ b/server/src/main/java/org/opensearch/http/HttpServerTransport.java @@ -35,7 +35,7 @@ import org.opensearch.common.lifecycle.LifecycleComponent; import org.opensearch.core.common.transport.BoundTransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; diff --git a/server/src/main/java/org/opensearch/index/SegmentReplicationPressureService.java b/server/src/main/java/org/opensearch/index/SegmentReplicationPressureService.java index 7e54d5179ea35..76e75bc533bcd 100644 --- a/server/src/main/java/org/opensearch/index/SegmentReplicationPressureService.java +++ b/server/src/main/java/org/opensearch/index/SegmentReplicationPressureService.java @@ -10,7 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.action.shard.ShardStateAction; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.collect.Tuple; diff --git a/server/src/main/java/org/opensearch/index/engine/CompletionStatsCache.java b/server/src/main/java/org/opensearch/index/engine/CompletionStatsCache.java index fb4e868a8903b..79341582e6cee 100644 --- a/server/src/main/java/org/opensearch/index/engine/CompletionStatsCache.java +++ b/server/src/main/java/org/opensearch/index/engine/CompletionStatsCache.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.Terms; import org.apache.lucene.search.ReferenceManager; import org.apache.lucene.search.suggest.document.CompletionTerms; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.common.FieldMemoryStats; import org.opensearch.common.Nullable; diff --git a/server/src/main/java/org/opensearch/index/query/AbstractGeometryQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/AbstractGeometryQueryBuilder.java index 042890c238410..3a1b93a626958 100644 --- a/server/src/main/java/org/opensearch/index/query/AbstractGeometryQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/AbstractGeometryQueryBuilder.java @@ -35,7 +35,7 @@ import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.GetResponse; import org.opensearch.client.Client; diff --git a/server/src/main/java/org/opensearch/index/query/MoreLikeThisQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/MoreLikeThisQueryBuilder.java index 625d520890422..b7953edd57553 100644 --- a/server/src/main/java/org/opensearch/index/query/MoreLikeThisQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/MoreLikeThisQueryBuilder.java @@ -48,6 +48,11 @@ import org.opensearch.action.termvectors.TermVectorsResponse; import org.opensearch.client.Client; import org.opensearch.common.Nullable; +import org.opensearch.common.lucene.search.MoreLikeThisQuery; +import org.opensearch.common.lucene.search.XMoreLikeThis; +import org.opensearch.common.lucene.uid.Versions; +import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.ParseField; import org.opensearch.core.common.ParsingException; import org.opensearch.core.common.Strings; @@ -55,16 +60,11 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.lucene.search.MoreLikeThisQuery; -import org.opensearch.common.lucene.search.XMoreLikeThis; -import org.opensearch.common.lucene.uid.Versions; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.VersionType; import org.opensearch.index.mapper.IdFieldMapper; import org.opensearch.index.mapper.KeywordFieldMapper.KeywordFieldType; diff --git a/server/src/main/java/org/opensearch/index/query/QueryRewriteContext.java b/server/src/main/java/org/opensearch/index/query/QueryRewriteContext.java index ab5406d5531bd..f3bc694fcac3f 100644 --- a/server/src/main/java/org/opensearch/index/query/QueryRewriteContext.java +++ b/server/src/main/java/org/opensearch/index/query/QueryRewriteContext.java @@ -31,7 +31,7 @@ package org.opensearch.index.query; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.client.Client; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.util.concurrent.CountDown; diff --git a/server/src/main/java/org/opensearch/index/query/QueryShardContext.java b/server/src/main/java/org/opensearch/index/query/QueryShardContext.java index a1fc4327997e8..332551b623917 100644 --- a/server/src/main/java/org/opensearch/index/query/QueryShardContext.java +++ b/server/src/main/java/org/opensearch/index/query/QueryShardContext.java @@ -39,7 +39,7 @@ import org.apache.lucene.search.join.BitSetProducer; import org.apache.lucene.search.similarities.Similarity; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.client.Client; import org.opensearch.common.CheckedFunction; import org.opensearch.core.common.ParsingException; diff --git a/server/src/main/java/org/opensearch/index/query/Rewriteable.java b/server/src/main/java/org/opensearch/index/query/Rewriteable.java index ea884f720f4fc..3ed779b52debf 100644 --- a/server/src/main/java/org/opensearch/index/query/Rewriteable.java +++ b/server/src/main/java/org/opensearch/index/query/Rewriteable.java @@ -31,7 +31,7 @@ package org.opensearch.index.query; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.ParsingException; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java index c677bab0ea7e0..3ffbde2bfb8f5 100644 --- a/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java @@ -37,7 +37,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefBuilder; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.get.GetRequest; import org.opensearch.client.Client; import org.opensearch.core.common.ParsingException; diff --git a/server/src/main/java/org/opensearch/index/reindex/AbstractBulkByScrollRequest.java b/server/src/main/java/org/opensearch/index/reindex/AbstractBulkByScrollRequest.java index 1ed4df0fb4fe9..18885a8c44175 100644 --- a/server/src/main/java/org/opensearch/index/reindex/AbstractBulkByScrollRequest.java +++ b/server/src/main/java/org/opensearch/index/reindex/AbstractBulkByScrollRequest.java @@ -43,7 +43,7 @@ import org.opensearch.search.Scroll; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.Arrays; diff --git a/server/src/main/java/org/opensearch/index/reindex/AbstractBulkIndexByScrollRequest.java b/server/src/main/java/org/opensearch/index/reindex/AbstractBulkIndexByScrollRequest.java index 663f6136d2105..3afbdd942bf7f 100644 --- a/server/src/main/java/org/opensearch/index/reindex/AbstractBulkIndexByScrollRequest.java +++ b/server/src/main/java/org/opensearch/index/reindex/AbstractBulkIndexByScrollRequest.java @@ -37,7 +37,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.script.Script; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/index/reindex/BulkByScrollResponse.java b/server/src/main/java/org/opensearch/index/reindex/BulkByScrollResponse.java index b96db441d6736..447aba184308a 100644 --- a/server/src/main/java/org/opensearch/index/reindex/BulkByScrollResponse.java +++ b/server/src/main/java/org/opensearch/index/reindex/BulkByScrollResponse.java @@ -34,7 +34,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchParseException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.bulk.BulkItemResponse.Failure; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.index.reindex.BulkByScrollTask.Status; diff --git a/server/src/main/java/org/opensearch/index/reindex/BulkByScrollTask.java b/server/src/main/java/org/opensearch/index/reindex/BulkByScrollTask.java index e1a952d81ead3..17a35189ee4cb 100644 --- a/server/src/main/java/org/opensearch/index/reindex/BulkByScrollTask.java +++ b/server/src/main/java/org/opensearch/index/reindex/BulkByScrollTask.java @@ -51,7 +51,7 @@ import org.opensearch.core.xcontent.XContentParser.Token; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/index/reindex/ClientScrollableHitSource.java b/server/src/main/java/org/opensearch/index/reindex/ClientScrollableHitSource.java index 3159d8bfc3c85..3be30d4dee557 100644 --- a/server/src/main/java/org/opensearch/index/reindex/ClientScrollableHitSource.java +++ b/server/src/main/java/org/opensearch/index/reindex/ClientScrollableHitSource.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.bulk.BackoffPolicy; import org.opensearch.action.search.ClearScrollRequest; import org.opensearch.action.search.ClearScrollResponse; diff --git a/server/src/main/java/org/opensearch/index/reindex/DeleteByQueryRequest.java b/server/src/main/java/org/opensearch/index/reindex/DeleteByQueryRequest.java index f3efa0040a0ea..71baab491c4e5 100644 --- a/server/src/main/java/org/opensearch/index/reindex/DeleteByQueryRequest.java +++ b/server/src/main/java/org/opensearch/index/reindex/DeleteByQueryRequest.java @@ -40,7 +40,7 @@ import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.query.QueryBuilder; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/index/reindex/LeaderBulkByScrollTaskState.java b/server/src/main/java/org/opensearch/index/reindex/LeaderBulkByScrollTaskState.java index 973ceeefe43b7..d0f6c64fa425b 100644 --- a/server/src/main/java/org/opensearch/index/reindex/LeaderBulkByScrollTaskState.java +++ b/server/src/main/java/org/opensearch/index/reindex/LeaderBulkByScrollTaskState.java @@ -32,7 +32,7 @@ package org.opensearch.index.reindex; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.util.concurrent.AtomicArray; import java.util.ArrayList; diff --git a/server/src/main/java/org/opensearch/index/reindex/ReindexRequest.java b/server/src/main/java/org/opensearch/index/reindex/ReindexRequest.java index 8a9a346a5344a..4471d86aa9ccb 100644 --- a/server/src/main/java/org/opensearch/index/reindex/ReindexRequest.java +++ b/server/src/main/java/org/opensearch/index/reindex/ReindexRequest.java @@ -53,7 +53,7 @@ import org.opensearch.index.query.QueryBuilder; import org.opensearch.script.Script; import org.opensearch.search.sort.SortOrder; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.io.InputStream; diff --git a/server/src/main/java/org/opensearch/index/reindex/RejectAwareActionListener.java b/server/src/main/java/org/opensearch/index/reindex/RejectAwareActionListener.java index da3afb178300e..aac1916865a8c 100644 --- a/server/src/main/java/org/opensearch/index/reindex/RejectAwareActionListener.java +++ b/server/src/main/java/org/opensearch/index/reindex/RejectAwareActionListener.java @@ -32,7 +32,7 @@ package org.opensearch.index.reindex; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.CheckedConsumer; import java.util.function.Consumer; diff --git a/server/src/main/java/org/opensearch/index/reindex/RetryListener.java b/server/src/main/java/org/opensearch/index/reindex/RetryListener.java index ad09080cfea2b..05dfa18a5eef7 100644 --- a/server/src/main/java/org/opensearch/index/reindex/RetryListener.java +++ b/server/src/main/java/org/opensearch/index/reindex/RetryListener.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.bulk.BackoffPolicy; import org.opensearch.common.unit.TimeValue; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/main/java/org/opensearch/index/reindex/ScrollableHitSource.java b/server/src/main/java/org/opensearch/index/reindex/ScrollableHitSource.java index 59426fd8cc0b8..a98b7ef268c71 100644 --- a/server/src/main/java/org/opensearch/index/reindex/ScrollableHitSource.java +++ b/server/src/main/java/org/opensearch/index/reindex/ScrollableHitSource.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.bulk.BackoffPolicy; import org.opensearch.action.bulk.BulkItemResponse; import org.opensearch.action.search.ShardSearchFailure; diff --git a/server/src/main/java/org/opensearch/index/reindex/UpdateByQueryRequest.java b/server/src/main/java/org/opensearch/index/reindex/UpdateByQueryRequest.java index 6601fc3a7513f..ee6f4c267138c 100644 --- a/server/src/main/java/org/opensearch/index/reindex/UpdateByQueryRequest.java +++ b/server/src/main/java/org/opensearch/index/reindex/UpdateByQueryRequest.java @@ -40,7 +40,7 @@ import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.query.QueryBuilder; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/index/seqno/GlobalCheckpointSyncAction.java b/server/src/main/java/org/opensearch/index/seqno/GlobalCheckpointSyncAction.java index 4ae693851c85f..389bf7651a839 100644 --- a/server/src/main/java/org/opensearch/index/seqno/GlobalCheckpointSyncAction.java +++ b/server/src/main/java/org/opensearch/index/seqno/GlobalCheckpointSyncAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.replication.ReplicationRequest; import org.opensearch.action.support.replication.ReplicationResponse; diff --git a/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java b/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java index 19fe9ee97cd2f..5823d3ed933af 100644 --- a/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java +++ b/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.LegacyESVersion; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.GroupedActionListener; import org.opensearch.action.support.replication.ReplicationResponse; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseActions.java b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseActions.java index 88a4f5d8ab2b5..287c8c9f4d9e2 100644 --- a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseActions.java +++ b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseActions.java @@ -32,9 +32,9 @@ package org.opensearch.index.seqno; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.single.shard.SingleShardRequest; diff --git a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncAction.java b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncAction.java index ec8d44846e30e..79fc78a06c5e1 100644 --- a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncAction.java +++ b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncAction.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.ActiveShardCount; import org.opensearch.action.support.replication.ReplicationRequest; @@ -58,7 +58,7 @@ import org.opensearch.indices.IndicesService; import org.opensearch.node.NodeClosedException; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportException; import org.opensearch.transport.TransportResponseHandler; diff --git a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncAction.java b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncAction.java index 0c50f9b06b2af..dddcf88807e97 100644 --- a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncAction.java +++ b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncAction.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.ActiveShardCount; import org.opensearch.action.support.WriteResponse; @@ -61,7 +61,7 @@ import org.opensearch.indices.IndicesService; import org.opensearch.indices.SystemIndices; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportException; import org.opensearch.transport.TransportResponseHandler; diff --git a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncer.java b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncer.java index db3e8c4012ae5..2d3d40624802e 100644 --- a/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncer.java +++ b/server/src/main/java/org/opensearch/index/seqno/RetentionLeaseSyncer.java @@ -32,7 +32,7 @@ package org.opensearch.index.seqno; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.replication.ReplicationResponse; import org.opensearch.common.inject.Inject; import org.opensearch.core.index.shard.ShardId; diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index c485773695334..7b5f96892c005 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -61,7 +61,7 @@ import org.opensearch.core.Assertions; import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.admin.indices.forcemerge.ForceMergeRequest; diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShardOperationPermits.java b/server/src/main/java/org/opensearch/index/shard/IndexShardOperationPermits.java index 7b93d05fb322a..0f8bd5f2ae0b0 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShardOperationPermits.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShardOperationPermits.java @@ -34,7 +34,7 @@ import org.opensearch.core.Assertions; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.support.ContextPreservingActionListener; import org.opensearch.common.CheckedRunnable; diff --git a/server/src/main/java/org/opensearch/index/shard/PrimaryReplicaSyncer.java b/server/src/main/java/org/opensearch/index/shard/PrimaryReplicaSyncer.java index a5d5e7dc545e1..b6964ff4693e9 100644 --- a/server/src/main/java/org/opensearch/index/shard/PrimaryReplicaSyncer.java +++ b/server/src/main/java/org/opensearch/index/shard/PrimaryReplicaSyncer.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.resync.ResyncReplicationRequest; @@ -54,7 +54,7 @@ import org.opensearch.index.seqno.SequenceNumbers; import org.opensearch.index.translog.Translog; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskManager; import org.opensearch.transport.TransportService; diff --git a/server/src/main/java/org/opensearch/index/shard/RemoteStoreRefreshListener.java b/server/src/main/java/org/opensearch/index/shard/RemoteStoreRefreshListener.java index 1357a77071786..9fbc3748f9383 100644 --- a/server/src/main/java/org/opensearch/index/shard/RemoteStoreRefreshListener.java +++ b/server/src/main/java/org/opensearch/index/shard/RemoteStoreRefreshListener.java @@ -17,7 +17,7 @@ import org.apache.lucene.store.FilterDirectory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.bulk.BackoffPolicy; import org.opensearch.action.support.GroupedActionListener; diff --git a/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java b/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java index 2c8a186a6ed53..0705b7601a310 100644 --- a/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java +++ b/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java @@ -43,7 +43,7 @@ import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.metadata.MappingMetadata; diff --git a/server/src/main/java/org/opensearch/index/store/RemoteDirectory.java b/server/src/main/java/org/opensearch/index/store/RemoteDirectory.java index f7fe7ca62e6ba..ce367e1b27ada 100644 --- a/server/src/main/java/org/opensearch/index/store/RemoteDirectory.java +++ b/server/src/main/java/org/opensearch/index/store/RemoteDirectory.java @@ -13,7 +13,7 @@ import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.Lock; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.common.blobstore.BlobContainer; import org.opensearch.common.blobstore.BlobMetadata; diff --git a/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java b/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java index a0d4128301006..2e5ac10fefdda 100644 --- a/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java +++ b/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java @@ -26,7 +26,7 @@ import org.apache.lucene.store.IndexOutput; import org.apache.lucene.util.Version; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.UUIDs; import org.opensearch.common.blobstore.VerifyingMultiStreamBlobContainer; import org.opensearch.common.blobstore.exception.CorruptFileException; diff --git a/server/src/main/java/org/opensearch/index/translog/transfer/BlobStoreTransferService.java b/server/src/main/java/org/opensearch/index/translog/transfer/BlobStoreTransferService.java index 95424d86fba34..61e6b5fce9b6c 100644 --- a/server/src/main/java/org/opensearch/index/translog/transfer/BlobStoreTransferService.java +++ b/server/src/main/java/org/opensearch/index/translog/transfer/BlobStoreTransferService.java @@ -11,7 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.common.blobstore.BlobMetadata; import org.opensearch.common.blobstore.BlobPath; diff --git a/server/src/main/java/org/opensearch/index/translog/transfer/TransferService.java b/server/src/main/java/org/opensearch/index/translog/transfer/TransferService.java index 885a2e32e915d..45cc47fcb1ad4 100644 --- a/server/src/main/java/org/opensearch/index/translog/transfer/TransferService.java +++ b/server/src/main/java/org/opensearch/index/translog/transfer/TransferService.java @@ -8,7 +8,7 @@ package org.opensearch.index.translog.transfer; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.blobstore.BlobMetadata; import org.opensearch.common.blobstore.BlobPath; import org.opensearch.common.blobstore.stream.write.WritePriority; diff --git a/server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java b/server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java index 850a0c1a6574c..c9d1022a15e28 100644 --- a/server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java +++ b/server/src/main/java/org/opensearch/index/translog/transfer/TranslogTransferManager.java @@ -12,7 +12,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.OutputStreamIndexOutput; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.common.SetOnce; import org.opensearch.common.blobstore.BlobMetadata; diff --git a/server/src/main/java/org/opensearch/indices/RunUnderPrimaryPermit.java b/server/src/main/java/org/opensearch/indices/RunUnderPrimaryPermit.java index b7995accda1da..3d2938c778fe4 100644 --- a/server/src/main/java/org/opensearch/indices/RunUnderPrimaryPermit.java +++ b/server/src/main/java/org/opensearch/indices/RunUnderPrimaryPermit.java @@ -9,7 +9,7 @@ package org.opensearch.indices; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.util.CancellableThreads; import org.opensearch.common.util.concurrent.FutureUtils; import org.opensearch.common.lease.Releasable; diff --git a/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java b/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java index 8f2b6cfde7a34..a527ae09d7666 100644 --- a/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java +++ b/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.ResourceAlreadyExistsException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateApplier; diff --git a/server/src/main/java/org/opensearch/indices/recovery/FileChunkWriter.java b/server/src/main/java/org/opensearch/indices/recovery/FileChunkWriter.java index c7021a0e969b9..a1ae6af8e15e9 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/FileChunkWriter.java +++ b/server/src/main/java/org/opensearch/indices/recovery/FileChunkWriter.java @@ -8,7 +8,7 @@ package org.opensearch.indices.recovery; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.index.store.StoreFileMetadata; diff --git a/server/src/main/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandler.java b/server/src/main/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandler.java index d7890d6e3e5e0..157db852eb0ba 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandler.java +++ b/server/src/main/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandler.java @@ -9,7 +9,7 @@ package org.opensearch.indices.recovery; import org.apache.lucene.index.IndexCommit; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.support.ThreadedActionListener; import org.opensearch.action.support.replication.ReplicationResponse; diff --git a/server/src/main/java/org/opensearch/indices/recovery/MultiChunkTransfer.java b/server/src/main/java/org/opensearch/indices/recovery/MultiChunkTransfer.java index 86e021bb6bfff..3772f1891a646 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/MultiChunkTransfer.java +++ b/server/src/main/java/org/opensearch/indices/recovery/MultiChunkTransfer.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.core.Assertions; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.collect.Tuple; import org.opensearch.common.util.concurrent.AsyncIOProcessor; import org.opensearch.common.util.concurrent.ThreadContext; diff --git a/server/src/main/java/org/opensearch/indices/recovery/PeerRecoverySourceService.java b/server/src/main/java/org/opensearch/indices/recovery/PeerRecoverySourceService.java index 1ff1844d9e6ac..124564c4fa680 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/PeerRecoverySourceService.java +++ b/server/src/main/java/org/opensearch/indices/recovery/PeerRecoverySourceService.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.ExceptionsHelper; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ChannelActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.ClusterChangedEvent; diff --git a/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java b/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java index 569977afd3ac5..d3e62282d6b5c 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java +++ b/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java @@ -39,7 +39,7 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateObserver; diff --git a/server/src/main/java/org/opensearch/indices/recovery/RecoverySourceHandler.java b/server/src/main/java/org/opensearch/indices/recovery/RecoverySourceHandler.java index f8ba63def6239..4f741a289987b 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/RecoverySourceHandler.java +++ b/server/src/main/java/org/opensearch/indices/recovery/RecoverySourceHandler.java @@ -39,7 +39,7 @@ import org.apache.lucene.index.IndexFormatTooOldException; import org.apache.lucene.store.RateLimiter; import org.apache.lucene.util.ArrayUtil; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.StepListener; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/main/java/org/opensearch/indices/recovery/RecoveryTarget.java b/server/src/main/java/org/opensearch/indices/recovery/RecoveryTarget.java index 1eba50ffcf172..d07e90aea31d0 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/RecoveryTarget.java +++ b/server/src/main/java/org/opensearch/indices/recovery/RecoveryTarget.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.IndexFormatTooOldException; import org.opensearch.core.Assertions; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.UUIDs; diff --git a/server/src/main/java/org/opensearch/indices/recovery/RecoveryTargetHandler.java b/server/src/main/java/org/opensearch/indices/recovery/RecoveryTargetHandler.java index b43253c32d844..ac28dabf815a5 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/RecoveryTargetHandler.java +++ b/server/src/main/java/org/opensearch/indices/recovery/RecoveryTargetHandler.java @@ -31,7 +31,7 @@ package org.opensearch.indices.recovery; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.index.seqno.ReplicationTracker; import org.opensearch.index.seqno.RetentionLeases; import org.opensearch.index.store.Store; diff --git a/server/src/main/java/org/opensearch/indices/recovery/RemoteRecoveryTargetHandler.java b/server/src/main/java/org/opensearch/indices/recovery/RemoteRecoveryTargetHandler.java index 35585def29365..2443bb2dd3603 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/RemoteRecoveryTargetHandler.java +++ b/server/src/main/java/org/opensearch/indices/recovery/RemoteRecoveryTargetHandler.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.Writeable; diff --git a/server/src/main/java/org/opensearch/indices/recovery/RemoteStorePeerRecoverySourceHandler.java b/server/src/main/java/org/opensearch/indices/recovery/RemoteStorePeerRecoverySourceHandler.java index 6af4ce7461633..57e19756b6490 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/RemoteStorePeerRecoverySourceHandler.java +++ b/server/src/main/java/org/opensearch/indices/recovery/RemoteStorePeerRecoverySourceHandler.java @@ -9,7 +9,7 @@ package org.opensearch.indices.recovery; import org.apache.lucene.index.IndexCommit; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.common.concurrent.GatedCloseable; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/main/java/org/opensearch/indices/recovery/RetryableTransportClient.java b/server/src/main/java/org/opensearch/indices/recovery/RetryableTransportClient.java index 7de2d0e2fb3d4..92590f2b1f27a 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/RetryableTransportClient.java +++ b/server/src/main/java/org/opensearch/indices/recovery/RetryableTransportClient.java @@ -10,7 +10,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.support.RetryableAction; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/main/java/org/opensearch/indices/replication/OngoingSegmentReplications.java b/server/src/main/java/org/opensearch/indices/replication/OngoingSegmentReplications.java index 4712ae6c18759..39e9d8fc7ff24 100644 --- a/server/src/main/java/org/opensearch/indices/replication/OngoingSegmentReplications.java +++ b/server/src/main/java/org/opensearch/indices/replication/OngoingSegmentReplications.java @@ -12,7 +12,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.util.concurrent.ConcurrentCollections; import org.opensearch.index.IndexService; diff --git a/server/src/main/java/org/opensearch/indices/replication/PrimaryShardReplicationSource.java b/server/src/main/java/org/opensearch/indices/replication/PrimaryShardReplicationSource.java index b1a6cab2ba57a..3f27912c48e95 100644 --- a/server/src/main/java/org/opensearch/indices/replication/PrimaryShardReplicationSource.java +++ b/server/src/main/java/org/opensearch/indices/replication/PrimaryShardReplicationSource.java @@ -10,7 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.index.shard.IndexShard; diff --git a/server/src/main/java/org/opensearch/indices/replication/RemoteSegmentFileChunkWriter.java b/server/src/main/java/org/opensearch/indices/replication/RemoteSegmentFileChunkWriter.java index d96f9544e5734..e0451f733d044 100644 --- a/server/src/main/java/org/opensearch/indices/replication/RemoteSegmentFileChunkWriter.java +++ b/server/src/main/java/org/opensearch/indices/replication/RemoteSegmentFileChunkWriter.java @@ -10,7 +10,7 @@ import org.apache.lucene.store.RateLimiter; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.index.shard.ShardId; diff --git a/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java b/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java index 7f444d0031533..2b22af070023a 100644 --- a/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java +++ b/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java @@ -14,7 +14,7 @@ import org.apache.lucene.store.FilterDirectory; import org.apache.lucene.store.IOContext; import org.apache.lucene.util.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.index.shard.IndexShard; import org.opensearch.index.shard.IndexShardState; import org.opensearch.index.store.RemoteSegmentStoreDirectory; diff --git a/server/src/main/java/org/opensearch/indices/replication/SegmentFileTransferHandler.java b/server/src/main/java/org/opensearch/indices/replication/SegmentFileTransferHandler.java index aec7908ef1165..5b05572b6d4d2 100644 --- a/server/src/main/java/org/opensearch/indices/replication/SegmentFileTransferHandler.java +++ b/server/src/main/java/org/opensearch/indices/replication/SegmentFileTransferHandler.java @@ -15,7 +15,7 @@ import org.apache.lucene.store.IndexInput; import org.apache.lucene.util.ArrayUtil; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; diff --git a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationSource.java b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationSource.java index 79b9b31e3d5c3..92175c2333e29 100644 --- a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationSource.java +++ b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationSource.java @@ -8,7 +8,7 @@ package org.opensearch.indices.replication; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.util.CancellableThreads.ExecutionCancelledException; import org.opensearch.index.shard.IndexShard; import org.opensearch.index.store.StoreFileMetadata; diff --git a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationSourceHandler.java b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationSourceHandler.java index 110fe9aafbf5f..0be1fb878caa9 100644 --- a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationSourceHandler.java +++ b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationSourceHandler.java @@ -10,7 +10,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.routing.IndexShardRoutingTable; diff --git a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTarget.java b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTarget.java index 3a84163bb979d..91c09e86f2602 100644 --- a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTarget.java +++ b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTarget.java @@ -15,7 +15,7 @@ import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.OpenSearchCorruptionException; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.common.UUIDs; import org.opensearch.core.common.bytes.BytesReference; diff --git a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTargetService.java b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTargetService.java index 84d6a722e572e..bf7fa8453dba7 100644 --- a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTargetService.java +++ b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTargetService.java @@ -12,7 +12,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchCorruptionException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ChannelActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.routing.ShardRouting; diff --git a/server/src/main/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointAction.java b/server/src/main/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointAction.java index e77f9e12212fc..e5ff99e9c2c2e 100644 --- a/server/src/main/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointAction.java +++ b/server/src/main/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointAction.java @@ -13,7 +13,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.replication.ReplicationResponse; import org.opensearch.action.support.replication.ReplicationTask; diff --git a/server/src/main/java/org/opensearch/indices/replication/common/ReplicationRequestTracker.java b/server/src/main/java/org/opensearch/indices/replication/common/ReplicationRequestTracker.java index 0b0d20fc9f17e..9442d673ff760 100644 --- a/server/src/main/java/org/opensearch/indices/replication/common/ReplicationRequestTracker.java +++ b/server/src/main/java/org/opensearch/indices/replication/common/ReplicationRequestTracker.java @@ -32,7 +32,7 @@ package org.opensearch.indices.replication.common; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.Nullable; import org.opensearch.common.util.concurrent.OpenSearchExecutors; import org.opensearch.common.util.concurrent.ListenableFuture; diff --git a/server/src/main/java/org/opensearch/indices/replication/common/ReplicationTarget.java b/server/src/main/java/org/opensearch/indices/replication/common/ReplicationTarget.java index 0e06791768745..fdcb9a7ab2526 100644 --- a/server/src/main/java/org/opensearch/indices/replication/common/ReplicationTarget.java +++ b/server/src/main/java/org/opensearch/indices/replication/common/ReplicationTarget.java @@ -12,7 +12,7 @@ import org.apache.lucene.store.RateLimiter; import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ChannelActionListener; import org.opensearch.common.CheckedFunction; import org.opensearch.common.Nullable; diff --git a/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java b/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java index 22c5c923e6322..1a562b6f3e51b 100644 --- a/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java +++ b/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionType; import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/ingest/IngestInfo.java b/server/src/main/java/org/opensearch/ingest/IngestInfo.java index 122aa4ab92002..2efd0a2a8e66c 100644 --- a/server/src/main/java/org/opensearch/ingest/IngestInfo.java +++ b/server/src/main/java/org/opensearch/ingest/IngestInfo.java @@ -35,7 +35,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; import java.util.List; diff --git a/server/src/main/java/org/opensearch/ingest/IngestService.java b/server/src/main/java/org/opensearch/ingest/IngestService.java index 52ced9c051d14..7850427844f74 100644 --- a/server/src/main/java/org/opensearch/ingest/IngestService.java +++ b/server/src/main/java/org/opensearch/ingest/IngestService.java @@ -38,7 +38,7 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.ExceptionsHelper; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.bulk.TransportBulkAction; import org.opensearch.action.index.IndexRequest; @@ -71,7 +71,7 @@ import org.opensearch.index.IndexSettings; import org.opensearch.index.VersionType; import org.opensearch.index.analysis.AnalysisRegistry; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import org.opensearch.plugins.IngestPlugin; import org.opensearch.script.ScriptService; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/main/java/org/opensearch/monitor/jvm/JvmInfo.java b/server/src/main/java/org/opensearch/monitor/jvm/JvmInfo.java index 9eafd80203a87..7d4801d43d0fc 100644 --- a/server/src/main/java/org/opensearch/monitor/jvm/JvmInfo.java +++ b/server/src/main/java/org/opensearch/monitor/jvm/JvmInfo.java @@ -41,7 +41,7 @@ import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; import java.lang.management.GarbageCollectorMXBean; diff --git a/server/src/main/java/org/opensearch/monitor/jvm/JvmService.java b/server/src/main/java/org/opensearch/monitor/jvm/JvmService.java index d59120063e338..548a5fb3650c1 100644 --- a/server/src/main/java/org/opensearch/monitor/jvm/JvmService.java +++ b/server/src/main/java/org/opensearch/monitor/jvm/JvmService.java @@ -38,7 +38,7 @@ import org.opensearch.common.settings.Setting.Property; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; /** * Service for monitoring the JVM diff --git a/server/src/main/java/org/opensearch/monitor/os/OsInfo.java b/server/src/main/java/org/opensearch/monitor/os/OsInfo.java index cc19e4a82aed8..8e95e66f8d8ae 100644 --- a/server/src/main/java/org/opensearch/monitor/os/OsInfo.java +++ b/server/src/main/java/org/opensearch/monitor/os/OsInfo.java @@ -36,7 +36,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.unit.TimeValue; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/monitor/os/OsService.java b/server/src/main/java/org/opensearch/monitor/os/OsService.java index 00e4bb1365b71..5ae2f4f990252 100644 --- a/server/src/main/java/org/opensearch/monitor/os/OsService.java +++ b/server/src/main/java/org/opensearch/monitor/os/OsService.java @@ -40,7 +40,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.SingleObjectCache; import org.opensearch.common.util.concurrent.OpenSearchExecutors; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/monitor/process/ProcessInfo.java b/server/src/main/java/org/opensearch/monitor/process/ProcessInfo.java index 8664deee63d3e..b764864117f13 100644 --- a/server/src/main/java/org/opensearch/monitor/process/ProcessInfo.java +++ b/server/src/main/java/org/opensearch/monitor/process/ProcessInfo.java @@ -36,7 +36,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.unit.TimeValue; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/monitor/process/ProcessService.java b/server/src/main/java/org/opensearch/monitor/process/ProcessService.java index 538f546bd98ee..c659724edf24f 100644 --- a/server/src/main/java/org/opensearch/monitor/process/ProcessService.java +++ b/server/src/main/java/org/opensearch/monitor/process/ProcessService.java @@ -39,7 +39,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.SingleObjectCache; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; /** * The service for the process diff --git a/server/src/main/java/org/opensearch/persistent/AllocatedPersistentTask.java b/server/src/main/java/org/opensearch/persistent/AllocatedPersistentTask.java index e5af66dd5054f..6006304f206a2 100644 --- a/server/src/main/java/org/opensearch/persistent/AllocatedPersistentTask.java +++ b/server/src/main/java/org/opensearch/persistent/AllocatedPersistentTask.java @@ -34,12 +34,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; import org.opensearch.common.Nullable; import org.opensearch.common.unit.TimeValue; import org.opensearch.tasks.CancellableTask; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskManager; import java.util.Map; diff --git a/server/src/main/java/org/opensearch/persistent/CompletionPersistentTaskAction.java b/server/src/main/java/org/opensearch/persistent/CompletionPersistentTaskAction.java index 9ef1749c077c9..e89f42a68bf11 100644 --- a/server/src/main/java/org/opensearch/persistent/CompletionPersistentTaskAction.java +++ b/server/src/main/java/org/opensearch/persistent/CompletionPersistentTaskAction.java @@ -31,7 +31,7 @@ package org.opensearch.persistent; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/persistent/PersistentTaskResponse.java b/server/src/main/java/org/opensearch/persistent/PersistentTaskResponse.java index b0fe789badb5e..c52b5574ecf5e 100644 --- a/server/src/main/java/org/opensearch/persistent/PersistentTaskResponse.java +++ b/server/src/main/java/org/opensearch/persistent/PersistentTaskResponse.java @@ -31,7 +31,7 @@ package org.opensearch.persistent; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask; diff --git a/server/src/main/java/org/opensearch/persistent/PersistentTasksClusterService.java b/server/src/main/java/org/opensearch/persistent/PersistentTasksClusterService.java index bce3095d0c30d..ea7b1cb89f08e 100644 --- a/server/src/main/java/org/opensearch/persistent/PersistentTasksClusterService.java +++ b/server/src/main/java/org/opensearch/persistent/PersistentTasksClusterService.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.ResourceAlreadyExistsException; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateListener; diff --git a/server/src/main/java/org/opensearch/persistent/PersistentTasksExecutor.java b/server/src/main/java/org/opensearch/persistent/PersistentTasksExecutor.java index 08a509af0b307..09d98a8dff85a 100644 --- a/server/src/main/java/org/opensearch/persistent/PersistentTasksExecutor.java +++ b/server/src/main/java/org/opensearch/persistent/PersistentTasksExecutor.java @@ -37,7 +37,7 @@ import org.opensearch.common.Nullable; import org.opensearch.persistent.PersistentTasksCustomMetadata.Assignment; import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.util.Map; import java.util.function.Predicate; diff --git a/server/src/main/java/org/opensearch/persistent/PersistentTasksNodeService.java b/server/src/main/java/org/opensearch/persistent/PersistentTasksNodeService.java index 9f6098e4fae8e..c44eb7d6a0ef1 100644 --- a/server/src/main/java/org/opensearch/persistent/PersistentTasksNodeService.java +++ b/server/src/main/java/org/opensearch/persistent/PersistentTasksNodeService.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterStateListener; @@ -47,7 +47,7 @@ import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskAwareRequest; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskManager; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/persistent/PersistentTasksService.java b/server/src/main/java/org/opensearch/persistent/PersistentTasksService.java index 224943ce8ce38..36c649a0014b0 100644 --- a/server/src/main/java/org/opensearch/persistent/PersistentTasksService.java +++ b/server/src/main/java/org/opensearch/persistent/PersistentTasksService.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse; @@ -47,7 +47,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.node.NodeClosedException; import org.opensearch.persistent.PersistentTasksCustomMetadata.PersistentTask; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import java.util.function.Predicate; diff --git a/server/src/main/java/org/opensearch/persistent/RemovePersistentTaskAction.java b/server/src/main/java/org/opensearch/persistent/RemovePersistentTaskAction.java index b9d9ea8f51fca..0702a7542df2e 100644 --- a/server/src/main/java/org/opensearch/persistent/RemovePersistentTaskAction.java +++ b/server/src/main/java/org/opensearch/persistent/RemovePersistentTaskAction.java @@ -31,7 +31,7 @@ package org.opensearch.persistent; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/persistent/StartPersistentTaskAction.java b/server/src/main/java/org/opensearch/persistent/StartPersistentTaskAction.java index b607bd7441858..d2d2dd0837d9f 100644 --- a/server/src/main/java/org/opensearch/persistent/StartPersistentTaskAction.java +++ b/server/src/main/java/org/opensearch/persistent/StartPersistentTaskAction.java @@ -31,7 +31,7 @@ package org.opensearch.persistent; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/persistent/UpdatePersistentTaskStatusAction.java b/server/src/main/java/org/opensearch/persistent/UpdatePersistentTaskStatusAction.java index 32c8961120663..715b00891dea6 100644 --- a/server/src/main/java/org/opensearch/persistent/UpdatePersistentTaskStatusAction.java +++ b/server/src/main/java/org/opensearch/persistent/UpdatePersistentTaskStatusAction.java @@ -31,7 +31,7 @@ package org.opensearch.persistent; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/main/java/org/opensearch/plugins/ActionPlugin.java b/server/src/main/java/org/opensearch/plugins/ActionPlugin.java index 031ac7d068ef9..2f17e6d0216ec 100644 --- a/server/src/main/java/org/opensearch/plugins/ActionPlugin.java +++ b/server/src/main/java/org/opensearch/plugins/ActionPlugin.java @@ -34,7 +34,7 @@ import org.opensearch.action.ActionType; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.RequestValidators; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; diff --git a/server/src/main/java/org/opensearch/plugins/PluginsService.java b/server/src/main/java/org/opensearch/plugins/PluginsService.java index 67ce664c629ec..832e8f1da97f6 100644 --- a/server/src/main/java/org/opensearch/plugins/PluginsService.java +++ b/server/src/main/java/org/opensearch/plugins/PluginsService.java @@ -51,7 +51,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.common.Strings; import org.opensearch.index.IndexModule; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import org.opensearch.threadpool.ExecutorBuilder; import org.opensearch.transport.TransportSettings; diff --git a/server/src/main/java/org/opensearch/repositories/FilterRepository.java b/server/src/main/java/org/opensearch/repositories/FilterRepository.java index 52e7f374507d4..a0370f93b9c89 100644 --- a/server/src/main/java/org/opensearch/repositories/FilterRepository.java +++ b/server/src/main/java/org/opensearch/repositories/FilterRepository.java @@ -33,7 +33,7 @@ import org.apache.lucene.index.IndexCommit; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateUpdateTask; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/server/src/main/java/org/opensearch/repositories/RepositoriesService.java b/server/src/main/java/org/opensearch/repositories/RepositoriesService.java index b113a8e32c40e..e332e8522feca 100644 --- a/server/src/main/java/org/opensearch/repositories/RepositoriesService.java +++ b/server/src/main/java/org/opensearch/repositories/RepositoriesService.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest; import org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest; diff --git a/server/src/main/java/org/opensearch/repositories/Repository.java b/server/src/main/java/org/opensearch/repositories/Repository.java index 683177b3c3639..16183d31106b9 100644 --- a/server/src/main/java/org/opensearch/repositories/Repository.java +++ b/server/src/main/java/org/opensearch/repositories/Repository.java @@ -33,7 +33,7 @@ import org.apache.lucene.index.IndexCommit; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateUpdateTask; import org.opensearch.cluster.SnapshotsInProgress; diff --git a/server/src/main/java/org/opensearch/repositories/VerifyNodeRepositoryAction.java b/server/src/main/java/org/opensearch/repositories/VerifyNodeRepositoryAction.java index 1f0a5060962c6..e394fe088426b 100644 --- a/server/src/main/java/org/opensearch/repositories/VerifyNodeRepositoryAction.java +++ b/server/src/main/java/org/opensearch/repositories/VerifyNodeRepositoryAction.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java index d66a8a3caa480..b85437c40fa4f 100644 --- a/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java @@ -47,7 +47,7 @@ import org.apache.lucene.util.BytesRef; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.StepListener; import org.opensearch.action.support.GroupedActionListener; @@ -79,7 +79,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.lifecycle.AbstractLifecycleComponent; -import org.opensearch.common.compress.Compressor; +import org.opensearch.core.common.compress.Compressor; import org.opensearch.common.compress.CompressorFactory; import org.opensearch.common.compress.CompressorType; import org.opensearch.core.common.compress.NotXContentException; diff --git a/server/src/main/java/org/opensearch/repositories/blobstore/ChecksumBlobStoreFormat.java b/server/src/main/java/org/opensearch/repositories/blobstore/ChecksumBlobStoreFormat.java index a138bfc8a7044..01b15b7d3dd0f 100644 --- a/server/src/main/java/org/opensearch/repositories/blobstore/ChecksumBlobStoreFormat.java +++ b/server/src/main/java/org/opensearch/repositories/blobstore/ChecksumBlobStoreFormat.java @@ -43,7 +43,7 @@ import org.opensearch.cluster.metadata.Metadata; import org.opensearch.common.CheckedFunction; import org.opensearch.common.blobstore.BlobContainer; -import org.opensearch.common.compress.Compressor; +import org.opensearch.core.common.compress.Compressor; import org.opensearch.common.io.Streams; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.lucene.store.ByteArrayIndexInput; diff --git a/server/src/main/java/org/opensearch/repositories/blobstore/FileRestoreContext.java b/server/src/main/java/org/opensearch/repositories/blobstore/FileRestoreContext.java index 080485f750173..a7eea3ab534a3 100644 --- a/server/src/main/java/org/opensearch/repositories/blobstore/FileRestoreContext.java +++ b/server/src/main/java/org/opensearch/repositories/blobstore/FileRestoreContext.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.lucene.Lucene; import org.opensearch.common.util.iterable.Iterables; import org.opensearch.core.index.shard.ShardId; diff --git a/server/src/main/java/org/opensearch/rest/action/RestActionListener.java b/server/src/main/java/org/opensearch/rest/action/RestActionListener.java index d1c1c98b1b827..846265b19e726 100644 --- a/server/src/main/java/org/opensearch/rest/action/RestActionListener.java +++ b/server/src/main/java/org/opensearch/rest/action/RestActionListener.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestChannel; diff --git a/server/src/main/java/org/opensearch/rest/action/RestCancellableNodeClient.java b/server/src/main/java/org/opensearch/rest/action/RestCancellableNodeClient.java index ad84b6db0ed3e..57897800f29db 100644 --- a/server/src/main/java/org/opensearch/rest/action/RestCancellableNodeClient.java +++ b/server/src/main/java/org/opensearch/rest/action/RestCancellableNodeClient.java @@ -32,9 +32,9 @@ package org.opensearch.rest.action; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; import org.opensearch.client.Client; @@ -43,7 +43,7 @@ import org.opensearch.client.node.NodeClient; import org.opensearch.http.HttpChannel; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.util.ArrayList; import java.util.HashSet; diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestCancelTasksAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestCancelTasksAction.java index 379c7ac2fc570..872e3f8716ea5 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestCancelTasksAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestCancelTasksAction.java @@ -38,7 +38,7 @@ import org.opensearch.core.common.Strings; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestRequest; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.List; diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestGetTaskAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestGetTaskAction.java index 963ab43acef48..4d711aa663249 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestGetTaskAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestGetTaskAction.java @@ -38,7 +38,7 @@ import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestRequest; import org.opensearch.rest.action.RestToXContentListener; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.List; diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestListTasksAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestListTasksAction.java index cdca1ae975ae7..895133bc5a722 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestListTasksAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestListTasksAction.java @@ -32,7 +32,7 @@ package org.opensearch.rest.action.admin.cluster; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.client.node.NodeClient; @@ -48,7 +48,7 @@ import org.opensearch.core.rest.RestStatus; import org.opensearch.rest.action.RestBuilderListener; import org.opensearch.rest.action.RestToXContentListener; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; import java.util.List; diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestIndicesAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestIndicesAction.java index a424f52c42b92..0b4dc78726560 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestIndicesAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestIndicesAction.java @@ -33,8 +33,8 @@ package org.opensearch.rest.action.cat; import org.opensearch.OpenSearchParseException; -import org.opensearch.action.ActionListener; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.state.ClusterStateRequest; diff --git a/server/src/main/java/org/opensearch/script/ScriptService.java b/server/src/main/java/org/opensearch/script/ScriptService.java index 11e72ee6a8b66..01a30d997b71b 100644 --- a/server/src/main/java/org/opensearch/script/ScriptService.java +++ b/server/src/main/java/org/opensearch/script/ScriptService.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest; import org.opensearch.action.admin.cluster.storedscripts.GetStoredScriptRequest; import org.opensearch.action.admin.cluster.storedscripts.PutStoredScriptRequest; diff --git a/server/src/main/java/org/opensearch/script/StoredScriptSource.java b/server/src/main/java/org/opensearch/script/StoredScriptSource.java index 2d181866c9518..0ff44b3af890a 100644 --- a/server/src/main/java/org/opensearch/script/StoredScriptSource.java +++ b/server/src/main/java/org/opensearch/script/StoredScriptSource.java @@ -35,14 +35,14 @@ import org.opensearch.cluster.AbstractDiffable; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.Diff; +import org.opensearch.common.logging.DeprecationLogger; +import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.core.ParseField; import org.opensearch.core.common.ParsingException; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.logging.DeprecationLogger; -import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; @@ -50,7 +50,6 @@ import org.opensearch.core.xcontent.ObjectParser.ValueType; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.XContentParser.Token; @@ -123,7 +122,7 @@ private void setSource(XContentParser parser) { try { if (parser.currentToken() == Token.START_OBJECT) { // this is really for search templates, that need to be converted to json format - XContentBuilder builder = XContentFactory.jsonBuilder(); + XContentBuilder builder = MediaTypeRegistry.JSON.contentBuilder(); source = builder.copyCurrentStructure(parser).toString(); options.put(Script.CONTENT_TYPE_OPTION, MediaTypeRegistry.JSON.mediaType()); } else { diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index d24e5a1aff6c4..a2e17df4c61e3 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -37,18 +37,18 @@ import org.opensearch.Version; import org.opensearch.action.OriginalIndices; import org.opensearch.common.Nullable; +import org.opensearch.common.compress.CompressorFactory; +import org.opensearch.common.document.DocumentField; +import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.common.ParsingException; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.compress.CompressorFactory; -import org.opensearch.common.document.DocumentField; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.common.text.Text; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.core.ParseField; import org.opensearch.core.index.shard.ShardId; +import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ConstructingObjectParser; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ObjectParser; diff --git a/server/src/main/java/org/opensearch/search/SearchService.java b/server/src/main/java/org/opensearch/search/SearchService.java index 9a116dd0d16dc..184bc0fb3ab3b 100644 --- a/server/src/main/java/org/opensearch/search/SearchService.java +++ b/server/src/main/java/org/opensearch/search/SearchService.java @@ -37,7 +37,7 @@ import org.apache.lucene.search.FieldDoc; import org.apache.lucene.search.TopDocs; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.OriginalIndices; import org.opensearch.action.search.DeletePitInfo; diff --git a/server/src/main/java/org/opensearch/search/aggregations/support/AggregationInfo.java b/server/src/main/java/org/opensearch/search/aggregations/support/AggregationInfo.java index 6801aacf095c6..629472a5f770b 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/support/AggregationInfo.java +++ b/server/src/main/java/org/opensearch/search/aggregations/support/AggregationInfo.java @@ -35,7 +35,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; import java.util.Collections; diff --git a/server/src/main/java/org/opensearch/search/aggregations/support/AggregationUsageService.java b/server/src/main/java/org/opensearch/search/aggregations/support/AggregationUsageService.java index eba64998014e2..7685ec5ff876f 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/support/AggregationUsageService.java +++ b/server/src/main/java/org/opensearch/search/aggregations/support/AggregationUsageService.java @@ -32,7 +32,7 @@ package org.opensearch.search.aggregations.support; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.util.HashMap; import java.util.Map; diff --git a/server/src/main/java/org/opensearch/search/dfs/DfsPhase.java b/server/src/main/java/org/opensearch/search/dfs/DfsPhase.java index 5094145ea1c6e..d4b7768186027 100644 --- a/server/src/main/java/org/opensearch/search/dfs/DfsPhase.java +++ b/server/src/main/java/org/opensearch/search/dfs/DfsPhase.java @@ -40,7 +40,7 @@ import org.apache.lucene.search.TermStatistics; import org.opensearch.search.internal.SearchContext; import org.opensearch.search.rescore.RescoreContext; -import org.opensearch.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskCancelledException; import java.io.IOException; import java.util.HashMap; diff --git a/server/src/main/java/org/opensearch/search/fetch/FetchPhase.java b/server/src/main/java/org/opensearch/search/fetch/FetchPhase.java index 67c6eeae02271..94ed124f99176 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchPhase.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchPhase.java @@ -72,7 +72,7 @@ import org.opensearch.search.internal.SearchContext; import org.opensearch.search.lookup.SearchLookup; import org.opensearch.search.lookup.SourceLookup; -import org.opensearch.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskCancelledException; import java.io.IOException; import java.util.ArrayList; diff --git a/server/src/main/java/org/opensearch/search/fetch/ShardFetchRequest.java b/server/src/main/java/org/opensearch/search/fetch/ShardFetchRequest.java index 017e74a12b61c..d3237eabca3aa 100644 --- a/server/src/main/java/org/opensearch/search/fetch/ShardFetchRequest.java +++ b/server/src/main/java/org/opensearch/search/fetch/ShardFetchRequest.java @@ -44,7 +44,7 @@ import org.opensearch.search.internal.ShardSearchRequest; import org.opensearch.search.internal.ShardSearchContextId; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.transport.TransportRequest; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/search/internal/InternalScrollSearchRequest.java b/server/src/main/java/org/opensearch/search/internal/InternalScrollSearchRequest.java index 6c407e6ba3401..590581574888e 100644 --- a/server/src/main/java/org/opensearch/search/internal/InternalScrollSearchRequest.java +++ b/server/src/main/java/org/opensearch/search/internal/InternalScrollSearchRequest.java @@ -38,7 +38,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.search.Scroll; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.transport.TransportRequest; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/search/internal/ShardSearchRequest.java b/server/src/main/java/org/opensearch/search/internal/ShardSearchRequest.java index d2f6bc234e752..164a64384d307 100644 --- a/server/src/main/java/org/opensearch/search/internal/ShardSearchRequest.java +++ b/server/src/main/java/org/opensearch/search/internal/ShardSearchRequest.java @@ -66,7 +66,7 @@ import org.opensearch.search.query.QuerySearchResult; import org.opensearch.search.sort.FieldSortBuilder; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.transport.TransportRequest; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/search/pipeline/SearchPipelineInfo.java b/server/src/main/java/org/opensearch/search/pipeline/SearchPipelineInfo.java index b2075a51ff732..a7cc8c052a630 100644 --- a/server/src/main/java/org/opensearch/search/pipeline/SearchPipelineInfo.java +++ b/server/src/main/java/org/opensearch/search/pipeline/SearchPipelineInfo.java @@ -12,7 +12,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; import java.util.Collections; diff --git a/server/src/main/java/org/opensearch/search/pipeline/SearchPipelineService.java b/server/src/main/java/org/opensearch/search/pipeline/SearchPipelineService.java index 1066d836e5183..30ea59a223760 100644 --- a/server/src/main/java/org/opensearch/search/pipeline/SearchPipelineService.java +++ b/server/src/main/java/org/opensearch/search/pipeline/SearchPipelineService.java @@ -13,7 +13,7 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchParseException; import org.opensearch.ResourceNotFoundException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.DeleteSearchPipelineRequest; import org.opensearch.action.search.PutSearchPipelineRequest; import org.opensearch.action.search.SearchRequest; @@ -41,7 +41,7 @@ import org.opensearch.index.IndexSettings; import org.opensearch.index.analysis.AnalysisRegistry; import org.opensearch.ingest.ConfigurationUtils; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import org.opensearch.plugins.SearchPipelinePlugin; import org.opensearch.script.ScriptService; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/main/java/org/opensearch/search/query/QueryPhase.java b/server/src/main/java/org/opensearch/search/query/QueryPhase.java index 8418fdca2f777..a3f84846bd1ac 100644 --- a/server/src/main/java/org/opensearch/search/query/QueryPhase.java +++ b/server/src/main/java/org/opensearch/search/query/QueryPhase.java @@ -67,7 +67,7 @@ import org.opensearch.search.rescore.RescoreProcessor; import org.opensearch.search.sort.SortAndFormats; import org.opensearch.search.suggest.SuggestProcessor; -import org.opensearch.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskCancelledException; import org.opensearch.threadpool.ThreadPool; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/search/query/QuerySearchRequest.java b/server/src/main/java/org/opensearch/search/query/QuerySearchRequest.java index 776b8fbb9fca2..0c1e7e06ea42f 100644 --- a/server/src/main/java/org/opensearch/search/query/QuerySearchRequest.java +++ b/server/src/main/java/org/opensearch/search/query/QuerySearchRequest.java @@ -44,7 +44,7 @@ import org.opensearch.search.internal.ShardSearchContextId; import org.opensearch.search.internal.ShardSearchRequest; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.transport.TransportRequest; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/snapshots/InternalSnapshotsInfoService.java b/server/src/main/java/org/opensearch/snapshots/InternalSnapshotsInfoService.java index 3c7a14fb2854a..45867a65216a6 100644 --- a/server/src/main/java/org/opensearch/snapshots/InternalSnapshotsInfoService.java +++ b/server/src/main/java/org/opensearch/snapshots/InternalSnapshotsInfoService.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateListener; diff --git a/server/src/main/java/org/opensearch/snapshots/RestoreService.java b/server/src/main/java/org/opensearch/snapshots/RestoreService.java index 119e632928cc7..67e0f7d4bba54 100644 --- a/server/src/main/java/org/opensearch/snapshots/RestoreService.java +++ b/server/src/main/java/org/opensearch/snapshots/RestoreService.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.admin.cluster.remotestore.restore.RestoreRemoteStoreRequest; import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; @@ -134,7 +134,7 @@ *

* Restore operation is performed in several stages. *

- * First {@link #restoreSnapshot(RestoreSnapshotRequest, org.opensearch.action.ActionListener)} + * First {@link #restoreSnapshot(RestoreSnapshotRequest, ActionListener)} * method reads information about snapshot and metadata from repository. In update cluster state task it checks restore * preconditions, restores global state if needed, creates {@link RestoreInProgress} record with list of shards that needs * to be restored and adds this shard to the routing table using diff --git a/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java b/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java index d8f9b8e1b984f..ca98d079e4516 100644 --- a/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java +++ b/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.lucene.index.IndexCommit; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterStateListener; import org.opensearch.cluster.SnapshotsInProgress; diff --git a/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java b/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java index 71dba24717ed1..6e9140a813638 100644 --- a/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRunnable; import org.opensearch.action.StepListener; import org.opensearch.action.admin.cluster.snapshots.clone.CloneSnapshotRequest; diff --git a/server/src/main/java/org/opensearch/snapshots/UpdateIndexShardSnapshotStatusResponse.java b/server/src/main/java/org/opensearch/snapshots/UpdateIndexShardSnapshotStatusResponse.java index 0ae7a8367d1a8..6bcbc932f3eff 100644 --- a/server/src/main/java/org/opensearch/snapshots/UpdateIndexShardSnapshotStatusResponse.java +++ b/server/src/main/java/org/opensearch/snapshots/UpdateIndexShardSnapshotStatusResponse.java @@ -31,7 +31,7 @@ package org.opensearch.snapshots; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamOutput; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/tasks/CancellableTask.java b/server/src/main/java/org/opensearch/tasks/CancellableTask.java index dc28c26700e6c..22806a749c686 100644 --- a/server/src/main/java/org/opensearch/tasks/CancellableTask.java +++ b/server/src/main/java/org/opensearch/tasks/CancellableTask.java @@ -35,6 +35,7 @@ import org.opensearch.common.Nullable; import org.opensearch.common.SetOnce; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.tasks.TaskId; import java.util.Map; diff --git a/server/src/main/java/org/opensearch/tasks/Task.java b/server/src/main/java/org/opensearch/tasks/Task.java index 3fa62ebbdcbed..dcd7fc581a8fd 100644 --- a/server/src/main/java/org/opensearch/tasks/Task.java +++ b/server/src/main/java/org/opensearch/tasks/Task.java @@ -35,10 +35,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionResponse; -import org.opensearch.action.NotifyOnceListener; -import org.opensearch.cluster.node.DiscoveryNode; +import org.opensearch.core.action.ActionResponse; +import org.opensearch.core.action.NotifyOnceListener; import org.opensearch.core.common.io.stream.NamedWriteable; +import org.opensearch.core.tasks.TaskId; +import org.opensearch.core.tasks.resourcetracker.ResourceStats; +import org.opensearch.core.tasks.resourcetracker.ResourceStatsType; +import org.opensearch.core.tasks.resourcetracker.ResourceUsageInfo; +import org.opensearch.core.tasks.resourcetracker.ResourceUsageMetric; +import org.opensearch.core.tasks.resourcetracker.TaskResourceStats; +import org.opensearch.core.tasks.resourcetracker.TaskResourceUsage; +import org.opensearch.core.tasks.resourcetracker.TaskThreadUsage; +import org.opensearch.core.tasks.resourcetracker.ThreadResourceInfo; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentObject; @@ -73,8 +81,6 @@ public class Task { private static final String MAX = "max"; - public static final String THREAD_INFO = "thread_info"; - private final long id; private final String type; @@ -505,13 +511,13 @@ public String getHeader(String header) { return headers.get(header); } - public TaskResult result(DiscoveryNode node, Exception error) throws IOException { - return new TaskResult(taskInfo(node.getId(), true, true), error); + public TaskResult result(final String nodeId, Exception error) throws IOException { + return new TaskResult(taskInfo(nodeId, true, true), error); } - public TaskResult result(DiscoveryNode node, ActionResponse response) throws IOException { + public TaskResult result(final String nodeId, ActionResponse response) throws IOException { if (response instanceof ToXContent) { - return new TaskResult(taskInfo(node.getId(), true, true), (ToXContent) response); + return new TaskResult(taskInfo(nodeId, true, true), (ToXContent) response); } else { throw new IllegalStateException("response has to implement ToXContent to be able to store the results"); } diff --git a/server/src/main/java/org/opensearch/tasks/TaskAwareRequest.java b/server/src/main/java/org/opensearch/tasks/TaskAwareRequest.java index baf2d1d94ea04..6913f6cfc375c 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskAwareRequest.java +++ b/server/src/main/java/org/opensearch/tasks/TaskAwareRequest.java @@ -32,6 +32,8 @@ package org.opensearch.tasks; +import org.opensearch.core.tasks.TaskId; + import java.util.Map; /** diff --git a/server/src/main/java/org/opensearch/tasks/TaskCancellation.java b/server/src/main/java/org/opensearch/tasks/TaskCancellation.java index b718bd2395cc5..9b61b2454b53c 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskCancellation.java +++ b/server/src/main/java/org/opensearch/tasks/TaskCancellation.java @@ -9,7 +9,7 @@ package org.opensearch.tasks; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import java.util.ArrayList; import java.util.List; diff --git a/server/src/main/java/org/opensearch/tasks/TaskCancellationService.java b/server/src/main/java/org/opensearch/tasks/TaskCancellationService.java index a24cdd02bbd30..4f4e002ab9c62 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskCancellationService.java +++ b/server/src/main/java/org/opensearch/tasks/TaskCancellationService.java @@ -36,13 +36,14 @@ import org.apache.logging.log4j.Logger; import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchSecurityException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.support.ChannelActionListener; import org.opensearch.action.support.GroupedActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.EmptyTransportResponseHandler; import org.opensearch.transport.TransportChannel; diff --git a/server/src/main/java/org/opensearch/tasks/TaskInfo.java b/server/src/main/java/org/opensearch/tasks/TaskInfo.java index 3212ed7481b8d..e24c47d7e8dbe 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskInfo.java +++ b/server/src/main/java/org/opensearch/tasks/TaskInfo.java @@ -33,16 +33,18 @@ package org.opensearch.tasks; import org.opensearch.Version; +import org.opensearch.common.unit.TimeValue; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.common.unit.TimeValue; -import org.opensearch.core.xcontent.ConstructingObjectParser; -import org.opensearch.common.xcontent.ObjectParserHelper; import org.opensearch.core.ParseField; +import org.opensearch.core.tasks.TaskId; +import org.opensearch.core.tasks.resourcetracker.TaskResourceStats; +import org.opensearch.core.xcontent.ConstructingObjectParser; import org.opensearch.core.xcontent.MediaTypeRegistry; +import org.opensearch.core.xcontent.ObjectParserHelper; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; diff --git a/server/src/main/java/org/opensearch/tasks/TaskManager.java b/server/src/main/java/org/opensearch/tasks/TaskManager.java index ec59a13dd1999..604085abcc1c7 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskManager.java +++ b/server/src/main/java/org/opensearch/tasks/TaskManager.java @@ -39,9 +39,9 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; -import org.opensearch.action.ActionResponse; -import org.opensearch.action.NotifyOnceListener; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; +import org.opensearch.core.action.NotifyOnceListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterStateApplier; import org.opensearch.cluster.node.DiscoveryNode; @@ -58,6 +58,8 @@ import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.lease.Releasable; import org.opensearch.common.lease.Releasables; +import org.opensearch.core.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TcpChannel; @@ -364,7 +366,7 @@ public void storeResult(Task task, Exception e } final TaskResult taskResult; try { - taskResult = task.result(localNode, error); + taskResult = task.result(localNode.getId(), error); } catch (IOException ex) { logger.warn(() -> new ParameterizedMessage("couldn't store error {}", ExceptionsHelper.detailedMessage(error)), ex); listener.onFailure(ex); @@ -397,7 +399,7 @@ public void storeResult(Task task, Response re } final TaskResult taskResult; try { - taskResult = task.result(localNode, response); + taskResult = task.result(localNode.getId(), response); } catch (IOException ex) { logger.warn(() -> new ParameterizedMessage("couldn't store response {}", response), ex); listener.onFailure(ex); diff --git a/server/src/main/java/org/opensearch/tasks/TaskResourceTrackingService.java b/server/src/main/java/org/opensearch/tasks/TaskResourceTrackingService.java index b4806b531429e..c90735cf934ff 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskResourceTrackingService.java +++ b/server/src/main/java/org/opensearch/tasks/TaskResourceTrackingService.java @@ -21,6 +21,9 @@ import org.opensearch.common.util.concurrent.ConcurrentCollections; import org.opensearch.common.util.concurrent.ConcurrentMapLong; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.tasks.resourcetracker.ResourceStats; +import org.opensearch.core.tasks.resourcetracker.ResourceUsageMetric; +import org.opensearch.core.tasks.resourcetracker.ThreadResourceInfo; import org.opensearch.threadpool.RunnableTaskExecutionListener; import org.opensearch.threadpool.ThreadPool; @@ -30,7 +33,7 @@ import java.util.List; import java.util.Map; -import static org.opensearch.tasks.ResourceStatsType.WORKER_STATS; +import static org.opensearch.core.tasks.resourcetracker.ResourceStatsType.WORKER_STATS; /** * Service that helps track resource usage of tasks running on a node. diff --git a/server/src/main/java/org/opensearch/tasks/TaskResult.java b/server/src/main/java/org/opensearch/tasks/TaskResult.java index 63e24b3175995..345172e8e4fdf 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskResult.java +++ b/server/src/main/java/org/opensearch/tasks/TaskResult.java @@ -41,12 +41,12 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.xcontent.InstantiatingObjectParser; -import org.opensearch.common.xcontent.ObjectParserHelper; +import org.opensearch.core.xcontent.ObjectParserHelper; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentHelper; +import org.opensearch.core.xcontent.XContentHelper; import java.io.IOException; import java.util.Map; @@ -54,9 +54,10 @@ import static java.util.Collections.emptyMap; import static java.util.Objects.requireNonNull; +import static org.opensearch.common.xcontent.XContentHelper.convertToMap; +import static org.opensearch.common.xcontent.XContentHelper.writeRawField; import static org.opensearch.core.xcontent.ConstructingObjectParser.constructorArg; import static org.opensearch.core.xcontent.ConstructingObjectParser.optionalConstructorArg; -import static org.opensearch.common.xcontent.XContentHelper.convertToMap; /** * Information about a running task or a task that stored its result. Running tasks just have a {@link #getTask()} while @@ -91,7 +92,7 @@ public TaskResult(TaskInfo task, Exception error) throws IOException { * Construct a {@linkplain TaskResult} for a task that completed successfully. */ public TaskResult(TaskInfo task, ToXContent response) throws IOException { - this(true, task, null, org.opensearch.core.xcontent.XContentHelper.toXContent(response, Requests.INDEX_CONTENT_TYPE, true)); + this(true, task, null, XContentHelper.toXContent(response, Requests.INDEX_CONTENT_TYPE, true)); } public TaskResult(boolean completed, TaskInfo task, @Nullable BytesReference error, @Nullable BytesReference result) { @@ -181,10 +182,10 @@ public XContentBuilder innerToXContent(XContentBuilder builder, Params params) t task.toXContent(builder, params); builder.endObject(); if (error != null) { - XContentHelper.writeRawField("error", error, builder, params); + writeRawField("error", error, builder, params); } if (response != null) { - XContentHelper.writeRawField("response", response, builder, params); + writeRawField("response", response, builder, params); } return builder; } diff --git a/server/src/main/java/org/opensearch/tasks/TaskResultsService.java b/server/src/main/java/org/opensearch/tasks/TaskResultsService.java index 3dc61635d9ba7..7dcc03e7ede5b 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskResultsService.java +++ b/server/src/main/java/org/opensearch/tasks/TaskResultsService.java @@ -37,7 +37,7 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; import org.opensearch.ResourceAlreadyExistsException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.action.bulk.BackoffPolicy; diff --git a/server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTasksLogger.java b/server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTasksLogger.java index 21cde24bd541d..6f977481852ec 100644 --- a/server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTasksLogger.java +++ b/server/src/main/java/org/opensearch/tasks/consumer/TopNSearchTasksLogger.java @@ -16,7 +16,7 @@ import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.tasks.ResourceStats; +import org.opensearch.core.tasks.resourcetracker.ResourceStats; import org.opensearch.tasks.Task; import java.util.Comparator; diff --git a/server/src/main/java/org/opensearch/threadpool/ThreadPool.java b/server/src/main/java/org/opensearch/threadpool/ThreadPool.java index 0851677bcb13a..fbacb61896ca0 100644 --- a/server/src/main/java/org/opensearch/threadpool/ThreadPool.java +++ b/server/src/main/java/org/opensearch/threadpool/ThreadPool.java @@ -53,7 +53,7 @@ import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.node.Node; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; import java.util.ArrayList; diff --git a/server/src/main/java/org/opensearch/threadpool/ThreadPoolInfo.java b/server/src/main/java/org/opensearch/threadpool/ThreadPoolInfo.java index 5087624ec0b3f..0046f5fe10072 100644 --- a/server/src/main/java/org/opensearch/threadpool/ThreadPoolInfo.java +++ b/server/src/main/java/org/opensearch/threadpool/ThreadPoolInfo.java @@ -35,7 +35,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; import java.util.Collections; diff --git a/server/src/main/java/org/opensearch/transport/CloseableConnection.java b/server/src/main/java/org/opensearch/transport/CloseableConnection.java index b612f2bd17e0f..cd5b9ae1128bc 100644 --- a/server/src/main/java/org/opensearch/transport/CloseableConnection.java +++ b/server/src/main/java/org/opensearch/transport/CloseableConnection.java @@ -32,7 +32,7 @@ package org.opensearch.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.concurrent.CompletableContext; /** diff --git a/server/src/main/java/org/opensearch/transport/ClusterConnectionManager.java b/server/src/main/java/org/opensearch/transport/ClusterConnectionManager.java index 1a4854cfad8db..3c7410a351d53 100644 --- a/server/src/main/java/org/opensearch/transport/ClusterConnectionManager.java +++ b/server/src/main/java/org/opensearch/transport/ClusterConnectionManager.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.AbstractRefCounted; diff --git a/server/src/main/java/org/opensearch/transport/ConnectionManager.java b/server/src/main/java/org/opensearch/transport/ConnectionManager.java index d48f2eb4e0bb1..e018e8209e2be 100644 --- a/server/src/main/java/org/opensearch/transport/ConnectionManager.java +++ b/server/src/main/java/org/opensearch/transport/ConnectionManager.java @@ -32,7 +32,7 @@ package org.opensearch.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import java.io.Closeable; diff --git a/server/src/main/java/org/opensearch/transport/OutboundHandler.java b/server/src/main/java/org/opensearch/transport/OutboundHandler.java index c67a6df8f90f6..fb9fae909902b 100644 --- a/server/src/main/java/org/opensearch/transport/OutboundHandler.java +++ b/server/src/main/java/org/opensearch/transport/OutboundHandler.java @@ -36,8 +36,8 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.Version; -import org.opensearch.action.ActionListener; -import org.opensearch.action.NotifyOnceListener; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.NotifyOnceListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.CheckedSupplier; import org.opensearch.core.common.bytes.BytesReference; diff --git a/server/src/main/java/org/opensearch/transport/ProxyConnectionStrategy.java b/server/src/main/java/org/opensearch/transport/ProxyConnectionStrategy.java index fcaad01e78a50..ed04d51bed662 100644 --- a/server/src/main/java/org/opensearch/transport/ProxyConnectionStrategy.java +++ b/server/src/main/java/org/opensearch/transport/ProxyConnectionStrategy.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodeRole; diff --git a/server/src/main/java/org/opensearch/transport/RemoteClusterAwareClient.java b/server/src/main/java/org/opensearch/transport/RemoteClusterAwareClient.java index ac79b21d73f69..5ec0705efb2f2 100644 --- a/server/src/main/java/org/opensearch/transport/RemoteClusterAwareClient.java +++ b/server/src/main/java/org/opensearch/transport/RemoteClusterAwareClient.java @@ -32,10 +32,10 @@ package org.opensearch.transport; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.client.Client; import org.opensearch.client.support.AbstractClient; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/main/java/org/opensearch/transport/RemoteClusterConnection.java b/server/src/main/java/org/opensearch/transport/RemoteClusterConnection.java index d95c0c647916b..15f380885c112 100644 --- a/server/src/main/java/org/opensearch/transport/RemoteClusterConnection.java +++ b/server/src/main/java/org/opensearch/transport/RemoteClusterConnection.java @@ -31,7 +31,7 @@ package org.opensearch.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.state.ClusterStateAction; import org.opensearch.action.admin.cluster.state.ClusterStateRequest; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; diff --git a/server/src/main/java/org/opensearch/transport/RemoteClusterService.java b/server/src/main/java/org/opensearch/transport/RemoteClusterService.java index 976c4b7043261..f2e0686970464 100644 --- a/server/src/main/java/org/opensearch/transport/RemoteClusterService.java +++ b/server/src/main/java/org/opensearch/transport/RemoteClusterService.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.action.support.GroupedActionListener; import org.opensearch.action.support.IndicesOptions; diff --git a/server/src/main/java/org/opensearch/transport/RemoteConnectionManager.java b/server/src/main/java/org/opensearch/transport/RemoteConnectionManager.java index 4da23175c4a0e..8e4c8b322bea5 100644 --- a/server/src/main/java/org/opensearch/transport/RemoteConnectionManager.java +++ b/server/src/main/java/org/opensearch/transport/RemoteConnectionManager.java @@ -32,7 +32,7 @@ package org.opensearch.transport; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/transport/RemoteConnectionStrategy.java b/server/src/main/java/org/opensearch/transport/RemoteConnectionStrategy.java index 76afeb20d18cf..4f9553322af70 100644 --- a/server/src/main/java/org/opensearch/transport/RemoteConnectionStrategy.java +++ b/server/src/main/java/org/opensearch/transport/RemoteConnectionStrategy.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.lucene.store.AlreadyClosedException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ContextPreservingActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.io.stream.Writeable; diff --git a/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java b/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java index c95a65fadf323..0df8517ec0d8b 100644 --- a/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java +++ b/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.admin.cluster.state.ClusterStateAction; import org.opensearch.action.admin.cluster.state.ClusterStateRequest; diff --git a/server/src/main/java/org/opensearch/transport/TcpChannel.java b/server/src/main/java/org/opensearch/transport/TcpChannel.java index 2e13fb49dcd15..2e721bc0b23af 100644 --- a/server/src/main/java/org/opensearch/transport/TcpChannel.java +++ b/server/src/main/java/org/opensearch/transport/TcpChannel.java @@ -32,7 +32,7 @@ package org.opensearch.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.network.CloseableChannel; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/main/java/org/opensearch/transport/TcpTransport.java b/server/src/main/java/org/opensearch/transport/TcpTransport.java index b99e750366018..24563f36a8689 100644 --- a/server/src/main/java/org/opensearch/transport/TcpTransport.java +++ b/server/src/main/java/org/opensearch/transport/TcpTransport.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ThreadedActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.Booleans; diff --git a/server/src/main/java/org/opensearch/transport/Transport.java b/server/src/main/java/org/opensearch/transport/Transport.java index 26bae24f70f26..247c0d7b9bf73 100644 --- a/server/src/main/java/org/opensearch/transport/Transport.java +++ b/server/src/main/java/org/opensearch/transport/Transport.java @@ -33,7 +33,7 @@ package org.opensearch.transport; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.collect.MapBuilder; import org.opensearch.common.lifecycle.LifecycleComponent; diff --git a/server/src/main/java/org/opensearch/transport/TransportDecompressor.java b/server/src/main/java/org/opensearch/transport/TransportDecompressor.java index 3e53c10c6a069..ca64a3c917d46 100644 --- a/server/src/main/java/org/opensearch/transport/TransportDecompressor.java +++ b/server/src/main/java/org/opensearch/transport/TransportDecompressor.java @@ -37,7 +37,7 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.bytes.ReleasableBytesReference; -import org.opensearch.common.compress.Compressor; +import org.opensearch.core.common.compress.Compressor; import org.opensearch.common.compress.CompressorFactory; import org.opensearch.common.recycler.Recycler; import org.opensearch.common.util.PageCacheRecycler; diff --git a/server/src/main/java/org/opensearch/transport/TransportHandshaker.java b/server/src/main/java/org/opensearch/transport/TransportHandshaker.java index 8ce4f6887cbd9..39ae95db2b84a 100644 --- a/server/src/main/java/org/opensearch/transport/TransportHandshaker.java +++ b/server/src/main/java/org/opensearch/transport/TransportHandshaker.java @@ -32,7 +32,7 @@ package org.opensearch.transport; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; diff --git a/server/src/main/java/org/opensearch/transport/TransportInfo.java b/server/src/main/java/org/opensearch/transport/TransportInfo.java index 308abb2bc28f4..97ca00b8c7981 100644 --- a/server/src/main/java/org/opensearch/transport/TransportInfo.java +++ b/server/src/main/java/org/opensearch/transport/TransportInfo.java @@ -40,7 +40,7 @@ import org.opensearch.core.common.transport.BoundTransportAddress; import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import java.io.IOException; import java.util.HashMap; diff --git a/server/src/main/java/org/opensearch/transport/TransportKeepAlive.java b/server/src/main/java/org/opensearch/transport/TransportKeepAlive.java index 5b542e4080641..7660fff1a4f42 100644 --- a/server/src/main/java/org/opensearch/transport/TransportKeepAlive.java +++ b/server/src/main/java/org/opensearch/transport/TransportKeepAlive.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.AsyncBiFunction; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.lifecycle.Lifecycle; diff --git a/server/src/main/java/org/opensearch/transport/TransportRequest.java b/server/src/main/java/org/opensearch/transport/TransportRequest.java index 3eb465718763e..d9e6e8e8ff61e 100644 --- a/server/src/main/java/org/opensearch/transport/TransportRequest.java +++ b/server/src/main/java/org/opensearch/transport/TransportRequest.java @@ -36,7 +36,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.transport.TransportMessage; import org.opensearch.tasks.TaskAwareRequest; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import java.io.IOException; diff --git a/server/src/main/java/org/opensearch/transport/TransportRequestDeduplicator.java b/server/src/main/java/org/opensearch/transport/TransportRequestDeduplicator.java index eec0310557690..9645b0b36e471 100644 --- a/server/src/main/java/org/opensearch/transport/TransportRequestDeduplicator.java +++ b/server/src/main/java/org/opensearch/transport/TransportRequestDeduplicator.java @@ -32,7 +32,7 @@ package org.opensearch.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.util.concurrent.ConcurrentCollections; import java.util.ArrayList; diff --git a/server/src/main/java/org/opensearch/transport/TransportService.java b/server/src/main/java/org/opensearch/transport/TransportService.java index 61900fa1f0014..9be4b9f14e0bd 100644 --- a/server/src/main/java/org/opensearch/transport/TransportService.java +++ b/server/src/main/java/org/opensearch/transport/TransportService.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchServerException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.ClusterName; @@ -63,7 +63,7 @@ import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException; import org.opensearch.core.transport.TransportResponse; import org.opensearch.node.NodeClosedException; -import org.opensearch.node.ReportingService; +import org.opensearch.core.service.ReportingService; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskManager; import org.opensearch.threadpool.Scheduler; diff --git a/server/src/test/java/org/opensearch/ExceptionSerializationTests.java b/server/src/test/java/org/opensearch/ExceptionSerializationTests.java index da29d90ac3539..d617ecbaa4bd9 100644 --- a/server/src/test/java/org/opensearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/opensearch/ExceptionSerializationTests.java @@ -69,20 +69,22 @@ import org.opensearch.common.collect.Tuple; import org.opensearch.common.io.PathUtils; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.common.util.CancellableThreadsTests; +import org.opensearch.common.util.set.Sets; import org.opensearch.core.common.io.stream.NotSerializableExceptionWrapper; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.core.common.unit.ByteSizeValue; -import org.opensearch.common.util.CancellableThreadsTests; -import org.opensearch.common.util.set.Sets; +import org.opensearch.core.index.Index; +import org.opensearch.core.index.shard.ShardId; import org.opensearch.core.index.snapshots.IndexShardSnapshotException; import org.opensearch.core.index.snapshots.IndexShardSnapshotFailedException; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentLocation; import org.opensearch.discovery.MasterNotDiscoveredException; import org.opensearch.env.ShardLockObtainFailedException; -import org.opensearch.core.index.Index; import org.opensearch.index.engine.RecoveryEngineException; import org.opensearch.index.query.QueryShardException; import org.opensearch.index.seqno.RetentionLeaseAlreadyExistsException; @@ -91,7 +93,6 @@ import org.opensearch.index.shard.IllegalIndexShardStateException; import org.opensearch.index.shard.IndexShardState; import org.opensearch.index.shard.PrimaryShardClosedException; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.index.shard.ShardNotInPrimaryModeException; import org.opensearch.indices.IndexTemplateMissingException; import org.opensearch.indices.InvalidIndexTemplateException; @@ -101,7 +102,6 @@ import org.opensearch.ingest.IngestProcessorException; import org.opensearch.cluster.coordination.NodeHealthCheckFailureException; import org.opensearch.repositories.RepositoryException; -import org.opensearch.core.rest.RestStatus; import org.opensearch.rest.action.admin.indices.AliasesNotFoundException; import org.opensearch.search.SearchContextMissingException; import org.opensearch.search.SearchException; @@ -865,7 +865,7 @@ public void testIds() { ids.put(143, org.opensearch.script.ScriptException.class); ids.put(144, org.opensearch.cluster.NotClusterManagerException.class); ids.put(145, org.opensearch.OpenSearchStatusException.class); - ids.put(146, org.opensearch.tasks.TaskCancelledException.class); + ids.put(146, org.opensearch.core.tasks.TaskCancelledException.class); ids.put(147, org.opensearch.env.ShardLockObtainFailedException.class); ids.put(148, null); ids.put(149, MultiBucketConsumerService.TooManyBucketsException.class); diff --git a/server/src/test/java/org/opensearch/action/ActionModuleTests.java b/server/src/test/java/org/opensearch/action/ActionModuleTests.java index 109c60aa1e4f1..6acc947a71ede 100644 --- a/server/src/test/java/org/opensearch/action/ActionModuleTests.java +++ b/server/src/test/java/org/opensearch/action/ActionModuleTests.java @@ -46,6 +46,8 @@ import org.opensearch.common.settings.SettingsFilter; import org.opensearch.common.settings.SettingsModule; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.extensions.ExtensionsManager; import org.opensearch.identity.IdentityService; import org.opensearch.plugins.ActionPlugin; diff --git a/server/src/test/java/org/opensearch/action/ActionTests.java b/server/src/test/java/org/opensearch/action/ActionTests.java index 9ed9ecffb134d..49cf15065ff45 100644 --- a/server/src/test/java/org/opensearch/action/ActionTests.java +++ b/server/src/test/java/org/opensearch/action/ActionTests.java @@ -32,6 +32,7 @@ package org.opensearch.action; +import org.opensearch.core.action.ActionResponse; import org.opensearch.test.OpenSearchTestCase; public class ActionTests extends OpenSearchTestCase { diff --git a/server/src/test/java/org/opensearch/action/DynamicActionRegistryTests.java b/server/src/test/java/org/opensearch/action/DynamicActionRegistryTests.java index c06791f0f0245..20d3aff0f0212 100644 --- a/server/src/test/java/org/opensearch/action/DynamicActionRegistryTests.java +++ b/server/src/test/java/org/opensearch/action/DynamicActionRegistryTests.java @@ -12,6 +12,8 @@ import org.opensearch.action.main.MainAction; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.TransportAction; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.extensions.action.ExtensionAction; diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksTests.java index c16584877c07d..b4adf51826a98 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksTests.java @@ -34,7 +34,7 @@ import com.carrotsearch.randomizedtesting.RandomizedContext; import com.carrotsearch.randomizedtesting.generators.RandomNumbers; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksAction; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse; @@ -50,8 +50,8 @@ import org.opensearch.common.settings.Settings; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskCancelledException; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import org.opensearch.tasks.TaskManager; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/RecordingTaskManagerListener.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/RecordingTaskManagerListener.java index 768a6c73af380..d696badbf6921 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/RecordingTaskManagerListener.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/RecordingTaskManagerListener.java @@ -35,9 +35,9 @@ import org.opensearch.common.collect.Tuple; import org.opensearch.common.regex.Regex; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; -import org.opensearch.tasks.ThreadResourceInfo; +import org.opensearch.core.tasks.resourcetracker.ThreadResourceInfo; import org.opensearch.test.tasks.MockTaskManagerListener; import java.util.ArrayList; diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/ResourceAwareTasksTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/ResourceAwareTasksTests.java index 485aae433aa16..77422b657c91e 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/ResourceAwareTasksTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/ResourceAwareTasksTests.java @@ -11,8 +11,8 @@ import com.sun.management.ThreadMXBean; import org.apache.lucene.util.Constants; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; -import org.opensearch.action.NotifyOnceListener; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.NotifyOnceListener; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; @@ -26,10 +26,10 @@ import org.opensearch.common.util.concurrent.AbstractRunnable; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskCancelledException; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; -import org.opensearch.tasks.TaskResourceUsage; +import org.opensearch.core.tasks.resourcetracker.TaskResourceUsage; import org.opensearch.test.tasks.MockTaskManager; import org.opensearch.test.tasks.MockTaskManagerListener; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TaskTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TaskTests.java index 84a7fdff3dfa2..e78a3074541ed 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TaskTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TaskTests.java @@ -35,11 +35,11 @@ import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskInfo; -import org.opensearch.tasks.ResourceUsageMetric; -import org.opensearch.tasks.ResourceStats; -import org.opensearch.tasks.ResourceStatsType; +import org.opensearch.core.tasks.resourcetracker.ResourceUsageMetric; +import org.opensearch.core.tasks.resourcetracker.ResourceStats; +import org.opensearch.core.tasks.resourcetracker.ResourceStatsType; import org.opensearch.test.OpenSearchTestCase; import java.nio.charset.StandardCharsets; diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TestTaskPlugin.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TestTaskPlugin.java index 6b4317d6ec934..feb8fdfd6869a 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TestTaskPlugin.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TestTaskPlugin.java @@ -32,10 +32,10 @@ package org.opensearch.action.admin.cluster.node.tasks; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestBuilder; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.IndicesRequest; import org.opensearch.action.FailedNodeException; import org.opensearch.action.ActionType; @@ -65,7 +65,7 @@ import org.opensearch.plugins.NetworkPlugin; import org.opensearch.tasks.CancellableTask; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.Transport; import org.opensearch.transport.TransportException; diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java index 67792f2a62b2c..0759d9a0d4640 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java @@ -31,8 +31,6 @@ package org.opensearch.action.admin.cluster.node.tasks; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.TaskOperationFailure; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; @@ -50,18 +48,20 @@ import org.opensearch.action.support.tasks.TransportTasksAction; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.cluster.service.ClusterService; +import org.opensearch.common.action.ActionFuture; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentHelper; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.core.tasks.TaskId; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; import org.opensearch.tasks.TaskInfo; import org.opensearch.test.tasks.MockTaskManager; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksRequestTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksRequestTests.java index 4c8f525541681..a98641a6f2c54 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksRequestTests.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.cluster.node.tasks.cancel; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import java.util.Collections; diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteTests.java index 5e535c77e80a7..2f984aa342e22 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.reroute; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.OpenSearchAllocationTestCase; import org.opensearch.cluster.EmptyClusterInfoService; diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/state/ClusterStateApiTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/state/ClusterStateApiTests.java index 039fde9455a2a..3d8d7e9ce1607 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/state/ClusterStateApiTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/state/ClusterStateApiTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.state; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/test/java/org/opensearch/action/admin/indices/close/CloseIndexRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/close/CloseIndexRequestTests.java index 15e04effe91c6..fec687f2faff4 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/close/CloseIndexRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/close/CloseIndexRequestTests.java @@ -37,7 +37,7 @@ import org.opensearch.action.support.IndicesOptions; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.VersionUtils; diff --git a/server/src/test/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java index 86e87de364a51..7efbdfa72ce40 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java @@ -36,7 +36,7 @@ import org.junit.Before; import org.junit.BeforeClass; import org.mockito.ArgumentCaptor; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.PlainActionFuture; @@ -65,7 +65,7 @@ import org.opensearch.index.shard.ReplicationGroup; import org.opensearch.core.index.shard.ShardId; import org.opensearch.indices.IndicesService; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.transport.CapturingTransport; import org.opensearch.threadpool.TestThreadPool; diff --git a/server/src/test/java/org/opensearch/action/admin/indices/get/GetIndexActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/get/GetIndexActionTests.java index 395cf375127a8..5f8e2476ac454 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/get/GetIndexActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/get/GetIndexActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.replication.ClusterStateCreationUtils; diff --git a/server/src/test/java/org/opensearch/action/admin/indices/rollover/TransportRolloverActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/rollover/TransportRolloverActionTests.java index 76ddb9facd192..e6ca5793e9254 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/rollover/TransportRolloverActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/rollover/TransportRolloverActionTests.java @@ -33,7 +33,7 @@ package org.opensearch.action.admin.indices.rollover; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.admin.indices.stats.CommonStats; import org.opensearch.action.admin.indices.stats.IndexStats; diff --git a/server/src/test/java/org/opensearch/action/admin/indices/settings/get/GetSettingsActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/settings/get/GetSettingsActionTests.java index 0d063c5969ff5..10c74010cea6f 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/settings/get/GetSettingsActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/settings/get/GetSettingsActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.settings.get; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.replication.ClusterStateCreationUtils; diff --git a/server/src/test/java/org/opensearch/action/admin/indices/stats/IndicesStatsTests.java b/server/src/test/java/org/opensearch/action/admin/indices/stats/IndicesStatsTests.java index 3f1b0cb44c601..406e33dc117db 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/stats/IndicesStatsTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/stats/IndicesStatsTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.stats; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.index.IndexResponse; import org.opensearch.core.action.support.DefaultShardOperationFailedException; import org.opensearch.action.support.WriteRequest.RefreshPolicy; diff --git a/server/src/test/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryActionTests.java index c1c0e9517607a..40790d05c89f5 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/validate/query/TransportValidateQueryActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.validate.query; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.test.OpenSearchSingleNodeTestCase; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/server/src/test/java/org/opensearch/action/bulk/BulkProcessorTests.java b/server/src/test/java/org/opensearch/action/bulk/BulkProcessorTests.java index c8a171df6cadc..eb53cc9f57be1 100644 --- a/server/src/test/java/org/opensearch/action/bulk/BulkProcessorTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/BulkProcessorTests.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.index.IndexRequest; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.unit.ByteSizeUnit; diff --git a/server/src/test/java/org/opensearch/action/bulk/BulkRequestModifierTests.java b/server/src/test/java/org/opensearch/action/bulk/BulkRequestModifierTests.java index 31c6472ad46b3..7a77384e935ed 100644 --- a/server/src/test/java/org/opensearch/action/bulk/BulkRequestModifierTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/BulkRequestModifierTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.bulk; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; diff --git a/server/src/test/java/org/opensearch/action/bulk/RetryTests.java b/server/src/test/java/org/opensearch/action/bulk/RetryTests.java index ea02b964b1c58..43c58008efbba 100644 --- a/server/src/test/java/org/opensearch/action/bulk/RetryTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/RetryTests.java @@ -32,8 +32,8 @@ package org.opensearch.action.bulk; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest.OpType; import org.opensearch.action.delete.DeleteResponse; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java index 0846a5f8dec5c..783cd414198d1 100644 --- a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java @@ -33,7 +33,7 @@ package org.opensearch.action.bulk; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.action.delete.DeleteRequest; import org.opensearch.action.index.IndexRequest; diff --git a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIngestTests.java b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIngestTests.java index 6a514b47e55a4..88b76a1921292 100644 --- a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIngestTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionIngestTests.java @@ -33,7 +33,7 @@ package org.opensearch.action.bulk; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.action.index.IndexAction; diff --git a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTests.java b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTests.java index d53b860e6524a..c4b9f0d9b755b 100644 --- a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTests.java @@ -34,7 +34,7 @@ import org.opensearch.ResourceAlreadyExistsException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.action.bulk.TransportBulkActionTookTests.Resolver; diff --git a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTookTests.java b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTookTests.java index e10b848a39431..0aa178e72e313 100644 --- a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTookTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTookTests.java @@ -35,9 +35,9 @@ import org.apache.lucene.util.Constants; import org.opensearch.action.ActionType; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.IndicesRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/test/java/org/opensearch/action/bulk/TransportShardBulkActionTests.java b/server/src/test/java/org/opensearch/action/bulk/TransportShardBulkActionTests.java index ebdc7dcbfd6ac..73bf93bcf5a9c 100644 --- a/server/src/test/java/org/opensearch/action/bulk/TransportShardBulkActionTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/TransportShardBulkActionTests.java @@ -35,7 +35,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchStatusException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.LatchedActionListener; diff --git a/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java b/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java index 39e8f1af8c331..bbe99ca398cc6 100644 --- a/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java +++ b/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java @@ -33,7 +33,7 @@ package org.opensearch.action.get; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.IndicesRequest; import org.opensearch.action.RoutingMissingException; import org.opensearch.action.support.ActionFilters; @@ -58,7 +58,7 @@ import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.indices.IndicesService; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskManager; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; diff --git a/server/src/test/java/org/opensearch/action/ingest/SimulateExecutionServiceTests.java b/server/src/test/java/org/opensearch/action/ingest/SimulateExecutionServiceTests.java index ff7b0dddb33a3..a5a082286f123 100644 --- a/server/src/test/java/org/opensearch/action/ingest/SimulateExecutionServiceTests.java +++ b/server/src/test/java/org/opensearch/action/ingest/SimulateExecutionServiceTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.ingest; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.index.VersionType; import org.opensearch.ingest.AbstractProcessor; import org.opensearch.ingest.CompoundProcessor; diff --git a/server/src/test/java/org/opensearch/action/main/MainActionTests.java b/server/src/test/java/org/opensearch/action/main/MainActionTests.java index b219e83524e7f..ecfc7de9e7bf9 100644 --- a/server/src/test/java/org/opensearch/action/main/MainActionTests.java +++ b/server/src/test/java/org/opensearch/action/main/MainActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.main; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.ClusterState; diff --git a/server/src/test/java/org/opensearch/action/resync/TransportResyncReplicationActionTests.java b/server/src/test/java/org/opensearch/action/resync/TransportResyncReplicationActionTests.java index 2e50c6225577d..d19f513693431 100644 --- a/server/src/test/java/org/opensearch/action/resync/TransportResyncReplicationActionTests.java +++ b/server/src/test/java/org/opensearch/action/resync/TransportResyncReplicationActionTests.java @@ -34,7 +34,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.action.support.replication.PendingReplicationActions; diff --git a/server/src/test/java/org/opensearch/action/search/AbstractSearchAsyncActionTests.java b/server/src/test/java/org/opensearch/action/search/AbstractSearchAsyncActionTests.java index d906c7be15a15..1322cf6d191b7 100644 --- a/server/src/test/java/org/opensearch/action/search/AbstractSearchAsyncActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/AbstractSearchAsyncActionTests.java @@ -34,7 +34,7 @@ import org.junit.After; import org.junit.Before; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.action.support.IndicesOptions; import org.opensearch.cluster.ClusterState; diff --git a/server/src/test/java/org/opensearch/action/search/CanMatchPreFilterSearchPhaseTests.java b/server/src/test/java/org/opensearch/action/search/CanMatchPreFilterSearchPhaseTests.java index 0561f81f96ce6..fdaf36234e231 100644 --- a/server/src/test/java/org/opensearch/action/search/CanMatchPreFilterSearchPhaseTests.java +++ b/server/src/test/java/org/opensearch/action/search/CanMatchPreFilterSearchPhaseTests.java @@ -33,7 +33,7 @@ import org.apache.lucene.util.BytesRef; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/test/java/org/opensearch/action/search/ClearScrollControllerTests.java b/server/src/test/java/org/opensearch/action/search/ClearScrollControllerTests.java index 55e597dab04dc..a17c84b6cd274 100644 --- a/server/src/test/java/org/opensearch/action/search/ClearScrollControllerTests.java +++ b/server/src/test/java/org/opensearch/action/search/ClearScrollControllerTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; diff --git a/server/src/test/java/org/opensearch/action/search/ClearScrollRequestTests.java b/server/src/test/java/org/opensearch/action/search/ClearScrollRequestTests.java index c28a437b48b60..859711b2b778c 100644 --- a/server/src/test/java/org/opensearch/action/search/ClearScrollRequestTests.java +++ b/server/src/test/java/org/opensearch/action/search/ClearScrollRequestTests.java @@ -32,14 +32,14 @@ package org.opensearch.action.search; +import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentHelper; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; -import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; diff --git a/server/src/test/java/org/opensearch/action/search/CreatePitControllerTests.java b/server/src/test/java/org/opensearch/action/search/CreatePitControllerTests.java index 2c585d152c5d4..6d219c565b30d 100644 --- a/server/src/test/java/org/opensearch/action/search/CreatePitControllerTests.java +++ b/server/src/test/java/org/opensearch/action/search/CreatePitControllerTests.java @@ -11,7 +11,7 @@ import org.apache.lucene.search.TotalHits; import org.junit.Before; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.StepListener; import org.opensearch.client.node.NodeClient; @@ -32,7 +32,7 @@ import org.opensearch.search.aggregations.InternalAggregations; import org.opensearch.search.internal.InternalSearchResponse; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.transport.MockTransportService; import org.opensearch.threadpool.TestThreadPool; diff --git a/server/src/test/java/org/opensearch/action/search/ExpandSearchPhaseTests.java b/server/src/test/java/org/opensearch/action/search/ExpandSearchPhaseTests.java index 8be2b9b203da6..ff181b7b96684 100644 --- a/server/src/test/java/org/opensearch/action/search/ExpandSearchPhaseTests.java +++ b/server/src/test/java/org/opensearch/action/search/ExpandSearchPhaseTests.java @@ -33,7 +33,7 @@ package org.opensearch.action.search; import org.apache.lucene.search.TotalHits; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.document.DocumentField; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.index.query.InnerHitBuilder; diff --git a/server/src/test/java/org/opensearch/action/search/MultiSearchActionTookTests.java b/server/src/test/java/org/opensearch/action/search/MultiSearchActionTookTests.java index fc4bd287c5f18..b6d3a7da2076e 100644 --- a/server/src/test/java/org/opensearch/action/search/MultiSearchActionTookTests.java +++ b/server/src/test/java/org/opensearch/action/search/MultiSearchActionTookTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.ActionFilters; import org.opensearch.client.node.NodeClient; diff --git a/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java b/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java index e14c7c39084f2..74c5e7bad0d97 100644 --- a/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java +++ b/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java @@ -36,21 +36,21 @@ import org.opensearch.action.support.IndicesOptions; import org.opensearch.common.CheckedBiConsumer; import org.opensearch.common.CheckedRunnable; +import org.opensearch.common.logging.DeprecationLogger; +import org.opensearch.common.unit.TimeValue; +import org.opensearch.common.xcontent.XContentHelper; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.ParseField; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; -import org.opensearch.common.logging.DeprecationLogger; -import org.opensearch.common.unit.TimeValue; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; -import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.query.MatchAllQueryBuilder; import org.opensearch.index.query.QueryBuilder; import org.opensearch.rest.RestRequest; diff --git a/server/src/test/java/org/opensearch/action/search/PitTestsUtil.java b/server/src/test/java/org/opensearch/action/search/PitTestsUtil.java index 07a0d3a1d97f2..fdb2caf61fd63 100644 --- a/server/src/test/java/org/opensearch/action/search/PitTestsUtil.java +++ b/server/src/test/java/org/opensearch/action/search/PitTestsUtil.java @@ -10,7 +10,7 @@ import org.junit.Assert; import org.opensearch.Version; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.state.ClusterStateRequest; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; import org.opensearch.action.admin.indices.segments.IndicesSegmentResponse; diff --git a/server/src/test/java/org/opensearch/action/search/SearchAsyncActionTests.java b/server/src/test/java/org/opensearch/action/search/SearchAsyncActionTests.java index 9ee3b11f05785..ed84ce4ff1927 100644 --- a/server/src/test/java/org/opensearch/action/search/SearchAsyncActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/SearchAsyncActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java b/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java index ddce6d9772b05..f62a065507390 100644 --- a/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java +++ b/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java @@ -44,7 +44,7 @@ import org.opensearch.search.builder.PointInTimeBuilder; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.search.rescore.QueryRescorerBuilder; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.VersionUtils; diff --git a/server/src/test/java/org/opensearch/action/search/SearchScrollAsyncActionTests.java b/server/src/test/java/org/opensearch/action/search/SearchScrollAsyncActionTests.java index 7ae96e51df76a..c26c406726743 100644 --- a/server/src/test/java/org/opensearch/action/search/SearchScrollAsyncActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/SearchScrollAsyncActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.search; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; diff --git a/server/src/test/java/org/opensearch/action/search/SearchScrollRequestTests.java b/server/src/test/java/org/opensearch/action/search/SearchScrollRequestTests.java index c91d4746b8fdf..f393b7e9eba05 100644 --- a/server/src/test/java/org/opensearch/action/search/SearchScrollRequestTests.java +++ b/server/src/test/java/org/opensearch/action/search/SearchScrollRequestTests.java @@ -33,17 +33,17 @@ package org.opensearch.action.search; import org.opensearch.common.UUIDs; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; -import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.unit.TimeValue; -import org.opensearch.core.xcontent.ToXContent; -import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.xcontent.ToXContent; +import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.XContentHelper; +import org.opensearch.core.xcontent.XContentParser; import org.opensearch.search.internal.InternalScrollSearchRequest; import org.opensearch.search.internal.ShardSearchContextId; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/action/search/TransportDeletePitActionTests.java b/server/src/test/java/org/opensearch/action/search/TransportDeletePitActionTests.java index 3d76e711788db..fc4802c6330ac 100644 --- a/server/src/test/java/org/opensearch/action/search/TransportDeletePitActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/TransportDeletePitActionTests.java @@ -9,7 +9,7 @@ import org.junit.Before; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilter; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.PlainActionFuture; @@ -27,7 +27,7 @@ import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.TermQueryBuilder; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.transport.MockTransportService; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java b/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java index 5fd5e7315e553..2126d31842be2 100644 --- a/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java @@ -33,7 +33,7 @@ package org.opensearch.action.search; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilter; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.ActionTestUtils; diff --git a/server/src/test/java/org/opensearch/action/search/TransportSearchActionTests.java b/server/src/test/java/org/opensearch/action/search/TransportSearchActionTests.java index 05df501faae82..bd1af3bad7776 100644 --- a/server/src/test/java/org/opensearch/action/search/TransportSearchActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/TransportSearchActionTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.search.TotalHits; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.action.OriginalIndicesTests; diff --git a/server/src/test/java/org/opensearch/action/support/ContextPreservingActionListenerTests.java b/server/src/test/java/org/opensearch/action/support/ContextPreservingActionListenerTests.java index 6ca38b2a2fc4f..9332e0e649f2d 100644 --- a/server/src/test/java/org/opensearch/action/support/ContextPreservingActionListenerTests.java +++ b/server/src/test/java/org/opensearch/action/support/ContextPreservingActionListenerTests.java @@ -31,7 +31,7 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/action/support/GroupedActionListenerTests.java b/server/src/test/java/org/opensearch/action/support/GroupedActionListenerTests.java index bbdd2351910d6..bac019264b7d3 100644 --- a/server/src/test/java/org/opensearch/action/support/GroupedActionListenerTests.java +++ b/server/src/test/java/org/opensearch/action/support/GroupedActionListenerTests.java @@ -31,7 +31,7 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; diff --git a/server/src/test/java/org/opensearch/action/support/ListenableActionFutureTests.java b/server/src/test/java/org/opensearch/action/support/ListenableActionFutureTests.java index b3fa03a3f873c..6ca275c4031fb 100644 --- a/server/src/test/java/org/opensearch/action/support/ListenableActionFutureTests.java +++ b/server/src/test/java/org/opensearch/action/support/ListenableActionFutureTests.java @@ -31,7 +31,7 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.util.concurrent.AbstractRunnable; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; diff --git a/server/src/test/java/org/opensearch/action/support/ListenerTimeoutsTests.java b/server/src/test/java/org/opensearch/action/support/ListenerTimeoutsTests.java index 9e9f27688e121..30fcfc9ca2cd0 100644 --- a/server/src/test/java/org/opensearch/action/support/ListenerTimeoutsTests.java +++ b/server/src/test/java/org/opensearch/action/support/ListenerTimeoutsTests.java @@ -33,7 +33,7 @@ package org.opensearch.action.support; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.coordination.DeterministicTaskQueue; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/test/java/org/opensearch/action/support/RetryableActionTests.java b/server/src/test/java/org/opensearch/action/support/RetryableActionTests.java index 85eda47e9b797..a1551b8536c63 100644 --- a/server/src/test/java/org/opensearch/action/support/RetryableActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/RetryableActionTests.java @@ -33,7 +33,7 @@ package org.opensearch.action.support; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.coordination.DeterministicTaskQueue; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/test/java/org/opensearch/action/support/TransportActionFilterChainTests.java b/server/src/test/java/org/opensearch/action/support/TransportActionFilterChainTests.java index 35c346957ebd2..3f1f8aceed3b9 100644 --- a/server/src/test/java/org/opensearch/action/support/TransportActionFilterChainTests.java +++ b/server/src/test/java/org/opensearch/action/support/TransportActionFilterChainTests.java @@ -33,10 +33,10 @@ package org.opensearch.action.support; import org.opensearch.OpenSearchTimeoutException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.LatchedActionListener; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.settings.Settings; diff --git a/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java b/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java index bcc4861db0a8d..aa5263517c43e 100644 --- a/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java @@ -33,10 +33,10 @@ import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionFuture; -import org.opensearch.action.ActionListener; +import org.opensearch.common.action.ActionFuture; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.action.support.ThreadedActionListener; diff --git a/server/src/test/java/org/opensearch/action/support/clustermanager/TransportMasterNodeActionUtils.java b/server/src/test/java/org/opensearch/action/support/clustermanager/TransportMasterNodeActionUtils.java index b9abddc5622c9..77d80c40626c7 100644 --- a/server/src/test/java/org/opensearch/action/support/clustermanager/TransportMasterNodeActionUtils.java +++ b/server/src/test/java/org/opensearch/action/support/clustermanager/TransportMasterNodeActionUtils.java @@ -32,8 +32,8 @@ package org.opensearch.action.support.clustermanager; -import org.opensearch.action.ActionListener; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.cluster.ClusterState; public class TransportMasterNodeActionUtils { diff --git a/server/src/test/java/org/opensearch/action/support/replication/BroadcastReplicationTests.java b/server/src/test/java/org/opensearch/action/support/replication/BroadcastReplicationTests.java index 9c02bacbadda2..a62a081b94a49 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/BroadcastReplicationTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/BroadcastReplicationTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.support.replication; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.NoShardAvailableActionException; import org.opensearch.action.UnavailableShardsException; import org.opensearch.action.admin.indices.flush.FlushRequest; diff --git a/server/src/test/java/org/opensearch/action/support/replication/PendingReplicationActionsTests.java b/server/src/test/java/org/opensearch/action/support/replication/PendingReplicationActionsTests.java index a26198a5602cc..fc5b269409b7c 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/PendingReplicationActionsTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/PendingReplicationActionsTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.support.replication; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.action.support.RetryableAction; import org.opensearch.common.UUIDs; diff --git a/server/src/test/java/org/opensearch/action/support/replication/ReplicationOperationTests.java b/server/src/test/java/org/opensearch/action/support/replication/ReplicationOperationTests.java index 10d5a87e8200a..b15c42ab4e630 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/ReplicationOperationTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/ReplicationOperationTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.UnavailableShardsException; import org.opensearch.action.support.ActiveShardCount; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationActionTests.java b/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationActionTests.java index 7d47238b8e5ab..5e61ec4990c23 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationActionTests.java @@ -41,7 +41,7 @@ import org.junit.BeforeClass; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.UnavailableShardsException; import org.opensearch.action.admin.indices.close.CloseIndexRequest; import org.opensearch.action.admin.indices.create.CreateIndexRequest; diff --git a/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationAllPermitsAcquisitionTests.java b/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationAllPermitsAcquisitionTests.java index f7c26ed8fea03..3e4898e8c49b2 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationAllPermitsAcquisitionTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationAllPermitsAcquisitionTests.java @@ -32,7 +32,7 @@ package org.opensearch.action.support.replication; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.ClusterState; diff --git a/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionForIndexingPressureTests.java b/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionForIndexingPressureTests.java index 4a7500f16197d..82eb014992870 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionForIndexingPressureTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionForIndexingPressureTests.java @@ -5,7 +5,7 @@ package org.opensearch.action.support.replication; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.stats.CommonStatsFlags; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionTests.java b/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionTests.java index a2d5e92fa11fe..72c0d8f51f7b8 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/TransportWriteActionTests.java @@ -34,7 +34,7 @@ import org.hamcrest.MatcherAssert; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.ActionTestUtils; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/test/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java b/server/src/test/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java index 02f245e94ffdc..f98dbd0f874d6 100644 --- a/server/src/test/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java @@ -33,8 +33,8 @@ package org.opensearch.action.support.single.instance; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/test/java/org/opensearch/action/termvectors/TermVectorsUnitTests.java b/server/src/test/java/org/opensearch/action/termvectors/TermVectorsUnitTests.java index 90efa3341eb73..ef38a30d8c8c4 100644 --- a/server/src/test/java/org/opensearch/action/termvectors/TermVectorsUnitTests.java +++ b/server/src/test/java/org/opensearch/action/termvectors/TermVectorsUnitTests.java @@ -60,7 +60,7 @@ import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.index.shard.ShardId; import org.opensearch.rest.action.document.RestTermVectorsAction; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.StreamsUtils; import org.hamcrest.Matchers; diff --git a/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java b/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java index 0b0827d704c74..341a2b6d3fa1d 100644 --- a/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java +++ b/server/src/test/java/org/opensearch/action/termvectors/TransportMultiTermVectorsActionTests.java @@ -33,7 +33,7 @@ package org.opensearch.action.termvectors; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.IndicesRequest; import org.opensearch.action.RoutingMissingException; import org.opensearch.action.get.TransportMultiGetActionTests; @@ -59,7 +59,7 @@ import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.indices.IndicesService; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskManager; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; diff --git a/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java b/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java index 0d324a0da7ee6..450d7ef2cfcdb 100644 --- a/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java +++ b/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java @@ -34,7 +34,7 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.reroute.ClusterRerouteAction; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotAction; import org.opensearch.action.admin.cluster.stats.ClusterStatsAction; diff --git a/server/src/test/java/org/opensearch/client/OriginSettingClientTests.java b/server/src/test/java/org/opensearch/client/OriginSettingClientTests.java index eca49516f42c2..134d0400baf14 100644 --- a/server/src/test/java/org/opensearch/client/OriginSettingClientTests.java +++ b/server/src/test/java/org/opensearch/client/OriginSettingClientTests.java @@ -33,9 +33,9 @@ package org.opensearch.client; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.bulk.BulkRequest; import org.opensearch.action.search.ClearScrollRequest; import org.opensearch.action.search.SearchRequest; diff --git a/server/src/test/java/org/opensearch/client/ParentTaskAssigningClientTests.java b/server/src/test/java/org/opensearch/client/ParentTaskAssigningClientTests.java index 93cd89ce31a08..0808e44c1dfc0 100644 --- a/server/src/test/java/org/opensearch/client/ParentTaskAssigningClientTests.java +++ b/server/src/test/java/org/opensearch/client/ParentTaskAssigningClientTests.java @@ -33,13 +33,13 @@ package org.opensearch.client; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.bulk.BulkRequest; import org.opensearch.action.search.ClearScrollRequest; import org.opensearch.action.search.SearchRequest; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.client.NoOpClient; diff --git a/server/src/test/java/org/opensearch/client/node/NodeClientHeadersTests.java b/server/src/test/java/org/opensearch/client/node/NodeClientHeadersTests.java index 36196d0d236c7..2c089b82ecf76 100644 --- a/server/src/test/java/org/opensearch/client/node/NodeClientHeadersTests.java +++ b/server/src/test/java/org/opensearch/client/node/NodeClientHeadersTests.java @@ -34,7 +34,7 @@ import org.opensearch.action.ActionType; import org.opensearch.action.ActionModule.DynamicActionRegistry; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.TransportAction; diff --git a/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java b/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java index 1cd21482566ef..47957decb16b9 100644 --- a/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java +++ b/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java @@ -33,9 +33,9 @@ package org.opensearch.cluster; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsRequest; diff --git a/server/src/test/java/org/opensearch/cluster/NodeConnectionsServiceTests.java b/server/src/test/java/org/opensearch/cluster/NodeConnectionsServiceTests.java index 25956f1a560f2..212fd889c6800 100644 --- a/server/src/test/java/org/opensearch/cluster/NodeConnectionsServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/NodeConnectionsServiceTests.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchTimeoutException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.coordination.DeterministicTaskQueue; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java b/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java index c3ea1608f1275..1f466552fafa7 100644 --- a/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java +++ b/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.cluster.action.index; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.mapping.put.AutoPutMappingAction; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.client.AdminClient; diff --git a/server/src/test/java/org/opensearch/cluster/action/shard/ShardStartedClusterStateTaskExecutorTests.java b/server/src/test/java/org/opensearch/cluster/action/shard/ShardStartedClusterStateTaskExecutorTests.java index b423a0f3dc8de..d484170386f3a 100644 --- a/server/src/test/java/org/opensearch/cluster/action/shard/ShardStartedClusterStateTaskExecutorTests.java +++ b/server/src/test/java/org/opensearch/cluster/action/shard/ShardStartedClusterStateTaskExecutorTests.java @@ -32,7 +32,7 @@ package org.opensearch.cluster.action.shard; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateTaskExecutor; import org.opensearch.cluster.OpenSearchAllocationTestCase; diff --git a/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java b/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java index 957da6ea65b89..780c8834845ad 100644 --- a/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java +++ b/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.index.CorruptIndexException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.replication.ClusterStateCreationUtils; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateObserver; diff --git a/server/src/test/java/org/opensearch/cluster/coordination/JoinHelperTests.java b/server/src/test/java/org/opensearch/cluster/coordination/JoinHelperTests.java index f63f33f345411..ee9d47e544395 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/JoinHelperTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/JoinHelperTests.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.Level; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.ClusterName; diff --git a/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java b/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java index 09a7b34958f2c..2095ea3583967 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.OpenSearchAllocationTestCase; diff --git a/server/src/test/java/org/opensearch/cluster/coordination/PublicationTests.java b/server/src/test/java/org/opensearch/cluster/coordination/PublicationTests.java index 366f19f74aac8..b9bc4e320aab1 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/PublicationTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/PublicationTests.java @@ -33,7 +33,7 @@ package org.opensearch.cluster.coordination; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.coordination.CoordinationMetadata.VotingConfiguration; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java index 7108e06fe39fc..7607e26faae9a 100644 --- a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java +++ b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java @@ -13,7 +13,7 @@ import org.junit.Before; import org.opensearch.OpenSearchTimeoutException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction; import org.opensearch.action.admin.cluster.configuration.TransportClearVotingConfigExclusionsAction; import org.opensearch.action.support.ActionFilters; diff --git a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java index 5509a238f700f..ae08385ad2a98 100644 --- a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java @@ -14,7 +14,7 @@ import org.junit.Before; import org.mockito.Mockito; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.decommission.awareness.delete.DeleteDecommissionStateResponse; import org.opensearch.action.admin.cluster.decommission.awareness.put.DecommissionRequest; import org.opensearch.action.admin.cluster.decommission.awareness.put.DecommissionResponse; diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java index dc8f0ea26dccc..e7fce9c120382 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java @@ -33,7 +33,7 @@ package org.opensearch.cluster.metadata; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.alias.Alias; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.cluster.ClusterState; diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataTests.java index 81f64ba4c56c6..6062f68001d0b 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataTests.java @@ -38,19 +38,19 @@ import org.opensearch.cluster.DataStreamTestHelper; import org.opensearch.cluster.coordination.CoordinationMetadata; import org.opensearch.cluster.coordination.CoordinationMetadata.VotingConfigExclusion; -import org.opensearch.core.common.Strings; import org.opensearch.common.UUIDs; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; -import org.opensearch.core.common.io.stream.NamedWriteableAwareStreamInput; -import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.set.Sets; -import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.common.Strings; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.io.stream.NamedWriteableAwareStreamInput; +import org.opensearch.core.common.io.stream.NamedWriteableRegistry; +import org.opensearch.core.xcontent.XContentBuilder; +import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.index.Index; import org.opensearch.plugins.MapperPlugin; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java index c0f0fc699ba78..959cd942dc19c 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java @@ -33,7 +33,7 @@ package org.opensearch.cluster.metadata; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest; import org.opensearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.opensearch.action.support.master.AcknowledgedResponse; diff --git a/server/src/test/java/org/opensearch/cluster/routing/BatchedRerouteServiceTests.java b/server/src/test/java/org/opensearch/cluster/routing/BatchedRerouteServiceTests.java index 796d73aa715de..689f168af1bc1 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/BatchedRerouteServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/BatchedRerouteServiceTests.java @@ -32,7 +32,7 @@ package org.opensearch.cluster.routing; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateUpdateTask; import org.opensearch.cluster.coordination.FailedToCommitClusterStateException; diff --git a/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java b/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java index 81464fcd2610d..652141dd31b2d 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java @@ -12,7 +12,7 @@ import org.junit.After; import org.junit.Before; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.shards.routing.weighted.delete.ClusterDeleteWeightedRoutingRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.admin.cluster.shards.routing.weighted.delete.ClusterDeleteWeightedRoutingResponse; diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitorTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitorTests.java index a8f8296cf9591..d2923041658df 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitorTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/DiskThresholdMonitorTests.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterInfo; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.ClusterState; diff --git a/server/src/test/java/org/opensearch/common/blobstore/fs/FsBlobContainerTests.java b/server/src/test/java/org/opensearch/common/blobstore/fs/FsBlobContainerTests.java index 4a2eeabeb7e58..2bc8d26197ef3 100644 --- a/server/src/test/java/org/opensearch/common/blobstore/fs/FsBlobContainerTests.java +++ b/server/src/test/java/org/opensearch/common/blobstore/fs/FsBlobContainerTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.tests.mockfile.FilterFileSystemProvider; import org.apache.lucene.tests.mockfile.FilterSeekableByteChannel; import org.apache.lucene.tests.util.LuceneTestCase; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.blobstore.BlobContainer; import org.opensearch.common.blobstore.BlobMetadata; import org.opensearch.common.blobstore.BlobPath; diff --git a/server/src/test/java/org/opensearch/common/compress/AbstractCompressorTests.java b/server/src/test/java/org/opensearch/common/compress/AbstractCompressorTests.java index 67ab4e240a4ef..a2a54f444ad9d 100644 --- a/server/src/test/java/org/opensearch/common/compress/AbstractCompressorTests.java +++ b/server/src/test/java/org/opensearch/common/compress/AbstractCompressorTests.java @@ -10,6 +10,7 @@ import org.apache.lucene.tests.util.LineFileDocs; import org.apache.lucene.tests.util.TestUtil; +import org.opensearch.core.common.compress.Compressor; import org.opensearch.test.OpenSearchTestCase; import java.io.ByteArrayInputStream; diff --git a/server/src/test/java/org/opensearch/common/compress/DeflateCompressTests.java b/server/src/test/java/org/opensearch/common/compress/DeflateCompressTests.java index 6178dcac9a390..8c7ab05addc4c 100644 --- a/server/src/test/java/org/opensearch/common/compress/DeflateCompressTests.java +++ b/server/src/test/java/org/opensearch/common/compress/DeflateCompressTests.java @@ -32,6 +32,8 @@ package org.opensearch.common.compress; +import org.opensearch.core.common.compress.Compressor; + /** * Test streaming compression (e.g. used for recovery) */ diff --git a/server/src/test/java/org/opensearch/common/compress/DeflateCompressedXContentTests.java b/server/src/test/java/org/opensearch/common/compress/DeflateCompressedXContentTests.java index eacbcaced2dcd..4d295e17b16aa 100644 --- a/server/src/test/java/org/opensearch/common/compress/DeflateCompressedXContentTests.java +++ b/server/src/test/java/org/opensearch/common/compress/DeflateCompressedXContentTests.java @@ -35,6 +35,7 @@ import org.apache.lucene.tests.util.TestUtil; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.core.common.compress.Compressor; import org.opensearch.test.OpenSearchTestCase; import org.junit.Assert; diff --git a/server/src/test/java/org/opensearch/common/compress/ZstdCompressTests.java b/server/src/test/java/org/opensearch/common/compress/ZstdCompressTests.java index b8de4a4e4bb1b..9def702792ffc 100644 --- a/server/src/test/java/org/opensearch/common/compress/ZstdCompressTests.java +++ b/server/src/test/java/org/opensearch/common/compress/ZstdCompressTests.java @@ -8,6 +8,8 @@ package org.opensearch.common.compress; +import org.opensearch.core.common.compress.Compressor; + /** * Test streaming compression */ diff --git a/server/src/test/java/org/opensearch/common/util/concurrent/ListenableFutureTests.java b/server/src/test/java/org/opensearch/common/util/concurrent/ListenableFutureTests.java index 32807cf3b88c8..5ab444c6ac602 100644 --- a/server/src/test/java/org/opensearch/common/util/concurrent/ListenableFutureTests.java +++ b/server/src/test/java/org/opensearch/common/util/concurrent/ListenableFutureTests.java @@ -33,7 +33,7 @@ package org.opensearch.common.util.concurrent; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.settings.Settings; import org.opensearch.test.OpenSearchTestCase; import org.junit.After; diff --git a/server/src/test/java/org/opensearch/common/xcontent/BaseXContentTestCase.java b/server/src/test/java/org/opensearch/common/xcontent/BaseXContentTestCase.java index 4f1972be7c9e1..7386b4e24fa0e 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/BaseXContentTestCase.java +++ b/server/src/test/java/org/opensearch/common/xcontent/BaseXContentTestCase.java @@ -39,14 +39,14 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.Constants; import org.opensearch.cluster.metadata.IndexMetadata; +import org.opensearch.common.geo.GeoPoint; +import org.opensearch.common.io.PathUtils; +import org.opensearch.common.unit.DistanceUnit; import org.opensearch.core.ParseField; import org.opensearch.core.common.Strings; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; -import org.opensearch.common.geo.GeoPoint; -import org.opensearch.common.io.PathUtils; import org.opensearch.core.common.text.Text; -import org.opensearch.common.unit.DistanceUnit; import org.opensearch.core.common.util.CollectionUtils; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.MediaTypeRegistry; diff --git a/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java b/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java index 72f0101925ff5..be194c070135a 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java +++ b/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java @@ -32,12 +32,12 @@ package org.opensearch.common.xcontent.support; -import org.opensearch.core.common.Strings; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.common.Strings; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/server/src/test/java/org/opensearch/discovery/HandshakingTransportAddressConnectorTests.java b/server/src/test/java/org/opensearch/discovery/HandshakingTransportAddressConnectorTests.java index e4703626d08fc..fa53a7883a228 100644 --- a/server/src/test/java/org/opensearch/discovery/HandshakingTransportAddressConnectorTests.java +++ b/server/src/test/java/org/opensearch/discovery/HandshakingTransportAddressConnectorTests.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.Nullable; diff --git a/server/src/test/java/org/opensearch/discovery/PeerFinderTests.java b/server/src/test/java/org/opensearch/discovery/PeerFinderTests.java index c3d27119b61be..9f411977add30 100644 --- a/server/src/test/java/org/opensearch/discovery/PeerFinderTests.java +++ b/server/src/test/java/org/opensearch/discovery/PeerFinderTests.java @@ -34,7 +34,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.coordination.DeterministicTaskQueue; import org.opensearch.cluster.coordination.PeersResponse; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/test/java/org/opensearch/http/DefaultRestChannelTests.java b/server/src/test/java/org/opensearch/http/DefaultRestChannelTests.java index fb545e8db582e..2d6e3b4b89911 100644 --- a/server/src/test/java/org/opensearch/http/DefaultRestChannelTests.java +++ b/server/src/test/java/org/opensearch/http/DefaultRestChannelTests.java @@ -33,7 +33,7 @@ package org.opensearch.http; import org.opensearch.Build; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.bytes.ReleasableBytesReference; diff --git a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java index e2dc545388412..f1c04fd7f7e13 100644 --- a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java @@ -85,7 +85,7 @@ import org.hamcrest.Matchers; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.TransportActions; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/server/src/test/java/org/opensearch/index/get/GetResultTests.java b/server/src/test/java/org/opensearch/index/get/GetResultTests.java index 7aa50452845d7..f88d28af87bd6 100644 --- a/server/src/test/java/org/opensearch/index/get/GetResultTests.java +++ b/server/src/test/java/org/opensearch/index/get/GetResultTests.java @@ -38,11 +38,11 @@ import org.opensearch.common.collect.Tuple; import org.opensearch.common.document.DocumentField; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.mapper.IdFieldMapper; import org.opensearch.index.mapper.IndexFieldMapper; import org.opensearch.index.mapper.SeqNoFieldMapper; diff --git a/server/src/test/java/org/opensearch/index/mapper/DataStreamFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/DataStreamFieldMapperTests.java index 285a1a472565f..8fdc1b8a62be6 100644 --- a/server/src/test/java/org/opensearch/index/mapper/DataStreamFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/DataStreamFieldMapperTests.java @@ -8,9 +8,9 @@ package org.opensearch.index.mapper; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.test.OpenSearchSingleNodeTestCase; diff --git a/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java index 83b782fb3fbd0..b8a1b9974546e 100644 --- a/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java @@ -39,18 +39,19 @@ import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; -import org.opensearch.core.common.ParsingException; -import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.geo.GeoPoint; -import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.lucene.search.function.CombineFunction; import org.opensearch.common.lucene.search.function.FieldValueFactorFunction; import org.opensearch.common.lucene.search.function.FunctionScoreQuery; import org.opensearch.common.lucene.search.function.WeightFactorFunction; import org.opensearch.common.unit.DistanceUnit; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.ParsingException; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.xcontent.MediaType; +import org.opensearch.core.xcontent.XContentHelper; +import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.mapper.SeqNoFieldMapper; import org.opensearch.index.query.MatchAllQueryBuilder; import org.opensearch.index.query.MatchNoneQueryBuilder; @@ -359,7 +360,7 @@ public void testParseFunctionsArray() throws IOException { * given that we copy part of the decay functions as bytes, we test that fromXContent and toXContent both work no matter what the * initial format was */ - for (XContentType xContentType : XContentType.values()) { + for (MediaType xContentType : XContentType.values()) { assertThat(queryBuilder, instanceOf(FunctionScoreQueryBuilder.class)); FunctionScoreQueryBuilder functionScoreQueryBuilder = (FunctionScoreQueryBuilder) queryBuilder; assertThat(functionScoreQueryBuilder.query(), instanceOf(TermQueryBuilder.class)); diff --git a/server/src/test/java/org/opensearch/index/reindex/AbstractBulkByScrollRequestTestCase.java b/server/src/test/java/org/opensearch/index/reindex/AbstractBulkByScrollRequestTestCase.java index 67969f2870f08..2abac646bc241 100644 --- a/server/src/test/java/org/opensearch/index/reindex/AbstractBulkByScrollRequestTestCase.java +++ b/server/src/test/java/org/opensearch/index/reindex/AbstractBulkByScrollRequestTestCase.java @@ -35,7 +35,7 @@ import org.opensearch.action.search.SearchRequest; import org.opensearch.action.support.ActiveShardCount; import org.opensearch.core.xcontent.ToXContent; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.AbstractXContentTestCase; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/index/reindex/LeaderBulkByScrollTaskStateTests.java b/server/src/test/java/org/opensearch/index/reindex/LeaderBulkByScrollTaskStateTests.java index d24f720273586..a1205980d4f11 100644 --- a/server/src/test/java/org/opensearch/index/reindex/LeaderBulkByScrollTaskStateTests.java +++ b/server/src/test/java/org/opensearch/index/reindex/LeaderBulkByScrollTaskStateTests.java @@ -32,8 +32,8 @@ package org.opensearch.index.reindex; -import org.opensearch.action.ActionListener; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.junit.Before; import org.mockito.ArgumentCaptor; diff --git a/server/src/test/java/org/opensearch/index/reindex/WorkerBulkByScrollTaskStateTests.java b/server/src/test/java/org/opensearch/index/reindex/WorkerBulkByScrollTaskStateTests.java index 1724f552da845..08ca8fd3ced90 100644 --- a/server/src/test/java/org/opensearch/index/reindex/WorkerBulkByScrollTaskStateTests.java +++ b/server/src/test/java/org/opensearch/index/reindex/WorkerBulkByScrollTaskStateTests.java @@ -34,7 +34,7 @@ import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.AbstractRunnable; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/test/java/org/opensearch/index/replication/IndexLevelReplicationTests.java b/server/src/test/java/org/opensearch/index/replication/IndexLevelReplicationTests.java index 9465f73394e40..cea443bccacb8 100644 --- a/server/src/test/java/org/opensearch/index/replication/IndexLevelReplicationTests.java +++ b/server/src/test/java/org/opensearch/index/replication/IndexLevelReplicationTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.bulk.BulkItemResponse; import org.opensearch.action.bulk.BulkShardRequest; diff --git a/server/src/test/java/org/opensearch/index/replication/RecoveryDuringReplicationTests.java b/server/src/test/java/org/opensearch/index/replication/RecoveryDuringReplicationTests.java index 13566a66034bd..1e7948d70e57b 100644 --- a/server/src/test/java/org/opensearch/index/replication/RecoveryDuringReplicationTests.java +++ b/server/src/test/java/org/opensearch/index/replication/RecoveryDuringReplicationTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.IndexableField; import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.admin.indices.forcemerge.ForceMergeRequest; import org.opensearch.action.bulk.BulkShardRequest; diff --git a/server/src/test/java/org/opensearch/index/replication/RetentionLeasesReplicationTests.java b/server/src/test/java/org/opensearch/index/replication/RetentionLeasesReplicationTests.java index b4d21a360bc9c..efa5782615648 100644 --- a/server/src/test/java/org/opensearch/index/replication/RetentionLeasesReplicationTests.java +++ b/server/src/test/java/org/opensearch/index/replication/RetentionLeasesReplicationTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.replication; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.action.support.replication.ReplicationResponse; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/server/src/test/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseExpiryTests.java b/server/src/test/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseExpiryTests.java index 4d9c73cd8cb0e..87989cf815e41 100644 --- a/server/src/test/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseExpiryTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseExpiryTests.java @@ -31,7 +31,7 @@ package org.opensearch.index.seqno; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.replication.ReplicationResponse; import org.opensearch.cluster.routing.AllocationId; import org.opensearch.cluster.routing.IndexShardRoutingTable; diff --git a/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java b/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java index 6c9bf879e725a..b760d9c276eea 100644 --- a/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.seqno; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.action.support.replication.ReplicationResponse; import org.opensearch.cluster.routing.AllocationId; diff --git a/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerTests.java b/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerTests.java index 5e88b892cc835..acdc1e3b52fcf 100644 --- a/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerTests.java @@ -33,7 +33,7 @@ package org.opensearch.index.seqno; import org.apache.lucene.codecs.Codec; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.replication.ReplicationResponse; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.routing.AllocationId; diff --git a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseActionsTests.java b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseActionsTests.java index 2a19a98c1d63a..44666dabf00a2 100644 --- a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseActionsTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseActionsTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.seqno; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.stats.IndicesStatsAction; import org.opensearch.action.admin.indices.stats.IndicesStatsRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; diff --git a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncActionTests.java b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncActionTests.java index baffd41d68dea..2dd8d72529fb2 100644 --- a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncActionTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseBackgroundSyncActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.seqno; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.ActionTestUtils; diff --git a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseStatsTests.java b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseStatsTests.java index 45bbc92c65aa5..3f0b23b26b330 100644 --- a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseStatsTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseStatsTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.seqno; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; import org.opensearch.action.support.replication.ReplicationResponse; import org.opensearch.common.settings.Settings; diff --git a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseSyncActionTests.java b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseSyncActionTests.java index 6a87ea1088492..064ac144a5abe 100644 --- a/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseSyncActionTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/RetentionLeaseSyncActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.seqno; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.ActionTestUtils; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/test/java/org/opensearch/index/shard/IndexShardOperationPermitsTests.java b/server/src/test/java/org/opensearch/index/shard/IndexShardOperationPermitsTests.java index 0296465352836..748892c3fb649 100644 --- a/server/src/test/java/org/opensearch/index/shard/IndexShardOperationPermitsTests.java +++ b/server/src/test/java/org/opensearch/index/shard/IndexShardOperationPermitsTests.java @@ -31,7 +31,7 @@ package org.opensearch.index.shard; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.common.CheckedRunnable; import org.opensearch.common.settings.Settings; diff --git a/server/src/test/java/org/opensearch/index/shard/IndexShardRetentionLeaseTests.java b/server/src/test/java/org/opensearch/index/shard/IndexShardRetentionLeaseTests.java index 3de5175bac7c5..3af4b3846140b 100644 --- a/server/src/test/java/org/opensearch/index/shard/IndexShardRetentionLeaseTests.java +++ b/server/src/test/java/org/opensearch/index/shard/IndexShardRetentionLeaseTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.shard; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.routing.RecoverySource; import org.opensearch.cluster.routing.ShardRoutingHelper; import org.opensearch.common.collect.Tuple; diff --git a/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java index a42d5ddf5d610..36805f275d1b4 100644 --- a/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java @@ -52,7 +52,7 @@ import org.junit.Assert; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.admin.indices.forcemerge.ForceMergeRequest; import org.opensearch.action.admin.indices.stats.CommonStats; @@ -74,6 +74,7 @@ import org.opensearch.common.CheckedFunction; import org.opensearch.common.Randomness; import org.opensearch.common.UUIDs; +import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.common.collect.Tuple; import org.opensearch.common.concurrent.GatedCloseable; import org.opensearch.common.io.PathUtils; diff --git a/server/src/test/java/org/opensearch/index/shard/RemoteStoreRefreshListenerTests.java b/server/src/test/java/org/opensearch/index/shard/RemoteStoreRefreshListenerTests.java index 889c6b0121450..2b2b1d744d061 100644 --- a/server/src/test/java/org/opensearch/index/shard/RemoteStoreRefreshListenerTests.java +++ b/server/src/test/java/org/opensearch/index/shard/RemoteStoreRefreshListenerTests.java @@ -14,7 +14,7 @@ import org.apache.lucene.store.FilterDirectory; import org.apache.lucene.tests.store.BaseDirectoryWrapper; import org.junit.After; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.routing.IndexShardRoutingTable; import org.opensearch.cluster.routing.ShardRouting; diff --git a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java index 549909dfc55e6..070bcae1b4a4b 100644 --- a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java @@ -13,7 +13,7 @@ import org.apache.lucene.store.AlreadyClosedException; import org.junit.Assert; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.admin.indices.forcemerge.ForceMergeRequest; import org.opensearch.action.index.IndexRequest; @@ -107,7 +107,6 @@ protected Settings getIndexSettings() { /** * Validates happy path of segment replication where primary index docs which are replicated to replica shards. Assertions * made on doc count on both primary and replica. - * @throws Exception */ public void testReplication() throws Exception { try (ReplicationGroup shards = createGroup(1, getIndexSettings(), indexMapping, new NRTReplicationEngineFactory());) { diff --git a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java index b7b9d15457755..1df7c72cbc8a8 100644 --- a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java @@ -10,7 +10,7 @@ import org.apache.lucene.index.SegmentInfos; import org.junit.Assert; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.delete.DeleteRequest; import org.opensearch.action.index.IndexRequest; @@ -353,7 +353,6 @@ public void testReplicaReceivesGenIncrease() throws Exception { /** * Verifies that commits on replica engine resulting from engine or reader close does not cleanup the temporary * replication files from ongoing round of segment replication - * @throws Exception */ public void testTemporaryFilesNotCleanup() throws Exception { String mappings = "{ \"" + MapperService.SINGLE_MAPPING_NAME + "\": { \"properties\": { \"foo\": { \"type\": \"keyword\"} }}}"; diff --git a/server/src/test/java/org/opensearch/index/store/RemoteDirectoryTests.java b/server/src/test/java/org/opensearch/index/store/RemoteDirectoryTests.java index 8ee5fcf0da9d7..d46b62048b4d3 100644 --- a/server/src/test/java/org/opensearch/index/store/RemoteDirectoryTests.java +++ b/server/src/test/java/org/opensearch/index/store/RemoteDirectoryTests.java @@ -12,7 +12,7 @@ import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; import org.junit.Before; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.common.blobstore.BlobContainer; import org.opensearch.common.blobstore.BlobMetadata; diff --git a/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryFactoryTests.java b/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryFactoryTests.java index 682c9c53d10a0..704f72037e571 100644 --- a/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryFactoryTests.java +++ b/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryFactoryTests.java @@ -11,7 +11,7 @@ import org.apache.lucene.store.Directory; import org.junit.Before; import org.mockito.ArgumentCaptor; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.blobstore.BlobContainer; 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 b2d55171e680d..317d083a75627 100644 --- a/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java +++ b/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java @@ -23,7 +23,7 @@ import org.junit.After; import org.junit.Before; import org.mockito.Mockito; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.UUIDs; import org.opensearch.common.blobstore.VerifyingMultiStreamBlobContainer; diff --git a/server/src/test/java/org/opensearch/index/translog/transfer/BlobStoreTransferServiceMockRepositoryTests.java b/server/src/test/java/org/opensearch/index/translog/transfer/BlobStoreTransferServiceMockRepositoryTests.java index 1175716679d0f..14d63080e4b6e 100644 --- a/server/src/test/java/org/opensearch/index/translog/transfer/BlobStoreTransferServiceMockRepositoryTests.java +++ b/server/src/test/java/org/opensearch/index/translog/transfer/BlobStoreTransferServiceMockRepositoryTests.java @@ -9,7 +9,7 @@ package org.opensearch.index.translog.transfer; import org.mockito.Mockito; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.common.blobstore.BlobPath; import org.opensearch.common.blobstore.BlobStore; diff --git a/server/src/test/java/org/opensearch/index/translog/transfer/BlobStoreTransferServiceTests.java b/server/src/test/java/org/opensearch/index/translog/transfer/BlobStoreTransferServiceTests.java index 5502dc3089c62..0f2090a2d83b0 100644 --- a/server/src/test/java/org/opensearch/index/translog/transfer/BlobStoreTransferServiceTests.java +++ b/server/src/test/java/org/opensearch/index/translog/transfer/BlobStoreTransferServiceTests.java @@ -8,7 +8,7 @@ package org.opensearch.index.translog.transfer; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.cluster.metadata.RepositoryMetadata; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/test/java/org/opensearch/index/translog/transfer/TranslogTransferManagerTests.java b/server/src/test/java/org/opensearch/index/translog/transfer/TranslogTransferManagerTests.java index 99937faa18584..ae354a2f38e81 100644 --- a/server/src/test/java/org/opensearch/index/translog/transfer/TranslogTransferManagerTests.java +++ b/server/src/test/java/org/opensearch/index/translog/transfer/TranslogTransferManagerTests.java @@ -10,7 +10,7 @@ import org.apache.lucene.tests.util.LuceneTestCase; import org.mockito.Mockito; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.common.blobstore.BlobContainer; import org.opensearch.common.blobstore.BlobMetadata; diff --git a/server/src/test/java/org/opensearch/indices/IndicesServiceTests.java b/server/src/test/java/org/opensearch/indices/IndicesServiceTests.java index 2c0f061f13e58..1c38e087e8da9 100644 --- a/server/src/test/java/org/opensearch/indices/IndicesServiceTests.java +++ b/server/src/test/java/org/opensearch/indices/IndicesServiceTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.search.similarities.Similarity; import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.stats.CommonStatsFlags; import org.opensearch.action.admin.indices.stats.IndexShardStats; import org.opensearch.cluster.ClusterName; diff --git a/server/src/test/java/org/opensearch/indices/cluster/AbstractIndicesClusterStateServiceTestCase.java b/server/src/test/java/org/opensearch/indices/cluster/AbstractIndicesClusterStateServiceTestCase.java index 65a70b9f059f7..3cc374fa1bfbf 100644 --- a/server/src/test/java/org/opensearch/indices/cluster/AbstractIndicesClusterStateServiceTestCase.java +++ b/server/src/test/java/org/opensearch/indices/cluster/AbstractIndicesClusterStateServiceTestCase.java @@ -33,7 +33,7 @@ package org.opensearch.indices.cluster; import org.junit.Before; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java b/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java index 16f046306dc7c..25e54daaa7fc1 100644 --- a/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java +++ b/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.admin.cluster.reroute.ClusterRerouteRequest; import org.opensearch.action.admin.cluster.reroute.TransportClusterRerouteAction; import org.opensearch.action.admin.indices.close.CloseIndexRequest; diff --git a/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java b/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java index 0eacb2c6c5b22..d6a022427faaf 100644 --- a/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java +++ b/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java @@ -49,7 +49,7 @@ import org.junit.Before; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.StepListener; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/test/java/org/opensearch/indices/recovery/PeerRecoveryTargetServiceTests.java b/server/src/test/java/org/opensearch/indices/recovery/PeerRecoveryTargetServiceTests.java index cde2c4d5a677f..b74f657d4b201 100644 --- a/server/src/test/java/org/opensearch/indices/recovery/PeerRecoveryTargetServiceTests.java +++ b/server/src/test/java/org/opensearch/indices/recovery/PeerRecoveryTargetServiceTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/test/java/org/opensearch/indices/recovery/RecoveryTests.java b/server/src/test/java/org/opensearch/indices/recovery/RecoveryTests.java index de25d7cf527ee..7e00a33cf2a88 100644 --- a/server/src/test/java/org/opensearch/indices/recovery/RecoveryTests.java +++ b/server/src/test/java/org/opensearch/indices/recovery/RecoveryTests.java @@ -41,7 +41,7 @@ import org.apache.lucene.index.NoMergePolicy; import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.bulk.BulkShardRequest; import org.opensearch.action.index.IndexRequest; diff --git a/server/src/test/java/org/opensearch/indices/recovery/ReplicationRequestTrackerTests.java b/server/src/test/java/org/opensearch/indices/recovery/ReplicationRequestTrackerTests.java index afad385deabe4..73a96160cf4d7 100644 --- a/server/src/test/java/org/opensearch/indices/recovery/ReplicationRequestTrackerTests.java +++ b/server/src/test/java/org/opensearch/indices/recovery/ReplicationRequestTrackerTests.java @@ -33,7 +33,7 @@ package org.opensearch.indices.recovery; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.common.util.concurrent.ConcurrentCollections; import org.opensearch.indices.replication.common.ReplicationRequestTracker; diff --git a/server/src/test/java/org/opensearch/indices/replication/OngoingSegmentReplicationsTests.java b/server/src/test/java/org/opensearch/indices/replication/OngoingSegmentReplicationsTests.java index 84f781b08e5f3..d04faf5a32a05 100644 --- a/server/src/test/java/org/opensearch/indices/replication/OngoingSegmentReplicationsTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/OngoingSegmentReplicationsTests.java @@ -9,7 +9,7 @@ package org.opensearch.indices.replication; import org.junit.Assert; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.settings.ClusterSettings; diff --git a/server/src/test/java/org/opensearch/indices/replication/PrimaryShardReplicationSourceTests.java b/server/src/test/java/org/opensearch/indices/replication/PrimaryShardReplicationSourceTests.java index 4d273c71e7861..1fbe3f1951d00 100644 --- a/server/src/test/java/org/opensearch/indices/replication/PrimaryShardReplicationSourceTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/PrimaryShardReplicationSourceTests.java @@ -11,7 +11,7 @@ import org.apache.lucene.codecs.Codec; import org.apache.lucene.util.Version; import org.junit.Assert; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodeRole; import org.opensearch.cluster.service.ClusterService; diff --git a/server/src/test/java/org/opensearch/indices/replication/SegmentFileTransferHandlerTests.java b/server/src/test/java/org/opensearch/indices/replication/SegmentFileTransferHandlerTests.java index d0065bfe013bd..f10ca5da0498c 100644 --- a/server/src/test/java/org/opensearch/indices/replication/SegmentFileTransferHandlerTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/SegmentFileTransferHandlerTests.java @@ -12,7 +12,7 @@ import org.apache.lucene.index.IndexFileNames; import org.junit.Assert; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.util.CancellableThreads; diff --git a/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceHandlerTests.java b/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceHandlerTests.java index ba993feb13362..53c01863eb478 100644 --- a/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceHandlerTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceHandlerTests.java @@ -14,7 +14,7 @@ import org.mockito.Mockito; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.settings.Settings; diff --git a/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceServiceTests.java b/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceServiceTests.java index 31ad67f35cdd2..55a50ff54a3a3 100644 --- a/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceServiceTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationSourceServiceTests.java @@ -10,7 +10,7 @@ import org.apache.lucene.codecs.Codec; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.routing.ShardRouting; diff --git a/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationTargetServiceTests.java b/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationTargetServiceTests.java index 4a04a64196918..75c2930c06db0 100644 --- a/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationTargetServiceTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationTargetServiceTests.java @@ -12,7 +12,7 @@ import org.junit.Assert; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationTargetTests.java b/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationTargetTests.java index 5b996fd774baf..9038c9fea8b16 100644 --- a/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationTargetTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/SegmentReplicationTargetTests.java @@ -28,7 +28,7 @@ import org.mockito.Mockito; import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchCorruptionException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; import org.opensearch.index.IndexSettings; diff --git a/server/src/test/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointActionTests.java b/server/src/test/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointActionTests.java index 48427ab7e5cd4..5ba8a79fb51ad 100644 --- a/server/src/test/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointActionTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/checkpoint/PublishCheckpointActionTests.java @@ -9,7 +9,7 @@ package org.opensearch.indices.replication.checkpoint; import org.apache.lucene.codecs.Codec; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.ActionTestUtils; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/test/java/org/opensearch/indices/settings/InternalOrPrivateSettingsPlugin.java b/server/src/test/java/org/opensearch/indices/settings/InternalOrPrivateSettingsPlugin.java index 7e79551605a6e..84db7cd1b298c 100644 --- a/server/src/test/java/org/opensearch/indices/settings/InternalOrPrivateSettingsPlugin.java +++ b/server/src/test/java/org/opensearch/indices/settings/InternalOrPrivateSettingsPlugin.java @@ -32,10 +32,10 @@ package org.opensearch.indices.settings; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest; diff --git a/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java b/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java index bfff3c77e1d89..766563bd1dc51 100644 --- a/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java +++ b/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java @@ -34,7 +34,7 @@ import org.opensearch.ResourceNotFoundException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.ClusterState; diff --git a/server/src/test/java/org/opensearch/persistent/PersistentTasksNodeServiceTests.java b/server/src/test/java/org/opensearch/persistent/PersistentTasksNodeServiceTests.java index 84ca449bec665..8ef8f5e248bdf 100644 --- a/server/src/test/java/org/opensearch/persistent/PersistentTasksNodeServiceTests.java +++ b/server/src/test/java/org/opensearch/persistent/PersistentTasksNodeServiceTests.java @@ -33,7 +33,7 @@ package org.opensearch.persistent; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse; import org.opensearch.client.Client; import org.opensearch.cluster.ClusterChangedEvent; @@ -52,7 +52,7 @@ import org.opensearch.persistent.TestPersistentTasksPlugin.TestParams; import org.opensearch.persistent.TestPersistentTasksPlugin.TestPersistentTasksExecutor; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.tasks.TaskManager; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; diff --git a/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java b/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java index 217fa7cf2d56c..818fef59c9a29 100644 --- a/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java +++ b/server/src/test/java/org/opensearch/persistent/TestPersistentTasksPlugin.java @@ -36,9 +36,9 @@ import org.apache.logging.log4j.Logger; import org.opensearch.Version; import org.opensearch.action.ActionType; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.FailedNodeException; import org.opensearch.action.TaskOperationFailure; import org.opensearch.action.support.ActionFilters; @@ -71,8 +71,8 @@ import org.opensearch.plugins.ActionPlugin; import org.opensearch.plugins.PersistentTaskPlugin; import org.opensearch.plugins.Plugin; -import org.opensearch.tasks.TaskCancelledException; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskId; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; diff --git a/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java b/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java index 076f11b679d16..164ea6871aacc 100644 --- a/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java +++ b/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.index.IndexCommit; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterName; diff --git a/server/src/test/java/org/opensearch/rest/action/RestCancellableNodeClientTests.java b/server/src/test/java/org/opensearch/rest/action/RestCancellableNodeClientTests.java index 0a4282451538e..1d60b7e34d8f5 100644 --- a/server/src/test/java/org/opensearch/rest/action/RestCancellableNodeClientTests.java +++ b/server/src/test/java/org/opensearch/rest/action/RestCancellableNodeClientTests.java @@ -32,9 +32,9 @@ package org.opensearch.rest.action; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksAction; import org.opensearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; @@ -47,7 +47,7 @@ import org.opensearch.http.HttpChannel; import org.opensearch.http.HttpResponse; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java b/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java index 6b463c3697162..cb7e457dbb9f1 100644 --- a/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/admin/indices/RestValidateQueryActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.rest.action.admin.indices; import java.util.List; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionType; import org.opensearch.action.ActionModule.DynamicActionRegistry; diff --git a/server/src/test/java/org/opensearch/rest/action/cat/RestTasksActionTests.java b/server/src/test/java/org/opensearch/rest/action/cat/RestTasksActionTests.java index 9657264aa7fe5..7654aba1e093b 100644 --- a/server/src/test/java/org/opensearch/rest/action/cat/RestTasksActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/cat/RestTasksActionTests.java @@ -32,9 +32,9 @@ package org.opensearch.rest.action.cat; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.cluster.node.DiscoveryNodes; diff --git a/server/src/test/java/org/opensearch/rest/action/document/RestBulkActionTests.java b/server/src/test/java/org/opensearch/rest/action/document/RestBulkActionTests.java index 9462a8f419bbf..e34f1584f68d1 100644 --- a/server/src/test/java/org/opensearch/rest/action/document/RestBulkActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/document/RestBulkActionTests.java @@ -33,7 +33,7 @@ package org.opensearch.rest.action.document; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.bulk.BulkRequest; import org.opensearch.action.bulk.BulkResponse; import org.opensearch.action.update.UpdateRequest; diff --git a/server/src/test/java/org/opensearch/search/ClearScrollResponseTests.java b/server/src/test/java/org/opensearch/search/ClearScrollResponseTests.java index 27c127e2c9ea1..9fa11ae92baa8 100644 --- a/server/src/test/java/org/opensearch/search/ClearScrollResponseTests.java +++ b/server/src/test/java/org/opensearch/search/ClearScrollResponseTests.java @@ -33,12 +33,13 @@ package org.opensearch.search; import org.opensearch.action.search.ClearScrollResponse; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentHelper; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.test.OpenSearchTestCase; @@ -58,17 +59,17 @@ public void testToXContent() throws IOException { } public void testToAndFromXContent() throws IOException { - XContentType xContentType = randomFrom(XContentType.values()); + MediaType mediaType = randomFrom(XContentType.values()); ClearScrollResponse originalResponse = createTestItem(); - BytesReference originalBytes = toShuffledXContent(originalResponse, xContentType, ToXContent.EMPTY_PARAMS, randomBoolean()); + BytesReference originalBytes = toShuffledXContent(originalResponse, mediaType, ToXContent.EMPTY_PARAMS, randomBoolean()); ClearScrollResponse parsedResponse; - try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) { + try (XContentParser parser = createParser(mediaType.xContent(), originalBytes)) { parsedResponse = ClearScrollResponse.fromXContent(parser); } assertEquals(originalResponse.isSucceeded(), parsedResponse.isSucceeded()); assertEquals(originalResponse.getNumFreed(), parsedResponse.getNumFreed()); - BytesReference parsedBytes = XContentHelper.toXContent(parsedResponse, xContentType, randomBoolean()); - assertToXContentEquivalent(originalBytes, parsedBytes, xContentType); + BytesReference parsedBytes = XContentHelper.toXContent(parsedResponse, mediaType, randomBoolean()); + assertToXContentEquivalent(originalBytes, parsedBytes, mediaType); } private static ClearScrollResponse createTestItem() { diff --git a/server/src/test/java/org/opensearch/search/CreatePitSingleNodeTests.java b/server/src/test/java/org/opensearch/search/CreatePitSingleNodeTests.java index 3a6743a334566..bfae712a9de36 100644 --- a/server/src/test/java/org/opensearch/search/CreatePitSingleNodeTests.java +++ b/server/src/test/java/org/opensearch/search/CreatePitSingleNodeTests.java @@ -9,7 +9,7 @@ package org.opensearch.search; import org.hamcrest.Matchers; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.search.CreatePitAction; import org.opensearch.action.search.CreatePitController; import org.opensearch.action.search.CreatePitRequest; diff --git a/server/src/test/java/org/opensearch/search/DeletePitResponseTests.java b/server/src/test/java/org/opensearch/search/DeletePitResponseTests.java index 638231b470689..8a9f635f7ef3b 100644 --- a/server/src/test/java/org/opensearch/search/DeletePitResponseTests.java +++ b/server/src/test/java/org/opensearch/search/DeletePitResponseTests.java @@ -10,13 +10,13 @@ import org.opensearch.action.search.DeletePitInfo; import org.opensearch.action.search.DeletePitResponse; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentHelper; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; -import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; diff --git a/server/src/test/java/org/opensearch/search/SearchCancellationTests.java b/server/src/test/java/org/opensearch/search/SearchCancellationTests.java index 011723da36a30..1ff797c7df81a 100644 --- a/server/src/test/java/org/opensearch/search/SearchCancellationTests.java +++ b/server/src/test/java/org/opensearch/search/SearchCancellationTests.java @@ -53,7 +53,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.search.internal.ContextIndexSearcher; import org.opensearch.search.internal.SearchContext; -import org.opensearch.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskCancelledException; import org.opensearch.test.OpenSearchTestCase; import org.junit.AfterClass; import org.junit.BeforeClass; diff --git a/server/src/test/java/org/opensearch/search/SearchServiceTests.java b/server/src/test/java/org/opensearch/search/SearchServiceTests.java index 8643941970fe0..bf4d1849e4cfd 100644 --- a/server/src/test/java/org/opensearch/search/SearchServiceTests.java +++ b/server/src/test/java/org/opensearch/search/SearchServiceTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.search.FieldDoc; import org.apache.lucene.search.Query; import org.apache.lucene.store.AlreadyClosedException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.action.index.IndexResponse; import org.opensearch.action.search.ClearScrollRequest; diff --git a/server/src/test/java/org/opensearch/search/aggregations/AggregationsTests.java b/server/src/test/java/org/opensearch/search/aggregations/AggregationsTests.java index fd82cd21e0fa6..f6b69fcc0340c 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/AggregationsTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/AggregationsTests.java @@ -32,16 +32,17 @@ package org.opensearch.search.aggregations; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.common.ParsingException; import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentHelper; +import org.opensearch.core.xcontent.XContentHelper; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.rest.action.search.RestSearchAction; import org.opensearch.search.aggregations.Aggregation.CommonFields; import org.opensearch.search.aggregations.bucket.adjacency.InternalAdjacencyMatrixTests; @@ -211,7 +212,7 @@ public void testFromXContentWithRandomFields() throws IOException { /** * Test that parsing works for a randomly created Aggregations object with a * randomized aggregation tree. The test randomly chooses an - * {@link XContentType}, randomizes the order of the {@link XContent} fields + * {@link MediaType}, randomizes the order of the {@link XContent} fields * and randomly sets the `humanReadable` flag when rendering the * {@link XContent}. * @@ -221,10 +222,10 @@ public void testFromXContentWithRandomFields() throws IOException { * responses */ private void parseAndAssert(boolean addRandomFields) throws IOException { - XContentType xContentType = randomFrom(XContentType.values()); + MediaType mediaType = randomFrom(XContentType.values()); final ToXContent.Params params = new ToXContent.MapParams(singletonMap(RestSearchAction.TYPED_KEYS_PARAM, "true")); Aggregations aggregations = createTestInstance(1, 0, 3); - BytesReference originalBytes = toShuffledXContent(aggregations, xContentType, params, randomBoolean()); + BytesReference originalBytes = toShuffledXContent(aggregations, mediaType, params, randomBoolean()); BytesReference mutated; if (addRandomFields) { /* @@ -254,18 +255,18 @@ private void parseAndAssert(boolean addRandomFields) throws IOException { || path.endsWith("correlation") || path.contains(CommonFields.VALUE.getPreferredName()) || path.endsWith(CommonFields.KEY.getPreferredName())) || path.contains("top_hits"); - mutated = insertRandomFields(xContentType, originalBytes, excludes, random()); + mutated = insertRandomFields(mediaType, originalBytes, excludes, random()); } else { mutated = originalBytes; } - try (XContentParser parser = createParser(xContentType.xContent(), mutated)) { + try (XContentParser parser = createParser(mediaType.xContent(), mutated)) { assertEquals(XContentParser.Token.START_OBJECT, parser.nextToken()); assertEquals(XContentParser.Token.FIELD_NAME, parser.nextToken()); assertEquals(Aggregations.AGGREGATIONS_FIELD, parser.currentName()); assertEquals(XContentParser.Token.START_OBJECT, parser.nextToken()); Aggregations parsedAggregations = Aggregations.fromXContent(parser); - BytesReference parsedBytes = XContentHelper.toXContent(parsedAggregations, xContentType, randomBoolean()); - OpenSearchAssertions.assertToXContentEquivalent(originalBytes, parsedBytes, xContentType); + BytesReference parsedBytes = XContentHelper.toXContent(parsedAggregations, mediaType, randomBoolean()); + OpenSearchAssertions.assertToXContentEquivalent(originalBytes, parsedBytes, mediaType); } } diff --git a/server/src/test/java/org/opensearch/search/aggregations/AggregatorFactoriesTests.java b/server/src/test/java/org/opensearch/search/aggregations/AggregatorFactoriesTests.java index 3a527ec7455d3..eed64189c7120 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/AggregatorFactoriesTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/AggregatorFactoriesTests.java @@ -31,7 +31,7 @@ package org.opensearch.search.aggregations; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.ParsingException; import org.opensearch.common.SetOnce; import org.opensearch.core.common.bytes.BytesReference; diff --git a/server/src/test/java/org/opensearch/search/internal/ShardSearchRequestTests.java b/server/src/test/java/org/opensearch/search/internal/ShardSearchRequestTests.java index d84cc1b5ff51f..c65262253d1fc 100644 --- a/server/src/test/java/org/opensearch/search/internal/ShardSearchRequestTests.java +++ b/server/src/test/java/org/opensearch/search/internal/ShardSearchRequestTests.java @@ -38,21 +38,21 @@ import org.opensearch.cluster.metadata.AliasMetadata; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.Nullable; -import org.opensearch.core.common.Strings; import org.opensearch.common.UUIDs; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; +import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.core.common.Strings; +import org.opensearch.core.index.shard.ShardId; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.query.RandomQueryBuilder; -import org.opensearch.core.index.shard.ShardId; import org.opensearch.indices.InvalidAliasNameException; import org.opensearch.search.AbstractSearchTestCase; import org.opensearch.search.SearchSortValuesAndFormatsTests; diff --git a/server/src/test/java/org/opensearch/search/pit/RestCreatePitActionTests.java b/server/src/test/java/org/opensearch/search/pit/RestCreatePitActionTests.java index 2ddd6eda122b4..64e57a89ebbed 100644 --- a/server/src/test/java/org/opensearch/search/pit/RestCreatePitActionTests.java +++ b/server/src/test/java/org/opensearch/search/pit/RestCreatePitActionTests.java @@ -8,7 +8,7 @@ package org.opensearch.search.pit; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.CreatePitRequest; import org.opensearch.action.search.CreatePitResponse; import org.opensearch.client.node.NodeClient; diff --git a/server/src/test/java/org/opensearch/search/pit/RestDeletePitActionTests.java b/server/src/test/java/org/opensearch/search/pit/RestDeletePitActionTests.java index d8e04519ed865..0628c82b4a0e2 100644 --- a/server/src/test/java/org/opensearch/search/pit/RestDeletePitActionTests.java +++ b/server/src/test/java/org/opensearch/search/pit/RestDeletePitActionTests.java @@ -8,7 +8,7 @@ package org.opensearch.search.pit; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.DeletePitRequest; import org.opensearch.action.search.DeletePitResponse; import org.opensearch.client.node.NodeClient; diff --git a/server/src/test/java/org/opensearch/search/query/QueryPhaseTests.java b/server/src/test/java/org/opensearch/search/query/QueryPhaseTests.java index a2303e6f76c41..c434e9ee71356 100644 --- a/server/src/test/java/org/opensearch/search/query/QueryPhaseTests.java +++ b/server/src/test/java/org/opensearch/search/query/QueryPhaseTests.java @@ -105,7 +105,7 @@ import org.opensearch.search.internal.ScrollContext; import org.opensearch.search.internal.SearchContext; import org.opensearch.search.sort.SortAndFormats; -import org.opensearch.tasks.TaskCancelledException; +import org.opensearch.core.tasks.TaskCancelledException; import org.opensearch.test.TestSearchContext; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/test/java/org/opensearch/search/scroll/RestClearScrollActionTests.java b/server/src/test/java/org/opensearch/search/scroll/RestClearScrollActionTests.java index f1614e9afb0a9..6cabdd42fd350 100644 --- a/server/src/test/java/org/opensearch/search/scroll/RestClearScrollActionTests.java +++ b/server/src/test/java/org/opensearch/search/scroll/RestClearScrollActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.search.scroll; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.ClearScrollRequest; import org.opensearch.action.search.ClearScrollResponse; import org.opensearch.client.node.NodeClient; diff --git a/server/src/test/java/org/opensearch/search/scroll/RestSearchScrollActionTests.java b/server/src/test/java/org/opensearch/search/scroll/RestSearchScrollActionTests.java index f8596c9e64966..fdada81862d01 100644 --- a/server/src/test/java/org/opensearch/search/scroll/RestSearchScrollActionTests.java +++ b/server/src/test/java/org/opensearch/search/scroll/RestSearchScrollActionTests.java @@ -32,7 +32,7 @@ package org.opensearch.search.scroll; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.search.SearchResponse; import org.opensearch.action.search.SearchScrollRequest; import org.opensearch.client.node.NodeClient; diff --git a/server/src/test/java/org/opensearch/snapshots/BlobStoreFormatTests.java b/server/src/test/java/org/opensearch/snapshots/BlobStoreFormatTests.java index 3129dce795cf8..008d569e22b38 100644 --- a/server/src/test/java/org/opensearch/snapshots/BlobStoreFormatTests.java +++ b/server/src/test/java/org/opensearch/snapshots/BlobStoreFormatTests.java @@ -40,7 +40,7 @@ import org.opensearch.common.blobstore.BlobStore; import org.opensearch.common.blobstore.fs.FsBlobStore; import org.opensearch.core.common.bytes.BytesArray; -import org.opensearch.common.compress.Compressor; +import org.opensearch.core.common.compress.Compressor; import org.opensearch.common.compress.CompressorFactory; import org.opensearch.common.compress.CompressorType; import org.opensearch.common.io.Streams; diff --git a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java index ce918ba40d8be..c3784028d5ba8 100644 --- a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java @@ -37,7 +37,7 @@ import org.mockito.Mockito; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionModule.DynamicActionRegistry; import org.opensearch.action.ActionType; import org.opensearch.action.RequestValidators; diff --git a/server/src/test/java/org/opensearch/tasks/ListTasksResponseTests.java b/server/src/test/java/org/opensearch/tasks/ListTasksResponseTests.java index 5da0727d23fed..afaf3e4cdaf59 100644 --- a/server/src/test/java/org/opensearch/tasks/ListTasksResponseTests.java +++ b/server/src/test/java/org/opensearch/tasks/ListTasksResponseTests.java @@ -37,6 +37,10 @@ import org.opensearch.action.TaskOperationFailure; import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.opensearch.core.common.Strings; +import org.opensearch.core.tasks.TaskId; +import org.opensearch.core.tasks.resourcetracker.TaskResourceStats; +import org.opensearch.core.tasks.resourcetracker.TaskResourceUsage; +import org.opensearch.core.tasks.resourcetracker.TaskThreadUsage; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.test.AbstractXContentTestCase; diff --git a/server/src/test/java/org/opensearch/tasks/TaskCancellationMonitoringServiceTests.java b/server/src/test/java/org/opensearch/tasks/TaskCancellationMonitoringServiceTests.java index 56e851871187b..abbf072b111c3 100644 --- a/server/src/test/java/org/opensearch/tasks/TaskCancellationMonitoringServiceTests.java +++ b/server/src/test/java/org/opensearch/tasks/TaskCancellationMonitoringServiceTests.java @@ -15,6 +15,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.transport.MockTransportService; import org.opensearch.threadpool.Scheduler; diff --git a/server/src/test/java/org/opensearch/tasks/TaskIdTests.java b/server/src/test/java/org/opensearch/tasks/TaskIdTests.java index 0e77f7523cea0..7d43b9b4b737e 100644 --- a/server/src/test/java/org/opensearch/tasks/TaskIdTests.java +++ b/server/src/test/java/org/opensearch/tasks/TaskIdTests.java @@ -36,6 +36,7 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; diff --git a/server/src/test/java/org/opensearch/tasks/TaskInfoTests.java b/server/src/test/java/org/opensearch/tasks/TaskInfoTests.java index 6ee91cec29d49..75cf57a24a95a 100644 --- a/server/src/test/java/org/opensearch/tasks/TaskInfoTests.java +++ b/server/src/test/java/org/opensearch/tasks/TaskInfoTests.java @@ -36,6 +36,10 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.core.common.io.stream.Writeable; +import org.opensearch.core.tasks.TaskId; +import org.opensearch.core.tasks.resourcetracker.TaskResourceStats; +import org.opensearch.core.tasks.resourcetracker.TaskResourceUsage; +import org.opensearch.core.tasks.resourcetracker.TaskThreadUsage; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.test.AbstractSerializingTestCase; diff --git a/server/src/test/java/org/opensearch/tasks/TaskManagerTests.java b/server/src/test/java/org/opensearch/tasks/TaskManagerTests.java index 31f3c0a7da094..5ae66577afc9b 100644 --- a/server/src/test/java/org/opensearch/tasks/TaskManagerTests.java +++ b/server/src/test/java/org/opensearch/tasks/TaskManagerTests.java @@ -32,13 +32,14 @@ package org.opensearch.tasks; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.node.tasks.TransportTasksActionTests; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.ConcurrentCollections; import org.opensearch.common.lease.Releasable; import org.opensearch.common.lease.Releasables; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.RunnableTaskExecutionListener; import org.opensearch.threadpool.TestThreadPool; diff --git a/server/src/test/java/org/opensearch/tasks/TaskResourceTrackingServiceTests.java b/server/src/test/java/org/opensearch/tasks/TaskResourceTrackingServiceTests.java index 3dcd634c234a3..913346b630a45 100644 --- a/server/src/test/java/org/opensearch/tasks/TaskResourceTrackingServiceTests.java +++ b/server/src/test/java/org/opensearch/tasks/TaskResourceTrackingServiceTests.java @@ -15,6 +15,8 @@ import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.tasks.TaskId; +import org.opensearch.core.tasks.resourcetracker.ThreadResourceInfo; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; @@ -26,8 +28,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import static org.opensearch.tasks.ResourceStats.CPU; -import static org.opensearch.tasks.ResourceStats.MEMORY; +import static org.opensearch.core.tasks.resourcetracker.ResourceStats.CPU; +import static org.opensearch.core.tasks.resourcetracker.ResourceStats.MEMORY; import static org.opensearch.tasks.TaskResourceTrackingService.TASK_ID; public class TaskResourceTrackingServiceTests extends OpenSearchTestCase { diff --git a/server/src/test/java/org/opensearch/tasks/consumer/SearchShardTaskDetailsLogMessageTests.java b/server/src/test/java/org/opensearch/tasks/consumer/SearchShardTaskDetailsLogMessageTests.java index 641fdef4891bd..099f70a3b14d3 100644 --- a/server/src/test/java/org/opensearch/tasks/consumer/SearchShardTaskDetailsLogMessageTests.java +++ b/server/src/test/java/org/opensearch/tasks/consumer/SearchShardTaskDetailsLogMessageTests.java @@ -9,9 +9,9 @@ package org.opensearch.tasks.consumer; import org.opensearch.action.search.SearchShardTask; -import org.opensearch.tasks.ResourceStats; -import org.opensearch.tasks.ResourceStatsType; -import org.opensearch.tasks.ResourceUsageMetric; +import org.opensearch.core.tasks.resourcetracker.ResourceStats; +import org.opensearch.core.tasks.resourcetracker.ResourceStatsType; +import org.opensearch.core.tasks.resourcetracker.ResourceUsageMetric; import org.opensearch.tasks.Task; import org.opensearch.test.OpenSearchSingleNodeTestCase; diff --git a/server/src/test/java/org/opensearch/tasks/consumer/TopNSearchTasksLoggerTests.java b/server/src/test/java/org/opensearch/tasks/consumer/TopNSearchTasksLoggerTests.java index 73f9f7c0e08cc..837404d740c10 100644 --- a/server/src/test/java/org/opensearch/tasks/consumer/TopNSearchTasksLoggerTests.java +++ b/server/src/test/java/org/opensearch/tasks/consumer/TopNSearchTasksLoggerTests.java @@ -21,9 +21,9 @@ import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; -import org.opensearch.tasks.ResourceStats; -import org.opensearch.tasks.ResourceStatsType; -import org.opensearch.tasks.ResourceUsageMetric; +import org.opensearch.core.tasks.resourcetracker.ResourceStats; +import org.opensearch.core.tasks.resourcetracker.ResourceStatsType; +import org.opensearch.core.tasks.resourcetracker.ResourceUsageMetric; import org.opensearch.tasks.Task; import org.opensearch.test.OpenSearchSingleNodeTestCase; diff --git a/server/src/test/java/org/opensearch/test/NoopDiscovery.java b/server/src/test/java/org/opensearch/test/NoopDiscovery.java index f7365d7d71693..f1fdbc018fb8f 100644 --- a/server/src/test/java/org/opensearch/test/NoopDiscovery.java +++ b/server/src/test/java/org/opensearch/test/NoopDiscovery.java @@ -31,7 +31,7 @@ package org.opensearch.test; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.common.lifecycle.Lifecycle; import org.opensearch.common.lifecycle.LifecycleListener; diff --git a/server/src/test/java/org/opensearch/transport/ClusterConnectionManagerTests.java b/server/src/test/java/org/opensearch/transport/ClusterConnectionManagerTests.java index e3d3e17c41fcb..9295bbc17585e 100644 --- a/server/src/test/java/org/opensearch/transport/ClusterConnectionManagerTests.java +++ b/server/src/test/java/org/opensearch/transport/ClusterConnectionManagerTests.java @@ -33,7 +33,7 @@ package org.opensearch.transport; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.settings.Settings; diff --git a/server/src/test/java/org/opensearch/transport/InboundHandlerTests.java b/server/src/test/java/org/opensearch/transport/InboundHandlerTests.java index d4959472bd08a..349982a2a96af 100644 --- a/server/src/test/java/org/opensearch/transport/InboundHandlerTests.java +++ b/server/src/test/java/org/opensearch/transport/InboundHandlerTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.util.BytesRef; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.bytes.ReleasableBytesReference; @@ -90,7 +90,7 @@ public void setUp() throws Exception { super.setUp(); taskManager = new TaskManager(Settings.EMPTY, threadPool, Collections.emptySet()); channel = new FakeTcpChannel(randomBoolean(), buildNewFakeTransportAddress().address(), buildNewFakeTransportAddress().address()) { - public void sendMessage(BytesReference reference, org.opensearch.action.ActionListener listener) { + public void sendMessage(BytesReference reference, ActionListener listener) { super.sendMessage(reference, listener); if (listener != null) { listener.onResponse(null); diff --git a/server/src/test/java/org/opensearch/transport/OutboundHandlerTests.java b/server/src/test/java/org/opensearch/transport/OutboundHandlerTests.java index ad82fd6ada5f4..9be7269b8de25 100644 --- a/server/src/test/java/org/opensearch/transport/OutboundHandlerTests.java +++ b/server/src/test/java/org/opensearch/transport/OutboundHandlerTests.java @@ -34,7 +34,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.breaker.CircuitBreaker; import org.opensearch.core.common.breaker.NoopCircuitBreaker; diff --git a/server/src/test/java/org/opensearch/transport/RemoteClusterAwareClientTests.java b/server/src/test/java/org/opensearch/transport/RemoteClusterAwareClientTests.java index 8e11c53e00b35..74040f30fd130 100644 --- a/server/src/test/java/org/opensearch/transport/RemoteClusterAwareClientTests.java +++ b/server/src/test/java/org/opensearch/transport/RemoteClusterAwareClientTests.java @@ -33,7 +33,7 @@ package org.opensearch.transport; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.LatchedActionListener; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsRequest; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsResponse; diff --git a/server/src/test/java/org/opensearch/transport/RemoteClusterConnectionTests.java b/server/src/test/java/org/opensearch/transport/RemoteClusterConnectionTests.java index e74c8b9fa7147..bc501356110c5 100644 --- a/server/src/test/java/org/opensearch/transport/RemoteClusterConnectionTests.java +++ b/server/src/test/java/org/opensearch/transport/RemoteClusterConnectionTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.search.TotalHits; import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsAction; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsGroup; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsRequest; diff --git a/server/src/test/java/org/opensearch/transport/RemoteClusterServiceTests.java b/server/src/test/java/org/opensearch/transport/RemoteClusterServiceTests.java index 52bf7aa08fe67..17801032c2343 100644 --- a/server/src/test/java/org/opensearch/transport/RemoteClusterServiceTests.java +++ b/server/src/test/java/org/opensearch/transport/RemoteClusterServiceTests.java @@ -32,7 +32,7 @@ package org.opensearch.transport; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.action.support.IndicesOptions; import org.opensearch.action.support.PlainActionFuture; diff --git a/server/src/test/java/org/opensearch/transport/RemoteConnectionManagerTests.java b/server/src/test/java/org/opensearch/transport/RemoteConnectionManagerTests.java index 5741024850756..64e379c912b8f 100644 --- a/server/src/test/java/org/opensearch/transport/RemoteConnectionManagerTests.java +++ b/server/src/test/java/org/opensearch/transport/RemoteConnectionManagerTests.java @@ -32,7 +32,7 @@ package org.opensearch.transport; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.settings.Settings; diff --git a/server/src/test/java/org/opensearch/transport/RemoteConnectionStrategyTests.java b/server/src/test/java/org/opensearch/transport/RemoteConnectionStrategyTests.java index 3888bcbdd3c99..b0c4a18892b3a 100644 --- a/server/src/test/java/org/opensearch/transport/RemoteConnectionStrategyTests.java +++ b/server/src/test/java/org/opensearch/transport/RemoteConnectionStrategyTests.java @@ -32,7 +32,7 @@ package org.opensearch.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/transport/TransportHandshakerTests.java b/server/src/test/java/org/opensearch/transport/TransportHandshakerTests.java index 6bbe926ea0384..0359dfbb68b5b 100644 --- a/server/src/test/java/org/opensearch/transport/TransportHandshakerTests.java +++ b/server/src/test/java/org/opensearch/transport/TransportHandshakerTests.java @@ -38,7 +38,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.unit.TimeValue; import org.opensearch.core.transport.TransportResponse; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; diff --git a/server/src/test/java/org/opensearch/transport/TransportRequestDeduplicatorTests.java b/server/src/test/java/org/opensearch/transport/TransportRequestDeduplicatorTests.java index 8b4a75a37317b..c28fc1116e6d6 100644 --- a/server/src/test/java/org/opensearch/transport/TransportRequestDeduplicatorTests.java +++ b/server/src/test/java/org/opensearch/transport/TransportRequestDeduplicatorTests.java @@ -31,9 +31,9 @@ package org.opensearch.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.common.SetOnce; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import java.util.concurrent.Phaser; diff --git a/server/src/test/java/org/opensearch/transport/TransportServiceDeserializationFailureTests.java b/server/src/test/java/org/opensearch/transport/TransportServiceDeserializationFailureTests.java index c23c213353888..73dd3d7ffdf2d 100644 --- a/server/src/test/java/org/opensearch/transport/TransportServiceDeserializationFailureTests.java +++ b/server/src/test/java/org/opensearch/transport/TransportServiceDeserializationFailureTests.java @@ -42,7 +42,7 @@ import org.opensearch.core.transport.TransportResponse; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskAwareRequest; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.transport.MockTransport; import org.opensearch.threadpool.ThreadPool; diff --git a/server/src/test/java/org/opensearch/transport/TransportServiceHandshakeTests.java b/server/src/test/java/org/opensearch/transport/TransportServiceHandshakeTests.java index b2bdf8e3cb4d9..8ff0561eed5f8 100644 --- a/server/src/test/java/org/opensearch/transport/TransportServiceHandshakeTests.java +++ b/server/src/test/java/org/opensearch/transport/TransportServiceHandshakeTests.java @@ -33,7 +33,7 @@ package org.opensearch.transport; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; diff --git a/test/framework/src/main/java/org/opensearch/action/support/ActionTestUtils.java b/test/framework/src/main/java/org/opensearch/action/support/ActionTestUtils.java index 1403bf71a7f92..b3dc8d94108ed 100644 --- a/test/framework/src/main/java/org/opensearch/action/support/ActionTestUtils.java +++ b/test/framework/src/main/java/org/opensearch/action/support/ActionTestUtils.java @@ -32,9 +32,9 @@ package org.opensearch.action.support; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.common.CheckedConsumer; import org.opensearch.tasks.Task; diff --git a/test/framework/src/main/java/org/opensearch/cluster/service/FakeThreadPoolClusterManagerService.java b/test/framework/src/main/java/org/opensearch/cluster/service/FakeThreadPoolClusterManagerService.java index 46893fe08bd76..25f893de74380 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/service/FakeThreadPoolClusterManagerService.java +++ b/test/framework/src/main/java/org/opensearch/cluster/service/FakeThreadPoolClusterManagerService.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.coordination.ClusterStatePublisher.AckListener; diff --git a/test/framework/src/main/java/org/opensearch/common/lucene/store/OpenSearchIndexInputTestCase.java b/test/framework/src/main/java/org/opensearch/common/lucene/store/OpenSearchIndexInputTestCase.java index 4fb310b2370ed..db35c6fb4392d 100644 --- a/test/framework/src/main/java/org/opensearch/common/lucene/store/OpenSearchIndexInputTestCase.java +++ b/test/framework/src/main/java/org/opensearch/common/lucene/store/OpenSearchIndexInputTestCase.java @@ -32,7 +32,7 @@ package org.opensearch.common.lucene.store; import org.apache.lucene.store.IndexInput; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.AbstractRunnable; diff --git a/test/framework/src/main/java/org/opensearch/index/reindex/AbstractAsyncBulkByScrollActionTestCase.java b/test/framework/src/main/java/org/opensearch/index/reindex/AbstractAsyncBulkByScrollActionTestCase.java index 10d6a8de139f8..2c3eadb32cafc 100644 --- a/test/framework/src/main/java/org/opensearch/index/reindex/AbstractAsyncBulkByScrollActionTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/reindex/AbstractAsyncBulkByScrollActionTestCase.java @@ -33,7 +33,7 @@ package org.opensearch.index.reindex; import org.opensearch.action.support.PlainActionFuture; -import org.opensearch.tasks.TaskId; +import org.opensearch.core.tasks.TaskId; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; diff --git a/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java b/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java index b6760b91434c6..a0d5be240d552 100644 --- a/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java @@ -34,7 +34,7 @@ import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.admin.indices.flush.FlushRequest; diff --git a/test/framework/src/main/java/org/opensearch/index/replication/TestReplicationSource.java b/test/framework/src/main/java/org/opensearch/index/replication/TestReplicationSource.java index cf4b3800069bf..b29e25a0bff2c 100644 --- a/test/framework/src/main/java/org/opensearch/index/replication/TestReplicationSource.java +++ b/test/framework/src/main/java/org/opensearch/index/replication/TestReplicationSource.java @@ -8,7 +8,7 @@ package org.opensearch.index.replication; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.index.shard.IndexShard; import org.opensearch.index.store.StoreFileMetadata; import org.opensearch.indices.replication.CheckpointInfoResponse; diff --git a/test/framework/src/main/java/org/opensearch/index/shard/IndexShardTestCase.java b/test/framework/src/main/java/org/opensearch/index/shard/IndexShardTestCase.java index 6c54c449db4b7..ebe43fc846899 100644 --- a/test/framework/src/main/java/org/opensearch/index/shard/IndexShardTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/shard/IndexShardTestCase.java @@ -41,7 +41,7 @@ import org.mockito.Mockito; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.PlainActionFuture; diff --git a/test/framework/src/main/java/org/opensearch/index/shard/RestoreOnlyRepository.java b/test/framework/src/main/java/org/opensearch/index/shard/RestoreOnlyRepository.java index 3744b06c35a72..c03fd7c915bc5 100644 --- a/test/framework/src/main/java/org/opensearch/index/shard/RestoreOnlyRepository.java +++ b/test/framework/src/main/java/org/opensearch/index/shard/RestoreOnlyRepository.java @@ -33,7 +33,7 @@ import org.apache.lucene.index.IndexCommit; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateUpdateTask; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/test/framework/src/main/java/org/opensearch/indices/recovery/AsyncRecoveryTarget.java b/test/framework/src/main/java/org/opensearch/indices/recovery/AsyncRecoveryTarget.java index b3398fb752be5..a89c83b7c1dc3 100644 --- a/test/framework/src/main/java/org/opensearch/indices/recovery/AsyncRecoveryTarget.java +++ b/test/framework/src/main/java/org/opensearch/indices/recovery/AsyncRecoveryTarget.java @@ -33,7 +33,7 @@ package org.opensearch.indices.recovery; import org.apache.lucene.util.BytesRef; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.index.seqno.ReplicationTracker; diff --git a/test/framework/src/main/java/org/opensearch/search/backpressure/SearchBackpressureTestHelpers.java b/test/framework/src/main/java/org/opensearch/search/backpressure/SearchBackpressureTestHelpers.java index ba3653d0b4a84..889264925b311 100644 --- a/test/framework/src/main/java/org/opensearch/search/backpressure/SearchBackpressureTestHelpers.java +++ b/test/framework/src/main/java/org/opensearch/search/backpressure/SearchBackpressureTestHelpers.java @@ -9,7 +9,7 @@ package org.opensearch.search.backpressure; import org.opensearch.tasks.CancellableTask; -import org.opensearch.tasks.TaskResourceUsage; +import org.opensearch.core.tasks.resourcetracker.TaskResourceUsage; import org.opensearch.test.OpenSearchTestCase; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/test/framework/src/main/java/org/opensearch/snapshots/AbstractSnapshotIntegTestCase.java b/test/framework/src/main/java/org/opensearch/snapshots/AbstractSnapshotIntegTestCase.java index a3c305775658a..2ac1e707109a2 100644 --- a/test/framework/src/main/java/org/opensearch/snapshots/AbstractSnapshotIntegTestCase.java +++ b/test/framework/src/main/java/org/opensearch/snapshots/AbstractSnapshotIntegTestCase.java @@ -32,7 +32,7 @@ package org.opensearch.snapshots; import org.opensearch.Version; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; import org.opensearch.action.index.IndexRequestBuilder; @@ -49,20 +49,20 @@ import org.opensearch.cluster.metadata.RepositoryMetadata; import org.opensearch.cluster.routing.allocation.decider.EnableAllocationDecider; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.core.common.Strings; import org.opensearch.common.UUIDs; import org.opensearch.common.blobstore.BlobContainer; import org.opensearch.common.blobstore.BlobPath; import org.opensearch.common.compress.CompressorType; import org.opensearch.common.settings.Settings; -import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.common.unit.TimeValue; +import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.common.Strings; +import org.opensearch.core.common.unit.ByteSizeUnit; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.IndexModule; import org.opensearch.index.store.RemoteBufferedOutputDirectory; import org.opensearch.indices.replication.common.ReplicationType; diff --git a/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java b/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java index 27f4f8a941311..4e7b2ce3a8926 100644 --- a/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java @@ -38,7 +38,7 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.util.Accountable; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.GetResponse; diff --git a/test/framework/src/main/java/org/opensearch/test/AbstractQueryTestCase.java b/test/framework/src/main/java/org/opensearch/test/AbstractQueryTestCase.java index 3de1287ae2f10..d6f26cbe67ffd 100644 --- a/test/framework/src/main/java/org/opensearch/test/AbstractQueryTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/AbstractQueryTestCase.java @@ -46,22 +46,22 @@ import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.collect.Tuple; import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.common.unit.Fuzziness; +import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.core.common.io.stream.NamedWriteableAwareStreamInput; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.Writeable.Reader; -import org.opensearch.common.unit.Fuzziness; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.xcontent.XContentGenerator; import org.opensearch.core.xcontent.XContentParseException; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; -import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.query.AbstractQueryBuilder; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryRewriteContext; diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java index 58c71b1c792df..cc7901d93bc4b 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java @@ -44,7 +44,7 @@ import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.ExceptionsHelper; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; diff --git a/test/framework/src/main/java/org/opensearch/test/client/NoOpClient.java b/test/framework/src/main/java/org/opensearch/test/client/NoOpClient.java index cc274f4dd0be3..04cb1e7d7a41c 100644 --- a/test/framework/src/main/java/org/opensearch/test/client/NoOpClient.java +++ b/test/framework/src/main/java/org/opensearch/test/client/NoOpClient.java @@ -33,9 +33,9 @@ package org.opensearch.test.client; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.client.support.AbstractClient; import org.opensearch.common.settings.Settings; diff --git a/test/framework/src/main/java/org/opensearch/test/client/NoOpNodeClient.java b/test/framework/src/main/java/org/opensearch/test/client/NoOpNodeClient.java index 37843ce7ff366..77081bc360718 100644 --- a/test/framework/src/main/java/org/opensearch/test/client/NoOpNodeClient.java +++ b/test/framework/src/main/java/org/opensearch/test/client/NoOpNodeClient.java @@ -33,10 +33,10 @@ package org.opensearch.test.client; import org.opensearch.OpenSearchException; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionModule.DynamicActionRegistry; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.client.Client; import org.opensearch.client.node.NodeClient; diff --git a/test/framework/src/main/java/org/opensearch/test/disruption/DisruptableMockTransport.java b/test/framework/src/main/java/org/opensearch/test/disruption/DisruptableMockTransport.java index 1cd60690ca9d5..dc4e5db80b857 100644 --- a/test/framework/src/main/java/org/opensearch/test/disruption/DisruptableMockTransport.java +++ b/test/framework/src/main/java/org/opensearch/test/disruption/DisruptableMockTransport.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.coordination.DeterministicTaskQueue; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.Nullable; diff --git a/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java b/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java index 808d9766dc49b..ba3191af7df9e 100644 --- a/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java +++ b/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java @@ -36,7 +36,7 @@ import org.apache.lucene.search.TotalHits; import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; -import org.opensearch.action.ActionFuture; +import org.opensearch.common.action.ActionFuture; import org.opensearch.action.ActionRequestBuilder; import org.opensearch.action.admin.cluster.health.ClusterHealthRequestBuilder; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; diff --git a/test/framework/src/main/java/org/opensearch/test/rest/FakeRestRequest.java b/test/framework/src/main/java/org/opensearch/test/rest/FakeRestRequest.java index 2bbaf8c80dfa4..467671fc68888 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/FakeRestRequest.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/FakeRestRequest.java @@ -32,7 +32,7 @@ package org.opensearch.test.rest; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.bytes.BytesArray; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.MediaType; 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 7a6400518fa5f..ea3d6e68c1d4f 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 @@ -69,6 +69,7 @@ import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.common.util.io.IOUtils; import org.opensearch.core.common.Strings; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.DeprecationHandler; import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.MediaTypeRegistry; @@ -77,7 +78,6 @@ import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.IndexSettings; import org.opensearch.index.seqno.ReplicationTracker; -import org.opensearch.core.rest.RestStatus; import org.opensearch.snapshots.SnapshotState; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.rest.yaml.ObjectPath; diff --git a/test/framework/src/main/java/org/opensearch/test/rest/RestActionTestCase.java b/test/framework/src/main/java/org/opensearch/test/rest/RestActionTestCase.java index 31f94039ae28f..c5b989de12780 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/RestActionTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/RestActionTestCase.java @@ -32,9 +32,9 @@ package org.opensearch.test.rest; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; +import org.opensearch.core.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; diff --git a/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java b/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java index 094af1efa208a..c3289e7651056 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java @@ -46,12 +46,12 @@ import org.opensearch.client.RestClientBuilder; import org.opensearch.client.WarningsHandler; import org.opensearch.client.sniff.OpenSearchNodesSniffer; -import org.opensearch.core.common.Strings; import org.opensearch.common.collect.Tuple; import org.opensearch.common.io.PathUtils; +import org.opensearch.common.util.io.IOUtils; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; -import org.opensearch.common.util.io.IOUtils; import org.opensearch.test.rest.OpenSearchRestTestCase; import org.opensearch.test.rest.yaml.restspec.ClientYamlSuiteRestApi; import org.opensearch.test.rest.yaml.restspec.ClientYamlSuiteRestSpec; diff --git a/test/framework/src/main/java/org/opensearch/test/transport/FakeTransport.java b/test/framework/src/main/java/org/opensearch/test/transport/FakeTransport.java index 9354d244e4c06..213b7dafd4066 100644 --- a/test/framework/src/main/java/org/opensearch/test/transport/FakeTransport.java +++ b/test/framework/src/main/java/org/opensearch/test/transport/FakeTransport.java @@ -32,7 +32,7 @@ package org.opensearch.test.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.lifecycle.AbstractLifecycleComponent; import org.opensearch.core.common.transport.BoundTransportAddress; diff --git a/test/framework/src/main/java/org/opensearch/test/transport/MockTransportService.java b/test/framework/src/main/java/org/opensearch/test/transport/MockTransportService.java index 5cf451980ec98..30171762880b2 100644 --- a/test/framework/src/main/java/org/opensearch/test/transport/MockTransportService.java +++ b/test/framework/src/main/java/org/opensearch/test/transport/MockTransportService.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.ClusterModule; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.Nullable; diff --git a/test/framework/src/main/java/org/opensearch/test/transport/StubbableConnectionManager.java b/test/framework/src/main/java/org/opensearch/test/transport/StubbableConnectionManager.java index 47de32acde351..86a0003f7045d 100644 --- a/test/framework/src/main/java/org/opensearch/test/transport/StubbableConnectionManager.java +++ b/test/framework/src/main/java/org/opensearch/test/transport/StubbableConnectionManager.java @@ -31,7 +31,7 @@ package org.opensearch.test.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.transport.TransportAddress; import org.opensearch.transport.ConnectTransportException; diff --git a/test/framework/src/main/java/org/opensearch/test/transport/StubbableTransport.java b/test/framework/src/main/java/org/opensearch/test/transport/StubbableTransport.java index 0aeb5f77af8c8..f52e438d4f247 100644 --- a/test/framework/src/main/java/org/opensearch/test/transport/StubbableTransport.java +++ b/test/framework/src/main/java/org/opensearch/test/transport/StubbableTransport.java @@ -33,7 +33,7 @@ package org.opensearch.test.transport; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.lifecycle.Lifecycle; import org.opensearch.common.lifecycle.LifecycleListener; diff --git a/test/framework/src/main/java/org/opensearch/transport/AbstractSimpleTransportTestCase.java b/test/framework/src/main/java/org/opensearch/transport/AbstractSimpleTransportTestCase.java index 6beda60ad4145..d323f130d71f8 100644 --- a/test/framework/src/main/java/org/opensearch/transport/AbstractSimpleTransportTestCase.java +++ b/test/framework/src/main/java/org/opensearch/transport/AbstractSimpleTransportTestCase.java @@ -43,7 +43,7 @@ import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.node.DiscoveryNode; diff --git a/test/framework/src/main/java/org/opensearch/transport/FakeTcpChannel.java b/test/framework/src/main/java/org/opensearch/transport/FakeTcpChannel.java index f7571c3e92081..46b3bc92ff19a 100644 --- a/test/framework/src/main/java/org/opensearch/transport/FakeTcpChannel.java +++ b/test/framework/src/main/java/org/opensearch/transport/FakeTcpChannel.java @@ -31,7 +31,7 @@ package org.opensearch.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.concurrent.CompletableContext; diff --git a/test/framework/src/main/java/org/opensearch/transport/TestTransportChannel.java b/test/framework/src/main/java/org/opensearch/transport/TestTransportChannel.java index 64bb01afe3430..e0852cf882345 100644 --- a/test/framework/src/main/java/org/opensearch/transport/TestTransportChannel.java +++ b/test/framework/src/main/java/org/opensearch/transport/TestTransportChannel.java @@ -32,7 +32,7 @@ package org.opensearch.transport; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.core.transport.TransportResponse; public class TestTransportChannel implements TransportChannel { diff --git a/test/framework/src/main/java/org/opensearch/transport/nio/MockNioTransport.java b/test/framework/src/main/java/org/opensearch/transport/nio/MockNioTransport.java index 73b2e5dd82f62..6f5a23cdca607 100644 --- a/test/framework/src/main/java/org/opensearch/transport/nio/MockNioTransport.java +++ b/test/framework/src/main/java/org/opensearch/transport/nio/MockNioTransport.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.opensearch.OpenSearchException; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.breaker.CircuitBreaker; diff --git a/test/framework/src/test/java/org/opensearch/cluster/service/FakeThreadPoolClusterManagerServiceTests.java b/test/framework/src/test/java/org/opensearch/cluster/service/FakeThreadPoolClusterManagerServiceTests.java index f09e62fa574e6..6fbdfc15d2b16 100644 --- a/test/framework/src/test/java/org/opensearch/cluster/service/FakeThreadPoolClusterManagerServiceTests.java +++ b/test/framework/src/test/java/org/opensearch/cluster/service/FakeThreadPoolClusterManagerServiceTests.java @@ -32,7 +32,7 @@ package org.opensearch.cluster.service; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.action.support.replication.ClusterStateCreationUtils; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateUpdateTask; diff --git a/test/framework/src/test/java/org/opensearch/transport/nio/SimpleMockNioTransportTests.java b/test/framework/src/test/java/org/opensearch/transport/nio/SimpleMockNioTransportTests.java index 158a770987207..12d60959b819c 100644 --- a/test/framework/src/test/java/org/opensearch/transport/nio/SimpleMockNioTransportTests.java +++ b/test/framework/src/test/java/org/opensearch/transport/nio/SimpleMockNioTransportTests.java @@ -33,7 +33,7 @@ package org.opensearch.transport.nio; import org.opensearch.Version; -import org.opensearch.action.ActionListener; +import org.opensearch.core.action.ActionListener; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.network.NetworkService; From 28864ff8082b519283d7e6187a79f9e42ebe4b6d Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Thu, 10 Aug 2023 15:15:03 -0400 Subject: [PATCH 14/26] Automatically update GitHub Actions dependencies with dependabot (#9221) Signed-off-by: Andriy Redko --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f49d899170d49..f6206d98cd10d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,6 +7,14 @@ updates: labels: - "dependabot" - "dependencies" + - directory: / + open-pull-requests-limit: 1 + package-ecosystem: "github-actions" + schedule: + interval: "weekly" + labels: + - "dependabot" + - "dependencies" - directory: /benchmarks/ open-pull-requests-limit: 1 package-ecosystem: gradle From 116286588f14c84fb2e2f43168ba095b6708b714 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Aug 2023 16:56:48 -0400 Subject: [PATCH 15/26] Bump com.azure:azure-storage-blob from 12.22.3 to 12.23.0 in /plugins/repository-azure (#9231) * Bump com.azure:azure-storage-blob in /plugins/repository-azure Bumps [com.azure:azure-storage-blob](https://github.com/Azure/azure-sdk-for-java) from 12.22.3 to 12.23.0. - [Release notes](https://github.com/Azure/azure-sdk-for-java/releases) - [Commits](https://github.com/Azure/azure-sdk-for-java/compare/azure-storage-blob_12.22.3...azure-storage-blob_12.23.0) --- updated-dependencies: - dependency-name: com.azure:azure-storage-blob dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Updating SHAs Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 3 ++- plugins/repository-azure/build.gradle | 2 +- .../licenses/azure-storage-blob-12.22.3.jar.sha1 | 1 - .../licenses/azure-storage-blob-12.23.0.jar.sha1 | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 plugins/repository-azure/licenses/azure-storage-blob-12.22.3.jar.sha1 create mode 100644 plugins/repository-azure/licenses/azure-storage-blob-12.23.0.jar.sha1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3799b8a2db9bf..6ccca0c7f4989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,6 +106,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Bump `netty` from 4.1.94.Final to 4.1.96.Final ([#9030](https://github.com/opensearch-project/OpenSearch/pull/9030)) - Bump `io.projectreactor.netty:reactor-netty-http` from 1.1.8 to 1.1.9 ([#9147](https://github.com/opensearch-project/OpenSearch/pull/9147)) - Bump `org.apache.maven:maven-model` from 3.9.3 to 3.9.4 ([#9148](https://github.com/opensearch-project/OpenSearch/pull/9148)) +- Bump `com.azure:azure-storage-blob` from 12.22.3 to 12.23.0 ([#9231](https://github.com/opensearch-project/OpenSearch/pull/9231)) ### Changed - Perform aggregation postCollection in ContextIndexSearcher after searching leaves ([#8303](https://github.com/opensearch-project/OpenSearch/pull/8303)) @@ -130,4 +131,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Security [Unreleased 3.0]: https://github.com/opensearch-project/OpenSearch/compare/2.x...HEAD -[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.10...2.x +[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.10...2.x \ No newline at end of file diff --git a/plugins/repository-azure/build.gradle b/plugins/repository-azure/build.gradle index 1ffb6ae4b9c95..7fd0a57189d7f 100644 --- a/plugins/repository-azure/build.gradle +++ b/plugins/repository-azure/build.gradle @@ -55,7 +55,7 @@ dependencies { api "io.netty:netty-resolver-dns:${versions.netty}" api "io.netty:netty-transport-native-unix-common:${versions.netty}" implementation project(':modules:transport-netty4') - api 'com.azure:azure-storage-blob:12.22.3' + api 'com.azure:azure-storage-blob:12.23.0' api 'org.reactivestreams:reactive-streams:1.0.4' api 'io.projectreactor:reactor-core:3.5.6' api 'io.projectreactor.netty:reactor-netty:1.1.8' diff --git a/plugins/repository-azure/licenses/azure-storage-blob-12.22.3.jar.sha1 b/plugins/repository-azure/licenses/azure-storage-blob-12.22.3.jar.sha1 deleted file mode 100644 index f6c3cc6e579fa..0000000000000 --- a/plugins/repository-azure/licenses/azure-storage-blob-12.22.3.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -0df12462c2eac3beaf25d283f707a0560853228b \ No newline at end of file diff --git a/plugins/repository-azure/licenses/azure-storage-blob-12.23.0.jar.sha1 b/plugins/repository-azure/licenses/azure-storage-blob-12.23.0.jar.sha1 new file mode 100644 index 0000000000000..5f32d64b00918 --- /dev/null +++ b/plugins/repository-azure/licenses/azure-storage-blob-12.23.0.jar.sha1 @@ -0,0 +1 @@ +3eeb49d5109e812343fb436e4bbb2eecac8fe386 \ No newline at end of file From c30154458a44e91a2f245b2357e69ecc839265a9 Mon Sep 17 00:00:00 2001 From: Marc Handalian Date: Thu, 10 Aug 2023 16:11:29 -0700 Subject: [PATCH 16/26] [Segment Replication] Refactor file cleanup logic and fix PIT/Scroll with remote store. (#9111) * Remove divergent commit logic with segment replication. This change removes divergent commit paths for segrep node-node and remote store. All replicas with segrep enabled will perform local commits and ignore any incoming segments_n file. This changes the recovery sync with remote store to also exclude the segments_n so that only the fetched infos bytes are committed before an engine is opened. This change also updates deletion logic with segment replication to automatically delete when a file is decref'd to 0. Signed-off-by: Marc Handalian * Add more NRTReplicationEngineTests. Signed-off-by: Marc Handalian * Ensure old commit files are wiped on remote store sync before we commit a new segmentInfos. Signed-off-by: Marc Handalian * Add more shard level tests. Signed-off-by: Marc Handalian * Add test ensuring commits are cleaned up on replicas. Signed-off-by: Marc Handalian * Self review. Signed-off-by: Marc Handalian * Use refresh level sync before recovery Signed-off-by: Marc Handalian * PR feedback. Signed-off-by: Marc Handalian --------- Signed-off-by: Marc Handalian --- .../replication/SegmentReplicationIT.java | 29 ++- .../opensearch/remotestore/RemoteStoreIT.java | 8 +- .../index/engine/NRTReplicationEngine.java | 74 +++--- .../index/engine/ReplicaFileTracker.java | 92 ++++++++ .../opensearch/index/shard/IndexShard.java | 35 +-- .../store/RemoteSegmentStoreDirectory.java | 2 +- .../index/store/ReplicaFileTracker.java | 51 ---- .../org/opensearch/index/store/Store.java | 101 +------- .../recovery/PeerRecoveryTargetService.java | 2 +- .../RemoteStoreReplicationSource.java | 9 +- .../replication/SegmentReplicationTarget.java | 27 +-- .../engine/NRTReplicationEngineTests.java | 217 ++++++++++++++---- .../index/shard/RemoteIndexShardTests.java | 150 ++++++++++++ .../SegmentReplicationIndexShardTests.java | 28 +++ ...licationWithNodeToNodeIndexShardTests.java | 48 ++-- .../opensearch/index/store/StoreTests.java | 46 ---- ...enSearchIndexLevelReplicationTestCase.java | 4 +- .../index/shard/IndexShardTestCase.java | 16 +- 18 files changed, 593 insertions(+), 346 deletions(-) create mode 100644 server/src/main/java/org/opensearch/index/engine/ReplicaFileTracker.java delete mode 100644 server/src/main/java/org/opensearch/index/store/ReplicaFileTracker.java diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java index 66469241b83d8..b14c59869ccbc 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java @@ -282,7 +282,6 @@ public void testIndexReopenClose() throws Exception { } public void testScrollWithConcurrentIndexAndSearch() throws Exception { - assumeFalse("Skipping the test with Remote store as its flaky.", segmentReplicationWithRemoteEnabled()); final String primary = internalCluster().startDataOnlyNode(); final String replica = internalCluster().startDataOnlyNode(); createIndex(INDEX_NAME); @@ -657,7 +656,6 @@ public void testDeleteOperations() throws Exception { * from xlog. */ public void testReplicationPostDeleteAndForceMerge() throws Exception { - assumeFalse("Skipping the test with Remote store as its flaky.", segmentReplicationWithRemoteEnabled()); final String primary = internalCluster().startDataOnlyNode(); createIndex(INDEX_NAME); final String replica = internalCluster().startDataOnlyNode(); @@ -966,7 +964,6 @@ private void assertAllocationIdsInReplicaShardStats(Set expected, Set rs.getRecoverySource().getType() == RecoverySource.Type.PEER) .findFirst(); assertFalse(recoverySource.isEmpty()); - if (numberOfIterations == 1 && invokeFlush) { - // segments_N file is copied to new replica - assertEquals(1, recoverySource.get().getIndex().recoveredFileCount()); - } else { - assertEquals(0, recoverySource.get().getIndex().recoveredFileCount()); - } + // segments_N file is copied to new replica + assertEquals(1, recoverySource.get().getIndex().recoveredFileCount()); IndexResponse response = indexSingleDoc(INDEX_NAME); assertEquals(indexStats.get(MAX_SEQ_NO_TOTAL) + 1, response.getSeqNo()); diff --git a/server/src/main/java/org/opensearch/index/engine/NRTReplicationEngine.java b/server/src/main/java/org/opensearch/index/engine/NRTReplicationEngine.java index 6b09b8d86dc6c..d545d9c1f6f45 100644 --- a/server/src/main/java/org/opensearch/index/engine/NRTReplicationEngine.java +++ b/server/src/main/java/org/opensearch/index/engine/NRTReplicationEngine.java @@ -57,9 +57,9 @@ public class NRTReplicationEngine extends Engine { private final CompletionStatsCache completionStatsCache; private final LocalCheckpointTracker localCheckpointTracker; private final WriteOnlyTranslogManager translogManager; - private final boolean shouldCommit; + protected final ReplicaFileTracker replicaFileTracker; - private volatile long lastReceivedGen = SequenceNumbers.NO_OPS_PERFORMED; + private volatile long lastReceivedPrimaryGen = SequenceNumbers.NO_OPS_PERFORMED; private static final int SI_COUNTER_INCREMENT = 10; @@ -69,7 +69,12 @@ public NRTReplicationEngine(EngineConfig engineConfig) { NRTReplicationReaderManager readerManager = null; WriteOnlyTranslogManager translogManagerRef = null; try { - lastCommittedSegmentInfos = store.readLastCommittedSegmentsInfo(); + this.replicaFileTracker = new ReplicaFileTracker(store::deleteQuiet); + this.lastCommittedSegmentInfos = store.readLastCommittedSegmentsInfo(); + // always protect latest commit on disk. + replicaFileTracker.incRef(this.lastCommittedSegmentInfos.files(true)); + // cleanup anything not referenced by the latest infos. + cleanUnreferencedFiles(); readerManager = buildReaderManager(); final SequenceNumbers.CommitInfo commitInfo = SequenceNumbers.loadSeqNoInfoFromLuceneCommit( this.lastCommittedSegmentInfos.getUserData().entrySet() @@ -85,7 +90,7 @@ public NRTReplicationEngine(EngineConfig engineConfig) { for (ReferenceManager.RefreshListener listener : engineConfig.getInternalRefreshListener()) { this.readerManager.addListener(listener); } - final Map userData = store.readLastCommittedSegmentsInfo().getUserData(); + final Map userData = this.lastCommittedSegmentInfos.getUserData(); final String translogUUID = Objects.requireNonNull(userData.get(Translog.TRANSLOG_UUID_KEY)); translogManagerRef = new WriteOnlyTranslogManager( engineConfig.getTranslogConfig(), @@ -116,18 +121,21 @@ public void onAfterTranslogSync() { engineConfig.getPrimaryModeSupplier() ); this.translogManager = translogManagerRef; - this.shouldCommit = engineConfig.getIndexSettings().isRemoteStoreEnabled() == false; } catch (IOException e) { IOUtils.closeWhileHandlingException(store::decRef, readerManager, translogManagerRef); throw new EngineCreationFailureException(shardId, "failed to create engine", e); } } + public void cleanUnreferencedFiles() throws IOException { + replicaFileTracker.deleteUnreferencedFiles(store.directory().listAll()); + } + private NRTReplicationReaderManager buildReaderManager() throws IOException { return new NRTReplicationReaderManager( OpenSearchDirectoryReader.wrap(getDirectoryReader(), shardId), - store::incRefFileDeleter, - store::decRefFileDeleter + replicaFileTracker::incRef, + replicaFileTracker::decRef ); } @@ -143,15 +151,16 @@ public synchronized void updateSegments(final SegmentInfos infos) throws IOExcep final long maxSeqNo = Long.parseLong(infos.userData.get(MAX_SEQ_NO)); final long incomingGeneration = infos.getGeneration(); readerManager.updateSegments(infos); - - // Commit and roll the translog when we receive a different generation than what was last received. - // lower/higher gens are possible from a new primary that was just elected. - if (incomingGeneration != lastReceivedGen) { + // Ensure that we commit and clear the local translog if a new commit has been made on the primary. + // We do not compare against the last local commit gen here because it is possible to receive + // a lower gen from a newly elected primary shard that is behind this shard's last commit gen. + // In that case we still commit into the next local generation. + if (incomingGeneration != this.lastReceivedPrimaryGen) { commitSegmentInfos(); translogManager.getDeletionPolicy().setLocalCheckpointOfSafeCommit(maxSeqNo); translogManager.rollTranslogGeneration(); } - lastReceivedGen = incomingGeneration; + this.lastReceivedPrimaryGen = incomingGeneration; localCheckpointTracker.fastForwardProcessedSeqNo(maxSeqNo); } } @@ -159,18 +168,19 @@ public synchronized void updateSegments(final SegmentInfos infos) throws IOExcep /** * Persist the latest live SegmentInfos. * - * This method creates a commit point from the latest SegmentInfos. It is intended to be used when this shard is about to be promoted as the new primary. - * - * TODO: If this method is invoked while the engine is currently updating segments on its reader, wait for that update to complete so the updated segments are used. - * + * This method creates a commit point from the latest SegmentInfos. * * @throws IOException - When there is an IO error committing the SegmentInfos. */ private void commitSegmentInfos(SegmentInfos infos) throws IOException { - if (shouldCommit) { - store.commitSegmentInfos(infos, localCheckpointTracker.getMaxSeqNo(), localCheckpointTracker.getProcessedCheckpoint()); - } + // get a reference to the previous commit files so they can be decref'd once a new commit is made. + final Collection previousCommitFiles = getLastCommittedSegmentInfos().files(true); + store.commitSegmentInfos(infos, localCheckpointTracker.getMaxSeqNo(), localCheckpointTracker.getProcessedCheckpoint()); this.lastCommittedSegmentInfos = store.readLastCommittedSegmentsInfo(); + // incref the latest on-disk commit. + replicaFileTracker.incRef(this.lastCommittedSegmentInfos.files(true)); + // decref the prev commit. + replicaFileTracker.decRef(previousCommitFiles); translogManager.syncTranslog(); } @@ -379,21 +389,19 @@ protected final void closeNoLock(String reason, CountDownLatch closedLatch) { assert rwl.isWriteLockedByCurrentThread() || failEngineLock.isHeldByCurrentThread() : "Either the write lock must be held or the engine must be currently be failing itself"; try { - // if remote store is enabled, all segments durably persisted - if (shouldCommit) { - final SegmentInfos latestSegmentInfos = getLatestSegmentInfos(); - /* - This is a workaround solution which decreases the chances of conflict on replica nodes when same file is copied - from two different primaries during failover. Increasing counter helps in avoiding this conflict as counter is - used to generate new segment file names. The ideal solution is to identify the counter from previous primary. - */ + final SegmentInfos latestSegmentInfos = getLatestSegmentInfos(); + /* + This is a workaround solution which decreases the chances of conflict on replica nodes when same file is copied + from two different primaries during failover. Increasing counter helps in avoiding this conflict as counter is + used to generate new segment file names. The ideal solution is to identify the counter from previous primary. + This is not required for remote store implementations given on failover the replica re-syncs with the store + during promotion. + */ + if (engineConfig.getIndexSettings().isRemoteStoreEnabled() == false) { latestSegmentInfos.counter = latestSegmentInfos.counter + SI_COUNTER_INCREMENT; latestSegmentInfos.changed(); - commitSegmentInfos(latestSegmentInfos); - } else { - store.directory().sync(List.of(store.directory().listAll())); - store.directory().syncMetaData(); } + commitSegmentInfos(latestSegmentInfos); IOUtils.close(readerManager, translogManager, store::decRef); } catch (Exception e) { logger.warn("failed to close engine", e); @@ -453,8 +461,8 @@ public synchronized GatedCloseable getSegmentInfosSnapshot() { // incref all files try { final Collection files = latestSegmentInfos.files(false); - store.incRefFileDeleter(files); - return new GatedCloseable<>(latestSegmentInfos, () -> store.decRefFileDeleter(files)); + replicaFileTracker.incRef(files); + return new GatedCloseable<>(latestSegmentInfos, () -> { replicaFileTracker.decRef(files); }); } catch (IOException e) { throw new EngineException(shardId, e.getMessage(), e); } diff --git a/server/src/main/java/org/opensearch/index/engine/ReplicaFileTracker.java b/server/src/main/java/org/opensearch/index/engine/ReplicaFileTracker.java new file mode 100644 index 0000000000000..2e8bd6409c2f6 --- /dev/null +++ b/server/src/main/java/org/opensearch/index/engine/ReplicaFileTracker.java @@ -0,0 +1,92 @@ +/* + * 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. + */ + +package org.opensearch.index.engine; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.function.BiConsumer; + +/** + * This class is heavily influenced by Lucene's ReplicaFileDeleter class used to keep track of + * segment files that should be preserved on replicas between replication events. + * + * https://github.com/apache/lucene/blob/main/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/ReplicaFileDeleter.java + * + * @opensearch.internal + */ +final class ReplicaFileTracker { + + public static final Logger logger = LogManager.getLogger(ReplicaFileTracker.class); + private final Map refCounts = new HashMap<>(); + private final BiConsumer fileDeleter; + private final Set EXCLUDE_FILES = Set.of("write.lock"); + + public ReplicaFileTracker(BiConsumer fileDeleter) { + this.fileDeleter = fileDeleter; + } + + public synchronized void incRef(Collection fileNames) { + for (String fileName : fileNames) { + refCounts.merge(fileName, 1, Integer::sum); + } + } + + public synchronized int refCount(String file) { + return Optional.ofNullable(refCounts.get(file)).orElse(0); + } + + public synchronized void decRef(Collection fileNames) { + Set toDelete = new HashSet<>(); + for (String fileName : fileNames) { + Integer curCount = refCounts.get(fileName); + assert curCount != null : "fileName=" + fileName; + assert curCount > 0; + if (curCount == 1) { + refCounts.remove(fileName); + toDelete.add(fileName); + } else { + refCounts.put(fileName, curCount - 1); + } + } + if (toDelete.isEmpty() == false) { + delete(toDelete); + } + } + + public void deleteUnreferencedFiles(String... toDelete) { + for (String file : toDelete) { + if (canDelete(file)) { + delete(file); + } + } + } + + private synchronized void delete(Collection toDelete) { + for (String fileName : toDelete) { + delete(fileName); + } + } + + private synchronized void delete(String fileName) { + assert canDelete(fileName); + fileDeleter.accept("delete unreferenced", fileName); + } + + private synchronized boolean canDelete(String fileName) { + return EXCLUDE_FILES.contains(fileName) == false && refCounts.containsKey(fileName) == false; + } + +} diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index 7b5f96892c005..16559eeabfd9b 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -56,7 +56,6 @@ import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; import org.apache.lucene.util.ThreadInterruptedException; -import org.opensearch.common.lucene.store.ByteArrayIndexInput; import org.opensearch.cluster.metadata.DataStream; import org.opensearch.core.Assertions; import org.opensearch.ExceptionsHelper; @@ -4657,7 +4656,13 @@ public void syncSegmentsFromRemoteSegmentStore(boolean overrideLocal, boolean re RemoteSegmentMetadata remoteSegmentMetadata = remoteDirectory.init(); Map uploadedSegments = remoteDirectory - .getSegmentsUploadedToRemoteStore(); + .getSegmentsUploadedToRemoteStore() + .entrySet() + .stream() + // if this is a refresh level sync, ignore any segments_n uploaded to the store, we will commit the received infos bytes + // locally. + .filter(entry -> refreshLevelSegmentSync && entry.getKey().startsWith(IndexFileNames.SEGMENTS) == false) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); store.incRef(); remoteStore.incRef(); try { @@ -4678,19 +4683,21 @@ public void syncSegmentsFromRemoteSegmentStore(boolean overrideLocal, boolean re copySegmentFiles(storeDirectory, remoteDirectory, null, uploadedSegments, overrideLocal); if (refreshLevelSegmentSync && remoteSegmentMetadata != null) { - try ( - ChecksumIndexInput indexInput = new BufferedChecksumIndexInput( - new ByteArrayIndexInput("Snapshot of SegmentInfos", remoteSegmentMetadata.getSegmentInfosBytes()) - ); - ) { - SegmentInfos infosSnapshot = SegmentInfos.readCommit( - store.directory(), - indexInput, - remoteSegmentMetadata.getGeneration() - ); - long processedLocalCheckpoint = Long.parseLong(infosSnapshot.getUserData().get(LOCAL_CHECKPOINT_KEY)); - store.commitSegmentInfos(infosSnapshot, processedLocalCheckpoint, processedLocalCheckpoint); + final SegmentInfos infosSnapshot = store.buildSegmentInfos( + remoteSegmentMetadata.getSegmentInfosBytes(), + remoteSegmentMetadata.getGeneration() + ); + long processedLocalCheckpoint = Long.parseLong(infosSnapshot.getUserData().get(LOCAL_CHECKPOINT_KEY)); + // delete any other commits, we want to start the engine only from a new commit made with the downloaded infos bytes. + // Extra segments will be wiped on engine open. + for (String file : List.of(store.directory().listAll())) { + if (file.startsWith(IndexFileNames.SEGMENTS)) { + store.deleteQuiet(file); + } } + assert Arrays.stream(store.directory().listAll()).filter(f -> f.startsWith(IndexFileNames.SEGMENTS)).findAny().isEmpty() + : "There should not be any segments file in the dir"; + store.commitSegmentInfos(infosSnapshot, processedLocalCheckpoint, processedLocalCheckpoint); } } catch (IOException e) { throw new IndexShardRecoveryException(shardId, "Exception while copying segment files from remote segment store", e); diff --git a/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java b/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java index 2e5ac10fefdda..9d5adc241ea0e 100644 --- a/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java +++ b/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectory.java @@ -197,7 +197,7 @@ public RemoteSegmentMetadata readLatestMetadataFile() throws IOException { if (metadataFiles.isEmpty() == false) { String latestMetadataFile = metadataFiles.get(0); - logger.info("Reading latest Metadata file {}", latestMetadataFile); + logger.trace("Reading latest Metadata file {}", latestMetadataFile); remoteSegmentMetadata = readMetadataFile(latestMetadataFile); } else { logger.info("No metadata file found, this can happen for new index with no data uploaded to remote segment store"); diff --git a/server/src/main/java/org/opensearch/index/store/ReplicaFileTracker.java b/server/src/main/java/org/opensearch/index/store/ReplicaFileTracker.java deleted file mode 100644 index 0ec282619337c..0000000000000 --- a/server/src/main/java/org/opensearch/index/store/ReplicaFileTracker.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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. - */ - -package org.opensearch.index.store; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/** - * This class is a version of Lucene's ReplicaFileDeleter class used to keep track of - * segment files that should be preserved on replicas between replication events. - * The difference is this component does not actually perform any deletions, it only handles refcounts. - * Our deletions are made through Store.java. - * - * https://github.com/apache/lucene/blob/main/lucene/replicator/src/java/org/apache/lucene/replicator/nrt/ReplicaFileDeleter.java - * - * @opensearch.internal - */ -final class ReplicaFileTracker { - - private final Map refCounts = new HashMap<>(); - - public synchronized void incRef(Collection fileNames) { - for (String fileName : fileNames) { - refCounts.merge(fileName, 1, Integer::sum); - } - } - - public synchronized void decRef(Collection fileNames) { - for (String fileName : fileNames) { - Integer curCount = refCounts.get(fileName); - assert curCount != null : "fileName=" + fileName; - assert curCount > 0; - if (curCount == 1) { - refCounts.remove(fileName); - } else { - refCounts.put(fileName, curCount - 1); - } - } - } - - public synchronized boolean canDelete(String fileName) { - return refCounts.containsKey(fileName) == false; - } -} diff --git a/server/src/main/java/org/opensearch/index/store/Store.java b/server/src/main/java/org/opensearch/index/store/Store.java index 921deae41946a..e94b89efb6cf6 100644 --- a/server/src/main/java/org/opensearch/index/store/Store.java +++ b/server/src/main/java/org/opensearch/index/store/Store.java @@ -65,7 +65,6 @@ import org.apache.lucene.util.BytesRefBuilder; import org.apache.lucene.util.Version; import org.opensearch.ExceptionsHelper; -import org.opensearch.common.CheckedConsumer; import org.opensearch.common.UUIDs; import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; @@ -105,7 +104,6 @@ import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; @@ -124,7 +122,6 @@ import static java.util.Collections.unmodifiableMap; import static org.opensearch.index.seqno.SequenceNumbers.LOCAL_CHECKPOINT_KEY; import static org.opensearch.index.store.Store.MetadataSnapshot.loadMetadata; -import static org.opensearch.indices.replication.SegmentReplicationTarget.REPLICATION_PREFIX; /** * A Store provides plain access to files written by an opensearch index shard. Each shard @@ -185,7 +182,6 @@ public class Store extends AbstractIndexShardComponent implements Closeable, Ref // used to ref count files when a new Reader is opened for PIT/Scroll queries // prevents segment files deletion until the PIT/Scroll expires or is discarded - private final ReplicaFileTracker replicaFileTracker; private final AbstractRefCounted refCounter = new AbstractRefCounted("store") { @Override @@ -207,8 +203,6 @@ public Store(ShardId shardId, IndexSettings indexSettings, Directory directory, this.directory = new StoreDirectory(sizeCachingDir, Loggers.getLogger("index.store.deletes", shardId)); this.shardLock = shardLock; this.onClose = onClose; - this.replicaFileTracker = indexSettings.isSegRepEnabled() ? new ReplicaFileTracker() : null; - assert onClose != null; assert shardLock != null; assert shardLock.getShardId().equals(shardId); @@ -788,90 +782,17 @@ public void cleanupAndVerify(String reason, MetadataSnapshot sourceMetadata) thr } } - /** - * Segment Replication method - * This method deletes files in store that are not referenced by latest on-disk commit point - * - * @param reason the reason for this cleanup operation logged for each deleted file - * @param fileToConsiderForCleanUp Files to consider for clean up. - * - * @throws IOException Exception on locking. - */ - public void cleanupAndPreserveLatestCommitPoint(Collection fileToConsiderForCleanUp, String reason) throws IOException { - assert indexSettings.isSegRepEnabled(); - // fetch a snapshot from the latest on disk Segments_N file. This can be behind - // the passed in local in memory snapshot, so we want to ensure files it references are not removed. - metadataLock.writeLock().lock(); - try (Lock writeLock = directory.obtainLock(IndexWriter.WRITE_LOCK_NAME)) { - cleanupFiles(fileToConsiderForCleanUp, reason, this.readLastCommittedSegmentsInfo().files(true)); - } finally { - metadataLock.writeLock().unlock(); - } - } - - private void cleanupFiles(Collection filesToConsiderForCleanup, String reason, Collection lastCommittedSegmentInfos) { - assert metadataLock.isWriteLockedByCurrentThread(); - for (String existingFile : filesToConsiderForCleanup) { - if (Store.isAutogenerated(existingFile) || lastCommittedSegmentInfos != null && lastCommittedSegmentInfos.contains(existingFile) - // also ensure we are not deleting a file referenced by an active reader. - || replicaFileTracker != null && replicaFileTracker.canDelete(existingFile) == false - // Prevent temporary replication files as it should be cleaned up MultiFileWriter - || existingFile.startsWith(REPLICATION_PREFIX)) { - // don't delete snapshot file, or the checksums file (note, this is extra protection since the Store won't delete - // checksum) - continue; - } - try { - directory.deleteFile(reason, existingFile); - } catch (IOException ex) { - if (existingFile.startsWith(IndexFileNames.SEGMENTS) || existingFile.startsWith(CORRUPTED_MARKER_NAME_PREFIX)) { - // TODO do we need to also fail this if we can't delete the pending commit file? - // if one of those files can't be deleted we better fail the cleanup otherwise we might leave an old commit - // point around? - throw new IllegalStateException("Can't delete " + existingFile + " - cleanup failed", ex); - } - logger.debug(() -> new ParameterizedMessage("failed to delete file [{}]", existingFile), ex); - // ignore, we don't really care, will get deleted later on - } - } - } - /** * Segment replication method * * This method takes the segment info bytes to build SegmentInfos. It inc'refs files pointed by passed in SegmentInfos * bytes to ensure they are not deleted. * - * @param tmpToFileName Map of temporary replication file to actual file name * @param infosBytes bytes[] of SegmentInfos supposed to be sent over by primary excluding segment_N file * @param segmentsGen segment generation number - * @param finalizeConsumer consumer for action on passed in SegmentInfos - * @param renameConsumer consumer for action on temporary copied over files * @throws IOException Exception while reading store and building segment infos */ - public void buildInfosFromBytes( - Map tmpToFileName, - byte[] infosBytes, - long segmentsGen, - CheckedConsumer finalizeConsumer, - CheckedConsumer, IOException> renameConsumer - ) throws IOException { - metadataLock.writeLock().lock(); - try { - final List values = new ArrayList<>(tmpToFileName.values()); - incRefFileDeleter(values); - try { - renameConsumer.accept(tmpToFileName); - finalizeConsumer.accept(buildSegmentInfos(infosBytes, segmentsGen)); - } finally { - decRefFileDeleter(values); - } - } finally { - metadataLock.writeLock().unlock(); - } - } - - private SegmentInfos buildSegmentInfos(byte[] infosBytes, long segmentsGen) throws IOException { + public SegmentInfos buildSegmentInfos(byte[] infosBytes, long segmentsGen) throws IOException { try (final ChecksumIndexInput input = toIndexInput(infosBytes)) { return SegmentInfos.readCommit(directory, input, segmentsGen); } @@ -959,7 +880,6 @@ public void commitSegmentInfos(SegmentInfos latestSegmentInfos, long maxSeqNo, l latestSegmentInfos.commit(directory()); directory.sync(latestSegmentInfos.files(true)); directory.syncMetaData(); - cleanupAndPreserveLatestCommitPoint(List.of(this.directory.listAll()), "After commit"); } finally { metadataLock.writeLock().unlock(); } @@ -2017,23 +1937,4 @@ private static IndexWriterConfig newIndexWriterConfig() { // we also don't specify a codec here and merges should use the engines for this index .setMergePolicy(NoMergePolicy.INSTANCE); } - - public void incRefFileDeleter(Collection files) { - if (this.indexSettings.isSegRepEnabled()) { - this.replicaFileTracker.incRef(files); - } - } - - public void decRefFileDeleter(Collection files) { - if (this.indexSettings.isSegRepEnabled()) { - this.replicaFileTracker.decRef(files); - try { - this.cleanupAndPreserveLatestCommitPoint(files, "On reader close"); - } catch (IOException e) { - // Log but do not rethrow - we can try cleaning up again after next replication cycle. - // If that were to fail, the shard will as well. - logger.error("Unable to clean store after reader closed", e); - } - } - } } diff --git a/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java b/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java index d3e62282d6b5c..d216721d702cc 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java +++ b/server/src/main/java/org/opensearch/indices/recovery/PeerRecoveryTargetService.java @@ -245,7 +245,7 @@ private void doRecovery(final long recoveryId, final StartRecoveryRequest preExi indexShard.prepareForIndexRecovery(); final boolean hasRemoteSegmentStore = indexShard.indexSettings().isRemoteStoreEnabled(); if (hasRemoteSegmentStore) { - indexShard.syncSegmentsFromRemoteSegmentStore(false, false); + indexShard.syncSegmentsFromRemoteSegmentStore(false, true); } final boolean hasRemoteTranslog = recoveryTarget.state().getPrimary() == false && indexShard.isRemoteTranslogEnabled(); final boolean hasNoTranslog = indexShard.indexSettings().isRemoteSnapshot(); diff --git a/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java b/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java index 2b22af070023a..c463e6abd3df2 100644 --- a/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java +++ b/server/src/main/java/org/opensearch/indices/replication/RemoteStoreReplicationSource.java @@ -11,9 +11,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.store.Directory; +import org.apache.lucene.index.SegmentInfos; import org.apache.lucene.store.FilterDirectory; import org.apache.lucene.store.IOContext; import org.apache.lucene.util.Version; +import org.opensearch.common.concurrent.GatedCloseable; import org.opensearch.core.action.ActionListener; import org.opensearch.index.shard.IndexShard; import org.opensearch.index.shard.IndexShardState; @@ -57,10 +59,11 @@ public void getCheckpointMetadata( ) { Map metadataMap; // TODO: Need to figure out a way to pass this information for segment metadata via remote store. - final Version version = indexShard.getSegmentInfosSnapshot().get().getCommitLuceneVersion(); - try { + try (final GatedCloseable segmentInfosSnapshot = indexShard.getSegmentInfosSnapshot()) { + final Version version = segmentInfosSnapshot.get().getCommitLuceneVersion(); RemoteSegmentMetadata mdFile = remoteDirectory.init(); - // During initial recovery flow, the remote store might not have metadata as primary hasn't uploaded anything yet. + // During initial recovery flow, the remote store might not + // have metadata as primary hasn't uploaded anything yet. if (mdFile == null && indexShard.state().equals(IndexShardState.STARTED) == false) { listener.onResponse(new CheckpointInfoResponse(checkpoint, Collections.emptyMap(), null)); return; diff --git a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTarget.java b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTarget.java index 91c09e86f2602..376dae40cda90 100644 --- a/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTarget.java +++ b/server/src/main/java/org/opensearch/indices/replication/SegmentReplicationTarget.java @@ -12,6 +12,7 @@ import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.IndexFormatTooNewException; import org.apache.lucene.index.IndexFormatTooOldException; +import org.apache.lucene.index.SegmentInfos; import org.apache.lucene.store.AlreadyClosedException; import org.opensearch.OpenSearchCorruptionException; import org.opensearch.OpenSearchException; @@ -34,8 +35,6 @@ import java.io.IOException; import java.util.List; import java.util.Locale; -import java.util.Map; -import java.util.stream.Collectors; /** * Represents the target of a replication event. @@ -170,7 +169,7 @@ public void startReplication(ActionListener listener) { }, listener::onFailure); getFilesListener.whenComplete(response -> { - finalizeReplication(checkpointInfoListener.result(), getFilesListener.result()); + finalizeReplication(checkpointInfoListener.result()); listener.onResponse(null); }, listener::onFailure); } @@ -201,8 +200,7 @@ private List getFiles(CheckpointInfoResponse checkpointInfo) return diff.missing; } - private void finalizeReplication(CheckpointInfoResponse checkpointInfoResponse, GetSegmentFilesResponse getSegmentFilesResponse) - throws OpenSearchCorruptionException { + private void finalizeReplication(CheckpointInfoResponse checkpointInfoResponse) throws OpenSearchCorruptionException { cancellableThreads.checkForCancel(); state.setStage(SegmentReplicationState.Stage.FINALIZE_REPLICATION); // Handle empty SegmentInfos bytes for recovering replicas @@ -213,23 +211,12 @@ private void finalizeReplication(CheckpointInfoResponse checkpointInfoResponse, try { store = store(); store.incRef(); - Map tempFileNames; - if (this.indexShard.indexSettings().isRemoteStoreEnabled() == true) { - tempFileNames = getSegmentFilesResponse.getFiles() - .stream() - .collect(Collectors.toMap(StoreFileMetadata::name, StoreFileMetadata::name)); - } else { - tempFileNames = multiFileWriter.getTempFileNames(); - } - store.buildInfosFromBytes( - tempFileNames, + multiFileWriter.renameAllTempFiles(); + final SegmentInfos infos = store.buildSegmentInfos( checkpointInfoResponse.getInfosBytes(), - checkpointInfoResponse.getCheckpoint().getSegmentsGen(), - indexShard::finalizeReplication, - this.indexShard.indexSettings().isRemoteStoreEnabled() == true - ? (files) -> {} - : (files) -> indexShard.store().renameTempFilesSafe(files) + checkpointInfoResponse.getCheckpoint().getSegmentsGen() ); + indexShard.finalizeReplication(infos); } catch (CorruptIndexException | IndexFormatTooNewException | IndexFormatTooOldException ex) { // this is a fatal exception at this stage. // this means we transferred files from the remote that have not be checksummed and they are diff --git a/server/src/test/java/org/opensearch/index/engine/NRTReplicationEngineTests.java b/server/src/test/java/org/opensearch/index/engine/NRTReplicationEngineTests.java index 4c87df48f583f..0aa96e38ebf3e 100644 --- a/server/src/test/java/org/opensearch/index/engine/NRTReplicationEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/NRTReplicationEngineTests.java @@ -13,6 +13,7 @@ import org.apache.lucene.index.SegmentInfos; import org.apache.lucene.search.ReferenceManager; import org.apache.lucene.store.IOContext; +import org.apache.lucene.util.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.UUIDs; import org.opensearch.common.concurrent.GatedCloseable; @@ -51,14 +52,6 @@ public class NRTReplicationEngineTests extends EngineTestCase { Settings.builder().put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT).build() ); - private static final IndexSettings REMOTE_STORE_INDEX_SETTINGS = IndexSettingsModule.newIndexSettings( - "index", - Settings.builder() - .put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT) - .put(IndexMetadata.SETTING_REMOTE_STORE_ENABLED, "true") - .build() - ); - public void testCreateEngine() throws IOException { final AtomicLong globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED); try ( @@ -144,29 +137,6 @@ public void testUpdateSegments_replicaReceivesSISWithHigherGen() throws IOExcept } } - public void testUpdateSegments_replicaReceivesSISWithHigherGen_remoteStoreEnabled() throws IOException { - final AtomicLong globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED); - - try ( - final Store nrtEngineStore = createStore(REMOTE_STORE_INDEX_SETTINGS, newDirectory()); - final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore, REMOTE_STORE_INDEX_SETTINGS) - ) { - // assume we start at the same gen. - assertEquals(2, nrtEngine.getLatestSegmentInfos().getGeneration()); - assertEquals(nrtEngine.getLatestSegmentInfos().getGeneration(), nrtEngine.getLastCommittedSegmentInfos().getGeneration()); - assertEquals(engine.getLatestSegmentInfos().getGeneration(), nrtEngine.getLatestSegmentInfos().getGeneration()); - - // flush the primary engine - we don't need any segments, just force a new commit point. - engine.flush(true, true); - assertEquals(3, engine.getLatestSegmentInfos().getGeneration()); - - // When remote store is enabled, we don't commit on replicas since all segments are durably persisted in the store - nrtEngine.updateSegments(engine.getLatestSegmentInfos()); - assertEquals(2, nrtEngine.getLastCommittedSegmentInfos().getGeneration()); - assertEquals(2, nrtEngine.getLatestSegmentInfos().getGeneration()); - } - } - public void testUpdateSegments_replicaReceivesSISWithLowerGen() throws IOException { // if the replica is already at segments_N that is received, it will commit segments_N+1. final AtomicLong globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED); @@ -175,8 +145,12 @@ public void testUpdateSegments_replicaReceivesSISWithLowerGen() throws IOExcepti final Store nrtEngineStore = createStore(INDEX_SETTINGS, newDirectory()); final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore) ) { + assertEquals(5, nrtEngine.getLatestSegmentInfos().getVersion()); nrtEngine.getLatestSegmentInfos().changed(); nrtEngine.getLatestSegmentInfos().changed(); + assertEquals(7, nrtEngine.getLatestSegmentInfos().getVersion()); + assertEquals(2, nrtEngine.getLastCommittedSegmentInfos().getGeneration()); + // commit the infos to push us to segments_3. nrtEngine.commitSegmentInfos(); assertEquals(3, nrtEngine.getLastCommittedSegmentInfos().getGeneration()); @@ -185,6 +159,7 @@ public void testUpdateSegments_replicaReceivesSISWithLowerGen() throws IOExcepti // update the replica with segments_2 from the primary. final SegmentInfos primaryInfos = engine.getLatestSegmentInfos(); assertEquals(2, primaryInfos.getGeneration()); + assertEquals(5, primaryInfos.getVersion()); nrtEngine.updateSegments(primaryInfos); assertEquals(4, nrtEngine.getLastCommittedSegmentInfos().getGeneration()); assertEquals(4, nrtEngine.getLatestSegmentInfos().getGeneration()); @@ -375,16 +350,9 @@ private NRTReplicationEngine buildNrtReplicaEngine(AtomicLong globalCheckpoint, public void testGetSegmentInfosSnapshotPreservesFilesUntilRelease() throws Exception { final AtomicLong globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED); - // TODO: Remove this divergent commit logic and copy Segments_N from primary with node-node. - // randomly toggle commit / no commit. - IndexSettings settings = REMOTE_STORE_INDEX_SETTINGS; - final boolean shouldCommit = randomBoolean(); - if (shouldCommit) { - settings = INDEX_SETTINGS; - } try ( - final Store nrtEngineStore = createStore(REMOTE_STORE_INDEX_SETTINGS, newDirectory()); - final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore, settings) + final Store nrtEngineStore = createStore(INDEX_SETTINGS, newDirectory()); + final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore, INDEX_SETTINGS) ) { // only index 2 docs here, this will create segments _0 and _1 and after forcemerge into _2. final int docCount = 2; @@ -436,7 +404,174 @@ public void testGetSegmentInfosSnapshotPreservesFilesUntilRelease() throws Excep // Ensure we still have all the active files. Note - we exclude the infos file here if we aren't committing // the nrt reader will still reference segments_n-1 after being loaded until a local commit occurs. - assertTrue(replicaFiles.containsAll(nrtEngine.getLatestSegmentInfos().files(shouldCommit))); + assertTrue(replicaFiles.containsAll(nrtEngine.getLatestSegmentInfos().files(false))); + } + } + + public void testRemoveExtraSegmentsOnStartup() throws Exception { + final AtomicLong globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED); + List operations = generateHistoryOnReplica(2, randomBoolean(), randomBoolean(), randomBoolean()); + for (Engine.Operation op : operations) { + applyOperation(engine, op); + // refresh to create a lot of segments. + engine.refresh("test"); + } + try (final Store nrtEngineStore = createStore(INDEX_SETTINGS, newDirectory());) { + nrtEngineStore.createEmpty(Version.LATEST); + final Collection extraSegments = engine.getLatestSegmentInfos().files(false); + for (String file : extraSegments) { + nrtEngineStore.directory().copyFrom(store.directory(), file, file, IOContext.DEFAULT); + } + List replicaFiles = List.of(nrtEngineStore.directory().listAll()); + for (String file : extraSegments) { + assertTrue(replicaFiles.contains(file)); + } + assertTrue(storeContainsAll(nrtEngineStore, extraSegments)); + try (NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore, INDEX_SETTINGS)) { + replicaFiles = List.of(nrtEngineStore.directory().listAll()); + for (String file : extraSegments) { + assertFalse(replicaFiles.contains(file)); + } + } + } + } + + public void testPreserveLatestCommit() throws Exception { + final AtomicLong globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED); + + try ( + final Store nrtEngineStore = createStore(INDEX_SETTINGS, newDirectory()); + final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore, INDEX_SETTINGS) + ) { + final int docCount = 4; + List operations = generateHistoryOnReplica(docCount, randomBoolean(), randomBoolean(), randomBoolean()); + indexOperations(nrtEngine, operations.subList(0, 2)); + // wipe the nrt directory initially so we can sync with primary. + cleanAndCopySegmentsFromPrimary(nrtEngine); + SegmentInfos primaryInfos; + + final SegmentInfos lastCommittedSegmentInfos = nrtEngine.getLastCommittedSegmentInfos(); + final Collection lastCommittedFiles = lastCommittedSegmentInfos.files(true); + assertTrue(storeContainsAll(nrtEngineStore, lastCommittedFiles)); + + // ensure segments and commit file are incref'd: + assertEquals( + "Segments_N is incref'd once", + 1, + nrtEngine.replicaFileTracker.refCount(lastCommittedSegmentInfos.getSegmentsFileName()) + ); + // segments are incref'd twice because they are loaded on the reader. + assertRefCount(nrtEngine, lastCommittedSegmentInfos.files(false), 2); + + // get and close a snapshot - this will decref files when closed. + final GatedCloseable segmentInfosSnapshot = nrtEngine.getSegmentInfosSnapshot(); + segmentInfosSnapshot.close(); + assertTrue(storeContainsAll(nrtEngineStore, lastCommittedFiles)); + + // index more docs and refresh the reader - this will incref/decref files again + indexOperations(nrtEngine, operations.subList(2, 4)); + primaryInfos = engine.getLatestSegmentInfos(); + copySegments(primaryInfos.files(false), nrtEngine); + nrtEngine.updateSegments(primaryInfos); + + // get the additional segments that are only on the reader - not part of a commit. + final Collection readerOnlySegments = primaryInfos.files(false); + readerOnlySegments.removeAll(lastCommittedFiles); + assertRefCount(nrtEngine, readerOnlySegments, 1); + + assertTrue(storeContainsAll(nrtEngineStore, lastCommittedFiles)); + assertEquals( + "Segments_N is incref'd once", + 1, + nrtEngine.replicaFileTracker.refCount(lastCommittedSegmentInfos.getSegmentsFileName()) + ); + assertRefCount(nrtEngine, lastCommittedSegmentInfos.files(false), 2); + + // flush the primary + engine.flush(true, true); + copySegments(engine.getLatestSegmentInfos().files(false), nrtEngine); + nrtEngine.updateSegments(engine.getLatestSegmentInfos()); + // after flush our segment_n is removed. + assertEquals( + "Segments_N is removed", + 0, + nrtEngine.replicaFileTracker.refCount(lastCommittedSegmentInfos.getSegmentsFileName()) + ); + assertFalse(storeContainsAll(nrtEngineStore, lastCommittedFiles)); + // close the engine - ensure we preserved the last commit + final SegmentInfos infosBeforeClose = nrtEngine.getLatestSegmentInfos(); + nrtEngine.close(); + assertTrue(storeContainsAll(nrtEngineStore, infosBeforeClose.files(false))); + assertEquals(store.readLastCommittedSegmentsInfo().files(false), infosBeforeClose.files(false)); + } + } + + private void assertRefCount(NRTReplicationEngine nrtEngine, Collection files, int count) { + for (String file : files) { + // refCount for our segments is 2 because they are still active on the reader + assertEquals(count, nrtEngine.replicaFileTracker.refCount(file)); + } + } + + private boolean storeContainsAll(Store nrtEngineStore, Collection lastCommittedFiles) throws IOException { + return List.of(nrtEngineStore.directory().listAll()).containsAll(lastCommittedFiles); + } + + private void cleanAndCopySegmentsFromPrimary(NRTReplicationEngine nrtEngine) throws IOException { + Lucene.cleanLuceneIndex(nrtEngine.store.directory()); + assertFalse( + Arrays.stream(nrtEngine.store.directory().listAll()) + .anyMatch(file -> file.equals("write.lock") == false && file.equals("extra0") == false) + ); + SegmentInfos primaryInfos = engine.getLatestSegmentInfos(); + copySegments(primaryInfos.files(false), nrtEngine); + nrtEngine.updateSegments(primaryInfos); + } + + private void indexOperations(NRTReplicationEngine nrtEngine, List operations) throws IOException { + for (Engine.Operation op : operations) { + applyOperation(engine, op); + applyOperation(nrtEngine, op); + engine.refresh("test"); + } + } + + public void testDecrefToZeroRemovesFile() throws IOException { + final AtomicLong globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED); + + try ( + final Store nrtEngineStore = createStore(INDEX_SETTINGS, newDirectory()); + final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore, INDEX_SETTINGS) + ) { + Lucene.cleanLuceneIndex(nrtEngineStore.directory()); + copySegments(engine.getLatestSegmentInfos().files(true), nrtEngine); + nrtEngine.updateSegments(engine.getLatestSegmentInfos()); + final SegmentInfos lastCommittedSegmentInfos = nrtEngine.getLastCommittedSegmentInfos(); + assertEquals( + "Segments_N is incref'd to 1", + 1, + nrtEngine.replicaFileTracker.refCount(lastCommittedSegmentInfos.getSegmentsFileName()) + ); + // create a new commit and update infos + engine.flush(true, true); + nrtEngine.updateSegments(engine.getLatestSegmentInfos()); + assertEquals( + "Segments_N is removed", + 0, + nrtEngine.replicaFileTracker.refCount(lastCommittedSegmentInfos.getSegmentsFileName()) + ); + assertFalse(List.of(nrtEngineStore.directory().listAll()).contains(lastCommittedSegmentInfos.getSegmentsFileName())); + } + } + + private void copySegments(Collection latestPrimaryFiles, Engine nrtEngine) throws IOException { + final Store store = nrtEngine.store; + final List replicaFiles = List.of(store.directory().listAll()); + // copy new segments in and load reader. + for (String file : latestPrimaryFiles) { + if (replicaFiles.contains(file) == false) { + store.directory().copyFrom(this.store.directory(), file, file, IOContext.DEFAULT); + } } } } diff --git a/server/src/test/java/org/opensearch/index/shard/RemoteIndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/RemoteIndexShardTests.java index a01169480de0b..c22fbdd8850ff 100644 --- a/server/src/test/java/org/opensearch/index/shard/RemoteIndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/RemoteIndexShardTests.java @@ -8,19 +8,32 @@ package org.opensearch.index.shard; +import org.apache.lucene.index.IndexFileNames; +import org.apache.lucene.index.SegmentInfos; +import org.apache.lucene.util.Version; +import org.hamcrest.MatcherAssert; import org.junit.Before; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.FeatureFlags; import org.opensearch.index.engine.DocIdSeqNoAndSource; +import org.opensearch.index.engine.Engine; import org.opensearch.index.engine.InternalEngine; import org.opensearch.index.engine.NRTReplicationEngineFactory; +import org.opensearch.index.store.Store; +import org.opensearch.index.store.StoreFileMetadata; import org.opensearch.indices.replication.common.ReplicationType; import java.io.IOException; +import java.nio.file.Path; +import java.util.Arrays; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.CountDownLatch; +import java.util.stream.Collectors; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.opensearch.index.engine.EngineTestCase.assertAtMostOneLuceneDocumentPerSequenceNumber; @@ -172,4 +185,141 @@ public void testNoDuplicateSeqNo() throws Exception { } } } + + public void testReplicaCommitsInfosBytesOnRecovery() throws Exception { + final Path remotePath = createTempDir(); + try (ReplicationGroup shards = createGroup(0, getIndexSettings(), indexMapping, new NRTReplicationEngineFactory(), remotePath)) { + shards.startAll(); + // ensure primary has uploaded something + shards.indexDocs(10); + shards.refresh("test"); + + final IndexShard primary = shards.getPrimary(); + final Engine primaryEngine = getEngine(primary); + assertNotNull(primaryEngine); + final SegmentInfos latestCommit = SegmentInfos.readLatestCommit(primary.store().directory()); + assertEquals("On-disk commit references no segments", Set.of("segments_3"), latestCommit.files(true)); + assertEquals( + "Latest remote commit On-disk commit references no segments", + Set.of("segments_3"), + primary.remoteStore().readLastCommittedSegmentsInfo().files(true) + ); + MatcherAssert.assertThat( + "Segments are referenced in memory only", + primaryEngine.getSegmentInfosSnapshot().get().files(false), + containsInAnyOrder("_0.cfe", "_0.si", "_0.cfs") + ); + + final IndexShard replica = shards.addReplica(remotePath); + replica.store().createEmpty(Version.LATEST); + assertEquals( + "Replica starts at empty segment 2", + Set.of("segments_1"), + replica.store().readLastCommittedSegmentsInfo().files(true) + ); + // commit replica infos so it has a conflicting commit with remote. + final SegmentInfos segmentCommitInfos = replica.store().readLastCommittedSegmentsInfo(); + segmentCommitInfos.commit(replica.store().directory()); + segmentCommitInfos.commit(replica.store().directory()); + assertEquals( + "Replica starts recovery at empty segment 3", + Set.of("segments_3"), + replica.store().readLastCommittedSegmentsInfo().files(true) + ); + + shards.recoverReplica(replica); + + final Engine replicaEngine = getEngine(replica); + assertNotNull(replicaEngine); + final SegmentInfos latestReplicaCommit = SegmentInfos.readLatestCommit(replica.store().directory()); + logger.info(List.of(replica.store().directory().listAll())); + MatcherAssert.assertThat( + "Replica commits infos bytes referencing latest refresh point", + latestReplicaCommit.files(true), + containsInAnyOrder("_0.cfe", "_0.si", "_0.cfs", "segments_5") + ); + MatcherAssert.assertThat( + "Segments are referenced in memory", + replicaEngine.getSegmentInfosSnapshot().get().files(false), + containsInAnyOrder("_0.cfe", "_0.si", "_0.cfs") + ); + final Store.RecoveryDiff recoveryDiff = Store.segmentReplicationDiff( + primary.getSegmentMetadataMap(), + replica.getSegmentMetadataMap() + ); + assertTrue(recoveryDiff.missing.isEmpty()); + assertTrue(recoveryDiff.different.isEmpty()); + } + } + + public void testPrimaryRestart_PrimaryHasExtraCommits() throws Exception { + final Path remotePath = createTempDir(); + try (ReplicationGroup shards = createGroup(0, getIndexSettings(), indexMapping, new NRTReplicationEngineFactory(), remotePath)) { + shards.startAll(); + // ensure primary has uploaded something + shards.indexDocs(10); + IndexShard primary = shards.getPrimary(); + if (randomBoolean()) { + flushShard(primary); + } else { + primary.refresh("test"); + } + assertDocCount(primary, 10); + // get a metadata map - we'll use segrep diff to ensure segments on reader are identical after restart. + final Map metadataBeforeRestart = primary.getSegmentMetadataMap(); + // restart the primary + shards.reinitPrimaryShard(remotePath); + // the store is open at this point but the shard has not yet run through recovery + primary = shards.getPrimary(); + SegmentInfos latestPrimaryCommit = SegmentInfos.readLatestCommit(primary.store().directory()); + latestPrimaryCommit.commit(primary.store().directory()); + latestPrimaryCommit = SegmentInfos.readLatestCommit(primary.store().directory()); + latestPrimaryCommit.commit(primary.store().directory()); + shards.startPrimary(); + assertDocCount(primary, 10); + final Store.RecoveryDiff diff = Store.segmentReplicationDiff(metadataBeforeRestart, primary.getSegmentMetadataMap()); + assertTrue(diff.missing.isEmpty()); + assertTrue(diff.different.isEmpty()); + } + } + + public void testRepicaCleansUpOldCommitsWhenReceivingNew() throws Exception { + final Path remotePath = createTempDir(); + try (ReplicationGroup shards = createGroup(1, getIndexSettings(), indexMapping, new NRTReplicationEngineFactory(), remotePath)) { + shards.startAll(); + final IndexShard primary = shards.getPrimary(); + final IndexShard replica = shards.getReplicas().get(0); + shards.indexDocs(1); + flushShard(primary); + replicateSegments(primary, shards.getReplicas()); + assertDocCount(primary, 1); + assertDocCount(replica, 1); + assertEquals("segments_4", replica.store().readLastCommittedSegmentsInfo().getSegmentsFileName()); + assertSingleSegmentFile(replica, "segments_4"); + + shards.indexDocs(1); + primary.refresh("test"); + replicateSegments(primary, shards.getReplicas()); + assertDocCount(replica, 2); + assertSingleSegmentFile(replica, "segments_4"); + + shards.indexDocs(1); + flushShard(primary); + replicateSegments(primary, shards.getReplicas()); + assertDocCount(replica, 3); + assertSingleSegmentFile(replica, "segments_5"); + + final Store.RecoveryDiff diff = Store.segmentReplicationDiff(primary.getSegmentMetadataMap(), replica.getSegmentMetadataMap()); + assertTrue(diff.missing.isEmpty()); + assertTrue(diff.different.isEmpty()); + } + } + + private void assertSingleSegmentFile(IndexShard shard, String fileName) throws IOException { + final Set segmentsFileNames = Arrays.stream(shard.store().directory().listAll()) + .filter(file -> file.startsWith(IndexFileNames.SEGMENTS)) + .collect(Collectors.toSet()); + assertEquals("Expected a single segment file", 1, segmentsFileNames.size()); + assertEquals(segmentsFileNames.stream().findFirst().get(), fileName); + } } diff --git a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java index 070bcae1b4a4b..88fcae17bf091 100644 --- a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java @@ -62,6 +62,7 @@ import org.opensearch.transport.TransportService; import java.io.IOException; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -773,6 +774,33 @@ public void testNoDuplicateSeqNo() throws Exception { } } + public void testPrimaryRestart() throws Exception { + final Path remotePath = createTempDir(); + try (ReplicationGroup shards = createGroup(0, getIndexSettings(), indexMapping, new NRTReplicationEngineFactory(), remotePath)) { + shards.startAll(); + // ensure primary has uploaded something + shards.indexDocs(10); + IndexShard primary = shards.getPrimary(); + if (randomBoolean()) { + flushShard(primary); + } else { + primary.refresh("test"); + } + assertDocCount(primary, 10); + // get a metadata map - we'll use segrep diff to ensure segments on reader are identical after restart. + final Map metadataBeforeRestart = primary.getSegmentMetadataMap(); + // restart the primary + shards.reinitPrimaryShard(remotePath); + // the store is open at this point but the shard has not yet run through recovery + primary = shards.getPrimary(); + shards.startPrimary(); + assertDocCount(primary, 10); + final Store.RecoveryDiff diff = Store.segmentReplicationDiff(metadataBeforeRestart, primary.getSegmentMetadataMap()); + assertTrue(diff.missing.isEmpty()); + assertTrue(diff.different.isEmpty()); + } + } + /** * Assert persisted and searchable doc counts. This method should not be used while docs are concurrently indexed because * it asserts point in time seqNos are relative to the doc counts. diff --git a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java index 1df7c72cbc8a8..0359a9b926cd9 100644 --- a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationWithNodeToNodeIndexShardTests.java @@ -432,45 +432,57 @@ public void testTemporaryFilesNotCleanup() throws Exception { } } - // Todo: Move this test to SegmentReplicationIndexShardTests so that it runs for both node-node & remote store public void testReplicaReceivesLowerGeneration() throws Exception { // when a replica gets incoming segments that are lower than what it currently has on disk. - - // start 3 nodes Gens: P [2], R [2], R[2] - // index some docs and flush twice, push to only 1 replica. - // State Gens: P [4], R-1 [3], R-2 [2] - // Promote R-2 as the new primary and demote the old primary. - // State Gens: R[4], R-1 [3], P [4] - *commit on close of NRTEngine, xlog replayed and commit made. - // index docs on new primary and flush - // replicate to all. - // Expected result: State Gens: P[4], R-1 [4], R-2 [4] + // this can happen when a replica is promoted that is further behind the other replicas. try (ReplicationGroup shards = createGroup(2, getIndexSettings(), new NRTReplicationEngineFactory())) { shards.startAll(); final IndexShard primary = shards.getPrimary(); - final IndexShard replica_1 = shards.getReplicas().get(0); + final IndexShard behindReplicaBeforeRestart = shards.getReplicas().get(0); final IndexShard replica_2 = shards.getReplicas().get(1); int numDocs = randomIntBetween(10, 100); + int totalDocs = numDocs; shards.indexDocs(numDocs); - flushShard(primary, false); - replicateSegments(primary, List.of(replica_1)); + flushShard(primary, true); + replicateSegments(primary, List.of(behindReplicaBeforeRestart)); numDocs = randomIntBetween(numDocs + 1, numDocs + 10); + totalDocs += numDocs; shards.indexDocs(numDocs); - flushShard(primary, false); - replicateSegments(primary, List.of(replica_1)); + flushShard(primary, true); + flushShard(primary, true); + flushShard(primary, true); + replicateSegments(primary, List.of(behindReplicaBeforeRestart)); + + // close behindReplicaBeforeRestart - we will re-open it after replica_2 is promoted as new primary. + assertEqualCommittedSegments(primary, behindReplicaBeforeRestart); - assertEqualCommittedSegments(primary, replica_1); + assertDocCount(behindReplicaBeforeRestart, totalDocs); + assertDocCount(replica_2, 0); shards.promoteReplicaToPrimary(replica_2).get(); - primary.close("demoted", false, false); + primary.close("demoted", randomBoolean(), false); primary.store().close(); IndexShard oldPrimary = shards.addReplicaWithExistingPath(primary.shardPath(), primary.routingEntry().currentNodeId()); shards.recoverReplica(oldPrimary); + behindReplicaBeforeRestart.close("restart", false, false); + behindReplicaBeforeRestart.store().close(); + shards.removeReplica(behindReplicaBeforeRestart); + final IndexShard behindReplicaAfterRestart = shards.addReplicaWithExistingPath( + behindReplicaBeforeRestart.shardPath(), + behindReplicaBeforeRestart.routingEntry().currentNodeId() + ); + shards.recoverReplica(behindReplicaAfterRestart); + numDocs = randomIntBetween(numDocs + 1, numDocs + 10); + totalDocs += numDocs; shards.indexDocs(numDocs); flushShard(replica_2, false); replicateSegments(replica_2, shards.getReplicas()); - assertEqualCommittedSegments(replica_2, oldPrimary, replica_1); + assertEqualCommittedSegments(replica_2, oldPrimary, behindReplicaAfterRestart); + assertDocCount(replica_2, totalDocs); + assertDocCount(oldPrimary, totalDocs); + assertDocCount(behindReplicaAfterRestart, totalDocs); } } diff --git a/server/src/test/java/org/opensearch/index/store/StoreTests.java b/server/src/test/java/org/opensearch/index/store/StoreTests.java index 9043dcce1b779..a4812a4a771bf 100644 --- a/server/src/test/java/org/opensearch/index/store/StoreTests.java +++ b/server/src/test/java/org/opensearch/index/store/StoreTests.java @@ -100,7 +100,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -109,8 +108,6 @@ import java.util.Map; import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; -import java.util.stream.Stream; import static java.util.Collections.unmodifiableMap; import static org.hamcrest.Matchers.anyOf; @@ -1169,49 +1166,6 @@ public void testGetMetadataWithSegmentInfos() throws IOException { store.close(); } - public void testCleanupAndPreserveLatestCommitPoint() throws IOException { - final ShardId shardId = new ShardId("index", "_na_", 1); - Store store = new Store( - shardId, - SEGMENT_REPLICATION_INDEX_SETTINGS, - StoreTests.newDirectory(random()), - new DummyShardLock(shardId) - ); - commitRandomDocs(store); - - Store.MetadataSnapshot commitMetadata = store.getMetadata(); - - // index more docs but only IW.flush, this will create additional files we'll clean up. - final IndexWriter writer = indexRandomDocs(store); - writer.flush(); - writer.close(); - - final List additionalSegments = new ArrayList<>(); - for (String file : store.directory().listAll()) { - if (commitMetadata.contains(file) == false) { - additionalSegments.add(file); - } - } - assertFalse(additionalSegments.isEmpty()); - - Collection filesToConsiderForCleanUp = Stream.of(store.readLastCommittedSegmentsInfo().files(true), additionalSegments) - .flatMap(Collection::stream) - .collect(Collectors.toList()); - - // clean up everything not in the latest commit point. - store.cleanupAndPreserveLatestCommitPoint(filesToConsiderForCleanUp, "test"); - - // we want to ensure commitMetadata files are preserved after calling cleanup - for (String existingFile : store.directory().listAll()) { - if (!IndexWriter.WRITE_LOCK_NAME.equals(existingFile)) { - assertTrue(commitMetadata.contains(existingFile)); - assertFalse(additionalSegments.contains(existingFile)); - } - } - deleteContent(store.directory()); - IOUtils.close(store); - } - public void testGetSegmentMetadataMap() throws IOException { final ShardId shardId = new ShardId("index", "_na_", 1); Store store = new Store( diff --git a/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java b/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java index a0d5be240d552..53d2d4b8b40ab 100644 --- a/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java @@ -622,8 +622,8 @@ public synchronized IndexShard getPrimary() { return primary; } - public synchronized void reinitPrimaryShard() throws IOException { - primary = reinitShard(primary); + public synchronized void reinitPrimaryShard(Path remotePath) throws IOException { + primary = reinitShard(primary, remotePath); computeReplicationTargets(); } diff --git a/test/framework/src/main/java/org/opensearch/index/shard/IndexShardTestCase.java b/test/framework/src/main/java/org/opensearch/index/shard/IndexShardTestCase.java index ebe43fc846899..a880aa25a4b4e 100644 --- a/test/framework/src/main/java/org/opensearch/index/shard/IndexShardTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/shard/IndexShardTestCase.java @@ -793,12 +793,18 @@ protected BlobContainer getBlobContainer(Path f) throws IOException { return new FsBlobContainer(fsBlobStore, blobPath, f); } + protected IndexShard reinitShard(IndexShard current, IndexingOperationListener... listeners) throws IOException { + return reinitShard(current, (Path) null, listeners); + } + /** * Takes an existing shard, closes it and starts a new initialing shard at the same location * + * @param current The current shard to reinit + * @param remotePath Remote path to recover from if remote storage is used * @param listeners new listerns to use for the newly created shard */ - protected IndexShard reinitShard(IndexShard current, IndexingOperationListener... listeners) throws IOException { + protected IndexShard reinitShard(IndexShard current, Path remotePath, IndexingOperationListener... listeners) throws IOException { final ShardRouting shardRouting = current.routingEntry(); return reinitShard( current, @@ -806,6 +812,7 @@ protected IndexShard reinitShard(IndexShard current, IndexingOperationListener.. shardRouting, shardRouting.primary() ? RecoverySource.ExistingStoreRecoverySource.INSTANCE : RecoverySource.PeerRecoverySource.INSTANCE ), + remotePath, listeners ); } @@ -817,13 +824,18 @@ protected IndexShard reinitShard(IndexShard current, IndexingOperationListener.. * @param listeners new listerns to use for the newly created shard */ protected IndexShard reinitShard(IndexShard current, ShardRouting routing, IndexingOperationListener... listeners) throws IOException { + return reinitShard(current, routing, null, listeners); + } + + protected IndexShard reinitShard(IndexShard current, ShardRouting routing, Path remotePath, IndexingOperationListener... listeners) + throws IOException { return reinitShard( current, routing, current.indexSettings.getIndexMetadata(), current.engineFactory, current.engineConfigFactory, - null, + remotePath, listeners ); } From 48ec2069960f6472628a64125d90dfb9e698dae5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Aug 2023 16:47:04 -0700 Subject: [PATCH 17/26] Bump com.diffplug.spotless from 6.19.0 to 6.20.0 (#9227) * Bump com.diffplug.spotless from 6.19.0 to 6.20.0 Bumps com.diffplug.spotless from 6.19.0 to 6.20.0. --- updated-dependencies: - dependency-name: com.diffplug.spotless dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 1 + build.gradle | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ccca0c7f4989..b6bdbafb0fe59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Bump `io.projectreactor.netty:reactor-netty-http` from 1.1.8 to 1.1.9 ([#9147](https://github.com/opensearch-project/OpenSearch/pull/9147)) - Bump `org.apache.maven:maven-model` from 3.9.3 to 3.9.4 ([#9148](https://github.com/opensearch-project/OpenSearch/pull/9148)) - Bump `com.azure:azure-storage-blob` from 12.22.3 to 12.23.0 ([#9231](https://github.com/opensearch-project/OpenSearch/pull/9231)) +- Bump `com.diffplug.spotless` from 6.19.0 to 6.20.0 ([#9227](https://github.com/opensearch-project/OpenSearch/pull/9227)) ### Changed - Perform aggregation postCollection in ContextIndexSearcher after searching leaves ([#8303](https://github.com/opensearch-project/OpenSearch/pull/8303)) diff --git a/build.gradle b/build.gradle index 4d85638270eca..eef5d6d5b442c 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,7 @@ plugins { id 'lifecycle-base' id 'opensearch.docker-support' id 'opensearch.global-build-info' - id "com.diffplug.spotless" version "6.19.0" apply false + id "com.diffplug.spotless" version "6.20.0" apply false id "org.gradle.test-retry" version "1.5.4" apply false id "test-report-aggregation" id 'jacoco-report-aggregation' From d352f2c1adbc925de9b3c18c9e3ad3f7ac149925 Mon Sep 17 00:00:00 2001 From: Marc Handalian Date: Thu, 10 Aug 2023 18:57:01 -0700 Subject: [PATCH 18/26] Fix test SegmentReplicationIndexShardTests.testPrimaryRestart. (#9245) --- .../index/shard/RemoteIndexShardTests.java | 28 +++++++++++++++++++ .../SegmentReplicationIndexShardTests.java | 28 ------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/server/src/test/java/org/opensearch/index/shard/RemoteIndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/RemoteIndexShardTests.java index c22fbdd8850ff..86f58066455f6 100644 --- a/server/src/test/java/org/opensearch/index/shard/RemoteIndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/RemoteIndexShardTests.java @@ -315,6 +315,34 @@ public void testRepicaCleansUpOldCommitsWhenReceivingNew() throws Exception { } } + public void testPrimaryRestart() throws Exception { + final Path remotePath = createTempDir(); + try (ReplicationGroup shards = createGroup(0, getIndexSettings(), indexMapping, new NRTReplicationEngineFactory(), remotePath)) { + shards.startAll(); + // ensure primary has uploaded something + shards.indexDocs(10); + IndexShard primary = shards.getPrimary(); + if (randomBoolean()) { + flushShard(primary); + } else { + primary.refresh("test"); + } + assertDocCount(primary, 10); + // get a metadata map - we'll use segrep diff to ensure segments on reader are identical after restart. + final Map metadataBeforeRestart = primary.getSegmentMetadataMap(); + // restart the primary + shards.reinitPrimaryShard(remotePath); + // the store is open at this point but the shard has not yet run through recovery + primary = shards.getPrimary(); + shards.startPrimary(); + assertDocCount(primary, 10); + final Store.RecoveryDiff diff = Store.segmentReplicationDiff(metadataBeforeRestart, primary.getSegmentMetadataMap()); + assertTrue(diff.missing.isEmpty()); + logger.info("DIFF FILE {}", diff.different); + assertTrue(diff.different.isEmpty()); + } + } + private void assertSingleSegmentFile(IndexShard shard, String fileName) throws IOException { final Set segmentsFileNames = Arrays.stream(shard.store().directory().listAll()) .filter(file -> file.startsWith(IndexFileNames.SEGMENTS)) diff --git a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java index 88fcae17bf091..070bcae1b4a4b 100644 --- a/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/SegmentReplicationIndexShardTests.java @@ -62,7 +62,6 @@ import org.opensearch.transport.TransportService; import java.io.IOException; -import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -774,33 +773,6 @@ public void testNoDuplicateSeqNo() throws Exception { } } - public void testPrimaryRestart() throws Exception { - final Path remotePath = createTempDir(); - try (ReplicationGroup shards = createGroup(0, getIndexSettings(), indexMapping, new NRTReplicationEngineFactory(), remotePath)) { - shards.startAll(); - // ensure primary has uploaded something - shards.indexDocs(10); - IndexShard primary = shards.getPrimary(); - if (randomBoolean()) { - flushShard(primary); - } else { - primary.refresh("test"); - } - assertDocCount(primary, 10); - // get a metadata map - we'll use segrep diff to ensure segments on reader are identical after restart. - final Map metadataBeforeRestart = primary.getSegmentMetadataMap(); - // restart the primary - shards.reinitPrimaryShard(remotePath); - // the store is open at this point but the shard has not yet run through recovery - primary = shards.getPrimary(); - shards.startPrimary(); - assertDocCount(primary, 10); - final Store.RecoveryDiff diff = Store.segmentReplicationDiff(metadataBeforeRestart, primary.getSegmentMetadataMap()); - assertTrue(diff.missing.isEmpty()); - assertTrue(diff.different.isEmpty()); - } - } - /** * Assert persisted and searchable doc counts. This method should not be used while docs are concurrently indexed because * it asserts point in time seqNos are relative to the doc counts. From a1fc31c1cee63919417257bd17c1d0aa76a28bba Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Sat, 12 Aug 2023 00:16:43 +1200 Subject: [PATCH 19/26] Force upgrade the vulnerable dependencies of hadoop-minicluster (#9252) * Force upgrade the vulnerable dependencies of hadoop-minicluster Signed-off-by: Thomas Farr * Add changelog entry Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr --- CHANGELOG.md | 3 +++ test/fixtures/hdfs-fixture/build.gradle | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6bdbafb0fe59..2a8cf50322cc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Bump `org.apache.maven:maven-model` from 3.9.3 to 3.9.4 ([#9148](https://github.com/opensearch-project/OpenSearch/pull/9148)) - Bump `com.azure:azure-storage-blob` from 12.22.3 to 12.23.0 ([#9231](https://github.com/opensearch-project/OpenSearch/pull/9231)) - Bump `com.diffplug.spotless` from 6.19.0 to 6.20.0 ([#9227](https://github.com/opensearch-project/OpenSearch/pull/9227)) +- Bump `org.xerial.snappy:snappy-java` from 1.1.8.2 to 1.1.10.3 ([#9252](https://github.com/opensearch-project/OpenSearch/pull/9252)) +- Bump `com.squareup.okhttp3:okhttp` from 4.9.3 to 4.11.0 ([#9252](https://github.com/opensearch-project/OpenSearch/pull/9252)) +- Bump `com.squareup.okio:okio` from 2.8.0 to 3.5.0 ([#9252](https://github.com/opensearch-project/OpenSearch/pull/9252)) ### Changed - Perform aggregation postCollection in ContextIndexSearcher after searching leaves ([#8303](https://github.com/opensearch-project/OpenSearch/pull/8303)) diff --git a/test/fixtures/hdfs-fixture/build.gradle b/test/fixtures/hdfs-fixture/build.gradle index ff25e1b0852e1..79841ca70b53a 100644 --- a/test/fixtures/hdfs-fixture/build.gradle +++ b/test/fixtures/hdfs-fixture/build.gradle @@ -45,6 +45,9 @@ dependencies { exclude module: 'protobuf-java' exclude group: 'org.codehaus.jackson' exclude group: "org.bouncycastle" + exclude group: "com.squareup.okhttp3" + exclude group: "org.xerial.snappy" + exclude module: "json-io" } api "org.codehaus.jettison:jettison:${versions.jettison}" api "org.apache.commons:commons-compress:1.23.0" @@ -65,5 +68,9 @@ dependencies { api "org.apache.commons:commons-text:1.10.0" api "commons-net:commons-net:3.9.0" runtimeOnly "com.google.guava:guava:${versions.guava}" - + runtimeOnly("com.squareup.okhttp3:okhttp:4.11.0") { + exclude group: "com.squareup.okio" + } + runtimeOnly "com.squareup.okio:okio:3.5.0" + runtimeOnly "org.xerial.snappy:snappy-java:1.1.10.3" } From d102a04b6eecf994527c7bd1bf75a1584bfabb1a Mon Sep 17 00:00:00 2001 From: Varun Bansal Date: Fri, 11 Aug 2023 18:23:22 +0530 Subject: [PATCH 20/26] [Remote Store] Introduce RemoteStoreRestoreService to handle restore from remote store (#9256) Signed-off-by: bansvaru --- .../TransportRestoreRemoteStoreAction.java | 33 ++-- .../recovery/RemoteStoreRestoreService.java | 153 ++++++++++++++++++ .../main/java/org/opensearch/node/Node.java | 6 + .../opensearch/snapshots/RestoreService.java | 2 +- 4 files changed, 175 insertions(+), 19 deletions(-) create mode 100644 server/src/main/java/org/opensearch/index/recovery/RemoteStoreRestoreService.java diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/TransportRestoreRemoteStoreAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/TransportRestoreRemoteStoreAction.java index 36c8038ba2d67..4cab507adde3a 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/TransportRestoreRemoteStoreAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/remotestore/restore/TransportRestoreRemoteStoreAction.java @@ -19,7 +19,7 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.core.common.io.stream.StreamInput; -import org.opensearch.snapshots.RestoreService; +import org.opensearch.index.recovery.RemoteStoreRestoreService; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; @@ -33,14 +33,14 @@ public final class TransportRestoreRemoteStoreAction extends TransportClusterManagerNodeAction< RestoreRemoteStoreRequest, RestoreRemoteStoreResponse> { - private final RestoreService restoreService; + private final RemoteStoreRestoreService restoreService; @Inject public TransportRestoreRemoteStoreAction( TransportService transportService, ClusterService clusterService, ThreadPool threadPool, - RestoreService restoreService, + RemoteStoreRestoreService restoreService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver ) { @@ -84,20 +84,17 @@ protected void clusterManagerOperation( final ClusterState state, final ActionListener listener ) { - restoreService.restoreFromRemoteStore( - request, - ActionListener.delegateFailure(listener, (delegatedListener, restoreCompletionResponse) -> { - if (restoreCompletionResponse.getRestoreInfo() == null && request.waitForCompletion()) { - RestoreClusterStateListener.createAndRegisterListener( - clusterService, - restoreCompletionResponse, - delegatedListener, - RestoreRemoteStoreResponse::new - ); - } else { - delegatedListener.onResponse(new RestoreRemoteStoreResponse(restoreCompletionResponse.getRestoreInfo())); - } - }) - ); + restoreService.restore(request, ActionListener.delegateFailure(listener, (delegatedListener, restoreCompletionResponse) -> { + if (restoreCompletionResponse.getRestoreInfo() == null && request.waitForCompletion()) { + RestoreClusterStateListener.createAndRegisterListener( + clusterService, + restoreCompletionResponse, + delegatedListener, + RestoreRemoteStoreResponse::new + ); + } else { + delegatedListener.onResponse(new RestoreRemoteStoreResponse(restoreCompletionResponse.getRestoreInfo())); + } + })); } } diff --git a/server/src/main/java/org/opensearch/index/recovery/RemoteStoreRestoreService.java b/server/src/main/java/org/opensearch/index/recovery/RemoteStoreRestoreService.java new file mode 100644 index 0000000000000..2617898fef491 --- /dev/null +++ b/server/src/main/java/org/opensearch/index/recovery/RemoteStoreRestoreService.java @@ -0,0 +1,153 @@ +/* + * 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. + */ + +package org.opensearch.index.recovery; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.opensearch.action.admin.cluster.remotestore.restore.RestoreRemoteStoreRequest; +import org.opensearch.cluster.ClusterState; +import org.opensearch.cluster.ClusterStateUpdateTask; +import org.opensearch.cluster.block.ClusterBlocks; +import org.opensearch.cluster.metadata.IndexMetadata; +import org.opensearch.cluster.metadata.Metadata; +import org.opensearch.cluster.routing.IndexShardRoutingTable; +import org.opensearch.cluster.routing.RecoverySource; +import org.opensearch.cluster.routing.RoutingTable; +import org.opensearch.cluster.routing.ShardRouting; +import org.opensearch.cluster.routing.allocation.AllocationService; +import org.opensearch.cluster.service.ClusterService; +import org.opensearch.common.UUIDs; +import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.action.ActionListener; +import org.opensearch.core.index.shard.ShardId; +import org.opensearch.repositories.IndexId; +import org.opensearch.snapshots.RestoreInfo; +import org.opensearch.snapshots.RestoreService; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_STORE_ENABLED; + +/** + * Service responsible for restoring index data from remote store + * + * @opensearch.internal + */ +public class RemoteStoreRestoreService { + private static final Logger logger = LogManager.getLogger(RemoteStoreRestoreService.class); + + private final ClusterService clusterService; + + private final AllocationService allocationService; + + public RemoteStoreRestoreService(ClusterService clusterService, AllocationService allocationService) { + this.clusterService = clusterService; + this.allocationService = allocationService; + } + + public void restore(RestoreRemoteStoreRequest request, final ActionListener listener) { + clusterService.submitStateUpdateTask("restore[remote_store]", new ClusterStateUpdateTask() { + final String restoreUUID = UUIDs.randomBase64UUID(); + RestoreInfo restoreInfo = null; + + @Override + public ClusterState execute(ClusterState currentState) { + // Updating cluster state + ClusterState.Builder builder = ClusterState.builder(currentState); + Metadata.Builder mdBuilder = Metadata.builder(currentState.metadata()); + ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks()); + RoutingTable.Builder rtBuilder = RoutingTable.builder(currentState.routingTable()); + + List indicesToBeRestored = new ArrayList<>(); + int totalShards = 0; + for (String index : request.indices()) { + IndexMetadata currentIndexMetadata = currentState.metadata().index(index); + if (currentIndexMetadata == null) { + // ToDo: Handle index metadata does not exist case. (GitHub #3457) + logger.warn("Remote store restore is not supported for non-existent index. Skipping: {}", index); + continue; + } + if (currentIndexMetadata.getSettings().getAsBoolean(SETTING_REMOTE_STORE_ENABLED, false)) { + IndexMetadata updatedIndexMetadata = currentIndexMetadata; + Map activeInitializingShards = new HashMap<>(); + if (request.restoreAllShards()) { + if (currentIndexMetadata.getState() != IndexMetadata.State.CLOSE) { + throw new IllegalStateException( + "cannot restore index [" + + index + + "] because an open index " + + "with same name already exists in the cluster. Close the existing index" + ); + } + updatedIndexMetadata = IndexMetadata.builder(currentIndexMetadata) + .state(IndexMetadata.State.OPEN) + .version(1 + currentIndexMetadata.getVersion()) + .mappingVersion(1 + currentIndexMetadata.getMappingVersion()) + .settingsVersion(1 + currentIndexMetadata.getSettingsVersion()) + .aliasesVersion(1 + currentIndexMetadata.getAliasesVersion()) + .build(); + } else { + activeInitializingShards = currentState.routingTable() + .index(index) + .shards() + .values() + .stream() + .map(IndexShardRoutingTable::primaryShard) + .filter(shardRouting -> shardRouting.unassigned() == false) + .collect(Collectors.toMap(ShardRouting::shardId, Function.identity())); + } + + IndexId indexId = new IndexId(index, updatedIndexMetadata.getIndexUUID()); + + RecoverySource.RemoteStoreRecoverySource recoverySource = new RecoverySource.RemoteStoreRecoverySource( + restoreUUID, + updatedIndexMetadata.getCreationVersion(), + indexId + ); + rtBuilder.addAsRemoteStoreRestore(updatedIndexMetadata, recoverySource, activeInitializingShards); + blocks.updateBlocks(updatedIndexMetadata); + mdBuilder.put(updatedIndexMetadata, true); + indicesToBeRestored.add(index); + totalShards += updatedIndexMetadata.getNumberOfShards(); + } else { + logger.warn("Remote store is not enabled for index: {}", index); + } + } + + restoreInfo = new RestoreInfo("remote_store", indicesToBeRestored, totalShards, totalShards); + + RoutingTable rt = rtBuilder.build(); + ClusterState updatedState = builder.metadata(mdBuilder).blocks(blocks).routingTable(rt).build(); + return allocationService.reroute(updatedState, "restored from remote store"); + } + + @Override + public void onFailure(String source, Exception e) { + logger.warn("failed to restore from remote store", e); + listener.onFailure(e); + } + + @Override + public TimeValue timeout() { + return request.masterNodeTimeout(); + } + + @Override + public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { + listener.onResponse(new RestoreService.RestoreCompletionResponse(restoreUUID, null, restoreInfo)); + } + }); + + } +} diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index 60c95a04a042f..f39fcd2714b6f 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -44,6 +44,7 @@ import org.opensearch.cluster.routing.allocation.AwarenessReplicaBalance; import org.opensearch.index.IndexModule; import org.opensearch.index.IndexingPressureService; +import org.opensearch.index.recovery.RemoteStoreRestoreService; import org.opensearch.index.store.remote.filecache.FileCache; import org.opensearch.index.store.remote.filecache.FileCacheCleaner; import org.opensearch.index.store.remote.filecache.FileCacheFactory; @@ -945,6 +946,10 @@ protected Node( indicesService, clusterInfoService::getClusterInfo ); + RemoteStoreRestoreService remoteStoreRestoreService = new RemoteStoreRestoreService( + clusterService, + clusterModule.getAllocationService() + ); final DiskThresholdMonitor diskThresholdMonitor = new DiskThresholdMonitor( settings, @@ -1141,6 +1146,7 @@ protected Node( b.bind(SnapshotShardsService.class).toInstance(snapshotShardsService); b.bind(TransportNodesSnapshotsStatus.class).toInstance(nodesSnapshotsStatus); b.bind(RestoreService.class).toInstance(restoreService); + b.bind(RemoteStoreRestoreService.class).toInstance(remoteStoreRestoreService); b.bind(RerouteService.class).toInstance(rerouteService); b.bind(ShardLimitValidator.class).toInstance(shardLimitValidator); b.bind(FsHealthService.class).toInstance(fsHealthService); diff --git a/server/src/main/java/org/opensearch/snapshots/RestoreService.java b/server/src/main/java/org/opensearch/snapshots/RestoreService.java index 67e0f7d4bba54..269590e628079 100644 --- a/server/src/main/java/org/opensearch/snapshots/RestoreService.java +++ b/server/src/main/java/org/opensearch/snapshots/RestoreService.java @@ -986,7 +986,7 @@ public static final class RestoreCompletionResponse { private final Snapshot snapshot; private final RestoreInfo restoreInfo; - private RestoreCompletionResponse(final String uuid, final Snapshot snapshot, final RestoreInfo restoreInfo) { + public RestoreCompletionResponse(final String uuid, final Snapshot snapshot, final RestoreInfo restoreInfo) { this.uuid = uuid; this.snapshot = snapshot; this.restoreInfo = restoreInfo; From 5c283e0b557119d7ae982f6d3848a2c7137f064f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Aug 2023 09:38:03 -0400 Subject: [PATCH 21/26] Bump com.google.code.gson:gson from 2.9.0 to 2.10.1 in /plugins/repository-gcs (#9230) * Bump com.google.code.gson:gson in /plugins/repository-gcs Bumps [com.google.code.gson:gson](https://github.com/google/gson) from 2.9.0 to 2.10.1. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/main/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.9.0...gson-parent-2.10.1) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Updating SHAs Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 1 + plugins/repository-gcs/build.gradle | 2 +- plugins/repository-gcs/licenses/gson-2.10.1.jar.sha1 | 1 + plugins/repository-gcs/licenses/gson-2.9.0.jar.sha1 | 1 - 4 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 plugins/repository-gcs/licenses/gson-2.10.1.jar.sha1 delete mode 100644 plugins/repository-gcs/licenses/gson-2.9.0.jar.sha1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a8cf50322cc7..eff03760a86da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,6 +111,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Bump `org.xerial.snappy:snappy-java` from 1.1.8.2 to 1.1.10.3 ([#9252](https://github.com/opensearch-project/OpenSearch/pull/9252)) - Bump `com.squareup.okhttp3:okhttp` from 4.9.3 to 4.11.0 ([#9252](https://github.com/opensearch-project/OpenSearch/pull/9252)) - Bump `com.squareup.okio:okio` from 2.8.0 to 3.5.0 ([#9252](https://github.com/opensearch-project/OpenSearch/pull/9252)) +- Bump `com.google.code.gson:gson` from 2.9.0 to 2.10.1 ([#9230](https://github.com/opensearch-project/OpenSearch/pull/9230)) ### Changed - Perform aggregation postCollection in ContextIndexSearcher after searching leaves ([#8303](https://github.com/opensearch-project/OpenSearch/pull/8303)) diff --git a/plugins/repository-gcs/build.gradle b/plugins/repository-gcs/build.gradle index 3719637a4b33e..1f4104a929116 100644 --- a/plugins/repository-gcs/build.gradle +++ b/plugins/repository-gcs/build.gradle @@ -70,7 +70,7 @@ dependencies { api 'com.google.cloud:google-cloud-core-http:2.21.1' api 'com.google.cloud:google-cloud-storage:1.113.1' - api 'com.google.code.gson:gson:2.9.0' + api 'com.google.code.gson:gson:2.10.1' runtimeOnly "com.google.guava:guava:${versions.guava}" api 'com.google.guava:failureaccess:1.0.1' diff --git a/plugins/repository-gcs/licenses/gson-2.10.1.jar.sha1 b/plugins/repository-gcs/licenses/gson-2.10.1.jar.sha1 new file mode 100644 index 0000000000000..9810309d1013a --- /dev/null +++ b/plugins/repository-gcs/licenses/gson-2.10.1.jar.sha1 @@ -0,0 +1 @@ +b3add478d4382b78ea20b1671390a858002feb6c \ No newline at end of file diff --git a/plugins/repository-gcs/licenses/gson-2.9.0.jar.sha1 b/plugins/repository-gcs/licenses/gson-2.9.0.jar.sha1 deleted file mode 100644 index 8e9626b0c949b..0000000000000 --- a/plugins/repository-gcs/licenses/gson-2.9.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -8a1167e089096758b49f9b34066ef98b2f4b37aa \ No newline at end of file From 4b21849c955a11f10561516cc77c5fe8db4303d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Aug 2023 09:45:52 -0700 Subject: [PATCH 22/26] Bump lycheeverse/lychee-action from 1.2.0 to 1.8.0 (#9228) * Bump lycheeverse/lychee-action from 1.2.0 to 1.8.0 Bumps [lycheeverse/lychee-action](https://github.com/lycheeverse/lychee-action) from 1.2.0 to 1.8.0. - [Release notes](https://github.com/lycheeverse/lychee-action/releases) - [Commits](https://github.com/lycheeverse/lychee-action/compare/v1.2.0...v1.8.0) --- updated-dependencies: - dependency-name: lycheeverse/lychee-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- .github/workflows/links.yml | 2 +- CHANGELOG.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index ac94f5ef5ec5e..4322a740145e6 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 - name: lychee Link Checker id: lychee - uses: lycheeverse/lychee-action@v1.2.0 + uses: lycheeverse/lychee-action@v1.8.0 with: args: --accept=200,403,429 --exclude-mail **/*.html **/*.md **/*.txt **/*.json --exclude-file .lychee.excludes fail: true diff --git a/CHANGELOG.md b/CHANGELOG.md index eff03760a86da..5e3ccb1326bdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,6 +112,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Bump `com.squareup.okhttp3:okhttp` from 4.9.3 to 4.11.0 ([#9252](https://github.com/opensearch-project/OpenSearch/pull/9252)) - Bump `com.squareup.okio:okio` from 2.8.0 to 3.5.0 ([#9252](https://github.com/opensearch-project/OpenSearch/pull/9252)) - Bump `com.google.code.gson:gson` from 2.9.0 to 2.10.1 ([#9230](https://github.com/opensearch-project/OpenSearch/pull/9230)) +- Bump `lycheeverse/lychee-action` from 1.2.0 to 1.8.0 ([#9228](https://github.com/opensearch-project/OpenSearch/pull/9228)) ### Changed - Perform aggregation postCollection in ContextIndexSearcher after searching leaves ([#8303](https://github.com/opensearch-project/OpenSearch/pull/8303)) From ab08d739363befc3dadbdf14827e79bc9f529a6f Mon Sep 17 00:00:00 2001 From: Marc Handalian Date: Fri, 11 Aug 2023 11:21:26 -0700 Subject: [PATCH 23/26] Fix flaky test SegmentReplicationIT.testDeleteOperations. (#9244) Signed-off-by: Marc Handalian --- .../opensearch/indices/replication/SegmentReplicationIT.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java index b14c59869ccbc..ad6c1491267bd 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java @@ -615,7 +615,7 @@ public void testDeleteOperations() throws Exception { createIndex(INDEX_NAME); ensureGreen(INDEX_NAME); - final int initialDocCount = scaledRandomIntBetween(0, 200); + final int initialDocCount = scaledRandomIntBetween(1, 20); try ( BackgroundIndexer indexer = new BackgroundIndexer( INDEX_NAME, @@ -632,7 +632,7 @@ public void testDeleteOperations() throws Exception { refresh(INDEX_NAME); waitForSearchableDocs(initialDocCount, nodeA, nodeB); - final int additionalDocCount = scaledRandomIntBetween(0, 200); + final int additionalDocCount = scaledRandomIntBetween(0, 20); final int expectedHitCount = initialDocCount + additionalDocCount; indexer.start(additionalDocCount); waitForDocs(expectedHitCount, indexer); @@ -641,6 +641,7 @@ public void testDeleteOperations() throws Exception { ensureGreen(INDEX_NAME); Set ids = indexer.getIds(); + assertFalse(ids.isEmpty()); String id = ids.toArray()[0].toString(); client(nodeA).prepareDelete(INDEX_NAME, id).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get(); From 4711dccdb9b69c49ea48fde9e4516d75c9fe6e69 Mon Sep 17 00:00:00 2001 From: Kunal Kotwani Date: Fri, 11 Aug 2023 11:22:25 -0700 Subject: [PATCH 24/26] Upgrade backport action to support failed labels (#9270) Signed-off-by: Kunal Kotwani --- .github/workflows/backport.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 2b95fb2510bdd..607c6de58b7f6 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -33,7 +33,8 @@ jobs: installation_id: 22958780 - name: Backport - uses: VachaShah/backport@v2.1.0 + uses: VachaShah/backport@v2.2.0 with: github_token: ${{ steps.github_app_token.outputs.token }} head_template: backport/backport-<%= number %>-to-<%= base %> + failure_labels: backport-failed From 3ddff4c1fc39b06218be4ba96aa33b3545fe733d Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Fri, 11 Aug 2023 14:34:17 -0400 Subject: [PATCH 25/26] Bump snakeyaml from 2.0 to 2.1 (#9269) Signed-off-by: Andriy Redko --- CHANGELOG.md | 1 + buildSrc/version.properties | 2 +- libs/x-content/licenses/snakeyaml-2.0.jar.sha1 | 1 - libs/x-content/licenses/snakeyaml-2.1.jar.sha1 | 1 + 4 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 libs/x-content/licenses/snakeyaml-2.0.jar.sha1 create mode 100644 libs/x-content/licenses/snakeyaml-2.1.jar.sha1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e3ccb1326bdd..6b677e9d33849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -113,6 +113,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Bump `com.squareup.okio:okio` from 2.8.0 to 3.5.0 ([#9252](https://github.com/opensearch-project/OpenSearch/pull/9252)) - Bump `com.google.code.gson:gson` from 2.9.0 to 2.10.1 ([#9230](https://github.com/opensearch-project/OpenSearch/pull/9230)) - Bump `lycheeverse/lychee-action` from 1.2.0 to 1.8.0 ([#9228](https://github.com/opensearch-project/OpenSearch/pull/9228)) +- Bump `snakeyaml` from 2.0 to 2.1 ([#9269](https://github.com/opensearch-project/OpenSearch/pull/9269)) ### Changed - Perform aggregation postCollection in ContextIndexSearcher after searching leaves ([#8303](https://github.com/opensearch-project/OpenSearch/pull/8303)) diff --git a/buildSrc/version.properties b/buildSrc/version.properties index 53fcd63944d6a..ff962309cf084 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -11,7 +11,7 @@ spatial4j = 0.7 jts = 1.15.0 jackson = 2.15.2 jackson_databind = 2.15.2 -snakeyaml = 2.0 +snakeyaml = 2.1 icu4j = 70.1 supercsv = 2.4.0 log4j = 2.20.0 diff --git a/libs/x-content/licenses/snakeyaml-2.0.jar.sha1 b/libs/x-content/licenses/snakeyaml-2.0.jar.sha1 deleted file mode 100644 index d09dea5564729..0000000000000 --- a/libs/x-content/licenses/snakeyaml-2.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3aab2116756442bf0d4cd1c089b24d34c3baa253 \ No newline at end of file diff --git a/libs/x-content/licenses/snakeyaml-2.1.jar.sha1 b/libs/x-content/licenses/snakeyaml-2.1.jar.sha1 new file mode 100644 index 0000000000000..5586b210a9736 --- /dev/null +++ b/libs/x-content/licenses/snakeyaml-2.1.jar.sha1 @@ -0,0 +1 @@ +c79f47315517560b5bd6a62376ee385e48105437 \ No newline at end of file From 00558e319acfb949ec952c86610fae05105ea606 Mon Sep 17 00:00:00 2001 From: Gagan Juneja Date: Sat, 12 Aug 2023 01:10:58 +0530 Subject: [PATCH 26/26] Adds attributes to startSpan (#9199) * Adds attributes to startSpan Signed-off-by: Gagan Juneja * Update Changelog Signed-off-by: Gagan Juneja * Adds attributes to startSpan Signed-off-by: Gagan Juneja * Refactor code Signed-off-by: Gagan Juneja * Add java doc Signed-off-by: Gagan Juneja * Refactor code Signed-off-by: Gagan Juneja * Refactor code Signed-off-by: Gagan Juneja * Refactor code Signed-off-by: Gagan Juneja * Removes dependency Signed-off-by: Gagan Juneja --------- Signed-off-by: Gagan Juneja Co-authored-by: Gagan Juneja --- CHANGELOG.md | 3 +- .../telemetry/tracing/DefaultTracer.java | 18 ++-- .../opensearch/telemetry/tracing/Tracer.java | 15 ++- .../telemetry/tracing/TracingTelemetry.java | 4 +- .../tracing/attributes/Attributes.java | 94 +++++++++++++++++++ .../tracing/attributes/package-info.java | 12 +++ .../telemetry/tracing/noop/NoopTracer.java | 12 ++- .../tracing/runnable/TraceableRunnable.java | 8 +- .../telemetry/tracing/DefaultTracerTests.java | 47 +++++++++- .../tracing/TraceableRunnableTests.java | 12 ++- .../tracing/OTelAttributesConverter.java | 51 ++++++++++ .../tracing/OTelTracingTelemetry.java | 19 ++-- .../tracing/OTelAttributesConverterTests.java | 48 ++++++++++ .../tracing/OTelTracingTelemetryTests.java | 62 +++++++++++- .../telemetry/tracing/WrappedTracer.java | 12 ++- .../telemetry/tracing/WrappedTracerTests.java | 18 +++- .../test/telemetry/tracing/MockSpan.java | 37 +++++++- .../tracing/MockTracingContextPropagator.java | 3 +- .../tracing/MockTracingTelemetry.java | 5 +- 19 files changed, 440 insertions(+), 40 deletions(-) create mode 100644 libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/Attributes.java create mode 100644 libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/package-info.java create mode 100644 plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelAttributesConverter.java create mode 100644 plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/tracing/OTelAttributesConverterTests.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b677e9d33849..59de7ea2fc2d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,6 +127,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - [Remove] Deprecated Fractional ByteSizeValue support #9005 ([#9005](https://github.com/opensearch-project/OpenSearch/pull/9005)) - Make MultiBucketConsumerService thread safe to use across slices during search ([#9047](https://github.com/opensearch-project/OpenSearch/pull/9047)) - Change shard_size and shard_min_doc_count evaluation to happen in shard level reduce phase ([#9085](https://github.com/opensearch-project/OpenSearch/pull/9085)) +- Add attributes to startSpan methods ([#9199](https://github.com/opensearch-project/OpenSearch/pull/9199)) ### Deprecated @@ -138,4 +139,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Security [Unreleased 3.0]: https://github.com/opensearch-project/OpenSearch/compare/2.x...HEAD -[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.10...2.x \ No newline at end of file +[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.10...2.x diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java index f46c3e57b6c4b..98d7863bc6bfe 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/DefaultTracer.java @@ -10,6 +10,7 @@ import java.io.Closeable; import java.io.IOException; +import org.opensearch.telemetry.tracing.attributes.Attributes; /** * @@ -37,16 +38,21 @@ public DefaultTracer(TracingTelemetry tracingTelemetry, TracerContextStorage attributesMap; + /** + * Empty value. + */ + public final static Attributes EMPTY = new Attributes(Collections.emptyMap()); + + /** + * Factory method. + * @return attributes. + */ + public static Attributes create() { + return new Attributes(new HashMap<>()); + } + + /** + * Constructor. + */ + private Attributes(Map attributesMap) { + this.attributesMap = attributesMap; + } + + /** + * Add String attribute. + * @param key key + * @param value value + * @return Same instance. + */ + public Attributes addAttribute(String key, String value) { + Objects.requireNonNull(value, "value cannot be null"); + attributesMap.put(key, value); + return this; + } + + /** + * Add long attribute. + * @param key key + * @param value value + * @return Same instance. + */ + public Attributes addAttribute(String key, long value) { + attributesMap.put(key, value); + return this; + }; + + /** + * Add double attribute. + * @param key key + * @param value value + * @return Same instance. + */ + public Attributes addAttribute(String key, double value) { + attributesMap.put(key, value); + return this; + }; + + /** + * Add boolean attribute. + * @param key key + * @param value value + * @return Same instance. + */ + public Attributes addAttribute(String key, boolean value) { + attributesMap.put(key, value); + return this; + }; + + /** + * Returns the attribute map. + * @return attributes map + */ + public Map getAttributesMap() { + return Collections.unmodifiableMap(attributesMap); + } + +} diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/package-info.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/package-info.java new file mode 100644 index 0000000000000..91d1c3291a4a5 --- /dev/null +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/attributes/package-info.java @@ -0,0 +1,12 @@ +/* + * 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. + */ + +/** + * Contains No-op implementations + */ +package org.opensearch.telemetry.tracing.attributes; diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java index 74480844f5a3c..8ac0deebbcfca 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/noop/NoopTracer.java @@ -11,6 +11,7 @@ import org.opensearch.telemetry.tracing.SpanScope; import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.telemetry.tracing.SpanContext; +import org.opensearch.telemetry.tracing.attributes.Attributes; /** * No-op implementation of Tracer @@ -32,15 +33,20 @@ public SpanScope startSpan(String spanName) { } @Override - public SpanContext getCurrentSpan() { - return null; + public SpanScope startSpan(String spanName, Attributes attributes) { + return SpanScope.NO_OP; } @Override - public SpanScope startSpan(String spanName, SpanContext parentSpan) { + public SpanScope startSpan(String spanName, SpanContext parentSpan, Attributes attributes) { return SpanScope.NO_OP; } + @Override + public SpanContext getCurrentSpan() { + return null; + } + @Override public void close() { diff --git a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/TraceableRunnable.java b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/TraceableRunnable.java index 5f179467d5426..54a5a7f1678e6 100644 --- a/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/TraceableRunnable.java +++ b/libs/telemetry/src/main/java/org/opensearch/telemetry/tracing/runnable/TraceableRunnable.java @@ -11,6 +11,7 @@ import org.opensearch.telemetry.tracing.SpanContext; import org.opensearch.telemetry.tracing.SpanScope; import org.opensearch.telemetry.tracing.Tracer; +import org.opensearch.telemetry.tracing.attributes.Attributes; /** * Wraps the runnable and add instrumentation to trace the {@link Runnable} @@ -20,24 +21,27 @@ public class TraceableRunnable implements Runnable { private final SpanContext parent; private final Tracer tracer; private final String spanName; + private final Attributes attributes; /** * Constructor. * @param tracer tracer * @param spanName spanName * @param parent parent Span. + * @param attributes attributes. * @param runnable runnable. */ - public TraceableRunnable(Tracer tracer, String spanName, SpanContext parent, Runnable runnable) { + public TraceableRunnable(Tracer tracer, String spanName, SpanContext parent, Attributes attributes, Runnable runnable) { this.tracer = tracer; this.spanName = spanName; this.parent = parent; + this.attributes = attributes; this.runnable = runnable; } @Override public void run() { - try (SpanScope spanScope = tracer.startSpan(spanName, parent)) { + try (SpanScope spanScope = tracer.startSpan(spanName, parent, attributes)) { runnable.run(); } } diff --git a/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java b/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java index 6c39b81783f65..e0d9889855414 100644 --- a/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java +++ b/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/DefaultTracerTests.java @@ -11,12 +11,17 @@ import org.junit.Assert; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.telemetry.tracing.attributes.Attributes; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; +import org.opensearch.test.telemetry.tracing.MockSpan; import org.opensearch.test.telemetry.tracing.MockTracingTelemetry; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.when; import static org.mockito.Mockito.verify; @@ -46,6 +51,42 @@ public void testCreateSpan() { Assert.assertEquals("span_name", defaultTracer.getCurrentSpan().getSpan().getSpanName()); } + public void testCreateSpanWithAttributesWithMock() { + DefaultTracer defaultTracer = new DefaultTracer(mockTracingTelemetry, mockTracerContextStorage); + Attributes attributes = Attributes.create().addAttribute("name", "value"); + when(mockTracingTelemetry.createSpan("span_name", mockParentSpan, attributes)).thenReturn(mockSpan); + defaultTracer.startSpan("span_name", attributes); + verify(mockTracingTelemetry).createSpan("span_name", mockParentSpan, attributes); + } + + public void testCreateSpanWithAttributesWithParentMock() { + DefaultTracer defaultTracer = new DefaultTracer(mockTracingTelemetry, mockTracerContextStorage); + Attributes attributes = Attributes.create().addAttribute("name", "value"); + when(mockTracingTelemetry.createSpan("span_name", mockParentSpan, attributes)).thenReturn(mockSpan); + defaultTracer.startSpan("span_name", new SpanContext(mockParentSpan), attributes); + verify(mockTracingTelemetry).createSpan("span_name", mockParentSpan, attributes); + verify(mockTracerContextStorage, never()).get(TracerContextStorage.CURRENT_SPAN); + } + + public void testCreateSpanWithAttributes() { + TracingTelemetry tracingTelemetry = new MockTracingTelemetry(); + DefaultTracer defaultTracer = new DefaultTracer( + tracingTelemetry, + new ThreadContextBasedTracerContextStorage(new ThreadContext(Settings.EMPTY), tracingTelemetry) + ); + + defaultTracer.startSpan( + "span_name", + Attributes.create().addAttribute("key1", 1.0).addAttribute("key2", 2l).addAttribute("key3", true).addAttribute("key4", "key4") + ); + + Assert.assertEquals("span_name", defaultTracer.getCurrentSpan().getSpan().getSpanName()); + Assert.assertEquals(1.0, ((MockSpan) defaultTracer.getCurrentSpan().getSpan()).getAttribute("key1")); + Assert.assertEquals(2l, ((MockSpan) defaultTracer.getCurrentSpan().getSpan()).getAttribute("key2")); + Assert.assertEquals(true, ((MockSpan) defaultTracer.getCurrentSpan().getSpan()).getAttribute("key3")); + Assert.assertEquals("key4", ((MockSpan) defaultTracer.getCurrentSpan().getSpan()).getAttribute("key4")); + } + public void testCreateSpanWithParent() { TracingTelemetry tracingTelemetry = new MockTracingTelemetry(); DefaultTracer defaultTracer = new DefaultTracer( @@ -57,7 +98,7 @@ public void testCreateSpanWithParent() { SpanContext parentSpan = defaultTracer.getCurrentSpan(); - defaultTracer.startSpan("span_name_1", parentSpan); + defaultTracer.startSpan("span_name_1", parentSpan, Attributes.EMPTY); Assert.assertEquals("span_name_1", defaultTracer.getCurrentSpan().getSpan().getSpanName()); Assert.assertEquals(parentSpan.getSpan(), defaultTracer.getCurrentSpan().getSpan().getParentSpan()); @@ -70,7 +111,7 @@ public void testCreateSpanWithNullParent() { new ThreadContextBasedTracerContextStorage(new ThreadContext(Settings.EMPTY), tracingTelemetry) ); - defaultTracer.startSpan("span_name", null); + defaultTracer.startSpan("span_name", null, Attributes.EMPTY); Assert.assertEquals("span_name", defaultTracer.getCurrentSpan().getSpan().getSpanName()); Assert.assertEquals(null, defaultTracer.getCurrentSpan().getSpan().getParentSpan()); @@ -105,6 +146,6 @@ private void setupMocks() { when(mockParentSpan.getSpanId()).thenReturn("parent_span_id"); when(mockParentSpan.getTraceId()).thenReturn("trace_id"); when(mockTracerContextStorage.get(TracerContextStorage.CURRENT_SPAN)).thenReturn(mockParentSpan, mockSpan); - when(mockTracingTelemetry.createSpan("span_name", mockParentSpan)).thenReturn(mockSpan); + when(mockTracingTelemetry.createSpan(eq("span_name"), eq(mockParentSpan), any(Attributes.class))).thenReturn(mockSpan); } } diff --git a/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/TraceableRunnableTests.java b/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/TraceableRunnableTests.java index 28cd036d44e5e..32ae48fd479a4 100644 --- a/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/TraceableRunnableTests.java +++ b/libs/telemetry/src/test/java/org/opensearch/telemetry/tracing/TraceableRunnableTests.java @@ -12,8 +12,10 @@ import java.util.concurrent.atomic.AtomicReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.telemetry.tracing.attributes.Attributes; import org.opensearch.telemetry.tracing.runnable.TraceableRunnable; import org.opensearch.test.OpenSearchTestCase; +import org.opensearch.test.telemetry.tracing.MockSpan; import org.opensearch.test.telemetry.tracing.MockTracingTelemetry; public class TraceableRunnableTests extends OpenSearchTestCase { @@ -27,16 +29,22 @@ public void testRunnableWithNullParent() throws Exception { String spanName = "testRunnable"; DefaultTracer defaultTracer = new DefaultTracer(new MockTracingTelemetry(), contextStorage); final AtomicBoolean isRunnableCompleted = new AtomicBoolean(false); + TraceableRunnable traceableRunnable = new TraceableRunnable( defaultTracer, spanName, null, - () -> { isRunnableCompleted.set(true); } + Attributes.create().addAttribute("name", "value"), + () -> { + isRunnableCompleted.set(true); + } ); traceableRunnable.run(); assertTrue(isRunnableCompleted.get()); assertEquals(spanName, defaultTracer.getCurrentSpan().getSpan().getSpanName()); assertEquals(null, defaultTracer.getCurrentSpan().getSpan().getParentSpan()); + assertEquals("value", ((MockSpan) defaultTracer.getCurrentSpan().getSpan()).getAttribute("name")); + } public void testRunnableWithParent() throws Exception { @@ -47,7 +55,7 @@ public void testRunnableWithParent() throws Exception { SpanContext parentSpan = defaultTracer.getCurrentSpan(); AtomicReference currrntSpan = new AtomicReference<>(new SpanContext(null)); final AtomicBoolean isRunnableCompleted = new AtomicBoolean(false); - TraceableRunnable traceableRunnable = new TraceableRunnable(defaultTracer, spanName, parentSpan, () -> { + TraceableRunnable traceableRunnable = new TraceableRunnable(defaultTracer, spanName, parentSpan, Attributes.EMPTY, () -> { isRunnableCompleted.set(true); currrntSpan.set(defaultTracer.getCurrentSpan()); }); diff --git a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelAttributesConverter.java b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelAttributesConverter.java new file mode 100644 index 0000000000000..ecb2296f959a2 --- /dev/null +++ b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelAttributesConverter.java @@ -0,0 +1,51 @@ +/* + * 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. + */ + +package org.opensearch.telemetry.tracing; + +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.common.AttributesBuilder; +import java.util.Locale; + +/** + * Converts {@link org.opensearch.telemetry.tracing.attributes.Attributes} to OTel {@link Attributes} + */ +final class OTelAttributesConverter { + + /** + * Constructor. + */ + private OTelAttributesConverter() {} + + /** + * Attribute converter. + * @param attributes attributes + * @return otel attributes. + */ + static Attributes convert(org.opensearch.telemetry.tracing.attributes.Attributes attributes) { + AttributesBuilder attributesBuilder = Attributes.builder(); + if (attributes != null) { + attributes.getAttributesMap().forEach((x, y) -> addSpanAttribute(x, y, attributesBuilder)); + } + return attributesBuilder.build(); + } + + private static void addSpanAttribute(String key, Object value, AttributesBuilder attributesBuilder) { + if (value instanceof Boolean) { + attributesBuilder.put(key, (Boolean) value); + } else if (value instanceof Long) { + attributesBuilder.put(key, (Long) value); + } else if (value instanceof Double) { + attributesBuilder.put(key, (Double) value); + } else if (value instanceof String) { + attributesBuilder.put(key, (String) value); + } else { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Span attribute value %s type not supported", value)); + } + } +} diff --git a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelTracingTelemetry.java b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelTracingTelemetry.java index 8a0034e098461..15914d7531afa 100644 --- a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelTracingTelemetry.java +++ b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelTracingTelemetry.java @@ -15,6 +15,7 @@ import java.io.Closeable; import java.io.IOException; +import org.opensearch.telemetry.tracing.attributes.Attributes; /** * OTel based Telemetry provider @@ -22,7 +23,6 @@ public class OTelTracingTelemetry implements TracingTelemetry { private static final Logger logger = LogManager.getLogger(OTelTracingTelemetry.class); - private final OpenTelemetry openTelemetry; private final io.opentelemetry.api.trace.Tracer otelTracer; @@ -46,8 +46,8 @@ public void close() { } @Override - public Span createSpan(String spanName, Span parentSpan) { - return createOtelSpan(spanName, parentSpan); + public Span createSpan(String spanName, Span parentSpan, Attributes attributes) { + return createOtelSpan(spanName, parentSpan, attributes); } @Override @@ -55,14 +55,17 @@ public TracingContextPropagator getContextPropagator() { return new OTelTracingContextPropagator(openTelemetry); } - private Span createOtelSpan(String spanName, Span parentSpan) { - io.opentelemetry.api.trace.Span otelSpan = otelSpan(spanName, parentSpan); + private Span createOtelSpan(String spanName, Span parentSpan, Attributes attributes) { + io.opentelemetry.api.trace.Span otelSpan = otelSpan(spanName, parentSpan, OTelAttributesConverter.convert(attributes)); return new OTelSpan(spanName, otelSpan, parentSpan); } - io.opentelemetry.api.trace.Span otelSpan(String spanName, Span parentOTelSpan) { + io.opentelemetry.api.trace.Span otelSpan(String spanName, Span parentOTelSpan, io.opentelemetry.api.common.Attributes attributes) { return parentOTelSpan == null || !(parentOTelSpan instanceof OTelSpan) - ? otelTracer.spanBuilder(spanName).startSpan() - : otelTracer.spanBuilder(spanName).setParent(Context.current().with(((OTelSpan) parentOTelSpan).getDelegateSpan())).startSpan(); + ? otelTracer.spanBuilder(spanName).setAllAttributes(attributes).startSpan() + : otelTracer.spanBuilder(spanName) + .setParent(Context.current().with(((OTelSpan) parentOTelSpan).getDelegateSpan())) + .setAllAttributes(attributes) + .startSpan(); } } diff --git a/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/tracing/OTelAttributesConverterTests.java b/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/tracing/OTelAttributesConverterTests.java new file mode 100644 index 0000000000000..ae304286fc0fd --- /dev/null +++ b/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/tracing/OTelAttributesConverterTests.java @@ -0,0 +1,48 @@ +/* + * 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. + */ + +package org.opensearch.telemetry.tracing; + +import io.opentelemetry.api.common.AttributeType; +import io.opentelemetry.api.internal.InternalAttributeKeyImpl; +import java.util.Map; +import org.opensearch.telemetry.tracing.attributes.Attributes; +import org.opensearch.test.OpenSearchTestCase; + +public class OTelAttributesConverterTests extends OpenSearchTestCase { + + public void testConverterNullAttributes() { + io.opentelemetry.api.common.Attributes otelAttributes = OTelAttributesConverter.convert(null); + assertEquals(0, otelAttributes.size()); + } + + public void testConverterEmptyAttributes() { + Attributes attributes = Attributes.EMPTY; + io.opentelemetry.api.common.Attributes otelAttributes = OTelAttributesConverter.convert(null); + assertEquals(0, otelAttributes.size()); + } + + public void testConverterSingleAttributes() { + Attributes attributes = Attributes.create().addAttribute("key1", "value"); + io.opentelemetry.api.common.Attributes otelAttributes = OTelAttributesConverter.convert(attributes); + assertEquals(1, otelAttributes.size()); + assertEquals("value", otelAttributes.get(InternalAttributeKeyImpl.create("key1", AttributeType.STRING))); + } + + public void testConverterMultipleAttributes() { + Attributes attributes = Attributes.create() + .addAttribute("key1", 1l) + .addAttribute("key2", 1.0) + .addAttribute("key3", true) + .addAttribute("key4", "value4"); + Map attributeMap = attributes.getAttributesMap(); + io.opentelemetry.api.common.Attributes otelAttributes = OTelAttributesConverter.convert(attributes); + assertEquals(4, otelAttributes.size()); + otelAttributes.asMap().forEach((x, y) -> assertEquals(attributeMap.get(x.getKey()), y)); + } +} diff --git a/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/tracing/OTelTracingTelemetryTests.java b/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/tracing/OTelTracingTelemetryTests.java index 7dec7824b9790..7ff99787b240b 100644 --- a/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/tracing/OTelTracingTelemetryTests.java +++ b/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/tracing/OTelTracingTelemetryTests.java @@ -9,8 +9,12 @@ package org.opensearch.telemetry.tracing; import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.api.trace.SpanBuilder; import io.opentelemetry.api.trace.Tracer; +import java.util.Collections; +import java.util.Map; +import org.opensearch.telemetry.tracing.attributes.Attributes; import org.opensearch.test.OpenSearchTestCase; import static org.mockito.ArgumentMatchers.any; @@ -27,12 +31,15 @@ public void testCreateSpanWithoutParent() { when(mockOpenTelemetry.getTracer("os-tracer")).thenReturn(mockTracer); SpanBuilder mockSpanBuilder = mock(SpanBuilder.class); when(mockTracer.spanBuilder("span_name")).thenReturn(mockSpanBuilder); + when(mockSpanBuilder.setAllAttributes(any(io.opentelemetry.api.common.Attributes.class))).thenReturn(mockSpanBuilder); when(mockSpanBuilder.startSpan()).thenReturn(mock(io.opentelemetry.api.trace.Span.class)); - + Map attributeMap = Collections.singletonMap("name", "value"); + Attributes attributes = Attributes.create().addAttribute("name", "value"); TracingTelemetry tracingTelemetry = new OTelTracingTelemetry(mockOpenTelemetry); - Span span = tracingTelemetry.createSpan("span_name", null); + Span span = tracingTelemetry.createSpan("span_name", null, attributes); verify(mockSpanBuilder, never()).setParent(any()); + verify(mockSpanBuilder).setAllAttributes(createAttribute(attributes)); assertNull(span.getParentSpan()); } @@ -43,18 +50,67 @@ public void testCreateSpanWithParent() { SpanBuilder mockSpanBuilder = mock(SpanBuilder.class); when(mockTracer.spanBuilder("span_name")).thenReturn(mockSpanBuilder); when(mockSpanBuilder.setParent(any())).thenReturn(mockSpanBuilder); + when(mockSpanBuilder.setAllAttributes(any(io.opentelemetry.api.common.Attributes.class))).thenReturn(mockSpanBuilder); + when(mockSpanBuilder.startSpan()).thenReturn(mock(io.opentelemetry.api.trace.Span.class)); + + Span parentSpan = new OTelSpan("parent_span", mock(io.opentelemetry.api.trace.Span.class), null); + + TracingTelemetry tracingTelemetry = new OTelTracingTelemetry(mockOpenTelemetry); + Attributes attributes = Attributes.create().addAttribute("name", 1l); + Span span = tracingTelemetry.createSpan("span_name", parentSpan, attributes); + + verify(mockSpanBuilder).setParent(any()); + verify(mockSpanBuilder).setAllAttributes(createAttributeLong(attributes)); + assertNotNull(span.getParentSpan()); + + assertEquals("parent_span", span.getParentSpan().getSpanName()); + } + + public void testCreateSpanWithParentWithMultipleAttributes() { + OpenTelemetry mockOpenTelemetry = mock(OpenTelemetry.class); + Tracer mockTracer = mock(Tracer.class); + when(mockOpenTelemetry.getTracer("os-tracer")).thenReturn(mockTracer); + SpanBuilder mockSpanBuilder = mock(SpanBuilder.class); + when(mockTracer.spanBuilder("span_name")).thenReturn(mockSpanBuilder); + when(mockSpanBuilder.setParent(any())).thenReturn(mockSpanBuilder); + when(mockSpanBuilder.setAllAttributes(any(io.opentelemetry.api.common.Attributes.class))).thenReturn(mockSpanBuilder); when(mockSpanBuilder.startSpan()).thenReturn(mock(io.opentelemetry.api.trace.Span.class)); Span parentSpan = new OTelSpan("parent_span", mock(io.opentelemetry.api.trace.Span.class), null); TracingTelemetry tracingTelemetry = new OTelTracingTelemetry(mockOpenTelemetry); - Span span = tracingTelemetry.createSpan("span_name", parentSpan); + Attributes attributes = Attributes.create() + .addAttribute("key1", 1l) + .addAttribute("key2", 2.0) + .addAttribute("key3", true) + .addAttribute("key4", "key4"); + Span span = tracingTelemetry.createSpan("span_name", parentSpan, attributes); + io.opentelemetry.api.common.Attributes otelAttributes = io.opentelemetry.api.common.Attributes.builder() + .put("key1", 1l) + .put("key2", 2.0) + .put("key3", true) + .put("key4", "key4") + .build(); verify(mockSpanBuilder).setParent(any()); + verify(mockSpanBuilder).setAllAttributes(otelAttributes); assertNotNull(span.getParentSpan()); + assertEquals("parent_span", span.getParentSpan().getSpanName()); } + private io.opentelemetry.api.common.Attributes createAttribute(Attributes attributes) { + AttributesBuilder attributesBuilder = io.opentelemetry.api.common.Attributes.builder(); + attributes.getAttributesMap().forEach((x, y) -> attributesBuilder.put(x, (String) y)); + return attributesBuilder.build(); + } + + private io.opentelemetry.api.common.Attributes createAttributeLong(Attributes attributes) { + AttributesBuilder attributesBuilder = io.opentelemetry.api.common.Attributes.builder(); + attributes.getAttributesMap().forEach((x, y) -> attributesBuilder.put(x, (Long) y)); + return attributesBuilder.build(); + } + public void testGetContextPropagator() { OpenTelemetry mockOpenTelemetry = mock(OpenTelemetry.class); Tracer mockTracer = mock(Tracer.class); diff --git a/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java b/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java index f633d3ebebe86..466abaac435f3 100644 --- a/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java +++ b/server/src/main/java/org/opensearch/telemetry/tracing/WrappedTracer.java @@ -9,6 +9,7 @@ package org.opensearch.telemetry.tracing; import org.opensearch.telemetry.TelemetrySettings; +import org.opensearch.telemetry.tracing.attributes.Attributes; import org.opensearch.telemetry.tracing.noop.NoopTracer; import java.io.IOException; @@ -36,7 +37,12 @@ public WrappedTracer(TelemetrySettings telemetrySettings, Tracer defaultTracer) @Override public SpanScope startSpan(String spanName) { - return startSpan(spanName, null); + return startSpan(spanName, Attributes.EMPTY); + } + + @Override + public SpanScope startSpan(String spanName, Attributes attributes) { + return startSpan(spanName, null, attributes); } @Override @@ -46,9 +52,9 @@ public SpanContext getCurrentSpan() { } @Override - public SpanScope startSpan(String spanName, SpanContext parentSpan) { + public SpanScope startSpan(String spanName, SpanContext parentSpan, Attributes attributes) { Tracer delegateTracer = getDelegateTracer(); - return delegateTracer.startSpan(spanName, parentSpan); + return delegateTracer.startSpan(spanName, parentSpan, attributes); } @Override diff --git a/server/src/test/java/org/opensearch/telemetry/tracing/WrappedTracerTests.java b/server/src/test/java/org/opensearch/telemetry/tracing/WrappedTracerTests.java index 50c720e1c8555..f45381e3b4cc4 100644 --- a/server/src/test/java/org/opensearch/telemetry/tracing/WrappedTracerTests.java +++ b/server/src/test/java/org/opensearch/telemetry/tracing/WrappedTracerTests.java @@ -13,6 +13,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.util.FeatureFlags; import org.opensearch.telemetry.TelemetrySettings; +import org.opensearch.telemetry.tracing.attributes.Attributes; import org.opensearch.telemetry.tracing.noop.NoopTracer; import org.opensearch.test.OpenSearchTestCase; @@ -21,6 +22,8 @@ import java.util.List; import java.util.Set; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -48,7 +51,20 @@ public void testStartSpanWithTracingEnabledInvokesDefaultTracer() throws Excepti wrappedTracer.startSpan("foo"); assertTrue(wrappedTracer.getDelegateTracer() instanceof DefaultTracer); - verify(mockDefaultTracer).startSpan("foo", null); + verify(mockDefaultTracer).startSpan(eq("foo"), eq(null), any(Attributes.class)); + } + } + + public void testStartSpanWithTracingEnabledInvokesDefaultTracerWithAttr() throws Exception { + Settings settings = Settings.builder().put(TelemetrySettings.TRACER_ENABLED_SETTING.getKey(), true).build(); + TelemetrySettings telemetrySettings = new TelemetrySettings(settings, new ClusterSettings(settings, getClusterSettings())); + DefaultTracer mockDefaultTracer = mock(DefaultTracer.class); + Attributes attributes = Attributes.create().addAttribute("key", "value"); + try (WrappedTracer wrappedTracer = new WrappedTracer(telemetrySettings, mockDefaultTracer)) { + wrappedTracer.startSpan("foo", attributes); + + assertTrue(wrappedTracer.getDelegateTracer() instanceof DefaultTracer); + verify(mockDefaultTracer).startSpan("foo", null, attributes); } } diff --git a/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockSpan.java b/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockSpan.java index 876145f6bf653..a7744b8de50d5 100644 --- a/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockSpan.java +++ b/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockSpan.java @@ -15,6 +15,7 @@ import java.util.function.Supplier; import org.opensearch.telemetry.tracing.AbstractSpan; import org.opensearch.telemetry.tracing.Span; +import org.opensearch.telemetry.tracing.attributes.Attributes; /** * MockSpan for testing and strict check validations. Not to be used for production cases. @@ -37,6 +38,24 @@ public class MockSpan extends AbstractSpan { * @param spanName span name * @param parentSpan parent span * @param spanProcessor span processor + * @param attributes attributes + */ + public MockSpan(String spanName, Span parentSpan, SpanProcessor spanProcessor, Attributes attributes) { + this( + spanName, + parentSpan, + parentSpan != null ? parentSpan.getTraceId() : IdGenerator.generateTraceId(), + IdGenerator.generateSpanId(), + spanProcessor, + attributes + ); + } + + /** + * Constructor. + * @param spanName span name. + * @param parentSpan parent span name + * @param spanProcessor span processor. */ public MockSpan(String spanName, Span parentSpan, SpanProcessor spanProcessor) { this( @@ -44,7 +63,8 @@ public MockSpan(String spanName, Span parentSpan, SpanProcessor spanProcessor) { parentSpan, parentSpan != null ? parentSpan.getTraceId() : IdGenerator.generateTraceId(), IdGenerator.generateSpanId(), - spanProcessor + spanProcessor, + Attributes.EMPTY ); } @@ -55,14 +75,18 @@ public MockSpan(String spanName, Span parentSpan, SpanProcessor spanProcessor) { * @param traceId Trace ID * @param spanId Span ID * @param spanProcessor Span Processor + * @param attributes attributes */ - public MockSpan(String spanName, Span parentSpan, String traceId, String spanId, SpanProcessor spanProcessor) { + public MockSpan(String spanName, Span parentSpan, String traceId, String spanId, SpanProcessor spanProcessor, Attributes attributes) { super(spanName, parentSpan); this.spanProcessor = spanProcessor; this.metadata = new HashMap<>(); this.traceId = traceId; this.spanId = spanId; this.startTime = System.nanoTime(); + if (attributes != null) { + this.metadata.putAll(attributes.getAttributesMap()); + } } @Override @@ -160,4 +184,13 @@ private static String generateTraceId() { } } + + /** + * Returns attribute. + * @param key key + * @return value + */ + public Object getAttribute(String key) { + return metadata.get(key); + } } diff --git a/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockTracingContextPropagator.java b/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockTracingContextPropagator.java index 7e3f5a9031100..a83012548aff0 100644 --- a/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockTracingContextPropagator.java +++ b/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockTracingContextPropagator.java @@ -13,6 +13,7 @@ import java.util.function.BiConsumer; import org.opensearch.telemetry.tracing.Span; import org.opensearch.telemetry.tracing.TracingContextPropagator; +import org.opensearch.telemetry.tracing.attributes.Attributes; /** * Mock {@link TracingContextPropagator} to persist the span for internode communication. @@ -38,7 +39,7 @@ public Span extract(Map props) { String[] values = value.split(SEPARATOR); String traceId = values[0]; String spanId = values[1]; - return new MockSpan(null, null, traceId, spanId, spanProcessor); + return new MockSpan(null, null, traceId, spanId, spanProcessor, Attributes.EMPTY); } else { return null; } diff --git a/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockTracingTelemetry.java b/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockTracingTelemetry.java index 7013ed6653e63..9b958bbb40f84 100644 --- a/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockTracingTelemetry.java +++ b/test/telemetry/src/main/java/org/opensearch/test/telemetry/tracing/MockTracingTelemetry.java @@ -11,6 +11,7 @@ import org.opensearch.telemetry.tracing.Span; import org.opensearch.telemetry.tracing.TracingContextPropagator; import org.opensearch.telemetry.tracing.TracingTelemetry; +import org.opensearch.telemetry.tracing.attributes.Attributes; import org.opensearch.test.telemetry.tracing.validators.AllSpansAreEndedProperly; import org.opensearch.test.telemetry.tracing.validators.AllSpansHaveUniqueId; @@ -32,8 +33,8 @@ public MockTracingTelemetry() { } @Override - public Span createSpan(String spanName, Span parentSpan) { - Span span = new MockSpan(spanName, parentSpan, spanProcessor); + public Span createSpan(String spanName, Span parentSpan, Attributes attributes) { + Span span = new MockSpan(spanName, parentSpan, spanProcessor, attributes); spanProcessor.onStart(span); return span; }

* Note, its preferable to either set it using {@link #setSource(XContentBuilder)} - * or using the {@link #setSource(byte[], XContentType)}. + * or using the {@link #setSource(byte[], MediaType)}. */ - public IndexRequestBuilder setSource(String source, XContentType xContentType) { - request.source(source, xContentType); + public IndexRequestBuilder setSource(String source, MediaType mediaType) { + request.source(source, mediaType); return this; } @@ -129,8 +129,8 @@ public IndexRequestBuilder setSource(XContentBuilder sourceBuilder) { /** * Sets the document to index in bytes form. */ - public IndexRequestBuilder setSource(byte[] source, XContentType xContentType) { - request.source(source, xContentType); + public IndexRequestBuilder setSource(byte[] source, MediaType mediaType) { + request.source(source, mediaType); return this; } @@ -141,10 +141,10 @@ public IndexRequestBuilder setSource(byte[] source, XContentType xContentType) { * @param source The source to index * @param offset The offset in the byte array * @param length The length of the data - * @param xContentType The type/format of the source + * @param mediaType The type/format of the source */ - public IndexRequestBuilder setSource(byte[] source, int offset, int length, XContentType xContentType) { - request.source(source, offset, length, xContentType); + public IndexRequestBuilder setSource(byte[] source, int offset, int length, MediaType mediaType) { + request.source(source, offset, length, mediaType); return this; } @@ -169,8 +169,8 @@ public IndexRequestBuilder setSource(Object... source) { * valid String representation. *