本文整理汇总了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;
}
示例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;
}