Search in sources :

Example 6 with SetAttributeOptions

use of alluxio.client.file.options.SetAttributeOptions in project alluxio by Alluxio.

the class JournalIntegrationTest method pin.

/**
   * Tests journalling of inodes being pinned.
   */
@Test
public void pin() throws Exception {
    SetAttributeOptions setPinned = SetAttributeOptions.defaults().setPinned(true);
    SetAttributeOptions setUnpinned = SetAttributeOptions.defaults().setPinned(false);
    AlluxioURI dirUri = new AlluxioURI("/myFolder");
    mFileSystem.createDirectory(dirUri);
    mFileSystem.setAttribute(dirUri, setPinned);
    AlluxioURI file0Path = new AlluxioURI("/myFolder/file0");
    CreateFileOptions op = CreateFileOptions.defaults().setBlockSizeBytes(64);
    mFileSystem.createFile(file0Path, op).close();
    mFileSystem.setAttribute(file0Path, setUnpinned);
    AlluxioURI file1Path = new AlluxioURI("/myFolder/file1");
    mFileSystem.createFile(file1Path, op).close();
    URIStatus directoryStatus = mFileSystem.getStatus(dirUri);
    URIStatus file0Status = mFileSystem.getStatus(file0Path);
    URIStatus file1Status = mFileSystem.getStatus(file1Path);
    mLocalAlluxioCluster.stopFS();
    pinTestUtil(directoryStatus, file0Status, file1Status);
    deleteFsMasterJournalLogs();
    pinTestUtil(directoryStatus, file0Status, file1Status);
}
Also used : SetAttributeOptions(alluxio.client.file.options.SetAttributeOptions) CreateFileOptions(alluxio.client.file.options.CreateFileOptions) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 7 with SetAttributeOptions

use of alluxio.client.file.options.SetAttributeOptions in project alluxio by Alluxio.

the class BaseFileSystemTest method setStateException.

/**
   * Ensures that an exception is propagated successfully when setting the state.
   */
@Test
public void setStateException() throws Exception {
    AlluxioURI file = new AlluxioURI("/file");
    SetAttributeOptions setAttributeOptions = SetAttributeOptions.defaults();
    Mockito.doThrow(EXCEPTION).when(mFileSystemMasterClient).setAttribute(file, setAttributeOptions);
    try {
        mFileSystem.setAttribute(file, setAttributeOptions);
        Assert.fail(SHOULD_HAVE_PROPAGATED_MESSAGE);
    } catch (Exception e) {
        Assert.assertSame(EXCEPTION, e);
    }
}
Also used : SetAttributeOptions(alluxio.client.file.options.SetAttributeOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with SetAttributeOptions

use of alluxio.client.file.options.SetAttributeOptions in project alluxio by Alluxio.

the class BaseFileSystemTest method setAttribute.

/**
   * Tests for the {@link BaseFileSystem#setAttribute(AlluxioURI, SetAttributeOptions)} method.
   */
@Test
public void setAttribute() throws Exception {
    AlluxioURI file = new AlluxioURI("/file");
    SetAttributeOptions setAttributeOptions = SetAttributeOptions.defaults();
    mFileSystem.setAttribute(file, setAttributeOptions);
    Mockito.verify(mFileSystemMasterClient).setAttribute(file, setAttributeOptions);
}
Also used : SetAttributeOptions(alluxio.client.file.options.SetAttributeOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 9 with SetAttributeOptions

use of alluxio.client.file.options.SetAttributeOptions in project alluxio by Alluxio.

the class ChmodCommand method chmod.

/**
   * Changes the permissions of directory or file with the path specified in args.
   *
   * @param path The {@link AlluxioURI} path as the input of the command
   * @param modeStr The new permission to be updated to the file or directory
   * @param recursive Whether change the permission recursively
   * @throws AlluxioException when Alluxio exception occurs
   * @throws IOException when non-Alluxio exception occurs
   */
private void chmod(AlluxioURI path, String modeStr, boolean recursive) throws AlluxioException, IOException {
    Mode mode = mParser.parse(modeStr);
    SetAttributeOptions options = SetAttributeOptions.defaults().setMode(mode).setRecursive(recursive);
    mFileSystem.setAttribute(path, options);
    System.out.println("Changed permission of " + path + " to " + Integer.toOctalString(mode.toShort()));
}
Also used : SetAttributeOptions(alluxio.client.file.options.SetAttributeOptions) Mode(alluxio.security.authorization.Mode)

Example 10 with SetAttributeOptions

use of alluxio.client.file.options.SetAttributeOptions in project alluxio by Alluxio.

the class ChownCommand method chown.

/**
   * Changes the owner for the directory or file with the path specified in args.
   *
   * @param path The {@link AlluxioURI} path as the input of the command
   * @param owner The owner to be updated to the file or directory
   * @param recursive Whether change the owner recursively
   * @throws AlluxioException when Alluxio exception occurs
   * @throws IOException when non-Alluxio exception occurs
   */
private void chown(AlluxioURI path, String owner, boolean recursive) throws AlluxioException, IOException {
    SetAttributeOptions options = SetAttributeOptions.defaults().setOwner(owner).setRecursive(recursive);
    mFileSystem.setAttribute(path, options);
    System.out.println("Changed owner of " + path + " to " + owner);
}
Also used : SetAttributeOptions(alluxio.client.file.options.SetAttributeOptions)

Aggregations

SetAttributeOptions (alluxio.client.file.options.SetAttributeOptions)10 AlluxioURI (alluxio.AlluxioURI)5 Test (org.junit.Test)3 AlluxioException (alluxio.exception.AlluxioException)2 Mode (alluxio.security.authorization.Mode)2 IOException (java.io.IOException)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 URIStatus (alluxio.client.file.URIStatus)1 CreateFileOptions (alluxio.client.file.options.CreateFileOptions)1