use of org.apache.curator.ensemble.fixed.FixedEnsembleProvider in project hive by apache.
the class SecretManager method checkRootAcls.
private static void checkRootAcls(Configuration conf, String path, String user) {
int stime = conf.getInt(ZK_DTSM_ZK_SESSION_TIMEOUT, ZK_DTSM_ZK_SESSION_TIMEOUT_DEFAULT), ctime = conf.getInt(ZK_DTSM_ZK_CONNECTION_TIMEOUT, ZK_DTSM_ZK_CONNECTION_TIMEOUT_DEFAULT);
CuratorFramework zkClient = CuratorFrameworkFactory.builder().namespace(null).retryPolicy(new RetryOneTime(10)).sessionTimeoutMs(stime).connectionTimeoutMs(ctime).ensembleProvider(new FixedEnsembleProvider(conf.get(ZK_DTSM_ZK_CONNECTION_STRING))).build();
// Hardcoded from a private field in ZKDelegationTokenSecretManager.
// We need to check the path under what it sets for namespace, since the namespace is
// created with world ACLs.
String nsPath = "/" + path + "/ZKDTSMRoot";
Id currentUser = new Id("sasl", user);
try {
zkClient.start();
List<String> children = zkClient.getChildren().forPath(nsPath);
for (String child : children) {
String childPath = nsPath + "/" + child;
checkAcls(zkClient, currentUser, childPath);
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
zkClient.close();
}
}
use of org.apache.curator.ensemble.fixed.FixedEnsembleProvider in project druid by druid-io.
the class CuratorModuleTest method defaultEnsembleProvider.
@Test
public void defaultEnsembleProvider() throws NoSuchFieldException, IllegalAccessException {
Injector injector = newInjector(new Properties());
// initialize related components
injector.getInstance(CuratorFramework.class);
EnsembleProvider ensembleProvider = injector.getInstance(EnsembleProvider.class);
Assert.assertTrue("EnsembleProvider should be FixedEnsembleProvider", ensembleProvider instanceof FixedEnsembleProvider);
Assert.assertEquals("The connectionString should be 'localhost'", "localhost", ensembleProvider.getConnectionString());
}
use of org.apache.curator.ensemble.fixed.FixedEnsembleProvider in project druid by druid-io.
the class CuratorModuleTest method emptyExhibitorHosts.
@Test
public void emptyExhibitorHosts() {
Properties props = new Properties();
props.put(curatorHostKey, "hostB");
props.put(exhibitorHostsKey, "[]");
Injector injector = newInjector(props);
// initialize related components
injector.getInstance(CuratorFramework.class);
EnsembleProvider ensembleProvider = injector.getInstance(EnsembleProvider.class);
Assert.assertTrue("EnsembleProvider should be FixedEnsembleProvider", ensembleProvider instanceof FixedEnsembleProvider);
Assert.assertEquals("The connectionString should be 'hostB'", "hostB", ensembleProvider.getConnectionString());
}
use of org.apache.curator.ensemble.fixed.FixedEnsembleProvider in project druid by druid-io.
the class CuratorModule method makeEnsembleProvider.
@Provides
@LazySingleton
public EnsembleProvider makeEnsembleProvider(CuratorConfig config, ExhibitorConfig exConfig) {
if (exConfig.getHosts().isEmpty()) {
return new FixedEnsembleProvider(config.getZkHosts());
}
return new ExhibitorEnsembleProvider(new Exhibitors(exConfig.getHosts(), exConfig.getRestPort(), newBackupProvider(config.getZkHosts())), new DefaultExhibitorRestClient(exConfig.getUseSsl()), exConfig.getRestUriPath(), exConfig.getPollingMs(), new BoundedExponentialBackoffRetry(BASE_SLEEP_TIME_MS, MAX_SLEEP_TIME_MS, MAX_RETRIES)) {
@Override
public void start() throws Exception {
log.info("Poll the list of zookeeper servers for initial ensemble");
this.pollForInitialEnsemble();
super.start();
}
};
}
use of org.apache.curator.ensemble.fixed.FixedEnsembleProvider in project druid by druid-io.
the class CuratorModuleTest method fixedZkHosts.
@Test
public void fixedZkHosts() {
Properties props = new Properties();
props.put(curatorHostKey, "hostA");
Injector injector = newInjector(props);
// initialize related components
injector.getInstance(CuratorFramework.class);
EnsembleProvider ensembleProvider = injector.getInstance(EnsembleProvider.class);
Assert.assertTrue("EnsembleProvider should be FixedEnsembleProvider", ensembleProvider instanceof FixedEnsembleProvider);
Assert.assertEquals("The connectionString should be 'hostA'", "hostA", ensembleProvider.getConnectionString());
}
Aggregations