Exemplo n.º 1
0
 void finalizeUpgrade(String bpID) throws IOException {
   for (StorageDirectory sd : storageDirs) {
     File prevDir = sd.getPreviousDir();
     if (prevDir.exists()) {
       throw new RuntimeException("未实现");
     } else {
       BlockPoolSliceStorage bpStorage = bpStorageMap.get(bpID);
       bpStorage.doFinalize(sd.getCurrentDir());
     }
   }
 }
Exemplo n.º 2
0
  synchronized List<StorageLocation> addStorageLocations(
      DataNode datanode,
      NamespaceInfo nsInfo,
      Collection<StorageLocation> dataDirs,
      StartupOption startOpt)
      throws IOException {

    final String bpid = nsInfo.getBlockPoolID();
    List<StorageLocation> successVolumes = Lists.newArrayList();

    for (StorageLocation dataDir : dataDirs) {
      File root = dataDir.getFile();
      if (!containsStorageDir(root)) {
        try {
          StorageDirectory sd = loadStorageDirectory(datanode, nsInfo, root, startOpt);
          addStorageDir(sd);
        } catch (IOException e) {
          LOG.warn(e);
          continue;
        }
      } else {
        LOG.info("Storage directory " + dataDir + " has already been used.");
      }
      List<File> bpDataDirs = new ArrayList<File>();
      bpDataDirs.add(BlockPoolSliceStorage.getBpRoot(bpid, new File(root, STORAGE_DIR_CURRENT)));

      try {
        makeBlockPoolDataDir(bpDataDirs, null);
        BlockPoolSliceStorage bpStorage = this.bpStorageMap.get(bpid);
        if (bpStorage == null) {
          bpStorage =
              new BlockPoolSliceStorage(
                  nsInfo.getNamespaceID(), bpid, nsInfo.getCTime(), nsInfo.getClusterID());
        }
        bpStorage.recoverTransitionRead(datanode, nsInfo, bpDataDirs, startOpt);
        addBlockPoolStorage(bpid, bpStorage);
      } catch (IOException e) {
        LOG.warn("Failed to add storage for block pool: " + bpid + " : " + e.getMessage());
        continue;
      }
      successVolumes.add(dataDir);
    }

    return successVolumes;
  }