|
|
@@ -31,6 +31,8 @@ import org.elasticsearch.node.Node;
|
|
|
import org.elasticsearch.tasks.TaskManager;
|
|
|
import org.elasticsearch.threadpool.ThreadPool;
|
|
|
|
|
|
+import java.util.function.Supplier;
|
|
|
+
|
|
|
public class ClusterService extends AbstractLifecycleComponent {
|
|
|
private final MasterService masterService;
|
|
|
|
|
|
@@ -54,13 +56,24 @@ public class ClusterService extends AbstractLifecycleComponent {
|
|
|
|
|
|
private final String nodeName;
|
|
|
|
|
|
- private RerouteService rerouteService;
|
|
|
+ private final Supplier<RerouteService> rerouteService;
|
|
|
|
|
|
public ClusterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool, TaskManager taskManager) {
|
|
|
+ this(settings, clusterSettings, threadPool, taskManager, () -> { throw new IllegalStateException("RerouteService not provided"); });
|
|
|
+ }
|
|
|
+
|
|
|
+ public ClusterService(
|
|
|
+ Settings settings,
|
|
|
+ ClusterSettings clusterSettings,
|
|
|
+ ThreadPool threadPool,
|
|
|
+ TaskManager taskManager,
|
|
|
+ Supplier<RerouteService> rerouteService
|
|
|
+ ) {
|
|
|
this(
|
|
|
settings,
|
|
|
clusterSettings,
|
|
|
new MasterService(settings, clusterSettings, threadPool, taskManager),
|
|
|
+ rerouteService,
|
|
|
new ClusterApplierService(Node.NODE_NAME_SETTING.get(settings), settings, clusterSettings, threadPool)
|
|
|
);
|
|
|
}
|
|
|
@@ -70,10 +83,27 @@ public class ClusterService extends AbstractLifecycleComponent {
|
|
|
ClusterSettings clusterSettings,
|
|
|
MasterService masterService,
|
|
|
ClusterApplierService clusterApplierService
|
|
|
+ ) {
|
|
|
+ this(
|
|
|
+ settings,
|
|
|
+ clusterSettings,
|
|
|
+ masterService,
|
|
|
+ () -> { throw new IllegalStateException("RerouteService not provided"); },
|
|
|
+ clusterApplierService
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public ClusterService(
|
|
|
+ Settings settings,
|
|
|
+ ClusterSettings clusterSettings,
|
|
|
+ MasterService masterService,
|
|
|
+ Supplier<RerouteService> rerouteService,
|
|
|
+ ClusterApplierService clusterApplierService
|
|
|
) {
|
|
|
this.settings = settings;
|
|
|
this.nodeName = Node.NODE_NAME_SETTING.get(settings);
|
|
|
this.masterService = masterService;
|
|
|
+ this.rerouteService = rerouteService;
|
|
|
this.operationRouting = new OperationRouting(settings, clusterSettings);
|
|
|
this.clusterSettings = clusterSettings;
|
|
|
this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
|
|
|
@@ -90,14 +120,8 @@ public class ClusterService extends AbstractLifecycleComponent {
|
|
|
clusterApplierService.setNodeConnectionsService(nodeConnectionsService);
|
|
|
}
|
|
|
|
|
|
- public void setRerouteService(RerouteService rerouteService) {
|
|
|
- assert this.rerouteService == null : "RerouteService is already set";
|
|
|
- this.rerouteService = rerouteService;
|
|
|
- }
|
|
|
-
|
|
|
public RerouteService getRerouteService() {
|
|
|
- assert this.rerouteService != null : "RerouteService not set";
|
|
|
- return rerouteService;
|
|
|
+ return rerouteService.get();
|
|
|
}
|
|
|
|
|
|
@Override
|