@Test public void renameTest() throws IOException { StringBuilder toCompare = new StringBuilder(); mFsShell.mkdir(new String[] { "mkdir", "/testFolder1" }); toCompare.append(getCommandOutput(new String[] { "mkdir", "/testFolder1" })); Assert.assertNotNull(mTfs.getFile("/testFolder1")); mFsShell.rename(new String[] { "rename", "/testFolder1", "/testFolder" }); toCompare.append(getCommandOutput(new String[] { "mv", "/testFolder1", "/testFolder" })); Assert.assertEquals(toCompare.toString(), mOutput.toString()); Assert.assertNotNull(mTfs.getFile("/testFolder")); Assert.assertNull(mTfs.getFile("/testFolder1")); }
public int rename(String argv[]) throws IOException { if (argv.length != 3) { System.out.println("Usage: tfs mv <src> <dst>"); return -1; } String srcPath = argv[1]; String dstPath = argv[2]; String srcMasterAddr = Utils.validatePath(srcPath); String dstMasterAddr = Utils.validatePath(dstPath); if (!srcMasterAddr.startsWith(dstMasterAddr.substring(0, Constants.HEADER.length()))) { throw new IOException("The file system of source and destination must be the same"); } String srcFile = Utils.getFilePath(srcPath); String dstFile = Utils.getFilePath(dstPath); TachyonFS tachyonClient = TachyonFS.get(srcMasterAddr); if (tachyonClient.rename(srcFile, dstFile)) { System.out.println("Renamed " + srcFile + " to " + dstFile); return 0; } else { return -1; } }
TFsShell { public int rename(String argv[]) throws IOException { if (argv.length != 3) { System.out.println("Usage: tfs mv <src> <dst>"); return -1; } String srcPath = argv[1]; String dstPath = argv[2]; String srcMasterAddr = Utils.validatePath(srcPath); String dstMasterAddr = Utils.validatePath(dstPath); if (!srcMasterAddr.startsWith(dstMasterAddr.substring(0, Constants.HEADER.length()))) { throw new IOException("The file system of source and destination must be the same"); } String srcFile = Utils.getFilePath(srcPath); String dstFile = Utils.getFilePath(dstPath); TachyonFS tachyonClient = TachyonFS.get(srcMasterAddr); if (tachyonClient.rename(srcFile, dstFile)) { System.out.println("Renamed " + srcFile + " to " + dstFile); return 0; } else { return -1; } } }
TFsShell { public int rename(String argv[]) throws IOException { if (argv.length != 3) { System.out.println("Usage: tfs mv <src> <dst>"); return -1; } String srcPath = argv[1]; String dstPath = argv[2]; String srcMasterAddr = Utils.validatePath(srcPath); String dstMasterAddr = Utils.validatePath(dstPath); if (!srcMasterAddr.startsWith(dstMasterAddr.substring(0, Constants.HEADER.length()))) { throw new IOException("The file system of source and destination must be the same"); } String srcFile = Utils.getFilePath(srcPath); String dstFile = Utils.getFilePath(dstPath); TachyonFS tachyonClient = TachyonFS.get(srcMasterAddr); if (tachyonClient.rename(srcFile, dstFile)) { System.out.println("Renamed " + srcFile + " to " + dstFile); return 0; } else { return -1; } }  }
TFsShell { public int rename(String argv[]) throws IOException { if (argv.length != 3) { System.out.println("Usage: tfs mv <src> <dst>"); return -1; } String srcPath = argv[1]; String dstPath = argv[2]; String srcMasterAddr = Utils.validatePath(srcPath); String dstMasterAddr = Utils.validatePath(dstPath); if (!srcMasterAddr.startsWith(dstMasterAddr.substring(0, Constants.HEADER.length()))) { throw new IOException("The file system of source and destination must be the same"); } String srcFile = Utils.getFilePath(srcPath); String dstFile = Utils.getFilePath(dstPath); TachyonFS tachyonClient = TachyonFS.get(srcMasterAddr); if (tachyonClient.rename(srcFile, dstFile)) { System.out.println("Renamed " + srcFile + " to " + dstFile); return 0; } else { return -1; } }  static void main(String argv[]); int cat(String argv[]); int copyFromLocal(String argv[]); int copyToLocal(String argv[]); int count(String argv[]); int fileinfo(String argv[]); int location(String argv[]); int ls(String argv[]); int lsr(String argv[]); int mkdir(String argv[]); int pin(String argv[]); int unpin(String argv[]); void printUsage(); int rename(String argv[]); int report(String argv[]); int request(String argv[]); int rm(String argv[]); int run(String argv[]); int tail(String argv[]); int touch(String argv[]); }
TFsShell { public int rename(String argv[]) throws IOException { if (argv.length != 3) { System.out.println("Usage: tfs mv <src> <dst>"); return -1; } String srcPath = argv[1]; String dstPath = argv[2]; String srcMasterAddr = Utils.validatePath(srcPath); String dstMasterAddr = Utils.validatePath(dstPath); if (!srcMasterAddr.startsWith(dstMasterAddr.substring(0, Constants.HEADER.length()))) { throw new IOException("The file system of source and destination must be the same"); } String srcFile = Utils.getFilePath(srcPath); String dstFile = Utils.getFilePath(dstPath); TachyonFS tachyonClient = TachyonFS.get(srcMasterAddr); if (tachyonClient.rename(srcFile, dstFile)) { System.out.println("Renamed " + srcFile + " to " + dstFile); return 0; } else { return -1; } }  static void main(String argv[]); int cat(String argv[]); int copyFromLocal(String argv[]); int copyToLocal(String argv[]); int count(String argv[]); int fileinfo(String argv[]); int location(String argv[]); int ls(String argv[]); int lsr(String argv[]); int mkdir(String argv[]); int pin(String argv[]); int unpin(String argv[]); void printUsage(); int rename(String argv[]); int report(String argv[]); int request(String argv[]); int rm(String argv[]); int run(String argv[]); int tail(String argv[]); int touch(String argv[]);  }