Java 类org.apache.zookeeper.proto.Create2Response 实例源码

项目:https-github.com-apache-zookeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of create with ttl.
 *
 * @see #create(String, byte[], List, CreateMode, Stat, long)
 */
public void create(final String path, byte data[], List<ACL> acl,
        CreateMode createMode, Create2Callback cb, Object ctx, long ttl)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());
    EphemeralType.validateTTL(createMode, ttl);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    setCreateHeader(createMode, h);
    ReplyHeader r = new ReplyHeader();
    Create2Response response = new Create2Response();
    Record record = makeCreateRecord(createMode, serverPath, data, acl, ttl);
    cnxn.queuePacket(h, r, record, response, cb, clientPath,
            serverPath, ctx, null);
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of create.
 *
 * @see #create(String, byte[], List, CreateMode, Stat)
 */
public void create(final String path, byte data[], List<ACL> acl,
        CreateMode createMode, Create2Callback cb, Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(createMode.isContainer() ? ZooDefs.OpCode.createContainer : ZooDefs.OpCode.create2);
    CreateRequest request = new CreateRequest();
    Create2Response response = new Create2Response();
    ReplyHeader r = new ReplyHeader();
    request.setData(data);
    request.setFlags(createMode.toFlag());
    request.setPath(serverPath);
    request.setAcl(acl);
    cnxn.queuePacket(h, r, request, response, cb, clientPath,
            serverPath, ctx, null);
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of create.
 *
 * @see #create(String, byte[], List, CreateMode, Stat)
 */
public void create(final String path, byte data[], List<ACL> acl,
        CreateMode createMode, Create2Callback cb, Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(createMode.isContainer() ? ZooDefs.OpCode.createContainer : ZooDefs.OpCode.create2);
    CreateRequest request = new CreateRequest();
    Create2Response response = new Create2Response();
    ReplyHeader r = new ReplyHeader();
    request.setData(data);
    request.setFlags(createMode.toFlag());
    request.setPath(serverPath);
    request.setAcl(acl);
    cnxn.queuePacket(h, r, request, response, cb, clientPath,
            serverPath, ctx, null);
}
项目:https-github.com-apache-zookeeper    文件:MultiResponse.java   
@Override
public void serialize(OutputArchive archive, String tag) throws IOException {
    archive.startRecord(this, tag);

    for (OpResult result : results) {
        int err = result.getType() == ZooDefs.OpCode.error ? ((OpResult.ErrorResult)result).getErr() : 0;

        new MultiHeader(result.getType(), false, err).serialize(archive, tag);

        switch (result.getType()) {
            case ZooDefs.OpCode.create:
                new CreateResponse(((OpResult.CreateResult) result).getPath()).serialize(archive, tag);
                break;
            case ZooDefs.OpCode.create2:
                OpResult.CreateResult createResult = (OpResult.CreateResult) result;
                new Create2Response(createResult.getPath(),
                        createResult.getStat()).serialize(archive, tag);
                break;
            case ZooDefs.OpCode.delete:
            case ZooDefs.OpCode.check:
                break;
            case ZooDefs.OpCode.setData:
                new SetDataResponse(((OpResult.SetDataResult) result).getStat()).serialize(archive, tag);
                break;
            case ZooDefs.OpCode.error:
                new ErrorResponse(((OpResult.ErrorResult) result).getErr()).serialize(archive, tag);
                break;
            default:
                throw new IOException("Invalid type " + result.getType() + " in MultiResponse");
        }
    }
    new MultiHeader(-1, true, -1).serialize(archive, tag);
    archive.endRecord(this, tag);
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeper.java   
/**
 * same as {@link #create(String, byte[], List, CreateMode, Stat)} but
 * allows for specifying a TTL when mode is {@link CreateMode#PERSISTENT_WITH_TTL}
 * or {@link CreateMode#PERSISTENT_SEQUENTIAL_WITH_TTL}. If the znode has not been modified
 * within the given TTL, it will be deleted once it has no children. The TTL unit is
 * milliseconds and must be greater than 0 and less than or equal to
 * {@link EphemeralType#MAX_TTL}.
 */
public String create(final String path, byte data[], List<ACL> acl,
        CreateMode createMode, Stat stat, long ttl)
        throws KeeperException, InterruptedException {
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());
    EphemeralType.validateTTL(createMode, ttl);
    validateACL(acl);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    setCreateHeader(createMode, h);
    Create2Response response = new Create2Response();
    Record record = makeCreateRecord(createMode, serverPath, data, acl, ttl);
    ReplyHeader r = cnxn.submitRequest(h, record, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    if (stat != null) {
        DataTree.copyStat(response.getStat(), stat);
    }
    if (cnxn.chrootPath == null) {
        return response.getPath();
    } else {
        return response.getPath().substring(cnxn.chrootPath.length());
    }
}
项目:SecureKeeper    文件:MultiResponse.java   
@Override
public void serialize(OutputArchive archive, String tag) throws IOException {
    archive.startRecord(this, tag);

    for (OpResult result : results) {
        int err = result.getType() == ZooDefs.OpCode.error ? ((OpResult.ErrorResult)result).getErr() : 0;

        new MultiHeader(result.getType(), false, err).serialize(archive, tag);

        switch (result.getType()) {
            case ZooDefs.OpCode.create:
                new CreateResponse(((OpResult.CreateResult) result).getPath()).serialize(archive, tag);
                break;
            case ZooDefs.OpCode.create2:
                OpResult.CreateResult createResult = (OpResult.CreateResult) result;
                new Create2Response(createResult.getPath(),
                        createResult.getStat()).serialize(archive, tag);
                break;
            case ZooDefs.OpCode.delete:
            case ZooDefs.OpCode.check:
                break;
            case ZooDefs.OpCode.setData:
                new SetDataResponse(((OpResult.SetDataResult) result).getStat()).serialize(archive, tag);
                break;
            case ZooDefs.OpCode.error:
                new ErrorResponse(((OpResult.ErrorResult) result).getErr()).serialize(archive, tag);
                break;
            default:
                throw new IOException("Invalid type " + result.getType() + " in MultiResponse");
        }
    }
    new MultiHeader(-1, true, -1).serialize(archive, tag);
    archive.endRecord(this, tag);
}
项目:SecureKeeper    文件:MultiResponse.java   
@Override
public void serialize(OutputArchive archive, String tag) throws IOException {
    archive.startRecord(this, tag);

    for (OpResult result : results) {
        int err = result.getType() == ZooDefs.OpCode.error ? ((OpResult.ErrorResult)result).getErr() : 0;

        new MultiHeader(result.getType(), false, err).serialize(archive, tag);

        switch (result.getType()) {
            case ZooDefs.OpCode.create:
                new CreateResponse(((OpResult.CreateResult) result).getPath()).serialize(archive, tag);
                break;
            case ZooDefs.OpCode.create2:
                OpResult.CreateResult createResult = (OpResult.CreateResult) result;
                new Create2Response(createResult.getPath(),
                        createResult.getStat()).serialize(archive, tag);
                break;
            case ZooDefs.OpCode.delete:
            case ZooDefs.OpCode.check:
                break;
            case ZooDefs.OpCode.setData:
                new SetDataResponse(((OpResult.SetDataResult) result).getStat()).serialize(archive, tag);
                break;
            case ZooDefs.OpCode.error:
                new ErrorResponse(((OpResult.ErrorResult) result).getErr()).serialize(archive, tag);
                break;
            default:
                throw new IOException("Invalid type " + result.getType() + " in MultiResponse");
        }
    }
    new MultiHeader(-1, true, -1).serialize(archive, tag);
    archive.endRecord(this, tag);
}
项目:https-github.com-apache-zookeeper    文件:MultiResponse.java   
@Override
public void deserialize(InputArchive archive, String tag) throws IOException {
    results = new ArrayList<OpResult>();

    archive.startRecord(tag);
    MultiHeader h = new MultiHeader();
    h.deserialize(archive, tag);
    while (!h.getDone()) {
        switch (h.getType()) {
            case ZooDefs.OpCode.create:
                CreateResponse cr = new CreateResponse();
                cr.deserialize(archive, tag);
                results.add(new OpResult.CreateResult(cr.getPath()));
                break;

            case ZooDefs.OpCode.create2:
                Create2Response cr2 = new Create2Response();
                cr2.deserialize(archive, tag);
                results.add(new OpResult.CreateResult(cr2.getPath(), cr2.getStat()));
                break;

            case ZooDefs.OpCode.delete:
                results.add(new OpResult.DeleteResult());
                break;

            case ZooDefs.OpCode.setData:
                SetDataResponse sdr = new SetDataResponse();
                sdr.deserialize(archive, tag);
                results.add(new OpResult.SetDataResult(sdr.getStat()));
                break;

            case ZooDefs.OpCode.check:
                results.add(new OpResult.CheckResult());
                break;

            case ZooDefs.OpCode.error:
                //FIXME: need way to more cleanly serialize/deserialize exceptions
                ErrorResponse er = new ErrorResponse();
                er.deserialize(archive, tag);
                results.add(new OpResult.ErrorResult(er.getErr()));
                break;

            default:
                throw new IOException("Invalid type " + h.getType() + " in MultiResponse");
        }
        h.deserialize(archive, tag);
    }
    archive.endRecord(tag);
}
项目:SecureKeeper    文件:MultiResponse.java   
@Override
public void deserialize(InputArchive archive, String tag) throws IOException {
    results = new ArrayList<OpResult>();

    archive.startRecord(tag);
    MultiHeader h = new MultiHeader();
    h.deserialize(archive, tag);
    while (!h.getDone()) {
        switch (h.getType()) {
            case ZooDefs.OpCode.create:
                CreateResponse cr = new CreateResponse();
                cr.deserialize(archive, tag);
                results.add(new OpResult.CreateResult(cr.getPath()));
                break;

            case ZooDefs.OpCode.create2:
                Create2Response cr2 = new Create2Response();
                cr2.deserialize(archive, tag);
                results.add(new OpResult.CreateResult(cr2.getPath(), cr2.getStat()));
                break;

            case ZooDefs.OpCode.delete:
                results.add(new OpResult.DeleteResult());
                break;

            case ZooDefs.OpCode.setData:
                SetDataResponse sdr = new SetDataResponse();
                sdr.deserialize(archive, tag);
                results.add(new OpResult.SetDataResult(sdr.getStat()));
                break;

            case ZooDefs.OpCode.check:
                results.add(new OpResult.CheckResult());
                break;

            case ZooDefs.OpCode.error:
                //FIXME: need way to more cleanly serialize/deserialize exceptions
                ErrorResponse er = new ErrorResponse();
                er.deserialize(archive, tag);
                results.add(new OpResult.ErrorResult(er.getErr()));
                break;

            default:
                throw new IOException("Invalid type " + h.getType() + " in MultiResponse");
        }
        h.deserialize(archive, tag);
    }
    archive.endRecord(tag);
}
项目:SecureKeeper    文件:MultiResponse.java   
@Override
public void deserialize(InputArchive archive, String tag) throws IOException {
    results = new ArrayList<OpResult>();

    archive.startRecord(tag);
    MultiHeader h = new MultiHeader();
    h.deserialize(archive, tag);
    while (!h.getDone()) {
        switch (h.getType()) {
            case ZooDefs.OpCode.create:
                CreateResponse cr = new CreateResponse();
                cr.deserialize(archive, tag);
                results.add(new OpResult.CreateResult(cr.getPath()));
                break;

            case ZooDefs.OpCode.create2:
                Create2Response cr2 = new Create2Response();
                cr2.deserialize(archive, tag);
                results.add(new OpResult.CreateResult(cr2.getPath(), cr2.getStat()));
                break;

            case ZooDefs.OpCode.delete:
                results.add(new OpResult.DeleteResult());
                break;

            case ZooDefs.OpCode.setData:
                SetDataResponse sdr = new SetDataResponse();
                sdr.deserialize(archive, tag);
                results.add(new OpResult.SetDataResult(sdr.getStat()));
                break;

            case ZooDefs.OpCode.check:
                results.add(new OpResult.CheckResult());
                break;

            case ZooDefs.OpCode.error:
                //FIXME: need way to more cleanly serialize/deserialize exceptions
                ErrorResponse er = new ErrorResponse();
                er.deserialize(archive, tag);
                results.add(new OpResult.ErrorResult(er.getErr()));
                break;

            default:
                throw new IOException("Invalid type " + h.getType() + " in MultiResponse");
        }
        h.deserialize(archive, tag);
    }
    archive.endRecord(tag);
}
项目:zookeeper-lite    文件:ICreate2Response.java   
public ICreate2Response() {
    this(new Create2Response());
}
项目:zookeeper-lite    文件:ICreate2Response.java   
public ICreate2Response(String path, Stat stat) {
    this(new Create2Response(path, stat));
}
项目:zookeeper-lite    文件:ICreate2Response.java   
public ICreate2Response(Create2Response record) {
    super(record);
}