@Test public void tailLargeFileTest() throws IOException { TestUtils.createByteFile(mTfs, "/testFile", WriteType.MUST_CACHE, 2048); mFsShell.tail(new String[] { "tail", "/testFile" }); byte expect[] = TestUtils.getIncreasingByteArray(1024, 1024); Assert.assertArrayEquals(expect, mOutput.toByteArray()); }
public int tail(String argv[]) throws IOException { if (argv.length != 2) { System.out.println("Usage: tfs tail <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[Constants.KB]; long bytesToRead = 0L; if (tFile.length() > Constants.KB) { bytesToRead = Constants.KB; } else { bytesToRead = tFile.length(); } is.skip(tFile.length() - bytesToRead); int read = is.read(buf); System.out.write(buf, 0, read); return 0; } else { System.out.println(file + " is not a file."); return -1; } }
TFsShell { public int tail(String argv[]) throws IOException { if (argv.length != 2) { System.out.println("Usage: tfs tail <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[Constants.KB]; long bytesToRead = 0L; if (tFile.length() > Constants.KB) { bytesToRead = Constants.KB; } else { bytesToRead = tFile.length(); } is.skip(tFile.length() - bytesToRead); int read = is.read(buf); System.out.write(buf, 0, read); return 0; } else { System.out.println(file + " is not a file."); return -1; } } }
TFsShell { public int tail(String argv[]) throws IOException { if (argv.length != 2) { System.out.println("Usage: tfs tail <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[Constants.KB]; long bytesToRead = 0L; if (tFile.length() > Constants.KB) { bytesToRead = Constants.KB; } else { bytesToRead = tFile.length(); } is.skip(tFile.length() - bytesToRead); int read = is.read(buf); System.out.write(buf, 0, read); return 0; } else { System.out.println(file + " is not a file."); return -1; } }  }
TFsShell { public int tail(String argv[]) throws IOException { if (argv.length != 2) { System.out.println("Usage: tfs tail <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[Constants.KB]; long bytesToRead = 0L; if (tFile.length() > Constants.KB) { bytesToRead = Constants.KB; } else { bytesToRead = tFile.length(); } is.skip(tFile.length() - bytesToRead); int read = is.read(buf); System.out.write(buf, 0, read); 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 tail(String argv[]) throws IOException { if (argv.length != 2) { System.out.println("Usage: tfs tail <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[Constants.KB]; long bytesToRead = 0L; if (tFile.length() > Constants.KB) { bytesToRead = Constants.KB; } else { bytesToRead = tFile.length(); } is.skip(tFile.length() - bytesToRead); int read = is.read(buf); System.out.write(buf, 0, read); 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[]);  }