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


Java OpCode.setWatches方法代码示例

本文整理汇总了Java中org.apache.zookeeper.ZooDefs.OpCode.setWatches方法的典型用法代码示例。如果您正苦于以下问题:Java OpCode.setWatches方法的具体用法?Java OpCode.setWatches怎么用?Java OpCode.setWatches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.zookeeper.ZooDefs.OpCode的用法示例。


在下文中一共展示了OpCode.setWatches方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isValid

import org.apache.zookeeper.ZooDefs.OpCode; //导入方法依赖的package包/类
/**
 * is the packet type a valid packet in zookeeper
 * 
 * @param type
 *                the type of the packet
 * @return true if a valid packet, false if not
 */
static boolean isValid(int type) {
    // make sure this is always synchronized with Zoodefs!!
    switch (type) {
    case OpCode.notification:
        return false;
    case OpCode.create:
    case OpCode.delete:
    case OpCode.createSession:
    case OpCode.exists:
    case OpCode.getData:
    case OpCode.setData:
    case OpCode.sync:
    case OpCode.getACL:
    case OpCode.setACL:
    case OpCode.getChildren:
    case OpCode.getChildren2:
    case OpCode.ping:
    case OpCode.closeSession:
    case OpCode.setWatches:
        return true;
    default:
        return false;
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:32,代码来源:Request.java

示例2: isValid

import org.apache.zookeeper.ZooDefs.OpCode; //导入方法依赖的package包/类
/**
 * is the packet type a valid packet in zookeeper
 * 
 * @param type
 *                the type of the packet
 * @return true if a valid packet, false if not
 */
static boolean isValid(int type) {
    // make sure this is always synchronized with Zoodefs!!
    switch (type) {
    case OpCode.notification:
        return false;
    case OpCode.create:
    case OpCode.delete:
    case OpCode.createSession:
    case OpCode.exists:
    case OpCode.getData:
    case OpCode.check:
    case OpCode.multi:
    case OpCode.setData:
    case OpCode.sync:
    case OpCode.getACL:
    case OpCode.setACL:
    case OpCode.getChildren:
    case OpCode.getChildren2:
    case OpCode.ping:
    case OpCode.closeSession:
    case OpCode.setWatches:
        return true;
    default:
        return false;
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:34,代码来源:Request.java

示例3: isValid

import org.apache.zookeeper.ZooDefs.OpCode; //导入方法依赖的package包/类
/**
 * is the packet type a valid packet in zookeeper
 *
 * @param type
 *                the type of the packet
 * @return true if a valid packet, false if not
 */
static boolean isValid(int type) {
    // make sure this is always synchronized with Zoodefs!!
    switch (type) {
    case OpCode.notification:
        return false;
    case OpCode.check:
    case OpCode.closeSession:
    case OpCode.create:
    case OpCode.create2:
    case OpCode.createTTL:
    case OpCode.createContainer:
    case OpCode.createSession:
    case OpCode.delete:
    case OpCode.deleteContainer:
    case OpCode.exists:
    case OpCode.getACL:
    case OpCode.getChildren:
    case OpCode.getChildren2:
    case OpCode.getData:
    case OpCode.multi:
    case OpCode.ping:
    case OpCode.reconfig:
    case OpCode.setACL:
    case OpCode.setData:
    case OpCode.setWatches:
    case OpCode.sync:
    case OpCode.checkWatches:
    case OpCode.removeWatches:
        return true;
    default:
        return false;
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:41,代码来源:Request.java

示例4: isValid

import org.apache.zookeeper.ZooDefs.OpCode; //导入方法依赖的package包/类
/**
 * is the packet type a valid packet in zookeeper
 *
 * @param type
 *                the type of the packet
 * @return true if a valid packet, false if not
 */
static boolean isValid(int type) {
    // make sure this is always synchronized with Zoodefs!!
    switch (type) {
    case OpCode.notification:
        return false;
    case OpCode.check:
    case OpCode.closeSession:
    case OpCode.create:
    case OpCode.create2:
    case OpCode.createContainer:
    case OpCode.createSession:
    case OpCode.delete:
    case OpCode.deleteContainer:
    case OpCode.exists:
    case OpCode.getACL:
    case OpCode.getChildren:
    case OpCode.getChildren2:
    case OpCode.getData:
    case OpCode.multi:
    case OpCode.ping:
    case OpCode.reconfig:
    case OpCode.setACL:
    case OpCode.setData:
    case OpCode.setWatches:
    case OpCode.sync:
    case OpCode.checkWatches:
    case OpCode.removeWatches:
        return true;
    default:
        return false;
    }
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:40,代码来源:Request.java

示例5: op2String

import org.apache.zookeeper.ZooDefs.OpCode; //导入方法依赖的package包/类
static String op2String(int op) {
    switch (op) {
    case OpCode.notification:
        return "notification";
    case OpCode.create:
        return "create";
    case OpCode.setWatches:
        return "setWatches";
    case OpCode.delete:
        return "delete";
    case OpCode.exists:
        return "exists";
    case OpCode.getData:
        return "getData";
    case OpCode.check:
        return "check";
    case OpCode.multi:
        return "multi";
    case OpCode.setData:
        return "setData";
    case OpCode.sync:
          return "sync:";
    case OpCode.getACL:
        return "getACL";
    case OpCode.setACL:
        return "setACL";
    case OpCode.getChildren:
        return "getChildren";
    case OpCode.getChildren2:
        return "getChildren2";
    case OpCode.ping:
        return "ping";
    case OpCode.createSession:
        return "createSession";
    case OpCode.closeSession:
        return "closeSession";
    case OpCode.error:
        return "error";
    default:
        return "unknown " + op;
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:43,代码来源:Request.java

示例6: toString

import org.apache.zookeeper.ZooDefs.OpCode; //导入方法依赖的package包/类
@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("sessionid:0x").append(Long.toHexString(sessionId))
        .append(" type:").append(op2String(type))
        .append(" cxid:0x").append(Long.toHexString(cxid))
        .append(" zxid:0x").append(Long.toHexString(hdr == null ?
                -2 : hdr.getZxid()))
        .append(" txntype:").append(hdr == null ?
                "unknown" : "" + hdr.getType());

    // best effort to print the path assoc with this request
    String path = "n/a";
    if (type != OpCode.createSession
            && type != OpCode.setWatches
            && type != OpCode.closeSession
            && request != null
            && request.remaining() >= 4)
    {
        try {
            // make sure we don't mess with request itself
            ByteBuffer rbuf = request.asReadOnlyBuffer();
            rbuf.clear();
            int pathLen = rbuf.getInt();
            // sanity check
            if (pathLen >= 0
                    && pathLen < 4096
                    && rbuf.remaining() >= pathLen)
            {
                byte b[] = new byte[pathLen];
                rbuf.get(b);
                path = new String(b);
            }
        } catch (Exception e) {
            // ignore - can't find the path, will output "n/a" instead
        }
    }
    sb.append(" reqpath:").append(path);

    return sb.toString();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:42,代码来源:Request.java

示例7: op2String

import org.apache.zookeeper.ZooDefs.OpCode; //导入方法依赖的package包/类
static String op2String(int op) {
    switch (op) {
    case OpCode.notification:
        return "notification";
    case OpCode.create:
        return "create";
    case OpCode.create2:
        return "create2";
    case OpCode.createTTL:
        return "createTtl";
    case OpCode.createContainer:
        return "createContainer";
    case OpCode.setWatches:
        return "setWatches";
    case OpCode.delete:
        return "delete";
    case OpCode.deleteContainer:
        return "deleteContainer";
    case OpCode.exists:
        return "exists";
    case OpCode.getData:
        return "getData";
    case OpCode.check:
        return "check";
    case OpCode.multi:
        return "multi";
    case OpCode.setData:
        return "setData";
    case OpCode.sync:
          return "sync:";
    case OpCode.getACL:
        return "getACL";
    case OpCode.setACL:
        return "setACL";
    case OpCode.getChildren:
        return "getChildren";
    case OpCode.getChildren2:
        return "getChildren2";
    case OpCode.ping:
        return "ping";
    case OpCode.createSession:
        return "createSession";
    case OpCode.closeSession:
        return "closeSession";
    case OpCode.error:
        return "error";
    case OpCode.reconfig:
       return "reconfig";
    case OpCode.checkWatches:
        return "checkWatches";
    case OpCode.removeWatches:
        return "removeWatches";
    default:
        return "unknown " + op;
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:57,代码来源:Request.java

示例8: primeConnection

import org.apache.zookeeper.ZooDefs.OpCode; //导入方法依赖的package包/类
/**
 * Setup session, previous watches, authentication.
 */
void primeConnection() throws IOException {
    LOG.info("Socket connection established, initiating session, client: {}, server: {}",
            clientCnxnSocket.getLocalSocketAddress(),
            clientCnxnSocket.getRemoteSocketAddress());
    isFirstConnect = false;
    long sessId = (seenRwServerBefore) ? sessionId : 0;
    ConnectRequest conReq = new ConnectRequest(0, lastZxid,
            sessionTimeout, sessId, sessionPasswd);
    // We add backwards since we are pushing into the front
    // Only send if there's a pending watch
    // TODO: here we have the only remaining use of zooKeeper in
    // this class. It's to be eliminated!
    if (!clientConfig.getBoolean(ZKClientConfig.DISABLE_AUTO_WATCH_RESET)) {
        List<String> dataWatches = zooKeeper.getDataWatches();
        List<String> existWatches = zooKeeper.getExistWatches();
        List<String> childWatches = zooKeeper.getChildWatches();
        if (!dataWatches.isEmpty()
                || !existWatches.isEmpty() || !childWatches.isEmpty()) {
            Iterator<String> dataWatchesIter = prependChroot(dataWatches).iterator();
            Iterator<String> existWatchesIter = prependChroot(existWatches).iterator();
            Iterator<String> childWatchesIter = prependChroot(childWatches).iterator();
            long setWatchesLastZxid = lastZxid;

            while (dataWatchesIter.hasNext()
                   || existWatchesIter.hasNext() || childWatchesIter.hasNext()) {
                List<String> dataWatchesBatch = new ArrayList<String>();
                List<String> existWatchesBatch = new ArrayList<String>();
                List<String> childWatchesBatch = new ArrayList<String>();
                int batchLength = 0;

                // Note, we may exceed our max length by a bit when we add the last
                // watch in the batch. This isn't ideal, but it makes the code simpler.
                while (batchLength < SET_WATCHES_MAX_LENGTH) {
                    final String watch;
                    if (dataWatchesIter.hasNext()) {
                        watch = dataWatchesIter.next();
                        dataWatchesBatch.add(watch);
                    } else if (existWatchesIter.hasNext()) {
                        watch = existWatchesIter.next();
                        existWatchesBatch.add(watch);
                    } else if (childWatchesIter.hasNext()) {
                        watch = childWatchesIter.next();
                        childWatchesBatch.add(watch);
                    } else {
                        break;
                    }
                    batchLength += watch.length();
                }

                SetWatches sw = new SetWatches(setWatchesLastZxid,
                                               dataWatchesBatch,
                                               existWatchesBatch,
                                               childWatchesBatch);
                RequestHeader header = new RequestHeader(-8, OpCode.setWatches);
                Packet packet = new Packet(header, new ReplyHeader(), sw, null, null);
                outgoingQueue.addFirst(packet);
            }
        }
    }

    for (AuthData id : authInfo) {
        outgoingQueue.addFirst(new Packet(new RequestHeader(-4,
                OpCode.auth), null, new AuthPacket(0, id.scheme,
                id.data), null, null));
    }
    outgoingQueue.addFirst(new Packet(null, null, conReq,
            null, null, readOnly));
    clientCnxnSocket.connectionPrimed();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session establishment request sent on "
                + clientCnxnSocket.getRemoteSocketAddress());
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:77,代码来源:ClientCnxn.java

示例9: op2String

import org.apache.zookeeper.ZooDefs.OpCode; //导入方法依赖的package包/类
static String op2String(int op) {
    switch (op) {
    case OpCode.notification:
        return "notification";
    case OpCode.create:
        return "create";
    case OpCode.create2:
        return "create2";
    case OpCode.createContainer:
        return "createContainer";
    case OpCode.setWatches:
        return "setWatches";
    case OpCode.delete:
        return "delete";
    case OpCode.deleteContainer:
        return "deleteContainer";
    case OpCode.exists:
        return "exists";
    case OpCode.getData:
        return "getData";
    case OpCode.check:
        return "check";
    case OpCode.multi:
        return "multi";
    case OpCode.setData:
        return "setData";
    case OpCode.sync:
          return "sync:";
    case OpCode.getACL:
        return "getACL";
    case OpCode.setACL:
        return "setACL";
    case OpCode.getChildren:
        return "getChildren";
    case OpCode.getChildren2:
        return "getChildren2";
    case OpCode.ping:
        return "ping";
    case OpCode.createSession:
        return "createSession";
    case OpCode.closeSession:
        return "closeSession";
    case OpCode.error:
        return "error";
    case OpCode.reconfig:
       return "reconfig";
    case OpCode.checkWatches:
        return "checkWatches";
    case OpCode.removeWatches:
        return "removeWatches";
    default:
        return "unknown " + op;
    }
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:55,代码来源:Request.java

示例10: primeConnection

import org.apache.zookeeper.ZooDefs.OpCode; //导入方法依赖的package包/类
/**
 * Setup session, previous watches, authentication.
 */
void primeConnection() throws IOException {
    LOG.info("Socket connection established, initiating session, client: {}, server: {}",
            clientCnxnSocket.getLocalSocketAddress(),
            clientCnxnSocket.getRemoteSocketAddress());
    isFirstConnect = false;
    long sessId = (seenRwServerBefore) ? sessionId : 0;
    ConnectRequest conReq = new ConnectRequest(0, lastZxid,
            sessionTimeout, sessId, sessionPasswd);
    // We add backwards since we are pushing into the front
    // Only send if there's a pending watch
    // TODO: here we have the only remaining use of zooKeeper in
    // this class. It's to be eliminated!
    if (!disableAutoWatchReset) {
        List<String> dataWatches = zooKeeper.getDataWatches();
        List<String> existWatches = zooKeeper.getExistWatches();
        List<String> childWatches = zooKeeper.getChildWatches();
        if (!dataWatches.isEmpty()
                || !existWatches.isEmpty() || !childWatches.isEmpty()) {
            Iterator<String> dataWatchesIter = prependChroot(dataWatches).iterator();
            Iterator<String> existWatchesIter = prependChroot(existWatches).iterator();
            Iterator<String> childWatchesIter = prependChroot(childWatches).iterator();
            long setWatchesLastZxid = lastZxid;

            while (dataWatchesIter.hasNext()
                   || existWatchesIter.hasNext() || childWatchesIter.hasNext()) {
                List<String> dataWatchesBatch = new ArrayList<String>();
                List<String> existWatchesBatch = new ArrayList<String>();
                List<String> childWatchesBatch = new ArrayList<String>();
                int batchLength = 0;

                // Note, we may exceed our max length by a bit when we add the last
                // watch in the batch. This isn't ideal, but it makes the code simpler.
                while (batchLength < SET_WATCHES_MAX_LENGTH) {
                    final String watch;
                    if (dataWatchesIter.hasNext()) {
                        watch = dataWatchesIter.next();
                        dataWatchesBatch.add(watch);
                    } else if (existWatchesIter.hasNext()) {
                        watch = existWatchesIter.next();
                        existWatchesBatch.add(watch);
                    } else if (childWatchesIter.hasNext()) {
                        watch = childWatchesIter.next();
                        childWatchesBatch.add(watch);
                    } else {
                        break;
                    }
                    batchLength += watch.length();
                }

                SetWatches sw = new SetWatches(setWatchesLastZxid,
                                               dataWatchesBatch,
                                               existWatchesBatch,
                                               childWatchesBatch);
                RequestHeader header = new RequestHeader(-8, OpCode.setWatches);
                Packet packet = new Packet(header, new ReplyHeader(), sw, null, null);
                outgoingQueue.addFirst(packet);
            }
        }
    }

    for (AuthData id : authInfo) {
        outgoingQueue.addFirst(new Packet(new RequestHeader(-4,
                OpCode.auth), null, new AuthPacket(0, id.scheme,
                id.data), null, null));
    }
    outgoingQueue.addFirst(new Packet(null, null, conReq,
            null, null, readOnly));
    clientCnxnSocket.connectionPrimed();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session establishment request sent on "
                + clientCnxnSocket.getRemoteSocketAddress());
    }
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:77,代码来源:ClientCnxn.java


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