org.apache.hadoop.hdfs.server.common.StorageInfo Java Examples

The following examples show how to use org.apache.hadoop.hdfs.server.common.StorageInfo. 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: UpgradeUtilities.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Create a <code>version</code> file for datanode inside the specified parent
 * directory.  If such a file already exists, it will be overwritten.
 * The given version string will be written to the file as the layout
 * version. None of the parameters may be null.
 *
 * @param parent directory where namenode VERSION file is stored
 * @param version StorageInfo to create VERSION file from
 * @param bpid Block pool Id
 * @param bpidToWrite Block pool Id to write into the version file
 */
public static void createDataNodeVersionFile(File[] parent,
    StorageInfo version, String bpid, String bpidToWrite) throws IOException {
  DataStorage storage = new DataStorage(version);
  storage.setDatanodeUuid("FixedDatanodeUuid");

  File[] versionFiles = new File[parent.length];
  for (int i = 0; i < parent.length; i++) {
    File versionFile = new File(parent[i], "VERSION");
    StorageDirectory sd = new StorageDirectory(parent[i].getParentFile());
    storage.createStorageID(sd, false);
    storage.writeProperties(versionFile, sd);
    versionFiles[i] = versionFile;
    File bpDir = BlockPoolSliceStorage.getBpRoot(bpid, parent[i]);
    createBlockPoolVersionFile(bpDir, version, bpidToWrite);
  }
}
 
Example #2
Source File: NNUpgradeUtil.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Return true if this storage dir can roll back to the previous storage
 * state, false otherwise. The NN will refuse to run the rollback operation
 * unless at least one JM or fsimage storage directory can roll back.
 * 
 * @param storage the storage info for the current state
 * @param prevStorage the storage info for the previous (unupgraded) state
 * @param targetLayoutVersion the layout version we intend to roll back to
 * @return true if this JM can roll back, false otherwise.
 * @throws IOException in the event of error
 */
static boolean canRollBack(StorageDirectory sd, StorageInfo storage,
    StorageInfo prevStorage, int targetLayoutVersion) throws IOException {
  File prevDir = sd.getPreviousDir();
  if (!prevDir.exists()) {  // use current directory then
    LOG.info("Storage directory " + sd.getRoot()
             + " does not contain previous fs state.");
    // read and verify consistency with other directories
    storage.readProperties(sd);
    return false;
  }

  // read and verify consistency of the prev dir
  prevStorage.readPreviousVersionProperties(sd);

  if (prevStorage.getLayoutVersion() != targetLayoutVersion) {
    throw new IOException(
      "Cannot rollback to storage version " +
      prevStorage.getLayoutVersion() +
      " using this version of the NameNode, which uses storage version " +
      targetLayoutVersion + ". " +
      "Please use the previous version of HDFS to perform the rollback.");
  }
  
  return true;
}
 
