Skip to content

Commit

Permalink
fix compilation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Gagan Juneja committed Jun 27, 2023
1 parent 4be4bb3 commit 02fae31
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 29 deletions.
5 changes: 5 additions & 0 deletions server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -1760,4 +1760,9 @@ private void initializeFileCache(Settings settings, CircuitBreaker circuitBreake
public FileCache fileCache() {
return this.fileCache;
}

//Visible for testing
TracerFactory getTracerFactory(){
return this.tracerFactory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void testWrapperIsBound() throws IOException {
() -> true,
new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)),
Collections.emptyMap(),
tracerFactory);
getNoopTracerFactory());
module.setReaderWrapper(s -> new Wrapper());

IndexService indexService = newIndexService(module);
Expand All @@ -294,7 +294,7 @@ public void testRegisterIndexStore() throws IOException {
() -> true,
new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)),
Collections.emptyMap(),
tracerFactory);
getNoopTracerFactory());

final IndexService indexService = newIndexService(module);
assertThat(indexService.getDirectoryFactory(), instanceOf(FooFunction.class));
Expand Down Expand Up @@ -622,7 +622,7 @@ public void testRegisterCustomRecoveryStateFactory() throws IOException {
() -> true,
new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)),
recoveryStateFactories,
tracerFactory);
null);

final IndexService indexService = newIndexService(module);

Expand Down Expand Up @@ -654,7 +654,7 @@ private static IndexModule createIndexModule(IndexSettings indexSettings, Analys
() -> true,
new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)),
Collections.emptyMap(),
tracerFactory);
null);
}

class CustomQueryCache implements QueryCache {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected Engine.Searcher acquireSearcherInternal(String source) {
false,
executor,
null,
this.tracerFactory);
getNoopTracerFactory());
contextWithoutScroll.from(300);
contextWithoutScroll.close();

Expand Down Expand Up @@ -258,7 +258,7 @@ protected Engine.Searcher acquireSearcherInternal(String source) {
false,
executor,
null,
this.tracerFactory);
getNoopTracerFactory());
context1.from(300);
exception = expectThrows(IllegalArgumentException.class, () -> context1.preProcess(false));
assertThat(
Expand Down Expand Up @@ -329,7 +329,7 @@ protected Engine.Searcher acquireSearcherInternal(String source) {
false,
executor,
null,
this.tracerFactory);
getNoopTracerFactory());

