/** * Find the block's on-disk length */ @Override // FsDatasetSpi public long getLength(ExtendedBlock b) throws IOException { return getBlockFile(b).length(); }
/** * Find the block's on-disk length */ @Override // FsDatasetSpi public long getLength(ExtendedBlock b) throws IOException { return getBlockFile(b).length(); }
@Override public boolean getPinning(ExtendedBlock block) throws IOException { if (!blockPinningEnabled) { return false; } File f = getBlockFile(block); FileStatus fss = localFS.getFileStatus(new Path(f.getAbsolutePath())); return fss.getPermission().getStickyBit(); }
/** * Get File name for a given block. */ private File getBlockFile(ExtendedBlock b) throws IOException { return getBlockFile(b.getBlockPoolId(), b.getBlockId()); }
/** * Get File name for a given block. */ private File getBlockFile(ExtendedBlock b) throws IOException { return getBlockFile(b.getBlockPoolId(), b.getBlockId()); }
@Override public boolean getPinning(ExtendedBlock block) throws IOException { if (!blockPinningEnabled) { return false; } File f = getBlockFile(block); FileStatus fss = localFS.getFileStatus(new Path(f.getAbsolutePath())); return fss.getPermission().getStickyBit(); }
@Override // FsDatasetSpi public LengthInputStream getMetaDataInputStream(ExtendedBlock b) throws IOException { File meta = FsDatasetUtil.getMetaFile(getBlockFile(b), b.getGenerationStamp()); if (meta == null || !meta.exists()) { return null; } if (isNativeIOAvailable) { return new LengthInputStream( NativeIO.getShareDeleteFileInputStream(meta), meta.length()); } return new LengthInputStream(new FileInputStream(meta), meta.length()); }
@Override // FsDatasetSpi public LengthInputStream getMetaDataInputStream(ExtendedBlock b) throws IOException { File meta = FsDatasetUtil.getMetaFile(getBlockFile(b), b.getGenerationStamp()); if (meta == null || !meta.exists()) { return null; } if (isNativeIOAvailable) { return new LengthInputStream( NativeIO.getShareDeleteFileInputStream(meta), meta.length()); } return new LengthInputStream(new FileInputStream(meta), meta.length()); }
@Override public void setPinning(ExtendedBlock block) throws IOException { if (!blockPinningEnabled) { return; } File f = getBlockFile(block); Path p = new Path(f.getAbsolutePath()); FsPermission oldPermission = localFS.getFileStatus( new Path(f.getAbsolutePath())).getPermission(); //sticky bit is used for pinning purpose FsPermission permission = new FsPermission(oldPermission.getUserAction(), oldPermission.getGroupAction(), oldPermission.getOtherAction(), true); localFS.setPermission(p, permission); }
@Override public void setPinning(ExtendedBlock block) throws IOException { if (!blockPinningEnabled) { return; } File f = getBlockFile(block); Path p = new Path(f.getAbsolutePath()); FsPermission oldPermission = localFS.getFileStatus( new Path(f.getAbsolutePath())).getPermission(); //sticky bit is used for pinning purpose FsPermission permission = new FsPermission(oldPermission.getUserAction(), oldPermission.getGroupAction(), oldPermission.getOtherAction(), true); localFS.setPermission(p, permission); }
public static File getBlockFile(FsDatasetSpi<?> fsd, String bpid, Block b ) throws IOException { return ((FsDatasetImpl)fsd).getBlockFile(bpid, b.getBlockId()); }
@Override // FsDatasetSpi public BlockLocalPathInfo getBlockLocalPathInfo(ExtendedBlock block) throws IOException { synchronized(this) { final Replica replica = volumeMap.get(block.getBlockPoolId(), block.getBlockId()); if (replica == null) { throw new ReplicaNotFoundException(block); } if (replica.getGenerationStamp() < block.getGenerationStamp()) { throw new IOException( "Replica generation stamp < block generation stamp, block=" + block + ", replica=" + replica); } else if (replica.getGenerationStamp() > block.getGenerationStamp()) { block.setGenerationStamp(replica.getGenerationStamp()); } } File datafile = getBlockFile(block); File metafile = FsDatasetUtil.getMetaFile(datafile, block.getGenerationStamp()); BlockLocalPathInfo info = new BlockLocalPathInfo(block, datafile.getAbsolutePath(), metafile.getAbsolutePath()); return info; }
@Override // FsDatasetSpi public BlockLocalPathInfo getBlockLocalPathInfo(ExtendedBlock block) throws IOException { synchronized(this) { final Replica replica = volumeMap.get(block.getBlockPoolId(), block.getBlockId()); if (replica == null) { throw new ReplicaNotFoundException(block); } if (replica.getGenerationStamp() < block.getGenerationStamp()) { throw new IOException( "Replica generation stamp < block generation stamp, block=" + block + ", replica=" + replica); } else if (replica.getGenerationStamp() > block.getGenerationStamp()) { block.setGenerationStamp(replica.getGenerationStamp()); } } File datafile = getBlockFile(block); File metafile = FsDatasetUtil.getMetaFile(datafile, block.getGenerationStamp()); BlockLocalPathInfo info = new BlockLocalPathInfo(block, datafile.getAbsolutePath(), metafile.getAbsolutePath()); return info; }