use of com.yelp.nrtsearch.server.plugins.Plugin in project nrtsearch by Yelp.
the class FieldDefCreator method initialize.
/**
* Initialize singleton instance of {@link FieldDefCreator}. Registers all the standard field
* types and any additional types provided by {@link FieldTypePlugin}s.
*
* @param configuration service configuration
* @param plugins list of loaded plugins
*/
public static void initialize(LuceneServerConfiguration configuration, Iterable<Plugin> plugins) {
instance = new FieldDefCreator(configuration);
for (Plugin plugin : plugins) {
if (plugin instanceof FieldTypePlugin) {
FieldTypePlugin fieldTypePlugin = (FieldTypePlugin) plugin;
instance.register(fieldTypePlugin.getFieldTypes());
}
}
}
use of com.yelp.nrtsearch.server.plugins.Plugin in project nrtsearch by Yelp.
the class LuceneServer method start.
private void start() throws IOException {
GlobalState globalState = GlobalState.createState(luceneServerConfiguration, incArchiver);
registerMetrics(globalState);
List<Plugin> plugins = pluginsService.loadPlugins();
String serviceName = luceneServerConfiguration.getServiceName();
String nodeName = luceneServerConfiguration.getNodeName();
// Otherwise, this will be done during GlobalState initialization.
if (luceneServerConfiguration.getStateConfig().useLegacyStateManagement() && luceneServerConfiguration.getRestoreState()) {
logger.info("Loading state for any previously backed up indexes");
List<String> indexes = RestoreStateHandler.restore(archiver, incArchiver, globalState, luceneServerConfiguration.getServiceName(), luceneServerConfiguration.getRestoreFromIncArchiver());
for (String index : indexes) {
logger.info("Loaded state for index " + index);
}
}
LuceneServerMonitoringServerInterceptor monitoringInterceptor = LuceneServerMonitoringServerInterceptor.create(Configuration.allMetrics().withLatencyBuckets(luceneServerConfiguration.getMetricsBuckets()).withCollectorRegistry(collectorRegistry), serviceName, nodeName);
/* The port on which the server should run */
server = ServerBuilder.forPort(luceneServerConfiguration.getPort()).addService(ServerInterceptors.intercept(new LuceneServerImpl(globalState, luceneServerConfiguration, archiver, incArchiver, collectorRegistry, plugins), monitoringInterceptor)).addService(ProtoReflectionService.newInstance()).executor(ThreadPoolExecutorFactory.getThreadPoolExecutor(ThreadPoolExecutorFactory.ExecutorType.LUCENESERVER, luceneServerConfiguration.getThreadPoolConfiguration())).maxInboundMessageSize(MAX_MESSAGE_BYTES_SIZE).compressorRegistry(LuceneServerStubBuilder.COMPRESSOR_REGISTRY).decompressorRegistry(LuceneServerStubBuilder.DECOMPRESSOR_REGISTRY).build().start();
logger.info("Server started, listening on " + luceneServerConfiguration.getPort() + " for messages");
if (luceneServerConfiguration.getMaxConcurrentCallsPerConnectionForReplication() != -1) {
replicationServer = NettyServerBuilder.forPort(luceneServerConfiguration.getReplicationPort()).addService(new ReplicationServerImpl(globalState)).executor(ThreadPoolExecutorFactory.getThreadPoolExecutor(ThreadPoolExecutorFactory.ExecutorType.REPLICATIONSERVER, luceneServerConfiguration.getThreadPoolConfiguration())).maxInboundMessageSize(MAX_MESSAGE_BYTES_SIZE).maxConcurrentCallsPerConnection(luceneServerConfiguration.getMaxConcurrentCallsPerConnectionForReplication()).maxConnectionAge(luceneServerConfiguration.getMaxConnectionAgeForReplication(), TimeUnit.SECONDS).maxConnectionAgeGrace(luceneServerConfiguration.getMaxConnectionAgeGraceForReplication(), TimeUnit.SECONDS).build().start();
} else {
replicationServer = ServerBuilder.forPort(luceneServerConfiguration.getReplicationPort()).addService(new ReplicationServerImpl(globalState)).executor(ThreadPoolExecutorFactory.getThreadPoolExecutor(ThreadPoolExecutorFactory.ExecutorType.REPLICATIONSERVER, luceneServerConfiguration.getThreadPoolConfiguration())).maxInboundMessageSize(MAX_MESSAGE_BYTES_SIZE).build().start();
}
logger.info("Server started, listening on " + luceneServerConfiguration.getReplicationPort() + " for replication messages");
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
logger.error("*** shutting down gRPC server since JVM is shutting down");
LuceneServer.this.stop();
logger.error("*** server shut down");
}
});
}
use of com.yelp.nrtsearch.server.plugins.Plugin in project nrtsearch by Yelp.
the class ScriptService method initialize.
/**
* Initialize the script service. Registers any {@link ScriptEngine} provided by the given {@link
* Plugin}.
*
* @param configuration server configuration
* @param plugins loaded plugins
*/
public static void initialize(LuceneServerConfiguration configuration, Iterable<Plugin> plugins) {
instance = new ScriptService(configuration);
for (Plugin plugin : plugins) {
if (plugin instanceof ScriptPlugin) {
ScriptPlugin scriptPlugin = (ScriptPlugin) plugin;
instance.register(scriptPlugin.getScriptEngines(builtInContexts));
}
}
}
use of com.yelp.nrtsearch.server.plugins.Plugin in project nrtsearch by Yelp.
the class AnalyzerCreator method initialize.
public static void initialize(LuceneServerConfiguration configuration, Iterable<Plugin> plugins) {
instance = new AnalyzerCreator(configuration);
for (Plugin plugin : plugins) {
if (plugin instanceof AnalysisPlugin) {
AnalysisPlugin analysisPlugin = (AnalysisPlugin) plugin;
instance.register(analysisPlugin.getAnalyzers());
}
}
}
Aggregations