Search in sources :

Example 1 with FileSystemCommandOptions

use of alluxio.thrift.FileSystemCommandOptions in project alluxio by Alluxio.

the class FileSystemMaster method workerHeartbeat.

/**
   * Instructs a worker to persist the files.
   * <p>
   * Needs {@link Mode.Bits#WRITE} permission on the list of files.
   *
   * @param workerId the id of the worker that heartbeats
   * @param persistedFiles the files that persisted on the worker
   * @return the command for persisting the blocks of a file
   * @throws FileDoesNotExistException if the file does not exist
   * @throws InvalidPathException if the file path corresponding to the file id is invalid
   * @throws AccessControlException if permission checking fails
   */
public FileSystemCommand workerHeartbeat(long workerId, List<Long> persistedFiles) throws FileDoesNotExistException, InvalidPathException, AccessControlException {
    for (long fileId : persistedFiles) {
        try {
            // Permission checking for each file is performed inside setAttribute
            setAttribute(getPath(fileId), SetAttributeOptions.defaults().setPersisted(true));
        } catch (FileDoesNotExistException | AccessControlException | InvalidPathException e) {
            LOG.error("Failed to set file {} as persisted, because {}", fileId, e);
        }
    }
    // get the files for the given worker to persist
    List<PersistFile> filesToPersist = mAsyncPersistHandler.pollFilesToPersist(workerId);
    if (!filesToPersist.isEmpty()) {
        LOG.debug("Sent files {} to worker {} to persist", filesToPersist, workerId);
    }
    FileSystemCommandOptions options = new FileSystemCommandOptions();
    options.setPersistOptions(new PersistCommandOptions(filesToPersist));
    return new FileSystemCommand(CommandType.Persist, options);
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) PersistFile(alluxio.thrift.PersistFile) AccessControlException(alluxio.exception.AccessControlException) PersistCommandOptions(alluxio.thrift.PersistCommandOptions) FileSystemCommandOptions(alluxio.thrift.FileSystemCommandOptions) FileSystemCommand(alluxio.thrift.FileSystemCommand) InvalidPathException(alluxio.exception.InvalidPathException)

Aggregations

AccessControlException (alluxio.exception.AccessControlException)1 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)1 InvalidPathException (alluxio.exception.InvalidPathException)1 FileSystemCommand (alluxio.thrift.FileSystemCommand)1 FileSystemCommandOptions (alluxio.thrift.FileSystemCommandOptions)1 PersistCommandOptions (alluxio.thrift.PersistCommandOptions)1 PersistFile (alluxio.thrift.PersistFile)1