Merge branch 'master' into enhancement/rollover_api

This commit is contained in:
Areek Zillur 2016-06-17 11:35:57 -04:00
commit 9356a6090f
195 changed files with 895 additions and 698 deletions

View File

@ -147,7 +147,8 @@ public class AllocationBenchmark {
for (int i = 1; i <= numNodes; i++) { for (int i = 1; i <= numNodes; i++) {
nb.put(Allocators.newNode("node" + i, Collections.singletonMap("tag", "tag_" + (i % numTags)))); nb.put(Allocators.newNode("node" + i, Collections.singletonMap("tag", "tag_" + (i % numTags))));
} }
initialClusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).nodes initialClusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData).routingTable(routingTable).nodes
(nb).build(); (nb).build();
} }

View File

@ -754,7 +754,6 @@
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]ClusterHealthIT.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]ClusterHealthIT.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]ClusterInfoServiceIT.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]ClusterInfoServiceIT.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]ClusterStateDiffIT.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]ClusterStateDiffIT.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]ClusterStateTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]DiskUsageTests.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]DiskUsageTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]MinimumMasterNodesIT.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]MinimumMasterNodesIT.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]NoMasterNodeIT.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]NoMasterNodeIT.java" checks="LineLength" />
@ -784,13 +783,11 @@
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]AllocationIdTests.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]AllocationIdTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]DelayedAllocationIT.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]DelayedAllocationIT.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]PrimaryAllocationIT.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]PrimaryAllocationIT.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]RoutingBackwardCompatibilityTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]RoutingServiceTests.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]RoutingServiceTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]RoutingTableTests.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]RoutingTableTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]ShardRoutingHelper.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]ShardRoutingHelper.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]ShardRoutingTests.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]ShardRoutingTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]UnassignedInfoTests.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]UnassignedInfoTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]allocation[/\\]ActiveAllocationIdTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]allocation[/\\]AddIncrementallyTests.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]allocation[/\\]AddIncrementallyTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]allocation[/\\]AllocationCommandsTests.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]allocation[/\\]AllocationCommandsTests.java" checks="LineLength" />
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]allocation[/\\]AllocationPriorityTests.java" checks="LineLength" /> <suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]cluster[/\\]routing[/\\]allocation[/\\]AllocationPriorityTests.java" checks="LineLength" />

View File

@ -23,7 +23,6 @@ import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction; import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateObserver; import org.elasticsearch.cluster.ClusterStateObserver;
import org.elasticsearch.cluster.ClusterStateUpdateTask; import org.elasticsearch.cluster.ClusterStateUpdateTask;
@ -47,16 +46,14 @@ import org.elasticsearch.transport.TransportService;
*/ */
public class TransportClusterHealthAction extends TransportMasterNodeReadAction<ClusterHealthRequest, ClusterHealthResponse> { public class TransportClusterHealthAction extends TransportMasterNodeReadAction<ClusterHealthRequest, ClusterHealthResponse> {
private final ClusterName clusterName;
private final GatewayAllocator gatewayAllocator; private final GatewayAllocator gatewayAllocator;
@Inject @Inject
public TransportClusterHealthAction(Settings settings, TransportService transportService, ClusterService clusterService, public TransportClusterHealthAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ClusterName clusterName, ActionFilters actionFilters, ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, GatewayAllocator gatewayAllocator) { IndexNameExpressionResolver indexNameExpressionResolver, GatewayAllocator gatewayAllocator) {
super(settings, ClusterHealthAction.NAME, false, transportService, clusterService, threadPool, actionFilters, super(settings, ClusterHealthAction.NAME, false, transportService, clusterService, threadPool, actionFilters,
indexNameExpressionResolver, ClusterHealthRequest::new); indexNameExpressionResolver, ClusterHealthRequest::new);
this.clusterName = clusterName;
this.gatewayAllocator = gatewayAllocator; this.gatewayAllocator = gatewayAllocator;
} }
@ -284,14 +281,14 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request); concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request);
} catch (IndexNotFoundException e) { } catch (IndexNotFoundException e) {
// one of the specified indices is not there - treat it as RED. // one of the specified indices is not there - treat it as RED.
ClusterHealthResponse response = new ClusterHealthResponse(clusterName.value(), Strings.EMPTY_ARRAY, clusterState, ClusterHealthResponse response = new ClusterHealthResponse(clusterState.getClusterName().value(), Strings.EMPTY_ARRAY, clusterState,
numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(clusterState), numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(clusterState),
pendingTaskTimeInQueue); pendingTaskTimeInQueue);
response.setStatus(ClusterHealthStatus.RED); response.setStatus(ClusterHealthStatus.RED);
return response; return response;
} }
return new ClusterHealthResponse(clusterName.value(), concreteIndices, clusterState, numberOfPendingTasks, return new ClusterHealthResponse(clusterState.getClusterName().value(), concreteIndices, clusterState, numberOfPendingTasks,
numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(clusterState), pendingTaskTimeInQueue); numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(clusterState), pendingTaskTimeInQueue);
} }
} }

View File

@ -47,17 +47,17 @@ public class TransportNodesHotThreadsAction extends TransportNodesAction<NodesHo
NodeHotThreads> { NodeHotThreads> {
@Inject @Inject
public TransportNodesHotThreadsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool, public TransportNodesHotThreadsAction(Settings settings, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ClusterService clusterService, TransportService transportService,
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, NodesHotThreadsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters, super(settings, NodesHotThreadsAction.NAME, threadPool, clusterService, transportService, actionFilters,
indexNameExpressionResolver, NodesHotThreadsRequest::new, NodeRequest::new, ThreadPool.Names.GENERIC, NodeHotThreads.class); indexNameExpressionResolver, NodesHotThreadsRequest::new, NodeRequest::new, ThreadPool.Names.GENERIC, NodeHotThreads.class);
} }
@Override @Override
protected NodesHotThreadsResponse newResponse(NodesHotThreadsRequest request, protected NodesHotThreadsResponse newResponse(NodesHotThreadsRequest request,
List<NodeHotThreads> responses, List<FailedNodeException> failures) { List<NodeHotThreads> responses, List<FailedNodeException> failures) {
return new NodesHotThreadsResponse(clusterName, responses, failures); return new NodesHotThreadsResponse(clusterService.getClusterName(), responses, failures);
} }
@Override @Override

View File

@ -23,7 +23,6 @@ import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.nodes.BaseNodeRequest; import org.elasticsearch.action.support.nodes.BaseNodeRequest;
import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.action.support.nodes.TransportNodesAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
@ -48,11 +47,11 @@ public class TransportNodesInfoAction extends TransportNodesAction<NodesInfoRequ
private final NodeService nodeService; private final NodeService nodeService;
@Inject @Inject
public TransportNodesInfoAction(Settings settings, ClusterName clusterName, ThreadPool threadPool, public TransportNodesInfoAction(Settings settings, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ClusterService clusterService, TransportService transportService,
NodeService nodeService, ActionFilters actionFilters, NodeService nodeService, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver) { IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, NodesInfoAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters, super(settings, NodesInfoAction.NAME, threadPool, clusterService, transportService, actionFilters,
indexNameExpressionResolver, NodesInfoRequest::new, NodeInfoRequest::new, ThreadPool.Names.MANAGEMENT, NodeInfo.class); indexNameExpressionResolver, NodesInfoRequest::new, NodeInfoRequest::new, ThreadPool.Names.MANAGEMENT, NodeInfo.class);
this.nodeService = nodeService; this.nodeService = nodeService;
} }
@ -60,7 +59,7 @@ public class TransportNodesInfoAction extends TransportNodesAction<NodesInfoRequ
@Override @Override
protected NodesInfoResponse newResponse(NodesInfoRequest nodesInfoRequest, protected NodesInfoResponse newResponse(NodesInfoRequest nodesInfoRequest,
List<NodeInfo> responses, List<FailedNodeException> failures) { List<NodeInfo> responses, List<FailedNodeException> failures) {
return new NodesInfoResponse(clusterName, responses, failures); return new NodesInfoResponse(clusterService.getClusterName(), responses, failures);
} }
@Override @Override

View File

@ -47,7 +47,7 @@ public final class LivenessResponse extends ActionResponse {
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
clusterName = ClusterName.readClusterName(in); clusterName = new ClusterName(in);
node = in.readOptionalWriteable(DiscoveryNode::new); node = in.readOptionalWriteable(DiscoveryNode::new);
} }

View File

@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.cluster.node.liveness; package org.elasticsearch.action.admin.cluster.node.liveness;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
@ -30,20 +29,17 @@ import org.elasticsearch.transport.TransportService;
public final class TransportLivenessAction implements TransportRequestHandler<LivenessRequest> { public final class TransportLivenessAction implements TransportRequestHandler<LivenessRequest> {
private final ClusterService clusterService; private final ClusterService clusterService;
private final ClusterName clusterName;
public static final String NAME = "cluster:monitor/nodes/liveness"; public static final String NAME = "cluster:monitor/nodes/liveness";
@Inject @Inject
public TransportLivenessAction(ClusterName clusterName, public TransportLivenessAction(ClusterService clusterService, TransportService transportService) {
ClusterService clusterService, TransportService transportService) {
this.clusterService = clusterService; this.clusterService = clusterService;
this.clusterName = clusterName;
transportService.registerRequestHandler(NAME, LivenessRequest::new, ThreadPool.Names.SAME, transportService.registerRequestHandler(NAME, LivenessRequest::new, ThreadPool.Names.SAME,
false, false /*can not trip circuit breaker*/, this); false, false /*can not trip circuit breaker*/, this);
} }
@Override @Override
public void messageReceived(LivenessRequest request, TransportChannel channel) throws Exception { public void messageReceived(LivenessRequest request, TransportChannel channel) throws Exception {
channel.sendResponse(new LivenessResponse(clusterName, clusterService.localNode())); channel.sendResponse(new LivenessResponse(clusterService.getClusterName(), clusterService.localNode()));
} }
} }

View File

@ -23,7 +23,6 @@ import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.nodes.BaseNodeRequest; import org.elasticsearch.action.support.nodes.BaseNodeRequest;
import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.action.support.nodes.TransportNodesAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
@ -48,18 +47,18 @@ public class TransportNodesStatsAction extends TransportNodesAction<NodesStatsRe
private final NodeService nodeService; private final NodeService nodeService;
@Inject @Inject
public TransportNodesStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool, public TransportNodesStatsAction(Settings settings, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ClusterService clusterService, TransportService transportService,
NodeService nodeService, ActionFilters actionFilters, NodeService nodeService, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver) { IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, NodesStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters, super(settings, NodesStatsAction.NAME, threadPool, clusterService, transportService, actionFilters,
indexNameExpressionResolver, NodesStatsRequest::new, NodeStatsRequest::new, ThreadPool.Names.MANAGEMENT, NodeStats.class); indexNameExpressionResolver, NodesStatsRequest::new, NodeStatsRequest::new, ThreadPool.Names.MANAGEMENT, NodeStats.class);
this.nodeService = nodeService; this.nodeService = nodeService;
} }
@Override @Override
protected NodesStatsResponse newResponse(NodesStatsRequest request, List<NodeStats> responses, List<FailedNodeException> failures) { protected NodesStatsResponse newResponse(NodesStatsRequest request, List<NodeStats> responses, List<FailedNodeException> failures) {
return new NodesStatsResponse(clusterName, responses, failures); return new NodesStatsResponse(clusterService.getClusterName(), responses, failures);
} }
@Override @Override

View File

@ -24,7 +24,6 @@ import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.TaskOperationFailure; import org.elasticsearch.action.TaskOperationFailure;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.tasks.TransportTasksAction; import org.elasticsearch.action.support.tasks.TransportTasksAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
@ -63,10 +62,10 @@ public class TransportCancelTasksAction extends TransportTasksAction<Cancellable
public static final String BAN_PARENT_ACTION_NAME = "internal:admin/tasks/ban"; public static final String BAN_PARENT_ACTION_NAME = "internal:admin/tasks/ban";
@Inject @Inject
public TransportCancelTasksAction(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, public TransportCancelTasksAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver
indexNameExpressionResolver) { indexNameExpressionResolver) {
super(settings, CancelTasksAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters, super(settings, CancelTasksAction.NAME, threadPool, clusterService, transportService, actionFilters,
indexNameExpressionResolver, CancelTasksRequest::new, CancelTasksResponse::new, ThreadPool.Names.MANAGEMENT); indexNameExpressionResolver, CancelTasksRequest::new, CancelTasksResponse::new, ThreadPool.Names.MANAGEMENT);
transportService.registerRequestHandler(BAN_PARENT_ACTION_NAME, BanParentTaskRequest::new, ThreadPool.Names.SAME, new transportService.registerRequestHandler(BAN_PARENT_ACTION_NAME, BanParentTaskRequest::new, ThreadPool.Names.SAME, new
BanParentRequestHandler()); BanParentRequestHandler());

View File

@ -23,7 +23,6 @@ import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.TaskOperationFailure; import org.elasticsearch.action.TaskOperationFailure;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.tasks.TransportTasksAction; import org.elasticsearch.action.support.tasks.TransportTasksAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
@ -55,9 +54,9 @@ public class TransportListTasksAction extends TransportTasksAction<Task, ListTas
private static final TimeValue DEFAULT_WAIT_FOR_COMPLETION_TIMEOUT = timeValueSeconds(30); private static final TimeValue DEFAULT_WAIT_FOR_COMPLETION_TIMEOUT = timeValueSeconds(30);
@Inject @Inject
public TransportListTasksAction(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, public TransportListTasksAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, ListTasksAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters, super(settings, ListTasksAction.NAME, threadPool, clusterService, transportService, actionFilters,
indexNameExpressionResolver, ListTasksRequest::new, ListTasksResponse::new, ThreadPool.Names.MANAGEMENT); indexNameExpressionResolver, ListTasksRequest::new, ListTasksResponse::new, ThreadPool.Names.MANAGEMENT);
} }

View File

@ -22,7 +22,6 @@ package org.elasticsearch.action.admin.cluster.repositories.verify;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.action.support.master.TransportMasterNodeAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.block.ClusterBlockLevel;
@ -42,15 +41,13 @@ public class TransportVerifyRepositoryAction extends TransportMasterNodeAction<V
private final RepositoriesService repositoriesService; private final RepositoriesService repositoriesService;
protected final ClusterName clusterName;
@Inject @Inject
public TransportVerifyRepositoryAction(Settings settings, ClusterName clusterName, TransportService transportService, ClusterService clusterService, public TransportVerifyRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters, RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver) { IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, VerifyRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, VerifyRepositoryRequest::new); super(settings, VerifyRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, VerifyRepositoryRequest::new);
this.repositoriesService = repositoriesService; this.repositoriesService = repositoriesService;
this.clusterName = clusterName;
} }
@Override @Override
@ -76,7 +73,7 @@ public class TransportVerifyRepositoryAction extends TransportMasterNodeAction<V
if (verifyResponse.failed()) { if (verifyResponse.failed()) {
listener.onFailure(new RepositoryVerificationException(request.name(), verifyResponse.failureDescription())); listener.onFailure(new RepositoryVerificationException(request.name(), verifyResponse.failureDescription()));
} else { } else {
listener.onResponse(new VerifyRepositoryResponse(clusterName, verifyResponse.nodes())); listener.onResponse(new VerifyRepositoryResponse(clusterService.getClusterName(), verifyResponse.nodes()));
} }
} }

View File

@ -51,7 +51,7 @@ public class VerifyRepositoryResponse extends ActionResponse implements ToXConte
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
clusterName = ClusterName.readClusterName(in); clusterName = new ClusterName(in);
nodes = new DiscoveryNode[in.readVInt()]; nodes = new DiscoveryNode[in.readVInt()];
for (int i=0; i<nodes.length; i++){ for (int i=0; i<nodes.length; i++){
nodes[i] = new DiscoveryNode(in); nodes[i] = new DiscoveryNode(in);

View File

@ -63,11 +63,11 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
private final SnapshotShardsService snapshotShardsService; private final SnapshotShardsService snapshotShardsService;
@Inject @Inject
public TransportNodesSnapshotsStatus(Settings settings, ClusterName clusterName, ThreadPool threadPool, public TransportNodesSnapshotsStatus(Settings settings, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ClusterService clusterService, TransportService transportService,
SnapshotShardsService snapshotShardsService, ActionFilters actionFilters, SnapshotShardsService snapshotShardsService, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver) { IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, ACTION_NAME, clusterName, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
Request::new, NodeRequest::new, ThreadPool.Names.GENERIC, NodeSnapshotStatus.class); Request::new, NodeRequest::new, ThreadPool.Names.GENERIC, NodeSnapshotStatus.class);
this.snapshotShardsService = snapshotShardsService; this.snapshotShardsService = snapshotShardsService;
} }
@ -89,7 +89,7 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
@Override @Override
protected NodesSnapshotStatus newResponse(Request request, List<NodeSnapshotStatus> responses, List<FailedNodeException> failures) { protected NodesSnapshotStatus newResponse(Request request, List<NodeSnapshotStatus> responses, List<FailedNodeException> failures) {
return new NodesSnapshotStatus(clusterName, responses, failures); return new NodesSnapshotStatus(clusterService.getClusterName(), responses, failures);
} }
@Override @Override
@ -158,9 +158,6 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
public static class NodesSnapshotStatus extends BaseNodesResponse<NodeSnapshotStatus> { public static class NodesSnapshotStatus extends BaseNodesResponse<NodeSnapshotStatus> {
NodesSnapshotStatus() {
}
public NodesSnapshotStatus(ClusterName clusterName, List<NodeSnapshotStatus> nodes, List<FailedNodeException> failures) { public NodesSnapshotStatus(ClusterName clusterName, List<NodeSnapshotStatus> nodes, List<FailedNodeException> failures) {
super(clusterName, nodes, failures); super(clusterName, nodes, failures);
} }

View File

@ -54,7 +54,7 @@ public class ClusterStateResponse extends ActionResponse {
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
clusterName = ClusterName.readClusterName(in); clusterName = new ClusterName(in);
clusterState = ClusterState.Builder.readFrom(in, null); clusterState = ClusterState.Builder.readFrom(in, null);
} }

View File

@ -23,7 +23,6 @@ import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction; import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
@ -42,13 +41,11 @@ import org.elasticsearch.transport.TransportService;
*/ */
public class TransportClusterStateAction extends TransportMasterNodeReadAction<ClusterStateRequest, ClusterStateResponse> { public class TransportClusterStateAction extends TransportMasterNodeReadAction<ClusterStateRequest, ClusterStateResponse> {
private final ClusterName clusterName;
@Inject @Inject
public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
ClusterName clusterName, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, ClusterStateAction.NAME, false, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterStateRequest::new); super(settings, ClusterStateAction.NAME, false, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterStateRequest::new);
this.clusterName = clusterName;
} }
@Override @Override
@ -127,7 +124,7 @@ public class TransportClusterStateAction extends TransportMasterNodeReadAction<C
if (request.customs()) { if (request.customs()) {
builder.customs(currentState.customs()); builder.customs(currentState.customs());
} }
listener.onResponse(new ClusterStateResponse(clusterName, builder.build())); listener.onResponse(new ClusterStateResponse(currentState.getClusterName(), builder.build()));
} }

