@Override public long getMetadataLength() { return getMetaFile().length(); }
@Override public OutputStream getMetadataOutputStream(boolean append) throws IOException { return new FileOutputStream(getMetaFile(), append); }
@Override public URI getMetadataURI() { return getMetaFile().toURI(); }
@Override public boolean renameMeta(URI destURI) throws IOException { return renameFile(getMetaFile(), new File(destURI)); }
@Override public void copyMetadata(URI destination) throws IOException { //for local replicas, we assume the destination URI is file getFileIoProvider().nativeCopyFileUnbuffered( getVolume(), getMetaFile(), new File(destination), true); }
@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); } }
@Override public LengthInputStream getMetadataInputStream(long offset) throws IOException { final File meta = getMetaFile(); return new LengthInputStream( getFileIoProvider().openAndSeek(getVolume(), meta, offset), meta.length()); }
@Override public boolean deleteMetadata() { return getFileIoProvider().fullyDelete(getVolume(), getMetaFile()); }
@Override public boolean metadataExists() { return getFileIoProvider().exists(getVolume(), getMetaFile()); }
@Override public void truncateBlock(long newLength) throws IOException { truncateBlock(getVolume(), getBlockFile(), getMetaFile(), getNumBytes(), newLength, getFileIoProvider()); }
final File oldmeta = oldReplica.getMetaFile(); final File newmeta = getMetaFile(); final FileIoProvider fileIoProvider = getFileIoProvider();
throw new IOException("detachBlock:Block not found. " + this); File meta = getMetaFile();