Exemplo n.º 1
0
 File addBlock(Block b, File f) throws IOException {
   File blockDir = DatanodeUtil.idToBlockDir(finalizedDir, b.getBlockId());
   if (!blockDir.exists()) {
     if (!blockDir.mkdirs()) {
       throw new IOException("Failed to mkdirs " + blockDir);
     }
   }
   File blockFile = FsDatasetImpl.moveBlockFiles(b, f, blockDir);
   File metaFile = FsDatasetUtil.getMetaFile(blockFile, b.getGenerationStamp());
   dfsUsage.incDfsUsed(b.getNumBytes() + metaFile.length());
   return blockFile;
 }
Exemplo n.º 2
0
  void addToReplicasMap(
      ReplicaMap volumeMap,
      File dir,
      final RamDiskReplicaTracker lazyWriteReplicaMap,
      boolean isFinalized)
      throws IOException {
    File files[] = FileUtil.listFiles(dir);

    for (File file : files) {
      if (file.isDirectory()) {
        addToReplicasMap(volumeMap, file, lazyWriteReplicaMap, isFinalized);
      }
      if (isFinalized && FsDatasetUtil.isUnlinkTmpFile(file)) {
        throw new RuntimeException("未实现");
      }
      if (!Block.isBlockFilename(file)) continue;
      long genStamp = FsDatasetUtil.getGenerationStampFromFile(files, file);
      long blockId = Block.filename2id(file.getName());
      ReplicaInfo newReplica = null;
      if (isFinalized) {
        newReplica =
            new FinalizedReplica(blockId, file.length(), genStamp, volume, file.getParentFile());
      } else {
        boolean loadRwr = true;
        File restartMeta =
            new File(file.getParent() + File.pathSeparator + "." + file.getName() + ".restart");
        try {
          if (!restartMeta.delete()) {
            FsDatasetImpl.LOG.warn("Failed to delete restart meta file: " + restartMeta.getPath());
          }
        } finally {
        }
        if (loadRwr) {
          LOG.error("未实现");
          continue;
        }
      }
      ReplicaInfo oldReplica = volumeMap.get(bpid, newReplica.getBlockId());
      if (oldReplica == null) {
        volumeMap.add(bpid, newReplica);
      } else {
        throw new RuntimeException("未实现");
      }
      if (newReplica.getVolume().isTransientStorage()) {
        throw new RuntimeException("未实现");
      } else {
        lazyWriteReplicaMap.discardReplica(bpid, blockId, false);
      }
    }
  }
Exemplo n.º 3
0
 File createRbwFile(Block b) throws IOException {
   File f = new File(rbwDir, b.getBlockName());
   return DatanodeUtil.createTmpFile(b, f);
 }