Search in sources :

Example 36 with NodeState

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

the class FleetControllerTest method setWantedState.

protected void setWantedState(DummyVdsNode node, State state, String reason) {
    if (supervisor == null) {
        supervisor = new Supervisor(new Transport());
    }
    NodeState ns = new NodeState(node.getType(), state);
    if (reason != null)
        ns.setDescription(reason);
    Target connection = supervisor.connect(new Spec("localhost", fleetController.getRpcPort()));
    Request req = new Request("setNodeState");
    req.parameters().add(new StringValue(node.getSlobrokName()));
    req.parameters().add(new StringValue(ns.serialize()));
    connection.invokeSync(req, timeoutS);
    if (req.isError()) {
        assertTrue("Failed to invoke setNodeState(): " + req.errorCode() + ": " + req.errorMessage(), false);
    }
    if (!req.checkReturnTypes("s")) {
        assertTrue("Failed to invoke setNodeState(): Invalid return types.", false);
    }
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) NodeState(com.yahoo.vdslib.state.NodeState) Request(com.yahoo.jrt.Request) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue)

Example 37 with NodeState

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

the class GroupAutoTakedownTest method init_progress_is_preserved_across_group_down_up_edge.

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

Example 38 with NodeState

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

the class NodeStateChangeCheckerTest method testMissingDistributorState.

@Test
public void testMissingDistributorState() {
    ContentCluster cluster = createCluster(createNodes(4));
    NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
    cluster.clusterInfo().getStorageNodeInfo(1).setReportedState(new NodeState(NodeType.STORAGE, State.UP), 0);
    NodeStateChangeChecker.Result result = nodeStateChangeChecker.evaluateTransition(nodeStorage, defaultAllUpClusterState(), SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
    assertFalse(result.settingWantedStateIsAllowed());
    assertFalse(result.wantedStateAlreadySet());
    assertThat(result.getReason(), is("Distributor node (0) has not reported any cluster state version yet."));
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) Test(org.junit.Test)

Example 39 with NodeState

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

the class NodeStateChangeCheckerTest method setAllNodesUp.

private void setAllNodesUp(ContentCluster cluster, HostInfo distributorHostInfo) {
    for (int x = 0; x < cluster.clusterInfo().getConfiguredNodes().size(); x++) {
        State state = State.UP;
        cluster.clusterInfo().getDistributorNodeInfo(x).setReportedState(new NodeState(NodeType.DISTRIBUTOR, state), 0);
        cluster.clusterInfo().getDistributorNodeInfo(x).setHostInfo(distributorHostInfo);
        cluster.clusterInfo().getStorageNodeInfo(x).setReportedState(new NodeState(NodeType.STORAGE, state), 0);
    }
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) NodeState(com.yahoo.vdslib.state.NodeState) ClusterState(com.yahoo.vdslib.state.ClusterState) State(com.yahoo.vdslib.state.State)

Example 40 with NodeState

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

the class NodeStateChangeCheckerTest method transitionToMaintenanceWithOneStorageNodeDown.

private NodeStateChangeChecker.Result transitionToMaintenanceWithOneStorageNodeDown(int storageNodeIndex, boolean alternatingUpRetiredAndInitializing) {
    ContentCluster cluster = createCluster(createNodes(4));
    NodeStateChangeChecker nodeStateChangeChecker = createChangeChecker(cluster);
    for (int x = 0; x < cluster.clusterInfo().getConfiguredNodes().size(); x++) {
        State state = State.UP;
        // Pick some retired and initializing nodes too
        if (alternatingUpRetiredAndInitializing) {
            // TODO: Move this into the calling test
            if (x % 3 == 1)
                state = State.RETIRED;
            else if (x % 3 == 2)
                state = State.INITIALIZING;
        }
        cluster.clusterInfo().getDistributorNodeInfo(x).setReportedState(new NodeState(NodeType.DISTRIBUTOR, state), 0);
        cluster.clusterInfo().getDistributorNodeInfo(x).setHostInfo(HostInfo.createHostInfo(createDistributorHostInfo(4, 5, 6)));
        cluster.clusterInfo().getStorageNodeInfo(x).setReportedState(new NodeState(NodeType.STORAGE, state), 0);
    }
    ClusterState clusterState = defaultAllUpClusterState();
    if (storageNodeIndex >= 0) {
        // TODO: Move this into the calling test
        NodeState downNodeState = new NodeState(NodeType.STORAGE, State.DOWN);
        cluster.clusterInfo().getStorageNodeInfo(storageNodeIndex).setReportedState(downNodeState, 4);
        clusterState.setNodeState(new Node(NodeType.STORAGE, storageNodeIndex), downNodeState);
    }
    return nodeStateChangeChecker.evaluateTransition(nodeStorage, clusterState, SetUnitStateRequest.Condition.SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) NodeState(com.yahoo.vdslib.state.NodeState) ClusterState(com.yahoo.vdslib.state.ClusterState) State(com.yahoo.vdslib.state.State) Node(com.yahoo.vdslib.state.Node) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode)

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