Search in sources :

Example 6 with Plugin

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());
        }
    }
}
Also used : FieldTypePlugin(com.yelp.nrtsearch.server.plugins.FieldTypePlugin) Plugin(com.yelp.nrtsearch.server.plugins.Plugin) FieldTypePlugin(com.yelp.nrtsearch.server.plugins.FieldTypePlugin)

Example 7 with Plugin

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");
        }
    });
}
Also used : ByteString(com.google.protobuf.ByteString) Plugin(com.yelp.nrtsearch.server.plugins.Plugin)

Example 8 with Plugin

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));
        }
    }
}
Also used : ScriptPlugin(com.yelp.nrtsearch.server.plugins.ScriptPlugin) Plugin(com.yelp.nrtsearch.server.plugins.Plugin) ScriptPlugin(com.yelp.nrtsearch.server.plugins.ScriptPlugin)

Example 9 with Plugin

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());
        }
    }
}
Also used : Plugin(com.yelp.nrtsearch.server.plugins.Plugin) AnalysisPlugin(com.yelp.nrtsearch.server.plugins.AnalysisPlugin) AnalysisPlugin(com.yelp.nrtsearch.server.plugins.AnalysisPlugin)

Aggregations

Plugin (com.yelp.nrtsearch.server.plugins.Plugin)9 ByteString (com.google.protobuf.ByteString)1 LuceneServerConfiguration (com.yelp.nrtsearch.server.config.LuceneServerConfiguration)1 AnalysisPlugin (com.yelp.nrtsearch.server.plugins.AnalysisPlugin)1 CollectorPlugin (com.yelp.nrtsearch.server.plugins.CollectorPlugin)1 FetchTaskPlugin (com.yelp.nrtsearch.server.plugins.FetchTaskPlugin)1 FieldTypePlugin (com.yelp.nrtsearch.server.plugins.FieldTypePlugin)1 RescorerPlugin (com.yelp.nrtsearch.server.plugins.RescorerPlugin)1 ScriptPlugin (com.yelp.nrtsearch.server.plugins.ScriptPlugin)1 SimilarityPlugin (com.yelp.nrtsearch.server.plugins.SimilarityPlugin)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 BeforeClass (org.junit.BeforeClass)1