static File getMetaFile(File f, long gs) { return new File(f.getParent(), DatanodeUtil.getMetaName(f.getName(), gs)); }
/** * Get the full path of this replica's meta file. * @return the full path of this replica's meta file */ @VisibleForTesting public File getMetaFile() { return new File(getDir(), DatanodeUtil.getMetaName(getBlockName(), getGenerationStamp())); }
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; }
static File getMetaFile(File f, long gs) { return new File(f.getParent(), DatanodeUtil.getMetaName(f.getName(), gs)); }
static File getMetaFile(File f, long gs) { return new File(f.getParent(), DatanodeUtil.getMetaName(f.getName(), gs)); }
/** * 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())); }
public boolean changeGenStampOfBlock(int dnIndex, ExtendedBlock blk, long newGenStamp) throws IOException { File blockFile = getBlockFile(dnIndex, blk); File metaFile = FsDatasetUtil.findMetaFile(blockFile); return metaFile.renameTo(new File(DatanodeUtil.getMetaName( blockFile.getAbsolutePath(), newGenStamp))); }
protected final boolean verifyBlockDeletedFromDir(File dir, LocatedBlocks locatedBlocks) { for (LocatedBlock lb : locatedBlocks.getLocatedBlocks()) { File targetDir = DatanodeUtil.idToBlockDir(dir, lb.getBlock().getBlockId()); File blockFile = new File(targetDir, lb.getBlock().getBlockName()); if (blockFile.exists()) { LOG.warn("blockFile: " + blockFile.getAbsolutePath() + " exists after deletion."); return false; } File metaFile = new File(targetDir, DatanodeUtil.getMetaName(lb.getBlock().getBlockName(), lb.getBlock().getGenerationStamp())); if (metaFile.exists()) { LOG.warn("metaFile: " + metaFile.getAbsolutePath() + " exists after deletion."); return false; } } return true; }