本文整理了Java中org.apache.helix.manager.zk.ZKHelixManager.isConnected()
方法的一些代码示例,展示了ZKHelixManager.isConnected()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKHelixManager.isConnected()
方法的具体详情如下:
包路径:org.apache.helix.manager.zk.ZKHelixManager
类名称:ZKHelixManager
方法名:isConnected
暂无
代码示例来源:origin: apache/helix
if (!isConnected()) {
LOG.warn(String.format("%s HelixManager is not connected", warnLogPrefix));
return false;
代码示例来源:origin: org.apache.helix/helix-core
/**
* Check if HelixManager is connected, if it is not connected,
* wait for the specified timeout and check again before return.
*
* @param timeout
*/
void checkConnected(long timeout) {
if (_zkclient == null || _zkclient.isClosed()) {
throw new HelixException(
"HelixManager (ZkClient) is not connected. Call HelixManager#connect()");
}
boolean isConnected = isConnected();
if (!isConnected && timeout > 0) {
LOG.warn(
"zkClient to " + _zkAddress + " is not connected, wait for " + _waitForConnectedTimeout
+ "ms.");
isConnected = _zkclient.waitUntilConnected(_waitForConnectedTimeout, TimeUnit.MILLISECONDS);
}
if (!isConnected) {
LOG.error("zkClient is not connected after waiting " + timeout + "ms."
+ ", clusterName: " + _clusterName + ", zkAddress: " + _zkAddress);
throw new HelixException(
"HelixManager is not connected within retry timeout for cluster " + _clusterName);
}
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public boolean isLeader() {
if (_instanceType != InstanceType.CONTROLLER
&& _instanceType != InstanceType.CONTROLLER_PARTICIPANT) {
return false;
}
if (!isConnected()) {
return false;
}
try {
LiveInstance leader = _dataAccessor.getProperty(_keyBuilder.controllerLeader());
if (leader != null) {
String leaderName = leader.getInstanceName();
String sessionId = leader.getSessionId();
if (leaderName != null && leaderName.equals(_instanceName) && sessionId != null
&& sessionId.equals(_sessionId)) {
return true;
}
}
} catch (Exception e) {
// log
}
return false;
}
代码示例来源:origin: apache/helix
/**
* Check if HelixManager is connected, if it is not connected,
* wait for the specified timeout and check again before return.
*
* @param timeout
*/
void checkConnected(long timeout) {
if (_zkclient == null || _zkclient.isClosed()) {
throw new HelixException(
"HelixManager (ZkClient) is not connected. Call HelixManager#connect()");
}
boolean isConnected = isConnected();
if (!isConnected && timeout > 0) {
LOG.warn(
"zkClient to " + _zkAddress + " is not connected, wait for " + _waitForConnectedTimeout
+ "ms.");
isConnected = _zkclient.waitUntilConnected(_waitForConnectedTimeout, TimeUnit.MILLISECONDS);
}
if (!isConnected) {
LOG.error("zkClient is not connected after waiting " + timeout + "ms."
+ ", clusterName: " + _clusterName + ", zkAddress: " + _zkAddress);
throw new HelixException(
"HelixManager is not connected within retry timeout for cluster " + _clusterName);
}
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void connect() throws Exception {
LOG.info("ClusterManager.connect()");
if (isConnected()) {
LOG.warn("Cluster manager: " + _instanceName + " for cluster: " + _clusterName
+ " already connected. skip connect");
代码示例来源:origin: apache/helix
@Override
public void connect() throws Exception {
LOG.info("ClusterManager.connect()");
if (isConnected()) {
LOG.warn("Cluster manager: " + _instanceName + " for cluster: " + _clusterName
+ " already connected. skip connect");
代码示例来源:origin: apache/helix
AssertJUnit.assertTrue(admin.isConnected());
AssertJUnit.assertFalse(admin.isConnected());
代码示例来源:origin: apache/helix
Assert.assertTrue(controller._zkclient
.waitUntilConnected(HelixZkClient.DEFAULT_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS));
Assert.assertTrue(controller.isConnected());
Assert.assertFalse(controller.isConnected());
代码示例来源:origin: apache/helix
AssertJUnit.assertTrue(controller.isConnected());
controller.connect();
AssertJUnit.assertTrue(controller.isConnected());
AssertJUnit.assertFalse(controller.isConnected());
内容来源于网络,如有侵权,请联系作者删除!