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


Java StatPersisted.setEphemeralOwner方法代码示例

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


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

示例1: convertStat

import org.apache.zookeeper.data.StatPersisted; //导入方法依赖的package包/类
/**
 * convert the old stat to new stat
 * @param oldStat the old stat
 * @return the new stat
 */
private StatPersisted convertStat(StatPersistedV1 oldStat) {
    StatPersisted stat = new StatPersisted();
    stat.setAversion(oldStat.getAversion());
    stat.setCtime(oldStat.getCtime());
    stat.setCversion(oldStat.getCversion());
    stat.setCzxid(oldStat.getCzxid());
    stat.setEphemeralOwner(oldStat.getEphemeralOwner());
    stat.setMtime(oldStat.getMtime());
    stat.setMzxid(oldStat.getMzxid());
    stat.setVersion(oldStat.getVersion());
    return stat;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:18,代码来源:UpgradeSnapShotV1.java

示例2: copyStatPersisted

import org.apache.zookeeper.data.StatPersisted; //导入方法依赖的package包/类
static public void copyStatPersisted(StatPersisted from, StatPersisted to) {
    to.setAversion(from.getAversion());
    to.setCtime(from.getCtime());
    to.setCversion(from.getCversion());
    to.setCzxid(from.getCzxid());
    to.setMtime(from.getMtime());
    to.setMzxid(from.getMzxid());
    to.setPzxid(from.getPzxid());
    to.setVersion(from.getVersion());
    to.setEphemeralOwner(from.getEphemeralOwner());
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:12,代码来源:DataTree.java

示例3: pRequest2TxnCreate

import org.apache.zookeeper.data.StatPersisted; //导入方法依赖的package包/类
private void pRequest2TxnCreate(int type, Request request, Record record, boolean deserialize) throws IOException, KeeperException {
    if (deserialize) {
        ByteBufferInputStream.byteBuffer2Record(request.request, record);
    }

    int flags;
    String path;
    List<ACL> acl;
    byte[] data;
    long ttl;
    if (type == OpCode.createTTL) {
        CreateTTLRequest createTtlRequest = (CreateTTLRequest)record;
        flags = createTtlRequest.getFlags();
        path = createTtlRequest.getPath();
        acl = createTtlRequest.getAcl();
        data = createTtlRequest.getData();
        ttl = createTtlRequest.getTtl();
    } else {
        CreateRequest createRequest = (CreateRequest)record;
        flags = createRequest.getFlags();
        path = createRequest.getPath();
        acl = createRequest.getAcl();
        data = createRequest.getData();
        ttl = -1;
    }
    CreateMode createMode = CreateMode.fromFlag(flags);
    validateCreateRequest(path, createMode, request, ttl);
    String parentPath = validatePathForCreate(path, request.sessionId);

    List<ACL> listACL = fixupACL(path, request.authInfo, acl);
    ChangeRecord parentRecord = getRecordForPath(parentPath);

    checkACL(zks, request.cnxn, parentRecord.acl, ZooDefs.Perms.CREATE, request.authInfo, path, listACL);
    int parentCVersion = parentRecord.stat.getCversion();
    if (createMode.isSequential()) {
        path = path + String.format(Locale.ENGLISH, "%010d", parentCVersion);
    }
    validatePath(path, request.sessionId);
    try {
        if (getRecordForPath(path) != null) {
            throw new KeeperException.NodeExistsException(path);
        }
    } catch (KeeperException.NoNodeException e) {
        // ignore this one
    }
    boolean ephemeralParent = EphemeralType.get(parentRecord.stat.getEphemeralOwner()) == EphemeralType.NORMAL;
    if (ephemeralParent) {
        throw new KeeperException.NoChildrenForEphemeralsException(path);
    }
    int newCversion = parentRecord.stat.getCversion()+1;
    if (type == OpCode.createContainer) {
        request.setTxn(new CreateContainerTxn(path, data, listACL, newCversion));
    } else if (type == OpCode.createTTL) {
        request.setTxn(new CreateTTLTxn(path, data, listACL, newCversion, ttl));
    } else {
        request.setTxn(new CreateTxn(path, data, listACL, createMode.isEphemeral(),
                newCversion));
    }
    StatPersisted s = new StatPersisted();
    if (createMode.isEphemeral()) {
        s.setEphemeralOwner(request.sessionId);
    }
    parentRecord = parentRecord.duplicate(request.getHdr().getZxid());
    parentRecord.childCount++;
    parentRecord.stat.setCversion(newCversion);
    addChangeRecord(parentRecord);
    addChangeRecord(new ChangeRecord(request.getHdr().getZxid(), path, s, 0, listACL));
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:69,代码来源:PrepRequestProcessor.java


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