use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class ClusterFixture method proposeDistributorWantedState.
public ClusterFixture proposeDistributorWantedState(final int index, State state) {
final ClusterState stateBefore = rawGeneratedClusterState();
final Node node = new Node(NodeType.DISTRIBUTOR, index);
final NodeState nodeState = new NodeState(NodeType.DISTRIBUTOR, state);
nodeState.setDescription("mockdesc");
NodeInfo nodeInfo = cluster.getNodeInfo(node);
nodeInfo.setWantedState(nodeState);
nodeStateChangeHandler.proposeNewNodeState(stateBefore, nodeInfo, nodeState);
return this;
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class ClusterFixture method doReportNodeState.
private void doReportNodeState(final Node node, final NodeState nodeState) {
final ClusterState stateBefore = rawGeneratedClusterState();
NodeStateOrHostInfoChangeHandler handler = mock(NodeStateOrHostInfoChangeHandler.class);
NodeInfo nodeInfo = cluster.getNodeInfo(node);
nodeStateChangeHandler.handleNewReportedNodeState(stateBefore, nodeInfo, nodeState, handler);
nodeInfo.setReportedState(nodeState, timer.getCurrentTimeInMillis());
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class SlimeClusterStateBundleCodec method decode.
@Override
public ClusterStateBundle decode(EncodedClusterStateBundle encodedClusterStateBundle) {
byte[] uncompressed = compressor.decompress(encodedClusterStateBundle.getCompression());
Slime slime = BinaryFormat.decode(uncompressed);
Inspector root = slime.get();
Inspector states = root.field("states");
ClusterState baseline = ClusterState.stateFromString(states.field("baseline").asString());
Inspector spaces = states.field("spaces");
Map<String, AnnotatedClusterState> derivedStates = new HashMap<>();
spaces.traverse(((ObjectTraverser) (key, value) -> {
derivedStates.put(key, AnnotatedClusterState.withoutAnnotations(ClusterState.stateFromString(value.asString())));
}));
return ClusterStateBundle.of(AnnotatedClusterState.withoutAnnotations(baseline), derivedStates);
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class EventDiffCalculator method emitWholeClusterDiffEvent.
private static void emitWholeClusterDiffEvent(final PerStateParams params, final List<Event> events) {
final ClusterState fromState = params.fromState.getClusterState();
final ClusterState toState = params.toState.getClusterState();
if (clusterHasTransitionedToUpState(fromState, toState)) {
events.add(createClusterEvent("Enough nodes available for system to become up", params));
} else if (clusterHasTransitionedToDownState(fromState, toState)) {
if (clusterDownBecause(params, ClusterStateReason.TOO_FEW_STORAGE_NODES_AVAILABLE)) {
events.add(createClusterEvent("Too few storage nodes available in cluster. Setting cluster state down", params));
} else if (clusterDownBecause(params, ClusterStateReason.TOO_FEW_DISTRIBUTOR_NODES_AVAILABLE)) {
events.add(createClusterEvent("Too few distributor nodes available in cluster. Setting cluster state down", params));
} else if (clusterDownBecause(params, ClusterStateReason.TOO_LOW_AVAILABLE_STORAGE_NODE_RATIO)) {
events.add(createClusterEvent("Too low ratio of available storage nodes. Setting cluster state down", params));
} else if (clusterDownBecause(params, ClusterStateReason.TOO_LOW_AVAILABLE_DISTRIBUTOR_NODE_RATIO)) {
events.add(createClusterEvent("Too low ratio of available distributor nodes. Setting cluster state down", params));
} else {
events.add(createClusterEvent("Cluster is down", params));
}
}
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class EventDiffCalculator method emitPerNodeDiffEvents.
private static void emitPerNodeDiffEvents(final PerStateParams params, final List<Event> events) {
final ContentCluster cluster = params.cluster;
final ClusterState fromState = params.fromState.getClusterState();
final ClusterState toState = params.toState.getClusterState();
for (ConfiguredNode node : cluster.getConfiguredNodes().values()) {
for (NodeType nodeType : NodeType.getTypes()) {
final Node n = new Node(nodeType, node.index());
emitSingleNodeEvents(params, events, cluster, fromState, toState, n);
}
}
}
Aggregations