本文整理汇总了Java中org.apache.zookeeper.Watcher.Event.KeeperState.SyncConnected方法的典型用法代码示例。如果您正苦于以下问题:Java KeeperState.SyncConnected方法的具体用法?Java KeeperState.SyncConnected怎么用?Java KeeperState.SyncConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.Watcher.Event.KeeperState
的用法示例。
在下文中一共展示了KeeperState.SyncConnected方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: process
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
public void process(WatchedEvent event) {
if (event.getState() == KeeperState.SyncConnected) {
synchronized(this) {
connected = true;
notifyAll();
}
} else if (event.getState() == KeeperState.Disconnected) {
synchronized(this) {
connected = false;
notifyAll();
}
}
}
示例3: queueEvent
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
void queueEvent(String clientPath, int err,
Set<Watcher> materializedWatchers, EventType eventType) {
KeeperState sessionState = KeeperState.SyncConnected;
if (KeeperException.Code.SESSIONEXPIRED.intValue() == err
|| KeeperException.Code.CONNECTIONLOSS.intValue() == err) {
sessionState = Event.KeeperState.Disconnected;
}
WatchedEvent event = new WatchedEvent(eventType, sessionState,
clientPath);
eventThread.queueEvent(event, materializedWatchers);
}
示例4: process
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
public void process(WatchedEvent event) {
LOG.info("Event:" + event.getState() + " " + event.getType() + " " + event.getPath());
if (event.getState() == KeeperState.SyncConnected
&& startSignal != null && startSignal.getCount() > 0)
{
startSignal.countDown();
}
}
示例5: process
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
@Override
public void process(WatchedEvent event) {
// TODO Auto-generated method stub
System.out.println("Receive Watcher Event:" + event);
if (KeeperState.SyncConnected == event.getState()) {
countDownLatch.countDown();
}
}
示例6: 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));
}
示例7: process
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
public void process(WatchedEvent event) {
LOG.info(name + " event:" + event.getState() + " "
+ event.getType() + " " + event.getPath());
if (event.getState() == KeeperState.SyncConnected
&& startSignal != null && startSignal.getCount() > 0)
{
startSignal.countDown();
}
}
示例8: process
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
public void process(WatchedEvent event) {
LOG.info("Event:" + event.getState() + " " + event.getType() + " "
+ event.getPath());
if (event.getState() == KeeperState.SyncConnected) {
if (startSignal != null && startSignal.getCount() > 0) {
LOG.info("startsignal.countDown()");
startSignal.countDown();
} else {
LOG.warn("startsignal " + startSignal);
}
}
}
示例9: process
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
public void process(WatchedEvent event) {
if(event.getState()==KeeperState.SyncConnected){
synchronized(this){
notifyAll();
}
}
}
示例10: isConnected
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
@Override
public boolean isConnected() {
return _currentState == KeeperState.SyncConnected;
}
示例11: isConnected
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
public boolean isConnected() {
return state == KeeperState.SyncConnected;
}
示例12: process
import org.apache.zookeeper.Watcher.Event.KeeperState; //导入方法依赖的package包/类
public void process(WatchedEvent event) {
if (event.getState() == KeeperState.SyncConnected) {
clientConnected.countDown();
}
}