Exemplo n.º 1
0
 /**
  * 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 IOException if a non-Alluxio related exception occurs
  */
 public static void setPinned(FileSystem fs, AlluxioURI path, boolean pinned) throws IOException {
   try {
     SetAttributeOptions options = SetAttributeOptions.defaults().setPinned(pinned);
     fs.setAttribute(path, options);
   } catch (AlluxioException e) {
     throw new IOException(e.getMessage());
   }
 }
Exemplo n.º 2
0
 /**
  * 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
  * @throws IOException when failing to set/unset the TTL
  */
 public static void setTtl(FileSystem fs, AlluxioURI path, long ttlMs) throws IOException {
   try {
     SetAttributeOptions options = SetAttributeOptions.defaults().setTtl(ttlMs);
     fs.setAttribute(path, options);
   } catch (AlluxioException e) {
     throw new IOException(e.getMessage());
   }
 }
Exemplo n.º 3
0
 /**
  * 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.info("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);
   }
 }
Exemplo n.º 4
0
 /**
  * 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.info("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);
     }
   }
 }