Search in sources :

Example 1 with ClusterState

use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.

the class FleetController method consolidatedClusterState.

/**
 * A "consolidated" cluster state is guaranteed to have up-to-date information on which nodes are
 * up or down even when the whole cluster is down. The regular, published cluster state is not
 * normally updated to reflect node events when the cluster is down.
 */
ClusterState consolidatedClusterState() {
    final ClusterState publishedState = stateVersionTracker.getVersionedClusterState();
    if (publishedState.getClusterState() == State.UP) {
        // Short-circuit; already represents latest node state
        return publishedState;
    }
    // Latest candidate state contains the most up to date state information, even if it may not
    // have been published yet.
    final ClusterState current = stateVersionTracker.getLatestCandidateState().getClusterState().clone();
    current.setVersion(publishedState.getVersion());
    return current;
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState)

Example 2 with ClusterState

use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.

the class ClusterStateView method getIndicesOfUpNodes.

/**
 * Returns the set of nodes that are up for a given node type. Non-private for testing.
 */
static Set<Integer> getIndicesOfUpNodes(ClusterState clusterState, NodeType type) {
    int nodeCount = clusterState.getNodeCount(type);
    Set<Integer> nodesBeingUp = new HashSet<>();
    for (int i = 0; i < nodeCount; ++i) {
        Node node = new Node(type, i);
        NodeState nodeState = clusterState.getNodeState(node);
        State state = nodeState.getState();
        if (state == State.UP || state == State.INITIALIZING || state == State.RETIRED || state == State.MAINTENANCE) {
            nodesBeingUp.add(i);
        }
    }
    return nodesBeingUp;
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) State(com.yahoo.vdslib.state.State) Node(com.yahoo.vdslib.state.Node) HashSet(java.util.HashSet)

Example 3 with ClusterState

use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.

the class DistributionBitCountTest method testStorageNodeReportingLowerBitCount.

/**
 * Test that then storage node report lower bit count, but another storage node with equally low bitcount, the fleetcontroller does nothing.
 * Test that then storage node report lower bit count, and then becomes the smallest, the fleetcontroller adjusts to use that bit in system state.
 */
@Test
public void testStorageNodeReportingLowerBitCount() throws Exception {
    setUpSystem("DistributionBitCountTest::testStorageNodeReportingLowerBitCount");
    nodes.get(1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(13));
    ClusterState currentState = waitForState("version:\\d+ bits:13 distributor:10 storage:10");
    int version = currentState.getVersion();
    nodes.get(3).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(15));
    assertEquals(version, currentState.getVersion());
    nodes.get(3).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(13));
    assertEquals(version, currentState.getVersion());
    nodes.get(3).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(12));
    waitForState("version:\\d+ bits:12 distributor:10 storage:10");
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) Test(org.junit.Test)

Example 4 with ClusterState

use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.

the class DistributionBitCountTest method testStorageNodeReportingHigherBitCount.

/**
 * Test that when storage node reports higher bit count, but another storage
 * node has equally low bitcount, the fleetcontroller does nothing.
 *
 * Test that when storage node reports higher bit count, but another storage
 * node now being lowest, the fleetcontroller adjusts to use that bit in system state.
 */
@Test
public void testStorageNodeReportingHigherBitCount() throws Exception {
    setUpSystem("DistributionBitCountTest::testStorageNodeReportingHigherBitCount");
    nodes.get(1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(11));
    nodes.get(3).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(11));
    ClusterState startState = waitForState("version:\\d+ bits:11 distributor:10 storage:10");
    nodes.get(1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(12));
    assertEquals(startState + "->" + fleetController.getSystemState(), startState.getVersion(), fleetController.getSystemState().getVersion());
    for (int i = 0; i < 10; ++i) {
        // nodes is array of [distr.0, stor.0, distr.1, stor.1, ...] and we just want the storage nodes
        nodes.get(i * 2 + 1).setNodeState(new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(17));
    }
    assertEquals(startState.getVersion() + 1, waitForState("version:\\d+ bits:17 distributor:10 storage:10").getVersion());
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) Test(org.junit.Test)

Example 5 with ClusterState

use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.

the class ClusterFixture method doProposeWantedState.

private void doProposeWantedState(final Node node, final NodeState nodeState, String description) {
    final ClusterState stateBefore = rawGeneratedClusterState();
    nodeState.setDescription(description);
    NodeInfo nodeInfo = cluster.getNodeInfo(node);
    nodeInfo.setWantedState(nodeState);
    nodeStateChangeHandler.proposeNewNodeState(stateBefore, nodeInfo, nodeState);
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState)

Aggregations

ClusterState (com.yahoo.vdslib.state.ClusterState)38 Test (org.junit.Test)11 NodeState (com.yahoo.vdslib.state.NodeState)10 Node (com.yahoo.vdslib.state.Node)8 BucketId (com.yahoo.document.BucketId)6 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)6 State (com.yahoo.vdslib.state.State)4 Request (com.yahoo.jrt.Request)2 Spec (com.yahoo.jrt.Spec)2 Supervisor (com.yahoo.jrt.Supervisor)2 Target (com.yahoo.jrt.Target)2 Transport (com.yahoo.jrt.Transport)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 ParseException (com.yahoo.document.select.parser.ParseException)1 StringValue (com.yahoo.jrt.StringValue)1 Distribution (com.yahoo.vdslib.distribution.Distribution)1 NodeType (com.yahoo.vdslib.state.NodeType)1 AnnotatedClusterState (com.yahoo.vespa.clustercontroller.core.AnnotatedClusterState)1 HostInfo (com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo)1