use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class WebHdfsHaDispatch method init.
@Override
public void init() {
super.init();
if (haProvider != null) {
HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(RESOURCE_ROLE);
maxFailoverAttempts = serviceConfig.getMaxFailoverAttempts();
failoverSleep = serviceConfig.getFailoverSleep();
maxRetryAttempts = serviceConfig.getMaxRetryAttempts();
retrySleep = serviceConfig.getRetrySleep();
}
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class AtlasZookeeperURLManagerTest 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("/apache_atlas");
zooKeeperClient.create().forPath("/apache_atlas/active_server_info");
zooKeeperClient.setData().forPath("/apache_atlas/active_server_info", atlasNode1.getBytes(Charset.forName("UTF-8")));
zooKeeperClient.close();
setAtlasActiveHostURLInZookeeper(atlasNode1);
manager = new AtlasZookeeperURLManager();
HaServiceConfig config = new DefaultHaServiceConfig("ATLAS-API");
config.setEnabled(true);
config.setZookeeperEnsemble(cluster.getConnectString());
config.setZookeeperNamespace("apache_atlas");
manager.setConfig(config);
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class DefaultHaProvider method addHaService.
@Override
public void addHaService(String serviceName, List<String> urls) {
HaServiceConfig haServiceConfig = descriptor.getServiceConfig(serviceName);
URLManager manager = URLManagerLoader.loadURLManager(haServiceConfig);
manager.setURLs(urls);
haServices.put(serviceName, manager);
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class HaDescriptorManagerTest method testDescriptorDefaults.
@Test
public void testDescriptorDefaults() throws IOException {
String xml = "<ha><service name='foo'/></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(HaServiceConfigConstants.DEFAULT_MAX_FAILOVER_ATTEMPTS, config.getMaxFailoverAttempts());
assertEquals(HaServiceConfigConstants.DEFAULT_FAILOVER_SLEEP, config.getFailoverSleep());
assertEquals(HaServiceConfigConstants.DEFAULT_MAX_RETRY_ATTEMPTS, config.getMaxRetryAttempts());
assertEquals(HaServiceConfigConstants.DEFAULT_RETRY_SLEEP, config.getRetrySleep());
assertEquals(HaServiceConfigConstants.DEFAULT_ENABLED, config.isEnabled());
}
use of org.apache.knox.gateway.ha.provider.HaServiceConfig in project knox by apache.
the class KafkaZookeeperURLManagerTest method testHBaseZookeeperURLManagerLoading.
@Test
public void testHBaseZookeeperURLManagerLoading() {
HaServiceConfig config = new DefaultHaServiceConfig("KAFKA");
config.setEnabled(true);
config.setZookeeperEnsemble(cluster.getConnectString());
URLManager manager = URLManagerLoader.loadURLManager(config);
Assert.assertNotNull(manager);
Assert.assertTrue(manager instanceof KafkaZookeeperURLManager);
}
Aggregations