use of com.yahoo.vdslib.state.State 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.State 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