Search in sources :

Example 11 with Distribution

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

the class DistributionBuilder method forHierarchicCluster.

public static Distribution forHierarchicCluster(GroupBuilder root) {
    List<ConfiguredNode> nodes = buildConfiguredNodes(root.totalNodeCount());
    StorDistributionConfig.Builder configBuilder = new StorDistributionConfig.Builder();
    configBuilder.redundancy(2);
    StorDistributionConfig.Group.Builder rootBuilder = new StorDistributionConfig.Group.Builder();
    rootBuilder.name("invalid");
    rootBuilder.index("invalid");
    rootBuilder.partitions(root.groupDistributionSpec());
    configBuilder.group(rootBuilder);
    int offset = 0;
    for (int group = 0; group < root.groupsWithNodeCount.size(); ++group) {
        int nodeCount = root.groupsWithNodeCount.get(group);
        StorDistributionConfig.Group.Builder groupBuilder = configuredGroup("group_" + (group + 1), group + 1, nodes.subList(offset, offset + nodeCount));
        configBuilder.group(groupBuilder);
        offset += nodeCount;
    }
    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 12 with Distribution

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

the class RpcServerTest method testSetNodeState.

@Test
public void testSetNodeState() throws Exception {
    startingTest("RpcServerTest::testSetNodeState");
    FleetControllerOptions options = new FleetControllerOptions("mycluster");
    Set<Integer> nodeIndexes = new TreeSet<>(Arrays.asList(new Integer[] { 4, 6, 9, 10, 14, 16, 21, 22, 23, 25 }));
    options.setStorageDistribution(new Distribution(getDistConfig(nodeIndexes)));
    setUpFleetController(true, options);
    setUpVdsNodes(true, new DummyVdsNodeOptions(), false, nodeIndexes);
    waitForState("version:\\d+ distributor:26 .0.s:d .1.s:d .2.s:d .3.s:d .5.s:d .7.s:d .8.s:d .11.s:d .12.s:d .13.s:d .15.s:d .17.s:d .18.s:d .19.s:d .20.s:d .24.s:d storage:26 .0.s:d .1.s:d .2.s:d .3.s:d .5.s:d .7.s:d .8.s:d .11.s:d .12.s:d .13.s:d .15.s:d .17.s:d .18.s:d .19.s:d .20.s:d .24.s:d");
    int rpcPort = fleetController.getRpcPort();
    supervisor = new Supervisor(new Transport());
    Target connection = supervisor.connect(new Spec("localhost", rpcPort));
    assertTrue(connection.isValid());
    Request req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/storage/14"));
    req.parameters().add(new StringValue("s:r"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("s"));
    waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r .*");
    req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/storage/16"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    assertTrue(req.toString(), req.checkReturnTypes("s"));
    ClusterState state = waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r.* .16.s:m .*");
    nodes.get(5 * 2 + 1).disconnect();
    waitForCompleteCycle();
    timer.advanceTime(100000000);
    waitForCompleteCycle();
    assertEquals(State.MAINTENANCE, fleetController.getSystemState().getNodeState(new Node(NodeType.STORAGE, 16)).getState());
    nodes.get(4 * 2 + 1).disconnect();
    waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:m.* .16.s:m .*");
    nodes.get(4 * 2 + 1).connect();
    timer.advanceTime(100000000);
    // Might need to pass more actual time while waiting below?
    waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r.* .16.s:m .*");
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) ClusterState(com.yahoo.vdslib.state.ClusterState) Node(com.yahoo.vdslib.state.Node) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Request(com.yahoo.jrt.Request) Target(com.yahoo.jrt.Target) TreeSet(java.util.TreeSet) Distribution(com.yahoo.vdslib.distribution.Distribution) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue) Test(org.junit.Test)

Example 13 with Distribution

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

the class RpcServerTest method testSetNodeStateOutOfRange.

@Test
public void testSetNodeStateOutOfRange() throws Exception {
    startingTest("RpcServerTest::testSetNodeStateOutOfRange");
    FleetControllerOptions options = new FleetControllerOptions("mycluster");
    options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(2, 10)));
    setUpFleetController(true, options);
    setUpVdsNodes(true, new DummyVdsNodeOptions());
    waitForStableSystem();
    int rpcPort = fleetController.getRpcPort();
    supervisor = new Supervisor(new Transport());
    Target connection = supervisor.connect(new Spec("localhost", rpcPort));
    assertTrue(connection.isValid());
    Request req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/storage/10"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
    assertEquals(req.toString(), "Cannot set wanted state of node storage.10. Index does not correspond to a configured node.", req.errorMessage());
    req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/distributor/10"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
    assertEquals(req.toString(), "Cannot set wanted state of node distributor.10. Index does not correspond to a configured node.", req.errorMessage());
    req = new Request("setNodeState");
    req.parameters().add(new StringValue("storage/cluster.mycluster/storage/9"));
    req.parameters().add(new StringValue("s:m"));
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
    waitForState("version:\\d+ distributor:10 storage:10 .9.s:m");
}
Also used : Supervisor(com.yahoo.jrt.Supervisor) Target(com.yahoo.jrt.Target) Distribution(com.yahoo.vdslib.distribution.Distribution) Request(com.yahoo.jrt.Request) Transport(com.yahoo.jrt.Transport) Spec(com.yahoo.jrt.Spec) StringValue(com.yahoo.jrt.StringValue) Test(org.junit.Test)

