/** * Copy the block and meta files for the given block to the given destination. * @return the new meta and block files. * @throws IOException */ static File[] copyBlockFiles(long blockId, long genStamp, ReplicaInfo srcReplica, File destRoot, boolean calculateChecksum, int smallBufferSize, final Configuration conf) throws IOException { final File destDir = DatanodeUtil.idToBlockDir(destRoot, blockId); // blockName is same as the filename for the block final File dstFile = new File(destDir, srcReplica.getBlockName()); final File dstMeta = FsDatasetUtil.getMetaFile(dstFile, genStamp); return copyBlockFiles(srcReplica, dstMeta, dstFile, calculateChecksum, smallBufferSize, conf); }
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; }
File newBlkFile = new File(getRbwDir(bpid), replicaInfo.getBlockName()); LocalReplicaInPipeline newReplicaInfo = new ReplicaBuilder(ReplicaState.RBW) .setBlockId(replicaInfo.getBlockId())
/** * Get the full path of this replica's data file * @return the full path of this replica's data file */ public File getBlockFile() { return new File(getDir(), getBlockName()); }
/** * Get the full path of this replica's data file * @return the full path of this replica's data file */ public File getBlockFile() { return new File(getDir(), getBlockName()); }
/** * Get the full path of this replica's meta file * @return the full path of this replica's meta file */ public File getMetaFile() { return new File(getDir(), DatanodeUtil.getMetaName(getBlockName(), getGenerationStamp())); }
/** * Get the full path of this replica's meta file * @return the full path of this replica's meta file */ public File getMetaFile() { return new File(getDir(), DatanodeUtil.getMetaName(getBlockName(), getGenerationStamp())); }