use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class BufferedBlockInStreamIntegrationTest method skip.
/**
* Tests {@link alluxio.client.block.BufferedBlockInStream#skip(long)}.
*/
@Test
public void skip() throws IOException, AlluxioException {
for (int k = MIN_LEN + DELTA; k <= MAX_LEN; k += DELTA) {
for (CreateFileOptions op : getOptionSet()) {
AlluxioURI path = new AlluxioURI(sTestPath + "/file_" + k + "_" + op.hashCode());
FileInStream is = sFileSystem.openFile(path, FileSystemTestUtils.toOpenFileOptions(op));
Assert.assertEquals(k / 2, is.skip(k / 2));
Assert.assertEquals(k / 2, is.read());
is.close();
is = sFileSystem.openFile(path, FileSystemTestUtils.toOpenFileOptions(op));
int t = k / 3;
Assert.assertEquals(t, is.skip(t));
Assert.assertEquals(t, is.read());
Assert.assertEquals(t, is.skip(t));
Assert.assertEquals(2 * t + 1, is.read());
is.close();
}
}
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method beforeClass.
@BeforeClass
public static final void beforeClass() throws Exception {
sFileSystem = sLocalAlluxioClusterResource.get().getClient();
sWriteBoth = CreateFileOptions.defaults().setMode(Mode.createFullAccess()).setWriteType(WriteType.CACHE_THROUGH);
sWriteAlluxio = CreateFileOptions.defaults().setMode(Mode.createFullAccess()).setWriteType(WriteType.MUST_CACHE);
sWriteUnderStore = CreateFileOptions.defaults().setMode(Mode.createFullAccess()).setWriteType(WriteType.THROUGH);
sTestPath = PathUtils.uniqPath();
// Create files of varying size and write type to later read from
for (int k = MIN_LEN; k <= MAX_LEN; k += DELTA) {
for (CreateFileOptions op : getOptionSet()) {
AlluxioURI path = new AlluxioURI(sTestPath + "/file_" + k + "_" + op.hashCode());
FileSystemTestUtils.createByteFile(sFileSystem, path, op, k);
}
}
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method skip.
/**
* Tests {@link FileInStream#skip(long)}.
*/
@Test
public void skip() throws Exception {
for (int k = MIN_LEN; k <= MAX_LEN; k += DELTA) {
for (CreateFileOptions op : getOptionSet()) {
String filename = sTestPath + "/file_" + k + "_" + op.hashCode();
AlluxioURI uri = new AlluxioURI(filename);
FileInStream is = sFileSystem.openFile(uri, FileSystemTestUtils.toOpenFileOptions(op));
Assert.assertEquals(k / 2, is.skip(k / 2));
Assert.assertEquals(k / 2, is.read());
is.close();
is = sFileSystem.openFile(uri, FileSystemTestUtils.toOpenFileOptions(op));
Assert.assertEquals(k / 3, is.skip(k / 3));
Assert.assertEquals(k / 3, is.read());
is.close();
}
}
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class FileInStreamIntegrationTest method eofSeek.
/**
* Tests {@link FileInStream#seek(long)} when at the end of a file at the block boundary.
*/
@Test
public void eofSeek() throws Exception {
String uniqPath = PathUtils.uniqPath();
int length = BLOCK_SIZE * 3;
for (CreateFileOptions op : getOptionSet()) {
String filename = uniqPath + "/file_" + op.hashCode();
AlluxioURI uri = new AlluxioURI(filename);
FileSystemTestUtils.createByteFile(sFileSystem, filename, length, op);
FileInStream is = sFileSystem.openFile(uri, FileSystemTestUtils.toOpenFileOptions(op));
byte[] data = new byte[length];
is.read(data, 0, length);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(length, data));
is.seek(0);
is.read(data, 0, length);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(length, data));
is.close();
}
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class JournalIntegrationTest method addBlock.
/**
* Tests adding a block.
*/
@Test
public void addBlock() throws Exception {
AlluxioURI uri = new AlluxioURI("/xyz");
CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(64);
FileOutStream os = mFileSystem.createFile(uri, options);
for (int k = 0; k < 1000; k++) {
os.write(k);
}
os.close();
URIStatus status = mFileSystem.getStatus(uri);
mLocalAlluxioCluster.stopFS();
addBlockTestUtil(status);
}
Aggregations