本文整理汇总了Java中org.apache.zookeeper.Watcher.Event.KeeperState.ConnectedReadOnly方法的典型用法代码示例。如果您正苦于以下问题:Java KeeperState.ConnectedReadOnly方法的具体用法?Java KeeperState.ConnectedReadOnly怎么用?Java KeeperState.ConnectedReadOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.Watcher.Event.KeeperState
的用法示例。
在下文中一共展示了KeeperState.ConnectedReadOnly方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
synchronized public void process(WatchedEvent event) {
KeeperState state = event.getState();
if (state == KeeperState.SyncConnected) {
connected = true;
syncConnected = true;
readOnlyConnected = false;
} else if (state == KeeperState.ConnectedReadOnly) {
connected = true;
syncConnected = false;
readOnlyConnected = true;
} else {
connected = false;
syncConnected = false;
readOnlyConnected = false;
}
notifyAll();
if (connected) {
clientConnected.countDown();
}
}
示例2: process
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
@Override
synchronized public void process(WatchedEvent event) {
if (event.getState() == KeeperState.SyncConnected ||
event.getState() == KeeperState.ConnectedReadOnly) {
connected = true;
notifyAll();
clientConnected.countDown();
} else {
connected = false;
notifyAll();
}
}
示例3: onConnected
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
/**
* Callback invoked by the ClientCnxnSocket once a connection has been
* established.
*
* @param _negotiatedSessionTimeout
* @param _sessionId
* @param _sessionPasswd
* @param isRO
* @throws IOException
*/
void onConnected(int _negotiatedSessionTimeout, long _sessionId,
byte[] _sessionPasswd, boolean isRO) throws IOException {
negotiatedSessionTimeout = _negotiatedSessionTimeout;
if (negotiatedSessionTimeout <= 0) {
state = States.CLOSED;
eventThread.queueEvent(new WatchedEvent(
Watcher.Event.EventType.None,
Watcher.Event.KeeperState.Expired, null));
eventThread.queueEventOfDeath();
String warnInfo;
warnInfo = "Unable to reconnect to ZooKeeper service, session 0x"
+ Long.toHexString(sessionId) + " has expired";
LOG.warn(warnInfo);
throw new SessionExpiredException(warnInfo);
}
if (!readOnly && isRO) {
LOG.error("Read/write client got connected to read-only server");
}
readTimeout = negotiatedSessionTimeout * 2 / 3;
connectTimeout = negotiatedSessionTimeout / hostProvider.size();
hostProvider.onConnected();
sessionId = _sessionId;
sessionPasswd = _sessionPasswd;
state = (isRO) ?
States.CONNECTEDREADONLY : States.CONNECTED;
seenRwServerBefore |= !isRO;
LOG.info("Session establishment complete on server "
+ clientCnxnSocket.getRemoteSocketAddress()
+ ", sessionid = 0x" + Long.toHexString(sessionId)
+ ", negotiated timeout = " + negotiatedSessionTimeout
+ (isRO ? " (READ-ONLY mode)" : ""));
KeeperState eventState = (isRO) ?
KeeperState.ConnectedReadOnly : KeeperState.SyncConnected;
eventThread.queueEvent(new WatchedEvent(
Watcher.Event.EventType.None,
eventState, null));
}
示例4: process
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
synchronized public void process(WatchedEvent event) {
if (event.getState() == KeeperState.SyncConnected ||
event.getState() == KeeperState.ConnectedReadOnly) {
connected = true;
notifyAll();
clientConnected.countDown();
} else {
connected = false;
notifyAll();
}
}
示例5: isAvailable
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
public boolean isAvailable() {
if(zookeeper == null) return false;
return _currentState == KeeperState.SyncConnected
|| _currentState == KeeperState.ConnectedReadOnly;
}