use of alluxio.grpc.SetAttributePOptions 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
*/
private void chmod(AlluxioURI path, String modeStr, boolean recursive) throws AlluxioException, IOException {
Mode mode = ModeParser.parse(modeStr);
SetAttributePOptions options = SetAttributePOptions.newBuilder().setMode(mode.toProto()).setRecursive(recursive).build();
mFileSystem.setAttribute(path, options);
System.out.println("Changed permission of " + path + " to " + Integer.toOctalString(mode.toShort()));
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class BaseFileSystemTest method setAttributeSyncMetadataInterval.
/**
* Tests that the metadata sync interval is included on setAttributePOptions by default.
*/
@Test
public void setAttributeSyncMetadataInterval() throws Exception {
AlluxioURI file = new AlluxioURI("/file");
SetAttributePOptions opt = FileSystemOptions.setAttributeClientDefaults(mFileContext.getPathConf(file));
// Check that metadata sync interval from configuration is used when options are omitted
mFileSystem.setAttribute(file);
verify(mFileSystemMasterClient).setAttribute(file, opt);
}
use of alluxio.grpc.SetAttributePOptions 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");
SetAttributePOptions setAttributeOptions = FileSystemOptions.setAttributeClientDefaults(mFileContext.getPathConf(file));
doThrow(EXCEPTION).when(mFileSystemMasterClient).setAttribute(file, setAttributeOptions);
try {
mFileSystem.setAttribute(file, setAttributeOptions);
fail(SHOULD_HAVE_PROPAGATED_MESSAGE);
} catch (Exception e) {
assertSame(EXCEPTION, e);
}
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class BaseFileSystemTest method setAttribute.
/**
* Tests for the {@link BaseFileSystem#setAttribute(AlluxioURI, SetAttributePOptions)} method.
*/
@Test
public void setAttribute() throws Exception {
AlluxioURI file = new AlluxioURI("/file");
SetAttributePOptions setAttributeOptions = FileSystemOptions.setAttributeClientDefaults(mFileContext.getPathConf(file));
mFileSystem.setAttribute(file, setAttributeOptions);
verify(mFileSystemMasterClient).setAttribute(file, setAttributeOptions);
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class FileSystemCommandUtils method setTtl.
/**
* Sets a new TTL value or unsets an existing TTL value for file at path.
*
* @param fs the file system for Alluxio
* @param path the file path
* @param ttlMs the TTL (time to live) value to use; it identifies duration (in milliseconds) the
* created file should be kept around before it is automatically deleted, irrespective of
* whether the file is pinned; {@link Constants#NO_TTL} means to unset the TTL value
* @param ttlAction Action to perform on Ttl expiry
*/
public static void setTtl(FileSystem fs, AlluxioURI path, long ttlMs, TtlAction ttlAction) throws AlluxioException, IOException {
SetAttributePOptions options = SetAttributePOptions.newBuilder().setRecursive(true).setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(ttlMs).setTtlAction(ttlAction).build()).build();
fs.setAttribute(path, options);
}
Aggregations