static void rename(VolumeManager fs, Path src, Path dst) throws IOException { if (!fs.rename(src, dst)) { throw new IOException("Rename " + src + " to " + dst + " returned false "); } }
fs.rename(fileStatus.getPath(), new Path(tableInfo.importDir, newName));
final Path originalPath = new Path(sourceDir, renameEntry.getKey()); Path newPath = new Path(bulkDir, renameEntry.getValue()); Boolean success = fs.rename(originalPath, newPath); if (success && log.isTraceEnabled()) log.trace("tid {} moved {} to {}", fmtTid, originalPath, newPath);
Path newPath = new Path(bulkDir, newName); try { fs.rename(fileStatus.getPath(), newPath); log.debug("Moved {} to {}", fileStatus.getPath(), newPath); } catch (IOException E1) {
+ Constants.HDFS_TABLES_DIR + Path.SEPARATOR + RootTable.ID; fs.mkdirs(new Path(newPath)); if (!fs.rename(oldPath, new Path(newPath))) { throw new IOException("Failed to move root tablet from " + oldPath + " to " + newPath);
Path orig = new Path(failure); Path dest = new Path(error, orig.getName()); fs.rename(orig, dest); log.debug("tid " + tid + " renamed " + orig + " to " + dest + ": import failed");
static void rename(VolumeManager fs, Path src, Path dst) throws IOException { if (!fs.rename(src, dst)) { throw new IOException("Rename " + src + " to " + dst + " returned false "); } }
protected void merge(VolumeManager fs, Path src, Path dest) throws IOException { for (FileStatus child : fs.listStatus(src)) { final String childName = child.getPath().getName(); final Path childInSrc = new Path(src, childName), childInDest = new Path(dest, childName); if (child.isFile()) { if (fs.exists(childInDest)) { log.warn("File already exists in archive, ignoring. " + childInDest); } else { fs.rename(childInSrc, childInDest); } } else if (child.isDirectory()) { if (fs.exists(childInDest)) { // Recurse merge(fs, childInSrc, childInDest); } else { fs.rename(childInSrc, childInDest); } } else { // Symlinks shouldn't exist in table directories.. log.warn("Ignoring archiving of non file/directory: " + child); } } }
return fs.rename(fileToArchive, fileArchivePath);
Path newPath = new Path(bulkDir, newName); try { fs.rename(fileStatus.getPath(), newPath); log.debug("Moved " + fileStatus.getPath() + " to " + newPath); } catch (IOException E1) {
protected void archiveFile(VolumeManager fs, String dir, String tableId) throws IOException { Path tableDirectory = new Path(dir, tableId); Volume v = fs.getVolumeByPath(tableDirectory); String basePath = v.getBasePath(); // Path component of URI String tableDirPath = tableDirectory.toUri().getPath(); // Just the suffix of the path (after the Volume's base path) String tableDirSuffix = tableDirPath.substring(basePath.length()); // Remove a leading path separator char because Path will treat the "child" as an absolute path // with it if (Path.SEPARATOR_CHAR == tableDirSuffix.charAt(0)) { if (tableDirSuffix.length() > 1) { tableDirSuffix = tableDirSuffix.substring(1); } else { tableDirSuffix = ""; } } // Get the file archive directory on this volume final Path fileArchiveDir = new Path(basePath, ServerConstants.FILE_ARCHIVE_DIR); // Make sure it exists just to be safe fs.mkdirs(fileArchiveDir); // The destination to archive this table to final Path destTableDir = new Path(fileArchiveDir, tableDirSuffix); log.debug("Archiving " + tableDirectory + " to " + tableDirectory); if (fs.exists(destTableDir)) { merge(fs, tableDirectory, destTableDir); } else { fs.rename(tableDirectory, destTableDir); } }
fs.rename(fileStatus.getPath(), new Path(tableInfo.importDir, newName));
private void moveRootTabletToRootTable(IZooReaderWriter zoo) throws Exception { String dirZPath = ZooUtil.getRoot(getInstance()) + RootTable.ZROOT_TABLET_PATH; if (!zoo.exists(dirZPath)) { Path oldPath = fs.getFullPath(FileType.TABLE, "/" + MetadataTable.ID + "/root_tablet"); if (fs.exists(oldPath)) { String newPath = fs.choose(Optional.of(RootTable.ID), ServerConstants.getBaseUris()) + Constants.HDFS_TABLES_DIR + Path.SEPARATOR + RootTable.ID; fs.mkdirs(new Path(newPath)); if (!fs.rename(oldPath, new Path(newPath))) { throw new IOException("Failed to move root tablet from " + oldPath + " to " + newPath); } log.info("Upgrade renamed " + oldPath + " to " + newPath); } Path location = null; for (String basePath : ServerConstants.getTablesDirs()) { Path path = new Path(basePath + "/" + RootTable.ID + RootTable.ROOT_TABLET_LOCATION); if (fs.exists(path)) { if (location != null) { throw new IllegalStateException( "Root table at multiple locations " + location + " " + path); } location = path; } } if (location == null) throw new IllegalStateException("Failed to find root tablet"); log.info("Upgrade setting root table location in zookeeper " + location); zoo.putPersistentData(dirZPath, location.toString().getBytes(), NodeExistsPolicy.FAIL); } }
Path orig = new Path(failure); Path dest = new Path(error, orig.getName()); fs.rename(orig, dest); log.debug("tid " + tid + " renamed " + orig + " to " + dest + ": import failed");