Java Code Examples for org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption#UPGRADEONLY

The following examples show how to use org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption#UPGRADEONLY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NNStorage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/** 
 * Processes the startup options for the clusterid and blockpoolid 
 * for the upgrade. 
 * @param startOpt Startup options 
 * @param layoutVersion Layout version for the upgrade 
 * @throws IOException
 */
void processStartupOptionsForUpgrade(StartupOption startOpt, int layoutVersion)
    throws IOException {
  if (startOpt == StartupOption.UPGRADE || startOpt == StartupOption.UPGRADEONLY) {
    // If upgrade from a release that does not support federation,
    // if clusterId is provided in the startupOptions use it.
    // Else generate a new cluster ID      
    if (!NameNodeLayoutVersion.supports(
        LayoutVersion.Feature.FEDERATION, layoutVersion)) {
      if (startOpt.getClusterId() == null) {
        startOpt.setClusterId(newClusterID());
      }
      setClusterID(startOpt.getClusterId());
      setBlockPoolID(newBlockPoolID());
    } else {
      // Upgrade from one version of federation to another supported
      // version of federation doesn't require clusterID.
      // Warn the user if the current clusterid didn't match with the input
      // clusterid.
      if (startOpt.getClusterId() != null
          && !startOpt.getClusterId().equals(getClusterID())) {
        LOG.warn("Clusterid mismatch - current clusterid: " + getClusterID()
            + ", Ignoring given clusterid: " + startOpt.getClusterId());
      }
    }
    LOG.info("Using clusterid: " + getClusterID());
  }
}
 
Example 2
Source File: NameNode.java    From hadoop with Apache License 2.0 5 votes vote down vote up
protected HAState createHAState(StartupOption startOpt) {
  if (!haEnabled || startOpt == StartupOption.UPGRADE 
      || startOpt == StartupOption.UPGRADEONLY) {
    return ACTIVE_STATE;
  } else {
    return STANDBY_STATE;
  }
}
 
Example 3
Source File: FSImage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
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();
  }
}
 
Example 4
Source File: NNStorage.java    From big-c with Apache License 2.0 5 votes vote down vote up
/** 
 * Processes the startup options for the clusterid and blockpoolid 
 * for the upgrade. 
 * @param startOpt Startup options 
 * @param layoutVersion Layout version for the upgrade 
 * @throws IOException
 */
void processStartupOptionsForUpgrade(StartupOption startOpt, int layoutVersion)
    throws IOException {
  if (startOpt == StartupOption.UPGRADE || startOpt == StartupOption.UPGRADEONLY) {
    // If upgrade from a release that does not support federation,
    // if clusterId is provided in the startupOptions use it.
    // Else generate a new cluster ID      
    if (!NameNodeLayoutVersion.supports(
        LayoutVersion.Feature.FEDERATION, layoutVersion)) {
      if (startOpt.getClusterId() == null) {
        startOpt.setClusterId(newClusterID());
      }
      setClusterID(startOpt.getClusterId());
      setBlockPoolID(newBlockPoolID());
    } else {
      // Upgrade from one version of federation to another supported
      // version of federation doesn't require clusterID.
      // Warn the user if the current clusterid didn't match with the input
      // clusterid.
      if (startOpt.getClusterId() != null
          && !startOpt.getClusterId().equals(getClusterID())) {
        LOG.warn("Clusterid mismatch - current clusterid: " + getClusterID()
            + ", Ignoring given clusterid: " + startOpt.getClusterId());
      }
    }
    LOG.info("Using clusterid: " + getClusterID());
  }
}
 
Example 5
Source File: NameNode.java    From big-c with Apache License 2.0 5 votes vote down vote up
protected HAState createHAState(StartupOption startOpt) {
  if (!haEnabled || startOpt == StartupOption.UPGRADE 
      || startOpt == StartupOption.UPGRADEONLY) {
    return ACTIVE_STATE;
  } else {
    return STANDBY_STATE;
  }
}
 
Example 6
Source File: FSImage.java    From big-c with Apache License 2.0 5 votes vote down vote up
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();
  }
}
 
Example 7
Source File: TestStartupOptionUpgrade.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Parameters
public static Collection<Object[]> startOption() {
  Object[][] params = new Object[][] { { StartupOption.UPGRADE },
      { StartupOption.UPGRADEONLY } };
  return Arrays.asList(params);
}
 
Example 8
Source File: TestStartupOptionUpgrade.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Parameters
public static Collection<Object[]> startOption() {
  Object[][] params = new Object[][] { { StartupOption.UPGRADE },
      { StartupOption.UPGRADEONLY } };
  return Arrays.asList(params);
}