private void load(AlluxioURI filePath, boolean local) throws AlluxioException, IOException {
    URIStatus status = mFileSystem.getStatus(filePath);
    if (status.isFolder()) {
      List<URIStatus> statuses = mFileSystem.listStatus(filePath);
      for (URIStatus uriStatus : statuses) {
        AlluxioURI newPath = new AlluxioURI(uriStatus.getPath());
        load(newPath, local);
      }
    } else {
      OpenFilePOptions options =
          OpenFilePOptions.newBuilder().setReadType(ReadPType.CACHE_PROMOTE).build();
      if (local) {
        if (!mFsContext.hasLocalWorker()) {
          System.out.println("When local option is specified,"
              + " there must be a local worker available");
          return;
        }
      } else if (status.getInAlluxioPercentage() == 100) {
        // The file has already been fully loaded into Alluxio.
        System.out.println(filePath + " already in Alluxio fully");
        return;
      }
      Closer closer = Closer.create();
      try {
        FileInStream in = closer.register(mFileSystem.openFile(filePath, options));
        byte[] buf = new byte[8 * Constants.MB];
        while (in.read(buf) != -1) {
        }
      } catch (Exception e) {
        throw closer.rethrow(e);
      } finally {
        closer.close();
      }
    }
    System.out.println(filePath + " loaded");
  }
private void load ( AlluxioURI filePath , boolean local ) throws AlluxioException , IOException { URIStatus status = mFileSystem . getStatus ( filePath ) ; if ( status . isFolder ( ) ) { List < URIStatus > statuses = mFileSystem . listStatus ( filePath ) ; for ( URIStatus uriStatus : statuses ) { AlluxioURI newPath = new AlluxioURI ( uriStatus . getPath ( ) ) ; load ( newPath , local ) ; } } else { OpenFilePOptions options = OpenFilePOptions . newBuilder ( ) . setReadType ( ReadPType . CACHE_PROMOTE ) . build ( ) ; if ( local ) { if ( ! mFsContext . hasLocalWorker ( ) ) { System . out . println ( "When local option is specified," + " there must be a local worker available" ) ; return ; } } else if ( status . getInAlluxioPercentage ( ) == 100 ) { System . out . println ( filePath + " already in Alluxio fully" ) ; return ; } Closer closer = Closer . create ( ) ; try { FileInStream in = closer . register ( mFileSystem . openFile ( filePath , options ) ) ; byte [ ] buf = new byte [ 8 * Constants . MB ] ; while ( in . read ( buf ) != - 1 ) { } } catch ( Exception e ) { throw closer . rethrow ( e ) ; } finally { closer . close ( ) ; } } System . out . println ( filePath + " loaded" ) ; }
Loads a file or directory in Alluxio space, makes it resident in Alluxio.

@param filePath The {@link AlluxioURI} path to load into Alluxio
@param local whether to load data to local worker even when the data is already loaded remotely