Search in sources :

Example 71 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class MiniBenchmark method readFile.

/**
   * Reads a file.
   *
   * @param fileSize the file size
   * @param iterations the number of iterations to run
   * @throws Exception if it fails to read
   */
private static void readFile(long fileSize, int iterations) throws Exception {
    FileSystem fileSystem = FileSystem.Factory.get();
    byte[] buffer = new byte[(int) Math.min(fileSize, 4 * Constants.MB)];
    long start = System.nanoTime();
    for (int i = 0; i < iterations; i++) {
        try (FileInStream inStream = fileSystem.openFile(new AlluxioURI(TEST_PATH))) {
            while (inStream.read(buffer) != -1) {
            }
        }
    }
    System.out.printf("Runtime: %f seconds.%n", (System.nanoTime() - start) * 1.0 / Constants.SECOND_NANO);
}
Also used : FileSystem(alluxio.client.file.FileSystem) FileInStream(alluxio.client.file.FileInStream) AlluxioURI(alluxio.AlluxioURI)

Example 72 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class BasicCheckpoint method call.

@Override
public Boolean call() throws Exception {
    FileSystem fs = FileSystem.Factory.get();
    writeFile(fs);
    return readFile(fs);
}
Also used : FileSystem(alluxio.client.file.FileSystem)

Example 73 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class MiniBenchmark method readFile.

/**
 * Reads a file.
 *
 * @param count the count to determine the filename
 * @throws Exception if it fails to read
 */
private static void readFile(CyclicBarrier barrier, AtomicLong runTime, int count, AlluxioConfiguration alluxioConf) throws Exception {
    FileSystem fileSystem = FileSystem.Factory.create(alluxioConf);
    byte[] buffer = new byte[(int) Math.min(sFileSize, 4 * Constants.MB)];
    barrier.await();
    long startTime = System.nanoTime();
    try (FileInStream inStream = fileSystem.openFile(filename(count))) {
        while (inStream.read(buffer) != -1) {
        }
    }
    runTime.addAndGet(System.nanoTime() - startTime);
}
Also used : FileSystem(alluxio.client.file.FileSystem) FileInStream(alluxio.client.file.FileInStream)

Example 74 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class MultiProcessClusterTest method clusterVerification.

/**
 * Verifies cluster running as expected.
 */
private void clusterVerification() throws Exception {
    try {
        mCluster.start();
        mCluster.waitForAllNodesRegistered(60 * Constants.SECOND_MS);
        FileSystem fs = mCluster.getFileSystemClient();
        createAndOpenFile(fs);
        mCluster.notifySuccess();
    } finally {
        mCluster.destroy();
    }
}
Also used : FileSystem(alluxio.client.file.FileSystem)

Example 75 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class ClientPool method getClient.

/**
 * Returns a {@link FileSystem} client. This client does not need to be
 * closed directly, but can be closed by calling {@link #close()} on this object.
 *
 * @return a {@link FileSystem} client
 */
public FileSystem getClient() throws IOException {
    final FileSystem fs = FileSystem.Factory.create(ServerConfiguration.global());
    mClients.add(fs);
    return fs;
}
Also used : FileSystem(alluxio.client.file.FileSystem)

Aggregations

FileSystem (alluxio.client.file.FileSystem)122 AlluxioURI (alluxio.AlluxioURI)90 Test (org.junit.Test)75 URIStatus (alluxio.client.file.URIStatus)42 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)22 FileInStream (alluxio.client.file.FileInStream)13 IOException (java.io.IOException)12 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)11 ArrayList (java.util.ArrayList)11 FileOutStream (alluxio.client.file.FileOutStream)10 AlluxioException (alluxio.exception.AlluxioException)9 File (java.io.File)9 Path (javax.ws.rs.Path)9 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)8 HashMap (java.util.HashMap)8 FileSystemContext (alluxio.client.file.FileSystemContext)7 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)6 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)6 TestUserState (alluxio.security.user.TestUserState)6 InstancedConfiguration (alluxio.conf.InstancedConfiguration)5