Esempio n. 1
0
 public void reportLostFile(TachyonFile file) throws IOException {
   FileSystemMasterClient masterClient = mContext.acquireMasterClient();
   try {
     masterClient.reportLostFile(file.getFileId());
   } finally {
     mContext.releaseMasterClient(masterClient);
   }
 }
Esempio n. 2
0
 /**
  * Removes the file from Tachyon Storage. The underlying under storage system file will not be
  * removed. If the file is a folder, its contents will be freed recursively. This method is
  * asynchronous and will be propagated to the workers through their heartbeats.
  *
  * @param file the handler for the file
  * @throws IOException if the master is unable to free the file
  */
 @Override
 public void free(TachyonFile file) throws IOException {
   FileSystemMasterClient masterClient = mContext.acquireMasterClient();
   try {
     masterClient.free(file.getFileId(), true);
   } finally {
     mContext.releaseMasterClient(masterClient);
   }
 }
Esempio n. 3
0
 /**
  * Renames an existing file in Tachyon space to another path in Tachyon space.
  *
  * @param src The file handler for the source file
  * @param dst The path of the destination file, this path should not exist
  * @return true if successful, false otherwise
  * @throws IOException if the destination already exists or is invalid
  */
 @Override
 public boolean rename(TachyonFile src, TachyonURI dst) throws IOException {
   FileSystemMasterClient masterClient = mContext.acquireMasterClient();
   try {
     return masterClient.renameFile(src.getFileId(), dst.getPath());
   } finally {
     mContext.releaseMasterClient(masterClient);
   }
 }
Esempio n. 4
0
 /**
  * Sets the pin status of a file. A pinned file will never be evicted for any reason. The pin
  * status is propagated asynchronously from this method call on the worker heartbeats.
  *
  * @param file the file handler for the file to pin
  * @param pinned true to pin the file, false to unpin it
  * @throws IOException if an error occurs during the pin operation
  */
 @Override
 public void setPin(TachyonFile file, boolean pinned) throws IOException {
   FileSystemMasterClient masterClient = mContext.acquireMasterClient();
   try {
     masterClient.setPinned(file.getFileId(), pinned);
   } finally {
     mContext.releaseMasterClient(masterClient);
   }
 }
Esempio n. 5
0
 /**
  * If the file is a folder, return the {@link FileInfo} of all the direct entries in it. Otherwise
  * return the FileInfo for the file. The file infos are snapshots of the file metadata, and the
  * locations, last modified time, and path are possibly inconsistent.
  *
  * @param file the handler for the file
  * @return a list of FileInfos representing the files which are children of the given file
  * @throws IOException if the file does not exist
  */
 @Override
 public List<FileInfo> listStatus(TachyonFile file) throws IOException {
   FileSystemMasterClient masterClient = mContext.acquireMasterClient();
   try {
     return masterClient.getFileInfoList(file.getFileId());
   } finally {
     mContext.releaseMasterClient(masterClient);
   }
 }
Esempio n. 6
0
 // TODO(calvin): Consider FileInfo caching.
 @Override
 public FileInfo getInfo(TachyonFile file) throws IOException {
   FileSystemMasterClient masterClient = mContext.acquireMasterClient();
   try {
     return masterClient.getFileInfo(file.getFileId());
   } catch (IOException e) {
     return null;
   } finally {
     mContext.releaseMasterClient(masterClient);
   }
 }
Esempio n. 7
0
 /**
  * Gets a {@link FileInStream} for the specified file. The stream's settings can be customized by
  * setting the options parameter. The user should close the stream after finishing the operations
  * on it.
  *
  * @param file the handler for the file.
  * @param options the set of options specific to this operation.
  * @return an input stream to read the file
  * @throws IOException if the file does not exist or the stream cannot be opened
  */
 public FileInStream getInStream(TachyonFile file, ClientOptions options) throws IOException {
   FileSystemMasterClient masterClient = mContext.acquireMasterClient();
   try {
     // TODO(calvin): Make sure the file is not a folder.
     FileInfo info = masterClient.getFileInfo(file.getFileId());
     if (info.isFolder) {
       throw new IOException("Cannot get an instream to a folder.");
     }
     return new FileInStream(info, options);
   } finally {
     mContext.releaseMasterClient(masterClient);
   }
 }