Search in sources :

Example 31 with AlluxioURI

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);
}
Also used : HashMap(java.util.HashMap) CreateDirectoryOptions(alluxio.client.file.options.CreateDirectoryOptions) Matchers.anyString(org.mockito.Matchers.anyString) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 32 with AlluxioURI

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);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) UnderFileSystem(alluxio.underfs.UnderFileSystem) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 33 with AlluxioURI

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);
}
Also used : FileInStream(alluxio.client.file.FileInStream) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 34 with AlluxioURI

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);
    }
}
Also used : BlockInfo(alluxio.wire.BlockInfo) WorkerNetAddress(alluxio.wire.WorkerNetAddress) RemoteBlockInStream(alluxio.client.block.RemoteBlockInStream) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 35 with AlluxioURI

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);
        }
    }
}
Also used : FileInStream(alluxio.client.file.FileInStream) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

AlluxioURI (alluxio.AlluxioURI)1552 Test (org.junit.Test)1094 URIStatus (alluxio.client.file.URIStatus)356 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)303 IOException (java.io.IOException)154 FileInStream (alluxio.client.file.FileInStream)152 FileInfo (alluxio.wire.FileInfo)130 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)124 ArrayList (java.util.ArrayList)120 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)119 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)114 File (java.io.File)107 FileSystem (alluxio.client.file.FileSystem)99 FileOutStream (alluxio.client.file.FileOutStream)97 AlluxioException (alluxio.exception.AlluxioException)92 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)76 InvalidPathException (alluxio.exception.InvalidPathException)68 AbstractAlluxioShellTest (alluxio.shell.AbstractAlluxioShellTest)63 UnderFileSystem (alluxio.underfs.UnderFileSystem)63 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)62