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


Java InputArchive.readByte方法代码示例

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


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

示例1: readTxnBytes

import org.apache.jute.InputArchive; //导入方法依赖的package包/类
/**
 * Reads a transaction entry from the input archive.
 * @param ia archive to read from
 * @return null if the entry is corrupted or EOF has been reached; a buffer
 * (possible empty) containing serialized transaction record.
 * @throws IOException
 */
public static byte[] readTxnBytes(InputArchive ia) throws IOException {
    try{
        byte[] bytes = ia.readBuffer("txtEntry");
        // Since we preallocate, we define EOF to be an
        // empty transaction
        if (bytes.length == 0)
            return bytes;
        if (ia.readByte("EOF") != 'B') {
            LOG.error("Last transaction was partial.");
            return null;
        }
        return bytes;
    }catch(EOFException e){}
    return null;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:23,代码来源:Util.java

示例2: playLog

import org.apache.jute.InputArchive; //导入方法依赖的package包/类
/**
 * play the log from this logstream into the datatree
 * @param logStream
 * @return
 * @throws IOException
 */
public long playLog(InputArchive logStream) throws IOException {
    long highestZxid = 0;
    try {
        while (true) {
            byte[] bytes = logStream.readBuffer("txnEntry");
            if (bytes.length == 0) {
                // Since we preallocate, we define EOF to be an
                // empty transaction
                throw new EOFException();
            }
            TxnHeader hdr = new TxnHeader();
            Record txn = SerializeUtils.deserializeTxn(bytes, hdr);
            if (logStream.readByte("EOR") != 'B') {
                LOG.warn("Last transaction was partial.");
                throw new EOFException("Last transaction was partial.");
            }
            if (hdr.getZxid() <= highestZxid && highestZxid != 0) {
                LOG.error(highestZxid + "(higestZxid) >= "
                        + hdr.getZxid() + "(next log) for type "
                        + hdr.getType());
            } else {
                highestZxid = hdr.getZxid();
            }
            switch (hdr.getType()) {
            case OpCode.createSession:
                sessionsWithTimeouts.put(hdr.getClientId(),
                        ((CreateSessionTxn) txn).getTimeOut());
                if (LOG.isTraceEnabled()) {
                    ZooTrace.logTraceMessage(LOG,
                                             ZooTrace.SESSION_TRACE_MASK,
                            "playLog --- create session in log: 0x"
                                    + Long.toHexString(hdr.getClientId())
                                    + " with timeout: "
                                    + ((CreateSessionTxn) txn).getTimeOut());
                }
                // give dataTree a chance to sync its lastProcessedZxid
                oldDataTree.processTxn(hdr, txn);
                break;
            case OpCode.closeSession:
                sessionsWithTimeouts.remove(hdr.getClientId());
                if (LOG.isTraceEnabled()) {
                    ZooTrace.logTraceMessage(LOG,
                            ZooTrace.SESSION_TRACE_MASK,
                            "playLog --- close session in log: 0x"
                                    + Long.toHexString(hdr.getClientId()));
                }
                oldDataTree.processTxn(hdr, txn);
                break;
            default:
                oldDataTree.processTxn(hdr, txn);
            }
            Request r = new Request(null, 0, hdr.getCxid(), hdr.getType(),
                    null, null);
            r.txn = txn;
            r.hdr = hdr;
            r.zxid = hdr.getZxid();
        }
    } catch (EOFException e) {
        // expected in some cases - see comments in try block
    }
    return highestZxid;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:69,代码来源:UpgradeSnapShotV1.java


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