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


Java RequestInfo.getIpcSerialNumber方法代码示例

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


在下文中一共展示了RequestInfo.getIpcSerialNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:Journal.java

示例2: 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);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:42,代码来源:Journal.java


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