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


Java RollingUpgradeStartupOption类代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption的典型用法代码示例。如果您正苦于以下问题:Java RollingUpgradeStartupOption类的具体用法?Java RollingUpgradeStartupOption怎么用?Java RollingUpgradeStartupOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RollingUpgradeStartupOption类属于org.apache.hadoop.hdfs.server.common.HdfsServerConstants包,在下文中一共展示了RollingUpgradeStartupOption类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRollingUpgradeStartupOptionParsing

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption; //导入依赖的package包/类
/**
 * Test that we can parse a StartupOption string with a
 * RollingUpgradeStartupOption.
 */
@Test
public void testRollingUpgradeStartupOptionParsing() {
  verifyStartupOptionResult("ROLLINGUPGRADE(ROLLBACK)",
                            StartupOption.ROLLINGUPGRADE,
                            RollingUpgradeStartupOption.ROLLBACK);
  verifyStartupOptionResult("ROLLINGUPGRADE(DOWNGRADE)",
                            StartupOption.ROLLINGUPGRADE,
                            RollingUpgradeStartupOption.DOWNGRADE);
  verifyStartupOptionResult("ROLLINGUPGRADE(STARTED)",
      StartupOption.ROLLINGUPGRADE,
      RollingUpgradeStartupOption.STARTED);

  try {
    verifyStartupOptionResult("ROLLINGUPGRADE(UNKNOWNOPTION)", StartupOption.ROLLINGUPGRADE, null);
    fail("Failed to get expected IllegalArgumentException");
  } catch(IllegalArgumentException iae) {
    // Expected!
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestHdfsServerConstants.java

示例2: testRollingUpgradeStartupOptionParsing

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption; //导入依赖的package包/类
/**
 * Test that we can parse a StartupOption string with a
 * RollingUpgradeStartupOption.
 */
@Test
public void testRollingUpgradeStartupOptionParsing() {
  verifyStartupOptionResult("ROLLINGUPGRADE(ROLLBACK)",
                            StartupOption.ROLLINGUPGRADE,
                            RollingUpgradeStartupOption.ROLLBACK);
  verifyStartupOptionResult("ROLLINGUPGRADE(STARTED)",
      StartupOption.ROLLINGUPGRADE,
      RollingUpgradeStartupOption.STARTED);

  try {
    verifyStartupOptionResult("ROLLINGUPGRADE(UNKNOWNOPTION)", StartupOption.ROLLINGUPGRADE, null);
    fail("Failed to get expected IllegalArgumentException");
  } catch(IllegalArgumentException iae) {
    // Expected!
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:21,代码来源:TestHdfsServerConstants.java

示例3: updateStorageVersionForRollingUpgrade

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption; //导入依赖的package包/类
private void updateStorageVersionForRollingUpgrade(final long layoutVersion,
    StartupOption startOpt) throws IOException {
  boolean rollingStarted = RollingUpgradeStartupOption.STARTED
      .matches(startOpt) && layoutVersion > HdfsConstants
      .NAMENODE_LAYOUT_VERSION;
  boolean rollingRollback = RollingUpgradeStartupOption.ROLLBACK
      .matches(startOpt);
  if (rollingRollback || rollingStarted) {
    fsImage.updateStorageVersion();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:FSNamesystem.java

示例4: loadFSImageFile

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption; //导入依赖的package包/类
void loadFSImageFile(FSNamesystem target, MetaRecoveryContext recovery,
    FSImageFile imageFile, StartupOption startupOption) throws IOException {
  LOG.debug("Planning to load image :\n" + imageFile);
  StorageDirectory sdForProperties = imageFile.sd;
  storage.readProperties(sdForProperties, startupOption);

  if (NameNodeLayoutVersion.supports(
      LayoutVersion.Feature.TXID_BASED_LAYOUT, getLayoutVersion())) {
    // For txid-based layout, we should have a .md5 file
    // next to the image file
    boolean isRollingRollback = RollingUpgradeStartupOption.ROLLBACK
        .matches(startupOption);
    loadFSImage(imageFile.getFile(), target, recovery, isRollingRollback);
  } else if (NameNodeLayoutVersion.supports(
      LayoutVersion.Feature.FSIMAGE_CHECKSUM, getLayoutVersion())) {
    // In 0.22, we have the checksum stored in the VERSION file.
    String md5 = storage.getDeprecatedProperty(
        NNStorage.DEPRECATED_MESSAGE_DIGEST_PROPERTY);
    if (md5 == null) {
      throw new InconsistentFSStateException(sdForProperties.getRoot(),
          "Message digest property " +
          NNStorage.DEPRECATED_MESSAGE_DIGEST_PROPERTY +
          " not set for storage directory " + sdForProperties.getRoot());
    }
    loadFSImage(imageFile.getFile(), new MD5Hash(md5), target, recovery,
        false);
  } else {
    // We don't have any record of the md5sum
    loadFSImage(imageFile.getFile(), null, target, recovery, false);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:FSImage.java

示例5: initEditLog

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption; //导入依赖的package包/类
public void initEditLog(StartupOption startOpt) throws IOException {
  Preconditions.checkState(getNamespaceID() != 0,
      "Must know namespace ID before initting edit log");
  String nameserviceId = DFSUtil.getNamenodeNameServiceId(conf);
  if (!HAUtil.isHAEnabled(conf, nameserviceId)) {
    // If this NN is not HA
    editLog.initJournalsForWrite();
    editLog.recoverUnclosedStreams();
  } else if (HAUtil.isHAEnabled(conf, nameserviceId)
      && (startOpt == StartupOption.UPGRADE
          || startOpt == StartupOption.UPGRADEONLY
          || RollingUpgradeStartupOption.ROLLBACK.matches(startOpt))) {
    // This NN is HA, but we're doing an upgrade or a rollback of rolling
    // upgrade so init the edit log for write.
    editLog.initJournalsForWrite();
    if (startOpt == StartupOption.UPGRADE
        || startOpt == StartupOption.UPGRADEONLY) {
      long sharedLogCTime = editLog.getSharedLogCTime();
      if (this.storage.getCTime() < sharedLogCTime) {
        throw new IOException("It looks like the shared log is already " +
            "being upgraded but this NN has not been upgraded yet. You " +
            "should restart this NameNode with the '" +
            StartupOption.BOOTSTRAPSTANDBY.getName() + "' option to bring " +
            "this NN in sync with the other.");
      }
    }
    editLog.recoverUnclosedStreams();
  } else {
    // This NN is HA and we're not doing an upgrade.
    editLog.initSharedJournalsForRead();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:FSImage.java

示例6: verifyStartupOptionResult

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption; //导入依赖的package包/类
/**
 * Verify that parsing a StartupOption string gives the expected results.
 * If a RollingUpgradeStartupOption is specified than it is also checked.
 *
 * @param value
 * @param expectedOption
 * @param expectedRollupOption optional, may be null.
 */
private static void verifyStartupOptionResult(String value,
    StartupOption expectedOption,
    RollingUpgradeStartupOption expectedRollupOption) {

  StartupOption option = StartupOption.getEnum(value);
  assertEquals(expectedOption, option);

  if (expectedRollupOption != null) {
    assertEquals(expectedRollupOption, option.getRollingUpgradeStartupOption());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestHdfsServerConstants.java

示例7: initEditLog

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption; //导入依赖的package包/类
public void initEditLog(StartupOption startOpt) throws IOException {
  Preconditions.checkState(getNamespaceID() != 0,
      "Must know namespace ID before initting edit log");
  String nameserviceId = DFSUtil.getNamenodeNameServiceId(conf);
  if (!HAUtil.isHAEnabled(conf, nameserviceId)) {
    // If this NN is not HA
    editLog.initJournalsForWrite();
    editLog.recoverUnclosedStreams();
  } else if (HAUtil.isHAEnabled(conf, nameserviceId)
      && (startOpt == StartupOption.UPGRADE
          || RollingUpgradeStartupOption.ROLLBACK.matches(startOpt))) {
    // This NN is HA, but we're doing an upgrade or a rollback of rolling
    // upgrade so init the edit log for write.
    editLog.initJournalsForWrite();
    if (startOpt == StartupOption.UPGRADE) {
      long sharedLogCTime = editLog.getSharedLogCTime();
      if (this.storage.getCTime() < sharedLogCTime) {
        throw new IOException("It looks like the shared log is already " +
            "being upgraded but this NN has not been upgraded yet. You " +
            "should restart this NameNode with the '" +
            StartupOption.BOOTSTRAPSTANDBY.getName() + "' option to bring " +
            "this NN in sync with the other.");
      }
    }
    editLog.recoverUnclosedStreams();
  } else {
    // This NN is HA and we're not doing an upgrade.
    editLog.initSharedJournalsForRead();
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:31,代码来源:FSImage.java

示例8: loadFSImage

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption; //导入依赖的package包/类
private void loadFSImage(StartupOption startOpt) throws IOException {
  final FSImage fsImage = getFSImage();

  // format before starting up if requested
  if (startOpt == StartupOption.FORMAT) {
    
    fsImage.format(this, fsImage.getStorage().determineClusterId());// reuse current id

    startOpt = StartupOption.REGULAR;
  }
  boolean success = false;
  writeLock();
  try {
    // We shouldn't be calling saveNamespace if we've come up in standby state.
    MetaRecoveryContext recovery = startOpt.createRecoveryContext();
    final boolean staleImage
        = fsImage.recoverTransitionRead(startOpt, this, recovery);
    if (RollingUpgradeStartupOption.ROLLBACK.matches(startOpt) ||
        RollingUpgradeStartupOption.DOWNGRADE.matches(startOpt)) {
      rollingUpgradeInfo = null;
    }
    final boolean needToSave = staleImage && !haEnabled && !isRollingUpgrade(); 
    LOG.info("Need to save fs image? " + needToSave
        + " (staleImage=" + staleImage + ", haEnabled=" + haEnabled
        + ", isRollingUpgrade=" + isRollingUpgrade() + ")");
    if (needToSave) {
      fsImage.saveNamespace(this);
    } else {
      updateStorageVersionForRollingUpgrade(fsImage.getLayoutVersion(),
          startOpt);
      // No need to save, so mark the phase done.
      StartupProgress prog = NameNode.getStartupProgress();
      prog.beginPhase(Phase.SAVING_CHECKPOINT);
      prog.endPhase(Phase.SAVING_CHECKPOINT);
    }
    // This will start a new log segment and write to the seen_txid file, so
    // we shouldn't do it when coming up in standby state
    if (!haEnabled || (haEnabled && startOpt == StartupOption.UPGRADE)
        || (haEnabled && startOpt == StartupOption.UPGRADEONLY)) {
      fsImage.openEditLogForWrite();
    }
    success = true;
  } finally {
    if (!success) {
      fsImage.close();
    }
    writeUnlock();
  }
  imageLoadComplete();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:51,代码来源:FSNamesystem.java

示例9: loadFSImage

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption; //导入依赖的package包/类
private void loadFSImage(StartupOption startOpt) throws IOException {
  final FSImage fsImage = getFSImage();

  // format before starting up if requested
  if (startOpt == StartupOption.FORMAT) {
    
    fsImage.format(this, fsImage.getStorage().determineClusterId());// reuse current id

    startOpt = StartupOption.REGULAR;
  }
  boolean success = false;
  writeLock();
  try {
    // We shouldn't be calling saveNamespace if we've come up in standby state.
    MetaRecoveryContext recovery = startOpt.createRecoveryContext();
    final boolean staleImage
        = fsImage.recoverTransitionRead(startOpt, this, recovery);
    if (RollingUpgradeStartupOption.ROLLBACK.matches(startOpt)) {
      rollingUpgradeInfo = null;
    }
    final boolean needToSave = staleImage && !haEnabled && !isRollingUpgrade(); 
    LOG.info("Need to save fs image? " + needToSave
        + " (staleImage=" + staleImage + ", haEnabled=" + haEnabled
        + ", isRollingUpgrade=" + isRollingUpgrade() + ")");
    if (needToSave) {
      fsImage.saveNamespace(this);
    } else {
      // No need to save, so mark the phase done.
      StartupProgress prog = NameNode.getStartupProgress();
      prog.beginPhase(Phase.SAVING_CHECKPOINT);
      prog.endPhase(Phase.SAVING_CHECKPOINT);
    }
    // This will start a new log segment and write to the seen_txid file, so
    // we shouldn't do it when coming up in standby state
    if (!haEnabled || (haEnabled && startOpt == StartupOption.UPGRADE)
        || (haEnabled && startOpt == StartupOption.UPGRADEONLY)) {
      fsImage.openEditLogForWrite(getEffectiveLayoutVersion());
    }
    success = true;
  } finally {
    if (!success) {
      fsImage.close();
    }
    writeUnlock();
  }
  imageLoadComplete();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:48,代码来源:FSNamesystem.java

示例10: loadFSImage

import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption; //导入依赖的package包/类
private void loadFSImage(StartupOption startOpt) throws IOException {
  final FSImage fsImage = getFSImage();

  // format before starting up if requested
  if (startOpt == StartupOption.FORMAT) {
    
    fsImage.format(this, fsImage.getStorage().determineClusterId());// reuse current id

    startOpt = StartupOption.REGULAR;
  }
  boolean success = false;
  writeLock();
  try {
    // We shouldn't be calling saveNamespace if we've come up in standby state.
    MetaRecoveryContext recovery = startOpt.createRecoveryContext();
    final boolean staleImage
        = fsImage.recoverTransitionRead(startOpt, this, recovery);
    if (RollingUpgradeStartupOption.ROLLBACK.matches(startOpt)) {
      rollingUpgradeInfo = null;
    }
    final boolean needToSave = staleImage && !haEnabled && !isRollingUpgrade(); 
    LOG.info("Need to save fs image? " + needToSave
        + " (staleImage=" + staleImage + ", haEnabled=" + haEnabled
        + ", isRollingUpgrade=" + isRollingUpgrade() + ")");
    if (needToSave) {
      fsImage.saveNamespace(this);
    } else {
      // No need to save, so mark the phase done.
      StartupProgress prog = NameNode.getStartupProgress();
      prog.beginPhase(Phase.SAVING_CHECKPOINT);
      prog.endPhase(Phase.SAVING_CHECKPOINT);
    }
    // This will start a new log segment and write to the seen_txid file, so
    // we shouldn't do it when coming up in standby state
    if (!haEnabled || (haEnabled && startOpt == StartupOption.UPGRADE)) {
      fsImage.openEditLogForWrite();
    }
    success = true;
  } finally {
    if (!success) {
      fsImage.close();
    }
    writeUnlock();
  }
  dir.imageLoadComplete();
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:47,代码来源:FSNamesystem.java


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