Search in sources :

Example 11 with ConfiguredNode

use of com.yahoo.vdslib.distribution.ConfiguredNode in project vespa by vespa-engine.

the class RpcServerTest method testGetNodeState.

@Test
public void testGetNodeState() throws Exception {
    startingTest("RpcServerTest::testGetNodeState");
    Set<ConfiguredNode> configuredNodes = new TreeSet<>();
    for (int i = 0; i < 10; i++) configuredNodes.add(new ConfiguredNode(i, false));
    FleetControllerOptions options = new FleetControllerOptions("mycluster", configuredNodes);
    options.minRatioOfStorageNodesUp = 0;
    options.maxInitProgressTime = 30000;
    options.stableStateTimePeriod = 60000;
    setUpFleetController(true, options);
    setUpVdsNodes(true, new DummyVdsNodeOptions());
    waitForStableSystem();
    setWantedNodeState(State.DOWN, NodeType.DISTRIBUTOR, 2);
    setWantedNodeState(State.RETIRED, NodeType.STORAGE, 2);
    setWantedNodeState(State.MAINTENANCE, NodeType.STORAGE, 7);
    waitForCompleteCycle();
    timer.advanceTime(1000000);
    // Make fleet controller notice that time has changed before any disconnects
    waitForCompleteCycle();
    nodes.get(0).disconnect();
    nodes.get(3).disconnect();
    nodes.get(5).disconnect();
    waitForState("version:\\d+ distributor:10 .0.s:d .2.s:d storage:10 .1.s:m .2.s:m .7.s:m");
    timer.advanceTime(1000000);
    waitForState("version:\\d+ distributor:10 .0.s:d .2.s:d storage:10 .1.s:d .2.s:d .7.s:m");
    timer.advanceTime(1000000);
    // Make fleet controller notice that time has changed before any disconnects
    waitForCompleteCycle();
    nodes.get(3).setNodeState(new NodeState(nodes.get(3).getType(), State.INITIALIZING).setInitProgress(0.2));
    nodes.get(3).connect();
    waitForState("version:\\d+ distributor:10 .0.s:d .2.s:d storage:10 .1.s:i .1.i:0.2 .2.s:d .7.s:m");
    int rpcPort = fleetController.getRpcPort();
    supervisor = new Supervisor(new Transport());
    Target connection = supervisor.connect(new Spec("localhost", rpcPort));
    assertTrue(connection.isValid());
    Request req = new Request("getNodeState");
    req.parameters().add(new StringValue("distributor"));
    req.parameters().add(new Int32Value(0));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("ssss"));
    assertEquals(State.DOWN, NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(0).asString()).getState());
    NodeState reported = NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(1).asString());
    assertTrue(req.returnValues().get(1).asString(), reported.getState().oneOf("d-"));
    assertEquals("", req.returnValues().get(2).asString());
    req = new Request("getNodeState");
    req.parameters().add(new StringValue("distributor"));
    req.parameters().add(new Int32Value(2));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("ssss"));
    assertEquals(State.DOWN, NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(0).asString()).getState());
    assertEquals("t:946080000", req.returnValues().get(1).asString());
    assertEquals(State.DOWN, NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(2).asString()).getState());
    req = new Request("getNodeState");
    req.parameters().add(new StringValue("distributor"));
    req.parameters().add(new Int32Value(4));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("ssss"));
    assertEquals("", req.returnValues().get(0).asString());
    assertEquals("t:946080000", req.returnValues().get(1).asString());
    assertEquals("", req.returnValues().get(2).asString());
    req = new Request("getNodeState");
    req.parameters().add(new StringValue("distributor"));
    req.parameters().add(new Int32Value(15));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
    assertEquals("No node distributor.15 exists in cluster mycluster", req.errorMessage());
    assertFalse(req.toString(), req.checkReturnTypes("ssss"));
    req = new Request("getNodeState");
    req.parameters().add(new StringValue("storage"));
    req.parameters().add(new Int32Value(1));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("ssss"));
    assertEquals("s:i i:0.2", req.returnValues().get(0).asString());
    assertEquals("s:i i:0.2", req.returnValues().get(1).asString());
    assertEquals("", req.returnValues().get(2).asString());
    req = new Request("getNodeState");
    req.parameters().add(new StringValue("storage"));
    req.parameters().add(new Int32Value(2));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("ssss"));
    assertEquals(State.DOWN, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(0).asString()).getState());
    reported = NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(1).asString());
    assertTrue(req.returnValues().get(1).asString(), reported.getState().oneOf("d-"));
    assertEquals(State.RETIRED, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(2).asString()).getState());
    req = new Request("getNodeState");
    req.parameters().add(new StringValue("storage"));
    req.parameters().add(new Int32Value(5));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("ssss"));
    assertEquals("", req.returnValues().get(0).asString());
    assertEquals("t:946080000", req.returnValues().get(1).asString());
    assertEquals("", req.returnValues().get(2).asString());
    req = new Request("getNodeState");
    req.parameters().add(new StringValue("storage"));
    req.parameters().add(new Int32Value(7));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("ssss"));
    assertEquals(State.MAINTENANCE, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(0).asString()).getState());
    assertEquals("t:946080000", req.returnValues().get(1).asString());
    assertEquals(State.MAINTENANCE, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(2).asString()).getState());
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) NodeState(com.yahoo.vdslib.state.NodeState) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Request(com.yahoo.jrt.Request) Target(com.yahoo.jrt.Target) TreeSet(java.util.TreeSet) Int32Value(com.yahoo.jrt.Int32Value) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue) Test(org.junit.Test)

