use of alluxio.client.file.options.SetAttributeOptions in project alluxio by Alluxio.
the class ChgrpCommand method chgrp.
/**
* Changes the group for the directory or file with the path specified in args.
*
* @param path The {@link AlluxioURI} path as the input of the command
* @param group The group to be updated to the file or directory
* @param recursive Whether change the group recursively
* @throws AlluxioException when Alluxio exception occurs
* @throws IOException when non-Alluxio exception occurs
*/
private void chgrp(AlluxioURI path, String group, boolean recursive) throws AlluxioException, IOException {
SetAttributeOptions options = SetAttributeOptions.defaults().setGroup(group).setRecursive(recursive);
mFileSystem.setAttribute(path, options);
System.out.println("Changed group of " + path + " to " + group);
}
use of alluxio.client.file.options.SetAttributeOptions in project alluxio by Alluxio.
the class CommandUtils method setPinned.
/**
* Sets pin state for the input path.
*
* @param fs The {@link FileSystem} client
* @param path The {@link AlluxioURI} path as the input of the command
* @param pinned the state to be set
* @throws AlluxioException when an Alluxio exception occurs
* @throws IOException when a non-Alluxio exception occurs
*/
public static void setPinned(FileSystem fs, AlluxioURI path, boolean pinned) throws AlluxioException, IOException {
SetAttributeOptions options = SetAttributeOptions.defaults().setPinned(pinned);
fs.setAttribute(path, options);
}
use of alluxio.client.file.options.SetAttributeOptions in project alluxio by Alluxio.
the class CommandUtils 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
* @throws AlluxioException when an Alluxio exception occurs
* @throws IOException when a non-Alluxio exception occurs
*/
public static void setTtl(FileSystem fs, AlluxioURI path, long ttlMs, TtlAction ttlAction) throws AlluxioException, IOException {
SetAttributeOptions options = SetAttributeOptions.defaults().setRecursive(true).setTtl(ttlMs).setTtlAction(ttlAction);
fs.setAttribute(path, options);
}
use of alluxio.client.file.options.SetAttributeOptions in project alluxio by Alluxio.
the class AbstractFileSystem method setOwner.
/**
* Changes owner or group of a path (i.e. a file or a directory). If username is null, the
* original username remains unchanged. Same as groupname. If username and groupname are non-null,
* both of them will be changed.
*
* @param path path to set owner or group
* @param username username to be set
* @param groupname groupname to be set
* @throws IOException if changing owner or group of the path failed
*/
@Override
public void setOwner(Path path, final String username, final String groupname) throws IOException {
LOG.debug("setOwner({},{},{})", path, username, groupname);
AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path));
SetAttributeOptions options = SetAttributeOptions.defaults();
boolean ownerOrGroupChanged = false;
if (username != null && !username.isEmpty()) {
options.setOwner(username).setRecursive(false);
ownerOrGroupChanged = true;
}
if (groupname != null && !groupname.isEmpty()) {
options.setGroup(groupname).setRecursive(false);
ownerOrGroupChanged = true;
}
if (ownerOrGroupChanged) {
try {
mFileSystem.setAttribute(uri, options);
} catch (AlluxioException e) {
throw new IOException(e);
}
}
}
use of alluxio.client.file.options.SetAttributeOptions in project alluxio by Alluxio.
the class AbstractFileSystem method setPermission.
/**
* Changes permission of a path.
*
* @param path path to set permission
* @param permission permission set to path
* @throws IOException if the path failed to be changed permission
*/
@Override
public void setPermission(Path path, FsPermission permission) throws IOException {
LOG.debug("setMode({},{})", path, permission.toString());
AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path));
SetAttributeOptions options = SetAttributeOptions.defaults().setMode(new Mode(permission.toShort())).setRecursive(false);
try {
mFileSystem.setAttribute(uri, options);
} catch (AlluxioException e) {
throw new IOException(e);
}
}
Aggregations