|
@@ -73,6 +73,7 @@ import org.elasticsearch.tasks.TaskResultsService;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -94,7 +95,6 @@ public class ClusterModule extends AbstractModule {
|
|
private final IndexNameExpressionResolver indexNameExpressionResolver;
|
|
private final IndexNameExpressionResolver indexNameExpressionResolver;
|
|
private final AllocationDeciders allocationDeciders;
|
|
private final AllocationDeciders allocationDeciders;
|
|
private final AllocationService allocationService;
|
|
private final AllocationService allocationService;
|
|
- private final Runnable onStarted;
|
|
|
|
// pkg private for tests
|
|
// pkg private for tests
|
|
final Collection<AllocationDecider> deciderList;
|
|
final Collection<AllocationDecider> deciderList;
|
|
final ShardsAllocator shardsAllocator;
|
|
final ShardsAllocator shardsAllocator;
|
|
@@ -107,9 +107,24 @@ public class ClusterModule extends AbstractModule {
|
|
this.clusterService = clusterService;
|
|
this.clusterService = clusterService;
|
|
this.indexNameExpressionResolver = new IndexNameExpressionResolver(settings);
|
|
this.indexNameExpressionResolver = new IndexNameExpressionResolver(settings);
|
|
this.allocationService = new AllocationService(settings, allocationDeciders, shardsAllocator, clusterInfoService);
|
|
this.allocationService = new AllocationService(settings, allocationDeciders, shardsAllocator, clusterInfoService);
|
|
- this.onStarted = () -> clusterPlugins.forEach(plugin -> plugin.onNodeStarted());
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static Map<String, Supplier<ClusterState.Custom>> getClusterStateCustomSuppliers(List<ClusterPlugin> clusterPlugins) {
|
|
|
|
+ final Map<String, Supplier<ClusterState.Custom>> customSupplier = new HashMap<>();
|
|
|
|
+ customSupplier.put(SnapshotDeletionsInProgress.TYPE, SnapshotDeletionsInProgress::new);
|
|
|
|
+ customSupplier.put(RestoreInProgress.TYPE, RestoreInProgress::new);
|
|
|
|
+ customSupplier.put(SnapshotsInProgress.TYPE, SnapshotsInProgress::new);
|
|
|
|
+ for (ClusterPlugin plugin : clusterPlugins) {
|
|
|
|
+ Map<String, Supplier<ClusterState.Custom>> initialCustomSupplier = plugin.getInitialClusterStateCustomSupplier();
|
|
|
|
+ for (String key : initialCustomSupplier.keySet()) {
|
|
|
|
+ if (customSupplier.containsKey(key)) {
|
|
|
|
+ throw new IllegalStateException("custom supplier key [" + key + "] is registered more than once");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ customSupplier.putAll(initialCustomSupplier);
|
|
|
|
+ }
|
|
|
|
+ return Collections.unmodifiableMap(customSupplier);
|
|
|
|
+ }
|
|
|
|
|
|
public static List<Entry> getNamedWriteables() {
|
|
public static List<Entry> getNamedWriteables() {
|
|
List<Entry> entries = new ArrayList<>();
|
|
List<Entry> entries = new ArrayList<>();
|
|
@@ -243,8 +258,4 @@ public class ClusterModule extends AbstractModule {
|
|
bind(AllocationDeciders.class).toInstance(allocationDeciders);
|
|
bind(AllocationDeciders.class).toInstance(allocationDeciders);
|
|
bind(ShardsAllocator.class).toInstance(shardsAllocator);
|
|
bind(ShardsAllocator.class).toInstance(shardsAllocator);
|
|
}
|
|
}
|
|
-
|
|
|
|
- public Runnable onStarted() {
|
|
|
|
- return onStarted;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|