@Override // Object public boolean equals(Object o) { return super.equals(o); }
@Override public void truncateBlock(long newLength) throws IOException { truncateBlock(getVolume(), getBlockFile(), getMetaFile(), getNumBytes(), newLength, getFileIoProvider()); }
@Override public ReplicaRecoveryInfo createInfo() { return new ReplicaRecoveryInfo(original.getBlockId(), original.getBytesOnDisk(), original.getGenerationStamp(), original.getState()); } }
@Override public InputStream getDataInputStream(long seekOffset) throws IOException { return getDataInputStream(getBlockFile(), seekOffset); }
@Override public void bumpReplicaGS(long newGS) throws IOException { long oldGS = getGenerationStamp(); final File oldmeta = getMetaFile(); setGenerationStamp(newGS); final File newmeta = getMetaFile(); // rename meta file to new GS if (LOG.isDebugEnabled()) { LOG.debug("Renaming " + oldmeta + " to " + newmeta); } try { // calling renameMeta on the ReplicaInfo doesn't work here getFileIoProvider().rename(getVolume(), oldmeta, newmeta); } catch (IOException e) { setGenerationStamp(oldGS); // restore old GS throw new IOException("Block " + this + " reopen failed. " + " Unable to move meta file " + oldmeta + " to " + newmeta, e); } }
final File file = getBlockFile(); final FileIoProvider fileIoProvider = getFileIoProvider(); if (file == null || getVolume() == null) { throw new IOException("detachBlock:Block not found. " + this); File meta = getMetaFile(); int linkCount = fileIoProvider.getHardLinkCount(getVolume(), file); if (linkCount > 1) { DataNode.LOG.info("Breaking hardlink for " + linkCount + "x-linked " + "block " + this); breakHardlinks(file, this); if (fileIoProvider.getHardLinkCount(getVolume(), meta) > 1) { breakHardlinks(meta, this);
@Override public OutputStream getDataOutputStream(boolean append) throws IOException { return getFileIoProvider().getFileOutputStream( getVolume(), getBlockFile(), append); }
@Override public boolean deleteMetadata() { return getFileIoProvider().fullyDelete(getVolume(), getMetaFile()); }
/** * Sync the parent directory changes to durable device. * @throws IOException */ public void fsyncDirectory() throws IOException { File dir = getDir(); try { getFileIoProvider().dirSync(getVolume(), getDir()); } catch (IOException e) { throw new IOException("Failed to sync " + dir, e); } } }
/** * 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 renameFile(File srcfile, File destfile) throws IOException { try { getFileIoProvider().rename(getVolume(), srcfile, destfile); return true; } catch (IOException e) { throw new IOException("Failed to move block file for " + this + " from " + srcfile + " to " + destfile.getAbsolutePath(), e); } }
@Override public boolean renameData(URI destURI) throws IOException { return renameFile(getBlockFile(), new File(destURI)); }
/** * Get the full path of this replica's data file. * @return the full path of this replica's data file */ @VisibleForTesting public File getBlockFile() { return new File(getDir(), getBlockName()); }
@Override public void setPinning(LocalFileSystem localFS) throws IOException { File f = getBlockFile(); Path p = new Path(f.getAbsolutePath()); setPinning(localFS, p); }
@Override public boolean getPinning(LocalFileSystem localFS) throws IOException { return getPinning(localFS, new Path(getBlockFile().getAbsolutePath())); }
final File oldBlockFile = oldReplica.getBlockFile(); final File oldmeta = oldReplica.getMetaFile(); final File newmeta = getMetaFile(); final FileIoProvider fileIoProvider = getFileIoProvider(); " Unable to move block file " + oldReplica.getBlockFile() + " to rbw dir " + newBlkFile, e);
@Override public long getBlockDataLength() { return getBlockFile().length(); }
finalizedReplica.fsyncDirectory(); LocalReplica localReplica = (LocalReplica) replicaInfo; localReplica.fsyncDirectory();
@Override public long getBytesOnDisk() { return original.getBytesOnDisk(); }