Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.elasticsearch.action.admin.cluster.bootstrap;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.cluster.ClusterState.VotingConfiguration;
import org.elasticsearch.cluster.coordination.CoordinationMetaData.VotingConfiguration;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterState.Builder;
import org.elasticsearch.cluster.ClusterStateObserver;
import org.elasticsearch.cluster.ClusterStateObserver.Listener;
import org.elasticsearch.cluster.ClusterStateUpdateTask;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.coordination.CoordinationMetaData;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Priority;
Expand Down Expand Up @@ -90,9 +91,10 @@ public ClusterState execute(ClusterState currentState) {
assert resolvedNodes == null : resolvedNodes;
resolvedNodes = resolveNodesAndCheckMaximum(request, currentState);

final Builder builder = ClusterState.builder(currentState);
CoordinationMetaData.Builder builder = CoordinationMetaData.builder(currentState.coordinationMetaData());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, could this be final please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolvedNodes.forEach(builder::addVotingTombstone);
final ClusterState newState = builder.build();
final MetaData newMetaData = MetaData.builder(currentState.metaData()).coordinationMetaData(builder.build()).build();
final ClusterState newState = ClusterState.builder(currentState).metaData(newMetaData).build();
assert newState.getVotingTombstones().size() <= MAXIMUM_VOTING_TOMBSTONES_SETTING.get(currentState.metaData().settings());
return newState;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterState.Builder;
import org.elasticsearch.cluster.ClusterStateObserver;
import org.elasticsearch.cluster.ClusterStateObserver.Listener;
import org.elasticsearch.cluster.ClusterStateUpdateTask;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.coordination.CoordinationMetaData;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Priority;
Expand Down Expand Up @@ -119,9 +120,11 @@ private void submitClearTombstonesTask(ClearVotingTombstonesRequest request, lon
clusterService.submitStateUpdateTask("clear-voting-tombstones", new ClusterStateUpdateTask(Priority.URGENT) {
@Override
public ClusterState execute(ClusterState currentState) {
final Builder builder = ClusterState.builder(currentState);
builder.clearVotingTombstones();
return builder.build();
final CoordinationMetaData newCoordinationMetaData =
CoordinationMetaData.builder(currentState.coordinationMetaData()).clearVotingTombstones().build();
final MetaData newMetaData = MetaData.builder(currentState.metaData()).
coordinationMetaData(newCoordinationMetaData).build();
return ClusterState.builder(currentState).metaData(newMetaData).build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,9 @@ protected void masterOperation(final ClusterStateRequest request, final ClusterS
ClusterState currentState = clusterService.state();
logger.trace("Serving cluster state request using version {}", currentState.version());
ClusterState.Builder builder = ClusterState.builder(currentState.getClusterName());
builder.term(currentState.term());
builder.version(currentState.version());
builder.stateUUID(currentState.stateUUID());
builder.lastCommittedConfiguration(currentState.getLastCommittedConfiguration());
builder.lastAcceptedConfiguration(currentState.getLastAcceptedConfiguration());

if (request.nodes()) {
builder.nodes(currentState.nodes());
}
Expand All @@ -105,6 +103,7 @@ protected void masterOperation(final ClusterStateRequest request, final ClusterS

MetaData.Builder mdBuilder = MetaData.builder();
mdBuilder.clusterUUID(currentState.metaData().clusterUUID());
mdBuilder.coordinationMetaData(currentState.coordinationMetaData());

if (request.metaData()) {
if (request.indices().length > 0) {
Expand Down
Loading