Java Code Examples for org.elasticsearch.common.inject.ModulesBuilder#createInjector()
The following examples show how to use
org.elasticsearch.common.inject.ModulesBuilder#createInjector() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlExpressions.java From crate with Apache License 2.0 | 5 votes |
public SqlExpressions(Map<RelationName, AnalyzedRelation> sources, @Nullable FieldResolver fieldResolver, User user, AbstractModule... additionalModules) { ModulesBuilder modulesBuilder = new ModulesBuilder() .add(new SessionSettingModule()) .add(new OperatorModule()) .add(new AggregationImplModule()) .add(new ScalarFunctionModule()) .add(new WindowFunctionModule()) .add(new TableFunctionModule()) .add(new PredicateModule()); if (additionalModules != null) { for (AbstractModule module : additionalModules) { modulesBuilder.add(module); } } injector = modulesBuilder.createInjector(); functions = injector.getInstance(Functions.class); coordinatorTxnCtx = new CoordinatorTxnCtx(new SessionContext(Option.NONE, user)); expressionAnalyzer = new ExpressionAnalyzer( functions, coordinatorTxnCtx, ParamTypeHints.EMPTY, new FullQualifiedNameFieldProvider( sources, ParentRelations.NO_PARENTS, coordinatorTxnCtx.sessionContext().searchPath().currentSchema()), new SubqueryAnalyzer( new RelationAnalyzer(functions, mock(Schemas.class)), new StatementAnalysisContext(ParamTypeHints.EMPTY, Operation.READ, coordinatorTxnCtx) ) ); normalizer = new EvaluatingNormalizer(functions, RowGranularity.DOC, null, fieldResolver); expressionAnalysisCtx = new ExpressionAnalysisContext(); }
Example 2
Source File: TransportClient.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Builds a new instance of the transport client. */ public TransportClient build() { Settings settings = InternalSettingsPreparer.prepareSettings(this.settings); settings = settingsBuilder() .put(NettyTransport.PING_SCHEDULE, "5s") // enable by default the transport schedule ping interval .put(settings) .put("network.server", false) .put("node.client", true) .put(CLIENT_TYPE_SETTING, CLIENT_TYPE) .build(); PluginsService pluginsService = new PluginsService(settings, null, null, pluginClasses); this.settings = pluginsService.updatedSettings(); Version version = Version.CURRENT; final ThreadPool threadPool = new ThreadPool(settings); NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(); boolean success = false; try { ModulesBuilder modules = new ModulesBuilder(); modules.add(new Version.Module(version)); // plugin modules must be added here, before others or we can get crazy injection errors... for (Module pluginModule : pluginsService.nodeModules()) { modules.add(pluginModule); } modules.add(new PluginsModule(pluginsService)); modules.add(new SettingsModule(this.settings)); modules.add(new NetworkModule(namedWriteableRegistry)); modules.add(new ClusterNameModule(this.settings)); modules.add(new ThreadPoolModule(threadPool)); modules.add(new TransportModule(this.settings, namedWriteableRegistry)); modules.add(new SearchModule() { @Override protected void configure() { // noop } }); modules.add(new ActionModule(true)); modules.add(new ClientTransportModule()); modules.add(new CircuitBreakerModule(this.settings)); pluginsService.processModules(modules); Injector injector = modules.createInjector(); final TransportService transportService = injector.getInstance(TransportService.class); transportService.start(); transportService.acceptIncomingRequests(); TransportClient transportClient = new TransportClient(injector); success = true; return transportClient; } finally { if (!success) { ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS); } } }
Example 3
Source File: TransportClient.java From elasticsearch-helper with Apache License 2.0 | 4 votes |
public TransportClient build() { Settings settings = InternalSettingsPreparer.prepareSettings(this.settings); settings = settingsBuilder() .put("transport.ping.schedule", this.settings.get("ping.interval", "30s")) .put(settings) .put("network.server", false) .put("node.client", true) .put(CLIENT_TYPE_SETTING, CLIENT_TYPE) .build(); PluginsService pluginsService = new PluginsService(settings, null, null, pluginClasses); this.settings = pluginsService.updatedSettings(); Version version = Version.CURRENT; final ThreadPool threadPool = new ThreadPool(settings); final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(); boolean success = false; try { ModulesBuilder modules = new ModulesBuilder(); modules.add(new Version.Module(version)); // plugin modules must be added here, before others or we can get crazy injection errors... for (Module pluginModule : pluginsService.nodeModules()) { modules.add(pluginModule); } modules.add(new PluginsModule(pluginsService)); modules.add(new SettingsModule(this.settings)); modules.add(new NetworkModule(namedWriteableRegistry)); modules.add(new ClusterNameModule(this.settings)); modules.add(new ThreadPoolModule(threadPool)); modules.add(new TransportModule(this.settings, namedWriteableRegistry)); modules.add(new SearchModule() { @Override protected void configure() { // noop } }); modules.add(new ActionModule(true)); modules.add(new ClientTransportModule(hostFailedListener)); modules.add(new CircuitBreakerModule(this.settings)); pluginsService.processModules(modules); Injector injector = modules.createInjector(); injector.getInstance(TransportService.class).start(); TransportClient transportClient = new TransportClient(injector); success = true; return transportClient; } finally { if (!success) { ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS); } } }