Search in sources :

Example 16 with HaServiceConfig

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();
    }
}
Also used : HaServiceConfig(org.apache.knox.gateway.ha.provider.HaServiceConfig)

Example 17 with HaServiceConfig

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);
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) TestingCluster(org.apache.curator.test.TestingCluster) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) HaServiceConfig(org.apache.knox.gateway.ha.provider.HaServiceConfig) Before(org.junit.Before)

Example 18 with HaServiceConfig

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);
}
Also used : URLManager(org.apache.knox.gateway.ha.provider.URLManager) HaServiceConfig(org.apache.knox.gateway.ha.provider.HaServiceConfig)

Example 19 with HaServiceConfig

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());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) HaDescriptor(org.apache.knox.gateway.ha.provider.HaDescriptor) HaServiceConfig(org.apache.knox.gateway.ha.provider.HaServiceConfig) Test(org.junit.Test)

Example 20 with HaServiceConfig

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);
}
Also used : URLManager(org.apache.knox.gateway.ha.provider.URLManager) HaServiceConfig(org.apache.knox.gateway.ha.provider.HaServiceConfig) Test(org.junit.Test)

Aggregations

HaServiceConfig (org.apache.knox.gateway.ha.provider.HaServiceConfig)20 Test (org.junit.Test)7 URLManager (org.apache.knox.gateway.ha.provider.URLManager)6 HaDescriptor (org.apache.knox.gateway.ha.provider.HaDescriptor)4 IOException (java.io.IOException)3 CuratorFramework (org.apache.curator.framework.CuratorFramework)3 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)3 TestingCluster (org.apache.curator.test.TestingCluster)3 Before (org.junit.Before)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 Document (org.w3c.dom.Document)2 Element (org.w3c.dom.Element)2 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 Transformer (javax.xml.transform.Transformer)1 TransformerException (javax.xml.transform.TransformerException)1 Service (org.apache.knox.gateway.topology.Service)1 Topology (org.apache.knox.gateway.topology.Topology)1 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)1