use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class ClusterStateGenerator method generatedStateFrom.
static AnnotatedClusterState generatedStateFrom(final Params params) {
final ContentCluster cluster = params.cluster;
final ClusterState workingState = ClusterState.emptyState();
final Map<Node, NodeStateReason> nodeStateReasons = new HashMap<>();
for (final NodeInfo nodeInfo : cluster.getNodeInfo()) {
final NodeState nodeState = computeEffectiveNodeState(nodeInfo, params);
workingState.setNodeState(nodeInfo.getNode(), nodeState);
}
takeDownGroupsWithTooLowAvailability(workingState, nodeStateReasons, params);
final Optional<ClusterStateReason> reasonToBeDown = clusterDownReason(workingState, params);
if (reasonToBeDown.isPresent()) {
workingState.setClusterState(State.DOWN);
}
workingState.setDistributionBits(inferDistributionBitCount(cluster, workingState, params));
return new AnnotatedClusterState(workingState, reasonToBeDown, nodeStateReasons);
}
use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class ClusterStateGenerator method takeDownGroupsWithTooLowAvailability.
private static void takeDownGroupsWithTooLowAvailability(final ClusterState workingState, Map<Node, NodeStateReason> nodeStateReasons, final Params params) {
final GroupAvailabilityCalculator calc = new GroupAvailabilityCalculator.Builder().withMinNodeRatioPerGroup(params.minNodeRatioPerGroup).withDistribution(params.cluster.getDistribution()).build();
final Set<Integer> nodesToTakeDown = calc.nodesThatShouldBeDown(workingState);
for (Integer idx : nodesToTakeDown) {
final Node node = storageNode(idx);
final NodeState newState = new NodeState(NodeType.STORAGE, State.DOWN);
newState.setDescription("group node availability below configured threshold");
workingState.setNodeState(node, newState);
nodeStateReasons.put(node, NodeStateReason.GROUP_IS_DOWN);
}
}
use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class EventDiffCalculator method emitSingleNodeEvents.
private static void emitSingleNodeEvents(PerStateParams params, List<Event> events, ContentCluster cluster, ClusterState fromState, ClusterState toState, Node n) {
final NodeState nodeFrom = fromState.getNodeState(n);
final NodeState nodeTo = toState.getNodeState(n);
if (!nodeTo.equals(nodeFrom)) {
final NodeInfo info = cluster.getNodeInfo(n);
events.add(createNodeEvent(info, String.format("Altered node state in cluster state from '%s' to '%s'", nodeFrom.toString(true), nodeTo.toString(true)), params));
NodeStateReason prevReason = params.fromState.getNodeStateReasons().get(n);
NodeStateReason currReason = params.toState.getNodeStateReasons().get(n);
if (isGroupDownEdge(prevReason, currReason)) {
events.add(createNodeEvent(info, "Group node availability is below configured threshold", params));
} else if (isGroupUpEdge(prevReason, currReason)) {
events.add(createNodeEvent(info, "Group node availability has been restored", params));
} else if (isMayHaveMergesPendingUpEdge(prevReason, currReason)) {
events.add(createNodeEvent(info, "Node may have merges pending", params));
} else if (isMayHaveMergesPendingDownEdge(prevReason, currReason)) {
events.add(createNodeEvent(info, "Node no longer have merges pending", params));
}
}
}
Aggregations