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);
}
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);
}
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);
}
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();
}
}
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;
}
Aggregations