View File

@ -28,7 +28,6 @@ import org.elasticsearch.action.admin.indices.stats.ShardStats;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.nodes.BaseNodeRequest; import org.elasticsearch.action.support.nodes.BaseNodeRequest;
import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.action.support.nodes.TransportNodesAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.health.ClusterStateHealth; import org.elasticsearch.cluster.health.ClusterStateHealth;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
@ -62,11 +61,11 @@ public class TransportClusterStatsAction extends TransportNodesAction<ClusterSta
@Inject @Inject
public TransportClusterStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool, public TransportClusterStatsAction(Settings settings, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ClusterService clusterService, TransportService transportService,
NodeService nodeService, IndicesService indicesService, NodeService nodeService, IndicesService indicesService,
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, ClusterStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters, super(settings, ClusterStatsAction.NAME, threadPool, clusterService, transportService, actionFilters,
indexNameExpressionResolver, ClusterStatsRequest::new, ClusterStatsNodeRequest::new, ThreadPool.Names.MANAGEMENT, indexNameExpressionResolver, ClusterStatsRequest::new, ClusterStatsNodeRequest::new, ThreadPool.Names.MANAGEMENT,
ClusterStatsNodeResponse.class); ClusterStatsNodeResponse.class);
this.nodeService = nodeService; this.nodeService = nodeService;
@ -76,8 +75,8 @@ public class TransportClusterStatsAction extends TransportNodesAction<ClusterSta
@Override @Override
protected ClusterStatsResponse newResponse(ClusterStatsRequest request, protected ClusterStatsResponse newResponse(ClusterStatsRequest request,
List<ClusterStatsNodeResponse> responses, List<FailedNodeException> failures) { List<ClusterStatsNodeResponse> responses, List<FailedNodeException> failures) {
return new ClusterStatsResponse(System.currentTimeMillis(), clusterName, clusterService.state().metaData().clusterUUID(), return new ClusterStatsResponse(System.currentTimeMillis(), clusterService.getClusterName(),
responses, failures); clusterService.state().metaData().clusterUUID(), responses, failures);
} }
@Override @Override

View File

@ -84,7 +84,7 @@ public class MainResponse extends ActionResponse implements ToXContent {
super.readFrom(in); super.readFrom(in);
nodeName = in.readString(); nodeName = in.readString();
version = Version.readVersion(in); version = Version.readVersion(in);
clusterName = ClusterName.readClusterName(in); clusterName = new ClusterName(in);
build = Build.readBuild(in); build = Build.readBuild(in);
available = in.readBoolean(); available = in.readBoolean();
} }

View File

@ -106,7 +106,7 @@ public abstract class BaseNodesResponse<TNodeResponse extends BaseNodeResponse>
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
clusterName = ClusterName.readClusterName(in); clusterName = new ClusterName(in);
nodes = readNodesFrom(in); nodes = readNodesFrom(in);
failures = in.readList(FailedNodeException::new); failures = in.readList(FailedNodeException::new);
} }

View File

