use of org.apache.rocketmq.redis.replicator.conf.ReplicatorConstants.DEPLOY_MODEL in project rocketmq-externals by apache.
the class RocketMQRedisReplicator method open.
@Override
public void open() throws IOException {
if (this.replicator instanceof RedisSocketReplicator) {
boolean single = configure.getString(DEPLOY_MODEL).equals(DEPLOY_MODEL_SINGLE);
if (single) {
this.replicator.open();
} else {
String address = configure.getString(CONFIG_PROP_ZK_ADDRESS);
final CuratorFramework client = newClient(address, new ExponentialBackoffRetry(1000, 3));
client.start();
String path = ROOT_DIR + "/" + uri.getHost() + "-" + uri.getPort();
final LeaderSelector selector = new LeaderSelector(client, path, new LeaderSelectorListenerAdapter() {
@Override
public void takeLeadership(final CuratorFramework client) throws Exception {
RocketMQRedisReplicator.this.addCloseListener(r -> client.close());
replicator.open();
}
});
selector.start();
}
} else {
this.replicator.open();
}
}
Aggregations