Example #3
Source File: QJournalProtocolTranslatorPB.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
public Boolean canRollBack(String journalId, StorageInfo storage,
    StorageInfo prevStorage, int targetLayoutVersion) throws IOException {
  try {
    CanRollBackResponseProto response = rpcProxy.canRollBack(
        NULL_CONTROLLER,
        CanRollBackRequestProto.newBuilder()
          .setJid(convertJournalId(journalId))
          .setStorage(PBHelper.convert(storage))
          .setPrevStorage(PBHelper.convert(prevStorage))
          .setTargetLayoutVersion(targetLayoutVersion)
          .build());
    return response.getCanRollBack();
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
Example #4
Source File: TestPBHelper.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testConvertNamenodeRegistration() {
  StorageInfo info = getStorageInfo(NodeType.NAME_NODE);
  NamenodeRegistration reg = new NamenodeRegistration("address:999",
      "http:1000", info, NamenodeRole.NAMENODE);
  NamenodeRegistrationProto regProto = PBHelper.convert(reg);
  NamenodeRegistration reg2 = PBHelper.convert(regProto);
  assertEquals(reg.getAddress(), reg2.getAddress());
  assertEquals(reg.getClusterID(), reg2.getClusterID());
  assertEquals(reg.getCTime(), reg2.getCTime());
  assertEquals(reg.getHttpAddress(), reg2.getHttpAddress());
  assertEquals(reg.getLayoutVersion(), reg2.getLayoutVersion());
  assertEquals(reg.getNamespaceID(), reg2.getNamespaceID());
  assertEquals(reg.getRegistrationID(), reg2.getRegistrationID());
  assertEquals(reg.getRole(), reg2.getRole());
  assertEquals(reg.getVersion(), reg2.getVersion());

}
 
Example #5
Source File: GetJournalEditServlet.java    From big-c with Apache License 2.0 6 votes vote down vote up
private boolean checkStorageInfoOrSendError(JNStorage storage,
    HttpServletRequest request, HttpServletResponse response)
    throws IOException {
  int myNsId = storage.getNamespaceID();
  String myClusterId = storage.getClusterID();
  
  String theirStorageInfoString = StringEscapeUtils.escapeHtml(
      request.getParameter(STORAGEINFO_PARAM));

  if (theirStorageInfoString != null) {
    int theirNsId = StorageInfo.getNsIdFromColonSeparatedString(
        theirStorageInfoString);
    String theirClusterId = StorageInfo.getClusterIdFromColonSeparatedString(
        theirStorageInfoString);
    if (myNsId != theirNsId || !myClusterId.equals(theirClusterId)) {
      String msg = "This node has namespaceId '" + myNsId + " and clusterId '"
          + myClusterId + "' but the requesting node expected '" + theirNsId
          + "' and '" + theirClusterId + "'";
      response.sendError(HttpServletResponse.SC_FORBIDDEN, msg);
      LOG.warn("Received an invalid request file transfer request from " +
          request.getRemoteAddr() + ": " + msg);
      return false;
    }
  }
  return true;
}
 
Example #6
Source File: GetJournalEditServlet.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private boolean checkStorageInfoOrSendError(JNStorage storage,
    HttpServletRequest request, HttpServletResponse response)
    throws IOException {
  int myNsId = storage.getNamespaceID();
  String myClusterId = storage.getClusterID();
  
  String theirStorageInfoString = StringEscapeUtils.escapeHtml(
      request.getParameter(STORAGEINFO_PARAM));

  if (theirStorageInfoString != null) {
    int theirNsId = StorageInfo.getNsIdFromColonSeparatedString(
        theirStorageInfoString);
    String theirClusterId = StorageInfo.getClusterIdFromColonSeparatedString(
        theirStorageInfoString);
    if (myNsId != theirNsId || !myClusterId.equals(theirClusterId)) {
      String msg = "This node has namespaceId '" + myNsId + " and clusterId '"
          + myClusterId + "' but the requesting node expected '" + theirNsId
          + "' and '" + theirClusterId + "'";
      response.sendError(HttpServletResponse.SC_FORBIDDEN, msg);
      LOG.warn("Received an invalid request file transfer request from " +
          request.getRemoteAddr() + ": " + msg);
      return false;
    }
  }
  return true;
}
 
Example #7
Source File: DatanodeRegistration.java    From big-c with Apache License 2.0 5 votes vote down vote up
public DatanodeRegistration(DatanodeID dn, StorageInfo info,
    ExportedBlockKeys keys, String softwareVersion) {
  super(dn);
  this.storageInfo = info;
  this.exportedKeys = keys;
  this.softwareVersion = softwareVersion;
}
 
Example #8
Source File: TestDFSStartupVersions.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the versions array.  This array stores all combinations 
 * of cross product:
 *  {oldLayoutVersion,currentLayoutVersion,futureLayoutVersion} X
 *    {currentNamespaceId,incorrectNamespaceId} X
 *      {pastFsscTime,currentFsscTime,futureFsscTime}
 */
private StorageInfo[] initializeVersions() throws Exception {
  int layoutVersionOld = Storage.LAST_UPGRADABLE_LAYOUT_VERSION;
  int layoutVersionCur = UpgradeUtilities.getCurrentLayoutVersion();
  int layoutVersionNew = Integer.MIN_VALUE;
  int namespaceIdCur = UpgradeUtilities.getCurrentNamespaceID(null);
  int namespaceIdOld = Integer.MIN_VALUE;
  long fsscTimeOld = Long.MIN_VALUE;
  long fsscTimeCur = UpgradeUtilities.getCurrentFsscTime(null);
  long fsscTimeNew = Long.MAX_VALUE;
  
  return new StorageInfo[] {
    new StorageInfo(layoutVersionOld, namespaceIdCur, fsscTimeOld), // 0
    new StorageInfo(layoutVersionOld, namespaceIdCur, fsscTimeCur), // 1
    new StorageInfo(layoutVersionOld, namespaceIdCur, fsscTimeNew), // 2
    new StorageInfo(layoutVersionOld, namespaceIdOld, fsscTimeOld), // 3
    new StorageInfo(layoutVersionOld, namespaceIdOld, fsscTimeCur), // 4
    new StorageInfo(layoutVersionOld, namespaceIdOld, fsscTimeNew), // 5
    new StorageInfo(layoutVersionCur, namespaceIdCur, fsscTimeOld), // 6
    new StorageInfo(layoutVersionCur, namespaceIdCur, fsscTimeCur), // 7
    new StorageInfo(layoutVersionCur, namespaceIdCur, fsscTimeNew), // 8
    new StorageInfo(layoutVersionCur, namespaceIdOld, fsscTimeOld), // 9
    new StorageInfo(layoutVersionCur, namespaceIdOld, fsscTimeCur), // 10
    new StorageInfo(layoutVersionCur, namespaceIdOld, fsscTimeNew), // 11
    new StorageInfo(layoutVersionNew, namespaceIdCur, fsscTimeOld), // 12
    new StorageInfo(layoutVersionNew, namespaceIdCur, fsscTimeCur), // 13
    new StorageInfo(layoutVersionNew, namespaceIdCur, fsscTimeNew), // 14
    new StorageInfo(layoutVersionNew, namespaceIdOld, fsscTimeOld), // 15
    new StorageInfo(layoutVersionNew, namespaceIdOld, fsscTimeCur), // 16
    new StorageInfo(layoutVersionNew, namespaceIdOld, fsscTimeNew), // 17
  };
}
 
Example #9
Source File: CheckpointSignature.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
void validateStorageInfo(StorageInfo si) throws IOException {
  if(layoutVersion != si.layoutVersion
      || namespaceID != si.namespaceID || cTime != si.cTime) {
    // checkpointTime can change when the image is saved - do not compare
    throw new IOException("Inconsistent checkpoint fileds. "
        + "LV = " + layoutVersion + " namespaceID = " + namespaceID
        + " cTime = " + cTime + ". Expecting respectively: "
        + si.layoutVersion + "; " + si.namespaceID + "; " + si.cTime);
  }
}
 
Example #10
Source File: PBHelper.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static NamespaceInfoProto convert(NamespaceInfo info) {
  return NamespaceInfoProto.newBuilder()
      .setBlockPoolID(info.getBlockPoolID())
      .setBuildVersion(info.getBuildVersion())
      .setUnused(0)
      .setStorageInfo(PBHelper.convert((StorageInfo)info))
      .setSoftwareVersion(info.getSoftwareVersion())
      .setCapabilities(info.getCapabilities())
      .build();
}
 
Example #11
Source File: IPCLoggerChannel.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public ListenableFuture<Boolean> canRollBack(final StorageInfo storage,
    final StorageInfo prevStorage, final int targetLayoutVersion) {
  return singleThreadExecutor.submit(new Callable<Boolean>() {
    @Override
    public Boolean call() throws IOException {
      return getProxy().canRollBack(journalId, storage, prevStorage,
          targetLayoutVersion);
    }
  });
}
 
Example #12
Source File: NamenodeRegistration.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public NamenodeRegistration(String address,
                            String httpAddress,
                            StorageInfo storageInfo,
                            NamenodeRole role) {
  super(storageInfo);
  this.rpcAddress = address;
  this.httpAddress = httpAddress;
  this.role = role;
}
 
Example #13
Source File: DatanodeRegistration.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public DatanodeRegistration(DatanodeID dn, StorageInfo info,
    ExportedBlockKeys keys, String softwareVersion) {
  super(dn);
  this.storageInfo = info;
  this.exportedKeys = keys;
  this.softwareVersion = softwareVersion;
}
 
Example #14
Source File: FSEditLog.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public synchronized boolean canRollBackSharedLog(StorageInfo prevStorage,
    int targetLayoutVersion) throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      return jas.getManager().canRollBack(storage, prevStorage,
          targetLayoutVersion);
    }
  }
  throw new IOException("No shared log found.");
}
 
