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