use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class HS2ZookeeperURLManagerTest method setup.
@Before
public void setup() throws Exception {
cluster = new TestingCluster(3);
cluster.start();
CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(cluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
String host1 = "hive.server2.authentication=NONE;hive.server2.transport.mode=http;hive.server2.thrift.http.path=cliservice;" + "hive.server2.thrift.http.port=10001;hive.server2.thrift.bind.host=host1;hive.server2.use.SSL=true";
String host2 = "hive.server2.authentication=NONE;hive.server2.transport.mode=http;hive.server2.thrift.http.path=foobar;" + "hive.server2.thrift.http.port=10002;hive.server2.thrift.bind.host=host2;hive.server2.use.SSL=false";
String host3 = "hive.server2.authentication=NONE;hive.server2.transport.mode=http;hive.server2.thrift.http.path=cliservice;" + "hive.server2.thrift.http.port=10003;hive.server2.thrift.bind.host=host3;hive.server2.use.SSL=false";
String host4 = "hive.server2.authentication=NONE;hive.server2.transport.mode=http;hive.server2.thrift.http.path=cliservice;" + "hive.server2.thrift.http.port=10004;hive.server2.thrift.bind.host=host4;hive.server2.use.SSL=true";
zooKeeperClient.start();
zooKeeperClient.create().forPath("/hiveServer2");
zooKeeperClient.create().forPath("/hiveServer2/host1", host1.getBytes());
zooKeeperClient.create().forPath("/hiveServer2/host2", host2.getBytes());
zooKeeperClient.create().forPath("/hiveServer2/host3", host3.getBytes());
zooKeeperClient.create().forPath("/hiveServer2/host4", host4.getBytes());
zooKeeperClient.close();
manager = new HS2ZookeeperURLManager();
HaServiceConfig config = new DefaultHaServiceConfig("HIVE");
config.setEnabled(true);
config.setZookeeperEnsemble(cluster.getConnectString());
config.setZookeeperNamespace("hiveServer2");
manager.setConfig(config);
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class HaDescriptorFactoryTest method testCreateServiceConfig.
@Test
public void testCreateServiceConfig() {
HaServiceConfig serviceConfig = HaDescriptorFactory.createServiceConfig("foo", "enabled=true;maxFailoverAttempts=42;failoverSleep=50;maxRetryAttempts=1;retrySleep=1000");
assertNotNull(serviceConfig);
assertTrue(serviceConfig.isEnabled());
assertEquals("foo", serviceConfig.getServiceName());
assertEquals(42, serviceConfig.getMaxFailoverAttempts());
assertEquals(50, serviceConfig.getFailoverSleep());
assertEquals(1, serviceConfig.getMaxRetryAttempts());
assertEquals(1000, serviceConfig.getRetrySleep());
serviceConfig = HaDescriptorFactory.createServiceConfig("bar", "false", "3", "1000", "5", "3000", null, null);
assertNotNull(serviceConfig);
assertFalse(serviceConfig.isEnabled());
assertEquals("bar", serviceConfig.getServiceName());
assertEquals(3, serviceConfig.getMaxFailoverAttempts());
assertEquals(1000, serviceConfig.getFailoverSleep());
assertEquals(5, serviceConfig.getMaxRetryAttempts());
assertEquals(3000, serviceConfig.getRetrySleep());
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class HaDescriptorManagerTest method testDescriptorLoad.
@Test
public void testDescriptorLoad() throws IOException {
String xml = "<ha><service name='foo' maxFailoverAttempts='42' failoverSleep='4000' maxRetryAttempts='2' retrySleep='2213' enabled='false'/>" + "<service name='bar' failoverLimit='3' enabled='true'/></ha>";
ByteArrayInputStream inputStream = new ByteArrayInputStream(xml.getBytes());
HaDescriptor descriptor = HaDescriptorManager.load(inputStream);
assertNotNull(descriptor);
assertEquals(1, descriptor.getEnabledServiceNames().size());
HaServiceConfig config = descriptor.getServiceConfig("foo");
assertNotNull(config);
assertEquals("foo", config.getServiceName());
assertEquals(42, config.getMaxFailoverAttempts());
assertEquals(4000, config.getFailoverSleep());
assertEquals(2, config.getMaxRetryAttempts());
assertEquals(2213, config.getRetrySleep());
assertFalse(config.isEnabled());
config = descriptor.getServiceConfig("bar");
assertTrue(config.isEnabled());
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class SOLRZookeeperURLManagerTest method testSOLRZookeeperURLManagerLoading.
@Test
public void testSOLRZookeeperURLManagerLoading() {
HaServiceConfig config = new DefaultHaServiceConfig("SOLR");
config.setEnabled(true);
config.setZookeeperEnsemble(cluster.getConnectString());
URLManager manager = URLManagerLoader.loadURLManager(config);
Assert.assertNotNull(manager);
Assert.assertTrue(manager instanceof SOLRZookeeperURLManager);
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class SOLRZookeeperURLManagerTest method setup.
@Before
public void setup() throws Exception {
cluster = new TestingCluster(3);
cluster.start();
CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(cluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
zooKeeperClient.start();
zooKeeperClient.create().forPath("/live_nodes");
zooKeeperClient.create().forPath("/live_nodes/host1:8983_solr");
zooKeeperClient.create().forPath("/live_nodes/host2:8983_solr");
zooKeeperClient.create().forPath("/live_nodes/host3:8983_solr");
zooKeeperClient.close();
manager = new SOLRZookeeperURLManager();
HaServiceConfig config = new DefaultHaServiceConfig("SOLR");
config.setEnabled(true);
config.setZookeeperEnsemble(cluster.getConnectString());
manager.setConfig(config);
}
Aggregations