From c30b12a4eacdbf81053e3730672cfd6aafb34c06 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Fri, 17 Nov 2023 11:53:16 -0500 Subject: [PATCH] [BWC and API enforcement] Reduce the visibility of some existing APIs (#11242) Signed-off-by: Andriy Redko --- .../org/opensearch/action/search/SearchPhaseContext.java | 6 +++--- .../opensearch/action/search/SearchRequestContext.java | 8 +++++--- .../action/search/SearchRequestOperationsListener.java | 8 ++++---- .../opensearch/index/mapper/ParametrizedFieldMapper.java | 4 ++-- .../opensearch/index/search/stats/SearchStatsTests.java | 3 +-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/server/src/main/java/org/opensearch/action/search/SearchPhaseContext.java b/server/src/main/java/org/opensearch/action/search/SearchPhaseContext.java index 0fa8569413eaf..df451e0745e3c 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchPhaseContext.java +++ b/server/src/main/java/org/opensearch/action/search/SearchPhaseContext.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.Logger; import org.opensearch.action.OriginalIndices; import org.opensearch.common.Nullable; -import org.opensearch.common.annotation.PublicApi; +import org.opensearch.common.annotation.InternalApi; import org.opensearch.common.lease.Releasable; import org.opensearch.common.util.concurrent.AtomicArray; import org.opensearch.search.SearchPhaseResult; @@ -49,9 +49,9 @@ /** * This class provide contextual state and access to resources across multiple search phases. * - * @opensearch.api + * @opensearch.internal */ -@PublicApi(since = "1.0.0") +@InternalApi public interface SearchPhaseContext extends Executor { // TODO maybe we can make this concrete later - for now we just implement this in the base class for all initial phases diff --git a/server/src/main/java/org/opensearch/action/search/SearchRequestContext.java b/server/src/main/java/org/opensearch/action/search/SearchRequestContext.java index 96e9d9efa5079..674363600b251 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchRequestContext.java +++ b/server/src/main/java/org/opensearch/action/search/SearchRequestContext.java @@ -10,6 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.lucene.search.TotalHits; +import org.opensearch.common.annotation.InternalApi; import java.util.EnumMap; import java.util.HashMap; @@ -22,7 +23,8 @@ * * @opensearch.internal */ -public class SearchRequestContext { +@InternalApi +class SearchRequestContext { private final SearchRequestOperationsListener searchRequestOperationsListener; private long absoluteStartNanos; private final Map phaseTookMap; @@ -32,11 +34,11 @@ public class SearchRequestContext { /** * This constructor is for testing only */ - public SearchRequestContext() { + SearchRequestContext() { this(new SearchRequestOperationsListener.CompositeListener(List.of(), LogManager.getLogger())); } - public SearchRequestContext(SearchRequestOperationsListener searchRequestOperationsListener) { + SearchRequestContext(SearchRequestOperationsListener searchRequestOperationsListener) { this.searchRequestOperationsListener = searchRequestOperationsListener; this.absoluteStartNanos = System.nanoTime(); this.phaseTookMap = new HashMap<>(); diff --git a/server/src/main/java/org/opensearch/action/search/SearchRequestOperationsListener.java b/server/src/main/java/org/opensearch/action/search/SearchRequestOperationsListener.java index 91e3eecbf8d13..056cb474eaf32 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchRequestOperationsListener.java +++ b/server/src/main/java/org/opensearch/action/search/SearchRequestOperationsListener.java @@ -10,17 +10,17 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.common.annotation.PublicApi; +import org.opensearch.common.annotation.InternalApi; import java.util.List; /** * A listener for search, fetch and context events at the coordinator node level * - * @opensearch.api + * @opensearch.internal */ -@PublicApi(since = "1.0.0") -public interface SearchRequestOperationsListener { +@InternalApi +interface SearchRequestOperationsListener { void onPhaseStart(SearchPhaseContext context); diff --git a/server/src/main/java/org/opensearch/index/mapper/ParametrizedFieldMapper.java b/server/src/main/java/org/opensearch/index/mapper/ParametrizedFieldMapper.java index a8e04aac45963..ee0b50024ab38 100644 --- a/server/src/main/java/org/opensearch/index/mapper/ParametrizedFieldMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/ParametrizedFieldMapper.java @@ -282,7 +282,7 @@ public Parameter setValidator(Consumer validator) { /** * Configure a custom serializer for this parameter */ - protected Parameter setSerializer(Serializer serializer, Function conflictSerializer) { + public Parameter setSerializer(Serializer serializer, Function conflictSerializer) { this.serializer = serializer; this.conflictSerializer = conflictSerializer; return this; @@ -291,7 +291,7 @@ protected Parameter setSerializer(Serializer serializer, Function setSerializerCheck(SerializerCheck check) { + public Parameter setSerializerCheck(SerializerCheck check) { this.serializerCheck = check; return this; } diff --git a/server/src/test/java/org/opensearch/index/search/stats/SearchStatsTests.java b/server/src/test/java/org/opensearch/index/search/stats/SearchStatsTests.java index 2ebb033899698..98c7b8e4b2bde 100644 --- a/server/src/test/java/org/opensearch/index/search/stats/SearchStatsTests.java +++ b/server/src/test/java/org/opensearch/index/search/stats/SearchStatsTests.java @@ -35,7 +35,6 @@ import org.opensearch.action.search.SearchPhase; import org.opensearch.action.search.SearchPhaseContext; import org.opensearch.action.search.SearchPhaseName; -import org.opensearch.action.search.SearchRequestContext; import org.opensearch.action.search.SearchRequestStats; import org.opensearch.index.search.stats.SearchStats.Stats; import org.opensearch.test.OpenSearchTestCase; @@ -86,7 +85,7 @@ public void testShardLevelSearchGroupStats() throws Exception { when(mockSearchPhase.getSearchPhaseName()).thenReturn(searchPhaseName); for (int iterator = 0; iterator < paramValue; iterator++) { testRequestStats.onPhaseStart(ctx); - testRequestStats.onPhaseEnd(ctx, new SearchRequestContext()); + testRequestStats.onPhaseEnd(ctx, null /* not needed */); } } searchStats1.setSearchRequestStats(testRequestStats);