public static File getFile(FsDatasetSpi<?> fsd, String bpid, long bid) { return ((FsDatasetImpl)fsd).getFile(bpid, bid, false); }
/** * Find the file corresponding to the block and return it if it exists. */ File validateBlockFile(String bpid, long blockId) { //Should we check for metadata file too? final File f; synchronized(this) { f = getFile(bpid, blockId, false); } if(f != null ) { if(f.exists()) return f; // if file is not null, but doesn't exist - possibly disk failed datanode.checkDiskErrorAsync(); } if (LOG.isDebugEnabled()) { LOG.debug("blockId=" + blockId + ", f=" + f); } return null; }
@Override // FsDatasetSpi public synchronized Block getStoredBlock(String bpid, long blkid) throws IOException { File blockfile = getFile(bpid, blkid, false); if (blockfile == null) { return null; } final File metafile = FsDatasetUtil.findMetaFile(blockfile); final long gs = FsDatasetUtil.parseGenerationStamp(blockfile, metafile); return new Block(blkid, blockfile.length(), gs); }
@Override // FsDatasetSpi public synchronized Block getStoredBlock(String bpid, long blkid) throws IOException { File blockfile = getFile(bpid, blkid, false); if (blockfile == null) { return null; } final File metafile = FsDatasetUtil.findMetaFile(blockfile); final long gs = FsDatasetUtil.parseGenerationStamp(blockfile, metafile); return new Block(blkid, blockfile.length(), gs); }
@Override // FsDatasetSpi public synchronized boolean contains(final ExtendedBlock block) { final long blockId = block.getLocalBlock().getBlockId(); return getFile(block.getBlockPoolId(), blockId, false) != null; }
@Override // FsDatasetSpi public synchronized boolean contains(final ExtendedBlock block) { final long blockId = block.getLocalBlock().getBlockId(); return getFile(block.getBlockPoolId(), blockId, false) != null; }
/** * Return the File associated with a block, without first * checking that it exists. This should be used when the * next operation is going to open the file for read anyway, * and thus the exists check is redundant. * * @param touch if true then update the last access timestamp of the * block. Currently used for blocks on transient storage. */ private File getBlockFileNoExistsCheck(ExtendedBlock b, boolean touch) throws IOException { final File f; synchronized(this) { f = getFile(b.getBlockPoolId(), b.getLocalBlock().getBlockId(), touch); } if (f == null) { throw new IOException("Block " + b + " is not valid"); } return f; }
/** * Find the file corresponding to the block and return it if it exists. */ File validateBlockFile(String bpid, long blockId) { //Should we check for metadata file too? final File f; synchronized(this) { f = getFile(bpid, blockId, false); } if(f != null ) { if(f.exists()) return f; // if file is not null, but doesn't exist - possibly disk failed datanode.checkDiskErrorAsync(); } if (LOG.isDebugEnabled()) { LOG.debug("blockId=" + blockId + ", f=" + f); } return null; }
/** * Return the File associated with a block, without first * checking that it exists. This should be used when the * next operation is going to open the file for read anyway, * and thus the exists check is redundant. * * @param touch if true then update the last access timestamp of the * block. Currently used for blocks on transient storage. */ private File getBlockFileNoExistsCheck(ExtendedBlock b, boolean touch) throws IOException { final File f; synchronized(this) { f = getFile(b.getBlockPoolId(), b.getLocalBlock().getBlockId(), touch); } if (f == null) { throw new IOException("Block " + b + " is not valid"); } return f; }