use of alluxio.client.file.FileInStream in project alluxio by Alluxio.
the class PathConfigurationIntegrationTest method checkCacheStatus.
private void checkCacheStatus(String path, boolean shouldCache) throws Exception {
AlluxioURI uri = new AlluxioURI(path);
Assert.assertEquals(0, mFileSystem.getStatus(uri).getInMemoryPercentage());
try (FileInStream is = mFileSystem.openFile(uri)) {
IOUtils.copy(is, ByteStreams.nullOutputStream());
}
FileSystemUtils.waitForAlluxioPercentage(mFileSystem, uri, shouldCache ? 100 : 0);
}
use of alluxio.client.file.FileInStream in project alluxio by Alluxio.
the class ReadOnlyMountIntegrationTest method openFile.
@Test
public void openFile() throws IOException, AlluxioException {
AlluxioURI fileUri = new AlluxioURI(FILE_PATH);
FileInStream inStream = mFileSystem.openFile(fileUri);
Assert.assertNotNull(inStream);
inStream.close();
fileUri = new AlluxioURI(SUB_FILE_PATH);
inStream = mFileSystem.openFile(fileUri);
Assert.assertNotNull(inStream);
inStream.close();
}
use of alluxio.client.file.FileInStream in project alluxio by Alluxio.
the class RemoteReadIntegrationTest method incompleteFileReadCancelsRecache.
/**
* Tests that not reading a file the whole way through then closing it will cause it to not
* recache.
*/
@Test
public void incompleteFileReadCancelsRecache() throws Exception {
String uniqPath = PathUtils.uniqPath();
AlluxioURI uri = new AlluxioURI(uniqPath);
FileSystemTestUtils.createByteFile(mFileSystem, uri, mWriteUnderStore, 2);
FileInStream is = mFileSystem.openFile(uri, mReadNoCache);
Assert.assertEquals(0, is.read());
is.close();
Assert.assertFalse(mFileSystem.getStatus(uri).getInAlluxioPercentage() == 100);
is = mFileSystem.openFile(uri, mReadNoCache);
is.close();
}
use of alluxio.client.file.FileInStream in project alluxio by Alluxio.
the class RemoteReadIntegrationTest method skip.
/**
* Tests skipping through data which is in a remote location.
*/
@Test
public void skip() throws Exception {
String uniqPath = PathUtils.uniqPath();
for (int k = MIN_LEN + DELTA; k <= MAX_LEN; k += DELTA) {
AlluxioURI uri = new AlluxioURI(uniqPath + "/file_" + k);
FileSystemTestUtils.createByteFile(mFileSystem, uri, mWriteUnderStore, k);
FileInStream is = mFileSystem.openFile(uri, mReadCache);
Assert.assertEquals(k / 2, is.skip(k / 2));
Assert.assertEquals(k / 2, is.read());
is.close();
IntegrationTestUtils.waitForFileCached(mFileSystem, uri, 1000);
if (k >= 3) {
is = mFileSystem.openFile(uri, mReadCache);
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();
IntegrationTestUtils.waitForFileCached(mFileSystem, uri, 1000);
}
}
}
use of alluxio.client.file.FileInStream in project alluxio by Alluxio.
the class RemoteReadIntegrationTest method heartbeat1.
/**
* Tests the read API from a remote location after a delay longer than the netty heartbeat
* timeout.
*/
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.WORKER_NETWORK_KEEPALIVE_TIME_MS, "1sec" })
public void heartbeat1() throws Exception {
String uniqPath = PathUtils.uniqPath();
int size = 100;
AlluxioURI uri = new AlluxioURI(uniqPath + "/file_" + size);
FileSystemTestUtils.createByteFile(mFileSystem, uri, mWriteUnderStore, size);
FileInStream is = mFileSystem.openFile(uri, mReadNoCache);
CommonUtils.sleepMs(2000);
byte[] ret = new byte[size];
Assert.assertEquals(size, is.read(ret));
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(size, ret));
Assert.assertEquals(-1, is.read(ret));
is.close();
Assert.assertFalse(mFileSystem.getStatus(uri).getInAlluxioPercentage() == 100);
}
Aggregations