本文整理汇总了Java中org.apache.hadoop.hdfs.qjournal.protocol.RequestInfo.hasCommittedTxId方法的典型用法代码示例。如果您正苦于以下问题:Java RequestInfo.hasCommittedTxId方法的具体用法?Java RequestInfo.hasCommittedTxId怎么用?Java RequestInfo.hasCommittedTxId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hdfs.qjournal.protocol.RequestInfo
的用法示例。
在下文中一共展示了RequestInfo.hasCommittedTxId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkRequest
import org.apache.hadoop.hdfs.qjournal.protocol.RequestInfo; //导入方法依赖的package包/类
/**
* Ensure that the given request is coming from the correct writer and in-order.
* @param reqInfo the request info
* @throws IOException if the request is invalid.
*/
private synchronized void checkRequest(RequestInfo reqInfo) throws IOException {
// Invariant 25 from ZAB paper
if (reqInfo.getEpoch() < lastPromisedEpoch.get()) {
throw new IOException("IPC's epoch " + reqInfo.getEpoch() +
" is less than the last promised epoch " +
lastPromisedEpoch.get());
} else if (reqInfo.getEpoch() > lastPromisedEpoch.get()) {
// A newer client has arrived. Fence any previous writers by updating
// the promise.
updateLastPromisedEpoch(reqInfo.getEpoch());
}
// Ensure that the IPCs are arriving in-order as expected.
checkSync(reqInfo.getIpcSerialNumber() > currentEpochIpcSerial,
"IPC serial %s from client %s was not higher than prior highest " +
"IPC serial %s", reqInfo.getIpcSerialNumber(),
Server.getRemoteIp(),
currentEpochIpcSerial);
currentEpochIpcSerial = reqInfo.getIpcSerialNumber();
if (reqInfo.hasCommittedTxId()) {
Preconditions.checkArgument(
reqInfo.getCommittedTxId() >= committedTxnId.get(),
"Client trying to move committed txid backward from " +
committedTxnId.get() + " to " + reqInfo.getCommittedTxId());
committedTxnId.set(reqInfo.getCommittedTxId());
}
}
示例2: convert
import org.apache.hadoop.hdfs.qjournal.protocol.RequestInfo; //导入方法依赖的package包/类
private QJournalProtocolProtos.RequestInfoProto convert(
RequestInfo reqInfo) {
RequestInfoProto.Builder builder = RequestInfoProto.newBuilder()
.setJournalId(convertJournalId(reqInfo.getJournalId()))
.setEpoch(reqInfo.getEpoch())
.setIpcSerialNumber(reqInfo.getIpcSerialNumber());
if (reqInfo.hasCommittedTxId()) {
builder.setCommittedTxId(reqInfo.getCommittedTxId());
}
return builder.build();
}
示例3: checkRequest
import org.apache.hadoop.hdfs.qjournal.protocol.RequestInfo; //导入方法依赖的package包/类
/**
* Ensure that the given request is coming from the correct writer and in-order.
* @param reqInfo the request info
* @throws IOException if the request is invalid.
*/
private synchronized void checkRequest(RequestInfo reqInfo) throws IOException {
// Invariant 25 from ZAB paper
if (reqInfo.getEpoch() < lastPromisedEpoch.get()) {
throw new IOException("IPC's epoch " + reqInfo.getEpoch() +
" is less than the last promised epoch " +
lastPromisedEpoch.get());
} else if (reqInfo.getEpoch() > lastPromisedEpoch.get()) {
// A newer client has arrived. Fence any previous writers by updating
// the promise.
updateLastPromisedEpoch(reqInfo.getEpoch());
}
// Ensure that the IPCs are arriving in-order as expected.
if (reqInfo.getIpcSerialNumber() <= currentEpochIpcSerial) {
checkSync(false,
"IPC serial %s from client %s was not higher than prior highest " +
"IPC serial %s", reqInfo.getIpcSerialNumber(),
Server.getRemoteIp(),
currentEpochIpcSerial);
}
currentEpochIpcSerial = reqInfo.getIpcSerialNumber();
if (reqInfo.hasCommittedTxId()) {
if (reqInfo.getCommittedTxId() < committedTxnId.get()) {
throw new IllegalArgumentException(
"Client trying to move committed txid backward from "
+ committedTxnId.get() + " to " + reqInfo.getCommittedTxId());
}
// persist txid every second, as it is not needed for correctness
boolean persist = (now() - lastPersistedCommittedTxId) > 1000;
if (persist) {
lastPersistedCommittedTxId = now();
}
committedTxnId.set(reqInfo.getCommittedTxId(), persist);
}
}