use of alluxio.client.ReadType in project alluxio by Alluxio.
the class OpenFileOptionsTest method fields.
/**
* Tests getting and setting fields.
*/
@Test
public void fields() {
FileWriteLocationPolicy policy = new RoundRobinPolicy();
ReadType readType = ReadType.NO_CACHE;
OpenFileOptions options = OpenFileOptions.defaults();
options.setReadType(readType);
options.setCacheLocationPolicy(policy);
options.setMaxUfsReadConcurrency(5);
options.setUfsReadLocationPolicy((BlockLocationPolicy) policy);
Assert.assertEquals(readType, options.getReadType());
Assert.assertEquals(policy, options.getCacheLocationPolicy());
Assert.assertEquals(5, options.getMaxUfsReadConcurrency());
Assert.assertEquals(policy, options.getUfsReadLocationPolicy());
}
use of alluxio.client.ReadType in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method asyncCacheAfterSeek.
@Test(timeout = 10000)
public void asyncCacheAfterSeek() throws Exception {
String filename = mTestPath + "/file_" + MAX_LEN + "_" + mWriteUnderStore.hashCode();
AlluxioURI uri = new AlluxioURI(filename);
for (ReadType readType : ReadType.values()) {
mFileSystem.free(uri);
CommonUtils.waitFor("No in-Alluxio data left from previous iteration.", () -> {
try {
URIStatus st = mFileSystem.getStatus(uri);
return st.getInAlluxioPercentage() == 0;
} catch (Exception e) {
return false;
}
});
FileInStream is = mFileSystem.openFile(uri, OpenFilePOptions.newBuilder().setReadType(readType.toProto()).build());
URIStatus status = mFileSystem.getStatus(uri);
is.seek(status.getBlockSizeBytes() + 1);
is.read();
status = mFileSystem.getStatus(uri);
Assert.assertEquals(0, status.getInAlluxioPercentage());
is.close();
if (readType.isCache()) {
CommonUtils.waitFor("Second block to be cached.", () -> {
try {
URIStatus st = mFileSystem.getStatus(uri);
boolean achieved = true;
// Expect only second block to be cached, other blocks should be empty in Alluxio
for (int i = 0; i < st.getFileBlockInfos().size(); i++) {
FileBlockInfo info = st.getFileBlockInfos().get(i);
if (i == 1) {
achieved = achieved && !info.getBlockInfo().getLocations().isEmpty();
} else {
achieved = achieved && info.getBlockInfo().getLocations().isEmpty();
}
}
return achieved;
} catch (Exception e) {
return false;
}
});
} else {
Thread.sleep(1000);
status = mFileSystem.getStatus(uri);
Assert.assertEquals(0, status.getInAlluxioPercentage());
}
}
}
use of alluxio.client.ReadType in project alluxio by Alluxio.
the class InStreamOptionsTest method fields.
/**
* Tests getting and setting fields.
*/
@Test
public void fields() {
ReadType readType = ReadType.NO_CACHE;
FileWriteLocationPolicy policy = new RoundRobinPolicy();
BlockLocationPolicy blockLocationPolicy = new DeterministicHashPolicy();
InStreamOptions options = InStreamOptions.defaults();
options.setReadType(readType);
options.setLocationPolicy(policy);
options.setCachePartiallyReadBlock(true);
options.setSeekBufferSizeBytes(Constants.MB);
options.setUfsReadLocationPolicy(blockLocationPolicy);
options.setMaxUfsReadConcurrency(5);
Assert.assertEquals(options.getAlluxioStorageType(), readType.getAlluxioStorageType());
Assert.assertEquals(policy, options.getCacheLocationPolicy());
Assert.assertTrue(options.isCachePartiallyReadBlock());
Assert.assertEquals(Constants.MB, options.getSeekBufferSizeBytes());
Assert.assertEquals(blockLocationPolicy, options.getUfsReadLocationPolicy());
Assert.assertEquals(5, options.getMaxUfsReadConcurrency());
}
use of alluxio.client.ReadType in project alluxio by Alluxio.
the class TestRunner method runTests.
/**
* Runs combinations of tests of operation, read and write type.
*
* @return the number of failed tests
*/
private int runTests() throws Exception {
mDirectory = PathUtils.concatPath(mDirectory, TEST_DIRECTORY_NAME);
AlluxioURI testDir = new AlluxioURI(mDirectory);
FileSystemContext fsContext = FileSystemContext.create(new InstancedConfiguration(ConfigurationUtils.defaults()));
FileSystem fs = FileSystem.Factory.create(fsContext);
if (fs.exists(testDir)) {
fs.delete(testDir, DeletePOptions.newBuilder().setRecursive(true).setUnchecked(true).build());
}
int failed = 0;
List<ReadType> readTypes = mReadType == null ? READ_TYPES : Lists.newArrayList(ReadType.valueOf(mReadType));
List<WriteType> writeTypes = mWriteType == null ? WRITE_TYPES : Lists.newArrayList(WriteType.valueOf(mWriteType));
List<OperationType> operations = mOperation == null ? Lists.newArrayList(OperationType.values()) : Lists.newArrayList(OperationType.valueOf(mOperation));
for (ReadType readType : readTypes) {
for (WriteType writeType : writeTypes) {
for (OperationType opType : operations) {
System.out.println(String.format("runTest --operation %s --readType %s --writeType %s", opType, readType, writeType));
failed += runTest(opType, readType, writeType, fsContext);
}
}
}
if (failed > 0) {
System.out.println("Number of failed tests: " + failed);
}
return failed;
}
use of alluxio.client.ReadType in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method asyncCacheFirstBlock.
@Test(timeout = 10000)
public void asyncCacheFirstBlock() throws Exception {
String filename = mTestPath + "/file_" + MAX_LEN + "_" + mWriteUnderStore.hashCode();
AlluxioURI uri = new AlluxioURI(filename);
for (ReadType readType : ReadType.values()) {
mFileSystem.free(uri);
CommonUtils.waitFor("No in-Alluxio data left from previous iteration.", () -> {
try {
URIStatus st = mFileSystem.getStatus(uri);
return st.getInAlluxioPercentage() == 0;
} catch (Exception e) {
return false;
}
});
FileInStream is = mFileSystem.openFile(uri, OpenFilePOptions.newBuilder().setReadType(readType.toProto()).build());
is.read();
URIStatus status = mFileSystem.getStatus(uri);
Assert.assertEquals(0, status.getInAlluxioPercentage());
is.close();
if (readType.isCache()) {
CommonUtils.waitFor("First block to be cached.", () -> {
try {
URIStatus st = mFileSystem.getStatus(uri);
boolean achieved = true;
// Expect only first block to be cached, other blocks should be empty in Alluxio
for (int i = 0; i < st.getFileBlockInfos().size(); i++) {
FileBlockInfo info = st.getFileBlockInfos().get(i);
if (i == 0) {
achieved = achieved && !info.getBlockInfo().getLocations().isEmpty();
} else {
achieved = achieved && info.getBlockInfo().getLocations().isEmpty();
}
}
return achieved;
} catch (Exception e) {
return false;
}
});
} else {
Thread.sleep(1000);
status = mFileSystem.getStatus(uri);
Assert.assertEquals(0, status.getInAlluxioPercentage());
}
}
}
Aggregations