Example #15
Source File: IPCLoggerChannel.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public ListenableFuture<Void> doUpgrade(final StorageInfo sInfo) {
  return singleThreadExecutor.submit(new Callable<Void>() {
    @Override
    public Void call() throws IOException {
      getProxy().doUpgrade(journalId, sInfo);
      return null;
    }
  });
}
 
Example #16
Source File: TestPBHelper.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testConvertStoragInfo() {
  StorageInfo info = getStorageInfo(NodeType.NAME_NODE);
  StorageInfoProto infoProto = PBHelper.convert(info);
  StorageInfo info2 = PBHelper.convert(infoProto, NodeType.NAME_NODE);
  assertEquals(info.getClusterID(), info2.getClusterID());
  assertEquals(info.getCTime(), info2.getCTime());
  assertEquals(info.getLayoutVersion(), info2.getLayoutVersion());
  assertEquals(info.getNamespaceID(), info2.getNamespaceID());
}
 
Example #17
Source File: QJournalProtocolTranslatorPB.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void doUpgrade(String journalId, StorageInfo sInfo) throws IOException {
  try {
    rpcProxy.doUpgrade(NULL_CONTROLLER,
        DoUpgradeRequestProto.newBuilder()
          .setJid(convertJournalId(journalId))
          .setSInfo(PBHelper.convert(sInfo))
          .build());
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
Example #18
Source File: ImageServlet.java    From hadoop with Apache License 2.0 5 votes vote down vote up
static String getParamStringForLog(RemoteEditLog log,
    StorageInfo remoteStorageInfo) {
  return "getedit=1&" + START_TXID_PARAM + "=" + log.getStartTxId()
      + "&" + END_TXID_PARAM + "=" + log.getEndTxId()
      + "&" + STORAGEINFO_PARAM + "=" +
        remoteStorageInfo.toColonSeparatedString();
}
 
Example #19
Source File: TestDFSStartupVersions.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Determines if the given Namenode version and Datanode version
 * are compatible with each other. Compatibility in this case mean
 * that the Namenode and Datanode will successfully start up and
 * will work together. The rules for compatibility,
 * taken from the DFS Upgrade Design, are as follows:
 * <pre>
 * 1. The data-node does regular startup (no matter which options 
 *    it is started with) if
 *       softwareLV == storedLV AND 
 *       DataNode.FSSCTime == NameNode.FSSCTime
 * 2. The data-node performs an upgrade if it is started without any 
 *    options and
 *       |softwareLV| > |storedLV| OR 
 *       (softwareLV == storedLV AND
 *        DataNode.FSSCTime < NameNode.FSSCTime)
 * 3. NOT TESTED: The data-node rolls back if it is started with
 *    the -rollback option and
 *       |softwareLV| >= |previous.storedLV| AND 
 *       DataNode.previous.FSSCTime <= NameNode.FSSCTime
 * 4. In all other cases the startup fails.
 * </pre>
 */
boolean isVersionCompatible(StorageInfo namenodeVer, StorageInfo datanodeVer) {
  // check #0
  if (namenodeVer.getNamespaceID() != datanodeVer.getNamespaceID()) {
    LOG.info("namespaceIDs are not equal: isVersionCompatible=false");
    return false;
  }
  // check #1
  int softwareLV = FSConstants.LAYOUT_VERSION;  // will also be Namenode's LV
  int storedLV = datanodeVer.getLayoutVersion();
  if (softwareLV == storedLV &&  
      datanodeVer.getCTime() == namenodeVer.getCTime()) 
    {
      LOG.info("layoutVersions and cTimes are equal: isVersionCompatible=true");
      return true;
    }
  // check #2
  long absSoftwareLV = Math.abs((long)softwareLV);
  long absStoredLV = Math.abs((long)storedLV);
  if (absSoftwareLV > absStoredLV ||
      (softwareLV == storedLV &&
       datanodeVer.getCTime() < namenodeVer.getCTime())) 
    {
      LOG.info("softwareLayoutVersion is newer OR namenode cTime is newer: isVersionCompatible=true");
      return true;
    }
  // check #4
  LOG.info("default case: isVersionCompatible=false");
  return false;
}
 
Example #20
Source File: AsyncLoggerSet.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public QuorumCall<AsyncLogger, Void> doUpgrade(StorageInfo sInfo) {
  Map<AsyncLogger, ListenableFuture<Void>> calls =
      Maps.newHashMap();
  for (AsyncLogger logger : loggers) {
    ListenableFuture<Void> future =
        logger.doUpgrade(sInfo);
    calls.put(logger, future);
  }
  return QuorumCall.create(calls);
}
 
Example #21
Source File: AsyncLoggerSet.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public QuorumCall<AsyncLogger, Boolean> canRollBack(StorageInfo storage,
    StorageInfo prevStorage, int targetLayoutVersion) {
  Map<AsyncLogger, ListenableFuture<Boolean>> calls =
      Maps.newHashMap();
  for (AsyncLogger logger : loggers) {
    ListenableFuture<Boolean> future =
        logger.canRollBack(storage, prevStorage, targetLayoutVersion);
    calls.put(logger, future);
  }
  return QuorumCall.create(calls);
}
 
Example #22
Source File: ImageServlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
static String getParamStringForLog(RemoteEditLog log,
    StorageInfo remoteStorageInfo) {
  return "getedit=1&" + START_TXID_PARAM + "=" + log.getStartTxId()
      + "&" + END_TXID_PARAM + "=" + log.getEndTxId()
      + "&" + STORAGEINFO_PARAM + "=" +
        remoteStorageInfo.toColonSeparatedString();
}
 
Example #23
Source File: IPCLoggerChannel.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public ListenableFuture<Boolean> canRollBack(final StorageInfo storage,
    final StorageInfo prevStorage, final int targetLayoutVersion) {
  return singleThreadExecutor.submit(new Callable<Boolean>() {
    @Override
    public Boolean call() throws IOException {
      return getProxy().canRollBack(journalId, storage, prevStorage,
          targetLayoutVersion);
    }
  });
}
 
Example #24
Source File: UpgradeUtilities.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static void createBlockPoolVersionFile(File bpDir,
    StorageInfo version, String bpid) throws IOException {
  // Create block pool version files
  if (DataNodeLayoutVersion.supports(
      LayoutVersion.Feature.FEDERATION, version.layoutVersion)) {
    File bpCurDir = new File(bpDir, Storage.STORAGE_DIR_CURRENT);
    BlockPoolSliceStorage bpStorage = new BlockPoolSliceStorage(version,
        bpid);
    File versionFile = new File(bpCurDir, "VERSION");
    StorageDirectory sd = new StorageDirectory(bpDir);
    bpStorage.writeProperties(versionFile, sd);
  }
}
 
Example #25
Source File: TestDFSStartupVersions.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Determines if the given Namenode version and Datanode version
 * are compatible with each other. Compatibility in this case mean
 * that the Namenode and Datanode will successfully start up and
 * will work together. The rules for compatibility,
 * taken from the DFS Upgrade Design, are as follows:
 * <pre>
 * 1. The data-node does regular startup (no matter which options 
 *    it is started with) if
 *       softwareLV == storedLV AND 
 *       DataNode.FSSCTime == NameNode.FSSCTime
 * 2. The data-node performs an upgrade if it is started without any 
 *    options and
 *       |softwareLV| > |storedLV| OR 
 *       (softwareLV == storedLV AND
 *        DataNode.FSSCTime < NameNode.FSSCTime)
 * 3. NOT TESTED: The data-node rolls back if it is started with
 *    the -rollback option and
 *       |softwareLV| >= |previous.storedLV| AND 
 *       DataNode.previous.FSSCTime <= NameNode.FSSCTime
 * 4. In all other cases the startup fails.
 * </pre>
 */
boolean isVersionCompatible(StorageInfo namenodeVer, StorageInfo datanodeVer) {
  // check #0
  if (namenodeVer.getNamespaceID() != datanodeVer.getNamespaceID()) {
    LOG.info("namespaceIDs are not equal: isVersionCompatible=false");
    return false;
  }
  // check #1
  int softwareLV = FSConstants.LAYOUT_VERSION;  // will also be Namenode's LV
  int storedLV = datanodeVer.getLayoutVersion();
  if (softwareLV == storedLV &&  
      datanodeVer.getCTime() == namenodeVer.getCTime()) 
    {
      LOG.info("layoutVersions and cTimes are equal: isVersionCompatible=true");
      return true;
    }
  // check #2
  long absSoftwareLV = Math.abs((long)softwareLV);
  long absStoredLV = Math.abs((long)storedLV);
  if (absSoftwareLV > absStoredLV ||
      (softwareLV == storedLV &&
       datanodeVer.getCTime() < namenodeVer.getCTime())) 
    {
      LOG.info("softwareLayoutVersion is newer OR namenode cTime is newer: isVersionCompatible=true");
      return true;
    }
  // check #4
  LOG.info("default case: isVersionCompatible=false");
  return false;
}
 
Example #26
Source File: QJournalProtocolServerSideTranslatorPB.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public DoUpgradeResponseProto doUpgrade(RpcController controller,
    DoUpgradeRequestProto request) throws ServiceException {
  StorageInfo si = PBHelper.convert(request.getSInfo(), NodeType.JOURNAL_NODE);
  try {
    impl.doUpgrade(convert(request.getJid()), si);
    return DoUpgradeResponseProto.getDefaultInstance();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example #27
Source File: QJournalProtocolTranslatorPB.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void doUpgrade(String journalId, StorageInfo sInfo) throws IOException {
  try {
    rpcProxy.doUpgrade(NULL_CONTROLLER,
        DoUpgradeRequestProto.newBuilder()
          .setJid(convertJournalId(journalId))
          .setSInfo(PBHelper.convert(sInfo))
          .build());
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
Example #28
Source File: UpgradeUtilities.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Create a <code>version</code> file for namenode inside the specified parent
 * directory.  If such a file already exists, it will be overwritten.
 * The given version string will be written to the file as the layout
 * version. None of the parameters may be null.
 *
 * @param parent directory where namenode VERSION file is stored
 * @param version StorageInfo to create VERSION file from
 * @param bpid Block pool Id
 *
 * @return the created version file
 */
public static File[] createNameNodeVersionFile(Configuration conf,
    File[] parent, StorageInfo version, String bpid) throws IOException {
  Storage storage = new NNStorage(conf, 
                            Collections.<URI>emptyList(), 
                            Collections.<URI>emptyList());
  storage.setStorageInfo(version);
  File[] versionFiles = new File[parent.length];
  for (int i = 0; i < parent.length; i++) {
    versionFiles[i] = new File(parent[i], "VERSION");
    StorageDirectory sd = new StorageDirectory(parent[i].getParentFile());
    storage.writeProperties(versionFiles[i], sd);
  }
  return versionFiles;
}
 
Example #29
Source File: TestPBHelper.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testConvertStoragInfo() {
  StorageInfo info = getStorageInfo(NodeType.NAME_NODE);
  StorageInfoProto infoProto = PBHelper.convert(info);
  StorageInfo info2 = PBHelper.convert(infoProto, NodeType.NAME_NODE);
  assertEquals(info.getClusterID(), info2.getClusterID());
  assertEquals(info.getCTime(), info2.getCTime());
  assertEquals(info.getLayoutVersion(), info2.getLayoutVersion());
  assertEquals(info.getNamespaceID(), info2.getNamespaceID());
}
 
Example #30
Source File: CheckpointSignature.java    From RDFS with Apache License 2.0 5 votes vote down vote up
void validateStorageInfo(StorageInfo si) throws IOException {
  if(layoutVersion != si.layoutVersion
      || namespaceID != si.namespaceID || cTime != si.cTime) {
    // checkpointTime can change when the image is saved - do not compare
    throw new IOException("Inconsistent checkpoint fileds. "
        + "LV = " + layoutVersion + " namespaceID = " + namespaceID
        + " cTime = " + cTime + ". Expecting respectively: "
        + si.layoutVersion + "; " + si.namespaceID + "; " + si.cTime);
  }
}