use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project VX-API-Gateway by EliMirren.
the class VxApiClusterZookeeperImpl method getConfig.
@Override
public void getConfig(Handler<AsyncResult<JsonObject>> event) {
vertx.<JsonObject>executeBlocking(get -> {
JsonObject retry = zkConf.getJsonObject("retry", new JsonObject());
String hosts = zkConf.getString("zookeeperHosts", "127.0.0.1");
int baseSleepTimeMs = retry.getInteger("initialSleepTime", 1000);
int maxRetries = retry.getInteger("maxTimes", 5);
int maxSleepMs = retry.getInteger("intervalTimes", 10000);
int sessionTimeoutMs = zkConf.getInteger("sessionTimeout", 20000);
int connectionTimeoutMs = zkConf.getInteger("connectTimeout", 3000);
ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(baseSleepTimeMs, maxRetries, maxSleepMs);
String vxApiConfPath = zkConf.getString("vxApiConfPath", "/io.vertx/vx.api.gateway/conf");
CuratorFramework client = CuratorFrameworkFactory.newClient(hosts, sessionTimeoutMs, connectionTimeoutMs, retryPolicy);
try {
client.start();
byte[] data = client.getData().forPath(vxApiConfPath);
String jsons = new String(data);
get.complete(new JsonObject(jsons));
} catch (Exception e) {
get.fail(e);
} finally {
client.close();
}
}, event);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project dble by actiontech.
the class DistributedSequenceHandler method initializeZK.
public void initializeZK(String zkAddress) {
if (zkAddress == null) {
throw new RuntimeException("please check zkURL is correct in config file \"myid.prperties\" .");
}
if (this.client != null) {
this.client.close();
}
this.client = CuratorFrameworkFactory.newClient(zkAddress, new ExponentialBackoffRetry(1000, 3));
this.client.start();
try {
if (client.checkExists().forPath(INSTANCE_PATH) == null) {
client.create().creatingParentContainersIfNeeded().forPath(INSTANCE_PATH);
}
} catch (Exception e) {
throw new RuntimeException("create instance path " + INSTANCE_PATH + "error", e);
}
this.leaderSelector = new LeaderSelector(client, KVPathUtil.getSequencesLeaderPath(), this);
this.leaderSelector.autoRequeue();
this.leaderSelector.start();
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
while (leaderSelector.getLeader() == null) {
Thread.currentThread().yield();
}
if (!leaderSelector.hasLeadership()) {
isLeader = false;
if (slavePath != null && client.checkExists().forPath(slavePath) != null) {
return;
}
slavePath = client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(PATH.concat("/instance/node"), "ready".getBytes());
while ("ready".equals(new String(client.getData().forPath(slavePath)))) {
Thread.currentThread().yield();
}
instanceId = Long.parseLong(new String(client.getData().forPath(slavePath)));
ready = true;
}
} catch (Exception e) {
LOGGER.info("Caught exception while handling zk!", e);
}
}
};
long selfCheckPeriod = 10L;
timerExecutor.scheduleAtFixedRate(runnable, 1L, selfCheckPeriod, TimeUnit.SECONDS);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project SpinalTap by airbnb.
the class SpinalTapStandaloneApp method main.
public static void main(String[] args) throws Exception {
if (args.length != 1) {
log.error("Usage: SpinalTapStandaloneApp <config.yaml>");
System.exit(1);
}
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
SpinalTapStandaloneConfiguration config = objectMapper.readValue(new File(args[0]), SpinalTapStandaloneConfiguration.class);
MySQLPipeFactory mySQLPipeFactory = new MySQLPipeFactory(config.getMysqlUser(), config.getMysqlPassword(), config.getMysqlServerId(), () -> new KafkaDestinationBuilder<>(config.getKafkaProducerConfig()), config.getMysqlSchemaStoreConfig(), new TaggedMetricRegistry());
CuratorFramework zkClient = CuratorFrameworkFactory.builder().namespace(config.getZkNamespace()).connectString(config.getZkConnectionString()).retryPolicy(new ExponentialBackoffRetry(100, 3)).build();
ZookeeperRepositoryFactory zkRepositoryFactory = new ZookeeperRepositoryFactory(zkClient);
zkClient.start();
PipeManager pipeManager = new PipeManager();
for (MysqlConfiguration mysqlSourceConfig : config.getMysqlSources()) {
String sourceName = mysqlSourceConfig.getName();
String partitionName = String.format("%s_0", sourceName);
pipeManager.addPipes(sourceName, partitionName, mySQLPipeFactory.createPipes(mysqlSourceConfig, partitionName, zkRepositoryFactory, 0));
}
Runtime.getRuntime().addShutdownHook(new Thread(() -> pipeManager.stop()));
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project iris by chicc999.
the class ZookeeperService method beforeStart.
@Override
public void beforeStart() throws Exception {
ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(1000, 3);
zk = CuratorFrameworkFactory.builder().connectString(connectionString).retryPolicy(retryPolicy).connectionTimeoutMs(connectionTimeout).sessionTimeoutMs(sessionTimeout).namespace(NAME_SPACE).build();
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project iris by chicc999.
the class MetaManager method beforeStart.
@Override
public void beforeStart() throws Exception {
if (zkClient == null) {
ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(metaConfig.getZookeeperBaseSleepTimeMs(), metaConfig.getZookeeperMaxRetries());
zkClient = CuratorFrameworkFactory.builder().connectString(metaConfig.getConnectionString()).retryPolicy(retryPolicy).connectionTimeoutMs(metaConfig.getConnectionTimeout()).sessionTimeoutMs(metaConfig.getSessionTimeout()).namespace(metaConfig.getNameSpace()).build();
}
// 初始化本地broker
if (this.broker == null) {
this.broker = new Broker(System.getProperty(ServerType.Broker.nameKey()));
}
// 初始化本地所在brokerGroup
if (this.brokerGroup == null) {
this.brokerGroup = new BrokerGroup();
}
this.brokerGroup.addBroker(this.broker);
}
Aggregations