Search in sources :

Example 1 with StorDistributionConfig

use of com.yahoo.vespa.config.content.StorDistributionConfig in project vespa by vespa-engine.

the class ClusterControllerClusterConfigurerTest method testSimple.

@Test
public void testSimple() throws Exception {
    ClusterController controller = new ClusterController();
    StorDistributionConfig.Builder distributionConfig = new StorDistributionConfig.Builder();
    StorDistributionConfig.Group.Builder group = new StorDistributionConfig.Group.Builder();
    group.index("0").name("foo");
    StorDistributionConfig.Group.Nodes.Builder node = new StorDistributionConfig.Group.Nodes.Builder();
    node.index(0);
    group.nodes.add(node);
    distributionConfig.group.add(group);
    FleetcontrollerConfig.Builder fleetcontrollerConfig = new FleetcontrollerConfig.Builder();
    fleetcontrollerConfig.cluster_name("storage").index(0).zookeeper_server("zoo").min_node_ratio_per_group(0.123);
    SlobroksConfig.Builder slobroksConfig = new SlobroksConfig.Builder();
    SlobroksConfig.Slobrok.Builder slobrok = new SlobroksConfig.Slobrok.Builder();
    slobrok.connectionspec("foo");
    slobroksConfig.slobrok.add(slobrok);
    ZookeepersConfig.Builder zookeepersConfig = new ZookeepersConfig.Builder();
    zookeepersConfig.zookeeperserverlist("foo");
    Metric metric = new Metric() {

        @Override
        public void set(String s, Number number, Context context) {
        }

        @Override
        public void add(String s, Number number, Context context) {
        }

        @Override
        public Context createContext(Map<String, ?> stringMap) {
            return null;
        }
    };
    // Used in standalone modus to get config without a cluster controller instance
    ClusterControllerClusterConfigurer configurer = new ClusterControllerClusterConfigurer(null, new StorDistributionConfig(distributionConfig), new FleetcontrollerConfig(fleetcontrollerConfig), new SlobroksConfig(slobroksConfig), new ZookeepersConfig(zookeepersConfig), metric);
    assertTrue(configurer.getOptions() != null);
    assertEquals(0.123, configurer.getOptions().minNodeRatioPerGroup, 0.01);
    // Oki with no zookeeper if one node
    zookeepersConfig.zookeeperserverlist("");
    new ClusterControllerClusterConfigurer(controller, new StorDistributionConfig(distributionConfig), new FleetcontrollerConfig(fleetcontrollerConfig), new SlobroksConfig(slobroksConfig), new ZookeepersConfig(zookeepersConfig), metric);
    try {
        fleetcontrollerConfig.fleet_controller_count(5);
        new ClusterControllerClusterConfigurer(controller, new StorDistributionConfig(distributionConfig), new FleetcontrollerConfig(fleetcontrollerConfig), new SlobroksConfig(slobroksConfig), new ZookeepersConfig(zookeepersConfig), metric);
        fail("Should not get here");
    } catch (Exception e) {
        assertEquals("Must set zookeeper server with multiple fleetcontrollers", e.getMessage());
    }
}
Also used : StorDistributionConfig(com.yahoo.vespa.config.content.StorDistributionConfig) SlobroksConfig(com.yahoo.cloud.config.SlobroksConfig) ZookeepersConfig(com.yahoo.cloud.config.ZookeepersConfig) Metric(com.yahoo.jdisc.Metric) FleetcontrollerConfig(com.yahoo.vespa.config.content.FleetcontrollerConfig) Map(java.util.Map) Test(org.junit.Test)

Example 2 with StorDistributionConfig

use of com.yahoo.vespa.config.content.StorDistributionConfig 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 3 with StorDistributionConfig

use of com.yahoo.vespa.config.content.StorDistributionConfig in project vespa by vespa-engine.

the class ClusterControllerTestCase method assertGroupSize.

private void assertGroupSize(VespaModel model, String configId, int size) {
    StorDistributionConfig.Builder builder = new StorDistributionConfig.Builder();
    model.getConfig(builder, configId);
    StorDistributionConfig cfg = new StorDistributionConfig(builder);
    assertThat(cfg.group().size(), is(size));
}
Also used : StorDistributionConfig(com.yahoo.vespa.config.content.StorDistributionConfig)

