本文整理了Java中org.apache.curator.ensemble.fixed.FixedEnsembleProvider.<init>()
方法的一些代码示例,展示了FixedEnsembleProvider.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FixedEnsembleProvider.<init>()
方法的具体详情如下:
包路径:org.apache.curator.ensemble.fixed.FixedEnsembleProvider
类名称:FixedEnsembleProvider
方法名:<init>
[英]The connection string to use
[中]要使用的连接字符串
代码示例来源:origin: apache/hive
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();
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
throw new RuntimeException("Could not Load ZK acls or auth");
zkClient = builder.ensembleProvider(new FixedEnsembleProvider(connString))
.build();
isExternalClient = false;
代码示例来源:origin: apache/incubator-druid
@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();
}
};
}
代码示例来源:origin: org.apache.curator/curator-framework
/**
* Set the list of servers to connect to. IMPORTANT: use either this or {@link #ensembleProvider(EnsembleProvider)}
* but not both.
*
* @param connectString list of servers to connect to
* @return this
*/
public Builder connectString(String connectString)
{
ensembleProvider = new FixedEnsembleProvider(connectString);
return this;
}
代码示例来源:origin: info.xiancloud/xian-curator-framework
/**
* Set the list of servers to connect to. IMPORTANT: use either this or {@link #ensembleProvider(EnsembleProvider)}
* but not both.
*
* @param connectString list of servers to connect to
* @return this
*/
public Builder connectString(String connectString)
{
ensembleProvider = new FixedEnsembleProvider(connectString);
return this;
}
代码示例来源:origin: xiancloud/xian
/**
*
* @param connectString list of servers to connect to
* @param sessionTimeoutMs session timeout
* @param connectionTimeoutMs connection timeout
* @param watcher default watcher or null
* @param retryPolicy the retry policy to use
*/
public CuratorZookeeperClient(String connectString, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy)
{
this(new DefaultZookeeperFactory(), new FixedEnsembleProvider(connectString), sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false);
}
代码示例来源:origin: io.fabric8/fabric-zookeeper
/**
*
* @param connectString list of servers to connect to
* @param sessionTimeoutMs session timeout
* @param connectionTimeoutMs connection timeout
* @param watcher default watcher or null
* @param retryPolicy the retry policy to use
*/
public CuratorZookeeperClient(String connectString, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy)
{
this(new DefaultZookeeperFactory(), new FixedEnsembleProvider(connectString), sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false);
}
代码示例来源:origin: jboss-fuse/fabric8
/**
*
* @param connectString list of servers to connect to
* @param sessionTimeoutMs session timeout
* @param connectionTimeoutMs connection timeout
* @param watcher default watcher or null
* @param retryPolicy the retry policy to use
*/
public CuratorZookeeperClient(String connectString, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy)
{
this(new DefaultZookeeperFactory(), new FixedEnsembleProvider(connectString), sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false);
}
代码示例来源:origin: org.apache.curator/curator-client
/**
*
* @param connectString list of servers to connect to
* @param sessionTimeoutMs session timeout
* @param connectionTimeoutMs connection timeout
* @param watcher default watcher or null
* @param retryPolicy the retry policy to use
*/
public CuratorZookeeperClient(String connectString, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy)
{
this(new DefaultZookeeperFactory(), new FixedEnsembleProvider(connectString), sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false, new StandardConnectionHandlingPolicy());
}
代码示例来源:origin: com.haulmont.addon.zookeeper/cubazk-global
protected void connect() {
log.info("Connecting to ZooKeeper at {}", connection);
if (connection == null || connection.trim().isEmpty()) {
throw new IllegalArgumentException("Cannot connect to ZooKeeper: missing connection property");
}
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
.ensembleProvider(new FixedEnsembleProvider(connection))
.connectionTimeoutMs(connectionTimeout)
.sessionTimeoutMs(sessionTimeout)
.retryPolicy(new RetryNTimes(maxRetry, retryInterval));
if (password != null && password.length() > 0) {
builder = builder.authorization("digest", password.getBytes());
}
curator = builder.build();
curator.start();
}
代码示例来源:origin: org.zalando.paradox/paradox-nakadi-consumer-partitioned-zk
public void init() throws Exception {
Preconditions.checkArgument(StringUtils.isNotEmpty(zookeeperBrokers), "zookeeperBrokers must not be empty");
final RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
final EnsembleProvider ensembleProvider;
if (StringUtils.isNotEmpty(exhibitorAddresses)) {
final Collection<String> exhibitorHosts = Arrays.asList(exhibitorAddresses.split("\\s*,\\s*"));
final Exhibitors exhibitors = new Exhibitors(exhibitorHosts, exhibitorPort, () -> zookeeperBrokers);
final ExhibitorRestClient exhibitorRestClient = new DefaultExhibitorRestClient();
ensembleProvider = new ExhibitorEnsembleProvider(exhibitors, exhibitorRestClient,
"/exhibitor/v1/cluster/list", 300000, retryPolicy);
((ExhibitorEnsembleProvider) ensembleProvider).pollForInitialEnsemble();
} else {
ensembleProvider = new FixedEnsembleProvider(zookeeperBrokers);
}
curator = CuratorFrameworkFactory.builder().ensembleProvider(ensembleProvider).retryPolicy(retryPolicy).build();
curator.start();
}
代码示例来源:origin: io.hops/hadoop-yarn-registry
/**
* Supply the binding information.
* This implementation returns a fixed ensemble bonded to
* the quorum supplied by {@link #buildConnectionString()}
* @return the binding information
*/
@Override
public BindingInformation supplyBindingInformation() {
BindingInformation binding = new BindingInformation();
String connectString = buildConnectionString();
binding.ensembleProvider = new FixedEnsembleProvider(connectString);
binding.description =
"fixed ZK quorum \"" + connectString + "\"";
return binding;
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry
/**
* Supply the binding information.
* This implementation returns a fixed ensemble bonded to
* the quorum supplied by {@link #buildConnectionString()}.
*
* @return the binding information
*/
@Override
public BindingInformation supplyBindingInformation() {
BindingInformation binding = new BindingInformation();
String connectString = buildConnectionString();
binding.ensembleProvider = new FixedEnsembleProvider(connectString);
binding.description =
"fixed ZK quorum \"" + connectString + "\"";
return binding;
}
代码示例来源:origin: jboss-fuse/fabric8
protected CuratorFramework createCurator() throws KeeperException {
log.info(String.format("Creating curator [%s], mode: %s", connection, getCreateMode()));
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
.ensembleProvider(new FixedEnsembleProvider(connection))
.connectionTimeoutMs(connectionTimeout)
.sessionTimeoutMs(sessionTimeout)
.retryPolicy(new RetryNTimes(maxRetry, retryInterval));
if (password != null && password.length() > 0) {
builder = builder.authorization(getScheme(), getAuth()).aclProvider(aclProvider);
}
return builder.build();
}
代码示例来源:origin: org.apache.hadoop/hadoop-yarn-registry
binding.ensembleProvider = new FixedEnsembleProvider(connectString);
binding.description =
getName() + " reachable at \"" + connectString + "\"";
代码示例来源:origin: io.hops/hadoop-yarn-registry
binding.ensembleProvider = new FixedEnsembleProvider(connectString);
binding.description =
getName() + " reachable at \"" + connectString + "\"";
代码示例来源:origin: jboss-fuse/fabric8
/**
* Builds a {@link org.apache.curator.framework.CuratorFramework} from the specified {@link java.util.Map<String, ?>}.
*/
private synchronized CuratorFramework buildCuratorFramework(CuratorConfig curatorConfig) {
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
.canBeReadOnly(true)
.ensembleProvider(new FixedEnsembleProvider(curatorConfig.getZookeeperUrl()))
.connectionTimeoutMs(curatorConfig.getZookeeperConnectionTimeOut())
.sessionTimeoutMs(curatorConfig.getZookeeperSessionTimeout())
.retryPolicy(new RetryNTimes(curatorConfig.getZookeeperRetryMax(), curatorConfig.getZookeeperRetryInterval()));
if (!Strings.isNullOrEmpty(curatorConfig.getZookeeperPassword())) {
String scheme = "digest";
byte[] auth = ("fabric:" + PasswordEncoder.decode(curatorConfig.getZookeeperPassword())).getBytes();
builder = builder.authorization(scheme, auth).aclProvider(aclProvider.get());
}
CuratorFramework framework = builder.build();
// ENTESB-2111: don't register SCR-bound ConnectionStateListeners here, rather
// invoke them once in State.stateChanged()
// for (ConnectionStateListener listener : connectionStateListeners) {
// framework.getConnectionStateListenable().addListener(listener);
// }
return framework;
}
代码示例来源:origin: io.fabric8/fabric-zookeeper
/**
* Builds a {@link org.apache.curator.framework.CuratorFramework} from the specified {@link java.util.Map<String, ?>}.
*/
private synchronized CuratorFramework buildCuratorFramework(CuratorConfig curatorConfig) {
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
.canBeReadOnly(true)
.ensembleProvider(new FixedEnsembleProvider(curatorConfig.getZookeeperUrl()))
.connectionTimeoutMs(curatorConfig.getZookeeperConnectionTimeOut())
.sessionTimeoutMs(curatorConfig.getZookeeperSessionTimeout())
.retryPolicy(new RetryNTimes(curatorConfig.getZookeeperRetryMax(), curatorConfig.getZookeeperRetryInterval()));
if (!Strings.isNullOrEmpty(curatorConfig.getZookeeperPassword())) {
String scheme = "digest";
byte[] auth = ("fabric:" + PasswordEncoder.decode(curatorConfig.getZookeeperPassword())).getBytes();
builder = builder.authorization(scheme, auth).aclProvider(aclProvider.get());
}
CuratorFramework framework = builder.build();
// ENTESB-2111: don't register SCR-bound ConnectionStateListeners here, rather
// invoke them once in State.stateChanged()
// for (ConnectionStateListener listener : connectionStateListeners) {
// framework.getConnectionStateListenable().addListener(listener);
// }
return framework;
}
代码示例来源:origin: org.apache.druid/druid-server
@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();
}
};
}
代码示例来源:origin: io.druid/druid-server
@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();
}
};
}
内容来源于网络,如有侵权,请联系作者删除!