Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename some LuceneServer class in the server core #756

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <p>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
Expand All @@ -35,5 +35,5 @@ public interface AnalysisComponent {
*
* @param configuration nrtsearch config accessor
*/
void initializeComponent(LuceneServerConfiguration configuration);
void initializeComponent(NrtsearchConfig configuration);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,12 +45,12 @@ public class AnalyzerCreator {

private static AnalyzerCreator instance;

private final LuceneServerConfiguration configuration;
private final NrtsearchConfig configuration;
private final Map<String, AnalysisProvider<? extends Analyzer>> analyzerMap = new HashMap<>();
private final Map<String, Class<? extends TokenFilterFactory>> tokenFilterMap = new HashMap<>();
private final Map<String, Class<? extends CharFilterFactory>> charFilterMap = new HashMap<>();

public AnalyzerCreator(LuceneServerConfiguration configuration) {
public AnalyzerCreator(NrtsearchConfig configuration) {
this.configuration = configuration;
registerAnalyzer(STANDARD, name -> new StandardAnalyzer());
registerAnalyzer(CLASSIC, name -> new ClassicAnalyzer());
Expand Down Expand Up @@ -131,7 +131,7 @@ private void registerCharFilter(
charFilterMap.put(name, filterClass);
}

public static void initialize(LuceneServerConfiguration configuration, Iterable<Plugin> plugins) {
public static void initialize(NrtsearchConfig configuration, Iterable<Plugin> plugins) {
instance = new AnalyzerCreator(configuration);
Set<String> builtInTokenFilters =
TokenFilterFactory.availableTokenFilters().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,9 +29,9 @@ public class CustomRequestProcessor {
private final Map<String, Map<String, CustomRequestPlugin.RequestProcessor>> routeMapping =
new HashMap<>();

public CustomRequestProcessor(LuceneServerConfiguration configuration) {}
public CustomRequestProcessor(NrtsearchConfig configuration) {}

public static void initialize(LuceneServerConfiguration configuration, Iterable<Plugin> plugins) {
public static void initialize(NrtsearchConfig configuration, Iterable<Plugin> plugins) {
instance = new CustomRequestProcessor(configuration);
for (Plugin plugin : plugins) {
if (plugin instanceof CustomRequestPlugin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,7 +34,7 @@ public class FieldDefCreator {

private final Map<String, FieldDefProvider<? extends FieldDef>> fieldDefMap = new HashMap<>();

public FieldDefCreator(LuceneServerConfiguration configuration) {
public FieldDefCreator(NrtsearchConfig configuration) {
register("ATOM", AtomFieldDef::new);
register("TEXT", TextFieldDef::new);
register("BOOLEAN", BooleanFieldDef::new);
Expand Down Expand Up @@ -119,7 +119,7 @@ private String getCustomFieldType(Map<String, ?> additionalProperties) {
* @param configuration service configuration
* @param plugins list of loaded plugins
*/
public static void initialize(LuceneServerConfiguration configuration, Iterable<Plugin> plugins) {
public static void initialize(NrtsearchConfig configuration, Iterable<Plugin> plugins) {
instance = new FieldDefCreator(configuration);
for (Plugin plugin : plugins) {
if (plugin instanceof FieldTypePlugin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public interface LuceneServerClientBuilder<T> {
public interface NrtsearchClientBuilder<T> {

T buildRequest(Path filePath) throws IOException;

class SettingsClientBuilder implements LuceneServerClientBuilder<SettingsRequest> {
class SettingsClientBuilder implements NrtsearchClientBuilder<SettingsRequest> {
private static final Logger logger =
LoggerFactory.getLogger(SettingsClientBuilder.class.getName());

Expand Down Expand Up @@ -70,7 +70,7 @@ public SettingsRequest buildRequest(Path filePath) throws IOException {
}
}

class SettingsV2ClientBuilder implements LuceneServerClientBuilder<SettingsV2Request> {
class SettingsV2ClientBuilder implements NrtsearchClientBuilder<SettingsV2Request> {
private static final Logger logger =
LoggerFactory.getLogger(SettingsClientBuilder.class.getName());

Expand All @@ -94,7 +94,7 @@ public SettingsV2Request buildRequest(Path filePath) throws IOException {
}
}

class StartIndexClientBuilder implements LuceneServerClientBuilder<StartIndexRequest> {
class StartIndexClientBuilder implements NrtsearchClientBuilder<StartIndexRequest> {
private static final Logger logger =
LoggerFactory.getLogger(StartIndexClientBuilder.class.getName());

Expand All @@ -116,7 +116,7 @@ public StartIndexRequest buildRequest(Path filePath) throws IOException {
}
}

class AddDocumentsClientBuilder implements LuceneServerClientBuilder<Stream<AddDocumentRequest>> {
class AddDocumentsClientBuilder implements NrtsearchClientBuilder<Stream<AddDocumentRequest>> {
private static final Logger logger =
LoggerFactory.getLogger(AddDocumentsClientBuilder.class.getName());
private final String indexName;
Expand Down Expand Up @@ -153,7 +153,7 @@ public Stream<AddDocumentRequest> buildRequest(Path filePath) {
}

class AddJsonDocumentsClientBuilder
implements LuceneServerClientBuilder<Stream<AddDocumentRequest>> {
implements NrtsearchClientBuilder<Stream<AddDocumentRequest>> {
private static final Logger logger =
LoggerFactory.getLogger(AddJsonDocumentsClientBuilder.class.getName());
private final String indexName;
Expand Down Expand Up @@ -231,7 +231,7 @@ public boolean isFinished() {
}
}

class SearchClientBuilder implements LuceneServerClientBuilder<SearchRequest> {
class SearchClientBuilder implements NrtsearchClientBuilder<SearchRequest> {
private static final Logger logger =
LoggerFactory.getLogger(SearchClientBuilder.class.getName());

Expand All @@ -253,7 +253,7 @@ public SearchRequest buildRequest(Path filePath) throws IOException {
}
}

class DeleteDocumentsBuilder implements LuceneServerClientBuilder<AddDocumentRequest> {
class DeleteDocumentsBuilder implements NrtsearchClientBuilder<AddDocumentRequest> {
private static final Logger logger =
LoggerFactory.getLogger(DeleteDocumentsBuilder.class.getName());

Expand Down
Loading
Loading