Example 12 with ConfiguredNode

use of com.yahoo.vdslib.distribution.ConfiguredNode in project vespa by vespa-engine.

the class StateRestApiTest method initializeCluster.

protected void initializeCluster(ContentCluster cluster, Collection<ConfiguredNode> nodes) {
    for (ConfiguredNode configuredNode : nodes) {
        for (NodeType type : NodeType.getTypes()) {
            NodeState reported = new NodeState(type, State.UP);
            if (type.equals(NodeType.STORAGE)) {
                reported.setDiskCount(2);
            }
            NodeInfo nodeInfo = cluster.clusterInfo().setRpcAddress(new Node(type, configuredNode.index()), "rpc:" + type + "/" + configuredNode);
            nodeInfo.setReportedState(reported, 10);
            nodeInfo.setHostInfo(HostInfo.createHostInfo(getHostInfo()));
        }
    }
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode)

Example 13 with ConfiguredNode

use of com.yahoo.vdslib.distribution.ConfiguredNode in project vespa by vespa-engine.

the class DistributionBuilder method forFlatCluster.

public static Distribution forFlatCluster(int nodeCount) {
    Collection<ConfiguredNode> nodes = buildConfiguredNodes(nodeCount);
    StorDistributionConfig.Builder configBuilder = new StorDistributionConfig.Builder();
    configBuilder.redundancy(2);
    configBuilder.group(configuredGroup("bar", 0, nodes));
    return new Distribution(new StorDistributionConfig(configBuilder));
}
Also used : StorDistributionConfig(com.yahoo.vespa.config.content.StorDistributionConfig) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Distribution(com.yahoo.vdslib.distribution.Distribution)

Example 14 with ConfiguredNode

use of com.yahoo.vdslib.distribution.ConfiguredNode in project vespa by vespa-engine.

the class ClusterInfo method setNodes.

/**
 * Sets the nodes which belongs to this cluster
 */
void setNodes(Collection<ConfiguredNode> newNodes, ContentCluster owner, Distribution distribution) {
    // Remove info for removed nodes
    Set<ConfiguredNode> newNodesSet = new HashSet<>(newNodes);
    for (ConfiguredNode existingNode : this.nodes.values()) {
        if (!newNodesSet.contains(existingNode)) {
            Node existingStorageNode = storageNodeInfo.remove(existingNode.index()).getNode();
            Node existingDistributorNode = distributorNodeInfo.remove(existingNode.index()).getNode();
            allNodeInfo.remove(existingDistributorNode);
            allNodeInfo.remove(existingStorageNode);
        }
    }
    // Add and update new nodes info
    for (ConfiguredNode node : newNodes) {
        if (!nodes.containsKey(node.index())) {
            // add new node info
            addNodeInfo(new DistributorNodeInfo(owner, node.index(), null, distribution));
            addNodeInfo(new StorageNodeInfo(owner, node.index(), node.retired(), null, distribution));
        } else {
            getStorageNodeInfo(node.index()).setConfiguredRetired(node.retired());
        }
    }
    // Update node set
    nodes.clear();
    for (ConfiguredNode node : newNodes) {
        this.nodes.put(node.index(), node);
    }
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Node(com.yahoo.vdslib.state.Node) HashSet(java.util.HashSet)

Example 15 with ConfiguredNode

use of com.yahoo.vdslib.distribution.ConfiguredNode 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

ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)26 Test (org.junit.Test)8 NodeState (com.yahoo.vdslib.state.NodeState)7 Distribution (com.yahoo.vdslib.distribution.Distribution)6 HashSet (java.util.HashSet)5 Node (com.yahoo.vdslib.state.Node)3 ArrayList (java.util.ArrayList)3 Group (com.yahoo.vdslib.distribution.Group)2 ClusterState (com.yahoo.vdslib.state.ClusterState)2 NodeType (com.yahoo.vdslib.state.NodeType)2 StorDistributionConfig (com.yahoo.vespa.config.content.StorDistributionConfig)2 Int32Value (com.yahoo.jrt.Int32Value)1 Request (com.yahoo.jrt.Request)1 Spec (com.yahoo.jrt.Spec)1 StringValue (com.yahoo.jrt.StringValue)1 Supervisor (com.yahoo.jrt.Supervisor)1 Target (com.yahoo.jrt.Target)1 Transport (com.yahoo.jrt.Transport)1 DatabaseHandler (com.yahoo.vespa.clustercontroller.core.database.DatabaseHandler)1 VdsClusterHtmlRendrer (com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRendrer)1