Search in sources :

Example 11 with NodeState

use of com.yahoo.vdslib.state.NodeState 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 12 with NodeState

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

the class FleetControllerTest method waitForNodeStateReported.

protected void waitForNodeStateReported(int nodeIndex, NodeState state, int ms) {
    long timeoutAtTime = System.currentTimeMillis() + ms;
    while (true) {
        Node node = nodes.get(nodeIndex).getNode();
        NodeState ns = fleetController.getReportedNodeState(node);
        if ((ns == null && state == null) || (ns != null && state != null && ns.equals(state)))
            break;
        if (System.currentTimeMillis() > timeoutAtTime) {
            throw new IllegalStateException("Failed to find " + node + " in nodestate " + state + " before timeout of " + ms + " milliseconds.");
        }
    }
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode)

Example 13 with NodeState

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

the class GroupAutoTakedownTest method disk_states_are_preserved_across_group_down_up_edge.

@Test
public void disk_states_are_preserved_across_group_down_up_edge() {
    ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
    final NodeState newState = new NodeState(NodeType.STORAGE, State.UP);
    newState.setDiskCount(7);
    newState.setDiskState(5, new DiskState(State.DOWN));
    fixture.reportStorageNodeState(4, newState);
    assertEquals("distributor:6 storage:6 .4.d:7 .4.d.5.s:d", fixture.generatedClusterState());
    assertEquals("distributor:6 storage:4", stateAfterStorageTransition(fixture, 5, State.DOWN));
    assertEquals("distributor:6 storage:6 .4.d:7 .4.d.5.s:d", stateAfterStorageTransition(fixture, 5, State.UP));
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) DiskState(com.yahoo.vdslib.state.DiskState) Test(org.junit.Test)

Example 14 with NodeState

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

the class GroupAutoTakedownTest method previously_cleared_start_timestamps_are_not_reintroduced_on_up_edge.

@Test
public void previously_cleared_start_timestamps_are_not_reintroduced_on_up_edge() throws Exception {
    ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
    final NodeState newState = new NodeState(NodeType.STORAGE, State.UP);
    newState.setStartTimestamp(123456);
    fixture.reportStorageNodeState(4, newState);
    assertEquals("distributor:6 storage:6 .4.t:123456", fixture.generatedClusterState());
    DatabaseHandler handler = mock(DatabaseHandler.class);
    DatabaseHandler.Context context = mock(DatabaseHandler.Context.class);
    when(context.getCluster()).thenReturn(fixture.cluster);
    Set<ConfiguredNode> nodes = new HashSet<>(fixture.cluster.clusterInfo().getConfiguredNodes().values());
    fixture.nodeStateChangeHandler.handleAllDistributorsInSync(fixture.annotatedGeneratedClusterState().getClusterState(), nodes, handler, context);
    // Timestamp should now be cleared from state
    assertEquals("distributor:6 storage:6", fixture.generatedClusterState());
    // Trigger a group down+up edge. Timestamp should _not_ be reintroduced since it was previously cleared.
    assertEquals("distributor:6 storage:4", stateAfterStorageTransition(fixture, 5, State.DOWN));
    assertEquals("distributor:6 storage:6", stateAfterStorageTransition(fixture, 5, State.UP));
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) DatabaseHandler(com.yahoo.vespa.clustercontroller.core.database.DatabaseHandler) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with NodeState

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

the class DatabaseHandler method loadWantedStates.

public boolean loadWantedStates(Context context) throws InterruptedException {
    log.log(LogLevel.DEBUG, "Fleetcontroller " + nodeIndex + ": Retrieving node wanted states.");
    synchronized (databaseMonitor) {
        if (database != null && !database.isClosed()) {
            currentlyStored.wantedStates = database.retrieveWantedStates();
        }
    }
    Map<Node, NodeState> wantedStates = currentlyStored.wantedStates;
    if (wantedStates == null) {
        if (usingZooKeeper()) {
            log.log(LogLevel.WARNING, "Fleetcontroller " + nodeIndex + ": Failed to retrieve wanted states from ZooKeeper. Assuming UP for all nodes.");
        }
        wantedStates = new TreeMap<>();
    }
    boolean altered = false;
    for (Node node : wantedStates.keySet()) {
        NodeInfo nodeInfo = context.getCluster().getNodeInfo(node);
        // ignore wanted state of nodes which doesn't exist
        if (nodeInfo == null)
            continue;
        NodeState wantedState = wantedStates.get(node);
        if (!nodeInfo.getUserWantedState().equals(wantedState)) {
            nodeInfo.setWantedState(wantedState);
            context.getNodeStateUpdateListener().handleNewWantedNodeState(nodeInfo, wantedState);
            altered = true;
        }
        log.log(LogLevel.DEBUG, "Fleetcontroller " + nodeIndex + ": Node " + node + " has wanted state " + wantedState);
    }
    // Remove wanted state from any node having a wanted state set that is no longer valid
    for (NodeInfo info : context.getCluster().getNodeInfo()) {
        NodeState wantedState = wantedStates.get(info.getNode());
        if (wantedState == null && !info.getUserWantedState().equals(new NodeState(info.getNode().getType(), State.UP))) {
            info.setWantedState(null);
            context.getNodeStateUpdateListener().handleNewWantedNodeState(info, info.getWantedState().clone());
            altered = true;
        }
    }
    return altered;
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) NodeInfo(com.yahoo.vespa.clustercontroller.core.NodeInfo) Node(com.yahoo.vdslib.state.Node)

Aggregations

NodeState (com.yahoo.vdslib.state.NodeState)68 Node (com.yahoo.vdslib.state.Node)31 Test (org.junit.Test)30 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)21 ClusterState (com.yahoo.vdslib.state.ClusterState)11 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)6 Request (com.yahoo.jrt.Request)5 Target (com.yahoo.jrt.Target)5 State (com.yahoo.vdslib.state.State)5 ClusterFixture.storageNode (com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode)5 HasStateReasonForNode.hasStateReasonForNode (com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode)5 Spec (com.yahoo.jrt.Spec)4 StringValue (com.yahoo.jrt.StringValue)4 Supervisor (com.yahoo.jrt.Supervisor)4 Transport (com.yahoo.jrt.Transport)4 DiskState (com.yahoo.vdslib.state.DiskState)4 ArrayList (java.util.ArrayList)4 PrintWriter (java.io.PrintWriter)3 StringWriter (java.io.StringWriter)3 HashSet (java.util.HashSet)3