Search in sources :

Example 31 with NodeState

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

the class RpcServerTest method setWantedNodeState.

private void setWantedNodeState(State newState, NodeType nodeType, int nodeIndex) {
    int rpcPort = fleetController.getRpcPort();
    if (supervisor == null) {
        supervisor = new Supervisor(new Transport());
    }
    Target connection = supervisor.connect(new Spec("localhost", rpcPort));
    assertTrue(connection.isValid());
    Node node = new Node(nodeType, nodeIndex);
    NodeState newNodeState = new NodeState(nodeType, newState);
    Request req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/" + node.getType().toString() + "/" + node.getIndex()));
    req.parameters().add(new StringValue(newNodeState.serialize(true)));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("s"));
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Request(com.yahoo.jrt.Request) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue)

Example 32 with NodeState

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

the class StateVersionTrackerTest method per_node_min_bits_changes_are_not_considered_different.

// For similarity purposes, only the cluster-wide bits matter, not the individual node state
// min used bits. The former is derived from the latter, but the latter is not visible in the
// published state (but _is_ visible in the internal ClusterState structures).
@Test
public void per_node_min_bits_changes_are_not_considered_different() {
    final StateVersionTracker versionTracker = createWithMockedMetrics();
    final AnnotatedClusterState stateWithMinBits = stateWithoutAnnotations("distributor:2 storage:2");
    stateWithMinBits.getClusterState().setNodeState(new Node(NodeType.STORAGE, 0), new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(15));
    updateAndPromote(versionTracker, stateWithMinBits, 123);
    versionTracker.updateLatestCandidateStateBundle(stateBundleWithoutAnnotations("distributor:2 storage:2"));
    assertFalse(versionTracker.candidateChangedEnoughFromCurrentToWarrantPublish());
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node) Test(org.junit.Test)

Example 33 with NodeState

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

the class NodeTest method testNodeNotSeenInSlobrok.

@Test
public void testNodeNotSeenInSlobrok() throws Exception {
    setUp(true);
    ContentCluster old = music.context.cluster;
    music.context.cluster = new ContentCluster(old.getName(), old.getConfiguredNodes().values(), old.getDistribution(), 0, 0.0);
    NodeState currentState = new NodeState(NodeType.STORAGE, State.DOWN);
    currentState.setDescription("Not seen");
    music.context.currentConsolidatedState.setNodeState(new Node(NodeType.STORAGE, 1), currentState);
    UnitResponse response = restAPI.getState(new StateRequest("music/storage/1", 0));
    String expected = "{\n" + "  \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" + "  \"state\": {\n" + "    \"generated\": {\n" + "      \"state\": \"down\",\n" + "      \"reason\": \"Not seen\"\n" + "    },\n" + "    \"unit\": {\n" + "      \"state\": \"down\",\n" + "      \"reason\": \"Node not seen in slobrok.\"\n" + "    },\n" + "    \"user\": {\n" + "      \"state\": \"up\",\n" + "      \"reason\": \"\"\n" + "    }\n" + "  }\n" + "}";
    assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) UnitResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse) Node(com.yahoo.vdslib.state.Node) ContentCluster(com.yahoo.vespa.clustercontroller.core.ContentCluster) Test(org.junit.Test)

Example 34 with NodeState

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

the class DistributionTestFactory method recordResult.

Test recordResult(BucketId bucket) {
    Test t = new Test(bucket);
    Distribution d = new Distribution(new StorDistributionConfig(distributionConfig));
    try {
        if (nodeType.equals(NodeType.DISTRIBUTOR)) {
            int node = d.getIdealDistributorNode(state, bucket, upStates);
            t.nodes.add(node);
        } else {
            for (int i : d.getIdealStorageNodes(state, bucket, upStates)) {
                t.nodes.add(i);
                NodeState ns = state.getNodeState(new Node(nodeType, i));
                if (ns.getDiskCount() != 0) {
                    t.disks.add(d.getIdealDisk(ns, i, bucket));
                } else {
                    t.disks.add(-1);
                }
            }
        }
    } catch (Distribution.TooFewBucketBitsInUseException e) {
        t.failure = Failure.TOO_FEW_BITS;
    } catch (Distribution.NoDistributorsAvailableException e) {
        t.failure = Failure.NO_DISTRIBUTORS_AVAILABLE;
    }
    if (results.size() > testsRecorded) {
        verifySame(t, results.get(testsRecorded));
    } else {
        results.add(t);
    }
    ++testsRecorded;
    return t;
}
Also used : StorDistributionConfig(com.yahoo.vespa.config.content.StorDistributionConfig) NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node)

Example 35 with NodeState

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

the class DistributionBitCountTest method setUpSystem.

private void setUpSystem(String testName) throws Exception {
    List<ConfiguredNode> configuredNodes = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        configuredNodes.add(new ConfiguredNode(i, false));
    }
    FleetControllerOptions options = new FleetControllerOptions("mycluster", configuredNodes);
    options.distributionBits = 17;
    setUpFleetController(false, options);
    startingTest(testName);
    List<DummyVdsNode> nodes = setUpVdsNodes(false, new DummyVdsNodeOptions(), true, configuredNodes);
    for (DummyVdsNode node : nodes) {
        node.setNodeState(new NodeState(node.getType(), State.UP).setMinUsedBits(20));
        node.connect();
    }
    waitForState("version:\\d+ bits:17 distributor:10 storage:10");
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ArrayList(java.util.ArrayList)

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