@Test public void catNotExistTest() throws IOException { int ret = mFsShell.cat(new String[] { "cat", "/testFile" }); Assert.assertEquals(-1, ret); }
public int cat(String argv[]) throws IOException { if (argv.length != 2) { System.out.println("Usage: tfs cat <path>"); } String path = argv[1]; String file = Utils.getFilePath(path); TachyonFS tachyonClient = TachyonFS.get(Utils.validatePath(path)); TachyonFile tFile = tachyonClient.getFile(file); if (tFile == null) { System.out.println(file + " does not exist."); return -1; } if (tFile.isFile()) { InStream is = tFile.getInStream(ReadType.NO_CACHE); byte[] buf = new byte[512]; int read = is.read(buf); while (read != -1) { System.out.write(buf, 0, read); read = is.read(buf); } return 0; } else { System.out.println(file + " is not a file."); return -1; } }
TFsShell { public int cat(String argv[]) throws IOException { if (argv.length != 2) { System.out.println("Usage: tfs cat <path>"); } String path = argv[1]; String file = Utils.getFilePath(path); TachyonFS tachyonClient = TachyonFS.get(Utils.validatePath(path)); TachyonFile tFile = tachyonClient.getFile(file); if (tFile == null) { System.out.println(file + " does not exist."); return -1; } if (tFile.isFile()) { InStream is = tFile.getInStream(ReadType.NO_CACHE); byte[] buf = new byte[512]; int read = is.read(buf); while (read != -1) { System.out.write(buf, 0, read); read = is.read(buf); } return 0; } else { System.out.println(file + " is not a file."); return -1; } } }
TFsShell { public int cat(String argv[]) throws IOException { if (argv.length != 2) { System.out.println("Usage: tfs cat <path>"); } String path = argv[1]; String file = Utils.getFilePath(path); TachyonFS tachyonClient = TachyonFS.get(Utils.validatePath(path)); TachyonFile tFile = tachyonClient.getFile(file); if (tFile == null) { System.out.println(file + " does not exist."); return -1; } if (tFile.isFile()) { InStream is = tFile.getInStream(ReadType.NO_CACHE); byte[] buf = new byte[512]; int read = is.read(buf); while (read != -1) { System.out.write(buf, 0, read); read = is.read(buf); } return 0; } else { System.out.println(file + " is not a file."); return -1; } }  }
TFsShell { public int cat(String argv[]) throws IOException { if (argv.length != 2) { System.out.println("Usage: tfs cat <path>"); } String path = argv[1]; String file = Utils.getFilePath(path); TachyonFS tachyonClient = TachyonFS.get(Utils.validatePath(path)); TachyonFile tFile = tachyonClient.getFile(file); if (tFile == null) { System.out.println(file + " does not exist."); return -1; } if (tFile.isFile()) { InStream is = tFile.getInStream(ReadType.NO_CACHE); byte[] buf = new byte[512]; int read = is.read(buf); while (read != -1) { System.out.write(buf, 0, read); read = is.read(buf); } return 0; } else { System.out.println(file + " is not a file."); 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 cat(String argv[]) throws IOException { if (argv.length != 2) { System.out.println("Usage: tfs cat <path>"); } String path = argv[1]; String file = Utils.getFilePath(path); TachyonFS tachyonClient = TachyonFS.get(Utils.validatePath(path)); TachyonFile tFile = tachyonClient.getFile(file); if (tFile == null) { System.out.println(file + " does not exist."); return -1; } if (tFile.isFile()) { InStream is = tFile.getInStream(ReadType.NO_CACHE); byte[] buf = new byte[512]; int read = is.read(buf); while (read != -1) { System.out.write(buf, 0, read); read = is.read(buf); } return 0; } else { System.out.println(file + " is not a file."); 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[]);  }