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


Java MultiHeader类代码示例

本文整理汇总了Java中org.apache.zookeeper.proto.MultiHeader的典型用法代码示例。如果您正苦于以下问题:Java MultiHeader类的具体用法?Java MultiHeader怎么用?Java MultiHeader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: serialize

import org.apache.zookeeper.proto.MultiHeader; //导入依赖的package包/类
@Override
public void serialize(OutputArchive archive, String tag) throws IOException {
    archive.startRecord(this, tag);

    int index = 0;
    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.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);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:31,代码来源:MultiResponse.java

示例2: serialize

import org.apache.zookeeper.proto.MultiHeader; //导入依赖的package包/类
@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);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:35,代码来源:MultiResponse.java

示例3: deserialize

import org.apache.zookeeper.proto.MultiHeader; //导入依赖的package包/类
@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.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);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:44,代码来源:MultiResponse.java

示例4: deserialize

import org.apache.zookeeper.proto.MultiHeader; //导入依赖的package包/类
@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);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:50,代码来源:MultiResponse.java

示例5: IMultiHeader

import org.apache.zookeeper.proto.MultiHeader; //导入依赖的package包/类
public IMultiHeader() {
    this(new MultiHeader());
}
 
开发者ID:lisaglendenning,项目名称:zookeeper-lite,代码行数:4,代码来源:IMultiHeader.java


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