Example 14 with Distribution

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

the class StatusPagesTest method testSimpleConnectionWithSomeContent.

@Test
public void testSimpleConnectionWithSomeContent() throws Exception {
    // Set this to true temporary if you want to check status page from browser. Should be false in checked in code always.
    boolean haltTestToViewStatusPage = false;
    startingTest("StatusPagesTest::testSimpleConnectionWithSomeContent()");
    FleetControllerOptions options = new FleetControllerOptions("mycluster");
    options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(3, 10)));
    // options.minRatioOfStorageNodesUp = 0.99;
    if (haltTestToViewStatusPage) {
        options.httpPort = 19234;
    }
    setUpFleetController(true, options);
    setUpVdsNodes(true, new DummyVdsNodeOptions());
    waitForStableSystem();
    nodes.get(2).disconnectBreakConnection();
    nodes.get(5).disconnectAsShutdown();
    nodes.get(7).disconnectSlobrok();
    fleetController.getCluster().getNodeInfo(new Node(NodeType.STORAGE, 3)).setWantedState(new NodeState(NodeType.STORAGE, State.MAINTENANCE).setDescription("Test&<>special"));
    String content = doHttpGetRequest("/");
    assertTrue(content, content.contains("<html>"));
    assertTrue(content, content.contains("</html>"));
    assertTrue(content, content.contains("Baseline cluster state"));
    assertTrue(content, content.contains("Cluster states"));
    assertTrue(content, content.contains("Event log"));
    if (haltTestToViewStatusPage) {
        System.err.println(content);
        try {
            Thread.sleep(1000000);
        } catch (InterruptedException e) {
        }
    }
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) Distribution(com.yahoo.vdslib.distribution.Distribution) Node(com.yahoo.vdslib.state.Node) Test(org.junit.Test)

Example 15 with Distribution

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

the class StatusPagesTest method testErrorResponseCode.

@Test
public void testErrorResponseCode() throws Exception {
    startingTest("StatusPagesTest::testNodePage()");
    FleetControllerOptions options = new FleetControllerOptions("mycluster");
    options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(3, 10)));
    setUpFleetController(true, options);
    setUpVdsNodes(true, new DummyVdsNodeOptions());
    waitForStableSystem();
    String content = doHttpGetRequest("/fraggle/rock");
    assertTrue(content.contains("404 Not Found"));
// System.err.println(sb.toString());
}
Also used : Distribution(com.yahoo.vdslib.distribution.Distribution) Test(org.junit.Test)

Aggregations

Distribution (com.yahoo.vdslib.distribution.Distribution)15 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)7 Test (org.junit.Test)7 Request (com.yahoo.jrt.Request)3 Spec (com.yahoo.jrt.Spec)3 Supervisor (com.yahoo.jrt.Supervisor)3 Target (com.yahoo.jrt.Target)3 Transport (com.yahoo.jrt.Transport)3 StringValue (com.yahoo.jrt.StringValue)2 Group (com.yahoo.vdslib.distribution.Group)2 Node (com.yahoo.vdslib.state.Node)2 NodeState (com.yahoo.vdslib.state.NodeState)2 StorDistributionConfig (com.yahoo.vespa.config.content.StorDistributionConfig)2 ClusterState (com.yahoo.vdslib.state.ClusterState)1 StatusHandler (com.yahoo.vespa.clustercontroller.core.status.StatusHandler)1 HttpRequest (com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest)1 HttpResult (com.yahoo.vespa.clustercontroller.utils.communication.http.HttpResult)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1