use of com.yahoo.cloud.config.ZookeepersConfig 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());
}
}
use of com.yahoo.cloud.config.ZookeepersConfig in project vespa by vespa-engine.
the class ClusterControllerTestCase method assertZookeepersConfig.
private void assertZookeepersConfig(TestRoot root) {
ZookeepersConfig.Builder builder = new ZookeepersConfig.Builder();
root.getConfig(builder, "admin/standalone");
ZookeepersConfig config = new ZookeepersConfig(builder);
assertThat(config.zookeeperserverlist().split(",").length, is(3));
}
use of com.yahoo.cloud.config.ZookeepersConfig 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());
}
Aggregations