Search in sources :

Example 1 with MountOptions

use of alluxio.master.file.options.MountOptions in project alluxio by Alluxio.

the class MountTableTest method readOnlyMount.

/**
   * Tests check of readonly mount points.
   */
@Test
public void readOnlyMount() throws Exception {
    MountOptions options = MountOptions.defaults().setReadOnly(true);
    String mountPath = "/mnt/foo";
    AlluxioURI alluxioUri = new AlluxioURI("alluxio://localhost:1234" + mountPath);
    mMountTable.add(alluxioUri, new AlluxioURI("hdfs://localhost:5678/foo"), options);
    try {
        mMountTable.checkUnderWritableMountPoint(alluxioUri);
        Assert.fail("Readonly mount point should not be writable.");
    } catch (AccessControlException e) {
        // Exception expected
        Assert.assertEquals(ExceptionMessage.MOUNT_READONLY.getMessage(alluxioUri, mountPath), e.getMessage());
    }
    try {
        String path = mountPath + "/sub/directory";
        alluxioUri = new AlluxioURI("alluxio://localhost:1234" + path);
        mMountTable.checkUnderWritableMountPoint(alluxioUri);
        Assert.fail("Readonly mount point should not be writable.");
    } catch (AccessControlException e) {
        // Exception expected
        Assert.assertEquals(ExceptionMessage.MOUNT_READONLY.getMessage(alluxioUri, mountPath), e.getMessage());
    }
}
Also used : AccessControlException(alluxio.exception.AccessControlException) MountOptions(alluxio.master.file.options.MountOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 2 with MountOptions

use of alluxio.master.file.options.MountOptions in project alluxio by Alluxio.

the class MountInfoTest method getFields.

/**
   * Tests getting fields of {@link MountInfo}.
   */
@Test
public void getFields() {
    AlluxioURI uri = new AlluxioURI("alluxio://localhost:19998/test");
    MountOptions options = MountOptions.defaults();
    MountInfo info = new MountInfo(uri, options);
    Assert.assertEquals(uri, info.getUfsUri());
    Assert.assertEquals(options, info.getOptions());
}
Also used : MountOptions(alluxio.master.file.options.MountOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 3 with MountOptions

use of alluxio.master.file.options.MountOptions in project alluxio by Alluxio.

the class FileSystemMaster method mountFromEntry.

/**
   * @param entry the entry to use
   * @throws FileAlreadyExistsException if the mount point already exists
   * @throws InvalidPathException if an invalid path is encountered
   * @throws IOException if an I/O exception occurs
   */
private void mountFromEntry(AddMountPointEntry entry) throws FileAlreadyExistsException, InvalidPathException, IOException {
    AlluxioURI alluxioURI = new AlluxioURI(entry.getAlluxioPath());
    AlluxioURI ufsURI = new AlluxioURI(entry.getUfsPath());
    try (LockedInodePath inodePath = mInodeTree.lockInodePath(alluxioURI, InodeTree.LockMode.WRITE)) {
        mountInternal(inodePath, ufsURI, true, /* replayed */
        new MountOptions(entry));
    }
}
Also used : LockedInodePath(alluxio.master.file.meta.LockedInodePath) MountOptions(alluxio.master.file.options.MountOptions) AlluxioURI(alluxio.AlluxioURI)

Aggregations

AlluxioURI (alluxio.AlluxioURI)3 MountOptions (alluxio.master.file.options.MountOptions)3 Test (org.junit.Test)2 AccessControlException (alluxio.exception.AccessControlException)1 LockedInodePath (alluxio.master.file.meta.LockedInodePath)1