/** * Convenience method for {@link #setState(TachyonFile, SetStateOptions)} with default options. */ public void setState(TachyonFile file) throws IOException, TachyonException { setState(file, SetStateOptions.defaults()); }
/** * Pins the given file or folder (recursively pinning all children if a folder). Pinned files are * never evicted from memory. * * @param path The TachyonURI path as the input of the command * @return 0 if command is successful, -1 if an error occurred */ public int pin(TachyonURI path) { try { TachyonFile fd = mTfs.open(path); SetStateOptions options = new SetStateOptions.Builder(mTachyonConf).setPinned(true).build(); mTfs.setState(fd, options); System.out.println("File '" + path + "' was successfully pinned."); return 0; } catch (Exception e) { e.printStackTrace(); System.out.println("File '" + path + "' could not be pinned."); return -1; } }
/** * Unpins the given file or folder (recursively unpinning all children if a folder). Pinned files * are never evicted from memory, so this method will allow such files to be evicted. * * @param path The TachyonURI path as the input of the command * @return 0 if command is successful, -1 if an error occurred * @throws IOException */ public int unpin(TachyonURI path) throws IOException { try { SetStateOptions options = new SetStateOptions.Builder(mTachyonConf).setPinned(false).build(); TachyonFile fd = mTfs.open(path); mTfs.setState(fd, options); System.out.println("File '" + path + "' was successfully unpinned."); return 0; } catch (Exception e) { e.printStackTrace(); System.out.println("File '" + path + "' could not be unpinned."); return -1; } }