本文整理匯總了Java中org.apache.curator.framework.imps.CuratorFrameworkState.LATENT屬性的典型用法代碼示例。如果您正苦於以下問題:Java CuratorFrameworkState.LATENT屬性的具體用法?Java CuratorFrameworkState.LATENT怎麽用?Java CuratorFrameworkState.LATENT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.curator.framework.imps.CuratorFrameworkState
的用法示例。
在下文中一共展示了CuratorFrameworkState.LATENT屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: register
@Override
public void register(String service, String version, String address) {
if(zkClient.getState() == CuratorFrameworkState.LATENT){
zkClient.start();
}
if (version == null || version == ""){
version ="1.0.0";
}
//創建臨時節點
try {
zkClient.create()
.creatingParentsIfNeeded()
.withMode(CreateMode.EPHEMERAL)
.forPath("/"+service+"/"+version+"/"+address);
} catch (Exception e) {
logger.error("register service address to zookeeper exception:{}",e);
throw new ThriftException("register service address to zookeeper exception:{}", e);
}
}
示例2: register
@Override
public void register(String service, String version, String address) {
if(curatorFramework.getState() == CuratorFrameworkState.LATENT){
curatorFramework.start();
}
if (version == null || version == ""){
version = ThriftConstant.DEFAULT_VERSION;
}
//創建臨時節點
try {
String path = "/"+service+"/"+version+"/"+address;
logger.info("register: {}", path);
curatorFramework.create()
.creatingParentsIfNeeded()
.withMode(CreateMode.EPHEMERAL_SEQUENTIAL)
.forPath(path);
} catch (Exception e) {
logger.error("register service address to zookeeper exception:{}",e);
throw new ThriftException("register service address to zookeeper exception:{}", e);
}
}
示例3: afterPropertiesSet
@Override
public void afterPropertiesSet() throws Exception {
// 如果zk尚未啟動,則啟動
if (zkClient.getState() == CuratorFrameworkState.LATENT) {
zkClient.start();
}
buildPathChildrenCache(zkClient, getServicePath(), true);
cachedPath.start(StartMode.POST_INITIALIZED_EVENT);
countDownLatch.await();
}
示例4: getCuratorFramework
/**
* Getting the curator oject to start the zookeeper connection estabished
*
* @param curator
* @return curator object
*/
public static CuratorFramework getCuratorFramework(CuratorFramework curator) {
if (curator.getState() == CuratorFrameworkState.LATENT) {
curator.start();
try {
curator.blockUntilConnected();
} catch (InterruptedException e) {
// Ignore
log.error("error while setting curator framework :" + e.getMessage());
}
}
return curator;
}
示例5: init
/** Initializes this IP Finder by creating the appropriate Curator objects. */
private void init() {
if (!initGuard.compareAndSet(false, true))
return;
String sysPropZkConnString = System.getProperty(PROP_ZK_CONNECTION_STRING);
if (sysPropZkConnString != null && sysPropZkConnString.trim().length() > 0)
zkConnectionString = sysPropZkConnString;
if (log.isInfoEnabled())
log.info("Initializing ZooKeeper IP Finder.");
if (curator == null) {
A.notNullOrEmpty(zkConnectionString, String.format("ZooKeeper URL (or system property %s) cannot be null " +
"or empty if a CuratorFramework object is not provided explicitly", PROP_ZK_CONNECTION_STRING));
curator = CuratorFrameworkFactory.newClient(zkConnectionString, retryPolicy);
}
if (curator.getState() == CuratorFrameworkState.LATENT)
curator.start();
A.ensure(curator.getState() == CuratorFrameworkState.STARTED, "CuratorFramework can't be started.");
discovery = ServiceDiscoveryBuilder.builder(IgniteInstanceDetails.class)
.client(curator)
.basePath(basePath)
.serializer(new JsonInstanceSerializer<>(IgniteInstanceDetails.class))
.build();
}
示例6: isUninitialized
public boolean isUninitialized() {
return client.getState() == CuratorFrameworkState.LATENT;
}
示例7: start
@Override
public void start() throws Exception {
if (_curator.getState() == CuratorFrameworkState.LATENT) {
_curator.start();
}
}
示例8: isStopped
/**
* 判斷Zookeeper客戶端是是否已徑關閉
*
* @param client Zookeeper客戶端
* @return 是否已徑關閉
*/
private boolean isStopped(final CuratorFramework client) {
return client.getState() == CuratorFrameworkState.STOPPED || client.getState() == CuratorFrameworkState.LATENT;
}