Java Code Examples for org.elasticsearch.cluster.service.ClusterService#addListener()
The following examples show how to use
org.elasticsearch.cluster.service.ClusterService#addListener() .
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: IndicesStore.java From crate with Apache License 2.0 | 6 votes |
@Inject public IndicesStore(Settings settings, IndicesService indicesService, ClusterService clusterService, TransportService transportService, ThreadPool threadPool) { this.settings = settings; this.indicesService = indicesService; this.clusterService = clusterService; this.transportService = transportService; this.threadPool = threadPool; transportService.registerRequestHandler(ACTION_SHARD_EXISTS, ShardActiveRequest::new, ThreadPool.Names.SAME, new ShardActiveRequestHandler()); this.deleteShardTimeout = INDICES_STORE_DELETE_SHARD_TIMEOUT.get(settings); // Doesn't make sense to delete shards on non-data nodes if (DiscoveryNode.isDataNode(settings)) { // we double check nothing has changed when responses come back from other nodes. // it's easier to do that check when the current cluster state is visible. // also it's good in general to let things settle down clusterService.addListener(this); } }
Example 3
Source File: SnapshotShardsService.java From crate with Apache License 2.0 | 6 votes |
@Inject public SnapshotShardsService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService, ThreadPool threadPool, TransportService transportService, IndicesService indicesService, IndexNameExpressionResolver indexNameExpressionResolver) { this.indicesService = indicesService; this.repositoriesService = repositoriesService; this.transportService = transportService; this.clusterService = clusterService; this.threadPool = threadPool; if (DiscoveryNode.isDataNode(settings)) { // this is only useful on the nodes that can hold data clusterService.addListener(this); } // The constructor of UpdateSnapshotStatusAction will register itself to the TransportService. this.updateSnapshotStatusHandler = new UpdateSnapshotStatusAction(transportService, clusterService, threadPool, indexNameExpressionResolver); }
Example 4
Source File: DanglingIndicesState.java From crate with Apache License 2.0 | 5 votes |
@Inject public DanglingIndicesState(NodeEnvironment nodeEnv, MetaStateService metaStateService, LocalAllocateDangledIndices allocateDangledIndices, ClusterService clusterService) { this.nodeEnv = nodeEnv; this.metaStateService = metaStateService; this.allocateDangledIndices = allocateDangledIndices; clusterService.addListener(this); }
Example 5
Source File: DelayedAllocationService.java From crate with Apache License 2.0 | 5 votes |
@Inject public DelayedAllocationService(ThreadPool threadPool, ClusterService clusterService, AllocationService allocationService) { this.threadPool = threadPool; this.clusterService = clusterService; this.allocationService = allocationService; clusterService.addListener(this); }
Example 6
Source File: TemplateUpgradeService.java From crate with Apache License 2.0 | 5 votes |
public TemplateUpgradeService(Client client, ClusterService clusterService, ThreadPool threadPool, Collection<UnaryOperator<Map<String, IndexTemplateMetaData>>> indexTemplateMetaDataUpgraders) { this.client = client; this.clusterService = clusterService; this.threadPool = threadPool; this.indexTemplateMetaDataUpgraders = templates -> { Map<String, IndexTemplateMetaData> upgradedTemplates = new HashMap<>(templates); for (UnaryOperator<Map<String, IndexTemplateMetaData>> upgrader : indexTemplateMetaDataUpgraders) { upgradedTemplates = upgrader.apply(upgradedTemplates); } return upgradedTemplates; }; clusterService.addListener(this); }
Example 7
Source File: CrateSettings.java From crate with Apache License 2.0 | 5 votes |
@Inject public CrateSettings(ClusterService clusterService, Settings settings) { logger = LogManager.getLogger(this.getClass()); Settings.Builder defaultsBuilder = Settings.builder(); for (CrateSetting<?> builtInSetting : BUILT_IN_SETTINGS) { defaultsBuilder.put(builtInSetting.getKey(), builtInSetting.setting().getDefaultRaw(settings)); } initialSettings = defaultsBuilder.put(settings).build(); this.settings = initialSettings; clusterService.addListener(this); }
Example 8
Source File: UserManagerService.java From crate with Apache License 2.0 | 5 votes |
@Inject public UserManagerService(TransportCreateUserAction transportCreateUserAction, TransportDropUserAction transportDropUserAction, TransportAlterUserAction transportAlterUserAction, TransportPrivilegesAction transportPrivilegesAction, SysTableRegistry sysTableRegistry, ClusterService clusterService, DDLClusterStateService ddlClusterStateService) { this.transportCreateUserAction = transportCreateUserAction; this.transportDropUserAction = transportDropUserAction; this.transportAlterUserAction = transportAlterUserAction; this.transportPrivilegesAction = transportPrivilegesAction; clusterService.addListener(this); var userTable = SysUsersTableInfo.create(); sysTableRegistry.registerSysTable( userTable, () -> CompletableFuture.completedFuture(users()), userTable.expressions(), false ); var privilegesTable = SysPrivilegesTableInfo.create(); sysTableRegistry.registerSysTable( privilegesTable, () -> CompletableFuture.completedFuture(SysPrivilegesTableInfo.buildPrivilegesRows(users())), privilegesTable.expressions(), false ); ddlClusterStateService.addModifier(DDL_MODIFIER); }
Example 9
Source File: InformationSchemaIterables.java From crate with Apache License 2.0 | 4 votes |
@Inject public InformationSchemaIterables(final Schemas schemas, final Functions functions, FulltextAnalyzerResolver fulltextAnalyzerResolver, ClusterService clusterService) { this.schemas = schemas; this.functions = functions; this.fulltextAnalyzerResolver = fulltextAnalyzerResolver; views = () -> viewsStream(schemas).iterator(); relations = () -> concat(tablesStream(schemas), viewsStream(schemas)).iterator(); primaryKeys = () -> sequentialStream(relations) .filter(this::isPrimaryKey) .iterator(); columns = () -> sequentialStream(relations) .flatMap(r -> sequentialStream(new ColumnsIterable(r))) .iterator(); Iterable<ConstraintInfo> primaryKeyConstraints = () -> sequentialStream(primaryKeys) .map(t -> new ConstraintInfo( t, t.ident().name() + PK_SUFFIX, ConstraintInfo.Type.PRIMARY_KEY)) .iterator(); Iterable<ConstraintInfo> notnullConstraints = () -> sequentialStream(relations) .flatMap(r -> sequentialStream(new NotNullConstraintIterable(r))) .iterator(); Iterable<ConstraintInfo> checkConstraints = () -> sequentialStream(relations) .flatMap(r -> r.checkConstraints() .stream() .map(chk -> new ConstraintInfo(r, chk.name(), ConstraintInfo.Type.CHECK))) .iterator(); constraints = () -> Stream.of(sequentialStream(primaryKeyConstraints), sequentialStream(notnullConstraints), sequentialStream(checkConstraints)) .flatMap(Function.identity()) .iterator(); partitionInfos = new PartitionInfos(clusterService); referentialConstraints = emptyList(); // these are initialized on a clusterState change routines = emptyList(); clusterService.addListener(this); pgIndices = () -> tablesStream(schemas).filter(this::isPrimaryKey).map(this::pgIndex).iterator(); pgClasses = () -> concat(sequentialStream(relations).map(this::relationToPgClassEntry), sequentialStream(primaryKeys).map(this::primaryKeyToPgClassEntry)).iterator(); pgBuiltInFunc = () -> sequentialStream(functions.functionResolvers().values()) .flatMap(List::stream) .map(this::pgProc) .iterator(); pgTypeReceiveFunctions = () -> Stream.concat( sequentialStream(PGTypes.pgTypes()) .filter(t -> t.typArray() != 0) .map(InformationSchemaIterables::typeToSignature) .map(PgProcTable.Entry::of), // Don't generate array_recv entry from pgTypes to avoid duplicate entries // (We want 1 array_recv entry, not one per array type) Stream.of( PgProcTable.Entry.of( Signature.scalar( "array_recv", DataTypes.INTEGER.getTypeSignature(), new ArrayType<>(DataTypes.UNDEFINED).getTypeSignature() ) ) ) ) .iterator(); }