use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project knox by apache.
the class HBaseZookeeperURLManagerTest 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("/hbase-unsecure");
zooKeeperClient.create().forPath("/hbase-unsecure/rs");
zooKeeperClient.close();
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework 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.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework 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);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project knox by apache.
the class RemoteConfigurationRegistryClientServiceTest method testMultipleUnsecuredZooKeeperWithSimpleRegistryConfig.
/**
* Test multiple configurations for an unsecured remote registry.
*/
@Test
public void testMultipleUnsecuredZooKeeperWithSimpleRegistryConfig() throws Exception {
final String REGISTRY_CLIENT_NAME_1 = "zkclient1";
final String REGISTRY_CLIENT_NAME_2 = "zkclient2";
final String PRINCIPAL = null;
final String PWD = null;
final String CRED_ALIAS = null;
// Configure and start a secure ZK cluster
TestingCluster zkCluster = setupAndStartSecureTestZooKeeper(PRINCIPAL, PWD);
try {
// Create the setup client for the test cluster, and initialize the test znodes
CuratorFramework setupClient = initializeTestClientAndZNodes(zkCluster, PRINCIPAL);
// Mock configuration
GatewayConfig config = EasyMock.createNiceMock(GatewayConfig.class);
final String registryConfigValue1 = GatewayConfig.REMOTE_CONFIG_REGISTRY_TYPE + "=" + ZooKeeperClientService.TYPE + ";" + GatewayConfig.REMOTE_CONFIG_REGISTRY_ADDRESS + "=" + zkCluster.getConnectString();
EasyMock.expect(config.getRemoteRegistryConfiguration(REGISTRY_CLIENT_NAME_1)).andReturn(registryConfigValue1).anyTimes();
final String registryConfigValue2 = GatewayConfig.REMOTE_CONFIG_REGISTRY_TYPE + "=" + ZooKeeperClientService.TYPE + ";" + GatewayConfig.REMOTE_CONFIG_REGISTRY_ADDRESS + "=" + zkCluster.getConnectString();
EasyMock.expect(config.getRemoteRegistryConfiguration(REGISTRY_CLIENT_NAME_2)).andReturn(registryConfigValue2).anyTimes();
EasyMock.expect(config.getRemoteRegistryConfigurationNames()).andReturn(Arrays.asList(REGISTRY_CLIENT_NAME_1, REGISTRY_CLIENT_NAME_2)).anyTimes();
EasyMock.replay(config);
// Create the client service instance
RemoteConfigurationRegistryClientService clientService = RemoteConfigurationRegistryClientServiceFactory.newInstance(config);
assertEquals("Wrong registry client service type.", clientService.getClass(), CuratorClientService.class);
clientService.setAliasService(null);
clientService.init(config, null);
clientService.start();
RemoteConfigurationRegistryClient client1 = clientService.get(REGISTRY_CLIENT_NAME_1);
assertNotNull(client1);
RemoteConfigurationRegistryClient client2 = clientService.get(REGISTRY_CLIENT_NAME_2);
assertNotNull(client2);
doTestZooKeeperClient(setupClient, REGISTRY_CLIENT_NAME_1, clientService, false);
doTestZooKeeperClient(setupClient, REGISTRY_CLIENT_NAME_2, clientService, false);
} finally {
zkCluster.stop();
}
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project knox by apache.
the class RemoteConfigurationRegistryClientServiceTest method initializeTestClientAndZNodes.
/**
* Create a ZooKeeper client with SASL digest auth configured, and initialize the test znodes.
*/
private CuratorFramework initializeTestClientAndZNodes(TestingCluster zkCluster, String principal) throws Exception {
// Create the client for the test cluster
CuratorFramework setupClient = CuratorFrameworkFactory.builder().connectString(zkCluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(100, 3)).build();
assertNotNull(setupClient);
setupClient.start();
List<ACL> acls = new ArrayList<>();
if (principal != null) {
acls.add(new ACL(ZooDefs.Perms.ALL, new Id("sasl", principal)));
} else {
acls.add(new ACL(ZooDefs.Perms.ALL, ZooDefs.Ids.ANYONE_ID_UNSAFE));
}
setupClient.create().creatingParentsIfNeeded().withACL(acls).forPath("/knox/config/descriptors");
setupClient.create().creatingParentsIfNeeded().withACL(acls).forPath("/knox/config/shared-providers");
List<ACL> negativeACLs = new ArrayList<>();
if (principal != null) {
negativeACLs.add(new ACL(ZooDefs.Perms.ALL, new Id("sasl", "notyou")));
} else {
negativeACLs.add(new ACL(ZooDefs.Perms.ALL, ZooDefs.Ids.ANYONE_ID_UNSAFE));
}
setupClient.create().creatingParentsIfNeeded().withACL(negativeACLs).forPath("/someotherconfig");
return setupClient;
}
Aggregations