Search in sources :

Example 1 with Distribution

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

the class StateChangeHandlerTest method initialize.

private void initialize(Config config) {
    Distribution distribution = new Distribution(Distribution.getDefaultDistributionConfig(2, 100));
    this.config = config;
    for (int i = 0; i < config.nodeCount; ++i) configuredNodes.add(new ConfiguredNode(i, false));
    cluster = new ContentCluster("testcluster", configuredNodes, distribution, 0, 0.0);
    nodeStateChangeHandler = new StateChangeHandler(clock, eventLog, null);
    params.minStorageNodesUp(1).minDistributorNodesUp(1).minRatioOfStorageNodesUp(0.0).minRatioOfDistributorNodesUp(0.0).maxPrematureCrashes(config.maxPrematureCrashes).transitionTimes(5000).cluster(cluster);
    nodeStateUpdateListener = new TestNodeStateOrHostInfoChangeHandler();
}
Also used : Distribution(com.yahoo.vdslib.distribution.Distribution) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode)

Example 2 with Distribution

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

the class ClusterFixture method forHierarchicCluster.

public static ClusterFixture forHierarchicCluster(DistributionBuilder.GroupBuilder root) {
    List<ConfiguredNode> nodes = DistributionBuilder.buildConfiguredNodes(root.totalNodeCount());
    Distribution distribution = DistributionBuilder.forHierarchicCluster(root);
    ContentCluster cluster = new ContentCluster("foo", nodes, distribution, 0, 0.0);
    return new ClusterFixture(cluster, distribution);
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Distribution(com.yahoo.vdslib.distribution.Distribution)

Example 3 with Distribution

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

the class ClusterFixture method forFlatCluster.

public static ClusterFixture forFlatCluster(int nodeCount) {
    Collection<ConfiguredNode> nodes = DistributionBuilder.buildConfiguredNodes(nodeCount);
    Distribution distribution = DistributionBuilder.forFlatCluster(nodeCount);
    ContentCluster cluster = new ContentCluster("foo", nodes, distribution, 0, 0.0);
    return new ClusterFixture(cluster, distribution);
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Distribution(com.yahoo.vdslib.distribution.Distribution)

Example 4 with Distribution

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

the class RpcServerTest method testGetMaster.

@Test
public void testGetMaster() throws Exception {
    startingTest("RpcServerTest::testGetMaster");
    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("getMaster");
    connection.invokeSync(req, timeoutS);
    assertEquals(req.toString(), 0, req.returnValues().get(0).asInt32());
    assertEquals(req.toString(), "All 1 nodes agree that 0 is current master.", req.returnValues().get(1).asString());
// Note that this feature is tested better in MasterElectionTest.testGetMaster as it has multiple fleetcontrollers
}
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) Test(org.junit.Test)

Example 5 with Distribution

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

the class StatusPagesTest method testStatusThroughContainer.

@Test
public void testStatusThroughContainer() throws Exception {
    startingTest("StatusPagesTest::testStatusThroughContainer()");
    FleetControllerOptions options = new FleetControllerOptions("mycluster");
    options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(3, 10)));
    final StatusHandler.ContainerStatusPageServer statusServer = new StatusHandler.ContainerStatusPageServer();
    setUpFleetController(true, options, true, statusServer);
    setUpVdsNodes(true, new DummyVdsNodeOptions());
    waitForStableSystem();
    // ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 100, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1000));
    // FleetControllerComponent fcComp = new FleetControllerComponent();
    // fcComp.addFleetController("mycluster", fleetController, statusServer);
    StatusHandler comp = new StatusHandler(new StatusHandler.ClusterStatusPageServerSet() {

        @Override
        public StatusHandler.ContainerStatusPageServer get(String cluster) {
            return ("mycluster".equals(cluster) ? statusServer : null);
        }

        @Override
        public Map<String, StatusHandler.ContainerStatusPageServer> getAll() {
            Map<String, StatusHandler.ContainerStatusPageServer> map = new HashMap<>();
            map.put("mycluster", statusServer);
            return map;
        }
    });
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 200, result.getHttpReturnCode());
        assertEquals("<title>clusters</title>\n<a href=\"./mycluster\">mycluster</a><br>\n", result.getContent().toString());
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1/");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 200, result.getHttpReturnCode());
        assertEquals("<title>clusters</title>\n<a href=\"./mycluster\">mycluster</a><br>\n", result.getContent().toString());
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1/mycluster");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 200, result.getHttpReturnCode());
        assertTrue(result.toString(true), result.getContent().toString().contains("mycluster Cluster Controller 0 Status Page"));
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1/mycluster/");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 200, result.getHttpReturnCode());
        assertTrue(result.toString(true), result.getContent().toString().contains("mycluster Cluster Controller 0 Status Page"));
        assertTrue(result.toString(true), result.getContent().toString().contains("href=\"mycluster/node=distributor.0\""));
        assertTrue(result.toString(true), result.getContent().toString().contains("href=\"mycluster/node=storage.0\""));
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1/mycluster/node=storage.0");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 200, result.getHttpReturnCode());
        assertTrue(result.toString(true), result.getContent().toString().contains("Node status for storage.0"));
        assertTrue(result.toString(true), result.getContent().toString().contains("href=\"..\""));
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1/foo");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 404, result.getHttpReturnCode());
    }
    {
        HttpRequest request = new HttpRequest().setPath("/foobar/v1/mycluster/");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 404, result.getHttpReturnCode());
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v2/");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 404, result.getHttpReturnCode());
    }
// executor.shutdown();
}
Also used : HttpRequest(com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest) StatusHandler(com.yahoo.vespa.clustercontroller.core.status.StatusHandler) Distribution(com.yahoo.vdslib.distribution.Distribution) HttpResult(com.yahoo.vespa.clustercontroller.utils.communication.http.HttpResult) HashMap(java.util.HashMap) Map(java.util.Map) 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