SliceBuilder sliceBuilder = mock(SliceBuilder.class);
int numSlices = maxSlicesPerScroll + randomIntBetween(1, 100);
Expand Down Expand Up @@ -369,7 +369,7 @@ protected Engine.Searcher acquireSearcherInternal(String source) {
false,
executor,
null,
this.tracerFactory);
getNoopTracerFactory());
ParsedQuery parsedQuery = ParsedQuery.parsedMatchAllQuery();
context3.sliceBuilder(null).parsedQuery(parsedQuery).preProcess(false);
assertEquals(context3.query(), context3.buildFilteredQuery(parsedQuery.query()));
Expand Down Expand Up @@ -405,7 +405,7 @@ protected Engine.Searcher acquireSearcherInternal(String source) {
false,
executor,
null,
this.tracerFactory);
getNoopTracerFactory());
context4.sliceBuilder(new SliceBuilder(1, 2)).parsedQuery(parsedQuery).preProcess(false);
Query query1 = context4.query();
context4.sliceBuilder(new SliceBuilder(0, 2)).parsedQuery(parsedQuery).preProcess(false);
Expand Down Expand Up @@ -436,7 +436,7 @@ protected Engine.Searcher acquireSearcherInternal(String source) {
false,
executor,
null,
this.tracerFactory);
getNoopTracerFactory());
int numSlicesForPit = maxSlicesPerPit + randomIntBetween(1, 100);
when(sliceBuilder.getMax()).thenReturn(numSlicesForPit);
context5.sliceBuilder(sliceBuilder);
Expand Down Expand Up @@ -534,7 +534,7 @@ protected Engine.Searcher acquireSearcherInternal(String source) {
false,
executor,
null,
this.tracerFactory);
getNoopTracerFactory());
assertThat(context.searcher().hasCancellations(), is(false));
context.searcher().addQueryCancellation(() -> {});
assertThat(context.searcher().hasCancellations(), is(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ public void testAddingCancellationActions() throws IOException {
IndexSearcher.getDefaultQueryCache(),
IndexSearcher.getDefaultQueryCachingPolicy(),
true,
null
null,
getNoopTracerFactory()
);
NullPointerException npe = expectThrows(NullPointerException.class, () -> searcher.addQueryCancellation(null));
assertEquals("cancellation runnable should not be null", npe.getMessage());
Expand All @@ -129,7 +130,8 @@ public void testCancellableCollector() throws IOException {
IndexSearcher.getDefaultQueryCache(),
IndexSearcher.getDefaultQueryCachingPolicy(),
true,
null
null,
getNoopTracerFactory()
);

searcher.search(new MatchAllDocsQuery(), collector1);
Expand Down Expand Up @@ -157,7 +159,8 @@ public void testExitableDirectoryReader() throws IOException {
IndexSearcher.getDefaultQueryCache(),
IndexSearcher.getDefaultQueryCachingPolicy(),
true,
null
null,
getNoopTracerFactory()
);
searcher.addQueryCancellation(cancellation);
CompiledAutomaton automaton = new CompiledAutomaton(new RegExp("a.*").toAutomaton());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ public void onRemoval(ShardId shardId, Accountable accountable) {
IndexSearcher.getDefaultQueryCache(),
IndexSearcher.getDefaultQueryCachingPolicy(),
true,
null
null,
getNoopTracerFactory()
);

for (LeafReaderContext context : searcher.getIndexReader().leaves()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public void setUp() throws Exception {
IndexSearcher.getDefaultQueryCache(),
ALWAYS_CACHE_POLICY,
true,
executor
executor,
getNoopTracerFactory()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,8 @@ private static ContextIndexSearcher newContextSearcher(IndexReader reader, Execu
IndexSearcher.getDefaultQueryCache(),
IndexSearcher.getDefaultQueryCachingPolicy(),
true,
executor
executor,
getNoopTracerFactory()
);
}

Expand All @@ -1222,7 +1223,8 @@ private static ContextIndexSearcher newEarlyTerminationContextSearcher(IndexRead
IndexSearcher.getDefaultQueryCache(),
IndexSearcher.getDefaultQueryCachingPolicy(),
true,
executor
executor,
getNoopTracerFactory()
) {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,8 @@ private static ContextIndexSearcher newContextSearcher(IndexReader reader, Execu
IndexSearcher.getDefaultQueryCache(),
IndexSearcher.getDefaultQueryCachingPolicy(),
true,
executor
executor,
getNoopTracerFactory()
);
}

Expand All @@ -1442,7 +1443,8 @@ private static ContextIndexSearcher newEarlyTerminationContextSearcher(IndexRead
IndexSearcher.getDefaultQueryCache(),
IndexSearcher.getDefaultQueryCachingPolicy(),
true,
executor
executor,
getNoopTracerFactory()
) {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ public void onFailure(final Exception e) {
new RemoteSegmentStoreDirectoryFactory(() -> repositoriesService),
repositoriesServiceReference::get,
fileCacheCleaner,
this.tracerFactory, tracerFactory1);
getNoopTracerFactory());
final RecoverySettings recoverySettings = new RecoverySettings(settings, clusterSettings);
snapshotShardsService = new SnapshotShardsService(
settings,
Expand Down Expand Up @@ -2035,7 +2035,7 @@ public void onFailure(final Exception e) {
responseCollectorService,
new NoneCircuitBreakerService(),
null,
tracerFactory);
getNoopTracerFactory());
SearchPhaseController searchPhaseController = new SearchPhaseController(
writableRegistry(),
searchService::aggReduceContextBuilder
Expand Down Expand Up @@ -2065,9 +2065,9 @@ public void onFailure(final Exception e) {
List.of(),
client,
false
)
)
);
),
getNoopTracerFactory()
);
actions.put(
RestoreSnapshotAction.INSTANCE,
new TransportRestoreSnapshotAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.opensearch.search.SearchService;
import org.opensearch.search.fetch.FetchPhase;
import org.opensearch.search.query.QueryPhase;
import org.opensearch.telemetry.tracing.TracerFactory;
import org.opensearch.test.MockHttpTransport;
import org.opensearch.test.transport.MockTransportService;
import org.opensearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -179,7 +180,8 @@ protected SearchService newSearchService(
queryPhase,
fetchPhase,
circuitBreakerService,
indexSearcherExecutor
indexSearcherExecutor,
getTracerFactory()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.opensearch.search.fetch.FetchPhase;
import org.opensearch.search.internal.ReaderContext;
import org.opensearch.search.query.QueryPhase;
import org.opensearch.telemetry.tracing.TracerFactory;
import org.opensearch.threadpool.ThreadPool;

import java.util.HashMap;
Expand Down Expand Up @@ -96,7 +97,8 @@ public MockSearchService(
QueryPhase queryPhase,
FetchPhase fetchPhase,
CircuitBreakerService circuitBreakerService,
Executor indexSearcherExecutor
Executor indexSearcherExecutor,
TracerFactory tracerFactory
) {
super(
clusterService,
Expand All @@ -109,7 +111,7 @@ public MockSearchService(
null,
circuitBreakerService,
indexSearcherExecutor,
tracerFactory);
tracerFactory);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ public boolean shouldCache(Query query) {
queryCache,
queryCachingPolicy,
false,
null
null,
getNoopTracerFactory()
);

SearchContext searchContext = mock(SearchContext.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
import com.carrotsearch.randomizedtesting.rules.TestRuleAdapter;
import java.util.Optional;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -85,6 +86,7 @@
import org.opensearch.common.logging.HeaderWarningAppender;
import org.opensearch.common.logging.LogConfigurator;
import org.opensearch.common.logging.Loggers;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.time.DateUtils;
Expand Down Expand Up @@ -125,6 +127,9 @@
import org.opensearch.script.Script;
import org.opensearch.script.ScriptType;
import org.opensearch.search.MockSearchService;
import org.opensearch.telemetry.TelemetrySettings;
import org.opensearch.telemetry.tracing.NoopTracerFactory;
import org.opensearch.telemetry.tracing.TracerFactory;
import org.opensearch.test.junit.listeners.LoggingListener;
import org.opensearch.test.junit.listeners.ReproduceInfoPrinter;
import org.opensearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -215,6 +220,8 @@ public abstract class OpenSearchTestCase extends LuceneTestCase {
private static final Collection<String> nettyLoggedLeaks = new ArrayList<>();
private HeaderWarningAppender headerWarningAppender;

private static TracerFactory noopTracerFactory = new NoopTracerFactory();

@AfterClass
public static void resetPortCounter() {
portGenerator.set(0);
Expand Down Expand Up @@ -504,6 +511,9 @@ protected final void assertSettingDeprecationsAndWarnings(final String[] setting
);
}

public static TracerFactory getNoopTracerFactory(){
return noopTracerFactory;
}
/**
* Convenience method to assert same warnings for settings deprecations and general deprecation warnings
* are not logged again.
Expand Down

0 comments on commit 02fae31

Please sign in to comment.