private boolean moveFiles() { if (trashDirectory == null) { LOG.error("Trash dir for replica " + replicaToDelete + " is null"); return false; } File trashDirFile = new File(trashDirectory); try { volume.getFileIoProvider().mkdirsWithExistsCheck( volume, trashDirFile); } catch (IOException e) { return false; } if (LOG.isDebugEnabled()) { LOG.debug("Moving files " + replicaToDelete.getBlockURI() + " and " + replicaToDelete.getMetadataURI() + " to trash."); } final String blockName = replicaToDelete.getBlockName(); final long genstamp = replicaToDelete.getGenerationStamp(); File newBlockFile = new File(trashDirectory, blockName); File newMetaFile = new File(trashDirectory, DatanodeUtil.getMetaName(blockName, genstamp)); try { return (replicaToDelete.renameData(newBlockFile.toURI()) && replicaToDelete.renameMeta(newMetaFile.toURI())); } catch (IOException e) { LOG.error("Error moving files to trash: " + replicaToDelete, e); } return false; }
fileIoProvider.mkdirsWithExistsCheck(volume, targetDir); } catch(IOException ioe) { LOG.warn("Failed to mkdirs " + targetDir);
File addFinalizedBlock(Block b, ReplicaInfo replicaInfo) throws IOException { File blockDir = DatanodeUtil.idToBlockDir(finalizedDir, b.getBlockId()); fileIoProvider.mkdirsWithExistsCheck(volume, blockDir); File blockFile = FsDatasetImpl.moveBlockFiles(b, replicaInfo, blockDir); File metaFile = FsDatasetUtil.getMetaFile(blockFile, b.getGenerationStamp()); if (dfsUsage instanceof CachingGetSpaceUsed) { ((CachingGetSpaceUsed) dfsUsage).incDfsUsed( b.getNumBytes() + metaFile.length()); } return blockFile; }