use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class JournalIntegrationTest method persistDirectoryLater.
@Test
public void persistDirectoryLater() throws Exception {
String[] directories = new String[] { "/d11", "/d11/d21", "/d11/d22", "/d12", "/d12/d21", "/d12/d22" };
CreateDirectoryOptions options = CreateDirectoryOptions.defaults().setRecursive(true).setWriteType(WriteType.MUST_CACHE);
for (String directory : directories) {
mFileSystem.createDirectory(new AlluxioURI(directory), options);
}
options.setWriteType(WriteType.CACHE_THROUGH);
for (String directory : directories) {
mFileSystem.createDirectory(new AlluxioURI(directory), options);
}
Map<String, URIStatus> directoryStatuses = new HashMap<>();
for (String directory : directories) {
directoryStatuses.put(directory, mFileSystem.getStatus(new AlluxioURI(directory)));
}
mLocalAlluxioCluster.stopFS();
persistDirectoryLaterTestUtil(directoryStatuses);
deleteFsMasterJournalLogs();
persistDirectoryLaterTestUtil(directoryStatuses);
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class JournalIntegrationTest method loadMetadata.
/**
* Tests loading metadata.
*/
@Test
public void loadMetadata() throws Exception {
String ufsRoot = PathUtils.concatPath(Configuration.get(PropertyKey.UNDERFS_ADDRESS));
UnderFileSystem ufs = UnderFileSystem.Factory.get(ufsRoot);
ufs.create(ufsRoot + "/xyz").close();
mFileSystem.loadMetadata(new AlluxioURI("/xyz"));
URIStatus status = mFileSystem.getStatus(new AlluxioURI("/xyz"));
mLocalAlluxioCluster.stopFS();
loadMetadataTestUtil(status);
deleteFsMasterJournalLogs();
loadMetadataTestUtil(status);
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class RemoteBlockInStreamIntegrationTest method completeFileReadTriggersRecache.
/**
* Tests that reading a file the whole way through with the STORE ReadType will recache it.
*/
@Test
public void completeFileReadTriggersRecache() throws Exception {
String uniqPath = PathUtils.uniqPath();
int len = 2;
AlluxioURI uri = new AlluxioURI(uniqPath);
FileSystemTestUtils.createByteFile(mFileSystem, uri, mWriteUnderStore, len);
FileInStream is = mFileSystem.openFile(uri, mReadCache);
for (int i = 0; i < len; ++i) {
Assert.assertEquals(i, is.read());
}
is.close();
Assert.assertTrue(mFileSystem.getStatus(uri).getInMemoryPercentage() == 100);
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class RemoteBlockInStreamIntegrationTest method readTest5.
/**
* Tests {@link RemoteBlockInStream#read(byte[])}. Read from remote data server.
*/
@Test
public void readTest5() 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, mWriteAlluxio, k);
long blockId = mFileSystem.getStatus(uri).getBlockIds().get(0);
BlockInfo info = AlluxioBlockStore.create().getInfo(blockId);
WorkerNetAddress workerAddr = info.getLocations().get(0).getWorkerAddress();
RemoteBlockInStream is = RemoteBlockInStream.create(info.getBlockId(), info.getLength(), workerAddr, FileSystemContext.INSTANCE, InStreamOptions.defaults());
byte[] ret = new byte[k];
int start = 0;
while (start < k) {
int read = is.read(ret);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(start, read, ret));
start += read;
}
is.close();
Assert.assertTrue(mFileSystem.getStatus(uri).getInMemoryPercentage() == 100);
}
}
use of alluxio.AlluxioURI in project alluxio by Alluxio.
the class RemoteBlockInStreamIntegrationTest method seekExceptionTest2.
/**
* Tests {@link RemoteBlockInStream#seek(long)}. Validate the expected exception for seeking a
* position that is past block size.
*/
@Test
public void seekExceptionTest2() throws Exception {
mThrown.expect(IllegalArgumentException.class);
mThrown.expectMessage(String.format(PreconditionMessage.ERR_SEEK_PAST_END_OF_FILE.toString(), 1));
String uniqPath = PathUtils.uniqPath();
for (int k = MIN_LEN; k <= MAX_LEN; k += DELTA) {
AlluxioURI uri = new AlluxioURI(uniqPath + "/file_" + k);
FileSystemTestUtils.createByteFile(mFileSystem, uri, mWriteUnderStore, k);
try (FileInStream is = mFileSystem.openFile(uri, mReadNoCache)) {
is.seek(k + 1);
}
}
}
Aggregations