@Override public boolean rename(Path src, Path dst) throws IOException { // Make sure for existing destination we return false as per FileSystem api contract return super.isFile(dst) ? false : super.rename(src, dst); } }
@Override public boolean rename(Path src, Path dst) throws IOException { // Make sure for existing destination we return false as per FileSystem api contract return super.isFile(dst) ? false : super.rename(src, dst); } }
localFS = FileSystem.getLocal(new Configuration()); localFS.rename (tmpIndexFilePath, indexFilePath);
localFS = FileSystem.getLocal(new Configuration()); localFS.rename (tmpIndexFilePath, indexFilePath);
localFS = FileSystem.getLocal(new Configuration()); localFS.rename (tmpIndexFilePath, indexFilePath);
localFS = FileSystem.getLocal(new Configuration()); localFS.rename (tmpIndexFilePath, indexFilePath);
localFS = FileSystem.getLocal(new Configuration()); localFS.rename (tmpIndexFilePath, indexFilePath);
localFS = FileSystem.getLocal(new Configuration()); localFS.rename (tmpIndexFilePath, indexFilePath);
/** * Tests a simple rename of a directory. */ @Test public void testRenameDirectory() throws IOException { Path src = new Path(TEST_ROOT_DIR, "dir1"); Path dst = new Path(TEST_ROOT_DIR, "dir2"); fileSys.delete(src, true); fileSys.delete(dst, true); assertTrue(fileSys.mkdirs(src)); assertTrue(fileSys.rename(src, dst)); assertTrue(fileSys.exists(dst)); assertFalse(fileSys.exists(src)); }
/** * Tests a simple rename of a directory. */ @Test public void testRenameDirectory() throws IOException { Path src = new Path(TEST_ROOT_DIR, "dir1"); Path dst = new Path(TEST_ROOT_DIR, "dir2"); fileSys.delete(src, true); fileSys.delete(dst, true); assertTrue(fileSys.mkdirs(src)); assertTrue(fileSys.rename(src, dst)); assertTrue(fileSys.exists(dst)); assertFalse(fileSys.exists(src)); }
writeFile(fileSys, new Path(src, "file2"), 1); assertTrue(fileSys.exists(dst)); assertTrue(fileSys.rename(src, dst)); assertTrue(fileSys.exists(dst)); assertTrue(fileSys.exists(new Path(dst, "dir3")));
writeFile(fileSys, new Path(src, "file2"), 1); assertTrue(fileSys.mkdirs(dst)); assertTrue(fileSys.rename(src, dst)); assertTrue(fileSys.exists(dst)); assertTrue(fileSys.exists(new Path(dst, "file1")));
writeFile(fileSys, new Path(src, "file2"), 1); assertTrue(fileSys.mkdirs(dst)); assertTrue(fileSys.rename(src, dst)); assertTrue(fileSys.exists(dst)); assertTrue(fileSys.exists(new Path(dst, "file1")));
writeFile(fileSys, new Path(src, "file2"), 1); assertTrue(fileSys.exists(dst)); assertTrue(fileSys.rename(src, dst)); assertTrue(fileSys.exists(dst)); assertTrue(fileSys.exists(new Path(dst, "dir3")));
void verifyRename(Path srcPath, Path dstPath, boolean dstIsDir) throws Exception { localFs.delete(srcPath,true); localFs.delete(dstPath,true); Path realDstPath = dstPath; if (dstIsDir) { localFs.mkdirs(dstPath); realDstPath = new Path(dstPath, srcPath.getName()); } // ensure file + checksum are moved writeFile(localFs, srcPath, 1); assertTrue(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertTrue(localFs.exists(localFs.getChecksumFile(realDstPath))); // create a file with no checksum, rename, ensure dst checksum is removed writeFile(localFs.getRawFileSystem(), srcPath, 1); assertFalse(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertFalse(localFs.exists(localFs.getChecksumFile(realDstPath))); // create file with checksum, rename over prior dst with no checksum writeFile(localFs, srcPath, 1); assertTrue(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertTrue(localFs.exists(localFs.getChecksumFile(realDstPath))); }
void verifyRename(Path srcPath, Path dstPath, boolean dstIsDir) throws Exception { localFs.delete(srcPath,true); localFs.delete(dstPath,true); Path realDstPath = dstPath; if (dstIsDir) { localFs.mkdirs(dstPath); realDstPath = new Path(dstPath, srcPath.getName()); } // ensure file + checksum are moved writeFile(localFs, srcPath, 1); assertTrue(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertTrue(localFs.exists(localFs.getChecksumFile(realDstPath))); // create a file with no checksum, rename, ensure dst checksum is removed writeFile(localFs.getRawFileSystem(), srcPath, 1); assertFalse(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertFalse(localFs.exists(localFs.getChecksumFile(realDstPath))); // create file with checksum, rename over prior dst with no checksum writeFile(localFs, srcPath, 1); assertTrue(localFs.exists(localFs.getChecksumFile(srcPath))); assertTrue(localFs.rename(srcPath, dstPath)); assertTrue(localFs.exists(localFs.getChecksumFile(realDstPath))); }