From c21f41a46151b529d29e04addf3691f694715c73 Mon Sep 17 00:00:00 2001 From: Andrew Prudhomme Date: Fri, 4 Oct 2024 15:53:25 -0700 Subject: [PATCH] Rename some LuceneServer class in the server core --- build.gradle | 4 +- .../server/analysis/AnalysisComponent.java | 8 +-- .../server/analysis/AnalyzerCreator.java | 8 +-- ...onfiguration.java => NrtsearchConfig.java} | 6 +- .../request/CustomRequestProcessor.java | 6 +- .../server/field/FieldDefCreator.java | 6 +- ...ServerClient.java => NrtsearchClient.java} | 19 +++-- ...ilder.java => NrtsearchClientBuilder.java} | 16 ++--- ...LuceneServer.java => NrtsearchServer.java} | 37 +++++----- .../nrtsearch/server/handler/Handler.java | 5 +- .../server/highlights/HighlighterService.java | 6 +- .../nrtsearch/server/index/IndexState.java | 4 +- .../nrtsearch/server/index/ShardState.java | 4 +- .../server/logging/HitsLoggerCreator.java | 6 +- .../server/modules/BackendModule.java | 5 +- ...ServerModule.java => NrtsearchModule.java} | 21 +++--- .../nrtsearch/server/modules/S3Module.java | 4 +- ...NrtsearchMonitoringServerInterceptor.java} | 8 +-- .../server/plugins/HighlighterPlugin.java | 7 +- .../server/plugins/HitsLoggerPlugin.java | 7 +- .../server/plugins/PluginsService.java | 22 +++--- .../nrtsearch/server/remote/s3/S3Backend.java | 4 +- .../nrtsearch/server/remote/s3/S3Util.java | 4 +- .../server/rescore/RescorerCreator.java | 6 +- .../server/script/ScriptService.java | 6 +- .../server/search/FetchTaskCreator.java | 6 +- .../search/collectors/CollectorCreator.java | 6 +- .../server/similarity/SimilarityCreator.java | 6 +- .../server/state/BackendGlobalState.java | 5 +- .../nrtsearch/server/state/GlobalState.java | 12 ++-- .../state/backend/RemoteStateBackend.java | 5 +- .../tools/cli/AddDocumentsCommand.java | 14 ++-- .../cli/BackupWarmingQueriesCommand.java | 6 +- .../nrtsearch/tools/cli/CommitCommand.java | 6 +- .../tools/cli/CreateIndexCommand.java | 6 +- .../tools/cli/DeleteAllDocumentsCommand.java | 6 +- .../tools/cli/DeleteDocumentsCommand.java | 6 +- .../tools/cli/DeleteIndexCommand.java | 6 +- .../tools/cli/ForceMergeCommand.java | 6 +- .../tools/cli/ForceMergeDeletesCommand.java | 6 +- .../tools/cli/GetCurrentSearcherVersion.java | 8 +-- .../nrtsearch/tools/cli/IndicesCommand.java | 6 +- .../tools/cli/LiveSettingsV2Command.java | 6 +- ...mmand.java => NrtsearchClientCommand.java} | 13 ++-- .../nrtsearch/tools/cli/ReadyCommand.java | 6 +- .../nrtsearch/tools/cli/RefreshCommand.java | 6 +- .../tools/cli/RegisterFieldsCommand.java | 6 +- .../tools/cli/ReloadStateCommand.java | 6 +- .../nrtsearch/tools/cli/SearchCommand.java | 6 +- .../tools/cli/SettingsV2Command.java | 6 +- .../tools/cli/StartIndexCommand.java | 6 +- .../tools/cli/StartIndexV2Command.java | 6 +- .../nrtsearch/tools/cli/StatsCommand.java | 6 +- .../nrtsearch/tools/cli/StatusCommand.java | 6 +- .../nrtsearch/tools/cli/StopIndexCommand.java | 6 +- .../tools/cli/WriteNRTPointCommand.java | 8 +-- ...NodeNameResolverAndLoadBalancingTests.java | 4 +- ...erModule.java => TestNrtsearchModule.java} | 21 +++--- .../yelp/nrtsearch/server/ServerTestCase.java | 12 ++-- .../server/analysis/AnalyzerCreatorTest.java | 14 ++-- .../SynonymV2GraphFilterFactoryITest.java | 6 +- .../SynonymV2GraphFilterFactoryTest.java | 6 +- .../server/codec/ServerCodecTest.java | 5 +- .../ThreadPoolExecutorFactoryTest.java | 6 +- ...tionTest.java => NrtsearchConfigTest.java} | 54 +++++++------- .../config/ThreadPoolConfigurationTest.java | 3 +- .../server/custom/request/CustomRpcTest.java | 4 +- .../server/doc/SharedDocContextTest.java | 4 +- .../server/facet/FacetScriptFacetsTest.java | 4 +- .../server/facet/RuntimeScriptFacetsTest.java | 4 +- .../server/field/AtomFieldDefTest.java | 6 +- .../server/field/FieldDefCreatorTest.java | 6 +- .../server/field/TestFieldDefTest.java | 6 +- .../server/field/TextFieldDefTest.java | 6 +- .../nrtsearch/server/grpc/AckedCopyTest.java | 10 +-- .../nrtsearch/server/grpc/CopyFileTest.java | 6 +- .../server/grpc/CustomFieldTypeTest.java | 4 +- .../nrtsearch/server/grpc/GrpcServer.java | 26 +++---- .../server/grpc/MergeBehaviorTests.java | 6 +- .../grpc/MultiIndexAddDocumentsTest.java | 2 +- ...t.java => NrtsearchClientBuilderTest.java} | 6 +- ...t.java => NrtsearchServerIdFieldTest.java} | 6 +- ...rverTest.java => NrtsearchServerTest.java} | 21 +++--- .../yelp/nrtsearch/server/grpc/QueryTest.java | 72 +++++++++---------- .../grpc/ReplicationServerClientTest.java | 6 +- .../server/grpc/ReplicationServerTest.java | 32 ++++----- .../server/grpc/StateBackendServerTest.java | 52 +++++++------- .../nrtsearch/server/grpc/TestServer.java | 18 ++--- .../server/index/BackendStateManagerTest.java | 6 +- .../server/index/FieldUpdateUtilsTest.java | 6 +- .../server/index/ImmutableIndexStateTest.java | 21 +++--- .../server/logging/HitsLoggerCreatorTest.java | 6 +- .../server/logging/HitsLoggerTest.java | 4 +- .../server/plugins/PluginsServiceTest.java | 28 ++++---- .../server/query/QueryNodeMapperTest.java | 6 +- .../server/remote/s3/S3BackendTest.java | 5 +- .../server/rescore/RescorerCreatorTest.java | 6 +- .../server/rescore/RescorerTest.java | 4 +- .../server/script/ScoreScriptTest.java | 4 +- .../server/script/ScriptServiceTest.java | 6 +- .../server/search/FetchTaskCreatorTest.java | 6 +- .../server/search/FetchTasksTest.java | 4 +- .../collectors/CollectorCreatorTest.java | 6 +- .../search/collectors/CollectorTest.java | 4 +- .../additional/CollectorStatsWrapperTest.java | 4 +- .../ScriptTermsCollectorManagerTest.java | 4 +- .../similarity/SimilarityCreatorTest.java | 6 +- .../server/similarity/SimilarityTest.java | 4 +- .../server/state/BackendGlobalStateTest.java | 23 +++--- .../server/state/GlobalStateTest.java | 10 +-- .../state/backend/LocalStateBackendTest.java | 8 +-- .../state/backend/RemoteStateBackendTest.java | 8 +-- .../LuceneServerTestConfigurationFactory.java | 13 ++-- .../nrtsearch/server/warming/WarmerTest.java | 5 +- .../nrtsearch/test_utils/NrtsearchTest.java | 31 ++++---- .../test_utils/TestLuceneServer.java | 30 ++++---- .../tools/cli/CreateIndexCommandTest.java | 12 ++-- .../tools/cli/IndicesCommandTest.java | 2 +- .../tools/cli/LiveSettingsV2CommandTest.java | 8 +-- .../nrtsearch/tools/cli/ReadyCommandTest.java | 14 ++-- .../tools/cli/StartIndexV2CommandTest.java | 2 +- .../yelp_reviews/YelpReviewsTest.java | 33 +++++---- .../utils/DocumentGeneratorAndIndexer.java | 6 +- .../yelp_reviews/utils/IndexerTask.java | 4 +- .../utils/ParallelDocumentIndexer.java | 6 +- 125 files changed, 605 insertions(+), 626 deletions(-) rename src/main/java/com/yelp/nrtsearch/server/config/{LuceneServerConfiguration.java => NrtsearchConfig.java} (98%) rename src/main/java/com/yelp/nrtsearch/server/grpc/{LuceneServerClient.java => NrtsearchClient.java} (95%) rename src/main/java/com/yelp/nrtsearch/server/grpc/{LuceneServerClientBuilder.java => NrtsearchClientBuilder.java} (94%) rename src/main/java/com/yelp/nrtsearch/server/grpc/{LuceneServer.java => NrtsearchServer.java} (96%) rename src/main/java/com/yelp/nrtsearch/server/modules/{LuceneServerModule.java => NrtsearchModule.java} (69%) rename src/main/java/com/yelp/nrtsearch/server/monitoring/{LuceneServerMonitoringServerInterceptor.java => NrtsearchMonitoringServerInterceptor.java} (88%) rename src/main/java/com/yelp/nrtsearch/tools/cli/{LuceneClientCommand.java => NrtsearchClientCommand.java} (87%) rename src/test/java/com/yelp/nrtsearch/module/{TestLuceneServerModule.java => TestNrtsearchModule.java} (65%) rename src/test/java/com/yelp/nrtsearch/server/config/{LuceneServerConfigurationTest.java => NrtsearchConfigTest.java} (76%) rename src/test/java/com/yelp/nrtsearch/server/grpc/{LuceneServerClientBuilderTest.java => NrtsearchClientBuilderTest.java} (91%) rename src/test/java/com/yelp/nrtsearch/server/grpc/{LuceneServerIdFieldTest.java => NrtsearchServerIdFieldTest.java} (98%) rename src/test/java/com/yelp/nrtsearch/server/grpc/{LuceneServerTest.java => NrtsearchServerTest.java} (98%) diff --git a/build.gradle b/build.gradle index 7d3b00488..26ee8138d 100644 --- a/build.gradle +++ b/build.gradle @@ -125,7 +125,7 @@ dependencies { startScripts.enabled = false task luceneServer(type: CreateStartScripts) { - mainClass = 'com.yelp.nrtsearch.server.grpc.LuceneServer' + mainClass = 'com.yelp.nrtsearch.server.grpc.NrtsearchServer' applicationName = 'lucene-server' outputDir = new File(project.buildDir, 'tmp-app') classpath = startScripts.classpath @@ -134,7 +134,7 @@ task luceneServer(type: CreateStartScripts) { } task luceneServerClient(type: CreateStartScripts) { - mainClass = 'com.yelp.nrtsearch.tools.cli.LuceneClientCommand' + mainClass = 'com.yelp.nrtsearch.tools.cli.NrtsearchClientCommand' applicationName = 'lucene-client' outputDir = new File(project.buildDir, 'tmp-app') classpath = startScripts.classpath diff --git a/src/main/java/com/yelp/nrtsearch/server/analysis/AnalysisComponent.java b/src/main/java/com/yelp/nrtsearch/server/analysis/AnalysisComponent.java index eea1b5187..942ad432b 100644 --- a/src/main/java/com/yelp/nrtsearch/server/analysis/AnalysisComponent.java +++ b/src/main/java/com/yelp/nrtsearch/server/analysis/AnalysisComponent.java @@ -15,13 +15,13 @@ */ package com.yelp.nrtsearch.server.analysis; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; /** * Interface to provide additional nrtsearch related information to components of {@link * org.apache.lucene.analysis.custom.CustomAnalyzer}s. The {@link - * #initializeComponent(LuceneServerConfiguration)} method is called after the custom analyzer is - * built, but before it is returned to the caller. + * #initializeComponent(NrtsearchConfig)} method is called after the custom analyzer is built, but + * before it is returned to the caller. * *

This is intended mainly to be used by custom implementations registered by plugins (currently * only token filters supported). This is needed because the custom analyzer building does not give @@ -35,5 +35,5 @@ public interface AnalysisComponent { * * @param configuration nrtsearch config accessor */ - void initializeComponent(LuceneServerConfiguration configuration); + void initializeComponent(NrtsearchConfig configuration); } diff --git a/src/main/java/com/yelp/nrtsearch/server/analysis/AnalyzerCreator.java b/src/main/java/com/yelp/nrtsearch/server/analysis/AnalyzerCreator.java index 279201275..9e6c969c0 100644 --- a/src/main/java/com/yelp/nrtsearch/server/analysis/AnalyzerCreator.java +++ b/src/main/java/com/yelp/nrtsearch/server/analysis/AnalyzerCreator.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.analysis; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.ConditionalTokenFilter; import com.yelp.nrtsearch.server.grpc.Field; import com.yelp.nrtsearch.server.grpc.NameAndParams; @@ -45,12 +45,12 @@ public class AnalyzerCreator { private static AnalyzerCreator instance; - private final LuceneServerConfiguration configuration; + private final NrtsearchConfig configuration; private final Map> analyzerMap = new HashMap<>(); private final Map> tokenFilterMap = new HashMap<>(); private final Map> charFilterMap = new HashMap<>(); - public AnalyzerCreator(LuceneServerConfiguration configuration) { + public AnalyzerCreator(NrtsearchConfig configuration) { this.configuration = configuration; registerAnalyzer(STANDARD, name -> new StandardAnalyzer()); registerAnalyzer(CLASSIC, name -> new ClassicAnalyzer()); @@ -131,7 +131,7 @@ private void registerCharFilter( charFilterMap.put(name, filterClass); } - public static void initialize(LuceneServerConfiguration configuration, Iterable plugins) { + public static void initialize(NrtsearchConfig configuration, Iterable plugins) { instance = new AnalyzerCreator(configuration); Set builtInTokenFilters = TokenFilterFactory.availableTokenFilters().stream() diff --git a/src/main/java/com/yelp/nrtsearch/server/config/LuceneServerConfiguration.java b/src/main/java/com/yelp/nrtsearch/server/config/NrtsearchConfig.java similarity index 98% rename from src/main/java/com/yelp/nrtsearch/server/config/LuceneServerConfiguration.java rename to src/main/java/com/yelp/nrtsearch/server/config/NrtsearchConfig.java index c008c3fa6..9ca195896 100644 --- a/src/main/java/com/yelp/nrtsearch/server/config/LuceneServerConfiguration.java +++ b/src/main/java/com/yelp/nrtsearch/server/config/NrtsearchConfig.java @@ -37,7 +37,7 @@ import java.util.regex.Pattern; import org.apache.lucene.search.suggest.document.CompletionPostingsFormat.FSTLoadMode; -public class LuceneServerConfiguration { +public class NrtsearchConfig { private static final Pattern ENV_VAR_PATTERN = Pattern.compile("\\$\\{([A-Za-z0-9_]+)}"); private static final long AS_LARGE_AS_INFINITE = TimeUnit.DAYS.toSeconds(1000L); @@ -110,7 +110,7 @@ public class LuceneServerConfiguration { private final boolean useKeepAliveForReplication; @Inject - public LuceneServerConfiguration(InputStream yamlStream) { + public NrtsearchConfig(InputStream yamlStream) { configReader = new YamlConfigReader(yamlStream); port = configReader.getInteger("port", DEFAULT_PORT); @@ -148,7 +148,7 @@ public LuceneServerConfiguration(InputStream yamlStream) { pluginSearchPath = configReader.get( "pluginSearchPath", - LuceneServerConfiguration::getPluginSearchPath, + NrtsearchConfig::getPluginSearchPath, List.of(DEFAULT_PLUGIN_SEARCH_PATH.toString())); serviceName = configReader.getString("serviceName", DEFAULT_SERVICE_NAME); preloadConfig = IndexPreloadConfig.fromConfig(configReader); diff --git a/src/main/java/com/yelp/nrtsearch/server/custom/request/CustomRequestProcessor.java b/src/main/java/com/yelp/nrtsearch/server/custom/request/CustomRequestProcessor.java index 3a3c4b642..536bc8fed 100644 --- a/src/main/java/com/yelp/nrtsearch/server/custom/request/CustomRequestProcessor.java +++ b/src/main/java/com/yelp/nrtsearch/server/custom/request/CustomRequestProcessor.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.custom.request; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.CustomRequest; import com.yelp.nrtsearch.server.grpc.CustomResponse; import com.yelp.nrtsearch.server.plugins.CustomRequestPlugin; @@ -29,9 +29,9 @@ public class CustomRequestProcessor { private final Map> routeMapping = new HashMap<>(); - public CustomRequestProcessor(LuceneServerConfiguration configuration) {} + public CustomRequestProcessor(NrtsearchConfig configuration) {} - public static void initialize(LuceneServerConfiguration configuration, Iterable plugins) { + public static void initialize(NrtsearchConfig configuration, Iterable plugins) { instance = new CustomRequestProcessor(configuration); for (Plugin plugin : plugins) { if (plugin instanceof CustomRequestPlugin) { diff --git a/src/main/java/com/yelp/nrtsearch/server/field/FieldDefCreator.java b/src/main/java/com/yelp/nrtsearch/server/field/FieldDefCreator.java index d842c8e90..a53bbd160 100644 --- a/src/main/java/com/yelp/nrtsearch/server/field/FieldDefCreator.java +++ b/src/main/java/com/yelp/nrtsearch/server/field/FieldDefCreator.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.field; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Field; import com.yelp.nrtsearch.server.grpc.FieldType; import com.yelp.nrtsearch.server.plugins.FieldTypePlugin; @@ -34,7 +34,7 @@ public class FieldDefCreator { private final Map> fieldDefMap = new HashMap<>(); - public FieldDefCreator(LuceneServerConfiguration configuration) { + public FieldDefCreator(NrtsearchConfig configuration) { register("ATOM", AtomFieldDef::new); register("TEXT", TextFieldDef::new); register("BOOLEAN", BooleanFieldDef::new); @@ -119,7 +119,7 @@ private String getCustomFieldType(Map additionalProperties) { * @param configuration service configuration * @param plugins list of loaded plugins */ - public static void initialize(LuceneServerConfiguration configuration, Iterable plugins) { + public static void initialize(NrtsearchConfig configuration, Iterable plugins) { instance = new FieldDefCreator(configuration); for (Plugin plugin : plugins) { if (plugin instanceof FieldTypePlugin) { diff --git a/src/main/java/com/yelp/nrtsearch/server/grpc/LuceneServerClient.java b/src/main/java/com/yelp/nrtsearch/server/grpc/NrtsearchClient.java similarity index 95% rename from src/main/java/com/yelp/nrtsearch/server/grpc/LuceneServerClient.java rename to src/main/java/com/yelp/nrtsearch/server/grpc/NrtsearchClient.java index 1dfd9ca54..8f6e7ba5a 100644 --- a/src/main/java/com/yelp/nrtsearch/server/grpc/LuceneServerClient.java +++ b/src/main/java/com/yelp/nrtsearch/server/grpc/NrtsearchClient.java @@ -35,9 +35,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** A simple client that requests a greeting from the {@link LuceneServer}. */ -public class LuceneServerClient implements Closeable { - private static final Logger logger = LoggerFactory.getLogger(LuceneServerClient.class.getName()); +/** A simple client that requests a greeting from the {@link NrtsearchServer}. */ +public class NrtsearchClient implements Closeable { + private static final Logger logger = LoggerFactory.getLogger(NrtsearchClient.class.getName()); private final ManagedChannel channel; @@ -53,7 +53,7 @@ public LuceneServerGrpc.LuceneServerStub getAsyncStub() { private final LuceneServerGrpc.LuceneServerStub asyncStub; /** Construct client connecting to LuceneServer server at {@code host:port}. */ - public LuceneServerClient(String host, int port) { + public NrtsearchClient(String host, int port) { this( ManagedChannelBuilder.forAddress(host, port) // Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid @@ -64,7 +64,7 @@ public LuceneServerClient(String host, int port) { } /** Construct client for accessing LuceneServer server using the existing channel. */ - LuceneServerClient(ManagedChannel channel) { + NrtsearchClient(ManagedChannel channel) { this.channel = channel; blockingStub = LuceneServerGrpc.newBlockingStub(channel) @@ -159,8 +159,7 @@ public void reloadState() { public void settingsV2(String indexName, Path filePath) throws IOException { SettingsV2Request settingsRequest; if (filePath != null) { - settingsRequest = - new LuceneServerClientBuilder.SettingsV2ClientBuilder().buildRequest(filePath); + settingsRequest = new NrtsearchClientBuilder.SettingsV2ClientBuilder().buildRequest(filePath); settingsRequest = settingsRequest.toBuilder().setIndexName(indexName).build(); } else { settingsRequest = SettingsV2Request.newBuilder().setIndexName(indexName).build(); @@ -181,7 +180,7 @@ public void settingsV2(String indexName, Path filePath) throws IOException { public void startIndex(Path filePath) throws IOException { StartIndexRequest startIndexRequest = - new LuceneServerClientBuilder.StartIndexClientBuilder().buildRequest(filePath); + new NrtsearchClientBuilder.StartIndexClientBuilder().buildRequest(filePath); StartIndexResponse response; try { response = blockingStub.startIndex(startIndexRequest); @@ -321,7 +320,7 @@ public boolean ready(String indices) { public void search(Path filePath) throws IOException { SearchRequest searchRequest = - new LuceneServerClientBuilder.SearchClientBuilder().buildRequest(filePath); + new NrtsearchClientBuilder.SearchClientBuilder().buildRequest(filePath); SearchResponse response; try { response = blockingStub.search(searchRequest); @@ -334,7 +333,7 @@ public void search(Path filePath) throws IOException { public void delete(Path filePath) throws IOException { AddDocumentRequest addDocumentRequest = - new LuceneServerClientBuilder.DeleteDocumentsBuilder().buildRequest(filePath); + new NrtsearchClientBuilder.DeleteDocumentsBuilder().buildRequest(filePath); AddDocumentResponse response; try { response = blockingStub.delete(addDocumentRequest); diff --git a/src/main/java/com/yelp/nrtsearch/server/grpc/LuceneServerClientBuilder.java b/src/main/java/com/yelp/nrtsearch/server/grpc/NrtsearchClientBuilder.java similarity index 94% rename from src/main/java/com/yelp/nrtsearch/server/grpc/LuceneServerClientBuilder.java rename to src/main/java/com/yelp/nrtsearch/server/grpc/NrtsearchClientBuilder.java index e68247605..bcf0dd81e 100644 --- a/src/main/java/com/yelp/nrtsearch/server/grpc/LuceneServerClientBuilder.java +++ b/src/main/java/com/yelp/nrtsearch/server/grpc/NrtsearchClientBuilder.java @@ -31,11 +31,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public interface LuceneServerClientBuilder { +public interface NrtsearchClientBuilder { T buildRequest(Path filePath) throws IOException; - class SettingsClientBuilder implements LuceneServerClientBuilder { + class SettingsClientBuilder implements NrtsearchClientBuilder { private static final Logger logger = LoggerFactory.getLogger(SettingsClientBuilder.class.getName()); @@ -70,7 +70,7 @@ public SettingsRequest buildRequest(Path filePath) throws IOException { } } - class SettingsV2ClientBuilder implements LuceneServerClientBuilder { + class SettingsV2ClientBuilder implements NrtsearchClientBuilder { private static final Logger logger = LoggerFactory.getLogger(SettingsClientBuilder.class.getName()); @@ -94,7 +94,7 @@ public SettingsV2Request buildRequest(Path filePath) throws IOException { } } - class StartIndexClientBuilder implements LuceneServerClientBuilder { + class StartIndexClientBuilder implements NrtsearchClientBuilder { private static final Logger logger = LoggerFactory.getLogger(StartIndexClientBuilder.class.getName()); @@ -116,7 +116,7 @@ public StartIndexRequest buildRequest(Path filePath) throws IOException { } } - class AddDocumentsClientBuilder implements LuceneServerClientBuilder> { + class AddDocumentsClientBuilder implements NrtsearchClientBuilder> { private static final Logger logger = LoggerFactory.getLogger(AddDocumentsClientBuilder.class.getName()); private final String indexName; @@ -153,7 +153,7 @@ public Stream buildRequest(Path filePath) { } class AddJsonDocumentsClientBuilder - implements LuceneServerClientBuilder> { + implements NrtsearchClientBuilder> { private static final Logger logger = LoggerFactory.getLogger(AddJsonDocumentsClientBuilder.class.getName()); private final String indexName; @@ -231,7 +231,7 @@ public boolean isFinished() { } } - class SearchClientBuilder implements LuceneServerClientBuilder { + class SearchClientBuilder implements NrtsearchClientBuilder { private static final Logger logger = LoggerFactory.getLogger(SearchClientBuilder.class.getName()); @@ -253,7 +253,7 @@ public SearchRequest buildRequest(Path filePath) throws IOException { } } - class DeleteDocumentsBuilder implements LuceneServerClientBuilder { + class DeleteDocumentsBuilder implements NrtsearchClientBuilder { private static final Logger logger = LoggerFactory.getLogger(DeleteDocumentsBuilder.class.getName()); diff --git a/src/main/java/com/yelp/nrtsearch/server/grpc/LuceneServer.java b/src/main/java/com/yelp/nrtsearch/server/grpc/NrtsearchServer.java similarity index 96% rename from src/main/java/com/yelp/nrtsearch/server/grpc/LuceneServer.java rename to src/main/java/com/yelp/nrtsearch/server/grpc/NrtsearchServer.java index ca2ccd77f..f07d54da6 100644 --- a/src/main/java/com/yelp/nrtsearch/server/grpc/LuceneServer.java +++ b/src/main/java/com/yelp/nrtsearch/server/grpc/NrtsearchServer.java @@ -27,7 +27,7 @@ import com.google.protobuf.util.JsonFormat; import com.yelp.nrtsearch.server.analysis.AnalyzerCreator; import com.yelp.nrtsearch.server.concurrent.ThreadPoolExecutorFactory; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.config.QueryCacheConfig; import com.yelp.nrtsearch.server.custom.request.CustomRequestProcessor; import com.yelp.nrtsearch.server.field.FieldDefCreator; @@ -77,14 +77,14 @@ import com.yelp.nrtsearch.server.handler.WriteNRTPointHandler; import com.yelp.nrtsearch.server.highlights.HighlighterService; import com.yelp.nrtsearch.server.logging.HitsLoggerCreator; -import com.yelp.nrtsearch.server.modules.LuceneServerModule; +import com.yelp.nrtsearch.server.modules.NrtsearchModule; import com.yelp.nrtsearch.server.monitoring.Configuration; import com.yelp.nrtsearch.server.monitoring.DeadlineMetrics; import com.yelp.nrtsearch.server.monitoring.DirSizeCollector; import com.yelp.nrtsearch.server.monitoring.IndexMetrics; -import com.yelp.nrtsearch.server.monitoring.LuceneServerMonitoringServerInterceptor; import com.yelp.nrtsearch.server.monitoring.MergeSchedulerCollector; import com.yelp.nrtsearch.server.monitoring.NrtMetrics; +import com.yelp.nrtsearch.server.monitoring.NrtsearchMonitoringServerInterceptor; import com.yelp.nrtsearch.server.monitoring.ProcStatCollector; import com.yelp.nrtsearch.server.monitoring.QueryCacheCollector; import com.yelp.nrtsearch.server.monitoring.SearchResponseCollector; @@ -123,19 +123,19 @@ import picocli.CommandLine; /** Server that manages startup/shutdown of a {@code LuceneServer} server. */ -public class LuceneServer { - private static final Logger logger = LoggerFactory.getLogger(LuceneServer.class.getName()); +public class NrtsearchServer { + private static final Logger logger = LoggerFactory.getLogger(NrtsearchServer.class.getName()); private final RemoteBackend remoteBackend; private final PrometheusRegistry prometheusRegistry; private final PluginsService pluginsService; private Server server; private Server replicationServer; - private final LuceneServerConfiguration luceneServerConfiguration; + private final NrtsearchConfig luceneServerConfiguration; @Inject - public LuceneServer( - LuceneServerConfiguration luceneServerConfiguration, + public NrtsearchServer( + NrtsearchConfig luceneServerConfiguration, RemoteBackend remoteBackend, PrometheusRegistry prometheusRegistry) { this.luceneServerConfiguration = luceneServerConfiguration; @@ -197,8 +197,8 @@ public void start() throws IOException { // Inform global state that the replication server is started, and it is safe to start indices globalState.replicationStarted(replicationServer.getPort()); - LuceneServerMonitoringServerInterceptor monitoringInterceptor = - LuceneServerMonitoringServerInterceptor.create( + NrtsearchMonitoringServerInterceptor monitoringInterceptor = + NrtsearchMonitoringServerInterceptor.create( Configuration.allMetrics() .withLatencyBuckets(luceneServerConfiguration.getMetricsBuckets()) .withPrometheusRegistry(prometheusRegistry)); @@ -267,7 +267,7 @@ private void registerMetrics(GlobalState globalState) { /** Main launches the server from the command line. */ public static void main(String[] args) { - System.exit(new CommandLine(new LuceneServerCommand()).execute(args)); + System.exit(new CommandLine(new NrtsearchServerCommand()).execute(args)); } @CommandLine.Command( @@ -275,7 +275,7 @@ public static void main(String[] args) { mixinStandardHelpOptions = true, versionProvider = VersionProvider.class, description = "Start NRT search server") - public static class LuceneServerCommand implements Callable { + public static class NrtsearchServerCommand implements Callable { @CommandLine.Parameters( arity = "0..1", paramLabel = "server_yaml_config_file", @@ -289,10 +289,10 @@ public Optional maybeConfigFile() { @Override public Integer call() throws Exception { - LuceneServer luceneServer; + NrtsearchServer luceneServer; try { - Injector injector = Guice.createInjector(new LuceneServerModule(this)); - luceneServer = injector.getInstance(LuceneServer.class); + Injector injector = Guice.createInjector(new NrtsearchModule(this)); + luceneServer = injector.getInstance(NrtsearchServer.class); luceneServer.start(); Runtime.getRuntime() @@ -365,7 +365,7 @@ static class LuceneServerImpl extends LuceneServerGrpc.LuceneServerImplBase { * @throws IOException */ LuceneServerImpl( - LuceneServerConfiguration configuration, + NrtsearchConfig configuration, RemoteBackend remoteBackend, PrometheusRegistry prometheusRegistry, List plugins) @@ -419,7 +419,7 @@ static class LuceneServerImpl extends LuceneServerGrpc.LuceneServerImplBase { } @VisibleForTesting - static void initQueryCache(LuceneServerConfiguration configuration) { + static void initQueryCache(NrtsearchConfig configuration) { QueryCacheConfig cacheConfig = configuration.getQueryCacheConfig(); QueryCache queryCache = null; if (cacheConfig.getEnabled()) { @@ -433,8 +433,7 @@ static void initQueryCache(LuceneServerConfiguration configuration) { IndexSearcher.setDefaultQueryCache(queryCache); } - private void initExtendableComponents( - LuceneServerConfiguration configuration, List plugins) { + private void initExtendableComponents(NrtsearchConfig configuration, List plugins) { // this block should be in alphabetical order AnalyzerCreator.initialize(configuration, plugins); CollectorCreator.initialize(configuration, plugins); diff --git a/src/main/java/com/yelp/nrtsearch/server/handler/Handler.java b/src/main/java/com/yelp/nrtsearch/server/handler/Handler.java index fd270370e..87e512090 100644 --- a/src/main/java/com/yelp/nrtsearch/server/handler/Handler.java +++ b/src/main/java/com/yelp/nrtsearch/server/handler/Handler.java @@ -18,6 +18,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.protobuf.GeneratedMessageV3; import com.yelp.nrtsearch.server.grpc.LuceneServerStubBuilder; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer; import com.yelp.nrtsearch.server.grpc.ReplicationServerClient; import com.yelp.nrtsearch.server.state.GlobalState; import io.grpc.Status; @@ -31,8 +32,8 @@ * streaming responses. For a gRPC method x, create a class xHandler that extends Handler. Override * the {@link #handle(StreamObserver)} method for streaming responses, or the {@link * #handle(GeneratedMessageV3, StreamObserver)} method for unary responses. Initialize the handler - * in {@link com.yelp.nrtsearch.server.grpc.LuceneServer.LuceneServerImpl} and call the appropriate - * method on the handler in the gRPC call. + * in {@link NrtsearchServer.LuceneServerImpl} and call the appropriate method on the handler in the + * gRPC call. * * @param Request type * @param Response type diff --git a/src/main/java/com/yelp/nrtsearch/server/highlights/HighlighterService.java b/src/main/java/com/yelp/nrtsearch/server/highlights/HighlighterService.java index 07efad3f1..021086abb 100644 --- a/src/main/java/com/yelp/nrtsearch/server/highlights/HighlighterService.java +++ b/src/main/java/com/yelp/nrtsearch/server/highlights/HighlighterService.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.highlights; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.plugins.HighlighterPlugin; import com.yelp.nrtsearch.server.plugins.Plugin; import java.util.HashMap; @@ -32,7 +32,7 @@ public class HighlighterService { * * @param configuration server configuration */ - public HighlighterService(LuceneServerConfiguration configuration) {} + public HighlighterService(NrtsearchConfig configuration) {} private void register(Iterable highlighters) { highlighters.forEach(highlighter -> register(highlighter.getName(), highlighter)); @@ -58,7 +58,7 @@ private static void initializeBuiltinHighlighters() { * @param configuration service configuration * @param plugins list of loaded plugins */ - public static void initialize(LuceneServerConfiguration configuration, Iterable plugins) { + public static void initialize(NrtsearchConfig configuration, Iterable plugins) { instance = new HighlighterService(configuration); initializeBuiltinHighlighters(); for (Plugin plugin : plugins) { diff --git a/src/main/java/com/yelp/nrtsearch/server/index/IndexState.java b/src/main/java/com/yelp/nrtsearch/server/index/IndexState.java index f6b22ef77..9d6c31cc5 100644 --- a/src/main/java/com/yelp/nrtsearch/server/index/IndexState.java +++ b/src/main/java/com/yelp/nrtsearch/server/index/IndexState.java @@ -17,7 +17,7 @@ import com.google.common.collect.ImmutableMap; import com.google.gson.JsonObject; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.config.ThreadPoolConfiguration; import com.yelp.nrtsearch.server.doc.DocLookup; import com.yelp.nrtsearch.server.doc.SegmentDocLookup; @@ -257,7 +257,7 @@ public void initWarmer(RemoteBackend remoteBackend) { } public void initWarmer(RemoteBackend remoteBackend, String indexName) { - LuceneServerConfiguration configuration = globalState.getConfiguration(); + NrtsearchConfig configuration = globalState.getConfiguration(); WarmerConfig warmerConfig = configuration.getWarmerConfig(); if (warmerConfig.isWarmOnStartup() || warmerConfig.getMaxWarmingQueries() > 0) { this.warmer = diff --git a/src/main/java/com/yelp/nrtsearch/server/index/ShardState.java b/src/main/java/com/yelp/nrtsearch/server/index/ShardState.java index e1e30a99f..206089007 100644 --- a/src/main/java/com/yelp/nrtsearch/server/index/ShardState.java +++ b/src/main/java/com/yelp/nrtsearch/server/index/ShardState.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.index; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.field.FieldDef; import com.yelp.nrtsearch.server.field.IndexableFieldDef.FacetValueType; import com.yelp.nrtsearch.server.field.properties.GlobalOrdinalable; @@ -940,7 +940,7 @@ public synchronized void startReplica( throw new IllegalStateException("index \"" + name + "\" was already started"); } IndexState indexState = indexStateManager.getCurrent(); - LuceneServerConfiguration configuration = indexState.getGlobalState().getConfiguration(); + NrtsearchConfig configuration = indexState.getGlobalState().getConfiguration(); // nocommit share code better w/ start and startPrimary! try { diff --git a/src/main/java/com/yelp/nrtsearch/server/logging/HitsLoggerCreator.java b/src/main/java/com/yelp/nrtsearch/server/logging/HitsLoggerCreator.java index cf0fefb92..081b20b26 100644 --- a/src/main/java/com/yelp/nrtsearch/server/logging/HitsLoggerCreator.java +++ b/src/main/java/com/yelp/nrtsearch/server/logging/HitsLoggerCreator.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.logging; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.LoggingHits; import com.yelp.nrtsearch.server.plugins.HitsLoggerPlugin; import com.yelp.nrtsearch.server.plugins.Plugin; @@ -33,7 +33,7 @@ public class HitsLoggerCreator { * * @param configuration server configuration */ - public HitsLoggerCreator(LuceneServerConfiguration configuration) {} + public HitsLoggerCreator(NrtsearchConfig configuration) {} private void register(Map> hitsLoggers) { hitsLoggers.forEach(this::register); @@ -53,7 +53,7 @@ private void register(String name, HitsLoggerProvider hitsLoggerProvider) { * @param configuration service configuration * @param plugins list of loaded plugins */ - public static void initialize(LuceneServerConfiguration configuration, Iterable plugins) { + public static void initialize(NrtsearchConfig configuration, Iterable plugins) { instance = new HitsLoggerCreator(configuration); for (Plugin plugin : plugins) { if (plugin instanceof HitsLoggerPlugin loggerPlugin) { diff --git a/src/main/java/com/yelp/nrtsearch/server/modules/BackendModule.java b/src/main/java/com/yelp/nrtsearch/server/modules/BackendModule.java index b712282cf..068aa88ba 100644 --- a/src/main/java/com/yelp/nrtsearch/server/modules/BackendModule.java +++ b/src/main/java/com/yelp/nrtsearch/server/modules/BackendModule.java @@ -17,7 +17,7 @@ import com.amazonaws.services.s3.AmazonS3; import com.google.inject.*; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.remote.RemoteBackend; import com.yelp.nrtsearch.server.remote.s3.S3Backend; @@ -26,8 +26,7 @@ public class BackendModule extends AbstractModule { @Inject @Singleton @Provides - protected RemoteBackend providesRemoteBackend( - LuceneServerConfiguration configuration, AmazonS3 s3) { + protected RemoteBackend providesRemoteBackend(NrtsearchConfig configuration, AmazonS3 s3) { return new S3Backend(configuration, s3); } } diff --git a/src/main/java/com/yelp/nrtsearch/server/modules/LuceneServerModule.java b/src/main/java/com/yelp/nrtsearch/server/modules/NrtsearchModule.java similarity index 69% rename from src/main/java/com/yelp/nrtsearch/server/modules/LuceneServerModule.java rename to src/main/java/com/yelp/nrtsearch/server/modules/NrtsearchModule.java index 1caad5cfb..20add1f40 100644 --- a/src/main/java/com/yelp/nrtsearch/server/modules/LuceneServerModule.java +++ b/src/main/java/com/yelp/nrtsearch/server/modules/NrtsearchModule.java @@ -19,20 +19,20 @@ import com.google.inject.Inject; import com.google.inject.Provides; import com.google.inject.Singleton; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; -import com.yelp.nrtsearch.server.grpc.LuceneServer; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer; import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Optional; -public class LuceneServerModule extends AbstractModule { +public class NrtsearchModule extends AbstractModule { private static final String DEFAULT_CONFIG_FILE_RESOURCE = "/lucene_server_default_configuration.yaml"; - private final LuceneServer.LuceneServerCommand args; + private final NrtsearchServer.NrtsearchServerCommand args; - public LuceneServerModule(LuceneServer.LuceneServerCommand args) { + public NrtsearchModule(NrtsearchServer.NrtsearchServerCommand args) { this.args = args; } @@ -52,17 +52,14 @@ public PrometheusRegistry providesPrometheusRegistry() { @Inject @Singleton @Provides - protected LuceneServerConfiguration providesLuceneServerConfiguration() - throws FileNotFoundException { - LuceneServerConfiguration luceneServerConfiguration; + protected NrtsearchConfig providesNrtsearchConfig() throws FileNotFoundException { + NrtsearchConfig luceneServerConfiguration; Optional maybeConfigFile = args.maybeConfigFile(); if (maybeConfigFile.isEmpty()) { luceneServerConfiguration = - new LuceneServerConfiguration( - getClass().getResourceAsStream(DEFAULT_CONFIG_FILE_RESOURCE)); + new NrtsearchConfig(getClass().getResourceAsStream(DEFAULT_CONFIG_FILE_RESOURCE)); } else { - luceneServerConfiguration = - new LuceneServerConfiguration(new FileInputStream(maybeConfigFile.get())); + luceneServerConfiguration = new NrtsearchConfig(new FileInputStream(maybeConfigFile.get())); } return luceneServerConfiguration; } diff --git a/src/main/java/com/yelp/nrtsearch/server/modules/S3Module.java b/src/main/java/com/yelp/nrtsearch/server/modules/S3Module.java index afa9531c3..a7bbcb2c5 100644 --- a/src/main/java/com/yelp/nrtsearch/server/modules/S3Module.java +++ b/src/main/java/com/yelp/nrtsearch/server/modules/S3Module.java @@ -20,14 +20,14 @@ import com.google.inject.Inject; import com.google.inject.Provides; import com.google.inject.Singleton; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.remote.s3.S3Util; public class S3Module extends AbstractModule { @Inject @Singleton @Provides - protected AmazonS3 providesAmazonS3(LuceneServerConfiguration luceneServerConfiguration) { + protected AmazonS3 providesAmazonS3(NrtsearchConfig luceneServerConfiguration) { return S3Util.buildS3Client(luceneServerConfiguration); } } diff --git a/src/main/java/com/yelp/nrtsearch/server/monitoring/LuceneServerMonitoringServerInterceptor.java b/src/main/java/com/yelp/nrtsearch/server/monitoring/NrtsearchMonitoringServerInterceptor.java similarity index 88% rename from src/main/java/com/yelp/nrtsearch/server/monitoring/LuceneServerMonitoringServerInterceptor.java rename to src/main/java/com/yelp/nrtsearch/server/monitoring/NrtsearchMonitoringServerInterceptor.java index 538771bc3..61587614a 100644 --- a/src/main/java/com/yelp/nrtsearch/server/monitoring/LuceneServerMonitoringServerInterceptor.java +++ b/src/main/java/com/yelp/nrtsearch/server/monitoring/NrtsearchMonitoringServerInterceptor.java @@ -23,17 +23,17 @@ import java.time.Clock; /** A {@link ServerInterceptor} which sends stats about incoming grpc calls to Prometheus. */ -public class LuceneServerMonitoringServerInterceptor implements ServerInterceptor { +public class NrtsearchMonitoringServerInterceptor implements ServerInterceptor { private final Clock clock; private final Configuration configuration; private final ServerMetrics.Factory serverMetricsFactory; - public static LuceneServerMonitoringServerInterceptor create(Configuration configuration) { - return new LuceneServerMonitoringServerInterceptor( + public static NrtsearchMonitoringServerInterceptor create(Configuration configuration) { + return new NrtsearchMonitoringServerInterceptor( Clock.systemDefaultZone(), configuration, new ServerMetrics.Factory(configuration)); } - private LuceneServerMonitoringServerInterceptor( + private NrtsearchMonitoringServerInterceptor( Clock clock, Configuration configuration, ServerMetrics.Factory serverMetricsFactory) { this.clock = clock; this.configuration = configuration; diff --git a/src/main/java/com/yelp/nrtsearch/server/plugins/HighlighterPlugin.java b/src/main/java/com/yelp/nrtsearch/server/plugins/HighlighterPlugin.java index e63bf4272..89abaab73 100644 --- a/src/main/java/com/yelp/nrtsearch/server/plugins/HighlighterPlugin.java +++ b/src/main/java/com/yelp/nrtsearch/server/plugins/HighlighterPlugin.java @@ -15,15 +15,16 @@ */ package com.yelp.nrtsearch.server.plugins; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer; import com.yelp.nrtsearch.server.highlights.Highlighter; import com.yelp.nrtsearch.server.highlights.HighlighterService; import java.util.Collections; /** * Plugin interface for providing custom highlighters. The plugins will be loaded at the startup - * time of the {@link com.yelp.nrtsearch.server.grpc.LuceneServer}. The highlighter instances - * provided from the getHighlighters will be responsible for handling the corresponding highlight - * tasks (identified by name). Therefore, do not alter the instance object for any requests. + * time of the {@link NrtsearchServer}. The highlighter instances provided from the getHighlighters + * will be responsible for handling the corresponding highlight tasks (identified by name). + * Therefore, do not alter the instance object for any requests. */ public interface HighlighterPlugin { /** diff --git a/src/main/java/com/yelp/nrtsearch/server/plugins/HitsLoggerPlugin.java b/src/main/java/com/yelp/nrtsearch/server/plugins/HitsLoggerPlugin.java index 9c1764d51..9fda0187c 100644 --- a/src/main/java/com/yelp/nrtsearch/server/plugins/HitsLoggerPlugin.java +++ b/src/main/java/com/yelp/nrtsearch/server/plugins/HitsLoggerPlugin.java @@ -15,6 +15,7 @@ */ package com.yelp.nrtsearch.server.plugins; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer; import com.yelp.nrtsearch.server.logging.HitsLogger; import com.yelp.nrtsearch.server.logging.HitsLoggerProvider; import java.util.Collections; @@ -22,9 +23,9 @@ /** * Plugin interface for providing custom logging. The plugins will be loaded at the startup time of - * the {@link com.yelp.nrtsearch.server.grpc.LuceneServer}. The hits logger instances provided from - * the getHitsLoggers() will be responsible for handling the corresponding hits logger task. - * Therefore, do not alter the instance objects for any requests. + * the {@link NrtsearchServer}. The hits logger instances provided from the getHitsLoggers() will be + * responsible for handling the corresponding hits logger task. Therefore, do not alter the instance + * objects for any requests. */ public interface HitsLoggerPlugin { default Map> getHitsLoggers() { diff --git a/src/main/java/com/yelp/nrtsearch/server/plugins/PluginsService.java b/src/main/java/com/yelp/nrtsearch/server/plugins/PluginsService.java index 307b5a1cd..af4b2d294 100644 --- a/src/main/java/com/yelp/nrtsearch/server/plugins/PluginsService.java +++ b/src/main/java/com/yelp/nrtsearch/server/plugins/PluginsService.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.plugins; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.remote.PluginDownloader; import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.io.File; @@ -33,23 +33,23 @@ /** * Class to handle the loading and registration of nrtsearch plugins. * - *

Loads the plugins specified by the {@link LuceneServerConfiguration}. Plugins are located by - * searching the config provided plugin search path for a folder matching the plugin name. A - * classloader is created with the jars provided in the plugin directory. The plugin provides a - * config file containing the {@link Plugin} classname that should be loaded. Reflection is used to - * give the loaded plugin access to the lucene server config. + *

Loads the plugins specified by the {@link NrtsearchConfig}. Plugins are located by searching + * the config provided plugin search path for a folder matching the plugin name. A classloader is + * created with the jars provided in the plugin directory. The plugin provides a config file + * containing the {@link Plugin} classname that should be loaded. Reflection is used to give the + * loaded plugin access to the lucene server config. */ public class PluginsService { private static final Logger logger = LoggerFactory.getLogger(PluginsService.class); - private final LuceneServerConfiguration config; + private final NrtsearchConfig config; private final PrometheusRegistry prometheusRegistry; private final List loadedPluginDescriptors = new ArrayList<>(); private final PluginDownloader pluginDownloader; public PluginsService( - LuceneServerConfiguration config, + NrtsearchConfig config, PluginDownloader pluginDownloader, PrometheusRegistry prometheusRegistry) { this.config = config; @@ -58,8 +58,8 @@ public PluginsService( } /** - * Load the list of plugins specified in the {@link LuceneServerConfiguration}. This handles both - * the loading of the plugin class from provided jars and creation of a new instance. + * Load the list of plugins specified in the {@link NrtsearchConfig}. This handles both the + * loading of the plugin class from provided jars and creation of a new instance. * * @return list of loaded plugin instances */ @@ -190,7 +190,7 @@ Plugin getPluginInstance(Class pluginClass) { try { Plugin plugin = pluginClass - .getDeclaredConstructor(new Class[] {LuceneServerConfiguration.class}) + .getDeclaredConstructor(new Class[] {NrtsearchConfig.class}) .newInstance(config); if (plugin instanceof MetricsPlugin) { ((MetricsPlugin) plugin).registerMetrics(prometheusRegistry); diff --git a/src/main/java/com/yelp/nrtsearch/server/remote/s3/S3Backend.java b/src/main/java/com/yelp/nrtsearch/server/remote/s3/S3Backend.java index 918b47228..fc75fbc97 100644 --- a/src/main/java/com/yelp/nrtsearch/server/remote/s3/S3Backend.java +++ b/src/main/java/com/yelp/nrtsearch/server/remote/s3/S3Backend.java @@ -30,7 +30,7 @@ import com.amazonaws.services.s3.transfer.TransferManagerBuilder; import com.amazonaws.services.s3.transfer.Upload; import com.google.common.annotations.VisibleForTesting; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.nrt.state.NrtFileMetaData; import com.yelp.nrtsearch.server.nrt.state.NrtPointState; import com.yelp.nrtsearch.server.remote.RemoteBackend; @@ -95,7 +95,7 @@ record FileNamePair(String fileName, String backendFileName) {} * @param configuration configuration * @param s3 s3 client */ - public S3Backend(LuceneServerConfiguration configuration, AmazonS3 s3) { + public S3Backend(NrtsearchConfig configuration, AmazonS3 s3) { this(configuration.getBucketName(), configuration.getSavePluginBeforeUnzip(), s3); } diff --git a/src/main/java/com/yelp/nrtsearch/server/remote/s3/S3Util.java b/src/main/java/com/yelp/nrtsearch/server/remote/s3/S3Util.java index 48bea24a4..3eb502868 100644 --- a/src/main/java/com/yelp/nrtsearch/server/remote/s3/S3Util.java +++ b/src/main/java/com/yelp/nrtsearch/server/remote/s3/S3Util.java @@ -31,7 +31,7 @@ import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.AmazonS3URI; import com.google.common.base.Strings; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import java.nio.file.Path; import java.nio.file.Paths; import org.slf4j.Logger; @@ -49,7 +49,7 @@ private S3Util() {} * @param luceneServerConfiguration configuration * @return s3 client */ - public static AmazonS3 buildS3Client(LuceneServerConfiguration luceneServerConfiguration) { + public static AmazonS3 buildS3Client(NrtsearchConfig luceneServerConfiguration) { AWSCredentialsProvider awsCredentialsProvider; if (luceneServerConfiguration.getBotoCfgPath() == null) { awsCredentialsProvider = new DefaultAWSCredentialsProviderChain(); diff --git a/src/main/java/com/yelp/nrtsearch/server/rescore/RescorerCreator.java b/src/main/java/com/yelp/nrtsearch/server/rescore/RescorerCreator.java index 6e4b685b1..6048ab2a2 100644 --- a/src/main/java/com/yelp/nrtsearch/server/rescore/RescorerCreator.java +++ b/src/main/java/com/yelp/nrtsearch/server/rescore/RescorerCreator.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.rescore; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.PluginRescorer; import com.yelp.nrtsearch.server.plugins.Plugin; import com.yelp.nrtsearch.server.plugins.RescorerPlugin; @@ -34,7 +34,7 @@ public class RescorerCreator { private final Map> rescorersMap = new HashMap<>(); - public RescorerCreator(LuceneServerConfiguration configuration) {} + public RescorerCreator(NrtsearchConfig configuration) {} /** * Get a {@link RescoreOperation} implementation by name, and with the given parameters. Valid @@ -73,7 +73,7 @@ private void register(String name, RescorerProvider * @param configuration service configuration * @param plugins list of loaded plugins */ - public static void initialize(LuceneServerConfiguration configuration, Iterable plugins) { + public static void initialize(NrtsearchConfig configuration, Iterable plugins) { instance = new RescorerCreator(configuration); for (Plugin plugin : plugins) { if (plugin instanceof RescorerPlugin) { diff --git a/src/main/java/com/yelp/nrtsearch/server/script/ScriptService.java b/src/main/java/com/yelp/nrtsearch/server/script/ScriptService.java index d43cde460..c798b44b4 100644 --- a/src/main/java/com/yelp/nrtsearch/server/script/ScriptService.java +++ b/src/main/java/com/yelp/nrtsearch/server/script/ScriptService.java @@ -19,7 +19,7 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.config.ScriptCacheConfig; import com.yelp.nrtsearch.server.grpc.Script; import com.yelp.nrtsearch.server.plugins.Plugin; @@ -53,7 +53,7 @@ public class ScriptService { private final Map scriptEngineMap = new HashMap<>(); private final LoadingCache scriptCache; - private ScriptService(LuceneServerConfiguration configuration) { + private ScriptService(NrtsearchConfig configuration) { // add provided javascript engine scriptEngineMap.put("js", new JsScriptEngine()); @@ -118,7 +118,7 @@ private void register(String name, ScriptEngine scriptEngine) { * @param configuration server configuration * @param plugins loaded plugins */ - public static void initialize(LuceneServerConfiguration configuration, Iterable plugins) { + public static void initialize(NrtsearchConfig configuration, Iterable plugins) { instance = new ScriptService(configuration); for (Plugin plugin : plugins) { if (plugin instanceof ScriptPlugin) { diff --git a/src/main/java/com/yelp/nrtsearch/server/search/FetchTaskCreator.java b/src/main/java/com/yelp/nrtsearch/server/search/FetchTaskCreator.java index b823e0bbb..3e6358705 100644 --- a/src/main/java/com/yelp/nrtsearch/server/search/FetchTaskCreator.java +++ b/src/main/java/com/yelp/nrtsearch/server/search/FetchTaskCreator.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.search; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.FetchTask; import com.yelp.nrtsearch.server.plugins.FetchTaskPlugin; import com.yelp.nrtsearch.server.plugins.Plugin; @@ -35,7 +35,7 @@ public class FetchTaskCreator { * * @param configuration server configuration */ - public FetchTaskCreator(LuceneServerConfiguration configuration) {} + public FetchTaskCreator(NrtsearchConfig configuration) {} /** * Create a {@link FetchTasks.FetchTask} instance given the {@link FetchTask} message from the @@ -70,7 +70,7 @@ private void register(String name, FetchTaskProvider plugins) { + public static void initialize(NrtsearchConfig configuration, Iterable plugins) { instance = new FetchTaskCreator(configuration); for (Plugin plugin : plugins) { if (plugin instanceof FetchTaskPlugin) { diff --git a/src/main/java/com/yelp/nrtsearch/server/search/collectors/CollectorCreator.java b/src/main/java/com/yelp/nrtsearch/server/search/collectors/CollectorCreator.java index aa12375a4..2dee2d2b7 100644 --- a/src/main/java/com/yelp/nrtsearch/server/search/collectors/CollectorCreator.java +++ b/src/main/java/com/yelp/nrtsearch/server/search/collectors/CollectorCreator.java @@ -16,7 +16,7 @@ package com.yelp.nrtsearch.server.search.collectors; import com.yelp.nrtsearch.server.collectors.BucketOrder; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Collector; import com.yelp.nrtsearch.server.grpc.CollectorResult; import com.yelp.nrtsearch.server.grpc.PluginCollector; @@ -50,7 +50,7 @@ public class CollectorCreator { ? extends org.apache.lucene.search.Collector, CollectorResult>>> collectorsMap = new HashMap<>(); - private CollectorCreator(LuceneServerConfiguration configuration) {} + private CollectorCreator(NrtsearchConfig configuration) {} /** * Create {@link AdditionalCollectorManager} for the given {@link Collector} definition message. @@ -157,7 +157,7 @@ private void register( * @param configuration service configuration * @param plugins list of loaded plugins */ - public static void initialize(LuceneServerConfiguration configuration, Iterable plugins) { + public static void initialize(NrtsearchConfig configuration, Iterable plugins) { instance = new CollectorCreator(configuration); for (Plugin plugin : plugins) { if (plugin instanceof CollectorPlugin) { diff --git a/src/main/java/com/yelp/nrtsearch/server/similarity/SimilarityCreator.java b/src/main/java/com/yelp/nrtsearch/server/similarity/SimilarityCreator.java index 4a2203211..085c70cf9 100644 --- a/src/main/java/com/yelp/nrtsearch/server/similarity/SimilarityCreator.java +++ b/src/main/java/com/yelp/nrtsearch/server/similarity/SimilarityCreator.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.similarity; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.plugins.Plugin; import com.yelp.nrtsearch.server.plugins.SimilarityPlugin; import java.util.HashMap; @@ -36,7 +36,7 @@ public class SimilarityCreator { private final Map> similarityMap = new HashMap<>(); - public SimilarityCreator(LuceneServerConfiguration configuration) { + public SimilarityCreator(NrtsearchConfig configuration) { register("classic", params -> new ClassicSimilarity()); register("BM25", params -> new BM25Similarity()); register("boolean", params -> new BooleanSimilarity()); @@ -81,7 +81,7 @@ private void register(String name, SimilarityProvider simi * @param configuration service configuration * @param plugins list of loaded plugins */ - public static void initialize(LuceneServerConfiguration configuration, Iterable plugins) { + public static void initialize(NrtsearchConfig configuration, Iterable plugins) { instance = new SimilarityCreator(configuration); for (Plugin plugin : plugins) { if (plugin instanceof SimilarityPlugin) { diff --git a/src/main/java/com/yelp/nrtsearch/server/state/BackendGlobalState.java b/src/main/java/com/yelp/nrtsearch/server/state/BackendGlobalState.java index 2f7ebcaaa..d7b00e62c 100644 --- a/src/main/java/com/yelp/nrtsearch/server/state/BackendGlobalState.java +++ b/src/main/java/com/yelp/nrtsearch/server/state/BackendGlobalState.java @@ -20,7 +20,7 @@ import com.google.common.annotations.VisibleForTesting; import com.yelp.nrtsearch.server.config.IndexStartConfig; import com.yelp.nrtsearch.server.config.IndexStartConfig.IndexDataLocationType; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.CreateIndexRequest; import com.yelp.nrtsearch.server.grpc.DummyResponse; import com.yelp.nrtsearch.server.grpc.GlobalStateInfo; @@ -103,8 +103,7 @@ public static String getUniqueIndexName(String indexName, String id) { * @param remoteBackend backend for persistent remote storage * @throws IOException on filesystem error */ - public BackendGlobalState( - LuceneServerConfiguration luceneServerConfiguration, RemoteBackend remoteBackend) + public BackendGlobalState(NrtsearchConfig luceneServerConfiguration, RemoteBackend remoteBackend) throws IOException { super(luceneServerConfiguration, remoteBackend); stateBackend = createStateBackend(); diff --git a/src/main/java/com/yelp/nrtsearch/server/state/GlobalState.java b/src/main/java/com/yelp/nrtsearch/server/state/GlobalState.java index 561e6712f..050aff35c 100644 --- a/src/main/java/com/yelp/nrtsearch/server/state/GlobalState.java +++ b/src/main/java/com/yelp/nrtsearch/server/state/GlobalState.java @@ -16,7 +16,7 @@ package com.yelp.nrtsearch.server.state; import com.yelp.nrtsearch.server.concurrent.ThreadPoolExecutorFactory; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.config.ThreadPoolConfiguration; import com.yelp.nrtsearch.server.grpc.CreateIndexRequest; import com.yelp.nrtsearch.server.grpc.DummyResponse; @@ -55,7 +55,7 @@ public abstract class GlobalState implements Closeable { private final String nodeName; - private final LuceneServerConfiguration configuration; + private final NrtsearchConfig configuration; /** Server shuts down once this latch is decremented. */ private final CountDownLatch shutdownNow = new CountDownLatch(1); @@ -68,8 +68,7 @@ public abstract class GlobalState implements Closeable { private final ThreadPoolExecutor searchThreadPoolExecutor; public static GlobalState createState( - LuceneServerConfiguration luceneServerConfiguration, RemoteBackend remoteBackend) - throws IOException { + NrtsearchConfig luceneServerConfiguration, RemoteBackend remoteBackend) throws IOException { return new BackendGlobalState(luceneServerConfiguration, remoteBackend); } @@ -77,8 +76,7 @@ public RemoteBackend getRemoteBackend() { return remoteBackend; } - protected GlobalState( - LuceneServerConfiguration luceneServerConfiguration, RemoteBackend remoteBackend) + protected GlobalState(NrtsearchConfig luceneServerConfiguration, RemoteBackend remoteBackend) throws IOException { this.remoteBackend = remoteBackend; this.nodeName = luceneServerConfiguration.getNodeName(); @@ -104,7 +102,7 @@ protected GlobalState( this.configuration = luceneServerConfiguration; } - public LuceneServerConfiguration getConfiguration() { + public NrtsearchConfig getConfiguration() { return configuration; } diff --git a/src/main/java/com/yelp/nrtsearch/server/state/backend/RemoteStateBackend.java b/src/main/java/com/yelp/nrtsearch/server/state/backend/RemoteStateBackend.java index 74b850175..1176b3f9a 100644 --- a/src/main/java/com/yelp/nrtsearch/server/state/backend/RemoteStateBackend.java +++ b/src/main/java/com/yelp/nrtsearch/server/state/backend/RemoteStateBackend.java @@ -16,7 +16,7 @@ package com.yelp.nrtsearch.server.state.backend; import com.google.protobuf.util.JsonFormat; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.config.StateConfig; import com.yelp.nrtsearch.server.grpc.GlobalStateInfo; import com.yelp.nrtsearch.server.grpc.IndexStateInfo; @@ -54,8 +54,7 @@ public static class RemoteBackendConfig { * @param luceneServerConfiguration server configuration * @return config for remote backend */ - public static RemoteBackendConfig fromConfig( - LuceneServerConfiguration luceneServerConfiguration) { + public static RemoteBackendConfig fromConfig(NrtsearchConfig luceneServerConfiguration) { boolean readOnly = luceneServerConfiguration.getConfigReader().getBoolean(CONFIG_PREFIX + "readOnly", true); return new RemoteBackendConfig(readOnly); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/AddDocumentsCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/AddDocumentsCommand.java index 82b6eeb36..35a8f2ffb 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/AddDocumentsCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/AddDocumentsCommand.java @@ -19,8 +19,8 @@ import com.google.gson.Gson; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; -import com.yelp.nrtsearch.server.grpc.LuceneServerClientBuilder; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClientBuilder; import java.io.Reader; import java.nio.file.Files; import java.nio.file.Path; @@ -35,7 +35,7 @@ public class AddDocumentsCommand implements Callable { public static final String ADD_DOCUMENTS = "addDocuments"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-f", "--fileName"}, @@ -81,7 +81,7 @@ public int getMaxBufferLen() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { String indexName = getIndexName(); String fileType = getFileType(); @@ -91,12 +91,12 @@ public Integer call() throws Exception { Reader reader = Files.newBufferedReader(filePath); CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT.withFirstRecordAsHeader()); addDocumentRequestStream = - new LuceneServerClientBuilder.AddDocumentsClientBuilder(indexName, csvParser) + new NrtsearchClientBuilder.AddDocumentsClientBuilder(indexName, csvParser) .buildRequest(filePath); client.addDocuments(addDocumentRequestStream); } else if (fileType.equalsIgnoreCase("json")) { - LuceneServerClientBuilder.AddJsonDocumentsClientBuilder addJsonDocumentsClientBuilder = - new LuceneServerClientBuilder.AddJsonDocumentsClientBuilder( + NrtsearchClientBuilder.AddJsonDocumentsClientBuilder addJsonDocumentsClientBuilder = + new NrtsearchClientBuilder.AddJsonDocumentsClientBuilder( indexName, new Gson(), filePath, getMaxBufferLen()); while (!addJsonDocumentsClientBuilder.isFinished()) { addDocumentRequestStream = addJsonDocumentsClientBuilder.buildRequest(filePath); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/BackupWarmingQueriesCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/BackupWarmingQueriesCommand.java index 7b89e111f..995081faa 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/BackupWarmingQueriesCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/BackupWarmingQueriesCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -25,7 +25,7 @@ public class BackupWarmingQueriesCommand implements Callable { public static final String BACKUP_WARMING_QUERIES = "backupWarmingQueries"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--index"}, @@ -66,7 +66,7 @@ public int getUptimeMinutesThreshold() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { client.backupWarmingQueries( getIndex(), getServiceName(), getNumQueriesThreshold(), getUptimeMinutesThreshold()); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/CommitCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/CommitCommand.java index 23ccd06a2..e6f19f32d 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/CommitCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/CommitCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -25,7 +25,7 @@ public class CommitCommand implements Callable { public static final String COMMIT = "commit"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -39,7 +39,7 @@ public String getIndexName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { client.commit(getIndexName()); } finally { diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/CreateIndexCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/CreateIndexCommand.java index e4e57feb4..3692e66ba 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/CreateIndexCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/CreateIndexCommand.java @@ -18,7 +18,7 @@ import com.yelp.nrtsearch.server.grpc.FieldDefRequest; import com.yelp.nrtsearch.server.grpc.IndexLiveSettings; import com.yelp.nrtsearch.server.grpc.IndexSettings; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -28,7 +28,7 @@ public class CreateIndexCommand implements Callable { public static final String CREATE_INDEX = "createIndex"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -72,7 +72,7 @@ public String getExistsWithId() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { IndexSettings indexSettings = null; IndexLiveSettings indexLiveSettings = null; diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteAllDocumentsCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteAllDocumentsCommand.java index 051c3d93b..7ec9d3ac0 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteAllDocumentsCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteAllDocumentsCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -25,7 +25,7 @@ public class DeleteAllDocumentsCommand implements Callable { public static final String DELETE_ALL_DOCS = "deleteAllDocs"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -39,7 +39,7 @@ public String getIndexName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { client.deleteAllDocuments(getIndexName()); } finally { diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteDocumentsCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteDocumentsCommand.java index f86724148..e5d653d86 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteDocumentsCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteDocumentsCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.Callable; @@ -27,7 +27,7 @@ public class DeleteDocumentsCommand implements Callable { public static final String DELETE_DOCS = "delete"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -51,7 +51,7 @@ public String getFileName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { Path filePath = Paths.get(getFileName()); client.delete(filePath); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteIndexCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteIndexCommand.java index 757621f42..c7ae8e74b 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteIndexCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/DeleteIndexCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -23,7 +23,7 @@ public class DeleteIndexCommand implements Callable { public static final String DELETE_INDEX = "deleteIndex"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -37,7 +37,7 @@ public String getIndexName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { client.deleteIndex(getIndexName()); } finally { diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/ForceMergeCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/ForceMergeCommand.java index c795e5512..fd3f9376d 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/ForceMergeCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/ForceMergeCommand.java @@ -17,7 +17,7 @@ import com.yelp.nrtsearch.server.grpc.ForceMergeRequest; import com.yelp.nrtsearch.server.grpc.ForceMergeResponse; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,7 +28,7 @@ public class ForceMergeCommand implements Callable { private static final Logger logger = LoggerFactory.getLogger(ForceMergeCommand.class); public static final String FORCE_MERGE = "forceMerge"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -63,7 +63,7 @@ public boolean getDoWait() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { ForceMergeResponse response = client diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/ForceMergeDeletesCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/ForceMergeDeletesCommand.java index 51d5c5a2c..d9e0b4e85 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/ForceMergeDeletesCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/ForceMergeDeletesCommand.java @@ -17,7 +17,7 @@ import com.yelp.nrtsearch.server.grpc.ForceMergeDeletesRequest; import com.yelp.nrtsearch.server.grpc.ForceMergeDeletesResponse; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,7 +30,7 @@ public class ForceMergeDeletesCommand implements Callable { private static final Logger logger = LoggerFactory.getLogger(ForceMergeDeletesCommand.class); public static final String FORCE_MERGE_DELETES = "forceMergeDeletes"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -55,7 +55,7 @@ public boolean getDoWait() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { ForceMergeDeletesResponse response = client diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/GetCurrentSearcherVersion.java b/src/main/java/com/yelp/nrtsearch/tools/cli/GetCurrentSearcherVersion.java index 97532f9a1..4703cb022 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/GetCurrentSearcherVersion.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/GetCurrentSearcherVersion.java @@ -15,9 +15,9 @@ */ package com.yelp.nrtsearch.tools.cli; -import static com.yelp.nrtsearch.tools.cli.LuceneClientCommand.logger; +import static com.yelp.nrtsearch.tools.cli.NrtsearchClientCommand.logger; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import com.yelp.nrtsearch.server.grpc.ReplicationServerClient; import com.yelp.nrtsearch.server.grpc.SearcherVersion; import java.util.concurrent.Callable; @@ -30,7 +30,7 @@ public class GetCurrentSearcherVersion implements Callable { public static final String CURRENT_SEARCHER_VERSION = "currSearcherVer"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -64,7 +64,7 @@ public int getPort() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { ReplicationServerClient replServerClient = new ReplicationServerClient(getHostName(), getPort()); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/IndicesCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/IndicesCommand.java index 6ade46d9f..c41acbc2e 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/IndicesCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/IndicesCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.List; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -25,11 +25,11 @@ public class IndicesCommand implements Callable { public static final String INDICES = "indices"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { List indicesList = client.getIndices(); System.out.println(); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/LiveSettingsV2Command.java b/src/main/java/com/yelp/nrtsearch/tools/cli/LiveSettingsV2Command.java index fd2937809..92814de2f 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/LiveSettingsV2Command.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/LiveSettingsV2Command.java @@ -21,7 +21,7 @@ import com.google.protobuf.UInt64Value; import com.yelp.nrtsearch.server.grpc.IndexLiveSettings; import com.yelp.nrtsearch.server.grpc.LiveSettingsV2Request; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -31,7 +31,7 @@ public class LiveSettingsV2Command implements Callable { public static final String LIVE_SETTINGS_V2 = "liveSettingsV2"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -136,7 +136,7 @@ public class LiveSettingsV2Command implements Callable { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { LiveSettingsV2Request.Builder settingsRequestV2Builder = LiveSettingsV2Request.newBuilder(); settingsRequestV2Builder.setIndexName(indexName); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/LuceneClientCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/NrtsearchClientCommand.java similarity index 87% rename from src/main/java/com/yelp/nrtsearch/tools/cli/LuceneClientCommand.java rename to src/main/java/com/yelp/nrtsearch/tools/cli/NrtsearchClientCommand.java index e6464dcce..f02042a31 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/LuceneClientCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/NrtsearchClientCommand.java @@ -16,7 +16,7 @@ package com.yelp.nrtsearch.tools.cli; import com.yelp.nrtsearch.server.Version; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import picocli.CommandLine; @@ -52,8 +52,9 @@ WriteNRTPointCommand.class, CommandLine.HelpCommand.class }) -public class LuceneClientCommand implements Runnable { - public static final Logger logger = LoggerFactory.getLogger(LuceneClientCommand.class.getName()); +public class NrtsearchClientCommand implements Runnable { + public static final Logger logger = + LoggerFactory.getLogger(NrtsearchClientCommand.class.getName()); @CommandLine.Option( names = {"-p", "--port"}, @@ -80,12 +81,12 @@ public String getHostname() { return hostname; } - public LuceneServerClient getClient() { - return new LuceneServerClient(getHostname(), getPort()); + public NrtsearchClient getClient() { + return new NrtsearchClient(getHostname(), getPort()); } public static void main(String[] args) { - System.exit(new CommandLine(new LuceneClientCommand()).execute(args)); + System.exit(new CommandLine(new NrtsearchClientCommand()).execute(args)); } @Override diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/ReadyCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/ReadyCommand.java index 5bcacbf5a..0907c4b21 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/ReadyCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/ReadyCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -25,7 +25,7 @@ public class ReadyCommand implements Callable { public static final String READY = "ready"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indices"}, @@ -36,7 +36,7 @@ public class ReadyCommand implements Callable { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); boolean ready; try { ready = client.ready(indices); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/RefreshCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/RefreshCommand.java index 24bc9857e..cbe5b4c5a 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/RefreshCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/RefreshCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -25,7 +25,7 @@ public class RefreshCommand implements Callable { public static final String REFRESH = "refresh"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -40,7 +40,7 @@ public String getIndexName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { client.refresh(getIndexName()); } finally { diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/RegisterFieldsCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/RegisterFieldsCommand.java index 187b57857..4ab4238b0 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/RegisterFieldsCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/RegisterFieldsCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.nio.file.Files; import java.nio.file.Paths; import java.util.concurrent.Callable; @@ -27,7 +27,7 @@ public class RegisterFieldsCommand implements Callable { public static final String REGISTER_FIELDS = "registerFields"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-f", "--fileName"}, @@ -41,7 +41,7 @@ public String getFileName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { String jsonStr = Files.readString(Paths.get(getFileName())); client.registerFields(jsonStr); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/ReloadStateCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/ReloadStateCommand.java index 4291094af..e9d46b012 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/ReloadStateCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/ReloadStateCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -25,11 +25,11 @@ public class ReloadStateCommand implements Callable { public static final String RELOAD_STATE = "reloadState"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { client.reloadState(); } finally { diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/SearchCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/SearchCommand.java index 97bc4bfac..825cad9b6 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/SearchCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/SearchCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.Callable; @@ -25,7 +25,7 @@ public class SearchCommand implements Callable { public static final String SEARCH = "search"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-f", "--fileName"}, @@ -39,7 +39,7 @@ public String getFileName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { Path filePath = Paths.get(getFileName()); client.search(filePath); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/SettingsV2Command.java b/src/main/java/com/yelp/nrtsearch/tools/cli/SettingsV2Command.java index dab0954e5..6f51eb33c 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/SettingsV2Command.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/SettingsV2Command.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.Callable; @@ -28,7 +28,7 @@ public class SettingsV2Command implements Callable { public static final String SETTINGS_V2 = "settingsV2"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -51,7 +51,7 @@ public String getFileName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { Path filePath = fileName == null ? null : Paths.get(getFileName()); client.settingsV2(indexName, filePath); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/StartIndexCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/StartIndexCommand.java index 15a3a7a5d..26c03c903 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/StartIndexCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/StartIndexCommand.java @@ -17,7 +17,7 @@ import static com.yelp.nrtsearch.tools.cli.StartIndexCommand.START_INDEX; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.Callable; @@ -27,7 +27,7 @@ public class StartIndexCommand implements Callable { public static final String START_INDEX = "startIndex"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-f", "--fileName"}, @@ -41,7 +41,7 @@ public String getFileName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { Path filePath = Paths.get(getFileName()); client.startIndex(filePath); diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/StartIndexV2Command.java b/src/main/java/com/yelp/nrtsearch/tools/cli/StartIndexV2Command.java index 68b669fa1..5a005634f 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/StartIndexV2Command.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/StartIndexV2Command.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -25,7 +25,7 @@ public class StartIndexV2Command implements Callable { public static final String START_INDEX_V2 = "startIndexV2"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -35,7 +35,7 @@ public class StartIndexV2Command implements Callable { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { client.startIndexV2(indexName); } finally { diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/StatsCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/StatsCommand.java index 8dca26bdf..81282229c 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/StatsCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/StatsCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -23,7 +23,7 @@ public class StatsCommand implements Callable { public static final String STATS = "stats"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -37,7 +37,7 @@ public String getIndexName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { client.stats(getIndexName()); } finally { diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/StatusCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/StatusCommand.java index 5e27e3fd8..a4413fc0c 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/StatusCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/StatusCommand.java @@ -17,7 +17,7 @@ import static com.yelp.nrtsearch.tools.cli.StatusCommand.STATUS; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -25,11 +25,11 @@ public class StatusCommand implements Callable { public static final String STATUS = "status"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { client.status(); } finally { diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/StopIndexCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/StopIndexCommand.java index de9bc8281..fd383a722 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/StopIndexCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/StopIndexCommand.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.tools.cli; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import picocli.CommandLine; @@ -23,7 +23,7 @@ public class StopIndexCommand implements Callable { public static final String STOP_INDEX = "stopIndex"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -37,7 +37,7 @@ public String getIndexName() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { client.stopIndex(getIndexName()); } finally { diff --git a/src/main/java/com/yelp/nrtsearch/tools/cli/WriteNRTPointCommand.java b/src/main/java/com/yelp/nrtsearch/tools/cli/WriteNRTPointCommand.java index becd90a94..10238b5b5 100644 --- a/src/main/java/com/yelp/nrtsearch/tools/cli/WriteNRTPointCommand.java +++ b/src/main/java/com/yelp/nrtsearch/tools/cli/WriteNRTPointCommand.java @@ -15,9 +15,9 @@ */ package com.yelp.nrtsearch.tools.cli; -import static com.yelp.nrtsearch.tools.cli.LuceneClientCommand.logger; +import static com.yelp.nrtsearch.tools.cli.NrtsearchClientCommand.logger; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import com.yelp.nrtsearch.server.grpc.ReplicationServerClient; import com.yelp.nrtsearch.server.grpc.SearcherVersion; import java.util.concurrent.Callable; @@ -29,7 +29,7 @@ public class WriteNRTPointCommand implements Callable { public static final String WRITE_NRT_POINT = "writeNRT"; - @CommandLine.ParentCommand private LuceneClientCommand baseCmd; + @CommandLine.ParentCommand private NrtsearchClientCommand baseCmd; @CommandLine.Option( names = {"-i", "--indexName"}, @@ -63,7 +63,7 @@ public int getPort() { @Override public Integer call() throws Exception { - LuceneServerClient client = baseCmd.getClient(); + NrtsearchClient client = baseCmd.getClient(); try { ReplicationServerClient replicationServerClient = new ReplicationServerClient(getHostName(), getPort()); diff --git a/src/test/java/com/yelp/nrtsearch/clientlib/NodeNameResolverAndLoadBalancingTests.java b/src/test/java/com/yelp/nrtsearch/clientlib/NodeNameResolverAndLoadBalancingTests.java index e2f938674..9c90b3d51 100644 --- a/src/test/java/com/yelp/nrtsearch/clientlib/NodeNameResolverAndLoadBalancingTests.java +++ b/src/test/java/com/yelp/nrtsearch/clientlib/NodeNameResolverAndLoadBalancingTests.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; import com.yelp.nrtsearch.server.grpc.CommitRequest; import com.yelp.nrtsearch.server.grpc.CreateIndexRequest; @@ -111,7 +111,7 @@ public void setup() throws IOException, InterruptedException { } private GrpcServer createGrpcServer() throws IOException { - LuceneServerConfiguration luceneServerConfiguration = + NrtsearchConfig luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot()); return new GrpcServer( grpcCleanup, diff --git a/src/test/java/com/yelp/nrtsearch/module/TestLuceneServerModule.java b/src/test/java/com/yelp/nrtsearch/module/TestNrtsearchModule.java similarity index 65% rename from src/test/java/com/yelp/nrtsearch/module/TestLuceneServerModule.java rename to src/test/java/com/yelp/nrtsearch/module/TestNrtsearchModule.java index d0eae5cb1..7e6a0a51d 100644 --- a/src/test/java/com/yelp/nrtsearch/module/TestLuceneServerModule.java +++ b/src/test/java/com/yelp/nrtsearch/module/TestNrtsearchModule.java @@ -20,21 +20,18 @@ import com.google.inject.Inject; import com.google.inject.Provides; import com.google.inject.Singleton; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer; import com.yelp.nrtsearch.server.modules.BackendModule; -/** - * A Guice module to initialize {@link com.yelp.nrtsearch.server.grpc.LuceneServer} instance for - * tests. - */ -public class TestLuceneServerModule extends AbstractModule { +/** A Guice module to initialize {@link NrtsearchServer} instance for tests. */ +public class TestNrtsearchModule extends AbstractModule { - private final LuceneServerConfiguration luceneServerConfiguration; + private final NrtsearchConfig nrtsearchConfig; private final AmazonS3 amazonS3; - public TestLuceneServerModule( - LuceneServerConfiguration luceneServerConfiguration, AmazonS3 amazonS3) { - this.luceneServerConfiguration = luceneServerConfiguration; + public TestNrtsearchModule(NrtsearchConfig nrtsearchConfig, AmazonS3 amazonS3) { + this.nrtsearchConfig = nrtsearchConfig; this.amazonS3 = amazonS3; } @@ -45,8 +42,8 @@ protected void configure() { @Inject @Singleton @Provides - protected LuceneServerConfiguration providesLuceneServerConfiguration() { - return luceneServerConfiguration; + protected NrtsearchConfig providesNrtsearchConfig() { + return nrtsearchConfig; } @Inject diff --git a/src/test/java/com/yelp/nrtsearch/server/ServerTestCase.java b/src/test/java/com/yelp/nrtsearch/server/ServerTestCase.java index 17a30d588..731efe8b3 100644 --- a/src/test/java/com/yelp/nrtsearch/server/ServerTestCase.java +++ b/src/test/java/com/yelp/nrtsearch/server/ServerTestCase.java @@ -20,16 +20,16 @@ import com.google.gson.Gson; import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.util.JsonFormat; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; import com.yelp.nrtsearch.server.grpc.AddDocumentResponse; import com.yelp.nrtsearch.server.grpc.CreateIndexRequest; import com.yelp.nrtsearch.server.grpc.FieldDefRequest; import com.yelp.nrtsearch.server.grpc.GrpcServer; import com.yelp.nrtsearch.server.grpc.LiveSettingsRequest; -import com.yelp.nrtsearch.server.grpc.LuceneServerClientBuilder; import com.yelp.nrtsearch.server.grpc.LuceneServerGrpc; import com.yelp.nrtsearch.server.grpc.Mode; +import com.yelp.nrtsearch.server.grpc.NrtsearchClientBuilder; import com.yelp.nrtsearch.server.grpc.RefreshRequest; import com.yelp.nrtsearch.server.grpc.SettingsRequest; import com.yelp.nrtsearch.server.grpc.StartIndexRequest; @@ -171,7 +171,7 @@ public static void addDocsFromResourceFile(String index, String resourceFile) th Reader reader = Files.newBufferedReader(filePath); CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT.withFirstRecordAsHeader()); Stream requestStream = - new LuceneServerClientBuilder.AddDocumentsClientBuilder(index, csvParser) + new NrtsearchClientBuilder.AddDocumentsClientBuilder(index, csvParser) .buildRequest(filePath); addDocuments(requestStream); } @@ -181,7 +181,7 @@ public static void addDocsFromJsonResourceFile(String index, String resourceFile Path filePath = Paths.get(ServerTestCase.class.getResource(resourceFile).toURI()); int maxBufferLen = 10; Stream requestStream = - new LuceneServerClientBuilder.AddJsonDocumentsClientBuilder( + new NrtsearchClientBuilder.AddJsonDocumentsClientBuilder( index, new Gson(), filePath, maxBufferLen) .buildRequest(); addDocuments(requestStream); @@ -217,7 +217,7 @@ public void setUpClass() throws Exception { private GrpcServer setUpGrpcServer(PrometheusRegistry prometheusRegistry) throws IOException { String testIndex = "test_index"; - LuceneServerConfiguration luceneServerConfiguration = + NrtsearchConfig luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig( Mode.STANDALONE, folder.getRoot(), getExtraConfig()); GrpcServer server = @@ -286,7 +286,7 @@ protected SettingsRequest getSettings(String name) { protected void initIndex(String name) throws Exception {} - protected List getPlugins(LuceneServerConfiguration configuration) { + protected List getPlugins(NrtsearchConfig configuration) { return Collections.emptyList(); } diff --git a/src/test/java/com/yelp/nrtsearch/server/analysis/AnalyzerCreatorTest.java b/src/test/java/com/yelp/nrtsearch/server/analysis/AnalyzerCreatorTest.java index 751d4e42d..48dfdaee0 100644 --- a/src/test/java/com/yelp/nrtsearch/server/analysis/AnalyzerCreatorTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/analysis/AnalyzerCreatorTest.java @@ -29,7 +29,7 @@ import com.carrotsearch.randomizedtesting.RandomizedRunner; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Field; import com.yelp.nrtsearch.server.grpc.IntObject; import com.yelp.nrtsearch.server.grpc.NameAndParams; @@ -80,9 +80,9 @@ private void init(List plugins) { AnalyzerCreator.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } // Tests for predefined analyzers @@ -576,14 +576,14 @@ public void testInvalidTokenFilterConstructor() { public static class TokenFilterAnalysisComponent extends LowerCaseFilterFactory implements AnalysisComponent { - LuceneServerConfiguration configuration; + NrtsearchConfig configuration; public TokenFilterAnalysisComponent(Map args) { super(args); } @Override - public void initializeComponent(LuceneServerConfiguration configuration) { + public void initializeComponent(NrtsearchConfig configuration) { this.configuration = configuration; } } @@ -780,14 +780,14 @@ public void testInvalidCharFilterConstructor() { public static class CharFilterAnalysisComponent extends MappingCharFilterFactory implements AnalysisComponent { - LuceneServerConfiguration configuration; + NrtsearchConfig configuration; public CharFilterAnalysisComponent(Map args) { super(args); } @Override - public void initializeComponent(LuceneServerConfiguration configuration) { + public void initializeComponent(NrtsearchConfig configuration) { this.configuration = configuration; } } diff --git a/src/test/java/com/yelp/nrtsearch/server/analysis/SynonymV2GraphFilterFactoryITest.java b/src/test/java/com/yelp/nrtsearch/server/analysis/SynonymV2GraphFilterFactoryITest.java index 719c6819e..70969db30 100644 --- a/src/test/java/com/yelp/nrtsearch/server/analysis/SynonymV2GraphFilterFactoryITest.java +++ b/src/test/java/com/yelp/nrtsearch/server/analysis/SynonymV2GraphFilterFactoryITest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.*; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest.MultiValuedField; import com.yelp.nrtsearch.server.plugins.Plugin; @@ -44,9 +44,9 @@ private void init(List plugins) { AnalyzerCreator.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } protected List getIndices() { diff --git a/src/test/java/com/yelp/nrtsearch/server/analysis/SynonymV2GraphFilterFactoryTest.java b/src/test/java/com/yelp/nrtsearch/server/analysis/SynonymV2GraphFilterFactoryTest.java index 4fcbc776b..29b9ba28d 100644 --- a/src/test/java/com/yelp/nrtsearch/server/analysis/SynonymV2GraphFilterFactoryTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/analysis/SynonymV2GraphFilterFactoryTest.java @@ -16,7 +16,7 @@ package com.yelp.nrtsearch.server.analysis; import com.carrotsearch.randomizedtesting.RandomizedRunner; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.plugins.Plugin; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -48,9 +48,9 @@ private void init(List plugins) { AnalyzerCreator.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } public void testNoSynonymMappings() throws IOException, ParseException { diff --git a/src/test/java/com/yelp/nrtsearch/server/codec/ServerCodecTest.java b/src/test/java/com/yelp/nrtsearch/server/codec/ServerCodecTest.java index 5ddd6d95e..0b9f45057 100644 --- a/src/test/java/com/yelp/nrtsearch/server/codec/ServerCodecTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/codec/ServerCodecTest.java @@ -19,7 +19,7 @@ import static org.junit.Assert.fail; import static org.mockito.Mockito.*; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.field.FieldDef; import com.yelp.nrtsearch.server.field.IndexableFieldDef; import com.yelp.nrtsearch.server.field.VectorFieldDef; @@ -43,8 +43,7 @@ public class ServerCodecTest { @BeforeClass public static void beforeClass() { SimilarityCreator.initialize( - new LuceneServerConfiguration(new ByteArrayInputStream("name: node1".getBytes())), - List.of()); + new NrtsearchConfig(new ByteArrayInputStream("name: node1".getBytes())), List.of()); } private IndexStateManager getManager(FieldDef fieldDef) { diff --git a/src/test/java/com/yelp/nrtsearch/server/concurrent/ThreadPoolExecutorFactoryTest.java b/src/test/java/com/yelp/nrtsearch/server/concurrent/ThreadPoolExecutorFactoryTest.java index ee5caefd6..bd41b3c9d 100644 --- a/src/test/java/com/yelp/nrtsearch/server/concurrent/ThreadPoolExecutorFactoryTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/concurrent/ThreadPoolExecutorFactoryTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.config.ThreadPoolConfiguration; import java.io.ByteArrayInputStream; import java.util.concurrent.ThreadPoolExecutor; @@ -31,8 +31,8 @@ private void init() { } private void init(String config) { - LuceneServerConfiguration luceneServerConfiguration = - new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + NrtsearchConfig luceneServerConfiguration = + new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); ThreadPoolExecutorFactory.init(luceneServerConfiguration.getThreadPoolConfiguration()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/config/LuceneServerConfigurationTest.java b/src/test/java/com/yelp/nrtsearch/server/config/NrtsearchConfigTest.java similarity index 76% rename from src/test/java/com/yelp/nrtsearch/server/config/LuceneServerConfigurationTest.java rename to src/test/java/com/yelp/nrtsearch/server/config/NrtsearchConfigTest.java index 822d10002..95a30019d 100644 --- a/src/test/java/com/yelp/nrtsearch/server/config/LuceneServerConfigurationTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/config/NrtsearchConfigTest.java @@ -25,16 +25,16 @@ import org.apache.lucene.search.suggest.document.CompletionPostingsFormat.FSTLoadMode; import org.junit.Test; -public class LuceneServerConfigurationTest { +public class NrtsearchConfigTest { - private LuceneServerConfiguration getForConfig(String config) { - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + private NrtsearchConfig getForConfig(String config) { + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } @Test public void testGetsHostName() { String config = String.join("\n", "nodeName: \"lucene_server_foo\"", "hostName: my_host_name"); - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals("my_host_name", luceneConfig.getHostName()); } @@ -42,7 +42,7 @@ public void testGetsHostName() { public void testGetEnvHostName() { String config = String.join("\n", "nodeName: \"lucene_server_foo\"", "hostName: ${CUSTOM_HOST}"); - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals("my_custom_host", luceneConfig.getHostName()); } @@ -51,7 +51,7 @@ public void testGetMultiEnvHostName() { String config = String.join( "\n", "nodeName: \"lucene_server_foo\"", "hostName: my_${VAR1}_${VAR2}_${VAR1}_host"); - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals("my_v1_v2_v1_host", luceneConfig.getHostName()); } @@ -60,14 +60,14 @@ public void testMissingEnvHostName() { String config = String.join( "\n", "nodeName: \"lucene_server_foo\"", "hostName: my_${VAR4}_${VAR3}_${VAR4}_host"); - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals("my__v3__host", luceneConfig.getHostName()); } @Test public void testDefaultDiscoveryFileUpdateInterval() { String config = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals( ReplicationServerClient.FILE_UPDATE_INTERVAL_MS, luceneConfig.getDiscoveryFileUpdateIntervalMs()); @@ -77,76 +77,74 @@ public void testDefaultDiscoveryFileUpdateInterval() { public void testSetDiscoveryFileUpdateInterval() { String config = String.join("\n", "nodeName: \"lucene_server_foo\"", "discoveryFileUpdateIntervalMs: 100"); - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals(100, luceneConfig.getDiscoveryFileUpdateIntervalMs()); } @Test public void testDefaultCompletionCodecLoadMode() { String config = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals(FSTLoadMode.ON_HEAP, luceneConfig.getCompletionCodecLoadMode()); } @Test public void testSetCompletionCodecLoadMode() { String config = "completionCodecLoadMode: OFF_HEAP"; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals(FSTLoadMode.OFF_HEAP, luceneConfig.getCompletionCodecLoadMode()); } @Test public void testInitialSyncPrimaryWaitMs_default() { String config = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals( - LuceneServerConfiguration.DEFAULT_INITIAL_SYNC_PRIMARY_WAIT_MS, + NrtsearchConfig.DEFAULT_INITIAL_SYNC_PRIMARY_WAIT_MS, luceneConfig.getInitialSyncPrimaryWaitMs()); } @Test public void testInitialSyncPrimaryWaitMs_set() { String config = "initialSyncPrimaryWaitMs: 100"; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals(100L, luceneConfig.getInitialSyncPrimaryWaitMs()); } @Test public void testInitialSyncMaxTimeMs_default() { String config = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals( - LuceneServerConfiguration.DEFAULT_INITIAL_SYNC_MAX_TIME_MS, - luceneConfig.getInitialSyncMaxTimeMs()); + NrtsearchConfig.DEFAULT_INITIAL_SYNC_MAX_TIME_MS, luceneConfig.getInitialSyncMaxTimeMs()); } @Test public void testInitialSyncMaxTimeMs_set() { String config = "initialSyncMaxTimeMs: 100"; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals(100L, luceneConfig.getInitialSyncMaxTimeMs()); } @Test public void testMaxS3ClientRetries_default() { String config = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals( - LuceneServerConfiguration.DEFAULT_MAX_S3_CLIENT_RETRIES, - luceneConfig.getMaxS3ClientRetries()); + NrtsearchConfig.DEFAULT_MAX_S3_CLIENT_RETRIES, luceneConfig.getMaxS3ClientRetries()); } @Test public void testMaxS3ClientRetries_set() { String config = "maxS3ClientRetries: 10"; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals(10, luceneConfig.getMaxS3ClientRetries()); } @Test public void testLiveSettingsOverride_default() { String config = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals( IndexLiveSettings.newBuilder().build(), luceneConfig.getLiveSettingsOverride("test_index")); } @@ -163,7 +161,7 @@ public void testLiveSettingsOverride_set() { " test_index_2:", " defaultSearchTimeoutSec: 10.25", " segmentsPerTier: 30"); - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals( IndexLiveSettings.newBuilder() .setSliceMaxDocs(Int32Value.newBuilder().setValue(1).build()) @@ -184,28 +182,28 @@ public void testLiveSettingsOverride_set() { @Test public void testLowPriorityCopyPercentage_default() { String config = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals(0, luceneConfig.getLowPriorityCopyPercentage()); } @Test public void testLowPriorityCopyPercentage_set() { String config = "lowPriorityCopyPercentage: 10"; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertEquals(10, luceneConfig.getLowPriorityCopyPercentage()); } @Test public void testVerifyReplicationIndexId_default() { String config = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertTrue(luceneConfig.getVerifyReplicationIndexId()); } @Test public void testVerifyReplicationIndexId_set() { String config = "verifyReplicationIndexId: false"; - LuceneServerConfiguration luceneConfig = getForConfig(config); + NrtsearchConfig luceneConfig = getForConfig(config); assertFalse(luceneConfig.getVerifyReplicationIndexId()); } } diff --git a/src/test/java/com/yelp/nrtsearch/server/config/ThreadPoolConfigurationTest.java b/src/test/java/com/yelp/nrtsearch/server/config/ThreadPoolConfigurationTest.java index d0e472751..9f925c1d4 100644 --- a/src/test/java/com/yelp/nrtsearch/server/config/ThreadPoolConfigurationTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/config/ThreadPoolConfigurationTest.java @@ -38,8 +38,7 @@ private int cpus() { public void testConfiguration() throws FileNotFoundException { String config = Paths.get("src", "test", "resources", "config.yaml").toAbsolutePath().toString(); - LuceneServerConfiguration luceneServerConfiguration = - new LuceneServerConfiguration(new FileInputStream(config)); + NrtsearchConfig luceneServerConfiguration = new NrtsearchConfig(new FileInputStream(config)); assertEquals("lucene_server_foo", luceneServerConfiguration.getNodeName()); assertEquals("foohost", luceneServerConfiguration.getHostName()); ThreadPoolConfiguration.ThreadPoolSettings threadPoolSettings = diff --git a/src/test/java/com/yelp/nrtsearch/server/custom/request/CustomRpcTest.java b/src/test/java/com/yelp/nrtsearch/server/custom/request/CustomRpcTest.java index b6fd248e3..20c3b9be3 100644 --- a/src/test/java/com/yelp/nrtsearch/server/custom/request/CustomRpcTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/custom/request/CustomRpcTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.CustomRequest; import com.yelp.nrtsearch.server.grpc.CustomResponse; import com.yelp.nrtsearch.server.plugins.Plugin; @@ -33,7 +33,7 @@ public class CustomRpcTest extends ServerTestCase { @ClassRule public static final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule(); @Override - protected List getPlugins(LuceneServerConfiguration configuration) { + protected List getPlugins(NrtsearchConfig configuration) { return List.of(new CustomRequestTestPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/doc/SharedDocContextTest.java b/src/test/java/com/yelp/nrtsearch/server/doc/SharedDocContextTest.java index 4551628d1..80ea2f12b 100644 --- a/src/test/java/com/yelp/nrtsearch/server/doc/SharedDocContextTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/doc/SharedDocContextTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; import com.yelp.nrtsearch.server.grpc.FieldDefRequest; import com.yelp.nrtsearch.server.grpc.Query; @@ -110,7 +110,7 @@ public void initIndex(String name) throws Exception { } @Override - public List getPlugins(LuceneServerConfiguration configuration) { + public List getPlugins(NrtsearchConfig configuration) { return Collections.singletonList(new TestSharedContextPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/facet/FacetScriptFacetsTest.java b/src/test/java/com/yelp/nrtsearch/server/facet/FacetScriptFacetsTest.java index 879837a80..400ad5953 100644 --- a/src/test/java/com/yelp/nrtsearch/server/facet/FacetScriptFacetsTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/facet/FacetScriptFacetsTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.doc.DocLookup; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; import com.yelp.nrtsearch.server.grpc.Facet; @@ -258,7 +258,7 @@ protected void initIndex(String name) throws Exception { } @Override - protected List getPlugins(LuceneServerConfiguration configuration) { + protected List getPlugins(NrtsearchConfig configuration) { return Collections.singletonList(new TestFacetScriptPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/facet/RuntimeScriptFacetsTest.java b/src/test/java/com/yelp/nrtsearch/server/facet/RuntimeScriptFacetsTest.java index ae67d8813..01c5d36d6 100644 --- a/src/test/java/com/yelp/nrtsearch/server/facet/RuntimeScriptFacetsTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/facet/RuntimeScriptFacetsTest.java @@ -19,7 +19,7 @@ import com.google.protobuf.Value; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.doc.DocLookup; import com.yelp.nrtsearch.server.doc.LoadedDocValues; import com.yelp.nrtsearch.server.grpc.*; @@ -225,7 +225,7 @@ protected void initIndex(String name) throws Exception { } @Override - protected List getPlugins(LuceneServerConfiguration configuration) { + protected List getPlugins(NrtsearchConfig configuration) { return Collections.singletonList(new TestRuntimeScriptPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/field/AtomFieldDefTest.java b/src/test/java/com/yelp/nrtsearch/server/field/AtomFieldDefTest.java index b64b02b94..eb5e7fcc4 100644 --- a/src/test/java/com/yelp/nrtsearch/server/field/AtomFieldDefTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/field/AtomFieldDefTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Field; import com.yelp.nrtsearch.server.grpc.TextDocValuesType; import com.yelp.nrtsearch.server.similarity.SimilarityCreator; @@ -33,8 +33,8 @@ public class AtomFieldDefTest { @BeforeClass public static void init() { String configStr = "node: node1"; - LuceneServerConfiguration configuration = - new LuceneServerConfiguration(new ByteArrayInputStream(configStr.getBytes())); + NrtsearchConfig configuration = + new NrtsearchConfig(new ByteArrayInputStream(configStr.getBytes())); SimilarityCreator.initialize(configuration, Collections.emptyList()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/field/FieldDefCreatorTest.java b/src/test/java/com/yelp/nrtsearch/server/field/FieldDefCreatorTest.java index ddb54931d..5d8c75498 100644 --- a/src/test/java/com/yelp/nrtsearch/server/field/FieldDefCreatorTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/field/FieldDefCreatorTest.java @@ -19,7 +19,7 @@ import com.google.protobuf.Struct; import com.google.protobuf.Value; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Field; import com.yelp.nrtsearch.server.grpc.FieldType; import com.yelp.nrtsearch.server.plugins.FieldTypePlugin; @@ -43,9 +43,9 @@ private void init(List plugins) { FieldDefCreator.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } static class TestFieldDef extends FieldDef { diff --git a/src/test/java/com/yelp/nrtsearch/server/field/TestFieldDefTest.java b/src/test/java/com/yelp/nrtsearch/server/field/TestFieldDefTest.java index d4df5a539..419d28bb7 100644 --- a/src/test/java/com/yelp/nrtsearch/server/field/TestFieldDefTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/field/TestFieldDefTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Field; import com.yelp.nrtsearch.server.similarity.SimilarityCreator; import java.io.ByteArrayInputStream; @@ -30,8 +30,8 @@ public class TestFieldDefTest { @BeforeClass public static void init() { String configStr = "node: node1"; - LuceneServerConfiguration configuration = - new LuceneServerConfiguration(new ByteArrayInputStream(configStr.getBytes())); + NrtsearchConfig configuration = + new NrtsearchConfig(new ByteArrayInputStream(configStr.getBytes())); SimilarityCreator.initialize(configuration, Collections.emptyList()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/field/TextFieldDefTest.java b/src/test/java/com/yelp/nrtsearch/server/field/TextFieldDefTest.java index 7013436d3..2a1c64e2a 100644 --- a/src/test/java/com/yelp/nrtsearch/server/field/TextFieldDefTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/field/TextFieldDefTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.*; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Field; import com.yelp.nrtsearch.server.grpc.TextDocValuesType; import com.yelp.nrtsearch.server.similarity.SimilarityCreator; @@ -33,8 +33,8 @@ public class TextFieldDefTest { @BeforeClass public static void init() { String configStr = "node: node1"; - LuceneServerConfiguration configuration = - new LuceneServerConfiguration(new ByteArrayInputStream(configStr.getBytes())); + NrtsearchConfig configuration = + new NrtsearchConfig(new ByteArrayInputStream(configStr.getBytes())); SimilarityCreator.initialize(configuration, Collections.emptyList()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/AckedCopyTest.java b/src/test/java/com/yelp/nrtsearch/server/grpc/AckedCopyTest.java index 0da1888e0..f8aba66d7 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/AckedCopyTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/AckedCopyTest.java @@ -19,7 +19,7 @@ import static com.yelp.nrtsearch.server.grpc.ReplicationServerTest.validateSearchResults; import com.amazonaws.services.s3.AmazonS3; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.remote.RemoteBackend; import com.yelp.nrtsearch.server.remote.s3.S3Backend; import com.yelp.nrtsearch.server.utils.LuceneServerTestConfigurationFactory; @@ -78,7 +78,7 @@ public void setUp(int chunkSize, int ackEvery, int maxInFlight) throws IOExcepti // set up primary servers String testIndex = "test_index"; - LuceneServerConfiguration luceneServerPrimaryConfiguration = + NrtsearchConfig luceneServerPrimaryConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.PRIMARY, folder.getRoot(), extraConfig); remoteBackend = new S3Backend(luceneServerPrimaryConfiguration, s3); luceneServerPrimary = @@ -105,7 +105,7 @@ public void setUp(int chunkSize, int ackEvery, int maxInFlight) throws IOExcepti .getGlobalState() .replicationStarted(luceneServerPrimaryConfiguration.getReplicationPort()); // set up secondary servers - LuceneServerConfiguration luceneServerSecondaryConfiguration = + NrtsearchConfig luceneServerSecondaryConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.REPLICA, folder.getRoot(), extraConfig); luceneServerSecondary = @@ -188,7 +188,7 @@ private void testReplication() throws IOException, InterruptedException { .setStartHit(0) .setTopHits(10) .setVersion(searcherVersionPrimary.getVersion()) - .addAllRetrieveFields(LuceneServerTest.RETRIEVED_VALUES) + .addAllRetrieveFields(NrtsearchServerTest.RETRIEVED_VALUES) .build()); // replica should too! @@ -201,7 +201,7 @@ private void testReplication() throws IOException, InterruptedException { .setStartHit(0) .setTopHits(10) .setVersion(searcherVersionPrimary.getVersion()) - .addAllRetrieveFields(LuceneServerTest.RETRIEVED_VALUES) + .addAllRetrieveFields(NrtsearchServerTest.RETRIEVED_VALUES) .build()); validateSearchResults(searchResponsePrimary); diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/CopyFileTest.java b/src/test/java/com/yelp/nrtsearch/server/grpc/CopyFileTest.java index 7598f9f53..eeb9966dd 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/CopyFileTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/CopyFileTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.when; import com.google.protobuf.ByteString; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.state.GlobalState; import io.grpc.inprocess.InProcessChannelBuilder; import io.grpc.inprocess.InProcessServerBuilder; @@ -57,7 +57,7 @@ public void sendRawFile() throws Exception { String serverName = InProcessServerBuilder.generateName(); GlobalState mockGlobalState = mock(GlobalState.class); - LuceneServerConfiguration mockConfiguration = mock(LuceneServerConfiguration.class); + NrtsearchConfig mockConfiguration = mock(NrtsearchConfig.class); when(mockGlobalState.getConfiguration()).thenReturn(mockConfiguration); when(mockConfiguration.getUseKeepAliveForReplication()).thenReturn(true); @@ -65,7 +65,7 @@ public void sendRawFile() throws Exception { grpcCleanup.register( InProcessServerBuilder.forName(serverName) .directExecutor() - .addService(new LuceneServer.ReplicationServerImpl(mockGlobalState, false)) + .addService(new NrtsearchServer.ReplicationServerImpl(mockGlobalState, false)) .build() .start()); diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/CustomFieldTypeTest.java b/src/test/java/com/yelp/nrtsearch/server/grpc/CustomFieldTypeTest.java index ca97cf631..b315a13ff 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/CustomFieldTypeTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/CustomFieldTypeTest.java @@ -18,7 +18,7 @@ import static com.yelp.nrtsearch.server.grpc.GrpcServer.rmDir; import static org.junit.Assert.assertEquals; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.doc.LoadedDocValues; import com.yelp.nrtsearch.server.field.FieldDef; import com.yelp.nrtsearch.server.field.FieldDefProvider; @@ -81,7 +81,7 @@ public void setUp() throws IOException { private GrpcServer setUpGrpcServer(PrometheusRegistry prometheusRegistry) throws IOException { String testIndex = "test_index"; - LuceneServerConfiguration luceneServerConfiguration = + NrtsearchConfig luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot()); return new GrpcServer( prometheusRegistry, diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/GrpcServer.java b/src/test/java/com/yelp/nrtsearch/server/grpc/GrpcServer.java index 2776c6fd9..c59d7f296 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/GrpcServer.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/GrpcServer.java @@ -17,10 +17,10 @@ import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.util.JsonFormat; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; -import com.yelp.nrtsearch.server.grpc.LuceneServer.LuceneServerImpl; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer.LuceneServerImpl; import com.yelp.nrtsearch.server.monitoring.Configuration; -import com.yelp.nrtsearch.server.monitoring.LuceneServerMonitoringServerInterceptor; +import com.yelp.nrtsearch.server.monitoring.NrtsearchMonitoringServerInterceptor; import com.yelp.nrtsearch.server.plugins.Plugin; import com.yelp.nrtsearch.server.remote.RemoteBackend; import com.yelp.nrtsearch.server.state.GlobalState; @@ -64,7 +64,7 @@ public class GrpcServer { private ReplicationServerGrpc.ReplicationServerStub replicationServerStub; private GlobalState globalState; - private LuceneServerConfiguration configuration; + private NrtsearchConfig configuration; private Server luceneServer; private ManagedChannel luceneServerManagedChannel; private Server replicationServer; @@ -73,7 +73,7 @@ public class GrpcServer { public GrpcServer( PrometheusRegistry prometheusRegistry, GrpcCleanupRule grpcCleanup, - LuceneServerConfiguration configuration, + NrtsearchConfig configuration, TemporaryFolder temporaryFolder, GlobalState replicationGlobalState, String indexDir, @@ -94,7 +94,7 @@ public GrpcServer( public GrpcServer( GrpcCleanupRule grpcCleanup, - LuceneServerConfiguration configuration, + NrtsearchConfig configuration, TemporaryFolder temporaryFolder, GlobalState replicationGlobalState, String indexDir, @@ -117,7 +117,7 @@ public GrpcServer( public GrpcServer( GrpcCleanupRule grpcCleanup, - LuceneServerConfiguration configuration, + NrtsearchConfig configuration, TemporaryFolder temporaryFolder, GlobalState replicationGlobalState, String indexDir, @@ -214,7 +214,7 @@ private void invoke( Server server; if (prometheusRegistry == null) { LuceneServerImpl serverImpl = - new LuceneServer.LuceneServerImpl( + new NrtsearchServer.LuceneServerImpl( configuration, remoteBackend, prometheusRegistry, plugins); globalState = serverImpl.getGlobalState(); // Create a server, add service, start, and register for automatic graceful shutdown. @@ -226,11 +226,11 @@ private void invoke( .build() .start(); } else { - LuceneServerMonitoringServerInterceptor monitoringInterceptor = - LuceneServerMonitoringServerInterceptor.create( + NrtsearchMonitoringServerInterceptor monitoringInterceptor = + NrtsearchMonitoringServerInterceptor.create( Configuration.allMetrics().withPrometheusRegistry(prometheusRegistry)); LuceneServerImpl serverImpl = - new LuceneServer.LuceneServerImpl( + new NrtsearchServer.LuceneServerImpl( configuration, remoteBackend, prometheusRegistry, plugins); globalState = serverImpl.getGlobalState(); // Create a server, add service, start, and register for automatic graceful shutdown. @@ -261,7 +261,7 @@ private void invoke( // Create a server, add service, start, and register for automatic graceful shutdown. Server server = ServerBuilder.forPort(port) - .addService(new LuceneServer.ReplicationServerImpl(globalState, false)) + .addService(new NrtsearchServer.ReplicationServerImpl(globalState, false)) .compressorRegistry(LuceneServerStubBuilder.COMPRESSOR_REGISTRY) .decompressorRegistry(LuceneServerStubBuilder.DECOMPRESSOR_REGISTRY) .build() @@ -401,7 +401,7 @@ private Stream getAddDocumentRequestStream(String fileName) Path filePath = Paths.get("src", "test", "resources", addDocsFile); Reader reader = Files.newBufferedReader(filePath); CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT.withFirstRecordAsHeader()); - return new LuceneServerClientBuilder.AddDocumentsClientBuilder( + return new NrtsearchClientBuilder.AddDocumentsClientBuilder( grpcServer.getTestIndex(), csvParser) .buildRequest(filePath); } diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/MergeBehaviorTests.java b/src/test/java/com/yelp/nrtsearch/server/grpc/MergeBehaviorTests.java index a003b0898..43327dd24 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/MergeBehaviorTests.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/MergeBehaviorTests.java @@ -16,11 +16,11 @@ package com.yelp.nrtsearch.server.grpc; import static com.yelp.nrtsearch.server.grpc.GrpcServer.rmDir; -import static com.yelp.nrtsearch.server.grpc.LuceneServerTest.RETRIEVED_VALUES; +import static com.yelp.nrtsearch.server.grpc.NrtsearchServerTest.RETRIEVED_VALUES; import static org.junit.Assert.*; import com.google.common.collect.Sets; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.state.BackendGlobalState; import com.yelp.nrtsearch.server.utils.LuceneServerTestConfigurationFactory; import io.grpc.testing.GrpcCleanupRule; @@ -85,7 +85,7 @@ public void setUp() throws IOException { private GrpcServer setUpGrpcServer(PrometheusRegistry prometheusRegistry) throws IOException { String testIndex = "test_index"; - LuceneServerConfiguration luceneServerConfiguration = + NrtsearchConfig luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot()); return new GrpcServer( prometheusRegistry, diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/MultiIndexAddDocumentsTest.java b/src/test/java/com/yelp/nrtsearch/server/grpc/MultiIndexAddDocumentsTest.java index 931cdf777..bad9bf665 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/MultiIndexAddDocumentsTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/MultiIndexAddDocumentsTest.java @@ -122,7 +122,7 @@ private Stream getAddDocumentRequestStream(String index) Path filePath = Paths.get(ServerTestCase.class.getResource(docsResourceFile).toURI()); Reader reader = Files.newBufferedReader(filePath); CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT.withFirstRecordAsHeader()); - return new LuceneServerClientBuilder.AddDocumentsClientBuilder(index, csvParser) + return new NrtsearchClientBuilder.AddDocumentsClientBuilder(index, csvParser) .buildRequest(filePath); } diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/LuceneServerClientBuilderTest.java b/src/test/java/com/yelp/nrtsearch/server/grpc/NrtsearchClientBuilderTest.java similarity index 91% rename from src/test/java/com/yelp/nrtsearch/server/grpc/LuceneServerClientBuilderTest.java rename to src/test/java/com/yelp/nrtsearch/server/grpc/NrtsearchClientBuilderTest.java index 728efbfe2..b1548375e 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/LuceneServerClientBuilderTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/NrtsearchClientBuilderTest.java @@ -26,14 +26,14 @@ import java.util.stream.Stream; import org.junit.Test; -public class LuceneServerClientBuilderTest { +public class NrtsearchClientBuilderTest { @Test public void buildRequest() throws IOException { Path filePath = Paths.get("src", "test", "resources", "addDocs.txt"); int maxBufferLen = 10; - LuceneServerClientBuilder.AddJsonDocumentsClientBuilder addJsonDocumentsClientBuilder = - new LuceneServerClientBuilder.AddJsonDocumentsClientBuilder( + NrtsearchClientBuilder.AddJsonDocumentsClientBuilder addJsonDocumentsClientBuilder = + new NrtsearchClientBuilder.AddJsonDocumentsClientBuilder( "test_index", new Gson(), filePath, maxBufferLen); Stream addDocumentRequestStream = addJsonDocumentsClientBuilder.buildRequest(filePath); diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/LuceneServerIdFieldTest.java b/src/test/java/com/yelp/nrtsearch/server/grpc/NrtsearchServerIdFieldTest.java similarity index 98% rename from src/test/java/com/yelp/nrtsearch/server/grpc/LuceneServerIdFieldTest.java rename to src/test/java/com/yelp/nrtsearch/server/grpc/NrtsearchServerIdFieldTest.java index 15b13efc4..191b85c5c 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/LuceneServerIdFieldTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/NrtsearchServerIdFieldTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.utils.LuceneServerTestConfigurationFactory; import io.grpc.StatusRuntimeException; import io.grpc.testing.GrpcCleanupRule; @@ -39,7 +39,7 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) -public class LuceneServerIdFieldTest { +public class NrtsearchServerIdFieldTest { /** * This rule manages automatic graceful shutdown for the registered servers and channels at the @@ -75,7 +75,7 @@ public void setUp() throws IOException { private GrpcServer setUpGrpcServer(PrometheusRegistry prometheusRegistry) throws IOException { String testIndex = "test_index"; - LuceneServerConfiguration luceneServerConfiguration = + NrtsearchConfig luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot()); return new GrpcServer( prometheusRegistry, diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/LuceneServerTest.java b/src/test/java/com/yelp/nrtsearch/server/grpc/NrtsearchServerTest.java similarity index 98% rename from src/test/java/com/yelp/nrtsearch/server/grpc/LuceneServerTest.java rename to src/test/java/com/yelp/nrtsearch/server/grpc/NrtsearchServerTest.java index 9d1d89e30..3ecce3e68 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/LuceneServerTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/NrtsearchServerTest.java @@ -27,8 +27,8 @@ import com.amazonaws.services.s3.AmazonS3; import com.google.api.HttpBody; import com.google.protobuf.Empty; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; -import com.yelp.nrtsearch.server.grpc.LuceneServer.LuceneServerImpl; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer.LuceneServerImpl; import com.yelp.nrtsearch.server.grpc.SearchResponse.Hit.CompositeFieldValue; import com.yelp.nrtsearch.server.remote.RemoteBackend; import com.yelp.nrtsearch.server.remote.s3.S3Backend; @@ -72,7 +72,7 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) -public class LuceneServerTest { +public class NrtsearchServerTest { public static final List RETRIEVED_VALUES = Arrays.asList( "doc_id", @@ -141,7 +141,7 @@ private void tearDownReplicaGrpcServer() throws IOException { @Before public void setUp() throws IOException { - LuceneServerConfiguration luceneServerConfiguration = + NrtsearchConfig luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig( Mode.STANDALONE, folder.getRoot(), "bucketName: " + bucketName); @@ -152,8 +152,7 @@ public void setUp() throws IOException { setUpWarmer(); } - private RemoteBackend setUpRemoteBackend(LuceneServerConfiguration configuration) - throws IOException { + private RemoteBackend setUpRemoteBackend(NrtsearchConfig configuration) throws IOException { s3 = s3Provider.getAmazonS3(); return new S3Backend(configuration, s3); } @@ -179,7 +178,7 @@ private List getTestSearchRequestsAsJsonStrings() { } private GrpcServer setUpGrpcServer( - LuceneServerConfiguration luceneServerConfiguration, PrometheusRegistry prometheusRegistry) + NrtsearchConfig luceneServerConfiguration, PrometheusRegistry prometheusRegistry) throws IOException { String testIndex = "test_index"; @@ -199,7 +198,7 @@ private GrpcServer setUpGrpcServer( private GrpcServer setUpReplicaGrpcServer(PrometheusRegistry prometheusRegistry) throws IOException { String testIndex = "test_index"; - LuceneServerConfiguration luceneServerReplicaConfiguration = + NrtsearchConfig luceneServerReplicaConfiguration = LuceneServerTestConfigurationFactory.getConfig( Mode.REPLICA, folder.getRoot(), getExtraConfig()); @@ -1237,13 +1236,13 @@ public void testQueryCache() { assertTrue(queryCache instanceof NrtQueryCache); String configStr = String.join("\n", "queryCache:", " enabled: false"); - LuceneServerConfiguration configuration = - new LuceneServerConfiguration(new ByteArrayInputStream(configStr.getBytes())); + NrtsearchConfig configuration = + new NrtsearchConfig(new ByteArrayInputStream(configStr.getBytes())); LuceneServerImpl.initQueryCache(configuration); assertNull(IndexSearcher.getDefaultQueryCache()); configStr = String.join("\n", "queryCache:", " enabled: true"); - configuration = new LuceneServerConfiguration(new ByteArrayInputStream(configStr.getBytes())); + configuration = new NrtsearchConfig(new ByteArrayInputStream(configStr.getBytes())); LuceneServerImpl.initQueryCache(configuration); queryCache = IndexSearcher.getDefaultQueryCache(); assertTrue(queryCache instanceof NrtQueryCache); diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/QueryTest.java b/src/test/java/com/yelp/nrtsearch/server/grpc/QueryTest.java index ac1ae8419..c2a63aef6 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/QueryTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/QueryTest.java @@ -20,7 +20,7 @@ import com.google.protobuf.Any; import com.google.protobuf.InvalidProtocolBufferException; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.utils.LuceneServerTestConfigurationFactory; import io.grpc.testing.GrpcCleanupRule; import java.io.IOException; @@ -76,7 +76,7 @@ public void setUp() throws Exception { private GrpcServer setUpGrpcServer() throws IOException { String testIndex = "test_index"; - LuceneServerConfiguration luceneServerConfiguration = + NrtsearchConfig luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot()); return new GrpcServer( grpcCleanup, @@ -98,7 +98,7 @@ public void testSearchQueryText() { .setIndexName(grpcServer.getTestIndex()) .setStartHit(0) .setTopHits(10) - .addAllRetrieveFields(LuceneServerTest.RETRIEVED_VALUES) + .addAllRetrieveFields(NrtsearchServerTest.RETRIEVED_VALUES) .setQueryText("SECOND") .build()); @@ -107,7 +107,7 @@ public void testSearchQueryText() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); } @Test @@ -120,7 +120,7 @@ public void testSearchV2QueryText() throws InvalidProtocolBufferException { .setIndexName(grpcServer.getTestIndex()) .setStartHit(0) .setTopHits(10) - .addAllRetrieveFields(LuceneServerTest.RETRIEVED_VALUES) + .addAllRetrieveFields(NrtsearchServerTest.RETRIEVED_VALUES) .setQueryText("SECOND") .build()); assertTrue(anyResponse.is(SearchResponse.class)); @@ -130,7 +130,7 @@ public void testSearchV2QueryText() throws InvalidProtocolBufferException { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); } @Test @@ -146,7 +146,7 @@ public void testSearchQueryResponseCompression() { .setIndexName(grpcServer.getTestIndex()) .setStartHit(0) .setTopHits(10) - .addAllRetrieveFields(LuceneServerTest.RETRIEVED_VALUES) + .addAllRetrieveFields(NrtsearchServerTest.RETRIEVED_VALUES) .setQueryText("SECOND") .setResponseCompression(compressionType) .build()); @@ -156,7 +156,7 @@ public void testSearchQueryResponseCompression() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); } } @@ -173,7 +173,7 @@ public void testSearchV2ResponseCompression() throws InvalidProtocolBufferExcept .setIndexName(grpcServer.getTestIndex()) .setStartHit(0) .setTopHits(10) - .addAllRetrieveFields(LuceneServerTest.RETRIEVED_VALUES) + .addAllRetrieveFields(NrtsearchServerTest.RETRIEVED_VALUES) .setQueryText("SECOND") .setResponseCompression(compressionType) .build()); @@ -184,7 +184,7 @@ public void testSearchV2ResponseCompression() throws InvalidProtocolBufferExcept SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); } } @@ -218,7 +218,7 @@ public void testSearchBooleanQuery() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("1", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -254,7 +254,7 @@ public void testSearchBooleanQueryMustNotBeOne() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -280,7 +280,7 @@ public void testSearchPhraseQuery() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -314,7 +314,7 @@ public void testSearchFunctionScoreQuery() { String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); assertEquals(14.0, hit.getScore(), 0.0); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -340,14 +340,14 @@ public void testSearchFunctionScoreQueryNoInnerQuery() { String firstDocId = firstHit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", firstDocId); assertEquals(14.0, firstHit.getScore(), 0.0); - LuceneServerTest.checkHits(firstHit); + NrtsearchServerTest.checkHits(firstHit); SearchResponse.Hit secondHit = searchResponse.getHits(1); String secondDocId = secondHit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("1", secondDocId); assertEquals(6.0, secondHit.getScore(), 0.0); - LuceneServerTest.checkHits(secondHit); + NrtsearchServerTest.checkHits(secondHit); }; testQuery(query, responseTester); @@ -369,7 +369,7 @@ public void testSearchFunctionFilterQuery() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -435,7 +435,7 @@ public void testSearchQueryRescorer() { // score should be equal 1.0 * firstPassScore + 4.0 * secondPassScore = 45 // the scores are hardcoded in query. firstPass: 5, secondsPass: 10 assertEquals(45, hit.getScore(), 0); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQueryWithRescorers(firstPassQuery, List.of(queryRescorer), responseTester); @@ -479,7 +479,7 @@ public void testSearchTermQuery() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; for (TermQuery termQuery : @@ -525,9 +525,9 @@ public void testSearchTermInSetQuery() { assertEquals(2, searchResponse.getTotalHits().getValue()); assertEquals(2, searchResponse.getHitsList().size()); SearchResponse.Hit firstHit = searchResponse.getHits(0); - LuceneServerTest.checkHits(firstHit); + NrtsearchServerTest.checkHits(firstHit); SearchResponse.Hit secondHit = searchResponse.getHits(1); - LuceneServerTest.checkHits(secondHit); + NrtsearchServerTest.checkHits(secondHit); }; for (TermInSetQuery termInSetQuery : @@ -575,7 +575,7 @@ public void testSearchDisjunctionMaxQuery() { String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); assertEquals(14.0, hit.getScore(), 0.0); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -599,7 +599,7 @@ public void testSearchMatchQuery() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -624,7 +624,7 @@ public void testSearchMatchQueryWithFuzzyParamsMaxEdits() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -652,7 +652,7 @@ public void testSearchMatchQueryWithFuzzyParamsAuto() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -678,7 +678,7 @@ public void testSearchMatchQueryWithFuzzyParamsAndMinShouldMatch1() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -728,7 +728,7 @@ public void testSearchMatchQueryFuzzyCustomAnalyzer() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -752,7 +752,7 @@ public void testSearchMatchPhraseQuery() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -795,7 +795,7 @@ public void testSearchMatchPhraseQueryPositionIncrementGap() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -882,7 +882,7 @@ public void testSearchMatchPhraseQueryCustomAnalyzer() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -920,7 +920,7 @@ public void testSearchMultiMatchQuery() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; testQuery(query, responseTester); @@ -963,7 +963,7 @@ public void testSearchRangeQuery() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; for (RangeQuery rangeQuery : List.of(intQuery, longQuery, floatQuery, doubleQuery, dateQuery)) { @@ -991,7 +991,7 @@ public void testSearchExplain() { SearchResponse.Hit hit = searchResponse.getHits(0); String docId = hit.getFieldsMap().get("doc_id").getFieldValue(0).getTextValue(); assertEquals("2", docId); - LuceneServerTest.checkHits(hit); + NrtsearchServerTest.checkHits(hit); }; SearchResponse searchResponse = grpcServer.getBlockingStub().search(buildSearchRequest(query)); responseTester.accept(searchResponse); @@ -1072,7 +1072,7 @@ private SearchRequest buildSearchRequest(Query query) { .setIndexName(grpcServer.getTestIndex()) .setStartHit(0) .setTopHits(10) - .addAllRetrieveFields(LuceneServerTest.RETRIEVED_VALUES) + .addAllRetrieveFields(NrtsearchServerTest.RETRIEVED_VALUES) .setQuery(query) .build(); } @@ -1082,7 +1082,7 @@ private SearchRequest buildSearchRequestWithExplain(Query query, boolean explain .setIndexName(grpcServer.getTestIndex()) .setStartHit(0) .setTopHits(10) - .addAllRetrieveFields(LuceneServerTest.RETRIEVED_VALUES) + .addAllRetrieveFields(NrtsearchServerTest.RETRIEVED_VALUES) .setQuery(query) .setExplain(explain) .build(); @@ -1093,7 +1093,7 @@ private SearchRequest buildSearchRequestWithRescorers(Query query, List getFieldMap(String jsonFieldMap) throws IOException { private final List fieldList = List.of("id", "field1", "field2", "field3", "field4"); private final List subFieldList = List.of("id", "field1", "field2"); - private void verifyDocs(int expectedCount, LuceneServerClient client) { + private void verifyDocs(int expectedCount, NrtsearchClient client) { SearchResponse response = client .getBlockingStub() @@ -484,7 +484,7 @@ private void verifyDocs(int expectedCount, LuceneServerClient client) { } } - private void verifySubFieldDocs(int expectedCount, LuceneServerClient client) { + private void verifySubFieldDocs(int expectedCount, NrtsearchClient client) { SearchResponse response = client .getBlockingStub() @@ -564,11 +564,11 @@ public void onCompleted() { return response.get(); } - private StartIndexResponse startIndex(LuceneServerClient client, Mode mode) { + private StartIndexResponse startIndex(NrtsearchClient client, Mode mode) { return startIndex(client, mode, 0); } - private StartIndexResponse startIndex(LuceneServerClient client, Mode mode, long primaryGen) { + private StartIndexResponse startIndex(NrtsearchClient client, Mode mode, long primaryGen) { if (mode.equals(Mode.REPLICA)) { return client .getBlockingStub() @@ -589,7 +589,7 @@ private StartIndexResponse startIndex(LuceneServerClient client, Mode mode, long } private StartIndexResponse startIndexWithRestore( - LuceneServerClient client, Mode mode, boolean deleteExistingData) { + NrtsearchClient client, Mode mode, boolean deleteExistingData) { if (mode.equals(Mode.REPLICA)) { return client .getBlockingStub() @@ -623,7 +623,7 @@ private StartIndexResponse startIndexWithRestore( } } - private DummyResponse stopIndex(LuceneServerClient client) { + private DummyResponse stopIndex(NrtsearchClient client) { DummyResponse response = client .getBlockingStub() @@ -632,13 +632,13 @@ private DummyResponse stopIndex(LuceneServerClient client) { return response; } - private CommitResponse commitIndex(LuceneServerClient client) { + private CommitResponse commitIndex(NrtsearchClient client) { return client .getBlockingStub() .commit(CommitRequest.newBuilder().setIndexName("test_index").build()); } - private RefreshResponse refreshIndex(LuceneServerClient client) { + private RefreshResponse refreshIndex(NrtsearchClient client) { return client .getBlockingStub() .refresh(RefreshRequest.newBuilder().setIndexName("test_index").build()); diff --git a/src/test/java/com/yelp/nrtsearch/server/grpc/TestServer.java b/src/test/java/com/yelp/nrtsearch/server/grpc/TestServer.java index 973ba5507..b474eeb63 100644 --- a/src/test/java/com/yelp/nrtsearch/server/grpc/TestServer.java +++ b/src/test/java/com/yelp/nrtsearch/server/grpc/TestServer.java @@ -28,11 +28,11 @@ import com.google.gson.JsonObject; import com.yelp.nrtsearch.clientlib.Node; import com.yelp.nrtsearch.server.config.IndexStartConfig.IndexDataLocationType; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.config.StateConfig.StateBackendType; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest.MultiValuedField; -import com.yelp.nrtsearch.server.grpc.LuceneServer.LuceneServerImpl; -import com.yelp.nrtsearch.server.grpc.LuceneServer.ReplicationServerImpl; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer.LuceneServerImpl; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer.ReplicationServerImpl; import com.yelp.nrtsearch.server.grpc.SearchResponse.Hit; import com.yelp.nrtsearch.server.index.IndexState; import com.yelp.nrtsearch.server.index.IndexStateManager; @@ -98,12 +98,12 @@ public class TestServer { private static S3Mock api; - private final LuceneServerConfiguration configuration; + private final NrtsearchConfig configuration; private final boolean writeDiscoveryFile; private final Path discoveryFilePath; private Server server; private Server replicationServer; - private LuceneServerClient client; + private NrtsearchClient client; private ReplicationServerClient replicationClient; private LuceneServerImpl serverImpl; private RemoteBackend remoteBackend; @@ -126,7 +126,7 @@ public static void cleanupAll() { } public TestServer( - LuceneServerConfiguration configuration, boolean writeDiscoveryFile, Path discoveryFilePath) + NrtsearchConfig configuration, boolean writeDiscoveryFile, Path discoveryFilePath) throws IOException { this.configuration = configuration; this.writeDiscoveryFile = writeDiscoveryFile; @@ -167,7 +167,7 @@ public void restart(boolean clearData) throws IOException { } server = ServerBuilder.forPort(0).addService(serverImpl).build().start(); - client = new LuceneServerClient("localhost", server.getPort()); + client = new NrtsearchClient("localhost", server.getPort()); replicationClient = new ReplicationServerClient("localhost", replicationServer.getPort()); } @@ -203,7 +203,7 @@ public GlobalState getGlobalState() { return serverImpl.getGlobalState(); } - public LuceneServerClient getClient() { + public NrtsearchClient getClient() { return client; } @@ -687,7 +687,7 @@ public TestServer build() throws IOException { "syncInitialNrtPoint: " + syncInitialNrtPoint, additionalConfig); return new TestServer( - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())), + new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())), writeDiscoveryFile, Paths.get(folder.getRoot().toString(), DISCOVERY_FILE)); } diff --git a/src/test/java/com/yelp/nrtsearch/server/index/BackendStateManagerTest.java b/src/test/java/com/yelp/nrtsearch/server/index/BackendStateManagerTest.java index 6c399db62..45b62df07 100644 --- a/src/test/java/com/yelp/nrtsearch/server/index/BackendStateManagerTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/index/BackendStateManagerTest.java @@ -30,7 +30,7 @@ import com.google.protobuf.DoubleValue; import com.google.protobuf.Int32Value; import com.google.protobuf.StringValue; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.field.FieldDefCreator; import com.yelp.nrtsearch.server.grpc.Field; import com.yelp.nrtsearch.server.grpc.FieldType; @@ -68,8 +68,8 @@ public class BackendStateManagerTest { @BeforeClass public static void setup() { String configFile = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration dummyConfig = - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + NrtsearchConfig dummyConfig = + new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); List dummyPlugins = Collections.emptyList(); // these must be initialized to create an IndexState FieldDefCreator.initialize(dummyConfig, dummyPlugins); diff --git a/src/test/java/com/yelp/nrtsearch/server/index/FieldUpdateUtilsTest.java b/src/test/java/com/yelp/nrtsearch/server/index/FieldUpdateUtilsTest.java index a430a222e..a31a75424 100644 --- a/src/test/java/com/yelp/nrtsearch/server/index/FieldUpdateUtilsTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/index/FieldUpdateUtilsTest.java @@ -26,7 +26,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.field.AtomFieldDef; import com.yelp.nrtsearch.server.field.BooleanFieldDef; import com.yelp.nrtsearch.server.field.DoubleFieldDef; @@ -85,8 +85,8 @@ public class FieldUpdateUtilsTest { @BeforeClass public static void setup() { String configFile = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration dummyConfig = - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + NrtsearchConfig dummyConfig = + new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); List dummyPlugins = Collections.emptyList(); // these must be initialized to create an IndexState FieldDefCreator.initialize(dummyConfig, dummyPlugins); diff --git a/src/test/java/com/yelp/nrtsearch/server/index/ImmutableIndexStateTest.java b/src/test/java/com/yelp/nrtsearch/server/index/ImmutableIndexStateTest.java index 934d471b5..e79ecd208 100644 --- a/src/test/java/com/yelp/nrtsearch/server/index/ImmutableIndexStateTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/index/ImmutableIndexStateTest.java @@ -37,7 +37,7 @@ import com.google.protobuf.StringValue; import com.google.protobuf.UInt64Value; import com.yelp.nrtsearch.server.config.IndexPreloadConfig; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.field.AtomFieldDef; import com.yelp.nrtsearch.server.field.FieldDef; import com.yelp.nrtsearch.server.field.FieldDefCreator; @@ -88,8 +88,8 @@ public class ImmutableIndexStateTest { @BeforeClass public static void setup() { String configFile = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration dummyConfig = - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + NrtsearchConfig dummyConfig = + new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); List dummyPlugins = Collections.emptyList(); // these must be initialized to create an IndexState FieldDefCreator.initialize(dummyConfig, dummyPlugins); @@ -130,8 +130,8 @@ private ImmutableIndexState getIndexState( GlobalState mockGlobalState = mock(GlobalState.class); String configFile = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration dummyConfig = - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + NrtsearchConfig dummyConfig = + new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); when(mockGlobalState.getIndexDirBase()).thenReturn(folder.getRoot().toPath()); when(mockGlobalState.getConfiguration()).thenReturn(dummyConfig); @@ -623,8 +623,8 @@ private ImmutableIndexState getIndexStateForVirtualShading( GlobalState mockGlobalState = mock(GlobalState.class); String configFile = "virtualSharding: " + (enabled ? "true" : "false"); - LuceneServerConfiguration dummyConfig = - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + NrtsearchConfig dummyConfig = + new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); when(mockGlobalState.getIndexDirBase()).thenReturn(folder.getRoot().toPath()); when(mockGlobalState.getConfiguration()).thenReturn(dummyConfig); @@ -873,8 +873,7 @@ public void testParallelFetchConfig_maxParallelism() throws IOException { GlobalState mockGlobalState = mock(GlobalState.class); String configFile = "threadPoolConfiguration:\n fetch:\n maxThreads: 10"; - LuceneServerConfiguration config = - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + NrtsearchConfig config = new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); when(mockGlobalState.getIndexDirBase()).thenReturn(folder.getRoot().toPath()); when(mockGlobalState.getConfiguration()).thenReturn(config); @@ -949,8 +948,8 @@ private ImmutableIndexState getIndexStateForLiveSettingsOverrides( GlobalState mockGlobalState = mock(GlobalState.class); String configFile = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration dummyConfig = - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + NrtsearchConfig dummyConfig = + new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); when(mockGlobalState.getIndexDirBase()).thenReturn(folder.getRoot().toPath()); when(mockGlobalState.getConfiguration()).thenReturn(dummyConfig); diff --git a/src/test/java/com/yelp/nrtsearch/server/logging/HitsLoggerCreatorTest.java b/src/test/java/com/yelp/nrtsearch/server/logging/HitsLoggerCreatorTest.java index 04ce66e61..fcf00243b 100644 --- a/src/test/java/com/yelp/nrtsearch/server/logging/HitsLoggerCreatorTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/logging/HitsLoggerCreatorTest.java @@ -21,7 +21,7 @@ import com.google.protobuf.Struct; import com.google.protobuf.Value; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.LoggingHits; import com.yelp.nrtsearch.server.grpc.SearchResponse; import com.yelp.nrtsearch.server.plugins.HitsLoggerPlugin; @@ -44,9 +44,9 @@ private void init(List plugins) { HitsLoggerCreator.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } public static class TestHitsLoggerPlugin extends Plugin implements HitsLoggerPlugin { diff --git a/src/test/java/com/yelp/nrtsearch/server/logging/HitsLoggerTest.java b/src/test/java/com/yelp/nrtsearch/server/logging/HitsLoggerTest.java index 0f5474554..5473920f2 100644 --- a/src/test/java/com/yelp/nrtsearch/server/logging/HitsLoggerTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/logging/HitsLoggerTest.java @@ -20,7 +20,7 @@ import com.google.protobuf.Struct; import com.google.protobuf.Value; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; import com.yelp.nrtsearch.server.grpc.FieldDefRequest; import com.yelp.nrtsearch.server.grpc.LoggingHits; @@ -47,7 +47,7 @@ public class HitsLoggerTest extends ServerTestCase { @ClassRule public static final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule(); @Override - protected List getPlugins(LuceneServerConfiguration configuration) { + protected List getPlugins(NrtsearchConfig configuration) { return Collections.singletonList(new HitsLoggerTest.TestHitsLoggerPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/plugins/PluginsServiceTest.java b/src/test/java/com/yelp/nrtsearch/server/plugins/PluginsServiceTest.java index eaffbd8aa..5ba5280dd 100644 --- a/src/test/java/com/yelp/nrtsearch/server/plugins/PluginsServiceTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/plugins/PluginsServiceTest.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.io.ByteArrayInputStream; import java.io.File; @@ -36,22 +36,22 @@ public class PluginsServiceTest { @Rule public TemporaryFolder folder = new TemporaryFolder(); - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } - private LuceneServerConfiguration getConfigWithSearchPath(String path) { + private NrtsearchConfig getConfigWithSearchPath(String path) { String config = "pluginSearchPath: \"" + path + "\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } - private LuceneServerConfiguration getConfigWithSearchPaths(String... paths) { + private NrtsearchConfig getConfigWithSearchPaths(String... paths) { StringBuilder config = new StringBuilder("pluginSearchPath:").append("\n"); for (String path : paths) { config.append(" - ").append(path).append("\n"); } - return new LuceneServerConfiguration(new ByteArrayInputStream(config.toString().getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.toString().getBytes())); } private PrometheusRegistry getPrometheusRegistry() { @@ -60,7 +60,7 @@ private PrometheusRegistry getPrometheusRegistry() { @Test public void testGetSinglePluginSearchPath() { - LuceneServerConfiguration config = getConfigWithSearchPath("some/plugin/path"); + NrtsearchConfig config = getConfigWithSearchPath("some/plugin/path"); PluginsService pluginsService = new PluginsService(config, null, getPrometheusRegistry()); List expectedPaths = new ArrayList<>(); expectedPaths.add(new File("some/plugin/path")); @@ -69,7 +69,7 @@ public void testGetSinglePluginSearchPath() { @Test public void testGetMultiPluginSearchPath() { - LuceneServerConfiguration config = + NrtsearchConfig config = getConfigWithSearchPaths( "some1/plugin1/path1", "some2/plugin2/path2", "some3/plugin3/path3"); PluginsService pluginsService = new PluginsService(config, null, getPrometheusRegistry()); @@ -141,10 +141,10 @@ public void testGetPluginJars() throws IOException { } public static class LoadTestPlugin extends Plugin { - public LuceneServerConfiguration config; + public NrtsearchConfig config; public PrometheusRegistry prometheusRegistry; - public LoadTestPlugin(LuceneServerConfiguration config) { + public LoadTestPlugin(NrtsearchConfig config) { this.config = config; } @@ -159,10 +159,10 @@ public void registerMetrics(PrometheusRegistry prometheusRegistry) { } public static class LoadTestPluginWithMetrics extends Plugin implements MetricsPlugin { - public LuceneServerConfiguration config; + public NrtsearchConfig config; public PrometheusRegistry prometheusRegistry; - public LoadTestPluginWithMetrics(LuceneServerConfiguration config) { + public LoadTestPluginWithMetrics(NrtsearchConfig config) { this.config = config; } @@ -217,7 +217,7 @@ public void testGetPluginInstanceWithMetrics() { @Test public void testGetPluginInstanceHasConfig() { - LuceneServerConfiguration config = getEmptyConfig(); + NrtsearchConfig config = getEmptyConfig(); PluginsService pluginsService = new PluginsService(config, null, getPrometheusRegistry()); Plugin loadedPlugin = pluginsService.getPluginInstance(LoadTestPlugin.class); LoadTestPlugin loadTestPlugin = (LoadTestPlugin) loadedPlugin; diff --git a/src/test/java/com/yelp/nrtsearch/server/query/QueryNodeMapperTest.java b/src/test/java/com/yelp/nrtsearch/server/query/QueryNodeMapperTest.java index d216bc577..995e02954 100644 --- a/src/test/java/com/yelp/nrtsearch/server/query/QueryNodeMapperTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/query/QueryNodeMapperTest.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertNotNull; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.doc.DocLookup; import com.yelp.nrtsearch.server.grpc.*; import com.yelp.nrtsearch.server.grpc.SearchResponse.Diagnostics; @@ -58,9 +58,9 @@ private void init(List plugins) { ScriptService.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } @Override diff --git a/src/test/java/com/yelp/nrtsearch/server/remote/s3/S3BackendTest.java b/src/test/java/com/yelp/nrtsearch/server/remote/s3/S3BackendTest.java index d9242431f..d00cd55fb 100644 --- a/src/test/java/com/yelp/nrtsearch/server/remote/s3/S3BackendTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/remote/s3/S3BackendTest.java @@ -27,7 +27,7 @@ import com.amazonaws.services.s3.model.PartETag; import com.amazonaws.services.s3.model.UploadPartRequest; import com.amazonaws.services.s3.model.UploadPartResult; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.nrt.state.NrtFileMetaData; import com.yelp.nrtsearch.server.nrt.state.NrtPointState; import com.yelp.nrtsearch.server.remote.RemoteBackend; @@ -72,8 +72,7 @@ public class S3BackendTest { @BeforeClass public static void setup() throws IOException { String configStr = "bucketName: " + BUCKET_NAME; - LuceneServerConfiguration config = - new LuceneServerConfiguration(new ByteArrayInputStream(configStr.getBytes())); + NrtsearchConfig config = new NrtsearchConfig(new ByteArrayInputStream(configStr.getBytes())); s3 = S3_PROVIDER.getAmazonS3(); s3Backend = new S3Backend(config, s3); s3.putObject(BUCKET_NAME, KEY, CONTENT); diff --git a/src/test/java/com/yelp/nrtsearch/server/rescore/RescorerCreatorTest.java b/src/test/java/com/yelp/nrtsearch/server/rescore/RescorerCreatorTest.java index 4bddd5584..8881b7ab5 100644 --- a/src/test/java/com/yelp/nrtsearch/server/rescore/RescorerCreatorTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/rescore/RescorerCreatorTest.java @@ -20,7 +20,7 @@ import com.google.protobuf.Struct; import com.google.protobuf.Value; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.PluginRescorer; import com.yelp.nrtsearch.server.plugins.Plugin; import com.yelp.nrtsearch.server.plugins.RescorerPlugin; @@ -45,9 +45,9 @@ private void init(List plugins) { RescorerCreator.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } public static class TestRescorerPlugin extends Plugin implements RescorerPlugin { diff --git a/src/test/java/com/yelp/nrtsearch/server/rescore/RescorerTest.java b/src/test/java/com/yelp/nrtsearch/server/rescore/RescorerTest.java index 78790d54b..55871aa29 100644 --- a/src/test/java/com/yelp/nrtsearch/server/rescore/RescorerTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/rescore/RescorerTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.fail; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.doc.LoadedDocValues; import com.yelp.nrtsearch.server.field.IndexableFieldDef; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; @@ -172,7 +172,7 @@ static class DocAndScore { } @Override - protected List getPlugins(LuceneServerConfiguration configuration) { + protected List getPlugins(NrtsearchConfig configuration) { return Collections.singletonList(new TestRescorerPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/script/ScoreScriptTest.java b/src/test/java/com/yelp/nrtsearch/server/script/ScoreScriptTest.java index 721118e34..f9f8fec12 100644 --- a/src/test/java/com/yelp/nrtsearch/server/script/ScoreScriptTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/script/ScoreScriptTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.fail; import com.google.common.primitives.Floats; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.doc.DocLookup; import com.yelp.nrtsearch.server.doc.LoadedDocValues; import com.yelp.nrtsearch.server.doc.LoadedDocValues.SingleVector; @@ -98,7 +98,7 @@ public void setUp() throws IOException { private GrpcServer setUpGrpcServer(PrometheusRegistry prometheusRegistry) throws IOException { String testIndex = "test_index"; - LuceneServerConfiguration luceneServerConfiguration = + NrtsearchConfig luceneServerConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.STANDALONE, folder.getRoot()); return new GrpcServer( prometheusRegistry, diff --git a/src/test/java/com/yelp/nrtsearch/server/script/ScriptServiceTest.java b/src/test/java/com/yelp/nrtsearch/server/script/ScriptServiceTest.java index a46ca31f0..97358bfc9 100644 --- a/src/test/java/com/yelp/nrtsearch/server/script/ScriptServiceTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/script/ScriptServiceTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertSame; import com.google.common.util.concurrent.UncheckedExecutionException; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Script; import com.yelp.nrtsearch.server.plugins.Plugin; import com.yelp.nrtsearch.server.plugins.ScriptPlugin; @@ -44,9 +44,9 @@ private void init(List plugins) { ScriptService.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } static class TestScriptPlugin extends Plugin implements ScriptPlugin { diff --git a/src/test/java/com/yelp/nrtsearch/server/search/FetchTaskCreatorTest.java b/src/test/java/com/yelp/nrtsearch/server/search/FetchTaskCreatorTest.java index 83084cfe9..d4e21a2fe 100644 --- a/src/test/java/com/yelp/nrtsearch/server/search/FetchTaskCreatorTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/search/FetchTaskCreatorTest.java @@ -20,7 +20,7 @@ import com.google.protobuf.Struct; import com.google.protobuf.Value; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.FetchTask; import com.yelp.nrtsearch.server.plugins.FetchTaskPlugin; import com.yelp.nrtsearch.server.plugins.Plugin; @@ -42,9 +42,9 @@ private void init(List plugins) { FetchTaskCreator.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } public static class TestFetchTaskPlugin extends Plugin implements FetchTaskPlugin { diff --git a/src/test/java/com/yelp/nrtsearch/server/search/FetchTasksTest.java b/src/test/java/com/yelp/nrtsearch/server/search/FetchTasksTest.java index 7103a8f76..ca2944f4a 100644 --- a/src/test/java/com/yelp/nrtsearch/server/search/FetchTasksTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/search/FetchTasksTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.doc.LoadedDocValues; import com.yelp.nrtsearch.server.field.FieldDef; import com.yelp.nrtsearch.server.field.IndexableFieldDef; @@ -83,7 +83,7 @@ protected void initIndex(String name) throws Exception { } @Override - public List getPlugins(LuceneServerConfiguration configuration) { + public List getPlugins(NrtsearchConfig configuration) { return Collections.singletonList(new TestFetchTaskPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/search/collectors/CollectorCreatorTest.java b/src/test/java/com/yelp/nrtsearch/server/search/collectors/CollectorCreatorTest.java index 03f996cc8..3ed0c41c9 100644 --- a/src/test/java/com/yelp/nrtsearch/server/search/collectors/CollectorCreatorTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/search/collectors/CollectorCreatorTest.java @@ -21,7 +21,7 @@ import com.google.protobuf.Struct; import com.google.protobuf.Value; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Collector; import com.yelp.nrtsearch.server.grpc.CollectorResult; import com.yelp.nrtsearch.server.grpc.PluginCollector; @@ -57,9 +57,9 @@ private void init(List plugins) { CollectorCreator.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } public static class TestCollectorPlugin extends Plugin implements CollectorPlugin { diff --git a/src/test/java/com/yelp/nrtsearch/server/search/collectors/CollectorTest.java b/src/test/java/com/yelp/nrtsearch/server/search/collectors/CollectorTest.java index 61eaab8e4..71837d60c 100644 --- a/src/test/java/com/yelp/nrtsearch/server/search/collectors/CollectorTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/search/collectors/CollectorTest.java @@ -24,7 +24,7 @@ import com.google.protobuf.Struct; import com.google.protobuf.Value; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.doc.LoadedDocValues; import com.yelp.nrtsearch.server.field.IndexableFieldDef; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; @@ -313,7 +313,7 @@ public void collect(int doc) throws IOException { } @Override - protected List getPlugins(LuceneServerConfiguration configuration) { + protected List getPlugins(NrtsearchConfig configuration) { return Collections.singletonList(new TestCollectorPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/search/collectors/additional/CollectorStatsWrapperTest.java b/src/test/java/com/yelp/nrtsearch/server/search/collectors/additional/CollectorStatsWrapperTest.java index a8e1aa544..269d1de4a 100644 --- a/src/test/java/com/yelp/nrtsearch/server/search/collectors/additional/CollectorStatsWrapperTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/search/collectors/additional/CollectorStatsWrapperTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertTrue; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.doc.DocLookup; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; import com.yelp.nrtsearch.server.grpc.Collector; @@ -112,7 +112,7 @@ public void initIndex(String name) throws Exception { } @Override - public List getPlugins(LuceneServerConfiguration configuration) { + public List getPlugins(NrtsearchConfig configuration) { return Collections.singletonList(new TestScriptPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/search/collectors/additional/ScriptTermsCollectorManagerTest.java b/src/test/java/com/yelp/nrtsearch/server/search/collectors/additional/ScriptTermsCollectorManagerTest.java index f1900dc28..0b5db8738 100644 --- a/src/test/java/com/yelp/nrtsearch/server/search/collectors/additional/ScriptTermsCollectorManagerTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/search/collectors/additional/ScriptTermsCollectorManagerTest.java @@ -18,7 +18,7 @@ import static com.yelp.nrtsearch.server.collectors.BucketOrder.COUNT; import static org.junit.Assert.assertEquals; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.doc.DocLookup; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; import com.yelp.nrtsearch.server.grpc.BucketOrder; @@ -230,7 +230,7 @@ protected AddDocumentRequest getIndexRequest(String index, int id) { } @Override - protected List getPlugins(LuceneServerConfiguration configuration) { + protected List getPlugins(NrtsearchConfig configuration) { return Collections.singletonList(new TestTermsScriptPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/similarity/SimilarityCreatorTest.java b/src/test/java/com/yelp/nrtsearch/server/similarity/SimilarityCreatorTest.java index e1afb7064..e5c3a381f 100644 --- a/src/test/java/com/yelp/nrtsearch/server/similarity/SimilarityCreatorTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/similarity/SimilarityCreatorTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.plugins.Plugin; import com.yelp.nrtsearch.server.plugins.SimilarityPlugin; import java.io.ByteArrayInputStream; @@ -47,9 +47,9 @@ private void init(List plugins) { SimilarityCreator.initialize(getEmptyConfig(), plugins); } - private LuceneServerConfiguration getEmptyConfig() { + private NrtsearchConfig getEmptyConfig() { String config = "nodeName: \"lucene_server_foo\""; - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } public static class TestSimilarityPlugin extends Plugin implements SimilarityPlugin { diff --git a/src/test/java/com/yelp/nrtsearch/server/similarity/SimilarityTest.java b/src/test/java/com/yelp/nrtsearch/server/similarity/SimilarityTest.java index 1d902eb9e..11183d8a4 100644 --- a/src/test/java/com/yelp/nrtsearch/server/similarity/SimilarityTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/similarity/SimilarityTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest.MultiValuedField; import com.yelp.nrtsearch.server.grpc.FieldDefRequest; @@ -107,7 +107,7 @@ protected void initIndex(String name) throws Exception { } @Override - protected List getPlugins(LuceneServerConfiguration configuration) { + protected List getPlugins(NrtsearchConfig configuration) { return Collections.singletonList(new TestSimilarityPlugin()); } diff --git a/src/test/java/com/yelp/nrtsearch/server/state/BackendGlobalStateTest.java b/src/test/java/com/yelp/nrtsearch/server/state/BackendGlobalStateTest.java index 450854bf6..2248de0c9 100644 --- a/src/test/java/com/yelp/nrtsearch/server/state/BackendGlobalStateTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/state/BackendGlobalStateTest.java @@ -30,7 +30,7 @@ import com.google.protobuf.Int32Value; import com.yelp.nrtsearch.server.concurrent.ThreadPoolExecutorFactory; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.field.FieldDefCreator; import com.yelp.nrtsearch.server.grpc.GlobalStateInfo; import com.yelp.nrtsearch.server.grpc.IndexGlobalState; @@ -84,8 +84,8 @@ public class BackendGlobalStateTest { @BeforeClass public static void setup() { String configFile = "nodeName: \"lucene_server_foo\""; - LuceneServerConfiguration dummyConfig = - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + NrtsearchConfig dummyConfig = + new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); List dummyPlugins = Collections.emptyList(); // these must be initialized to create an IndexState FieldDefCreator.initialize(dummyConfig, dummyPlugins); @@ -111,8 +111,7 @@ static class MockBackendGlobalState extends BackendGlobalState { * @param luceneServerConfiguration server config * @throws IOException on filesystem error */ - public MockBackendGlobalState(LuceneServerConfiguration luceneServerConfiguration) - throws IOException { + public MockBackendGlobalState(NrtsearchConfig luceneServerConfiguration) throws IOException { super(luceneServerConfiguration, null); } @@ -138,7 +137,7 @@ public String getIndexId() { } } - private LuceneServerConfiguration getConfig() throws IOException { + private NrtsearchConfig getConfig() throws IOException { String configFile = String.join( "\n", @@ -146,10 +145,10 @@ private LuceneServerConfiguration getConfig() throws IOException { " backendType: LOCAL", "stateDir: " + folder.newFolder("state").getAbsolutePath(), "indexDir: " + folder.newFolder("index").getAbsolutePath()); - return new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); } - private LuceneServerConfiguration getConfigWithLiveSettingsOverrides() throws IOException { + private NrtsearchConfig getConfigWithLiveSettingsOverrides() throws IOException { String configFile = String.join( "\n", @@ -161,7 +160,7 @@ private LuceneServerConfiguration getConfigWithLiveSettingsOverrides() throws IO " test_index:", " sliceMaxDocs: 1", " virtualShards: 100"); - return new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); } @Test @@ -730,8 +729,7 @@ public void testUseLocalBackend() throws IOException { " backendType: LOCAL", "stateDir: " + folder.newFolder("state").getAbsolutePath(), "indexDir: " + folder.newFolder("index").getAbsolutePath()); - LuceneServerConfiguration config = - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + NrtsearchConfig config = new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); BackendGlobalState backendGlobalState = new BackendGlobalState(config, null); assertTrue(backendGlobalState.getStateBackend() instanceof LocalStateBackend); } @@ -747,8 +745,7 @@ public void testUseRemoteBackend() throws IOException { " readOnly: false", "stateDir: " + folder.newFolder("state").getAbsolutePath(), "indexDir: " + folder.newFolder("index").getAbsolutePath()); - LuceneServerConfiguration config = - new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + NrtsearchConfig config = new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); Path tmpStateFolder = Paths.get(folder.getRoot().getAbsolutePath(), StateUtils.GLOBAL_STATE_FOLDER); diff --git a/src/test/java/com/yelp/nrtsearch/server/state/GlobalStateTest.java b/src/test/java/com/yelp/nrtsearch/server/state/GlobalStateTest.java index 316cbe07f..60b07e67c 100644 --- a/src/test/java/com/yelp/nrtsearch/server/state/GlobalStateTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/state/GlobalStateTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import java.io.ByteArrayInputStream; import java.io.IOException; import org.junit.Rule; @@ -29,8 +29,8 @@ public class GlobalStateTest { @Rule public final TemporaryFolder folder = new TemporaryFolder(); - private LuceneServerConfiguration getConfig(String config) { - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + private NrtsearchConfig getConfig(String config) { + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } @Test @@ -41,7 +41,7 @@ public void testCreateBackendGlobalState() throws IOException { "stateConfig:", " backendType: LOCAL", "stateDir: " + folder.getRoot().getAbsolutePath()); - LuceneServerConfiguration configuration = getConfig(configFile); + NrtsearchConfig configuration = getConfig(configFile); GlobalState globalState = GlobalState.createState(configuration, null); assertTrue(globalState instanceof BackendGlobalState); } @@ -49,7 +49,7 @@ public void testCreateBackendGlobalState() throws IOException { @Test public void testGetGeneration() throws IOException { String configFile = String.join("\n", "stateConfig:", " backendType: LOCAL"); - LuceneServerConfiguration configuration = getConfig(configFile); + NrtsearchConfig configuration = getConfig(configFile); GlobalState globalState = GlobalState.createState(configuration, null); long gen = globalState.getGeneration(); assertTrue(gen > 0); diff --git a/src/test/java/com/yelp/nrtsearch/server/state/backend/LocalStateBackendTest.java b/src/test/java/com/yelp/nrtsearch/server/state/backend/LocalStateBackendTest.java index d847d3ae6..9d46d3834 100644 --- a/src/test/java/com/yelp/nrtsearch/server/state/backend/LocalStateBackendTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/state/backend/LocalStateBackendTest.java @@ -28,7 +28,7 @@ import com.google.protobuf.DoubleValue; import com.google.protobuf.Int32Value; import com.google.protobuf.StringValue; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.GlobalStateInfo; import com.yelp.nrtsearch.server.grpc.IndexGlobalState; import com.yelp.nrtsearch.server.grpc.IndexLiveSettings; @@ -52,19 +52,19 @@ public class LocalStateBackendTest { @Rule public final TemporaryFolder folder = new TemporaryFolder(); - private LuceneServerConfiguration getConfig() throws IOException { + private NrtsearchConfig getConfig() throws IOException { String configFile = String.join( "\n", "stateConfig:", " backendType: LOCAL", "stateDir: " + folder.getRoot().getAbsolutePath()); - return new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); } private GlobalState getMockGlobalState() throws IOException { GlobalState mockState = mock(GlobalState.class); - LuceneServerConfiguration serverConfiguration = getConfig(); + NrtsearchConfig serverConfiguration = getConfig(); when(mockState.getConfiguration()).thenReturn(serverConfiguration); when(mockState.getStateDir()).thenReturn(Paths.get(serverConfiguration.getStateDir())); return mockState; diff --git a/src/test/java/com/yelp/nrtsearch/server/state/backend/RemoteStateBackendTest.java b/src/test/java/com/yelp/nrtsearch/server/state/backend/RemoteStateBackendTest.java index b7348dbbb..8a908b30c 100644 --- a/src/test/java/com/yelp/nrtsearch/server/state/backend/RemoteStateBackendTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/state/backend/RemoteStateBackendTest.java @@ -29,7 +29,7 @@ import com.google.protobuf.DoubleValue; import com.google.protobuf.Int32Value; import com.google.protobuf.StringValue; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.GlobalStateInfo; import com.yelp.nrtsearch.server.grpc.IndexGlobalState; import com.yelp.nrtsearch.server.grpc.IndexLiveSettings; @@ -67,7 +67,7 @@ public void setup() throws IOException { remoteBackend = new S3Backend(TEST_BUCKET, false, s3Provider.getAmazonS3()); } - private LuceneServerConfiguration getConfig(boolean readOnly) throws IOException { + private NrtsearchConfig getConfig(boolean readOnly) throws IOException { String configFile = String.join( "\n", @@ -77,12 +77,12 @@ private LuceneServerConfiguration getConfig(boolean readOnly) throws IOException " readOnly: " + readOnly, "stateDir: " + folder.getRoot().getAbsolutePath(), "serviceName: " + TEST_SERVICE_NAME); - return new LuceneServerConfiguration(new ByteArrayInputStream(configFile.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(configFile.getBytes())); } private GlobalState getMockGlobalState(boolean readOnly) throws IOException { GlobalState mockState = mock(GlobalState.class); - LuceneServerConfiguration serverConfiguration = getConfig(readOnly); + NrtsearchConfig serverConfiguration = getConfig(readOnly); when(mockState.getConfiguration()).thenReturn(serverConfiguration); when(mockState.getStateDir()).thenReturn(Paths.get(serverConfiguration.getStateDir())); when(mockState.getRemoteBackend()).thenReturn(remoteBackend); diff --git a/src/test/java/com/yelp/nrtsearch/server/utils/LuceneServerTestConfigurationFactory.java b/src/test/java/com/yelp/nrtsearch/server/utils/LuceneServerTestConfigurationFactory.java index 5ca8f6a3d..7156f845e 100644 --- a/src/test/java/com/yelp/nrtsearch/server/utils/LuceneServerTestConfigurationFactory.java +++ b/src/test/java/com/yelp/nrtsearch/server/utils/LuceneServerTestConfigurationFactory.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.server.utils; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Mode; import java.io.ByteArrayInputStream; import java.io.File; @@ -25,12 +25,11 @@ public class LuceneServerTestConfigurationFactory { static AtomicLong atomicLong = new AtomicLong(); - public static LuceneServerConfiguration getConfig(Mode mode, File dataRootDir) { + public static NrtsearchConfig getConfig(Mode mode, File dataRootDir) { return getConfig(mode, dataRootDir, ""); } - public static LuceneServerConfiguration getConfig( - Mode mode, File dataRootDir, String extraConfig) { + public static NrtsearchConfig getConfig(Mode mode, File dataRootDir, String extraConfig) { String dirNum = String.valueOf(atomicLong.addAndGet(1)); if (mode.equals(Mode.STANDALONE)) { String stateDir = @@ -46,7 +45,7 @@ public static LuceneServerConfiguration getConfig( "port: " + (9700 + atomicLong.intValue()), "replicationPort: " + (17000 + atomicLong.intValue()), extraConfig); - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } else if (mode.equals(Mode.PRIMARY)) { String stateDir = Paths.get(dataRootDir.getAbsolutePath(), "primary", dirNum, "state").toString(); @@ -61,7 +60,7 @@ public static LuceneServerConfiguration getConfig( "port: " + 9900, "replicationPort: " + 9001, extraConfig); - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } else if (mode.equals(Mode.REPLICA)) { String stateDir = Paths.get(dataRootDir.getAbsolutePath(), "replica", dirNum, "state").toString(); @@ -76,7 +75,7 @@ public static LuceneServerConfiguration getConfig( "port: " + 9902, "replicationPort: " + 9003, extraConfig); - return new LuceneServerConfiguration(new ByteArrayInputStream(config.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(config.getBytes())); } throw new RuntimeException("Invalid mode %s, cannot build config" + mode); } diff --git a/src/test/java/com/yelp/nrtsearch/server/warming/WarmerTest.java b/src/test/java/com/yelp/nrtsearch/server/warming/WarmerTest.java index ec80719da..0f163739a 100644 --- a/src/test/java/com/yelp/nrtsearch/server/warming/WarmerTest.java +++ b/src/test/java/com/yelp/nrtsearch/server/warming/WarmerTest.java @@ -21,7 +21,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import com.amazonaws.services.s3.AmazonS3; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.Query; import com.yelp.nrtsearch.server.grpc.SearchRequest; import com.yelp.nrtsearch.server.grpc.TermQuery; @@ -61,8 +61,7 @@ public class WarmerTest { @Before public void setup() throws IOException { String configStr = "bucketName: " + bucketName; - LuceneServerConfiguration config = - new LuceneServerConfiguration(new ByteArrayInputStream(configStr.getBytes())); + NrtsearchConfig config = new NrtsearchConfig(new ByteArrayInputStream(configStr.getBytes())); s3 = s3Provider.getAmazonS3(); remoteBackend = new S3Backend(config, s3); warmer = new Warmer(remoteBackend, service, index, 2); diff --git a/src/test/java/com/yelp/nrtsearch/test_utils/NrtsearchTest.java b/src/test/java/com/yelp/nrtsearch/test_utils/NrtsearchTest.java index 0b9a0041f..c8c3c3bc4 100644 --- a/src/test/java/com/yelp/nrtsearch/test_utils/NrtsearchTest.java +++ b/src/test/java/com/yelp/nrtsearch/test_utils/NrtsearchTest.java @@ -20,9 +20,11 @@ import static com.yelp.nrtsearch.test_utils.DefaultTestProperties.S3_BUCKET_NAME; import com.amazonaws.services.s3.AmazonS3; +import com.yelp.nrtsearch.module.TestNrtsearchModule; import com.yelp.nrtsearch.server.ServerTestCase; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer; import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.file.Path; @@ -38,10 +40,9 @@ /** * Base class for tests which need to initialize an Nrtsearch instance. Unlike {@link * ServerTestCase} which directly creates a gRPC server using {@link - * com.yelp.nrtsearch.server.grpc.LuceneServer.LuceneServerImpl}, this class creates and starts - * {@link com.yelp.nrtsearch.server.grpc.LuceneServer} using a custom guice module ({@link - * com.yelp.nrtsearch.module.TestLuceneServerModule}. This class is useful for tests which require - * testing the initialization path of {@link com.yelp.nrtsearch.server.grpc.LuceneServer}. + * NrtsearchServer.LuceneServerImpl}, this class creates and starts {@link NrtsearchServer} using a + * custom guice module ({@link TestNrtsearchModule}. This class is useful for tests which require + * testing the initialization path of {@link NrtsearchServer}. */ public class NrtsearchTest { @@ -82,11 +83,11 @@ protected Path getPluginSearchPath() { /** * Override this method to add any additional configuration which will be used to build {@link - * LuceneServerConfiguration} for the test Nrtsearch instance. When overriding this method - * remember to call {@code super.addNrtsearchConfigs(config)} so that the default configs get - * added as well, unless you don't need the defaults. + * NrtsearchConfig} for the test Nrtsearch instance. When overriding this method remember to call + * {@code super.addNrtsearchConfigs(config)} so that the default configs get added as well, unless + * you don't need the defaults. * - * @param config A {@link Map} which will be used to built {@link LuceneServerConfiguration} + * @param config A {@link Map} which will be used to built {@link NrtsearchConfig} */ protected void addNrtsearchConfigs(Map config) { config.put("port", PORT); @@ -102,7 +103,7 @@ protected void addNrtsearchConfigs(Map config) { } } - private LuceneServerConfiguration getConfig() { + private NrtsearchConfig getConfig() { Map config = new HashMap<>(); addNrtsearchConfigs(config); @@ -111,15 +112,15 @@ private LuceneServerConfiguration getConfig() { options.setPrettyFlow(false); String yamlConfig = yaml.dump(config); - return new LuceneServerConfiguration(new ByteArrayInputStream(yamlConfig.getBytes())); + return new NrtsearchConfig(new ByteArrayInputStream(yamlConfig.getBytes())); } /** - * Get the {@link LuceneServerClient} for the test Nrtsearch instance + * Get the {@link NrtsearchClient} for the test Nrtsearch instance * - * @return {@link LuceneServerClient} + * @return {@link NrtsearchClient} */ - protected LuceneServerClient getClient() { + protected NrtsearchClient getClient() { return testLuceneServer.getClient(); } diff --git a/src/test/java/com/yelp/nrtsearch/test_utils/TestLuceneServer.java b/src/test/java/com/yelp/nrtsearch/test_utils/TestLuceneServer.java index 28a45d7b0..42fc1946c 100644 --- a/src/test/java/com/yelp/nrtsearch/test_utils/TestLuceneServer.java +++ b/src/test/java/com/yelp/nrtsearch/test_utils/TestLuceneServer.java @@ -18,25 +18,25 @@ import com.amazonaws.services.s3.AmazonS3; import com.google.inject.Guice; import com.google.inject.Injector; -import com.yelp.nrtsearch.module.TestLuceneServerModule; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; -import com.yelp.nrtsearch.server.grpc.LuceneServer; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.module.TestNrtsearchModule; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchServer; import java.io.IOException; import org.junit.rules.ExternalResource; /** - * A JUnit {@link org.junit.Rule} that creates a {@link LuceneServer} instance and starts the grpc - * server from it. After the test it will delete the index data and stop the server. + * A JUnit {@link org.junit.Rule} that creates a {@link NrtsearchServer} instance and starts the + * grpc server from it. After the test it will delete the index data and stop the server. */ public class TestLuceneServer extends ExternalResource { - private final LuceneServerConfiguration luceneServerConfiguration; + private final NrtsearchConfig luceneServerConfiguration; private final AmazonS3 amazonS3; - private LuceneServer luceneServer; - private LuceneServerClient client; + private NrtsearchServer luceneServer; + private NrtsearchClient client; - public TestLuceneServer(LuceneServerConfiguration luceneServerConfiguration, AmazonS3 amazonS3) { + public TestLuceneServer(NrtsearchConfig luceneServerConfiguration, AmazonS3 amazonS3) { this.luceneServerConfiguration = luceneServerConfiguration; this.amazonS3 = amazonS3; } @@ -44,7 +44,7 @@ public TestLuceneServer(LuceneServerConfiguration luceneServerConfiguration, Ama @Override protected void before() throws Throwable { this.luceneServer = createTestServer(); - this.client = new LuceneServerClient("localhost", luceneServerConfiguration.getPort()); + this.client = new NrtsearchClient("localhost", luceneServerConfiguration.getPort()); } @Override @@ -54,14 +54,14 @@ protected void after() { luceneServer.stop(); } - protected LuceneServerClient getClient() { + protected NrtsearchClient getClient() { return client; } - private LuceneServer createTestServer() throws IOException { + private NrtsearchServer createTestServer() throws IOException { Injector injector = - Guice.createInjector(new TestLuceneServerModule(luceneServerConfiguration, amazonS3)); - LuceneServer luceneServer = injector.getInstance(LuceneServer.class); + Guice.createInjector(new TestNrtsearchModule(luceneServerConfiguration, amazonS3)); + NrtsearchServer luceneServer = injector.getInstance(NrtsearchServer.class); luceneServer.start(); return luceneServer; } diff --git a/src/test/java/com/yelp/nrtsearch/tools/cli/CreateIndexCommandTest.java b/src/test/java/com/yelp/nrtsearch/tools/cli/CreateIndexCommandTest.java index 962ad177a..166018f52 100644 --- a/src/test/java/com/yelp/nrtsearch/tools/cli/CreateIndexCommandTest.java +++ b/src/test/java/com/yelp/nrtsearch/tools/cli/CreateIndexCommandTest.java @@ -56,7 +56,7 @@ private TestServer getTestServer() throws IOException { public void testCreateIndex() throws IOException { TestServer server = getTestServer(); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", @@ -76,7 +76,7 @@ public void testCreateIndex() throws IOException { public void testCreateIndexWithSettings() throws IOException { TestServer server = getTestServer(); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", @@ -99,7 +99,7 @@ public void testCreateIndexWithSettings() throws IOException { public void testCreateIndexWithLiveSettings() throws IOException { TestServer server = getTestServer(); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", @@ -122,7 +122,7 @@ public void testCreateIndexWithLiveSettings() throws IOException { public void testCreateIndexWithFields() throws IOException { TestServer server = getTestServer(); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", @@ -154,7 +154,7 @@ public void testCreateIndexWithFields() throws IOException { public void testCreateIndexWithAll() throws IOException { TestServer server = getTestServer(); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", @@ -191,7 +191,7 @@ public void testCreateIndexWithAll() throws IOException { public void testCreateAndStartIndex() throws IOException { TestServer server = getTestServer(); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", diff --git a/src/test/java/com/yelp/nrtsearch/tools/cli/IndicesCommandTest.java b/src/test/java/com/yelp/nrtsearch/tools/cli/IndicesCommandTest.java index 14b950dfa..454e2df1e 100644 --- a/src/test/java/com/yelp/nrtsearch/tools/cli/IndicesCommandTest.java +++ b/src/test/java/com/yelp/nrtsearch/tools/cli/IndicesCommandTest.java @@ -80,7 +80,7 @@ public void testIndices() { } private int runIndicesCommand() { - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); return cmd.execute( "--hostname=localhost", "--port=" + getGrpcServer().getGlobalState().getPort(), "indices"); } diff --git a/src/test/java/com/yelp/nrtsearch/tools/cli/LiveSettingsV2CommandTest.java b/src/test/java/com/yelp/nrtsearch/tools/cli/LiveSettingsV2CommandTest.java index fdf20a21c..23c683a3c 100644 --- a/src/test/java/com/yelp/nrtsearch/tools/cli/LiveSettingsV2CommandTest.java +++ b/src/test/java/com/yelp/nrtsearch/tools/cli/LiveSettingsV2CommandTest.java @@ -53,7 +53,7 @@ public void testVerboseMetrics() throws IOException { assertFalse(server.getGlobalState().getIndex("test_index").getVerboseMetrics()); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", @@ -99,7 +99,7 @@ public void testVerboseMetrics_invalid() throws IOException { server.createSimpleIndex("test_index"); server.startIndexV2(StartIndexV2Request.newBuilder().setIndexName("test_index").build()); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", @@ -119,7 +119,7 @@ public void testSetsSettings() throws IOException { assertEquals( 0.0, server.getGlobalState().getIndex("test_index").getDefaultSearchTimeoutSec(), 0); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", @@ -146,7 +146,7 @@ public void testSetsLocalSettings() throws IOException { assertEquals( 0.0, server.getGlobalState().getIndex("test_index").getDefaultSearchTimeoutSec(), 0); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", diff --git a/src/test/java/com/yelp/nrtsearch/tools/cli/ReadyCommandTest.java b/src/test/java/com/yelp/nrtsearch/tools/cli/ReadyCommandTest.java index 474ec4314..d9067fa37 100644 --- a/src/test/java/com/yelp/nrtsearch/tools/cli/ReadyCommandTest.java +++ b/src/test/java/com/yelp/nrtsearch/tools/cli/ReadyCommandTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.CreateIndexRequest; import com.yelp.nrtsearch.server.grpc.GrpcServer; import com.yelp.nrtsearch.server.grpc.Mode; @@ -48,7 +48,7 @@ public void cleanup() { private GrpcServer server; private void startServer() throws IOException { - LuceneServerConfiguration luceneServerPrimaryConfiguration = + NrtsearchConfig luceneServerPrimaryConfiguration = LuceneServerTestConfigurationFactory.getConfig(Mode.PRIMARY, folder.getRoot()); server = new GrpcServer( @@ -77,7 +77,7 @@ private void startIndex(String indexName) { @Test public void testNoServer() { - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute("--hostname=localhost", "--port=12345", "ready"); assertEquals(1, exitCode); } @@ -85,7 +85,7 @@ public void testNoServer() { @Test public void testNoIndices() throws IOException { startServer(); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute("--hostname=localhost", "--port=" + server.getGlobalState().getPort(), "ready"); assertEquals(0, exitCode); @@ -124,7 +124,7 @@ public void testMultipleIndices() throws IOException { verifyIndicesReady("test_index,test_index_2", 0); verifyIndicesReady("test_index,test_index_3", 1); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute("--hostname=localhost", "--port=" + server.getGlobalState().getPort(), "ready"); assertEquals(0, exitCode); @@ -144,14 +144,14 @@ public void testSomeIndicesReady() throws IOException { verifyIndicesReady("test_index,test_index_2", 1); verifyIndicesReady("test_index,test_index_3", 0); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute("--hostname=localhost", "--port=" + server.getGlobalState().getPort(), "ready"); assertEquals(0, exitCode); } private void verifyIndicesReady(String indices, int expectedExitCode) { - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", diff --git a/src/test/java/com/yelp/nrtsearch/tools/cli/StartIndexV2CommandTest.java b/src/test/java/com/yelp/nrtsearch/tools/cli/StartIndexV2CommandTest.java index b4badfb29..bbcf2a209 100644 --- a/src/test/java/com/yelp/nrtsearch/tools/cli/StartIndexV2CommandTest.java +++ b/src/test/java/com/yelp/nrtsearch/tools/cli/StartIndexV2CommandTest.java @@ -52,7 +52,7 @@ public void testStartIndexV2() throws IOException { assertTrue(server.indices().contains("test_index")); assertFalse(server.isStarted("test_index")); - CommandLine cmd = new CommandLine(new LuceneClientCommand()); + CommandLine cmd = new CommandLine(new NrtsearchClientCommand()); int exitCode = cmd.execute( "--hostname=localhost", diff --git a/src/test/java/com/yelp/nrtsearch/yelp_reviews/YelpReviewsTest.java b/src/test/java/com/yelp/nrtsearch/yelp_reviews/YelpReviewsTest.java index b88a9699a..e24376444 100644 --- a/src/test/java/com/yelp/nrtsearch/yelp_reviews/YelpReviewsTest.java +++ b/src/test/java/com/yelp/nrtsearch/yelp_reviews/YelpReviewsTest.java @@ -18,7 +18,7 @@ import com.google.gson.Gson; import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.util.JsonFormat; -import com.yelp.nrtsearch.server.config.LuceneServerConfiguration; +import com.yelp.nrtsearch.server.config.NrtsearchConfig; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; import com.yelp.nrtsearch.server.grpc.CreateIndexRequest; import com.yelp.nrtsearch.server.grpc.CreateIndexResponse; @@ -29,8 +29,8 @@ import com.yelp.nrtsearch.server.grpc.HealthCheckResponse; import com.yelp.nrtsearch.server.grpc.LiveSettingsRequest; import com.yelp.nrtsearch.server.grpc.LiveSettingsResponse; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; import com.yelp.nrtsearch.server.grpc.Mode; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import com.yelp.nrtsearch.server.grpc.ReplicationServerClient; import com.yelp.nrtsearch.server.grpc.SearchRequest; import com.yelp.nrtsearch.server.grpc.SearchResponse; @@ -257,10 +257,10 @@ public static void main(String[] args) throws IOException, InterruptedException HostPort primaryHostPort = new HostPort(getLuceneServerPrimaryConfigurationYaml()); HostPort secondaryHostPort = new HostPort(getLuceneServerReplicaConfigurationYaml()); - LuceneServerClient primaryServerClient = - new LuceneServerClient(primaryHostPort.hostName, primaryHostPort.port); - LuceneServerClient secondaryServerClient = - new LuceneServerClient(secondaryHostPort.hostName, secondaryHostPort.port); + NrtsearchClient primaryServerClient = + new NrtsearchClient(primaryHostPort.hostName, primaryHostPort.port); + NrtsearchClient secondaryServerClient = + new NrtsearchClient(secondaryHostPort.hostName, secondaryHostPort.port); // healthcheck, make sure servers are up ensureServersUp(primaryServerClient); @@ -367,8 +367,7 @@ public static void main(String[] args) throws IOException, InterruptedException } } - public static void startIndex( - LuceneServerClient serverClient, StartIndexRequest startIndexRequest) { + public static void startIndex(NrtsearchClient serverClient, StartIndexRequest startIndexRequest) { StartIndexResponse startIndexResponse = serverClient.getBlockingStub().startIndex(startIndexRequest); logger.info( @@ -379,7 +378,7 @@ public static void startIndex( startIndexResponse.getStartTimeMS()); } - private static void settings(LuceneServerClient serverClient, ServerType serverType) + private static void settings(NrtsearchClient serverClient, ServerType serverType) throws IOException { String settingsJson = readResourceAsString("settings.json", serverType); SettingsRequest settingsRequest = getSettings(settingsJson); @@ -387,7 +386,7 @@ private static void settings(LuceneServerClient serverClient, ServerType serverT logger.info(settingsResponse.getResponse()); } - private static void registerFields(LuceneServerClient serverClient) throws IOException { + private static void registerFields(NrtsearchClient serverClient) throws IOException { String registerFieldsJson = readResourceAsString("register_fields.json", ServerType.unknown); FieldDefRequest fieldDefRequest = getFieldDefRequest(registerFieldsJson); FieldDefResponse fieldDefResponse = @@ -395,7 +394,7 @@ private static void registerFields(LuceneServerClient serverClient) throws IOExc logger.info(fieldDefResponse.getResponse()); } - private static void liveSettings(LuceneServerClient serverClient) { + private static void liveSettings(NrtsearchClient serverClient) { LiveSettingsRequest liveSettingsRequest = LiveSettingsRequest.newBuilder() .setIndexName(INDEX_NAME) @@ -407,7 +406,7 @@ private static void liveSettings(LuceneServerClient serverClient) { logger.info(liveSettingsResponse.getResponse()); } - private static void createIndex(LuceneServerClient serverClient) { + private static void createIndex(NrtsearchClient serverClient) { CreateIndexResponse response = serverClient .getBlockingStub() @@ -490,8 +489,8 @@ public String toString() { } HostPort(String confiFileName) throws FileNotFoundException { - LuceneServerConfiguration luceneServerConfiguration = - new LuceneServerConfiguration(new FileInputStream(confiFileName)); + NrtsearchConfig luceneServerConfiguration = + new NrtsearchConfig(new FileInputStream(confiFileName)); this.hostName = luceneServerConfiguration.getHostName(); this.port = luceneServerConfiguration.getPort(); this.replicationPort = luceneServerConfiguration.getReplicationPort(); @@ -524,7 +523,7 @@ private static SettingsRequest getSettings(String jsonStr) { return settingsRequest; } - private static void ensureServersUp(LuceneServerClient serverClient) throws InterruptedException { + private static void ensureServersUp(NrtsearchClient serverClient) throws InterruptedException { int retry = 0; final int RETRY_LIMIT = 10; while (retry < RETRY_LIMIT) { @@ -570,10 +569,10 @@ public AddDocumentRequest buildOneDoc(String line, Gson gson) { private static class SearchTask implements Callable { - private final LuceneServerClient luceneServerClient; + private final NrtsearchClient luceneServerClient; private final AtomicBoolean indexingDone; - SearchTask(LuceneServerClient luceneServerClient, AtomicBoolean indexingDone) { + SearchTask(NrtsearchClient luceneServerClient, AtomicBoolean indexingDone) { this.luceneServerClient = luceneServerClient; this.indexingDone = indexingDone; } diff --git a/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/DocumentGeneratorAndIndexer.java b/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/DocumentGeneratorAndIndexer.java index a3be8d301..e18a370de 100644 --- a/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/DocumentGeneratorAndIndexer.java +++ b/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/DocumentGeneratorAndIndexer.java @@ -17,7 +17,7 @@ import com.google.gson.Gson; import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.util.concurrent.Callable; import java.util.stream.Stream; import org.slf4j.Logger; @@ -27,13 +27,13 @@ public class DocumentGeneratorAndIndexer implements Callable { private final Stream lines; private final Gson gson = new Gson(); - final LuceneServerClient luceneServerClient; + final NrtsearchClient luceneServerClient; private static final Logger logger = LoggerFactory.getLogger(DocumentGeneratorAndIndexer.class.getName()); private final OneDocBuilder oneDocBuilder; public DocumentGeneratorAndIndexer( - OneDocBuilder oneDocBuilder, Stream lines, LuceneServerClient luceneServerClient) { + OneDocBuilder oneDocBuilder, Stream lines, NrtsearchClient luceneServerClient) { this.lines = lines; this.luceneServerClient = luceneServerClient; this.oneDocBuilder = oneDocBuilder; diff --git a/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/IndexerTask.java b/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/IndexerTask.java index f4c1b2cec..109b7cc76 100644 --- a/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/IndexerTask.java +++ b/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/IndexerTask.java @@ -17,7 +17,7 @@ import com.yelp.nrtsearch.server.grpc.AddDocumentRequest; import com.yelp.nrtsearch.server.grpc.AddDocumentResponse; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import io.grpc.stub.StreamObserver; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -30,7 +30,7 @@ public class IndexerTask { private String genId; public Long index( - LuceneServerClient luceneServerClient, Stream addDocumentRequestStream) + NrtsearchClient luceneServerClient, Stream addDocumentRequestStream) throws Exception { String threadId = Thread.currentThread().getName() + Thread.currentThread().getId(); diff --git a/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/ParallelDocumentIndexer.java b/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/ParallelDocumentIndexer.java index e9fc65fea..1a2480f9d 100644 --- a/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/ParallelDocumentIndexer.java +++ b/src/test/java/com/yelp/nrtsearch/yelp_reviews/utils/ParallelDocumentIndexer.java @@ -15,7 +15,7 @@ */ package com.yelp.nrtsearch.yelp_reviews.utils; -import com.yelp.nrtsearch.server.grpc.LuceneServerClient; +import com.yelp.nrtsearch.server.grpc.NrtsearchClient; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; @@ -37,7 +37,7 @@ public static List> buildAndIndexDocs( OneDocBuilder oneDocBuilder, Path path, ExecutorService executorService, - LuceneServerClient luceneServerClient) + NrtsearchClient luceneServerClient) throws IOException, InterruptedException { try (BufferedReader br = new BufferedReader(new FileReader(path.toFile()))) { String line; @@ -71,7 +71,7 @@ public static List> buildAndIndexDocs( private static Future submitTask( OneDocBuilder oneDocBuilder, ExecutorService executorService, - LuceneServerClient luceneServerClient, + NrtsearchClient luceneServerClient, List rawLines) throws InterruptedException { Future genIdFuture;