Search in sources :

Example 21 with FileSystem

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

the class AlluxioFrameworkIntegrationTest method basicAlluxioTests.

private static void basicAlluxioTests() throws Exception {
    LOG.info("Running tests");
    FileSystem fs = FileSystem.Factory.get();
    int listSize = fs.listStatus(new AlluxioURI("/")).size();
    if (listSize != 1) {
        throw new RuntimeException("Expected 1 path to exist at the root, but found " + listSize);
    }
    FileOutStream outStream = fs.createFile(new AlluxioURI("/test"));
    outStream.write("abc".getBytes());
    outStream.close();
    FileInStream inStream = fs.openFile(new AlluxioURI("/test"));
    String result = IOUtils.toString(inStream);
    if (!result.equals("abc")) {
        throw new RuntimeException("Expected abc but got " + result);
    }
    LOG.info("Tests passed");
}
Also used : FileSystem(alluxio.client.file.FileSystem) FileOutStream(alluxio.client.file.FileOutStream) FileInStream(alluxio.client.file.FileInStream) AlluxioURI(alluxio.AlluxioURI)

Example 22 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 23 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)

Aggregations

FileSystem (alluxio.client.file.FileSystem)23 AlluxioURI (alluxio.AlluxioURI)16 Test (org.junit.Test)10 URIStatus (alluxio.client.file.URIStatus)7 FileInStream (alluxio.client.file.FileInStream)6 FileOutStream (alluxio.client.file.FileOutStream)4 OpenFileOptions (alluxio.client.file.options.OpenFileOptions)2 LineageFileSystem (alluxio.client.lineage.LineageFileSystem)2 CommandLineJob (alluxio.job.CommandLineJob)2 JobConf (alluxio.job.JobConf)2 ArrayList (java.util.ArrayList)2 CreateFileOptions (alluxio.client.file.options.CreateFileOptions)1 RoundRobinPolicy (alluxio.client.file.policy.RoundRobinPolicy)1 AlluxioLineage (alluxio.client.lineage.AlluxioLineage)1 LineageMasterClient (alluxio.client.lineage.LineageMasterClient)1 DeleteLineageOptions (alluxio.client.lineage.options.DeleteLineageOptions)1 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 UnderFileSystem (alluxio.underfs.UnderFileSystem)1 FileBlockInfo (alluxio.wire.FileBlockInfo)1