本文整理汇总了Java中org.apache.hadoop.hdfs.qjournal.protocol.RequestInfo.getEpoch方法的典型用法代码示例。如果您正苦于以下问题:Java RequestInfo.getEpoch方法的具体用法?Java RequestInfo.getEpoch怎么用?Java RequestInfo.getEpoch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hdfs.qjournal.protocol.RequestInfo
的用法示例。
在下文中一共展示了RequestInfo.getEpoch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: checkWriteRequest
import org.apache.hadoop.hdfs.qjournal.protocol.RequestInfo; //导入方法依赖的package包/类
private synchronized void checkWriteRequest(RequestInfo reqInfo) throws IOException {
checkRequest(reqInfo);
if (reqInfo.getEpoch() != lastWriterEpoch.get()) {
throw new IOException("IPC's epoch " + reqInfo.getEpoch() +
" is not the current writer epoch " +
lastWriterEpoch.get());
}
}
示例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);
}
}
示例4: syncLog
import org.apache.hadoop.hdfs.qjournal.protocol.RequestInfo; //导入方法依赖的package包/类
/**
* Synchronize a log segment from another JournalNode. The log is
* downloaded from the provided URL into a temporary location on disk,
* which is named based on the current request's epoch.
*
* @return the temporary location of the downloaded file
*/
File syncLog(RequestInfo reqInfo, final SegmentStateProto segment,
final URL url) throws IOException {
long startTxId = segment.getStartTxId();
long epoch = reqInfo.getEpoch();
return syncLog(epoch, segment.getStartTxId(), url, segment.toString(),
journalStorage.getSyncLogTemporaryFile(startTxId, epoch));
}