Example 4 with StorDistributionConfig

use of com.yahoo.vespa.config.content.StorDistributionConfig in project vespa by vespa-engine.

the class StorageGroupTest method testNestedGroups.

@Test
public void testNestedGroups() throws Exception {
    StorDistributionConfig.Builder builder = new StorDistributionConfig.Builder();
    parse("<content version=\"1.0\" id=\"storage\">\n" + "  <documents/>" + "  <group>\n" + "    <distribution partitions=\"1|*\"/>\n" + "    <group distribution-key=\"0\" name=\"sub1\">\n" + "      <node hostalias=\"mockhost\" distribution-key=\"0\"/>\n" + "      <node hostalias=\"mockhost\" distribution-key=\"1\"/>\n" + "    </group>\n" + "    <group distribution-key=\"1\" name=\"sub2\">\n" + "      <distribution partitions=\"1|*\"/>\n" + "      <group distribution-key=\"0\" name=\"sub3\">\n" + "        <node hostalias=\"mockhost\" distribution-key=\"2\"/>\n" + "        <node hostalias=\"mockhost\" distribution-key=\"3\"/>\n" + "      </group>\n" + "      <group distribution-key=\"1\" name=\"sub4\">\n" + "        <node hostalias=\"mockhost\" distribution-key=\"4\"/>\n" + "        <node hostalias=\"mockhost\" distribution-key=\"5\"/>\n" + "      </group>\n" + "    </group>\n" + "  </group>\n" + "</content>").getConfig(builder);
    StorDistributionConfig config = new StorDistributionConfig(builder);
    assertEquals(5, config.group().size());
    assertEquals("invalid", config.group(0).index());
    assertEquals("0", config.group(1).index());
    assertEquals("1", config.group(2).index());
    assertEquals("1.0", config.group(3).index());
    assertEquals("1.1", config.group(4).index());
    assertEquals("invalid", config.group(0).name());
    assertEquals("sub1", config.group(1).name());
    assertEquals("sub2", config.group(2).name());
    assertEquals("sub3", config.group(3).name());
    assertEquals("sub4", config.group(4).name());
    assertEquals(2, config.group(1).nodes().size());
    assertEquals(0, config.group(1).nodes(0).index());
    assertEquals(1, config.group(1).nodes(1).index());
    assertEquals(0, config.group(2).nodes().size());
    assertEquals(2, config.group(3).nodes().size());
    assertEquals(2, config.group(3).nodes(0).index());
    assertEquals(3, config.group(3).nodes(1).index());
    assertEquals(2, config.group(4).nodes().size());
    assertEquals(4, config.group(4).nodes(0).index());
    assertEquals(5, config.group(4).nodes(1).index());
    assertEquals("1|*", config.group(0).partitions());
}
Also used : StorDistributionConfig(com.yahoo.vespa.config.content.StorDistributionConfig) Test(org.junit.Test)

Example 5 with StorDistributionConfig

use of com.yahoo.vespa.config.content.StorDistributionConfig 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)

Aggregations

StorDistributionConfig (com.yahoo.vespa.config.content.StorDistributionConfig)16 Test (org.junit.Test)11 ContentClusterBuilder (com.yahoo.vespa.model.content.utils.ContentClusterBuilder)5 SearchDefinitionBuilder (com.yahoo.vespa.model.content.utils.SearchDefinitionBuilder)5 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)4 BucketId (com.yahoo.document.BucketId)2 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)2 Distribution (com.yahoo.vdslib.distribution.Distribution)2 ProtonConfig (com.yahoo.vespa.config.search.core.ProtonConfig)2 SlobroksConfig (com.yahoo.cloud.config.SlobroksConfig)1 ZookeepersConfig (com.yahoo.cloud.config.ZookeepersConfig)1 Metric (com.yahoo.jdisc.Metric)1 ClusterState (com.yahoo.vdslib.state.ClusterState)1 Node (com.yahoo.vdslib.state.Node)1 NodeState (com.yahoo.vdslib.state.NodeState)1 FleetcontrollerConfig (com.yahoo.vespa.config.content.FleetcontrollerConfig)1 Map (java.util.Map)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 JSONObject (org.codehaus.jettison.json.JSONObject)1