use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class RPCCommunicator method setSystemState.
@Override
public void setSystemState(ClusterStateBundle stateBundle, NodeInfo node, Waiter<SetClusterStateRequest> externalWaiter) {
final RPCSetClusterStateWaiter waiter = new RPCSetClusterStateWaiter(externalWaiter, timer);
final ClusterState baselineState = stateBundle.getBaselineClusterState();
Target connection = getConnection(node);
if (!connection.isValid()) {
log.log(LogLevel.DEBUG, "Connection to " + node.getRpcAddress() + " could not be created.");
return;
}
final int nodeVersion = node.getVersion();
// TODO remove this deprecated legacy stuff
if (nodeVersion == 0 && node.getConnectionVersion() > 0) {
doVersion0HandShake(connection, node);
clearOldStoredNodeState(connection, node);
}
Request req;
if (nodeVersion == 0) {
req = new Request("setsystemstate");
req.parameters().add(new StringValue(baselineState.toString(true)));
} else if (nodeVersion <= 2) {
req = new Request(LEGACY_SET_SYSTEM_STATE2_RPC_METHOD_NAME);
req.parameters().add(new StringValue(baselineState.toString(false)));
} else {
req = new Request(SET_DISTRIBUTION_STATES_RPC_METHOD_NAME);
SlimeClusterStateBundleCodec codec = new SlimeClusterStateBundleCodec();
EncodedClusterStateBundle encodedBundle = codec.encode(stateBundle);
Values v = req.parameters();
v.add(new Int8Value(encodedBundle.getCompression().type().getCode()));
v.add(new Int32Value(encodedBundle.getCompression().uncompressedSize()));
v.add(new DataValue(encodedBundle.getCompression().data()));
}
log.log(LogLevel.DEBUG, () -> String.format("Sending '%s' RPC to %s for state version %d", req.methodName(), node.getRpcAddress(), stateBundle.getVersion()));
RPCSetClusterStateRequest stateRequest = new RPCSetClusterStateRequest(node, req, baselineState.getVersion());
waiter.setRequest(stateRequest);
connection.invokeAsync(req, 60, waiter);
node.setSystemStateVersionSent(baselineState);
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class FleetController method handleNewSystemState.
@Override
public void handleNewSystemState(ClusterStateBundle stateBundle) {
verifyInControllerThread();
ClusterState baselineState = stateBundle.getBaselineClusterState();
newStates.add(stateBundle);
metricUpdater.updateClusterStateMetrics(cluster, baselineState);
systemStateBroadcaster.handleNewClusterStates(stateBundle);
// ZK store will not risk reusing the same version number.
if (masterElectionHandler.isMaster()) {
storeClusterStateVersionToZooKeeper(baselineState);
}
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class FleetController method handleAllDistributorsInSync.
/**
* Called when all distributors have acked newest cluster state version.
*/
public void handleAllDistributorsInSync(DatabaseHandler database, DatabaseHandler.Context context) throws InterruptedException {
Set<ConfiguredNode> nodes = new HashSet<>(cluster.clusterInfo().getConfiguredNodes().values());
ClusterState currentState = stateVersionTracker.getVersionedClusterState();
log.fine(() -> String.format("All distributors have ACKed cluster state version %d", currentState.getVersion()));
stateChangeHandler.handleAllDistributorsInSync(currentState, nodes, database, context);
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class NodeStateChangeChecker method contentNodesWithAvailableNodeState.
private int contentNodesWithAvailableNodeState(ClusterState clusterState) {
final int nodeCount = clusterState.getNodeCount(NodeType.STORAGE);
int upNodesCount = 0;
for (int i = 0; i < nodeCount; ++i) {
final Node node = new Node(NodeType.STORAGE, i);
final State state = clusterState.getNodeState(node).getState();
if (state == State.UP || state == State.RETIRED || state == State.INITIALIZING) {
upNodesCount++;
}
}
return upNodesCount;
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class NodeStateChangeChecker method canSetStateDownPermanently.
private Result canSetStateDownPermanently(NodeInfo nodeInfo, ClusterState clusterState) {
State reportedState = nodeInfo.getReportedState().getState();
if (reportedState != State.UP) {
return Result.createDisallowed("Reported state (" + reportedState + ") is not UP, so no bucket data is available");
}
State currentState = clusterState.getNodeState(nodeInfo.getNode()).getState();
if (currentState != State.RETIRED) {
return Result.createDisallowed("Only retired nodes are allowed to be set to DOWN in safe mode - is " + currentState);
}
Result thresholdCheckResult = checkUpThresholds(clusterState);
if (!thresholdCheckResult.settingWantedStateIsAllowed()) {
return thresholdCheckResult;
}
HostInfo hostInfo = nodeInfo.getHostInfo();
Integer hostInfoNodeVersion = hostInfo.getClusterStateVersionOrNull();
int clusterControllerVersion = clusterState.getVersion();
if (hostInfoNodeVersion == null || hostInfoNodeVersion != clusterControllerVersion) {
return Result.createDisallowed("Cluster controller at version " + clusterControllerVersion + " got info for storage node " + nodeInfo.getNodeIndex() + " at a different version " + hostInfoNodeVersion);
}
Optional<Metrics.Value> bucketsMetric = hostInfo.getMetrics().getValue(BUCKETS_METRIC_NAME);
if (!bucketsMetric.isPresent() || bucketsMetric.get().getLast() == null) {
return Result.createDisallowed("Missing last value of the " + BUCKETS_METRIC_NAME + " metric for storage node " + nodeInfo.getNodeIndex());
}
long lastBuckets = bucketsMetric.get().getLast();
if (lastBuckets > 0) {
return Result.createDisallowed("The storage node manages " + lastBuckets + " buckets");
}
return Result.allowSettingOfWantedState();
}
Aggregations