本文整理汇总了Java中org.apache.jute.Record.serialize方法的典型用法代码示例。如果您正苦于以下问题:Java Record.serialize方法的具体用法?Java Record.serialize怎么用?Java Record.serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jute.Record
的用法示例。
在下文中一共展示了Record.serialize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: marshallTxnEntry
import org.apache.jute.Record; //导入方法依赖的package包/类
/**
* Serializes transaction header and transaction data into a byte buffer.
*
* @param hdr transaction header
* @param txn transaction data
* @return serialized transaction record
* @throws IOException
*/
public static byte[] marshallTxnEntry(TxnHeader hdr, Record txn)
throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputArchive boa = BinaryOutputArchive.getArchive(baos);
hdr.serialize(boa, "hdr");
if (txn != null) {
txn.serialize(boa, "txn");
}
return baos.toByteArray();
}
示例2: createRequest
import org.apache.jute.Record; //导入方法依赖的package包/类
private Request createRequest(Record record, int opCode) throws IOException {
// encoding
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
record.serialize(boa, "request");
baos.close();
// Id
List<Id> ids = Arrays.asList(Ids.ANYONE_ID_UNSAFE);
return new Request(null, 1l, 0, opCode, ByteBuffer.wrap(baos.toByteArray()), ids);
}
示例3: next
import org.apache.jute.Record; //导入方法依赖的package包/类
/**
* Proposal returned by this iterator has request part set to null, since
* it is not used for follower sync-up.
*/
@Override
public Proposal next() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
Proposal p = new Proposal();
try {
TxnHeader hdr = itr.getHeader();
Record txn = itr.getTxn();
hdr.serialize(boa, "hdr");
if (txn != null) {
txn.serialize(boa, "txn");
}
baos.close();
QuorumPacket pp = new QuorumPacket(Leader.PROPOSAL, itr.getHeader()
.getZxid(), baos.toByteArray(), null);
p.packet = pp;
p.request = null;
// This is the only place that can throw IO exception
hasNext = itr.next();
} catch (IOException e) {
LOG.error("Unable to read txnlog from disk", e);
hasNext = false;
}
return p;
}
示例4: newRequest
import org.apache.jute.Record; //导入方法依赖的package包/类
private Request newRequest(Record rec, int type, int sessionId, int xid)
throws IOException {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
BinaryOutputArchive boa = BinaryOutputArchive.getArchive(boas);
rec.serialize(boa, "request");
ByteBuffer bb = ByteBuffer.wrap(boas.toByteArray());
return new Request(null, sessionId, xid, type, bb, new ArrayList<Id>());
}
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:9,代码来源:CommitProcessorConcurrencyTest.java
示例5: createRequest
import org.apache.jute.Record; //导入方法依赖的package包/类
private Request createRequest(Record record, int opCode) throws IOException {
// encoding
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
record.serialize(boa, "request");
baos.close();
// Id
List<Id> ids = Arrays.asList(Ids.ANYONE_ID_UNSAFE);
return new Request(null, 1l, 0, opCode, ByteBuffer.wrap(baos.toByteArray()), ids);
}
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:11,代码来源:PrepRequestProcessorTest.java
示例6: record2ByteBuffer
import org.apache.jute.Record; //导入方法依赖的package包/类
static public void record2ByteBuffer(Record record, ByteBuffer bb)
throws IOException {
BinaryOutputArchive oa;
oa = BinaryOutputArchive.getArchive(new ByteBufferOutputStream(bb));
record.serialize(oa, "request");
}