当前位置: 首页>>代码示例>>Java>>正文


Java KeeperState.ConnectedReadOnly方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:22,代码来源:ClientBase.java

示例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();
    }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:13,代码来源:ClientBaseWithFixes.java

示例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));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:50,代码来源:ClientCnxn.java

示例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();
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:12,代码来源:ClientBase.java

示例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;
}
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:6,代码来源:ZkClient.java


注:本文中的org.apache.zookeeper.Watcher.Event.KeeperState.ConnectedReadOnly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。