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);
}
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);
}
}
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);
}
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()));
}
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);
}
Aggregations