Search in sources :

Example 1 with SlobroksConfig

use of com.yahoo.cloud.config.SlobroksConfig 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 SlobroksConfig

use of com.yahoo.cloud.config.SlobroksConfig in project vespa by vespa-engine.

the class AdminTestCase method testOnlyAdminserver.

/**
 * Test that a very simple config with only adminserver tag creates
 * adminserver, logserver, configserver and slobroks
 */
@Test
public void testOnlyAdminserver() throws Exception {
    VespaModel vespaModel = getVespaModel(TESTDIR + "simpleadminconfig20");
    // Verify that the admin plugin has been loaded (always loads routing).
    assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
    ApplicationConfigProducerRoot root = vespaModel.getVespa();
    assertNotNull(root);
    // Verify configIds
    Set<String> configIds = vespaModel.getConfigIds();
    String localhost = HostName.getLocalhost();
    String localhostConfigId = "hosts/" + localhost;
    assertTrue(configIds.contains(localhostConfigId));
    assertTrue(configIds.contains("admin/logserver"));
    assertTrue(configIds.contains("admin/configservers/configserver.0"));
    assertTrue(configIds.contains("admin/slobrok.0"));
    assertFalse(configIds.contains("admin/slobrok.1"));
    // Verify services in the sentinel config
    SentinelConfig.Builder b = new SentinelConfig.Builder();
    vespaModel.getConfig(b, localhostConfigId);
    SentinelConfig sentinelConfig = new SentinelConfig(b);
    assertThat(sentinelConfig.service().size(), is(3));
    assertThat(sentinelConfig.service(0).name(), is("logserver"));
    assertThat(sentinelConfig.service(1).name(), is("slobrok"));
    assertThat(sentinelConfig.service(2).name(), is("logd"));
    assertThat(sentinelConfig.service(0).affinity().cpuSocket(), is(-1));
    assertTrue(sentinelConfig.service(0).preShutdownCommand().isEmpty());
    // Confirm slobrok config
    SlobroksConfig.Builder sb = new SlobroksConfig.Builder();
    vespaModel.getConfig(sb, "admin");
    SlobroksConfig sc = new SlobroksConfig(sb);
    assertEquals(sc.slobrok().size(), 1);
    assertTrue(sc.slobrok().get(0).connectionspec().matches(".*" + localhost + ".*"));
}
Also used : SlobroksConfig(com.yahoo.cloud.config.SlobroksConfig) ApplicationConfigProducerRoot(com.yahoo.config.model.ApplicationConfigProducerRoot) SentinelConfig(com.yahoo.cloud.config.SentinelConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 3 with SlobroksConfig

use of com.yahoo.cloud.config.SlobroksConfig in project vespa by vespa-engine.

the class AdminTestCase method testAdmin20.

/**
 * Test that version 2.0 of adminconfig works as expected.
 */
@Test
public void testAdmin20() throws Exception {
    VespaModel vespaModel = getVespaModel(TESTDIR + "adminconfig20");
    // Verify that the admin plugin has been loaded (always loads routing).
    assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
    ApplicationConfigProducerRoot root = vespaModel.getVespa();
    assertNotNull(root);
    // Verify configIds
    Set<String> configIds = vespaModel.getConfigIds();
    String localhost = HostName.getLocalhost();
    String localhostConfigId = "hosts/" + localhost;
    assertTrue(configIds.contains(localhostConfigId));
    assertTrue(configIds.contains("admin/logserver"));
    assertTrue(configIds.contains("admin/configservers/configserver.0"));
    assertTrue(configIds.contains("admin/slobrok.0"));
    assertTrue(configIds.contains("admin/slobrok.1"));
    assertFalse(configIds.contains("admin/slobrok.2"));
    assertTrue(configIds.contains("admin"));
    // Confirm 2 slobroks in config
    SlobroksConfig.Builder sb = new SlobroksConfig.Builder();
    vespaModel.getConfig(sb, "admin/slobrok.0");
    SlobroksConfig sc = new SlobroksConfig(sb);
    assertEquals(sc.slobrok().size(), 2);
    boolean localHostOK = false;
    for (Slobrok s : sc.slobrok()) {
        if (s.connectionspec().matches(".*" + localhost + ".*"))
            localHostOK = true;
    }
    assertTrue(localHostOK);
    LogdConfig.Builder lb = new LogdConfig.Builder();
    vespaModel.getConfig(lb, "admin/slobrok.0");
    LogdConfig lc = new LogdConfig(lb);
    assertEquals(lc.logserver().host(), localhost);
    // Verify services in the sentinel config
    SentinelConfig.Builder b = new SentinelConfig.Builder();
    vespaModel.getConfig(b, localhostConfigId);
    SentinelConfig sentinelConfig = new SentinelConfig(b);
    assertThat(sentinelConfig.service().size(), is(4));
    assertThat(sentinelConfig.service(0).name(), is("logserver"));
    assertThat(sentinelConfig.service(1).name(), is("slobrok"));
    assertThat(sentinelConfig.service(2).name(), is("slobrok2"));
    assertThat(sentinelConfig.service(3).name(), is("logd"));
}
Also used : SlobroksConfig(com.yahoo.cloud.config.SlobroksConfig) LogdConfig(com.yahoo.cloud.config.log.LogdConfig) ApplicationConfigProducerRoot(com.yahoo.config.model.ApplicationConfigProducerRoot) SentinelConfig(com.yahoo.cloud.config.SentinelConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Slobrok(com.yahoo.cloud.config.SlobroksConfig.Slobrok) Test(org.junit.Test)

Example 4 with SlobroksConfig

use of com.yahoo.cloud.config.SlobroksConfig in project vespa by vespa-engine.

the class VespaModelTestCase method testCommonConfig.

// Verify that common config from plugins is delivered from the root node for any configId, using the Builder based API
@Test
public void testCommonConfig() throws Exception {
    VespaModel model = getVespaModel(TESTDIR + "app_nohosts/");
    LogdConfig.Builder b = new LogdConfig.Builder();
    b = (LogdConfig.Builder) model.getConfig(b, "");
    LogdConfig c = new LogdConfig(b);
    assertEquals(HostName.getLocalhost(), c.logserver().host());
    SlobroksConfig.Builder sb = new SlobroksConfig.Builder();
    sb = (com.yahoo.cloud.config.SlobroksConfig.Builder) model.getConfig(sb, "");
    SlobroksConfig sbc = new SlobroksConfig(sb);
    assertEquals(sbc.slobrok().size(), 1);
    ZookeepersConfig.Builder zb = new ZookeepersConfig.Builder();
    zb = (ZookeepersConfig.Builder) model.getConfig(zb, "");
    ZookeepersConfig zc = new ZookeepersConfig(zb);
    assertEquals(zc.zookeeperserverlist().split(",").length, 2);
    assertTrue(zc.zookeeperserverlist().startsWith(HostName.getLocalhost()));
    ApplicationIdConfig.Builder appIdBuilder = new ApplicationIdConfig.Builder();
    appIdBuilder = (ApplicationIdConfig.Builder) model.getConfig(appIdBuilder, "");
    ApplicationIdConfig applicationIdConfig = new ApplicationIdConfig(appIdBuilder);
    assertEquals(ApplicationId.defaultId().tenant().value(), applicationIdConfig.tenant());
    assertEquals(ApplicationId.defaultId().application().value(), applicationIdConfig.application());
    assertEquals(ApplicationId.defaultId().instance().value(), applicationIdConfig.instance());
}
Also used : SlobroksConfig(com.yahoo.cloud.config.SlobroksConfig) ApplicationIdConfig(com.yahoo.cloud.config.ApplicationIdConfig) LogdConfig(com.yahoo.cloud.config.log.LogdConfig) VespaModel(com.yahoo.vespa.model.VespaModel) ZookeepersConfig(com.yahoo.cloud.config.ZookeepersConfig) Test(org.junit.Test)

Aggregations

SlobroksConfig (com.yahoo.cloud.config.SlobroksConfig)4 Test (org.junit.Test)4 VespaModel (com.yahoo.vespa.model.VespaModel)3 SentinelConfig (com.yahoo.cloud.config.SentinelConfig)2 ZookeepersConfig (com.yahoo.cloud.config.ZookeepersConfig)2 LogdConfig (com.yahoo.cloud.config.log.LogdConfig)2 ApplicationConfigProducerRoot (com.yahoo.config.model.ApplicationConfigProducerRoot)2 ApplicationIdConfig (com.yahoo.cloud.config.ApplicationIdConfig)1 Slobrok (com.yahoo.cloud.config.SlobroksConfig.Slobrok)1 Metric (com.yahoo.jdisc.Metric)1 FleetcontrollerConfig (com.yahoo.vespa.config.content.FleetcontrollerConfig)1 StorDistributionConfig (com.yahoo.vespa.config.content.StorDistributionConfig)1 Map (java.util.Map)1