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); } }
/** * Recover an unlinked tmp file on datanode restart. If the original block * does not exist, then the tmp file is renamed to be the * original file name and the original name is returned; otherwise the tmp * file is deleted and null is returned. */ File recoverTempUnlinkedBlock(File unlinkedTmp) throws IOException { File blockFile = FsDatasetUtil.getOrigFile(unlinkedTmp); if (blockFile.exists()) { // If the original block file still exists, then no recovery is needed. if (!fileIoProvider.delete(volume, unlinkedTmp)) { throw new IOException("Unable to cleanup unlinked tmp file " + unlinkedTmp); } return null; } else { fileIoProvider.rename(volume, unlinkedTmp, blockFile); return blockFile; } }
fileIoProvider.rename(getVolume(), oldmeta, newmeta); } catch (IOException e) { throw new IOException("Block " + oldReplicaInfo + " reopen failed. " + fileIoProvider.rename(getVolume(), oldBlockFile, newBlkFile); } catch (IOException e) { try { fileIoProvider.rename(getVolume(), newmeta, oldmeta); } catch (IOException ex) { LOG.warn("Cannot move meta file " + newmeta +
@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); } }