@ -24,13 +24,11 @@ import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.NoSuchNodeException; import org.elasticsearch.action.NoSuchNodeException;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
@ -59,21 +57,19 @@ public abstract class TransportNodesAction<NodesRequest extends BaseNodesRequest
NodeResponse extends BaseNodeResponse> NodeResponse extends BaseNodeResponse>
extends HandledTransportAction<NodesRequest, NodesResponse> { extends HandledTransportAction<NodesRequest, NodesResponse> {
protected final ClusterName clusterName;
protected final ClusterService clusterService; protected final ClusterService clusterService;
protected final TransportService transportService; protected final TransportService transportService;
protected final Class<NodeResponse> nodeResponseClass; protected final Class<NodeResponse> nodeResponseClass;
final String transportNodeAction; final String transportNodeAction;
protected TransportNodesAction(Settings settings, String actionName, ClusterName clusterName, ThreadPool threadPool, protected TransportNodesAction(Settings settings, String actionName, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, ClusterService clusterService, TransportService transportService, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<NodesRequest> request, Supplier<NodeRequest> nodeRequest, Supplier<NodesRequest> request, Supplier<NodeRequest> nodeRequest,
String nodeExecutor, String nodeExecutor,
Class<NodeResponse> nodeResponseClass) { Class<NodeResponse> nodeResponseClass) {
super(settings, actionName, threadPool, transportService, actionFilters, indexNameExpressionResolver, request); super(settings, actionName, threadPool, transportService, actionFilters, indexNameExpressionResolver, request);
this.clusterName = Objects.requireNonNull(clusterName);
this.clusterService = Objects.requireNonNull(clusterService); this.clusterService = Objects.requireNonNull(clusterService);
this.transportService = Objects.requireNonNull(transportService); this.transportService = Objects.requireNonNull(transportService);
this.nodeResponseClass = Objects.requireNonNull(nodeResponseClass); this.nodeResponseClass = Objects.requireNonNull(nodeResponseClass);

View File

@ -26,7 +26,6 @@ import org.elasticsearch.action.NoSuchNodeException;
import org.elasticsearch.action.TaskOperationFailure; import org.elasticsearch.action.TaskOperationFailure;
import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
@ -67,7 +66,6 @@ public abstract class TransportTasksAction<
TaskResponse extends Writeable TaskResponse extends Writeable
> extends HandledTransportAction<TasksRequest, TasksResponse> { > extends HandledTransportAction<TasksRequest, TasksResponse> {
protected final ClusterName clusterName;
protected final ClusterService clusterService; protected final ClusterService clusterService;
protected final TransportService transportService; protected final TransportService transportService;
protected final Supplier<TasksRequest> requestSupplier; protected final Supplier<TasksRequest> requestSupplier;
@ -75,13 +73,12 @@ public abstract class TransportTasksAction<
protected final String transportNodeAction; protected final String transportNodeAction;
protected TransportTasksAction(Settings settings, String actionName, ClusterName clusterName, ThreadPool threadPool, protected TransportTasksAction(Settings settings, String actionName, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, ClusterService clusterService, TransportService transportService, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, Supplier<TasksRequest> requestSupplier, IndexNameExpressionResolver indexNameExpressionResolver, Supplier<TasksRequest> requestSupplier,
Supplier<TasksResponse> responseSupplier, Supplier<TasksResponse> responseSupplier,
String nodeExecutor) { String nodeExecutor) {
super(settings, actionName, threadPool, transportService, actionFilters, indexNameExpressionResolver, requestSupplier); super(settings, actionName, threadPool, transportService, actionFilters, indexNameExpressionResolver, requestSupplier);
this.clusterName = clusterName;
this.clusterService = clusterService; this.clusterService = clusterService;
this.transportService = transportService; this.transportService = transportService;
this.transportNodeAction = actionName + "[n]"; this.transportNodeAction = actionName + "[n]";

View File

@ -28,7 +28,6 @@ import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.client.support.AbstractClient; import org.elasticsearch.client.support.AbstractClient;
import org.elasticsearch.client.transport.support.TransportProxyClient; import org.elasticsearch.client.transport.support.TransportProxyClient;
import org.elasticsearch.cluster.ClusterNameModule;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.Injector;
@ -137,7 +136,6 @@ public class TransportClient extends AbstractClient {
} }
modules.add(new PluginsModule(pluginsService)); modules.add(new PluginsModule(pluginsService));
modules.add(new NetworkModule(networkService, settings, true, namedWriteableRegistry)); modules.add(new NetworkModule(networkService, settings, true, namedWriteableRegistry));
modules.add(new ClusterNameModule(settings));
modules.add(b -> b.bind(ThreadPool.class).toInstance(threadPool)); modules.add(b -> b.bind(ThreadPool.class).toInstance(threadPool));
modules.add(new SearchModule(settings, namedWriteableRegistry) { modules.add(new SearchModule(settings, namedWriteableRegistry) {
@Override @Override

View File

@ -111,10 +111,10 @@ public class TransportClientNodesService extends AbstractComponent {
Setting.boolSetting("client.transport.sniff", false, Property.NodeScope); Setting.boolSetting("client.transport.sniff", false, Property.NodeScope);
@Inject @Inject
public TransportClientNodesService(Settings settings, ClusterName clusterName, TransportService transportService, public TransportClientNodesService(Settings settings,TransportService transportService,
ThreadPool threadPool, Version version) { ThreadPool threadPool, Version version) {
super(settings); super(settings);
this.clusterName = clusterName; this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
this.transportService = transportService; this.transportService = transportService;
this.threadPool = threadPool; this.threadPool = threadPool;
this.minCompatibilityVersion = version.minimumCompatibilityVersion(); this.minCompatibilityVersion = version.minimumCompatibilityVersion();

View File

@ -100,17 +100,19 @@ public class ClusterModule extends AbstractModule {
private final ExtensionPoint.SelectedType<ShardsAllocator> shardsAllocators = new ExtensionPoint.SelectedType<>("shards_allocator", ShardsAllocator.class); private final ExtensionPoint.SelectedType<ShardsAllocator> shardsAllocators = new ExtensionPoint.SelectedType<>("shards_allocator", ShardsAllocator.class);
private final ExtensionPoint.ClassSet<AllocationDecider> allocationDeciders = new ExtensionPoint.ClassSet<>("allocation_decider", AllocationDecider.class, AllocationDeciders.class); private final ExtensionPoint.ClassSet<AllocationDecider> allocationDeciders = new ExtensionPoint.ClassSet<>("allocation_decider", AllocationDecider.class, AllocationDeciders.class);
private final ExtensionPoint.ClassSet<IndexTemplateFilter> indexTemplateFilters = new ExtensionPoint.ClassSet<>("index_template_filter", IndexTemplateFilter.class); private final ExtensionPoint.ClassSet<IndexTemplateFilter> indexTemplateFilters = new ExtensionPoint.ClassSet<>("index_template_filter", IndexTemplateFilter.class);
private final ClusterService clusterService;
// pkg private so tests can mock // pkg private so tests can mock
Class<? extends ClusterInfoService> clusterInfoServiceImpl = InternalClusterInfoService.class; Class<? extends ClusterInfoService> clusterInfoServiceImpl = InternalClusterInfoService.class;
public ClusterModule(Settings settings) { public ClusterModule(Settings settings, ClusterService clusterService) {
this.settings = settings; this.settings = settings;
for (Class<? extends AllocationDecider> decider : ClusterModule.DEFAULT_ALLOCATION_DECIDERS) { for (Class<? extends AllocationDecider> decider : ClusterModule.DEFAULT_ALLOCATION_DECIDERS) {
registerAllocationDecider(decider); registerAllocationDecider(decider);
} }
registerShardsAllocator(ClusterModule.BALANCED_ALLOCATOR, BalancedShardsAllocator.class); registerShardsAllocator(ClusterModule.BALANCED_ALLOCATOR, BalancedShardsAllocator.class);
registerShardsAllocator(ClusterModule.EVEN_SHARD_COUNT_ALLOCATOR, BalancedShardsAllocator.class); registerShardsAllocator(ClusterModule.EVEN_SHARD_COUNT_ALLOCATOR, BalancedShardsAllocator.class);
this.clusterService = clusterService;
} }
public void registerAllocationDecider(Class<? extends AllocationDecider> allocationDecider) { public void registerAllocationDecider(Class<? extends AllocationDecider> allocationDecider) {
@ -140,9 +142,8 @@ public class ClusterModule extends AbstractModule {
bind(GatewayAllocator.class).asEagerSingleton(); bind(GatewayAllocator.class).asEagerSingleton();
bind(AllocationService.class).asEagerSingleton(); bind(AllocationService.class).asEagerSingleton();
bind(DiscoveryNodeService.class).asEagerSingleton(); bind(DiscoveryNodeService.class).asEagerSingleton();
bind(ClusterService.class).asEagerSingleton(); bind(ClusterService.class).toInstance(clusterService);
bind(NodeConnectionsService.class).asEagerSingleton(); bind(NodeConnectionsService.class).asEagerSingleton();
bind(OperationRouting.class).asEagerSingleton();
bind(MetaDataCreateIndexService.class).asEagerSingleton(); bind(MetaDataCreateIndexService.class).asEagerSingleton();
bind(MetaDataDeleteIndexService.class).asEagerSingleton(); bind(MetaDataDeleteIndexService.class).asEagerSingleton();
bind(MetaDataIndexStateService.class).asEagerSingleton(); bind(MetaDataIndexStateService.class).asEagerSingleton();

View File

@ -21,37 +21,29 @@ package org.elasticsearch.cluster;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
/** public class ClusterName implements Writeable {
*
*/
public class ClusterName implements Streamable {
public static final Setting<String> CLUSTER_NAME_SETTING = new Setting<>("cluster.name", "elasticsearch", (s) -> { public static final Setting<ClusterName> CLUSTER_NAME_SETTING = new Setting<>("cluster.name", "elasticsearch", (s) -> {
if (s.isEmpty()) { if (s.isEmpty()) {
throw new IllegalArgumentException("[cluster.name] must not be empty"); throw new IllegalArgumentException("[cluster.name] must not be empty");
} }
return s; return new ClusterName(s);
}, Property.NodeScope); }, Setting.Property.NodeScope);
public static final ClusterName DEFAULT = CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY);
public static final ClusterName DEFAULT = new ClusterName(CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY).intern()); private final String value;
private String value; public ClusterName(StreamInput input) throws IOException {
this(input.readString());
public static ClusterName clusterNameFromSettings(Settings settings) {
return new ClusterName(CLUSTER_NAME_SETTING.get(settings));
} }
private ClusterName() {
}
public ClusterName(String value) { public ClusterName(String value) {
this.value = value.intern(); this.value = value.intern();
} }
@ -60,17 +52,6 @@ public class ClusterName implements Streamable {
return this.value; return this.value;
} }
public static ClusterName readClusterName(StreamInput in) throws IOException {
ClusterName clusterName = new ClusterName();
clusterName.readFrom(in);
return clusterName;
}
@Override
public void readFrom(StreamInput in) throws IOException {
value = in.readString().intern();
}
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeString(value); out.writeString(value);
@ -90,7 +71,7 @@ public class ClusterName implements Streamable {
@Override @Override
public int hashCode() { public int hashCode() {
return value != null ? value.hashCode() : 0; return Objects.hash(value);
} }
@Override @Override

View File

@ -1,40 +0,0 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.cluster;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.settings.Settings;
/**
*
*/
public class ClusterNameModule extends AbstractModule {
private final Settings settings;
public ClusterNameModule(Settings settings) {
this.settings = settings;
}
@Override
protected void configure() {
bind(ClusterName.class).toInstance(ClusterName.clusterNameFromSettings(settings));
}
}

View File

@ -90,7 +90,7 @@ import java.util.Set;
*/ */
public class ClusterState implements ToXContent, Diffable<ClusterState> { public class ClusterState implements ToXContent, Diffable<ClusterState> {
public static final ClusterState PROTO = builder(ClusterName.DEFAULT).build(); public static final ClusterState PROTO = builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).build();
public static enum ClusterStateStatus { public static enum ClusterStateStatus {
UNKNOWN((byte) 0), UNKNOWN((byte) 0),
@ -734,7 +734,7 @@ public class ClusterState implements ToXContent, Diffable<ClusterState> {
} }
public ClusterState readFrom(StreamInput in, DiscoveryNode localNode) throws IOException { public ClusterState readFrom(StreamInput in, DiscoveryNode localNode) throws IOException {
ClusterName clusterName = ClusterName.readClusterName(in); ClusterName clusterName = new ClusterName(in);
Builder builder = new Builder(clusterName); Builder builder = new Builder(clusterName);
builder.version = in.readLong(); builder.version = in.readLong();
builder.uuid = in.readString(); builder.uuid = in.readString();
@ -805,7 +805,7 @@ public class ClusterState implements ToXContent, Diffable<ClusterState> {
} }
public ClusterStateDiff(StreamInput in, ClusterState proto) throws IOException { public ClusterStateDiff(StreamInput in, ClusterState proto) throws IOException {
clusterName = ClusterName.readClusterName(in); clusterName = new ClusterName(in);
fromUuid = in.readString(); fromUuid = in.readString();
toUuid = in.readString(); toUuid = in.readString();
toVersion = in.readLong(); toVersion = in.readLong();

View File

@ -18,12 +18,9 @@
*/ */
package org.elasticsearch.cluster.health; package org.elasticsearch.cluster.health;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.routing.IndexRoutingTable; import org.elasticsearch.cluster.routing.IndexRoutingTable;
import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
@ -50,16 +47,6 @@ public final class ClusterStateHealth implements Iterable<ClusterIndexHealth>, W
private final ClusterHealthStatus status; private final ClusterHealthStatus status;
private final Map<String, ClusterIndexHealth> indices = new HashMap<>(); private final Map<String, ClusterIndexHealth> indices = new HashMap<>();
/**
* Creates a new <code>ClusterStateHealth</code> instance based on cluster meta data and its routing table as a convenience.
*
* @param clusterMetaData Current cluster meta data. Must not be null.
* @param routingTables Current routing table. Must not be null.
*/
public ClusterStateHealth(final MetaData clusterMetaData, final RoutingTable routingTables) {
this(ClusterState.builder(ClusterName.DEFAULT).metaData(clusterMetaData).routingTable(routingTables).build());
}
/** /**
* Creates a new <code>ClusterStateHealth</code> instance considering the current cluster state and all indices in the cluster. * Creates a new <code>ClusterStateHealth</code> instance considering the current cluster state and all indices in the cluster.
* *

View File

@ -26,7 +26,7 @@ import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationD
import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardId;
@ -42,12 +42,17 @@ import java.util.stream.Collectors;
public class OperationRouting extends AbstractComponent { public class OperationRouting extends AbstractComponent {
private final AwarenessAllocationDecider awarenessAllocationDecider; private String[] awarenessAttributes;
@Inject public OperationRouting(Settings settings, ClusterSettings clusterSettings) {
public OperationRouting(Settings settings, AwarenessAllocationDecider awarenessAllocationDecider) {
super(settings); super(settings);
this.awarenessAllocationDecider = awarenessAllocationDecider; this.awarenessAttributes = AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING.get(settings);
clusterSettings.addSettingsUpdateConsumer(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING,
this::setAwarenessAttributes);
}
private void setAwarenessAttributes(String[] awarenessAttributes) {
this.awarenessAttributes = awarenessAttributes;
} }
public ShardIterator indexShards(ClusterState clusterState, String index, String id, @Nullable String routing) { public ShardIterator indexShards(ClusterState clusterState, String index, String id, @Nullable String routing) {
@ -111,7 +116,6 @@ public class OperationRouting extends AbstractComponent {
private ShardIterator preferenceActiveShardIterator(IndexShardRoutingTable indexShard, String localNodeId, DiscoveryNodes nodes, @Nullable String preference) { private ShardIterator preferenceActiveShardIterator(IndexShardRoutingTable indexShard, String localNodeId, DiscoveryNodes nodes, @Nullable String preference) {
if (preference == null || preference.isEmpty()) { if (preference == null || preference.isEmpty()) {
String[] awarenessAttributes = awarenessAllocationDecider.awarenessAttributes();
if (awarenessAttributes.length == 0) { if (awarenessAttributes.length == 0) {
return indexShard.activeInitializingShardsRandomIt(); return indexShard.activeInitializingShardsRandomIt();
} else { } else {
@ -143,7 +147,6 @@ public class OperationRouting extends AbstractComponent {
} }
// no more preference // no more preference
if (index == -1 || index == preference.length() - 1) { if (index == -1 || index == preference.length() - 1) {
String[] awarenessAttributes = awarenessAllocationDecider.awarenessAttributes();
if (awarenessAttributes.length == 0) { if (awarenessAttributes.length == 0) {
return indexShard.activeInitializingShardsRandomIt(); return indexShard.activeInitializingShardsRandomIt();
} else { } else {
@ -186,7 +189,6 @@ public class OperationRouting extends AbstractComponent {
} }
} }
// if not, then use it as the index // if not, then use it as the index
String[] awarenessAttributes = awarenessAllocationDecider.awarenessAttributes();
if (awarenessAttributes.length == 0) { if (awarenessAttributes.length == 0) {
return indexShard.activeInitializingShardsIt(Murmur3HashFunction.hash(preference)); return indexShard.activeInitializingShardsIt(Murmur3HashFunction.hash(preference));
} else { } else {

View File

@ -20,6 +20,7 @@
package org.elasticsearch.cluster.routing.allocation; package org.elasticsearch.cluster.routing.allocation;
import org.elasticsearch.cluster.ClusterInfoService; import org.elasticsearch.cluster.ClusterInfoService;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.health.ClusterStateHealth; import org.elasticsearch.cluster.health.ClusterStateHealth;
@ -68,6 +69,7 @@ public class AllocationService extends AbstractComponent {
private final GatewayAllocator gatewayAllocator; private final GatewayAllocator gatewayAllocator;
private final ShardsAllocator shardsAllocator; private final ShardsAllocator shardsAllocator;
private final ClusterInfoService clusterInfoService; private final ClusterInfoService clusterInfoService;
private final ClusterName clusterName;
@Inject @Inject
public AllocationService(Settings settings, AllocationDeciders allocationDeciders, GatewayAllocator gatewayAllocator, public AllocationService(Settings settings, AllocationDeciders allocationDeciders, GatewayAllocator gatewayAllocator,
@ -77,6 +79,7 @@ public class AllocationService extends AbstractComponent {
this.gatewayAllocator = gatewayAllocator; this.gatewayAllocator = gatewayAllocator;
this.shardsAllocator = shardsAllocator; this.shardsAllocator = shardsAllocator;
this.clusterInfoService = clusterInfoService; this.clusterInfoService = clusterInfoService;
clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
} }
/** /**
@ -118,8 +121,10 @@ public class AllocationService extends AbstractComponent {
MetaData newMetaData = updateMetaDataWithRoutingTable(oldMetaData, oldRoutingTable, newRoutingTable); MetaData newMetaData = updateMetaDataWithRoutingTable(oldMetaData, oldRoutingTable, newRoutingTable);
assert newRoutingTable.validate(newMetaData); // validates the routing table is coherent with the cluster state metadata assert newRoutingTable.validate(newMetaData); // validates the routing table is coherent with the cluster state metadata
logClusterHealthStateChange( logClusterHealthStateChange(
new ClusterStateHealth(allocation.metaData(), allocation.routingTable()), new ClusterStateHealth(ClusterState.builder(clusterName).
new ClusterStateHealth(newMetaData, newRoutingTable), metaData(allocation.metaData()).routingTable(allocation.routingTable()).build()),
new ClusterStateHealth(ClusterState.builder(clusterName).
metaData(newMetaData).routingTable(newRoutingTable).build()),
reason reason
); );
return new RoutingAllocation.Result(true, newRoutingTable, newMetaData, explanations); return new RoutingAllocation.Result(true, newRoutingTable, newMetaData, explanations);

View File

@ -203,7 +203,6 @@ public class BalancedShardsAllocator extends AbstractComponent implements Shards
final float weightIndex = node.numShards(index) + numAdditionalShards - balancer.avgShardsPerNode(index); final float weightIndex = node.numShards(index) + numAdditionalShards - balancer.avgShardsPerNode(index);
return theta0 * weightShard + theta1 * weightIndex; return theta0 * weightShard + theta1 * weightIndex;
} }
} }
/** /**

View File

@ -126,15 +126,6 @@ public class AwarenessAllocationDecider extends AllocationDecider {
this.forcedAwarenessAttributes = forcedAwarenessAttributes; this.forcedAwarenessAttributes = forcedAwarenessAttributes;
} }
/**
* Get the attributes defined by this instance
*
* @return attributes defined by this instance
*/
public String[] awarenessAttributes() {
return this.awarenessAttributes;
}
private void setAwarenessAttributes(String[] awarenessAttributes) { private void setAwarenessAttributes(String[] awarenessAttributes) {
this.awarenessAttributes = awarenessAttributes; this.awarenessAttributes = awarenessAttributes;
} }

View File

@ -44,7 +44,6 @@ import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Priority; import org.elasticsearch.common.Priority;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.ClusterSettings;
@ -97,6 +96,7 @@ public class ClusterService extends AbstractLifecycleComponent<ClusterService> {
public static final String UPDATE_THREAD_NAME = "clusterService#updateTask"; public static final String UPDATE_THREAD_NAME = "clusterService#updateTask";
private final ThreadPool threadPool; private final ThreadPool threadPool;
private final ClusterName clusterName;
private BiConsumer<ClusterChangedEvent, Discovery.AckListener> clusterStatePublisher; private BiConsumer<ClusterChangedEvent, Discovery.AckListener> clusterStatePublisher;
@ -130,14 +130,13 @@ public class ClusterService extends AbstractLifecycleComponent<ClusterService> {
private NodeConnectionsService nodeConnectionsService; private NodeConnectionsService nodeConnectionsService;
@Inject public ClusterService(Settings settings,
public ClusterService(Settings settings, OperationRouting operationRouting, ClusterSettings clusterSettings, ThreadPool threadPool) {
ClusterSettings clusterSettings, ThreadPool threadPool, ClusterName clusterName) {
super(settings); super(settings);
this.operationRouting = operationRouting; this.operationRouting = new OperationRouting(settings, clusterSettings);
this.threadPool = threadPool; this.threadPool = threadPool;
this.clusterSettings = clusterSettings; this.clusterSettings = clusterSettings;
this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
// will be replaced on doStart. // will be replaced on doStart.
this.clusterState = ClusterState.builder(clusterName).build(); this.clusterState = ClusterState.builder(clusterName).build();
@ -490,6 +489,10 @@ public class ClusterService extends AbstractLifecycleComponent<ClusterService> {
return true; return true;
} }
public ClusterName getClusterName() {
return clusterName;
}
static abstract class SourcePrioritizedRunnable extends PrioritizedRunnable { static abstract class SourcePrioritizedRunnable extends PrioritizedRunnable {
protected final String source; protected final String source;
@ -1039,4 +1042,8 @@ public class ClusterService extends AbstractLifecycleComponent<ClusterService> {
public ClusterSettings getClusterSettings() { public ClusterSettings getClusterSettings() {
return clusterSettings; return clusterSettings;
} }
public Settings getSettings() {
return settings;
}
} }

View File

@ -169,11 +169,11 @@ public class NetworkModule extends AbstractModule {
public static final String LOCAL_TRANSPORT = "local"; public static final String LOCAL_TRANSPORT = "local";
public static final String NETTY_TRANSPORT = "netty"; public static final String NETTY_TRANSPORT = "netty";
public static final Setting<String> HTTP_TYPE_SETTING = Setting.simpleString("http.type", Property.NodeScope); public static final Setting<String> HTTP_TYPE_SETTING = Setting.simpleString(HTTP_TYPE_KEY, Property.NodeScope);
public static final Setting<Boolean> HTTP_ENABLED = Setting.boolSetting("http.enabled", true, Property.NodeScope); public static final Setting<Boolean> HTTP_ENABLED = Setting.boolSetting("http.enabled", true, Property.NodeScope);
public static final Setting<String> TRANSPORT_SERVICE_TYPE_SETTING = public static final Setting<String> TRANSPORT_SERVICE_TYPE_SETTING =
Setting.simpleString("transport.service.type", Property.NodeScope); Setting.simpleString(TRANSPORT_SERVICE_TYPE_KEY, Property.NodeScope);
public static final Setting<String> TRANSPORT_TYPE_SETTING = Setting.simpleString("transport.type", Property.NodeScope); public static final Setting<String> TRANSPORT_TYPE_SETTING = Setting.simpleString(TRANSPORT_TYPE_KEY, Property.NodeScope);

View File

@ -24,11 +24,11 @@ import org.elasticsearch.action.support.AutoCreateIndex;
import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.action.support.DestructiveOperations;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction; import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.bootstrap.BootstrapSettings; import org.elasticsearch.bootstrap.BootstrapSettings;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.common.util.PageCacheRecycler; import org.elasticsearch.common.util.PageCacheRecycler;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClientNodesService; import org.elasticsearch.client.transport.TransportClientNodesService;
import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.ClusterModule;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.InternalClusterInfoService; import org.elasticsearch.cluster.InternalClusterInfoService;
import org.elasticsearch.cluster.NodeConnectionsService; import org.elasticsearch.cluster.NodeConnectionsService;
import org.elasticsearch.cluster.action.index.MappingUpdatedAction; import org.elasticsearch.cluster.action.index.MappingUpdatedAction;

View File

@ -75,9 +75,9 @@ public class LocalDiscovery extends AbstractLifecycleComponent<Discovery> implem
private volatile ClusterState lastProcessedClusterState; private volatile ClusterState lastProcessedClusterState;
@Inject @Inject
public LocalDiscovery(Settings settings, ClusterName clusterName, ClusterService clusterService, ClusterSettings clusterSettings) { public LocalDiscovery(Settings settings, ClusterService clusterService, ClusterSettings clusterSettings) {
super(settings); super(settings);
this.clusterName = clusterName; this.clusterName = clusterService.getClusterName();
this.clusterService = clusterService; this.clusterService = clusterService;
this.discoverySettings = new DiscoverySettings(settings, clusterSettings); this.discoverySettings = new DiscoverySettings(settings, clusterSettings);
} }

View File

@ -150,12 +150,12 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
private volatile NodeJoinController nodeJoinController; private volatile NodeJoinController nodeJoinController;
@Inject @Inject
public ZenDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, public ZenDiscovery(Settings settings, ThreadPool threadPool,
TransportService transportService, final ClusterService clusterService, ClusterSettings clusterSettings, TransportService transportService, final ClusterService clusterService, ClusterSettings clusterSettings,
ZenPingService pingService, ElectMasterService electMasterService) { ZenPingService pingService, ElectMasterService electMasterService) {
super(settings); super(settings);
this.clusterName = clusterName;
this.clusterService = clusterService; this.clusterService = clusterService;
this.clusterName = clusterService.getClusterName();
this.transportService = transportService; this.transportService = transportService;
this.discoverySettings = new DiscoverySettings(settings, clusterSettings); this.discoverySettings = new DiscoverySettings(settings, clusterSettings);
this.pingService = pingService; this.pingService = pingService;
@ -182,10 +182,10 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
} }
}); });
this.masterFD = new MasterFaultDetection(settings, threadPool, transportService, clusterName, clusterService); this.masterFD = new MasterFaultDetection(settings, threadPool, transportService, clusterService);
this.masterFD.addListener(new MasterNodeFailureListener()); this.masterFD.addListener(new MasterNodeFailureListener());
this.nodesFD = new NodesFaultDetection(settings, threadPool, transportService, clusterName); this.nodesFD = new NodesFaultDetection(settings, threadPool, transportService, clusterService.getClusterName());
this.nodesFD.addListener(new NodeFaultDetectionListener()); this.nodesFD.addListener(new NodeFaultDetectionListener());
this.publishClusterState = this.publishClusterState =
@ -195,7 +195,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
clusterService::state, clusterService::state,
new NewPendingClusterStateListener(), new NewPendingClusterStateListener(),
discoverySettings, discoverySettings,
clusterName); clusterService.getClusterName());
this.pingService.setPingContextProvider(this); this.pingService.setPingContextProvider(this);
this.membership = new MembershipAction(settings, clusterService, transportService, this, new MembershipListener()); this.membership = new MembershipAction(settings, clusterService, transportService, this, new MembershipListener());

View File

@ -76,8 +76,8 @@ public class MasterFaultDetection extends FaultDetection {
private final AtomicBoolean notifiedMasterFailure = new AtomicBoolean(); private final AtomicBoolean notifiedMasterFailure = new AtomicBoolean();
public MasterFaultDetection(Settings settings, ThreadPool threadPool, TransportService transportService, public MasterFaultDetection(Settings settings, ThreadPool threadPool, TransportService transportService,
ClusterName clusterName, ClusterService clusterService) { ClusterService clusterService) {
super(settings, threadPool, transportService, clusterName); super(settings, threadPool, transportService, clusterService.getClusterName());
this.clusterService = clusterService; this.clusterService = clusterService;
logger.debug("[master] uses ping_interval [{}], ping_timeout [{}], ping_retries [{}]", pingInterval, pingRetryTimeout, pingRetryCount); logger.debug("[master] uses ping_interval [{}], ping_timeout [{}], ping_retries [{}]", pingInterval, pingRetryTimeout, pingRetryCount);
@ -418,7 +418,7 @@ public class MasterFaultDetection extends FaultDetection {
super.readFrom(in); super.readFrom(in);
nodeId = in.readString(); nodeId = in.readString();
masterNodeId = in.readString(); masterNodeId = in.readString();
clusterName = ClusterName.readClusterName(in); clusterName = new ClusterName(in);
} }
@Override @Override

View File

@ -314,7 +314,7 @@ public class NodesFaultDetection extends FaultDetection {
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
nodeId = in.readString(); nodeId = in.readString();
clusterName = ClusterName.readClusterName(in); clusterName = new ClusterName(in);
masterNode = new DiscoveryNode(in); masterNode = new DiscoveryNode(in);
clusterStateVersion = in.readLong(); clusterStateVersion = in.readLong();
} }

View File

@ -32,11 +32,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static org.elasticsearch.cluster.ClusterName.readClusterName;
/**
*
*/
public interface ZenPing extends LifecycleComponent<ZenPing> { public interface ZenPing extends LifecycleComponent<ZenPing> {
void setPingContextProvider(PingContextProvider contextProvider); void setPingContextProvider(PingContextProvider contextProvider);
@ -118,7 +113,7 @@ public interface ZenPing extends LifecycleComponent<ZenPing> {
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
clusterName = readClusterName(in); clusterName = new ClusterName(in);
node = new DiscoveryNode(in); node = new DiscoveryNode(in);
if (in.readBoolean()) { if (in.readBoolean()) {
master = new DiscoveryNode(in); master = new DiscoveryNode(in);

View File

@ -131,13 +131,13 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
private volatile boolean closed = false; private volatile boolean closed = false;
@Inject @Inject
public UnicastZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterName clusterName, public UnicastZenPing(Settings settings, ThreadPool threadPool, TransportService transportService,
Version version, ElectMasterService electMasterService, Version version, ElectMasterService electMasterService,
@Nullable Set<UnicastHostsProvider> unicastHostsProviders) { @Nullable Set<UnicastHostsProvider> unicastHostsProviders) {
super(settings); super(settings);
this.threadPool = threadPool; this.threadPool = threadPool;
this.transportService = transportService; this.transportService = transportService;
this.clusterName = clusterName; this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
this.electMasterService = electMasterService; this.electMasterService = electMasterService;
if (unicastHostsProviders != null) { if (unicastHostsProviders != null) {
@ -206,10 +206,6 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
hostsProviders.add(provider); hostsProviders.add(provider);
} }
public void removeHostsProvider(UnicastHostsProvider provider) {
hostsProviders.remove(provider);
}
@Override @Override
public void setPingContextProvider(PingContextProvider contextProvider) { public void setPingContextProvider(PingContextProvider contextProvider) {
this.contextProvider = contextProvider; this.contextProvider = contextProvider;
@ -222,16 +218,13 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
temporalResponses.clear(); temporalResponses.clear();
} }
public PingResponse[] pingAndWait(TimeValue timeout) { public PingResponse[] pingAndWait(TimeValue duration) {
final AtomicReference<PingResponse[]> response = new AtomicReference<>(); final AtomicReference<PingResponse[]> response = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
ping(new PingListener() { ping(pings -> {
@Override response.set(pings);
public void onPing(PingResponse[] pings) { latch.countDown();
response.set(pings); }, duration);
latch.countDown();
}
}, timeout);
try { try {
latch.await(); latch.await();
return response.get(); return response.get();
@ -241,25 +234,26 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
} }
@Override @Override
public void ping(final PingListener listener, final TimeValue timeout) { public void ping(final PingListener listener, final TimeValue duration) {
final SendPingsHandler sendPingsHandler = new SendPingsHandler(pingHandlerIdGenerator.incrementAndGet()); final SendPingsHandler sendPingsHandler = new SendPingsHandler(pingHandlerIdGenerator.incrementAndGet());
try { try {
receivedResponses.put(sendPingsHandler.id(), sendPingsHandler); receivedResponses.put(sendPingsHandler.id(), sendPingsHandler);
try { try {
sendPings(timeout, null, sendPingsHandler); sendPings(duration, null, sendPingsHandler);
} catch (RejectedExecutionException e) { } catch (RejectedExecutionException e) {
logger.debug("Ping execution rejected", e); logger.debug("Ping execution rejected", e);
// The RejectedExecutionException can come from the fact unicastConnectExecutor is at its max down in sendPings // The RejectedExecutionException can come from the fact unicastConnectExecutor is at its max down in sendPings
// But don't bail here, we can retry later on after the send ping has been scheduled. // But don't bail here, we can retry later on after the send ping has been scheduled.
} }
threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 2), ThreadPool.Names.GENERIC, new AbstractRunnable() {
threadPool.schedule(TimeValue.timeValueMillis(duration.millis() / 2), ThreadPool.Names.GENERIC, new AbstractRunnable() {
@Override @Override
protected void doRun() { protected void doRun() {
sendPings(timeout, null, sendPingsHandler); sendPings(duration, null, sendPingsHandler);
threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 2), ThreadPool.Names.GENERIC, new AbstractRunnable() { threadPool.schedule(TimeValue.timeValueMillis(duration.millis() / 2), ThreadPool.Names.GENERIC, new AbstractRunnable() {
@Override @Override
protected void doRun() throws Exception { protected void doRun() throws Exception {
sendPings(timeout, TimeValue.timeValueMillis(timeout.millis() / 2), sendPingsHandler); sendPings(duration, TimeValue.timeValueMillis(duration.millis() / 2), sendPingsHandler);
sendPingsHandler.close(); sendPingsHandler.close();
listener.onPing(sendPingsHandler.pingCollection().toArray()); listener.onPing(sendPingsHandler.pingCollection().toArray());
for (DiscoveryNode node : sendPingsHandler.nodeToDisconnect) { for (DiscoveryNode node : sendPingsHandler.nodeToDisconnect) {

View File

@ -130,16 +130,17 @@ public class Environment {
pluginsFile = homeFile.resolve("plugins"); pluginsFile = homeFile.resolve("plugins");
List<String> dataPaths = PATH_DATA_SETTING.get(settings); List<String> dataPaths = PATH_DATA_SETTING.get(settings);
final ClusterName clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
if (dataPaths.isEmpty() == false) { if (dataPaths.isEmpty() == false) {
dataFiles = new Path[dataPaths.size()]; dataFiles = new Path[dataPaths.size()];
dataWithClusterFiles = new Path[dataPaths.size()]; dataWithClusterFiles = new Path[dataPaths.size()];
for (int i = 0; i < dataPaths.size(); i++) { for (int i = 0; i < dataPaths.size(); i++) {
dataFiles[i] = PathUtils.get(dataPaths.get(i)); dataFiles[i] = PathUtils.get(dataPaths.get(i));
dataWithClusterFiles[i] = dataFiles[i].resolve(ClusterName.clusterNameFromSettings(settings).value()); dataWithClusterFiles[i] = dataFiles[i].resolve(clusterName.value());
} }
} else { } else {
dataFiles = new Path[]{homeFile.resolve("data")}; dataFiles = new Path[]{homeFile.resolve("data")};
dataWithClusterFiles = new Path[]{homeFile.resolve("data").resolve(ClusterName.clusterNameFromSettings(settings).value())}; dataWithClusterFiles = new Path[]{homeFile.resolve("data").resolve(clusterName.value())};
} }
if (PATH_SHARED_DATA_SETTING.exists(settings)) { if (PATH_SHARED_DATA_SETTING.exists(settings)) {
sharedDataFile = PathUtils.get(cleanPath(PATH_SHARED_DATA_SETTING.get(settings))); sharedDataFile = PathUtils.get(cleanPath(PATH_SHARED_DATA_SETTING.get(settings)));

View File

@ -155,7 +155,7 @@ public class Gateway extends AbstractComponent implements ClusterStateListener {
final ClusterSettings clusterSettings = clusterService.getClusterSettings(); final ClusterSettings clusterSettings = clusterService.getClusterSettings();
metaDataBuilder.persistentSettings(clusterSettings.archiveUnknownOrBrokenSettings(metaDataBuilder.persistentSettings())); metaDataBuilder.persistentSettings(clusterSettings.archiveUnknownOrBrokenSettings(metaDataBuilder.persistentSettings()));
metaDataBuilder.transientSettings(clusterSettings.archiveUnknownOrBrokenSettings(metaDataBuilder.transientSettings())); metaDataBuilder.transientSettings(clusterSettings.archiveUnknownOrBrokenSettings(metaDataBuilder.transientSettings()));
ClusterState.Builder builder = ClusterState.builder(clusterService.state().getClusterName()); ClusterState.Builder builder = ClusterState.builder(clusterService.getClusterName());
builder.metaData(metaDataBuilder); builder.metaData(metaDataBuilder);
listener.onSuccess(builder.build()); listener.onSuccess(builder.build());
} }

View File

@ -58,10 +58,10 @@ public class TransportNodesListGatewayMetaState extends TransportNodesAction<Tra
private GatewayMetaState metaState; private GatewayMetaState metaState;
@Inject @Inject
public TransportNodesListGatewayMetaState(Settings settings, ClusterName clusterName, ThreadPool threadPool, public TransportNodesListGatewayMetaState(Settings settings, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ClusterService clusterService, TransportService transportService,
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, ACTION_NAME, clusterName, threadPool, clusterService, transportService, actionFilters, super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters,
indexNameExpressionResolver, Request::new, NodeRequest::new, ThreadPool.Names.GENERIC, NodeGatewayMetaState.class); indexNameExpressionResolver, Request::new, NodeRequest::new, ThreadPool.Names.GENERIC, NodeGatewayMetaState.class);
} }
@ -91,7 +91,7 @@ public class TransportNodesListGatewayMetaState extends TransportNodesAction<Tra
@Override @Override
protected NodesGatewayMetaState newResponse(Request request, List<NodeGatewayMetaState> responses, List<FailedNodeException> failures) { protected NodesGatewayMetaState newResponse(Request request, List<NodeGatewayMetaState> responses, List<FailedNodeException> failures) {
return new NodesGatewayMetaState(clusterName, responses, failures); return new NodesGatewayMetaState(clusterService.getClusterName(), responses, failures);
} }
@Override @Override

View File

@ -69,12 +69,12 @@ public class TransportNodesListGatewayStartedShards extends
@Inject @Inject
public TransportNodesListGatewayStartedShards(Settings settings, ClusterName clusterName, ThreadPool threadPool, public TransportNodesListGatewayStartedShards(Settings settings, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ClusterService clusterService, TransportService transportService,
ActionFilters actionFilters, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, IndexNameExpressionResolver indexNameExpressionResolver,
NodeEnvironment env) { NodeEnvironment env) {
super(settings, ACTION_NAME, clusterName, threadPool, clusterService, transportService, actionFilters, super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters,
indexNameExpressionResolver, Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STARTED, indexNameExpressionResolver, Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STARTED,
NodeGatewayStartedShards.class); NodeGatewayStartedShards.class);
this.nodeEnv = env; this.nodeEnv = env;
@ -111,7 +111,7 @@ public class TransportNodesListGatewayStartedShards extends
@Override @Override
protected NodesGatewayStartedShards newResponse(Request request, protected NodesGatewayStartedShards newResponse(Request request,
List<NodeGatewayStartedShards> responses, List<FailedNodeException> failures) { List<NodeGatewayStartedShards> responses, List<FailedNodeException> failures) {
return new NodesGatewayStartedShards(clusterName, responses, failures); return new NodesGatewayStartedShards(clusterService.getClusterName(), responses, failures);
} }
@Override @Override

View File

@ -351,7 +351,7 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe
} }
private IndexShard getShard(ShardActiveRequest request) { private IndexShard getShard(ShardActiveRequest request) {
ClusterName thisClusterName = clusterService.state().getClusterName(); ClusterName thisClusterName = clusterService.getClusterName();
if (!thisClusterName.equals(request.clusterName)) { if (!thisClusterName.equals(request.clusterName)) {
logger.trace("shard exists request meant for cluster[{}], but this is cluster[{}], ignoring request", request.clusterName, thisClusterName); logger.trace("shard exists request meant for cluster[{}], but this is cluster[{}], ignoring request", request.clusterName, thisClusterName);
return null; return null;
@ -385,7 +385,7 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
clusterName = ClusterName.readClusterName(in); clusterName = new ClusterName(in);
indexUUID = in.readString(); indexUUID = in.readString();
shardId = ShardId.readShardId(in); shardId = ShardId.readShardId(in);
timeout = new TimeValue(in.readLong(), TimeUnit.MILLISECONDS); timeout = new TimeValue(in.readLong(), TimeUnit.MILLISECONDS);

View File

@ -76,11 +76,11 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesAction<T
private final NodeEnvironment nodeEnv; private final NodeEnvironment nodeEnv;
@Inject @Inject
public TransportNodesListShardStoreMetaData(Settings settings, ClusterName clusterName, ThreadPool threadPool, public TransportNodesListShardStoreMetaData(Settings settings, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ClusterService clusterService, TransportService transportService,
IndicesService indicesService, NodeEnvironment nodeEnv, ActionFilters actionFilters, IndicesService indicesService, NodeEnvironment nodeEnv, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver) { IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, ACTION_NAME, clusterName, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STORE, NodeStoreFilesMetaData.class); Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STORE, NodeStoreFilesMetaData.class);
this.indicesService = indicesService; this.indicesService = indicesService;
this.nodeEnv = nodeEnv; this.nodeEnv = nodeEnv;
@ -111,7 +111,7 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesAction<T
@Override @Override
protected NodesStoreFilesMetaData newResponse(Request request, protected NodesStoreFilesMetaData newResponse(Request request,
List<NodeStoreFilesMetaData> responses, List<FailedNodeException> failures) { List<NodeStoreFilesMetaData> responses, List<FailedNodeException> failures) {
return new NodesStoreFilesMetaData(clusterName, responses, failures); return new NodesStoreFilesMetaData(clusterService.getClusterName(), responses, failures);
} }
@Override @Override

View File

@ -29,7 +29,6 @@ import org.elasticsearch.action.ActionModule;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.client.node.NodeClientModule; import org.elasticsearch.client.node.NodeClientModule;
import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.ClusterModule;
import org.elasticsearch.cluster.ClusterNameModule;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateObserver; import org.elasticsearch.cluster.ClusterStateObserver;
import org.elasticsearch.cluster.MasterNodeChangePredicate; import org.elasticsearch.cluster.MasterNodeChangePredicate;
@ -243,6 +242,8 @@ public class Node implements Closeable {
throw new IllegalStateException("Failed to created node environment", ex); throw new IllegalStateException("Failed to created node environment", ex);
} }
final NetworkService networkService = new NetworkService(settings); final NetworkService networkService = new NetworkService(settings);
final ClusterService clusterService = new ClusterService(settings, settingsModule.getClusterSettings(), threadPool);
resourcesToClose.add(clusterService);
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(); NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
ModulesBuilder modules = new ModulesBuilder(); ModulesBuilder modules = new ModulesBuilder();
modules.add(new Version.Module(version)); modules.add(new Version.Module(version));
@ -257,9 +258,8 @@ public class Node implements Closeable {
modules.add(new NetworkModule(networkService, settings, false, namedWriteableRegistry)); modules.add(new NetworkModule(networkService, settings, false, namedWriteableRegistry));
modules.add(scriptModule); modules.add(scriptModule);
modules.add(new NodeEnvironmentModule(nodeEnvironment)); modules.add(new NodeEnvironmentModule(nodeEnvironment));
modules.add(new ClusterNameModule(this.settings));
modules.add(new DiscoveryModule(this.settings)); modules.add(new DiscoveryModule(this.settings));
modules.add(new ClusterModule(this.settings)); modules.add(new ClusterModule(this.settings, clusterService));
modules.add(new IndicesModule(namedWriteableRegistry)); modules.add(new IndicesModule(namedWriteableRegistry));
modules.add(new SearchModule(settings, namedWriteableRegistry)); modules.add(new SearchModule(settings, namedWriteableRegistry));
modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false)); modules.add(new ActionModule(DiscoveryNode.isIngestNode(settings), false));

View File

@ -46,8 +46,9 @@ import java.util.Objects;
class InternalOrder extends Terms.Order { class InternalOrder extends Terms.Order {
private static final byte COUNT_DESC_ID = 1; private static final byte COUNT_DESC_ID = 1;
private static final byte TERM_DESC_ID = 2; private static final byte COUNT_ASC_ID = 2;
private static final byte TERM_ASC_ID = 3; private static final byte TERM_DESC_ID = 3;
private static final byte TERM_ASC_ID = 4;
/** /**
* Order by the (higher) count of each term. * Order by the (higher) count of each term.
@ -59,6 +60,17 @@ class InternalOrder extends Terms.Order {
} }
}); });
/**
* Order by the (lower) count of each term.
*/
public static final InternalOrder COUNT_ASC = new InternalOrder(COUNT_ASC_ID, "_count", true, new Comparator<Terms.Bucket>() {
@Override
public int compare(Terms.Bucket o1, Terms.Bucket o2) {
return Long.compare(o1.getDocCount(), o2.getDocCount());
}
});
/** /**
* Order by the terms. * Order by the terms.
*/ */
@ -81,7 +93,7 @@ class InternalOrder extends Terms.Order {
} }
}); });
public static boolean isCountOrder(Terms.Order order) { public static boolean isCountDesc(Terms.Order order) {
if (order == COUNT_DESC) { if (order == COUNT_DESC) {
return true; return true;
} else if (order instanceof CompoundOrder) { } else if (order instanceof CompoundOrder) {
@ -336,6 +348,7 @@ class InternalOrder extends Terms.Order {
byte id = in.readByte(); byte id = in.readByte();
switch (id) { switch (id) {
case COUNT_DESC_ID: return absoluteOrder ? new CompoundOrder(Collections.singletonList((Terms.Order) InternalOrder.COUNT_DESC)) : InternalOrder.COUNT_DESC; case COUNT_DESC_ID: return absoluteOrder ? new CompoundOrder(Collections.singletonList((Terms.Order) InternalOrder.COUNT_DESC)) : InternalOrder.COUNT_DESC;
case COUNT_ASC_ID: return absoluteOrder ? new CompoundOrder(Collections.singletonList((Terms.Order) InternalOrder.COUNT_ASC)) : InternalOrder.COUNT_ASC;
case TERM_DESC_ID: return InternalOrder.TERM_DESC; case TERM_DESC_ID: return InternalOrder.TERM_DESC;
case TERM_ASC_ID: return InternalOrder.TERM_ASC; case TERM_ASC_ID: return InternalOrder.TERM_ASC;
case Aggregation.ID: case Aggregation.ID:

View File

@ -192,7 +192,7 @@ public abstract class InternalTerms<A extends InternalTerms, B extends InternalT
final long thisAggDocCountError; final long thisAggDocCountError;
if (terms.buckets.size() < this.shardSize || InternalOrder.isTermOrder(order)) { if (terms.buckets.size() < this.shardSize || InternalOrder.isTermOrder(order)) {
thisAggDocCountError = 0; thisAggDocCountError = 0;
} else if (InternalOrder.isCountOrder(this.order)) { } else if (InternalOrder.isCountDesc(this.order)) {
thisAggDocCountError = terms.buckets.get(terms.buckets.size() - 1).docCount; thisAggDocCountError = terms.buckets.get(terms.buckets.size() - 1).docCount;
} else { } else {
thisAggDocCountError = -1; thisAggDocCountError = -1;

View File

@ -100,10 +100,10 @@ public interface Terms extends MultiBucketsAggregation {
static abstract class Order implements ToXContent { static abstract class Order implements ToXContent {
/** /**
* @return a bucket ordering strategy that sorts buckets by their document counts (descending) * @return a bucket ordering strategy that sorts buckets by their document counts (ascending or descending)
*/ */
public static Order count() { public static Order count(boolean asc) {
return InternalOrder.COUNT_DESC; return asc ? InternalOrder.COUNT_ASC : InternalOrder.COUNT_DESC;
} }
/** /**

View File

@ -53,7 +53,7 @@ public class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Valu
public static final ParseField SHOW_TERM_DOC_COUNT_ERROR = new ParseField("show_term_doc_count_error"); public static final ParseField SHOW_TERM_DOC_COUNT_ERROR = new ParseField("show_term_doc_count_error");
public static final ParseField ORDER_FIELD = new ParseField("order"); public static final ParseField ORDER_FIELD = new ParseField("order");
private Terms.Order order = Terms.Order.compound(Terms.Order.count(), Terms.Order.term(true)); private Terms.Order order = Terms.Order.compound(Terms.Order.count(false), Terms.Order.term(true));
private IncludeExclude includeExclude = null; private IncludeExclude includeExclude = null;
private String executionHint = null; private String executionHint = null;
private SubAggCollectionMode collectMode = null; private SubAggCollectionMode collectMode = null;

View File

@ -77,19 +77,9 @@ public class TermsParser extends AbstractTermsParser {
@Override @Override
public boolean parseSpecial(String aggregationName, XContentParser parser, ParseFieldMatcher parseFieldMatcher, Token token, public boolean parseSpecial(String aggregationName, XContentParser parser, ParseFieldMatcher parseFieldMatcher, Token token,
String currentFieldName, Map<ParseField, Object> otherOptions) throws IOException { String currentFieldName, Map<ParseField, Object> otherOptions) throws IOException {
if (token == Token.VALUE_STRING) { if (token == XContentParser.Token.START_OBJECT) {
if (parseFieldMatcher.match(currentFieldName, TermsAggregationBuilder.ORDER_FIELD)) { if (parseFieldMatcher.match(currentFieldName, TermsAggregationBuilder.ORDER_FIELD)) {
if ("_count".equals(parser.text())) { otherOptions.put(TermsAggregationBuilder.ORDER_FIELD, Collections.singletonList(parseOrderParam(aggregationName, parser)));
otherOptions.put(TermsAggregationBuilder.ORDER_FIELD,
Collections.singletonList(new OrderElement(parser.text(), false)));
return true;
}
}
return false;
} else if (token == XContentParser.Token.START_OBJECT) {
if (parseFieldMatcher.match(currentFieldName, TermsAggregationBuilder.ORDER_FIELD)) {
otherOptions.put(TermsAggregationBuilder.ORDER_FIELD,
Collections.singletonList(parseOrderParam(aggregationName, parser)));
return true; return true;
} }
} else if (token == XContentParser.Token.START_ARRAY) { } else if (token == XContentParser.Token.START_ARRAY) {
@ -127,10 +117,6 @@ public class TermsParser extends AbstractTermsParser {
} else if (token == XContentParser.Token.VALUE_STRING) { } else if (token == XContentParser.Token.VALUE_STRING) {
String dir = parser.text(); String dir = parser.text();
if ("asc".equalsIgnoreCase(dir)) { if ("asc".equalsIgnoreCase(dir)) {
if ("_count".equals(orderKey)) {
throw new ParsingException(parser.getTokenLocation(),
"Sort by ascending _count is not supported in [" + aggregationName + "].");
}
orderAsc = true; orderAsc = true;
} else if ("desc".equalsIgnoreCase(dir)) { } else if ("desc".equalsIgnoreCase(dir)) {
orderAsc = false; orderAsc = false;
@ -181,7 +167,7 @@ public class TermsParser extends AbstractTermsParser {
return Order.term(asc); return Order.term(asc);
} }
if ("_count".equals(key)) { if ("_count".equals(key)) {
return Order.count(); return Order.count(asc);
} }
return Order.aggregation(key, asc); return Order.aggregation(key, asc);
} }

View File

@ -77,7 +77,7 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
private final CountDownLatch blockIncomingRequestsLatch = new CountDownLatch(1); private final CountDownLatch blockIncomingRequestsLatch = new CountDownLatch(1);
protected final Transport transport; protected final Transport transport;
protected final ThreadPool threadPool; protected final ThreadPool threadPool;
private final ClusterName clusterName; protected final ClusterName clusterName;
protected final TaskManager taskManager; protected final TaskManager taskManager;
volatile Map<String, RequestHandlerRegistry> requestHandlers = Collections.emptyMap(); volatile Map<String, RequestHandlerRegistry> requestHandlers = Collections.emptyMap();
@ -117,16 +117,12 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
/** if set will call requests sent to this id to shortcut and executed locally */ /** if set will call requests sent to this id to shortcut and executed locally */
volatile DiscoveryNode localNode = null; volatile DiscoveryNode localNode = null;
public TransportService(Transport transport, ThreadPool threadPool, ClusterName clusterName) {
this(EMPTY_SETTINGS, transport, threadPool, clusterName);
}
@Inject @Inject
public TransportService(Settings settings, Transport transport, ThreadPool threadPool, ClusterName clusterName) { public TransportService(Settings settings, Transport transport, ThreadPool threadPool) {
super(settings); super(settings);
this.transport = transport; this.transport = transport;
this.threadPool = threadPool; this.threadPool = threadPool;
this.clusterName = clusterName; this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
setTracerLogInclude(TRACE_LOG_INCLUDE_SETTING.get(settings)); setTracerLogInclude(TRACE_LOG_INCLUDE_SETTING.get(settings));
setTracerLogExclude(TRACE_LOG_EXCLUDE_SETTING.get(settings)); setTracerLogExclude(TRACE_LOG_EXCLUDE_SETTING.get(settings));
tracerLog = Loggers.getLogger(logger, ".tracer"); tracerLog = Loggers.getLogger(logger, ".tracer");
@ -397,7 +393,7 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
discoveryNode = in.readOptionalWriteable(DiscoveryNode::new); discoveryNode = in.readOptionalWriteable(DiscoveryNode::new);
clusterName = ClusterName.readClusterName(in); clusterName = new ClusterName(in);
version = Version.readVersion(in); version = Version.readVersion(in);
} }
@ -1054,5 +1050,4 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
} }
} }
} }

View File

@ -25,6 +25,7 @@ import org.elasticsearch.cluster.health.ClusterStateHealth;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
@ -52,7 +53,7 @@ public class ClusterHealthResponsesTests extends ESTestCase {
} }
public void testClusterHealth() throws IOException { public void testClusterHealth() throws IOException {
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).build(); ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).build();
int pendingTasks = randomIntBetween(0, 200); int pendingTasks = randomIntBetween(0, 200);
int inFlight = randomIntBetween(0, 200); int inFlight = randomIntBetween(0, 200);
int delayedUnassigned = randomIntBetween(0, 200); int delayedUnassigned = randomIntBetween(0, 200);

View File

@ -28,7 +28,6 @@ import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
import org.elasticsearch.action.support.nodes.BaseNodeRequest; import org.elasticsearch.action.support.nodes.BaseNodeRequest;
import org.elasticsearch.action.support.nodes.BaseNodesRequest; import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.action.support.replication.ClusterStateCreationUtils; import org.elasticsearch.action.support.replication.ClusterStateCreationUtils;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
@ -140,10 +139,10 @@ public class CancellableTasksTests extends TaskManagerTestCase {
final CountDownLatch actionStartedLatch; final CountDownLatch actionStartedLatch;
CancellableTestNodesAction(Settings settings, String actionName, ClusterName clusterName, ThreadPool threadPool, CancellableTestNodesAction(Settings settings, String actionName, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, boolean shouldBlock, CountDownLatch ClusterService clusterService, TransportService transportService, boolean shouldBlock, CountDownLatch
actionStartedLatch) { actionStartedLatch) {
super(settings, actionName, clusterName, threadPool, clusterService, transportService, CancellableNodesRequest::new, super(settings, actionName, threadPool, clusterService, transportService, CancellableNodesRequest::new,
CancellableNodeRequest::new); CancellableNodeRequest::new);
this.shouldBlock = shouldBlock; this.shouldBlock = shouldBlock;
this.actionStartedLatch = actionStartedLatch; this.actionStartedLatch = actionStartedLatch;
@ -202,7 +201,7 @@ public class CancellableTasksTests extends TaskManagerTestCase {
for (int i = 0; i < testNodes.length; i++) { for (int i = 0; i < testNodes.length; i++) {
boolean shouldBlock = blockOnNodes.contains(testNodes[i]); boolean shouldBlock = blockOnNodes.contains(testNodes[i]);
logger.info("The action in the node [{}] should block: [{}]", testNodes[i].discoveryNode.getId(), shouldBlock); logger.info("The action in the node [{}] should block: [{}]", testNodes[i].discoveryNode.getId(), shouldBlock);
actions[i] = new CancellableTestNodesAction(Settings.EMPTY, "testAction", CLUSTER_NAME, threadPool, testNodes[i] actions[i] = new CancellableTestNodesAction(CLUSTER_SETTINGS, "testAction", threadPool, testNodes[i]
.clusterService, testNodes[i].transportService, shouldBlock, actionLatch); .clusterService, testNodes[i].transportService, shouldBlock, actionLatch);
} }
Task task = actions[0].execute(request, listener); Task task = actions[0].execute(request, listener);

View File

@ -67,7 +67,7 @@ import static org.elasticsearch.test.ClusterServiceUtils.setState;
public abstract class TaskManagerTestCase extends ESTestCase { public abstract class TaskManagerTestCase extends ESTestCase {
protected static ThreadPool threadPool; protected static ThreadPool threadPool;
public static final ClusterName CLUSTER_NAME = new ClusterName("test-cluster"); public static final Settings CLUSTER_SETTINGS = Settings.builder().put("cluster.name", "test-cluster").build();
protected TestNode[] testNodes; protected TestNode[] testNodes;
protected int nodesCount; protected int nodesCount;
@ -136,17 +136,17 @@ public abstract class TaskManagerTestCase extends ESTestCase {
abstract class AbstractTestNodesAction<NodesRequest extends BaseNodesRequest<NodesRequest>, NodeRequest extends BaseNodeRequest> abstract class AbstractTestNodesAction<NodesRequest extends BaseNodesRequest<NodesRequest>, NodeRequest extends BaseNodeRequest>
extends TransportNodesAction<NodesRequest, NodesResponse, NodeRequest, NodeResponse> { extends TransportNodesAction<NodesRequest, NodesResponse, NodeRequest, NodeResponse> {
AbstractTestNodesAction(Settings settings, String actionName, ClusterName clusterName, ThreadPool threadPool, AbstractTestNodesAction(Settings settings, String actionName, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, Supplier<NodesRequest> request, ClusterService clusterService, TransportService transportService, Supplier<NodesRequest> request,
Supplier<NodeRequest> nodeRequest) { Supplier<NodeRequest> nodeRequest) {
super(settings, actionName, clusterName, threadPool, clusterService, transportService, super(settings, actionName, threadPool, clusterService, transportService,
new ActionFilters(new HashSet<>()), new IndexNameExpressionResolver(Settings.EMPTY), new ActionFilters(new HashSet<>()), new IndexNameExpressionResolver(Settings.EMPTY),
request, nodeRequest, ThreadPool.Names.GENERIC, NodeResponse.class); request, nodeRequest, ThreadPool.Names.GENERIC, NodeResponse.class);
} }
@Override @Override
protected NodesResponse newResponse(NodesRequest request, List<NodeResponse> responses, List<FailedNodeException> failures) { protected NodesResponse newResponse(NodesRequest request, List<NodeResponse> responses, List<FailedNodeException> failures) {
return new NodesResponse(clusterName, responses, failures); return new NodesResponse(clusterService.getClusterName(), responses, failures);
} }
@Override @Override
@ -166,10 +166,9 @@ public abstract class TaskManagerTestCase extends ESTestCase {
public static class TestNode implements Releasable { public static class TestNode implements Releasable {
public TestNode(String name, ThreadPool threadPool, Settings settings) { public TestNode(String name, ThreadPool threadPool, Settings settings) {
clusterService = createClusterService(threadPool); clusterService = createClusterService(threadPool);
ClusterName clusterName = clusterService.state().getClusterName();
transportService = new TransportService(settings, transportService = new TransportService(settings,
new LocalTransport(settings, threadPool, Version.CURRENT, new NamedWriteableRegistry(), new LocalTransport(settings, threadPool, Version.CURRENT, new NamedWriteableRegistry(),
new NoneCircuitBreakerService()), threadPool, clusterName) { new NoneCircuitBreakerService()), threadPool) {
@Override @Override
protected TaskManager createTaskManager() { protected TaskManager createTaskManager() {
if (MockTaskManager.USE_MOCK_TASK_MANAGER_SETTING.get(settings)) { if (MockTaskManager.USE_MOCK_TASK_MANAGER_SETTING.get(settings)) {
@ -185,9 +184,9 @@ public abstract class TaskManagerTestCase extends ESTestCase {
emptyMap(), emptySet(), Version.CURRENT); emptyMap(), emptySet(), Version.CURRENT);
IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(settings); IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(settings);
ActionFilters actionFilters = new ActionFilters(emptySet()); ActionFilters actionFilters = new ActionFilters(emptySet());
transportListTasksAction = new TransportListTasksAction(settings, CLUSTER_NAME, threadPool, clusterService, transportService, transportListTasksAction = new TransportListTasksAction(settings, threadPool, clusterService, transportService,
actionFilters, indexNameExpressionResolver); actionFilters, indexNameExpressionResolver);
transportCancelTasksAction = new TransportCancelTasksAction(settings, CLUSTER_NAME, threadPool, clusterService, transportCancelTasksAction = new TransportCancelTasksAction(settings, threadPool, clusterService,
transportService, actionFilters, indexNameExpressionResolver); transportService, actionFilters, indexNameExpressionResolver);
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
} }

View File

@ -246,9 +246,9 @@ public class TestTaskPlugin extends Plugin {
public static class TransportTestTaskAction extends TransportNodesAction<NodesRequest, NodesResponse, NodeRequest, NodeResponse> { public static class TransportTestTaskAction extends TransportNodesAction<NodesRequest, NodesResponse, NodeRequest, NodeResponse> {
@Inject @Inject
public TransportTestTaskAction(Settings settings, ClusterName clusterName, ThreadPool threadPool, public TransportTestTaskAction(Settings settings, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService) { ClusterService clusterService, TransportService transportService) {
super(settings, TestTaskAction.NAME, clusterName, threadPool, clusterService, transportService, super(settings, TestTaskAction.NAME, threadPool, clusterService, transportService,
new ActionFilters(new HashSet<>()), new IndexNameExpressionResolver(Settings.EMPTY), new ActionFilters(new HashSet<>()), new IndexNameExpressionResolver(Settings.EMPTY),
NodesRequest::new, NodeRequest::new, ThreadPool.Names.GENERIC, NodeResponse.class); NodesRequest::new, NodeRequest::new, ThreadPool.Names.GENERIC, NodeResponse.class);
} }
@ -258,7 +258,7 @@ public class TestTaskPlugin extends Plugin {
if (request.getShouldFail()) { if (request.getShouldFail()) {
throw new IllegalStateException("Simulating operation failure"); throw new IllegalStateException("Simulating operation failure");
} }
return new NodesResponse(clusterName, responses, failures); return new NodesResponse(clusterService.getClusterName(), responses, failures);
} }
@Override @Override
@ -425,10 +425,10 @@ public class TestTaskPlugin extends Plugin {
UnblockTestTasksResponse, UnblockTestTaskResponse> { UnblockTestTasksResponse, UnblockTestTaskResponse> {
@Inject @Inject
public TransportUnblockTestTasksAction(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService public TransportUnblockTestTasksAction(Settings settings,ThreadPool threadPool, ClusterService
clusterService, clusterService,
TransportService transportService) { TransportService transportService) {
super(settings, UnblockTestTasksAction.NAME, clusterName, threadPool, clusterService, transportService, new ActionFilters(new super(settings, UnblockTestTasksAction.NAME, threadPool, clusterService, transportService, new ActionFilters(new
HashSet<>()), new IndexNameExpressionResolver(Settings.EMPTY), HashSet<>()), new IndexNameExpressionResolver(Settings.EMPTY),
UnblockTestTasksRequest::new, UnblockTestTasksResponse::new, ThreadPool.Names.MANAGEMENT); UnblockTestTasksRequest::new, UnblockTestTasksResponse::new, ThreadPool.Names.MANAGEMENT);
} }

View File

@ -35,7 +35,6 @@ import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.action.support.tasks.BaseTasksRequest; import org.elasticsearch.action.support.tasks.BaseTasksRequest;
import org.elasticsearch.action.support.tasks.BaseTasksResponse; import org.elasticsearch.action.support.tasks.BaseTasksResponse;
import org.elasticsearch.action.support.tasks.TransportTasksAction; import org.elasticsearch.action.support.tasks.TransportTasksAction;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
@ -170,9 +169,9 @@ public class TransportTasksActionTests extends TaskManagerTestCase {
*/ */
abstract class TestNodesAction extends AbstractTestNodesAction<NodesRequest, NodeRequest> { abstract class TestNodesAction extends AbstractTestNodesAction<NodesRequest, NodeRequest> {
TestNodesAction(Settings settings, String actionName, ClusterName clusterName, ThreadPool threadPool, TestNodesAction(Settings settings, String actionName, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService) { ClusterService clusterService, TransportService transportService) {
super(settings, actionName, clusterName, threadPool, clusterService, transportService, NodesRequest::new, NodeRequest::new); super(settings, actionName, threadPool, clusterService, transportService, NodesRequest::new, NodeRequest::new);
} }
@Override @Override
@ -252,9 +251,9 @@ public class TransportTasksActionTests extends TaskManagerTestCase {
*/ */
static abstract class TestTasksAction extends TransportTasksAction<Task, TestTasksRequest, TestTasksResponse, TestTaskResponse> { static abstract class TestTasksAction extends TransportTasksAction<Task, TestTasksRequest, TestTasksResponse, TestTaskResponse> {
protected TestTasksAction(Settings settings, String actionName, ClusterName clusterName, ThreadPool threadPool, protected TestTasksAction(Settings settings, String actionName, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService) { ClusterService clusterService, TransportService transportService) {
super(settings, actionName, clusterName, threadPool, clusterService, transportService, new ActionFilters(new HashSet<>()), super(settings, actionName, threadPool, clusterService, transportService, new ActionFilters(new HashSet<>()),
new IndexNameExpressionResolver(Settings.EMPTY), TestTasksRequest::new, TestTasksResponse::new, new IndexNameExpressionResolver(Settings.EMPTY), TestTasksRequest::new, TestTasksResponse::new,
ThreadPool.Names.MANAGEMENT); ThreadPool.Names.MANAGEMENT);
} }
@ -298,7 +297,7 @@ public class TransportTasksActionTests extends TaskManagerTestCase {
TestNodesAction[] actions = new TestNodesAction[nodesCount]; TestNodesAction[] actions = new TestNodesAction[nodesCount];
for (int i = 0; i < testNodes.length; i++) { for (int i = 0; i < testNodes.length; i++) {
final int node = i; final int node = i;
actions[i] = new TestNodesAction(Settings.EMPTY, "testAction", CLUSTER_NAME, threadPool, testNodes[i].clusterService, actions[i] = new TestNodesAction(CLUSTER_SETTINGS, "testAction", threadPool, testNodes[i].clusterService,
testNodes[i].transportService) { testNodes[i].transportService) {
@Override @Override
protected NodeResponse nodeOperation(NodeRequest request) { protected NodeResponse nodeOperation(NodeRequest request) {
@ -583,7 +582,7 @@ public class TransportTasksActionTests extends TaskManagerTestCase {
RecordingTaskManagerListener[] listeners = setupListeners(testNodes, "testAction*"); RecordingTaskManagerListener[] listeners = setupListeners(testNodes, "testAction*");
for (int i = 0; i < testNodes.length; i++) { for (int i = 0; i < testNodes.length; i++) {
final int node = i; final int node = i;
actions[i] = new TestNodesAction(Settings.EMPTY, "testAction", CLUSTER_NAME, threadPool, testNodes[i].clusterService, actions[i] = new TestNodesAction(CLUSTER_SETTINGS, "testAction", threadPool, testNodes[i].clusterService,
testNodes[i].transportService) { testNodes[i].transportService) {
@Override @Override
protected NodeResponse nodeOperation(NodeRequest request) { protected NodeResponse nodeOperation(NodeRequest request) {
@ -623,7 +622,7 @@ public class TransportTasksActionTests extends TaskManagerTestCase {
for (int i = 0; i < testNodes.length; i++) { for (int i = 0; i < testNodes.length; i++) {
final int node = i; final int node = i;
// Simulate task action that fails on one of the tasks on one of the nodes // Simulate task action that fails on one of the tasks on one of the nodes
tasksActions[i] = new TestTasksAction(Settings.EMPTY, "testTasksAction", CLUSTER_NAME, threadPool, testNodes[i].clusterService, tasksActions[i] = new TestTasksAction(CLUSTER_SETTINGS, "testTasksAction", threadPool, testNodes[i].clusterService,
testNodes[i].transportService) { testNodes[i].transportService) {
@Override @Override
protected TestTaskResponse taskOperation(TestTasksRequest request, Task task) { protected TestTaskResponse taskOperation(TestTasksRequest request, Task task) {
@ -681,7 +680,7 @@ public class TransportTasksActionTests extends TaskManagerTestCase {
final int node = i; final int node = i;
// Simulate a task action that works on all nodes except nodes listed in filterNodes. // Simulate a task action that works on all nodes except nodes listed in filterNodes.
// We are testing that it works. // We are testing that it works.
tasksActions[i] = new TestTasksAction(Settings.EMPTY, "testTasksAction", CLUSTER_NAME, threadPool, tasksActions[i] = new TestTasksAction(CLUSTER_SETTINGS, "testTasksAction", threadPool,
testNodes[i].clusterService, testNodes[i].transportService) { testNodes[i].clusterService, testNodes[i].transportService) {
@Override @Override

View File

@ -163,7 +163,8 @@ public class ClusterRerouteTests extends ESAllocationTestCase {
routingTableBuilder.addAsNew(metaData.index("idx")); routingTableBuilder.addAsNew(metaData.index("idx"));
RoutingTable routingTable = routingTableBuilder.build(); RoutingTable routingTable = routingTableBuilder.build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING
.getDefault(Settings.EMPTY))
.metaData(metaData).routingTable(routingTable).build(); .metaData(metaData).routingTable(routingTable).build();
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))) clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")))
.build(); .build();

View File

@ -22,6 +22,7 @@ package org.elasticsearch.action.admin.indices.shrink;
import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriter;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.EmptyClusterInfoService; import org.elasticsearch.cluster.EmptyClusterInfoService;
import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.block.ClusterBlocks;
@ -61,7 +62,7 @@ public class TransportShrinkActionTests extends ESTestCase {
routingTableBuilder.addAsNew(metaData.index(name)); routingTableBuilder.addAsNew(metaData.index(name));
RoutingTable routingTable = routingTableBuilder.build(); RoutingTable routingTable = routingTableBuilder.build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData).routingTable(routingTable).blocks(ClusterBlocks.builder().addBlocks(indexMetaData)).build(); .metaData(metaData).routingTable(routingTable).blocks(ClusterBlocks.builder().addBlocks(indexMetaData)).build();
return clusterState; return clusterState;
} }

View File

@ -87,7 +87,7 @@ public class TransportBulkActionTookTests extends ESTestCase {
private TransportBulkAction createAction(boolean controlled, AtomicLong expected) { private TransportBulkAction createAction(boolean controlled, AtomicLong expected) {
CapturingTransport capturingTransport = new CapturingTransport(); CapturingTransport capturingTransport = new CapturingTransport();
TransportService transportService = new TransportService(capturingTransport, threadPool, clusterService.state().getClusterName()); TransportService transportService = new TransportService(clusterService.getSettings(), capturingTransport, threadPool);
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
IndexNameExpressionResolver resolver = new Resolver(Settings.EMPTY); IndexNameExpressionResolver resolver = new Resolver(Settings.EMPTY);

View File

@ -142,6 +142,6 @@ public class AutoCreateIndexTests extends ESTestCase {
for (String index : indices) { for (String index : indices) {
metaData.put(IndexMetaData.builder(index).settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1)); metaData.put(IndexMetaData.builder(index).settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1));
} }
return ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).build(); return ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).build();
} }
} }

View File

@ -191,7 +191,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase {
super.setUp(); super.setUp();
transport = new CapturingTransport(); transport = new CapturingTransport();
clusterService = createClusterService(THREAD_POOL); clusterService = createClusterService(THREAD_POOL);
final TransportService transportService = new TransportService(transport, THREAD_POOL, clusterService.state().getClusterName()); final TransportService transportService = new TransportService(clusterService.getSettings(), transport, THREAD_POOL);
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
setClusterState(clusterService, TEST_INDEX); setClusterState(clusterService, TEST_INDEX);

View File

@ -86,7 +86,7 @@ public class TransportMasterNodeActionTests extends ESTestCase {
super.setUp(); super.setUp();
transport = new CapturingTransport(); transport = new CapturingTransport();
clusterService = createClusterService(threadPool); clusterService = createClusterService(threadPool);
transportService = new TransportService(transport, threadPool, clusterService.state().getClusterName()); transportService = new TransportService(clusterService.getSettings(), transport, threadPool);
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
localNode = new DiscoveryNode("local_node", DummyTransportAddress.INSTANCE, Collections.emptyMap(), localNode = new DiscoveryNode("local_node", DummyTransportAddress.INSTANCE, Collections.emptyMap(),

View File

@ -63,7 +63,6 @@ import static org.mockito.Mockito.mock;
public class TransportNodesActionTests extends ESTestCase { public class TransportNodesActionTests extends ESTestCase {
private static ThreadPool THREAD_POOL; private static ThreadPool THREAD_POOL;
private static ClusterName CLUSTER_NAME = new ClusterName("test-cluster");
private ClusterService clusterService; private ClusterService clusterService;
private CapturingTransport transport; private CapturingTransport transport;
@ -178,7 +177,7 @@ public class TransportNodesActionTests extends ESTestCase {
super.setUp(); super.setUp();
transport = new CapturingTransport(); transport = new CapturingTransport();
clusterService = createClusterService(THREAD_POOL); clusterService = createClusterService(THREAD_POOL);
transportService = new TransportService(transport, THREAD_POOL, clusterService.state().getClusterName()); transportService = new TransportService(clusterService.getSettings(), transport, THREAD_POOL);
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
int numNodes = randomIntBetween(3, 10); int numNodes = randomIntBetween(3, 10);
@ -196,7 +195,7 @@ public class TransportNodesActionTests extends ESTestCase {
} }
discoBuilder.localNodeId(randomFrom(discoveryNodes).getId()); discoBuilder.localNodeId(randomFrom(discoveryNodes).getId());
discoBuilder.masterNodeId(randomFrom(discoveryNodes).getId()); discoBuilder.masterNodeId(randomFrom(discoveryNodes).getId());
ClusterState.Builder stateBuilder = ClusterState.builder(CLUSTER_NAME); ClusterState.Builder stateBuilder = ClusterState.builder(clusterService.getClusterName());
stateBuilder.nodes(discoBuilder); stateBuilder.nodes(discoBuilder);
ClusterState clusterState = stateBuilder.build(); ClusterState clusterState = stateBuilder.build();
setState(clusterService, clusterState); setState(clusterService, clusterState);
@ -246,14 +245,14 @@ public class TransportNodesActionTests extends ESTestCase {
TestTransportNodesAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService TestTransportNodesAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService
transportService, ActionFilters actionFilters, Supplier<TestNodesRequest> request, transportService, ActionFilters actionFilters, Supplier<TestNodesRequest> request,
Supplier<TestNodeRequest> nodeRequest, String nodeExecutor) { Supplier<TestNodeRequest> nodeRequest, String nodeExecutor) {
super(settings, "indices:admin/test", CLUSTER_NAME, threadPool, clusterService, transportService, actionFilters, super(settings, "indices:admin/test", threadPool, clusterService, transportService, actionFilters,
null, request, nodeRequest, nodeExecutor, TestNodeResponse.class); null, request, nodeRequest, nodeExecutor, TestNodeResponse.class);
} }
@Override @Override
protected TestNodesResponse newResponse(TestNodesRequest request, protected TestNodesResponse newResponse(TestNodesRequest request,
List<TestNodeResponse> responses, List<FailedNodeException> failures) { List<TestNodeResponse> responses, List<FailedNodeException> failures) {
return new TestNodesResponse(request, responses, failures); return new TestNodesResponse(clusterService.getClusterName(), request, responses, failures);
} }
@Override @Override
@ -302,8 +301,9 @@ public class TransportNodesActionTests extends ESTestCase {
private final TestNodesRequest request; private final TestNodesRequest request;
TestNodesResponse(TestNodesRequest request, List<TestNodeResponse> nodeResponses, List<FailedNodeException> failures) { TestNodesResponse(ClusterName clusterName, TestNodesRequest request, List<TestNodeResponse> nodeResponses,
super(CLUSTER_NAME, nodeResponses, failures); List<FailedNodeException> failures) {
super(clusterName, nodeResponses, failures);
this.request = request; this.request = request;
} }

View File

@ -91,7 +91,7 @@ public class BroadcastReplicationTests extends ESTestCase {
super.setUp(); super.setUp();
LocalTransport transport = new LocalTransport(Settings.EMPTY, threadPool, Version.CURRENT, new NamedWriteableRegistry(), circuitBreakerService); LocalTransport transport = new LocalTransport(Settings.EMPTY, threadPool, Version.CURRENT, new NamedWriteableRegistry(), circuitBreakerService);
clusterService = createClusterService(threadPool); clusterService = createClusterService(threadPool);
transportService = new TransportService(transport, threadPool, clusterService.state().getClusterName()); transportService = new TransportService(clusterService.getSettings(), transport, threadPool);
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
broadcastReplicationAction = new TestBroadcastReplicationAction(Settings.EMPTY, threadPool, clusterService, transportService, new ActionFilters(new HashSet<ActionFilter>()), new IndexNameExpressionResolver(Settings.EMPTY), null); broadcastReplicationAction = new TestBroadcastReplicationAction(Settings.EMPTY, threadPool, clusterService, transportService, new ActionFilters(new HashSet<ActionFilter>()), new IndexNameExpressionResolver(Settings.EMPTY), null);

View File

@ -119,7 +119,7 @@ public class TransportReplicationActionTests extends ESTestCase {
super.setUp(); super.setUp();
transport = new CapturingTransport(); transport = new CapturingTransport();
clusterService = createClusterService(threadPool); clusterService = createClusterService(threadPool);
transportService = new TransportService(transport, threadPool, clusterService.state().getClusterName()); transportService = new TransportService(clusterService.getSettings(), transport, threadPool);
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
action = new Action(Settings.EMPTY, "testAction", transportService, clusterService, threadPool); action = new Action(Settings.EMPTY, "testAction", transportService, clusterService, threadPool);

View File

@ -142,7 +142,7 @@ public class TransportInstanceSingleOperationActionTests extends ESTestCase {
super.setUp(); super.setUp();
transport = new CapturingTransport(); transport = new CapturingTransport();
clusterService = createClusterService(THREAD_POOL); clusterService = createClusterService(THREAD_POOL);
transportService = new TransportService(transport, THREAD_POOL, clusterService.state().getClusterName()); transportService = new TransportService(clusterService.getSettings(), transport, THREAD_POOL);
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
action = new TestTransportInstanceSingleOperationAction( action = new TestTransportInstanceSingleOperationAction(

View File

@ -238,7 +238,7 @@ public abstract class AbstractTermVectorsTestCase extends ESIntegTestCase {
contentArray[j] = fieldContentOptions[randomInt(fieldContentOptions.length - 1)]; contentArray[j] = fieldContentOptions[randomInt(fieldContentOptions.length - 1)];
docSource.put(fieldSettings[j].name, contentArray[j]); docSource.put(fieldSettings[j].name, contentArray[j]);
} }
final String id = routingKeyForShard(index, "type", i); final String id = routingKeyForShard(index, i);
TestDoc doc = new TestDoc(id, fieldSettings, contentArray.clone()); TestDoc doc = new TestDoc(id, fieldSettings, contentArray.clone());
index(doc.index, doc.type, doc.id, docSource); index(doc.index, doc.type, doc.id, docSource);
testDocs[i] = doc; testDocs[i] = doc;

View File

@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.component.Lifecycle; import org.elasticsearch.common.component.Lifecycle;
import org.elasticsearch.common.component.LifecycleListener; import org.elasticsearch.common.component.LifecycleListener;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.BoundTransportAddress; import org.elasticsearch.common.transport.BoundTransportAddress;
import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.ConnectTransportException; import org.elasticsearch.transport.ConnectTransportException;
@ -74,7 +75,8 @@ abstract class FailAndRetryMockTransport<Response extends TransportResponse> imp
//we make sure that nodes get added to the connected ones when calling addTransportAddress, by returning proper nodes info //we make sure that nodes get added to the connected ones when calling addTransportAddress, by returning proper nodes info
if (connectMode) { if (connectMode) {
TransportResponseHandler transportResponseHandler = transportServiceAdapter.onResponseReceived(requestId); TransportResponseHandler transportResponseHandler = transportServiceAdapter.onResponseReceived(requestId);
transportResponseHandler.handleResponse(new LivenessResponse(ClusterName.DEFAULT, node)); transportResponseHandler.handleResponse(new LivenessResponse(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY),
node));
return; return;
} }

View File

@ -67,6 +67,7 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase {
TransportClient client = TransportClient.builder() TransportClient client = TransportClient.builder()
.settings(Settings.builder() .settings(Settings.builder()
.put("client.transport.sniff", false) .put("client.transport.sniff", false)
.put("cluster.name", "cluster1")
.put("node.name", "transport_client_" + this.getTestName()) .put("node.name", "transport_client_" + this.getTestName())
.put(headersSettings) .put(headersSettings)
.build()) .build())
@ -115,8 +116,8 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase {
CountDownLatch clusterStateLatch = new CountDownLatch(1); CountDownLatch clusterStateLatch = new CountDownLatch(1);
@Inject @Inject
public InternalTransportService(Settings settings, Transport transport, ThreadPool threadPool, ClusterName clusterName) { public InternalTransportService(Settings settings, Transport transport, ThreadPool threadPool) {
super(settings, transport, threadPool, clusterName); super(settings, transport, threadPool);
} }
@Override @SuppressWarnings("unchecked") @Override @SuppressWarnings("unchecked")
@ -124,7 +125,7 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase {
TransportRequestOptions options, TransportResponseHandler<T> handler) { TransportRequestOptions options, TransportResponseHandler<T> handler) {
if (TransportLivenessAction.NAME.equals(action)) { if (TransportLivenessAction.NAME.equals(action)) {
assertHeaders(threadPool); assertHeaders(threadPool);
((TransportResponseHandler<LivenessResponse>) handler).handleResponse(new LivenessResponse(ClusterName.DEFAULT, node)); ((TransportResponseHandler<LivenessResponse>) handler).handleResponse(new LivenessResponse(clusterName, node));
return; return;
} }
if (ClusterStateAction.NAME.equals(action)) { if (ClusterStateAction.NAME.equals(action)) {

View File

@ -63,7 +63,8 @@ public class TransportClientNodesServiceTests extends ESTestCase {
private final int nodesCount; private final int nodesCount;
TestIteration() { TestIteration() {
ClusterName clusterName = new ClusterName("test"); Settings settings = Settings.builder().put("cluster.name", "test").build();
ClusterName clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
threadPool = new TestThreadPool("transport-client-nodes-service-tests"); threadPool = new TestThreadPool("transport-client-nodes-service-tests");
transport = new FailAndRetryMockTransport<TestResponse>(random(), clusterName) { transport = new FailAndRetryMockTransport<TestResponse>(random(), clusterName) {
@Override @Override
@ -76,7 +77,7 @@ public class TransportClientNodesServiceTests extends ESTestCase {
return new TestResponse(); return new TestResponse();
} }
}; };
transportService = new TransportService(Settings.EMPTY, transport, threadPool, clusterName) { transportService = new TransportService(settings, transport, threadPool) {
@Override @Override
public <T extends TransportResponse> void sendRequest(DiscoveryNode node, String action, public <T extends TransportResponse> void sendRequest(DiscoveryNode node, String action,
TransportRequest request, final TransportResponseHandler<T> handler) { TransportRequest request, final TransportResponseHandler<T> handler) {
@ -101,7 +102,7 @@ public class TransportClientNodesServiceTests extends ESTestCase {
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
transportClientNodesService = transportClientNodesService =
new TransportClientNodesService(Settings.EMPTY, clusterName, transportService, threadPool, Version.CURRENT); new TransportClientNodesService(settings, transportService, threadPool, Version.CURRENT);
this.nodesCount = randomIntBetween(1, 10); this.nodesCount = randomIntBetween(1, 10);
for (int i = 0; i < nodesCount; i++) { for (int i = 0; i < nodesCount; i++) {
transportClientNodesService.addTransportAddresses(new LocalTransportAddress("node" + i)); transportClientNodesService.addTransportAddresses(new LocalTransportAddress("node" + i));

View File

@ -29,6 +29,7 @@ import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllo
import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocator; import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocator;
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider;
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.ModuleTestCase; import org.elasticsearch.common.inject.ModuleTestCase;
import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings; import org.elasticsearch.common.settings.IndexScopedSettings;
@ -40,7 +41,8 @@ import org.elasticsearch.common.settings.SettingsModule;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class ClusterModuleTests extends ModuleTestCase { public class ClusterModuleTests extends ModuleTestCase {
private ClusterService clusterService = new ClusterService(Settings.EMPTY,
new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), null);
public static class FakeAllocationDecider extends AllocationDecider { public static class FakeAllocationDecider extends AllocationDecider {
protected FakeAllocationDecider(Settings settings) { protected FakeAllocationDecider(Settings settings) {
super(settings); super(settings);
@ -97,7 +99,7 @@ public class ClusterModuleTests extends ModuleTestCase {
} }
public void testRegisterAllocationDeciderDuplicate() { public void testRegisterAllocationDeciderDuplicate() {
ClusterModule module = new ClusterModule(Settings.EMPTY); ClusterModule module = new ClusterModule(Settings.EMPTY, clusterService);
try { try {
module.registerAllocationDecider(EnableAllocationDecider.class); module.registerAllocationDecider(EnableAllocationDecider.class);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -107,20 +109,20 @@ public class ClusterModuleTests extends ModuleTestCase {
} }
public void testRegisterAllocationDecider() { public void testRegisterAllocationDecider() {
ClusterModule module = new ClusterModule(Settings.EMPTY); ClusterModule module = new ClusterModule(Settings.EMPTY, clusterService);
module.registerAllocationDecider(FakeAllocationDecider.class); module.registerAllocationDecider(FakeAllocationDecider.class);
assertSetMultiBinding(module, AllocationDecider.class, FakeAllocationDecider.class); assertSetMultiBinding(module, AllocationDecider.class, FakeAllocationDecider.class);
} }
public void testRegisterShardsAllocator() { public void testRegisterShardsAllocator() {
Settings settings = Settings.builder().put(ClusterModule.SHARDS_ALLOCATOR_TYPE_SETTING.getKey(), "custom").build(); Settings settings = Settings.builder().put(ClusterModule.SHARDS_ALLOCATOR_TYPE_SETTING.getKey(), "custom").build();
ClusterModule module = new ClusterModule(settings); ClusterModule module = new ClusterModule(settings, clusterService);
module.registerShardsAllocator("custom", FakeShardsAllocator.class); module.registerShardsAllocator("custom", FakeShardsAllocator.class);
assertBinding(module, ShardsAllocator.class, FakeShardsAllocator.class); assertBinding(module, ShardsAllocator.class, FakeShardsAllocator.class);
} }
public void testRegisterShardsAllocatorAlreadyRegistered() { public void testRegisterShardsAllocatorAlreadyRegistered() {
ClusterModule module = new ClusterModule(Settings.EMPTY); ClusterModule module = new ClusterModule(Settings.EMPTY, clusterService);
try { try {
module.registerShardsAllocator(ClusterModule.BALANCED_ALLOCATOR, FakeShardsAllocator.class); module.registerShardsAllocator(ClusterModule.BALANCED_ALLOCATOR, FakeShardsAllocator.class);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -130,19 +132,19 @@ public class ClusterModuleTests extends ModuleTestCase {
public void testUnknownShardsAllocator() { public void testUnknownShardsAllocator() {
Settings settings = Settings.builder().put(ClusterModule.SHARDS_ALLOCATOR_TYPE_SETTING.getKey(), "dne").build(); Settings settings = Settings.builder().put(ClusterModule.SHARDS_ALLOCATOR_TYPE_SETTING.getKey(), "dne").build();
ClusterModule module = new ClusterModule(settings); ClusterModule module = new ClusterModule(settings, clusterService);
assertBindingFailure(module, "Unknown [shards_allocator]"); assertBindingFailure(module, "Unknown [shards_allocator]");
} }
public void testEvenShardsAllocatorBackcompat() { public void testEvenShardsAllocatorBackcompat() {
Settings settings = Settings.builder() Settings settings = Settings.builder()
.put(ClusterModule.SHARDS_ALLOCATOR_TYPE_SETTING.getKey(), ClusterModule.EVEN_SHARD_COUNT_ALLOCATOR).build(); .put(ClusterModule.SHARDS_ALLOCATOR_TYPE_SETTING.getKey(), ClusterModule.EVEN_SHARD_COUNT_ALLOCATOR).build();
ClusterModule module = new ClusterModule(settings); ClusterModule module = new ClusterModule(settings, clusterService);
assertBinding(module, ShardsAllocator.class, BalancedShardsAllocator.class); assertBinding(module, ShardsAllocator.class, BalancedShardsAllocator.class);
} }
public void testRegisterIndexTemplateFilterDuplicate() { public void testRegisterIndexTemplateFilterDuplicate() {
ClusterModule module = new ClusterModule(Settings.EMPTY); ClusterModule module = new ClusterModule(Settings.EMPTY, clusterService);
try { try {
module.registerIndexTemplateFilter(FakeIndexTemplateFilter.class); module.registerIndexTemplateFilter(FakeIndexTemplateFilter.class);
module.registerIndexTemplateFilter(FakeIndexTemplateFilter.class); module.registerIndexTemplateFilter(FakeIndexTemplateFilter.class);
@ -153,7 +155,7 @@ public class ClusterModuleTests extends ModuleTestCase {
} }
public void testRegisterIndexTemplateFilter() { public void testRegisterIndexTemplateFilter() {
ClusterModule module = new ClusterModule(Settings.EMPTY); ClusterModule module = new ClusterModule(Settings.EMPTY, clusterService);
module.registerIndexTemplateFilter(FakeIndexTemplateFilter.class); module.registerIndexTemplateFilter(FakeIndexTemplateFilter.class);
assertSetMultiBinding(module, IndexTemplateFilter.class, FakeIndexTemplateFilter.class); assertSetMultiBinding(module, IndexTemplateFilter.class, FakeIndexTemplateFilter.class);
} }

View File

@ -21,6 +21,7 @@ package org.elasticsearch.cluster;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.DummyTransportAddress; import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
@ -34,11 +35,15 @@ public class ClusterStateTests extends ESTestCase {
final DiscoveryNode node1 = new DiscoveryNode("node1", DummyTransportAddress.INSTANCE, emptyMap(), emptySet(), Version.CURRENT); final DiscoveryNode node1 = new DiscoveryNode("node1", DummyTransportAddress.INSTANCE, emptyMap(), emptySet(), Version.CURRENT);
final DiscoveryNode node2 = new DiscoveryNode("node2", DummyTransportAddress.INSTANCE, emptyMap(), emptySet(), Version.CURRENT); final DiscoveryNode node2 = new DiscoveryNode("node2", DummyTransportAddress.INSTANCE, emptyMap(), emptySet(), Version.CURRENT);
final DiscoveryNodes nodes = DiscoveryNodes.builder().put(node1).put(node2).build(); final DiscoveryNodes nodes = DiscoveryNodes.builder().put(node1).put(node2).build();
ClusterState noMaster1 = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(nodes).build(); ClusterName name = ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY);
ClusterState noMaster2 = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(nodes).build(); ClusterState noMaster1 = ClusterState.builder(name).version(randomInt(5)).nodes(nodes).build();
ClusterState withMaster1a = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.getId())).build(); ClusterState noMaster2 = ClusterState.builder(name).version(randomInt(5)).nodes(nodes).build();
ClusterState withMaster1b = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.getId())).build(); ClusterState withMaster1a = ClusterState.builder(name).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes)
ClusterState withMaster2 = ClusterState.builder(ClusterName.DEFAULT).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node2.getId())).build(); .masterNodeId(node1.getId())).build();
ClusterState withMaster1b = ClusterState.builder(name).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes)
.masterNodeId(node1.getId())).build();
ClusterState withMaster2 = ClusterState.builder(name).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes)
.masterNodeId(node2.getId())).build();
// states with no master should never supersede anything // states with no master should never supersede anything
assertFalse(noMaster1.supersedes(noMaster2)); assertFalse(noMaster1.supersedes(noMaster2));

View File

@ -149,7 +149,7 @@ public class NodeConnectionsServiceTests extends ESTestCase {
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
this.transport = new MockTransport(); this.transport = new MockTransport();
transportService = new TransportService(transport, THREAD_POOL, ClusterName.DEFAULT); transportService = new TransportService(Settings.EMPTY, transport, THREAD_POOL);
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
} }

View File

@ -84,7 +84,7 @@ public class ShardFailedClusterStateTaskExecutorTests extends ESAllocationTestCa
routingTable = RoutingTable.builder() routingTable = RoutingTable.builder()
.addAsNew(metaData.index(INDEX)) .addAsNew(metaData.index(INDEX))
.build(); .build();
clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
executor = new ShardStateAction.ShardFailedClusterStateTaskExecutor(allocationService, null, logger); executor = new ShardStateAction.ShardFailedClusterStateTaskExecutor(allocationService, null, logger);
} }

View File

@ -107,7 +107,7 @@ public class ShardStateActionTests extends ESTestCase {
super.setUp(); super.setUp();
this.transport = new CapturingTransport(); this.transport = new CapturingTransport();
clusterService = createClusterService(THREAD_POOL); clusterService = createClusterService(THREAD_POOL);
transportService = new TransportService(transport, THREAD_POOL, clusterService.state().getClusterName()); transportService = new TransportService(clusterService.getSettings(), transport, THREAD_POOL);
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
shardStateAction = new TestShardStateAction(Settings.EMPTY, clusterService, transportService, null, null); shardStateAction = new TestShardStateAction(Settings.EMPTY, clusterService, transportService, null, null);

View File

@ -81,7 +81,7 @@ public class ClusterStateHealthTests extends ESTestCase {
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
clusterService = createClusterService(threadPool); clusterService = createClusterService(threadPool);
transportService = new TransportService(new CapturingTransport(), threadPool, clusterService.state().getClusterName()); transportService = new TransportService(clusterService.getSettings(), new CapturingTransport(), threadPool);
transportService.start(); transportService.start();
transportService.acceptIncomingRequests(); transportService.acceptIncomingRequests();
} }
@ -127,8 +127,7 @@ public class ClusterStateHealthTests extends ESTestCase {
listenerCalled.await(); listenerCalled.await();
TransportClusterHealthAction action = new TransportClusterHealthAction(Settings.EMPTY, transportService, TransportClusterHealthAction action = new TransportClusterHealthAction(Settings.EMPTY, transportService,
clusterService, threadPool, clusterService.state().getClusterName(), new ActionFilters(new HashSet<>()), clusterService, threadPool, new ActionFilters(new HashSet<>()), indexNameExpressionResolver, NoopGatewayAllocator.INSTANCE);
indexNameExpressionResolver, NoopGatewayAllocator.INSTANCE);
PlainActionFuture<ClusterHealthResponse> listener = new PlainActionFuture<>(); PlainActionFuture<ClusterHealthResponse> listener = new PlainActionFuture<>();
action.execute(new ClusterHealthRequest(), listener); action.execute(new ClusterHealthRequest(), listener);
@ -158,7 +157,7 @@ public class ClusterStateHealthTests extends ESTestCase {
metaData.put(indexMetaData, true); metaData.put(indexMetaData, true);
routingTable.add(indexRoutingTable); routingTable.add(indexRoutingTable);
} }
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable.build()).build(); ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable.build()).build();
String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, IndicesOptions.strictExpand(), (String[]) null); String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, IndicesOptions.strictExpand(), (String[]) null);
ClusterStateHealth clusterStateHealth = new ClusterStateHealth(clusterState, concreteIndices); ClusterStateHealth clusterStateHealth = new ClusterStateHealth(clusterState, concreteIndices);
logger.info("cluster status: {}, expected {}", clusterStateHealth.getStatus(), counter.status()); logger.info("cluster status: {}, expected {}", clusterStateHealth.getStatus(), counter.status());

View File

@ -61,7 +61,8 @@ public class MetaDataCreateIndexServiceTests extends ESTestCase {
routingTableBuilder.addAsNew(metaData.index(name)); routingTableBuilder.addAsNew(metaData.index(name));
RoutingTable routingTable = routingTableBuilder.build(); RoutingTable routingTable = routingTableBuilder.build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING
.getDefault(Settings.EMPTY))
.metaData(metaData).routingTable(routingTable).blocks(ClusterBlocks.builder().addBlocks(indexMetaData)).build(); .metaData(metaData).routingTable(routingTable).blocks(ClusterBlocks.builder().addBlocks(indexMetaData)).build();
return clusterState; return clusterState;
} }
@ -200,7 +201,8 @@ public class MetaDataCreateIndexServiceTests extends ESTestCase {
private void validateIndexName(String indexName, String errorMessage) { private void validateIndexName(String indexName, String errorMessage) {
InvalidIndexNameException e = expectThrows(InvalidIndexNameException.class, InvalidIndexNameException e = expectThrows(InvalidIndexNameException.class,
() -> getCreateIndexService().validateIndexName(indexName, ClusterState.builder(ClusterName.DEFAULT).build())); () -> getCreateIndexService().validateIndexName(indexName, ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING
.getDefault(Settings.EMPTY)).build()));
assertThat(e.getMessage(), endsWith(errorMessage)); assertThat(e.getMessage(), endsWith(errorMessage));
} }

View File

@ -92,7 +92,7 @@ public class DelayedAllocationServiceTests extends ESAllocationTestCase {
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "0")) .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "0"))
.numberOfShards(1).numberOfReplicas(1)) .numberOfShards(1).numberOfReplicas(1))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build(); .routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
clusterState = ClusterState.builder(clusterState) clusterState = ClusterState.builder(clusterState)
@ -138,7 +138,7 @@ public class DelayedAllocationServiceTests extends ESAllocationTestCase {
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delaySetting)) .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delaySetting))
.numberOfShards(1).numberOfReplicas(1)) .numberOfShards(1).numberOfReplicas(1))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build(); .routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
clusterState = ClusterState.builder(clusterState) clusterState = ClusterState.builder(clusterState)
@ -236,7 +236,7 @@ public class DelayedAllocationServiceTests extends ESAllocationTestCase {
.settings(settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), longDelaySetting)) .settings(settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), longDelaySetting))
.numberOfShards(1).numberOfReplicas(1)) .numberOfShards(1).numberOfReplicas(1))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData)
.routingTable(RoutingTable.builder().addAsNew(metaData.index("short_delay")).addAsNew(metaData.index("long_delay")).build()) .routingTable(RoutingTable.builder().addAsNew(metaData.index("short_delay")).addAsNew(metaData.index("long_delay")).build())
.nodes(DiscoveryNodes.builder() .nodes(DiscoveryNodes.builder()
.put(newNode("node0", singleton(DiscoveryNode.Role.MASTER))).localNodeId("node0").masterNodeId("node0") .put(newNode("node0", singleton(DiscoveryNode.Role.MASTER))).localNodeId("node0").masterNodeId("node0")
@ -390,7 +390,7 @@ public class DelayedAllocationServiceTests extends ESAllocationTestCase {
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), shorterDelaySetting)) .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), shorterDelaySetting))
.numberOfShards(1).numberOfReplicas(1)) .numberOfShards(1).numberOfReplicas(1))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder() .routingTable(RoutingTable.builder()
.addAsNew(metaData.index("foo")) .addAsNew(metaData.index("foo"))

View File

@ -24,6 +24,7 @@ import org.elasticsearch.action.support.replication.ClusterStateCreationUtils;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index; import org.elasticsearch.index.Index;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardId;
@ -210,7 +211,8 @@ public class OperationRoutingTests extends ESTestCase{
} }
} }
final ShardIterator it = final ShardIterator it =
new OperationRouting(Settings.EMPTY, new AwarenessAllocationDecider()) new OperationRouting(Settings.EMPTY, new ClusterSettings(Settings.EMPTY,
ClusterSettings.BUILT_IN_CLUSTER_SETTINGS))
.getShards(clusterService.state(), indexName, 0, "_prefer_nodes:" + String.join(",", nodes)); .getShards(clusterService.state(), indexName, 0, "_prefer_nodes:" + String.join(",", nodes));
final List<ShardRouting> all = new ArrayList<>(); final List<ShardRouting> all = new ArrayList<>();
ShardRouting shard; ShardRouting shard;

View File

@ -79,8 +79,8 @@ public class PrimaryTermsTests extends ESAllocationTestCase {
.build()) .build())
.build(); .build();
this.clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData) this.clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.routingTable(testRoutingTable).build(); .metaData(metaData).routingTable(testRoutingTable).build();
} }
/** /**

View File

@ -25,6 +25,7 @@ import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils; import org.elasticsearch.test.VersionUtils;
@ -36,7 +37,8 @@ import java.util.Arrays;
public class RoutingBackwardCompatibilityTests extends ESTestCase { public class RoutingBackwardCompatibilityTests extends ESTestCase {
public void testBackwardCompatibility() throws Exception { public void testBackwardCompatibility() throws Exception {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(RoutingBackwardCompatibilityTests.class.getResourceAsStream("/org/elasticsearch/cluster/routing/shard_routes.txt"), "UTF-8"))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(RoutingBackwardCompatibilityTests.class
.getResourceAsStream("/org/elasticsearch/cluster/routing/shard_routes.txt"), "UTF-8"))) {
for (String line = reader.readLine(); line != null; line = reader.readLine()) { for (String line = reader.readLine(); line != null; line = reader.readLine()) {
if (line.startsWith("#")) { // comment if (line.startsWith("#")) { // comment
continue; continue;
@ -51,17 +53,20 @@ public class RoutingBackwardCompatibilityTests extends ESTestCase {
final int pre20ExpectedShardId = Integer.parseInt(parts[5]); // not needed anymore - old hashing is gone final int pre20ExpectedShardId = Integer.parseInt(parts[5]); // not needed anymore - old hashing is gone
final int currentExpectedShard = Integer.parseInt(parts[6]); final int currentExpectedShard = Integer.parseInt(parts[6]);
OperationRouting operationRouting = new OperationRouting(Settings.EMPTY, null); OperationRouting operationRouting = new OperationRouting(Settings.EMPTY, new ClusterSettings(Settings.EMPTY,
ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
for (Version version : VersionUtils.allVersions()) { for (Version version : VersionUtils.allVersions()) {
if (version.onOrAfter(Version.V_2_0_0) == false) { if (version.onOrAfter(Version.V_2_0_0) == false) {
// unsupported version, no need to test // unsupported version, no need to test
continue; continue;
} }
final Settings settings = settings(version).build(); final Settings settings = settings(version).build();
IndexMetaData indexMetaData = IndexMetaData.builder(index).settings(settings).numberOfShards(numberOfShards).numberOfReplicas(randomInt(3)).build(); IndexMetaData indexMetaData = IndexMetaData.builder(index).settings(settings).numberOfShards(numberOfShards)
.numberOfReplicas(randomInt(3)).build();
MetaData.Builder metaData = MetaData.builder().put(indexMetaData, false); MetaData.Builder metaData = MetaData.builder().put(indexMetaData, false);
RoutingTable routingTable = RoutingTable.builder().addAsNew(indexMetaData).build(); RoutingTable routingTable = RoutingTable.builder().addAsNew(indexMetaData).build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData).routingTable(routingTable).build();
final int shardId = operationRouting.indexShards(clusterState, index, id, routing).shardId().getId(); final int shardId = operationRouting.indexShards(clusterState, index, id, routing).shardId().getId();
assertEquals(currentExpectedShard, shardId); assertEquals(currentExpectedShard, shardId);
} }

View File

@ -73,7 +73,7 @@ public class RoutingTableTests extends ESAllocationTestCase {
.add(new IndexRoutingTable.Builder(metaData.index(TEST_INDEX_1).getIndex()).initializeAsNew(metaData.index(TEST_INDEX_1)).build()) .add(new IndexRoutingTable.Builder(metaData.index(TEST_INDEX_1).getIndex()).initializeAsNew(metaData.index(TEST_INDEX_1)).build())
.add(new IndexRoutingTable.Builder(metaData.index(TEST_INDEX_2).getIndex()).initializeAsNew(metaData.index(TEST_INDEX_2)).build()) .add(new IndexRoutingTable.Builder(metaData.index(TEST_INDEX_2).getIndex()).initializeAsNew(metaData.index(TEST_INDEX_2)).build())
.build(); .build();
this.clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(testRoutingTable).build(); this.clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(testRoutingTable).build();
} }
/** /**

View File

@ -94,7 +94,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3))) .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build(); .routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) { for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) {
@ -106,7 +106,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3))) .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsRecovery(metaData.index("test")).build()).build(); .routingTable(RoutingTable.builder().addAsRecovery(metaData.index("test")).build()).build();
for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) { for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) {
@ -118,7 +118,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3))) .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsFromCloseToOpen(metaData.index("test")).build()).build(); .routingTable(RoutingTable.builder().addAsFromCloseToOpen(metaData.index("test")).build()).build();
for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) { for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) {
@ -130,7 +130,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3))) .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsNewRestore(metaData.index("test"), new RestoreSource(new Snapshot("rep1", new SnapshotId("snp1", UUIDs.randomBase64UUID())), Version.CURRENT, "test"), new IntHashSet()).build()).build(); .routingTable(RoutingTable.builder().addAsNewRestore(metaData.index("test"), new RestoreSource(new Snapshot("rep1", new SnapshotId("snp1", UUIDs.randomBase64UUID())), Version.CURRENT, "test"), new IntHashSet()).build()).build();
for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) { for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) {
@ -142,7 +142,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3))) .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsRestore(metaData.index("test"), new RestoreSource(new Snapshot("rep1", new SnapshotId("snp1", UUIDs.randomBase64UUID())), Version.CURRENT, "test")).build()).build(); .routingTable(RoutingTable.builder().addAsRestore(metaData.index("test"), new RestoreSource(new Snapshot("rep1", new SnapshotId("snp1", UUIDs.randomBase64UUID())), Version.CURRENT, "test")).build()).build();
for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) { for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) {
@ -154,7 +154,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3))) .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(randomIntBetween(1, 3)).numberOfReplicas(randomIntBetween(0, 3)))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsFromDangling(metaData.index("test")).build()).build(); .routingTable(RoutingTable.builder().addAsFromDangling(metaData.index("test")).build()).build();
for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) { for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) {
@ -168,7 +168,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0)) .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(0))
.build(); .build();
final Index index = metaData.index("test").getIndex(); final Index index = metaData.index("test").getIndex();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsNew(metaData.index(index)).build()).build(); .routingTable(RoutingTable.builder().addAsNew(metaData.index(index)).build()).build();
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
@ -208,7 +208,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1)) .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build(); .routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -237,7 +237,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1)) .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build(); .routingTable(RoutingTable.builder().addAsNew(metaData.index("test")).build()).build();
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -286,7 +286,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
.put(IndexMetaData.builder("test1").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1)) .put(IndexMetaData.builder("test1").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
.put(IndexMetaData.builder("test2").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1)) .put(IndexMetaData.builder("test2").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test1")).addAsNew(metaData.index("test2")).build()).build(); .routingTable(RoutingTable.builder().addAsNew(metaData.index("test1")).addAsNew(metaData.index("test2")).build()).build();
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -314,7 +314,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase {
.put(IndexMetaData.builder("test1").settings(settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayTest1)).numberOfShards(1).numberOfReplicas(1)) .put(IndexMetaData.builder("test1").settings(settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayTest1)).numberOfShards(1).numberOfReplicas(1))
.put(IndexMetaData.builder("test2").settings(settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayTest2)).numberOfShards(1).numberOfReplicas(1)) .put(IndexMetaData.builder("test2").settings(settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayTest2)).numberOfShards(1).numberOfReplicas(1))
.build(); .build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData) .metaData(metaData)
.routingTable(RoutingTable.builder().addAsNew(metaData.index("test1")).addAsNew(metaData.index("test2")).build()).build(); .routingTable(RoutingTable.builder().addAsNew(metaData.index("test1")).addAsNew(metaData.index("test2")).build()).build();
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();

View File

@ -25,6 +25,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import java.util.Arrays; import java.util.Arrays;
@ -50,7 +51,8 @@ public class ActiveAllocationIdTests extends ESAllocationTestCase {
RoutingTable routingTable = RoutingTable.builder() RoutingTable routingTable = RoutingTable.builder()
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING
.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("adding three nodes and performing rerouting"); logger.info("adding three nodes and performing rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put( clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(

View File

@ -306,7 +306,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
for (int i = 0; i < numberOfNodes; i++) { for (int i = 0; i < numberOfNodes; i++) {
nodes.put(newNode("node" + i)); nodes.put(newNode("node" + i));
} }
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).nodes(nodes).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).nodes(nodes).metaData(metaData).routingTable(routingTable).build();
routingTable = service.reroute(clusterState, "reroute").routingTable(); routingTable = service.reroute(clusterState, "reroute").routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build(); clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
RoutingNodes routingNodes = clusterState.getRoutingNodes(); RoutingNodes routingNodes = clusterState.getRoutingNodes();

View File

@ -76,7 +76,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
RoutingTable routingTable = RoutingTable.builder() RoutingTable routingTable = RoutingTable.builder()
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("adding two nodes and performing rerouting"); logger.info("adding two nodes and performing rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -133,7 +133,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
RoutingTable routingTable = RoutingTable.builder() RoutingTable routingTable = RoutingTable.builder()
.addAsRecovery(metaData.index(index)) .addAsRecovery(metaData.index(index))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
final ShardId shardId = new ShardId(metaData.index(index).getIndex(), 0); final ShardId shardId = new ShardId(metaData.index(index).getIndex(), 0);
logger.info("--> adding 3 nodes on same rack and do rerouting"); logger.info("--> adding 3 nodes on same rack and do rerouting");
@ -256,7 +256,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
RoutingTable routingTable = RoutingTable.builder() RoutingTable routingTable = RoutingTable.builder()
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding 3 nodes"); logger.info("--> adding 3 nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()

View File

@ -65,7 +65,7 @@ public class AllocationPriorityTests extends ESAllocationTestCase {
.addAsNew(metaData.index("first")) .addAsNew(metaData.index("first"))
.addAsNew(metaData.index("second")) .addAsNew(metaData.index("second"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute"); RoutingAllocation.Result rerouteResult = allocation.reroute(clusterState, "reroute");

View File

@ -68,7 +68,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding two nodes on same rack and do rerouting"); logger.info("--> adding two nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -136,7 +136,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding two nodes on same rack and do rerouting"); logger.info("--> adding two nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -210,7 +210,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding two nodes on same rack and do rerouting"); logger.info("--> adding two nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -301,7 +301,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test2")) .addAsNew(metaData.index("test2"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding two nodes on same rack and do rerouting"); logger.info("--> adding two nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -392,7 +392,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding two nodes on same rack and do rerouting"); logger.info("--> adding two nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -470,7 +470,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding two nodes on same rack and do rerouting"); logger.info("--> adding two nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -551,7 +551,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding two nodes on same rack and do rerouting"); logger.info("--> adding two nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -618,7 +618,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding two nodes on same rack and do rerouting"); logger.info("--> adding two nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -693,7 +693,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test2")) .addAsNew(metaData.index("test2"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding two nodes on same rack and do rerouting"); logger.info("--> adding two nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -772,7 +772,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding two nodes in different zones and do rerouting"); logger.info("--> adding two nodes in different zones and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -833,7 +833,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding 5 nodes in different zones and do rerouting"); logger.info("--> adding 5 nodes in different zones and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()

View File

@ -131,7 +131,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
for (int i = 0; i < numberOfNodes; i++) { for (int i = 0; i < numberOfNodes; i++) {
nodes.put(newNode("node" + i)); nodes.put(newNode("node" + i));
} }
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).nodes(nodes).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).nodes(nodes).metaData(metaData).routingTable(routingTable).build();
routingTable = strategy.reroute(clusterState, "reroute").routingTable(); routingTable = strategy.reroute(clusterState, "reroute").routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build(); clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
RoutingNodes routingNodes = clusterState.getRoutingNodes(); RoutingNodes routingNodes = clusterState.getRoutingNodes();
@ -381,7 +381,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
nodes.put(node); nodes.put(node);
} }
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).nodes(nodes).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).nodes(nodes).metaData(metaData).routingTable(routingTable).build();
routingTable = strategy.reroute(clusterState, "reroute").routingTable(); routingTable = strategy.reroute(clusterState, "reroute").routingTable();
clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build(); clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build();
RoutingNodes routingNodes = clusterState.getRoutingNodes(); RoutingNodes routingNodes = clusterState.getRoutingNodes();

View File

@ -120,7 +120,7 @@ public abstract class CatAllocationTestCase extends ESAllocationTestCase {
for (String node : nodes) { for (String node : nodes) {
builderDiscoNodes.put(newNode(node)); builderDiscoNodes.put(newNode(node));
} }
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).nodes(builderDiscoNodes.build()).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).nodes(builderDiscoNodes.build()).build();
if (balanceFirst()) { if (balanceFirst()) {
clusterState = rebalance(clusterState); clusterState = rebalance(clusterState);
} }

View File

@ -60,7 +60,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test2")) .addAsNew(metaData.index("test2"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("start two nodes"); logger.info("start two nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -146,7 +146,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test2")) .addAsNew(metaData.index("test2"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("start two nodes"); logger.info("start two nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -250,7 +250,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test2")) .addAsNew(metaData.index("test2"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("start two nodes"); logger.info("start two nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -334,7 +334,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test2")) .addAsNew(metaData.index("test2"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("start two nodes"); logger.info("start two nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -457,7 +457,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test2")) .addAsNew(metaData.index("test2"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("start two nodes"); logger.info("start two nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -541,7 +541,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test2")) .addAsNew(metaData.index("test2"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("start two nodes"); logger.info("start two nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -661,7 +661,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test1")) .addAsNew(metaData.index("test1"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("start two nodes"); logger.info("start two nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
@ -760,7 +760,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test1")) .addAsNew(metaData.index("test1"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("start two nodes"); logger.info("start two nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();

View File

@ -57,7 +57,7 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
assertThat(routingTable.index("test").shards().size(), equalTo(5)); assertThat(routingTable.index("test").shards().size(), equalTo(5));
for (int i = 0; i < routingTable.index("test").shards().size(); i++) { for (int i = 0; i < routingTable.index("test").shards().size(); i++) {

View File

@ -56,7 +56,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
RoutingTable routingTable = RoutingTable.builder() RoutingTable routingTable = RoutingTable.builder()
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding 2 nodes on same rack and do rerouting"); logger.info("--> adding 2 nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -107,7 +107,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
RoutingTable routingTable = RoutingTable.builder() RoutingTable routingTable = RoutingTable.builder()
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding 2 nodes on same rack and do rerouting"); logger.info("--> adding 2 nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -181,7 +181,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
RoutingTable routingTable = RoutingTable.builder() RoutingTable routingTable = RoutingTable.builder()
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding 2 nodes on same rack and do rerouting"); logger.info("--> adding 2 nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()

View File

@ -55,7 +55,7 @@ public class ElectReplicaAsPrimaryDuringRelocationTests extends ESAllocationTest
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("Adding two nodes and performing rerouting"); logger.info("Adding two nodes and performing rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();

View File

@ -78,7 +78,7 @@ public class ExpectedShardSizeAllocationTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("Adding one node and performing rerouting"); logger.info("Adding one node and performing rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
routingTable = strategy.reroute(clusterState, "reroute").routingTable(); routingTable = strategy.reroute(clusterState, "reroute").routingTable();
@ -130,7 +130,7 @@ public class ExpectedShardSizeAllocationTests extends ESAllocationTestCase {
RoutingTable routingTable = RoutingTable.builder() RoutingTable routingTable = RoutingTable.builder()
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("adding two nodes and performing rerouting"); logger.info("adding two nodes and performing rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();

View File

@ -54,7 +54,7 @@ public class FailedNodeRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test2")) .addAsNew(metaData.index("test2"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("start 4 nodes"); logger.info("start 4 nodes");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build();

View File

@ -67,7 +67,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
RoutingTable routingTable = RoutingTable.builder() RoutingTable routingTable = RoutingTable.builder()
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("--> adding 2 nodes on same rack and do rerouting"); logger.info("--> adding 2 nodes on same rack and do rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder() clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
@ -158,7 +158,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("Adding two nodes and performing rerouting"); logger.info("Adding two nodes and performing rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -239,7 +239,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("Adding single node and performing rerouting"); logger.info("Adding single node and performing rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1"))).build();
@ -295,7 +295,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("Adding {} nodes and performing rerouting", numberOfReplicas + 1); logger.info("Adding {} nodes and performing rerouting", numberOfReplicas + 1);
DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(); DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder();
@ -351,7 +351,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("Adding two nodes and performing rerouting"); logger.info("Adding two nodes and performing rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -411,7 +411,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
logger.info("Adding two nodes and performing rerouting"); logger.info("Adding two nodes and performing rerouting");
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))).build();
@ -502,7 +502,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
// add 4 nodes // add 4 nodes
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build();
@ -548,7 +548,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
.addAsNew(metaData.index("test")) .addAsNew(metaData.index("test"))
.build(); .build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build(); ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
// add 4 nodes // add 4 nodes
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build(); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")).put(newNode("node3")).put(newNode("node4"))).build();

View File

@ -114,8 +114,8 @@ public class FilterAllocationDeciderTests extends ESAllocationTestCase {
routingTableBuilder.addAsNew(metaData.index("idx")); routingTableBuilder.addAsNew(metaData.index("idx"));
RoutingTable routingTable = routingTableBuilder.build(); RoutingTable routingTable = routingTableBuilder.build();
ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT) ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING
.metaData(metaData).routingTable(routingTable).build(); .getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2"))) clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().put(newNode("node1")).put(newNode("node2")))
.build(); .build();
routingTable = service.reroute(clusterState, "reroute", false).routingTable(); routingTable = service.reroute(clusterState, "reroute", false).routingTable();

Some files were not shown because too many files have changed in this diff Show More