use of org.apache.curator.ensemble.exhibitor.Exhibitors in project storm by apache.
the class Utils method setupBuilder.
protected static void setupBuilder(CuratorFrameworkFactory.Builder builder, final String zkStr, Map conf, ZookeeperAuthInfo auth) {
List<String> exhibitorServers = getStrings(conf.get(Config.STORM_EXHIBITOR_SERVERS));
if (!exhibitorServers.isEmpty()) {
// use exhibitor servers
builder.ensembleProvider(new ExhibitorEnsembleProvider(new Exhibitors(exhibitorServers, Utils.getInt(conf.get(Config.STORM_EXHIBITOR_PORT)), new Exhibitors.BackupConnectionStringProvider() {
@Override
public String getBackupConnectionString() throws Exception {
// use zk servers as backup if they exist
return zkStr;
}
}), new DefaultExhibitorRestClient(), Utils.getString(conf.get(Config.STORM_EXHIBITOR_URIPATH)), Utils.getInt(conf.get(Config.STORM_EXHIBITOR_POLL)), new StormBoundedExponentialBackoffRetry(Utils.getInt(conf.get(Config.STORM_EXHIBITOR_RETRY_INTERVAL)), Utils.getInt(conf.get(Config.STORM_EXHIBITOR_RETRY_INTERVAL_CEILING)), Utils.getInt(conf.get(Config.STORM_EXHIBITOR_RETRY_TIMES)))));
} else {
builder.connectString(zkStr);
}
builder.connectionTimeoutMs(Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_CONNECTION_TIMEOUT))).sessionTimeoutMs(Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_SESSION_TIMEOUT))).retryPolicy(new StormBoundedExponentialBackoffRetry(Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_INTERVAL)), Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_INTERVAL_CEILING)), Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_TIMES))));
if (auth != null && auth.scheme != null && auth.payload != null) {
builder.authorization(auth.scheme, auth.payload);
}
}
use of org.apache.curator.ensemble.exhibitor.Exhibitors 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.exhibitor.Exhibitors in project exhibitor by soabase.
the class ExhibitorCreator method makeCurator.
private CuratorFramework makeCurator(final String connectString, int baseSleepTimeMs, int maxRetries, int exhibitorPort, String exhibitorRestPath, int pollingMs) {
List<String> hostnames = Lists.newArrayList();
String[] parts = connectString.split(",");
for (String spec : parts) {
String[] subParts = spec.split(":");
try {
if (subParts.length != 2) {
log.error("Bad connection string: " + connectString);
return null;
}
} catch (NumberFormatException e) {
log.error("Bad connection string: " + connectString);
return null;
}
hostnames.add(subParts[0]);
}
ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(baseSleepTimeMs, maxRetries);
Exhibitors.BackupConnectionStringProvider backupConnectionStringProvider = new Exhibitors.BackupConnectionStringProvider() {
@Override
public String getBackupConnectionString() throws Exception {
return connectString;
}
};
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().connectString(connectString).retryPolicy(retryPolicy);
if (exhibitorPort > 0) {
Exhibitors exhibitors = new Exhibitors(hostnames, exhibitorPort, backupConnectionStringProvider);
ExhibitorEnsembleProvider ensembleProvider = new ExhibitorEnsembleProvider(exhibitors, new DefaultExhibitorRestClient(), exhibitorRestPath + "exhibitor/v1/cluster/list", pollingMs, retryPolicy);
builder = builder.ensembleProvider(ensembleProvider);
} else {
log.warn("Exhibitor on the shared ZooKeeper config ensemble is not being used.");
}
return builder.build();
}
use of org.apache.curator.ensemble.exhibitor.Exhibitors in project chassis by Kixeye.
the class CuratorFrameworkBuilder method withExhibitors.
public CuratorFrameworkBuilder withExhibitors(int port, final String... exhibitors) {
Preconditions.checkNotNull(exhibitors);
Preconditions.checkArgument(exhibitors.length > 0);
Preconditions.checkArgument(port > 0);
if (this.zookeeperConnectionString != null) {
BootstrapException.zookeeperExhibitorConflict();
}
this.exhibitors = new Exhibitors(Arrays.asList(exhibitors), port, new Exhibitors.BackupConnectionStringProvider() {
@Override
public String getBackupConnectionString() throws Exception {
//no backup zookeeper connection string
return "";
}
});
return this;
}
Aggregations