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


Java NamenodeRegistration.getAddress方法代码示例

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


在下文中一共展示了NamenodeRegistration.getAddress方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startCheckpoint

import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; //导入方法依赖的package包/类
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  return new CheckpointCommand(sig, needToReturnImg);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:50,代码来源:FSImage.java

示例2: startCheckpoint

import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; //导入方法依赖的package包/类
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg,
                                int layoutVersion) // active name-node
throws IOException {
  LOG.info("Start checkpoint at txid " + getEditLog().getLastWrittenTxId());
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != storage.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + storage.getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.NAMENODE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < storage.getLayoutVersion()
      || (bnReg.getLayoutVersion() == storage.getLayoutVersion()
          && bnReg.getCTime() > storage.getCTime()))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + ". Current version: LV = " + storage.getLayoutVersion()
          + " cTime = " + storage.getCTime();
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean needToReturnImg = true;
  if(storage.getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog(layoutVersion);
  return new CheckpointCommand(sig, needToReturnImg);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:51,代码来源:FSImage.java

示例3: journal

import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; //导入方法依赖的package包/类
@Override // NamenodeProtocol
public void journal(NamenodeRegistration nnReg,
                    int jAction,
                    int length,
                    byte[] args) throws IOException {
  verifyRequest(nnReg);
  if(!nnRpcAddress.equals(nnReg.getAddress()))
    throw new IOException("Journal request from unexpected name-node: "
        + nnReg.getAddress() + " expecting " + nnRpcAddress);
  BackupStorage bnImage = (BackupStorage)getFSImage();
  switch(jAction) {
    case (int)JA_IS_ALIVE:
      return;
    case (int)JA_JOURNAL:
      bnImage.journal(length, args);
      return;
    case (int)JA_JSPOOL_START:
      bnImage.startJournalSpool(nnReg);
      return;
    case (int)JA_CHECKPOINT_TIME:
      bnImage.setCheckpointTime(length, args);
      setRegistration(); // keep registration up to date
      return;
    default:
      throw new IOException("Unexpected journal action: " + jAction);
  }
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:28,代码来源:BackupNode.java

示例4: registerWith

import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; //导入方法依赖的package包/类
/**
 * Register this backup node with the active name-node.
 * @param nsInfo
 * @throws IOException
 */
private void registerWith(NamespaceInfo nsInfo) throws IOException {
  BackupStorage bnImage = (BackupStorage)getFSImage();
  // verify namespaceID
  if(bnImage.getNamespaceID() == 0) // new backup storage
    bnImage.setStorageInfo(nsInfo);
  else if(bnImage.getNamespaceID() != nsInfo.getNamespaceID())
    throw new IOException("Incompatible namespaceIDs"
        + ": active node namespaceID = " + nsInfo.getNamespaceID() 
        + "; backup node namespaceID = " + bnImage.getNamespaceID());

  setRegistration();
  NamenodeRegistration nnReg = null;
  while(!isStopRequested()) {
    try {
      nnReg = namenode.register(getRegistration());
      break;
    } catch(SocketTimeoutException e) {  // name-node is busy
      LOG.info("Problem connecting to name-node: " + nnRpcAddress);
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ie) {}
    }
  }

  String msg = null;
  if(nnReg == null) // consider as a rejection
    msg = "Registration rejected by " + nnRpcAddress;
  else if(!nnReg.isRole(NamenodeRole.ACTIVE)) {
    msg = "Name-node " + nnRpcAddress + " is not active";
  }
  if(msg != null) {
    msg += ". Shutting down.";
    LOG.error(msg);
    throw new IOException(msg); // stop the node
  }
  nnRpcAddress = nnReg.getAddress();
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:43,代码来源:BackupNode.java

示例5: registerWith

import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; //导入方法依赖的package包/类
/**
 * Register this backup node with the active name-node.
 * @param nsInfo namespace information
 * @throws IOException
 */
private void registerWith(NamespaceInfo nsInfo) throws IOException {
  BackupImage bnImage = (BackupImage)getFSImage();
  NNStorage storage = bnImage.getStorage();
  // verify namespaceID
  if (storage.getNamespaceID() == 0) { // new backup storage
    storage.setStorageInfo(nsInfo);
    storage.setBlockPoolID(nsInfo.getBlockPoolID());
    storage.setClusterID(nsInfo.getClusterID());
  } else {
    nsInfo.validateStorage(storage);
  }
  bnImage.initEditLog(StartupOption.REGULAR);
  setRegistration();
  NamenodeRegistration nnReg = null;
  while(!isStopRequested()) {
    try {
      nnReg = namenode.registerSubordinateNamenode(getRegistration());
      break;
    } catch(SocketTimeoutException e) {  // name-node is busy
      LOG.info("Problem connecting to name-node: " + nnRpcAddress);
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ie) {
        LOG.warn("Encountered exception ", e);
      }
    }
  }

  String msg = null;
  if(nnReg == null) // consider as a rejection
    msg = "Registration rejected by " + nnRpcAddress;
  else if(!nnReg.isRole(NamenodeRole.NAMENODE)) {
    msg = "Name-node " + nnRpcAddress + " is not active";
  }
  if(msg != null) {
    msg += ". Shutting down.";
    LOG.error(msg);
    throw new IOException(msg); // stop the node
  }
  nnRpcAddress = nnReg.getAddress();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:47,代码来源:BackupNode.java

示例6: registerWith

import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; //导入方法依赖的package包/类
/**
 * Register this backup node with the active name-node.
 * @param nsInfo
 * @throws IOException
 */
private void registerWith(NamespaceInfo nsInfo) throws IOException {
  BackupImage bnImage = (BackupImage)getFSImage();
  NNStorage storage = bnImage.getStorage();
  // verify namespaceID
  if (storage.getNamespaceID() == 0) { // new backup storage
    storage.setStorageInfo(nsInfo);
    storage.setBlockPoolID(nsInfo.getBlockPoolID());
    storage.setClusterID(nsInfo.getClusterID());
  } else {
    nsInfo.validateStorage(storage);
  }
  bnImage.initEditLog();
  setRegistration();
  NamenodeRegistration nnReg = null;
  while(!isStopRequested()) {
    try {
      nnReg = namenode.registerSubordinateNamenode(getRegistration());
      break;
    } catch(SocketTimeoutException e) {  // name-node is busy
      LOG.info("Problem connecting to name-node: " + nnRpcAddress);
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ie) {
        LOG.warn("Encountered exception ", e);
      }
    }
  }

  String msg = null;
  if(nnReg == null) // consider as a rejection
    msg = "Registration rejected by " + nnRpcAddress;
  else if(!nnReg.isRole(NamenodeRole.NAMENODE)) {
    msg = "Name-node " + nnRpcAddress + " is not active";
  }
  if(msg != null) {
    msg += ". Shutting down.";
    LOG.error(msg);
    throw new IOException(msg); // stop the node
  }
  nnRpcAddress = nnReg.getAddress();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:47,代码来源:BackupNode.java

示例7: registerWith

import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; //导入方法依赖的package包/类
/**
 * Register this backup node with the active name-node.
 * @param nsInfo
 * @throws IOException
 */
private void registerWith(NamespaceInfo nsInfo) throws IOException {
  BackupImage bnImage = (BackupImage)getFSImage();
  NNStorage storage = bnImage.getStorage();
  // verify namespaceID
  if (storage.getNamespaceID() == 0) { // new backup storage
    storage.setStorageInfo(nsInfo);
    storage.setBlockPoolID(nsInfo.getBlockPoolID());
    storage.setClusterID(nsInfo.getClusterID());
  } else {
    nsInfo.validateStorage(storage);
  }
  bnImage.initEditLog(StartupOption.REGULAR);
  setRegistration();
  NamenodeRegistration nnReg = null;
  while(!isStopRequested()) {
    try {
      nnReg = namenode.registerSubordinateNamenode(getRegistration());
      break;
    } catch(SocketTimeoutException e) {  // name-node is busy
      LOG.info("Problem connecting to name-node: " + nnRpcAddress);
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ie) {
        LOG.warn("Encountered exception ", e);
      }
    }
  }

  String msg = null;
  if(nnReg == null) // consider as a rejection
    msg = "Registration rejected by " + nnRpcAddress;
  else if(!nnReg.isRole(NamenodeRole.NAMENODE)) {
    msg = "Name-node " + nnRpcAddress + " is not active";
  }
  if(msg != null) {
    msg += ". Shutting down.";
    LOG.error(msg);
    throw new IOException(msg); // stop the node
  }
  nnRpcAddress = nnReg.getAddress();
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:47,代码来源:BackupNode.java

示例8: startCheckpoint

import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; //导入方法依赖的package包/类
/**
 * Start checkpoint.
 * <p>
 * If backup storage contains image that is newer than or incompatible with 
 * what the active name-node has, then the backup node should shutdown.<br>
 * If the backup image is older than the active one then it should 
 * be discarded and downloaded from the active node.<br>
 * If the images are the same then the backup image will be used as current.
 * 
 * @param bnReg the backup node registration.
 * @param nnReg this (active) name-node registration.
 * @return {@link NamenodeCommand} if backup node should shutdown or
 * {@link CheckpointCommand} prescribing what backup node should 
 *         do with its image.
 * @throws IOException
 */
NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node
                                NamenodeRegistration nnReg) // active name-node
throws IOException {
  String msg = null;
  // Verify that checkpoint is allowed
  if(bnReg.getNamespaceID() != this.getNamespaceID())
    msg = "Name node " + bnReg.getAddress()
          + " has incompatible namespace id: " + bnReg.getNamespaceID()
          + " expected: " + getNamespaceID();
  else if(bnReg.isRole(NamenodeRole.ACTIVE))
    msg = "Name node " + bnReg.getAddress()
          + " role " + bnReg.getRole() + ": checkpoint is not allowed.";
  else if(bnReg.getLayoutVersion() < this.getLayoutVersion()
      || (bnReg.getLayoutVersion() == this.getLayoutVersion()
          && bnReg.getCTime() > this.getCTime())
      || (bnReg.getLayoutVersion() == this.getLayoutVersion()
          && bnReg.getCTime() == this.getCTime()
          && bnReg.getCheckpointTime() > this.checkpointTime))
    // remote node has newer image age
    msg = "Name node " + bnReg.getAddress()
          + " has newer image layout version: LV = " +bnReg.getLayoutVersion()
          + " cTime = " + bnReg.getCTime()
          + " checkpointTime = " + bnReg.getCheckpointTime()
          + ". Current version: LV = " + getLayoutVersion()
          + " cTime = " + getCTime()
          + " checkpointTime = " + checkpointTime;
  if(msg != null) {
    LOG.error(msg);
    return new NamenodeCommand(NamenodeProtocol.ACT_SHUTDOWN);
  }
  boolean isImgObsolete = true;
  if(bnReg.getLayoutVersion() == this.getLayoutVersion()
      && bnReg.getCTime() == this.getCTime()
      && bnReg.getCheckpointTime() == this.checkpointTime)
    isImgObsolete = false;
  boolean needToReturnImg = true;
  if(getNumStorageDirs(NameNodeDirType.IMAGE) == 0)
    // do not return image if there are no image directories
    needToReturnImg = false;
  CheckpointSignature sig = rollEditLog();
  getEditLog().logJSpoolStart(bnReg, nnReg);
  return new CheckpointCommand(sig, isImgObsolete, needToReturnImg);
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:60,代码来源:FSImage.java

示例9: startJournalSpool

import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; //导入方法依赖的package包/类
/**
 * Start journal spool.
 * Switch to writing into edits.new instead of edits.
 * 
 * edits.new for spooling is in separate directory "spool" rather than in
 * "current" because the two directories should be independent.
 * While spooling a checkpoint can happen and current will first
 * move to lastcheckpoint.tmp and then to previous.checkpoint
 * spool/edits.new will remain in place during that.
 */
synchronized void startJournalSpool(NamenodeRegistration nnReg)
throws IOException {
  switch(jsState) {
    case OFF:
      break;
    case INPROGRESS:
      return;
    case WAIT:
      waitSpoolEnd();
  }
  
  List<StorageDirectory> errorSDs = new ArrayList<StorageDirectory>();
  // create journal spool directories
  for(Iterator<StorageDirectory> it = 
                        dirIterator(NameNodeDirType.EDITS); it.hasNext();) {
    StorageDirectory sd = it.next();
    File jsDir = getJSpoolDir(sd);
    if (!jsDir.exists() && !jsDir.mkdirs()) {
      throw new IOException("Mkdirs failed to create "
                            + jsDir.getCanonicalPath());
    }
    // create edit file if missing
    File eFile = getEditFile(sd);
    if(!eFile.exists()) {
      try {
        editLog.createEditLogFile(eFile);
      } catch (IOException ie) {
        LOG.error("Unable to save edits for " + sd.getRoot(), ie);
        errorSDs.add(sd);
      }
    }
  }
  
  if (errorSDs.size() > 0)
    processIOError(errorSDs, true);
  
  if(!editLog.isOpen())
    editLog.open();

  // create streams pointing to the journal spool files
  // subsequent journal records will go directly to the spool
  editLog.divertFileStreams(STORAGE_JSPOOL_DIR + "/" + STORAGE_JSPOOL_FILE);
  setCheckpointState(CheckpointStates.ROLLED_EDITS);

  // set up spooling
  if(backupInputStream == null)
    backupInputStream = new EditLogBackupInputStream(nnReg.getAddress());
  jsState = JSpoolState.INPROGRESS;
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:60,代码来源:BackupStorage.java


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