org.elasticsearch.watcher.ResourceWatcherService Java Examples
The following examples show how to use
org.elasticsearch.watcher.ResourceWatcherService.
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: LtrQueryParserPlugin.java From elasticsearch-learning-to-rank with Apache License 2.0 | 6 votes |
@Override public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, IndexNameExpressionResolver indexNameExpressionResolver) { clusterService.addListener(event -> { for (Index i : event.indicesDeleted()) { if (IndexFeatureStore.isIndexStore(i.getName())) { caches.evict(i.getName()); } } }); return asList(caches, parserFactory); }
Example #2
Source File: OpenDistroSecuritySSLPlugin.java From deprecated-security-ssl with Apache License 2.0 | 5 votes |
@Override public Collection<Object> createComponents(Client localClient, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { final List<Object> components = new ArrayList<>(1); if(client) { return components; } final String principalExtractorClass = settings.get(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_PRINCIPAL_EXTRACTOR_CLASS, null); if(principalExtractorClass == null) { principalExtractor = new com.amazon.opendistroforelasticsearch.security.ssl.transport.DefaultPrincipalExtractor(); } else { try { log.debug("Try to load and instantiate '{}'", principalExtractorClass); Class<?> principalExtractorClazz = Class.forName(principalExtractorClass); principalExtractor = (PrincipalExtractor) principalExtractorClazz.newInstance(); } catch (Exception e) { log.error("Unable to load '{}' due to", principalExtractorClass, e); throw new ElasticsearchException(e); } } components.add(principalExtractor); return components; }
Example #3
Source File: Node.java From Elasticsearch with Apache License 2.0 | 5 votes |
private Node stop() { if (!lifecycle.moveToStopped()) { return this; } ESLogger logger = Loggers.getLogger(Node.class, settings.get("name")); logger.info("stopping ..."); injector.getInstance(TribeService.class).stop(); injector.getInstance(ResourceWatcherService.class).stop(); if (settings.getAsBoolean("http.enabled", true)) { injector.getInstance(HttpServer.class).stop(); } injector.getInstance(SnapshotsService.class).stop(); injector.getInstance(SnapshotShardsService.class).stop(); // stop any changes happening as a result of cluster state changes injector.getInstance(IndicesClusterStateService.class).stop(); // we close indices first, so operations won't be allowed on it injector.getInstance(IndexingMemoryController.class).stop(); injector.getInstance(IndicesTTLService.class).stop(); injector.getInstance(RoutingService.class).stop(); injector.getInstance(ClusterService.class).stop(); injector.getInstance(DiscoveryService.class).stop(); injector.getInstance(MonitorService.class).stop(); injector.getInstance(GatewayService.class).stop(); injector.getInstance(SearchService.class).stop(); injector.getInstance(RestController.class).stop(); injector.getInstance(TransportService.class).stop(); for (Class<? extends LifecycleComponent> plugin : pluginsService.nodeServices()) { injector.getInstance(plugin).stop(); } // we should stop this last since it waits for resources to get released // if we had scroll searchers etc or recovery going on we wait for to finish. injector.getInstance(IndicesService.class).stop(); logger.info("stopped"); return this; }
Example #4
Source File: DynamicSynonymPlugin.java From elasticsearch-analysis-dynamic-synonym with Apache License 2.0 | 5 votes |
@Override public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry) { Collection<Object> components = new ArrayList<>(); components.add(pluginComponent); return components; }
Example #5
Source File: OpenShiftElasticSearchPlugin.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
@Override public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry namedXContentRegistry) { final PluginSettings pluginSettings = new PluginSettings(settings); final IndexMappingLoader indexMappingLoader = new IndexMappingLoader(settings); final PluginClient pluginClient = new PluginClient(client, threadPool.getThreadContext()); final OpenshiftAPIService apiService = new OpenshiftAPIService(); final RequestUtils requestUtils = new RequestUtils(pluginSettings, apiService); final OpenshiftRequestContextFactory contextFactory = new OpenshiftRequestContextFactory(settings, requestUtils, apiService, threadPool.getThreadContext()); final SearchGuardSyncStrategyFactory documentFactory = new SearchGuardSyncStrategyFactory(pluginSettings); final KibanaUtils kUtils = new KibanaUtils(pluginSettings, pluginClient); final KibanaSeed seed = new KibanaSeed(pluginSettings, indexMappingLoader, pluginClient, kUtils); final ACLDocumentManager aclDocumentManager = new ACLDocumentManager(pluginClient, pluginSettings, documentFactory, threadPool); this.aclFilter = new DynamicACLFilter(pluginSettings, seed, client, threadPool, requestUtils, aclDocumentManager); PluginServiceFactory.setApiService(apiService); PluginServiceFactory.setContextFactory(contextFactory); PluginServiceFactory.setThreadContext(threadPool.getThreadContext()); PluginServiceFactory.markReady(); List<Object> list = new ArrayList<>(); list.add(aclDocumentManager); list.add(pluginSettings); list.add(indexMappingLoader); list.add(pluginClient); list.add(requestUtils); list.add(apiService); list.add(contextFactory); list.add(documentFactory); list.add(kUtils); list.add(seed); list.add(aclFilter); list.add(new FieldStatsResponseFilter(pluginClient)); list.addAll(sgPlugin.createComponents(client, clusterService, threadPool, resourceWatcherService, scriptService, namedXContentRegistry)); return list; }
Example #6
Source File: RangerElasticsearchPlugin.java From ranger with Apache License 2.0 | 5 votes |
@Override public Collection<Object> createComponents(final Client client, final ClusterService clusterService, final ThreadPool threadPool, final ResourceWatcherService resourceWatcherService, final ScriptService scriptService, final NamedXContentRegistry xContentRegistry, final Environment environment, final NodeEnvironment nodeEnvironment, final NamedWriteableRegistry namedWriteableRegistry) { addPluginConfig2Classpath(environment); rangerSecurityActionFilter = new RangerSecurityActionFilter(threadPool.getThreadContext()); return Collections.singletonList(rangerSecurityActionFilter); }
Example #7
Source File: SynonymPlugin.java From elasticsearch-analysis-synonym with Apache License 2.0 | 5 votes |
@Override public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { final Collection<Object> components = new ArrayList<>(); components.add(pluginComponent); return components; }
Example #8
Source File: ClusteringPlugin.java From elasticsearch-carrot2 with Apache License 2.0 | 5 votes |
@Override public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry) { List<Object> components = new ArrayList<>(); if (pluginEnabled && !transportClient) { components.add(new ClusteringContext(environment, reorderAlgorithms(algorithmProviders), new LinkedHashMap<>(languageComponentProviders))); } return components; }
Example #9
Source File: ScriptService.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Inject public ScriptService(Settings settings, Environment env, Set<ScriptEngineService> scriptEngines, ResourceWatcherService resourceWatcherService, ScriptContextRegistry scriptContextRegistry) throws IOException { super(settings); this.parseFieldMatcher = new ParseFieldMatcher(settings); if (Strings.hasLength(settings.get(DISABLE_DYNAMIC_SCRIPTING_SETTING))) { throw new IllegalArgumentException(DISABLE_DYNAMIC_SCRIPTING_SETTING + " is not a supported setting, replace with fine-grained script settings. \n" + "Dynamic scripts can be enabled for all languages and all operations by replacing `script.disable_dynamic: false` with `script.inline: on` and `script.indexed: on` in elasticsearch.yml"); } this.scriptEngines = scriptEngines; this.scriptContextRegistry = scriptContextRegistry; int cacheMaxSize = settings.getAsInt(SCRIPT_CACHE_SIZE_SETTING, SCRIPT_CACHE_SIZE_DEFAULT); TimeValue cacheExpire = settings.getAsTime(SCRIPT_CACHE_EXPIRE_SETTING, null); logger.debug("using script cache with max_size [{}], expire [{}]", cacheMaxSize, cacheExpire); this.defaultLang = settings.get(DEFAULT_SCRIPTING_LANGUAGE_SETTING, DEFAULT_LANG); CacheBuilder cacheBuilder = CacheBuilder.newBuilder(); if (cacheMaxSize >= 0) { cacheBuilder.maximumSize(cacheMaxSize); } if (cacheExpire != null) { cacheBuilder.expireAfterAccess(cacheExpire.nanos(), TimeUnit.NANOSECONDS); } this.cache = cacheBuilder.removalListener(new ScriptCacheRemovalListener()).build(); ImmutableMap.Builder<String, ScriptEngineService> enginesByLangBuilder = ImmutableMap.builder(); ImmutableMap.Builder<String, ScriptEngineService> enginesByExtBuilder = ImmutableMap.builder(); for (ScriptEngineService scriptEngine : scriptEngines) { for (String type : scriptEngine.types()) { enginesByLangBuilder.put(type, scriptEngine); } for (String ext : scriptEngine.extensions()) { enginesByExtBuilder.put(ext, scriptEngine); } } this.scriptEnginesByLang = enginesByLangBuilder.build(); this.scriptEnginesByExt = enginesByExtBuilder.build(); this.scriptModes = new ScriptModes(this.scriptEnginesByLang, scriptContextRegistry, settings); // add file watcher for static scripts scriptsDirectory = env.scriptsFile(); if (logger.isTraceEnabled()) { logger.trace("Using scripts directory [{}] ", scriptsDirectory); } FileWatcher fileWatcher = new FileWatcher(scriptsDirectory); fileWatcher.addListener(new ScriptChangesListener()); if (settings.getAsBoolean(SCRIPT_AUTO_RELOAD_ENABLED_SETTING, true)) { // automatic reload is enabled - register scripts resourceWatcherService.add(fileWatcher); } else { // automatic reload is disable just load scripts once fileWatcher.init(); } }
Example #10
Source File: Node.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Start the node. If the node is already started, this method is no-op. */ public Node start() { if (!lifecycle.moveToStarted()) { return this; } ESLogger logger = Loggers.getLogger(Node.class, settings.get("name")); logger.info("starting ..."); // hack around dependency injection problem (for now...) injector.getInstance(Discovery.class).setRoutingService(injector.getInstance(RoutingService.class)); for (Class<? extends LifecycleComponent> plugin : pluginsService.nodeServices()) { injector.getInstance(plugin).start(); } injector.getInstance(MappingUpdatedAction.class).setClient(client); injector.getInstance(IndicesService.class).start(); injector.getInstance(IndexingMemoryController.class).start(); injector.getInstance(IndicesClusterStateService.class).start(); injector.getInstance(IndicesTTLService.class).start(); injector.getInstance(SnapshotsService.class).start(); injector.getInstance(SnapshotShardsService.class).start(); injector.getInstance(RoutingService.class).start(); injector.getInstance(SearchService.class).start(); injector.getInstance(MonitorService.class).start(); injector.getInstance(RestController.class).start(); // TODO hack around circular dependencies problems injector.getInstance(GatewayAllocator.class).setReallocation(injector.getInstance(ClusterService.class), injector.getInstance(RoutingService.class)); injector.getInstance(ResourceWatcherService.class).start(); injector.getInstance(GatewayService.class).start(); injector.getInstance(TenantManagementService.class).start(); // Start the transport service now so the publish address will be added to the local disco node in ClusterService TransportService transportService = injector.getInstance(TransportService.class); transportService.start(); injector.getInstance(ClusterService.class).start(); // start after cluster service so the local disco is known DiscoveryService discoService = injector.getInstance(DiscoveryService.class).start(); transportService.acceptIncomingRequests(); discoService.joinClusterAndWaitForInitialState(); if (settings.getAsBoolean("http.enabled", true)) { injector.getInstance(HttpServer.class).start(); } injector.getInstance(TribeService.class).start(); if (settings.getAsBoolean("node.portsfile", false)) { if (settings.getAsBoolean("http.enabled", true)) { HttpServerTransport http = injector.getInstance(HttpServerTransport.class); writePortsFile("http", http.boundAddress()); } TransportService transport = injector.getInstance(TransportService.class); writePortsFile("transport", transport.boundAddress()); } logger.info("started"); return this; }
Example #11
Source File: CustomRealmExtension.java From shield-custom-realm-example with Apache License 2.0 | 3 votes |
/** * Returns a map of the custom realms provided by this extension. The first parameter is the string representation of the realm type; * this is the value that is specified when declaring a realm in the settings. Note, the realm type cannot be one of the types * defined by X-Pack. In order to avoid a conflict, you may wish to use some prefix to your realm types. * * The second parameter is an instance of the {@link Factory} implementation. This factory class will be used to create realms of * this type that are defined in the elasticsearch settings. */ @Override public Map<String, Factory> getRealms(ResourceWatcherService resourceWatcherService) { return new MapBuilder<String, Factory>() .put(CustomRealm.TYPE, new CustomRealmFactory()) .put(CustomCachingRealm.TYPE, new CustomCachingRealmFactory()) .immutableMap(); }