@Override public String toString() { return MoreObjects.toStringHelper(this) .add("ProtoOptions", getOptions().build()) .add("OperationTimeMs", mOperationTimeMs) .add("UfsFingerprint", mUfsFingerprint) .toString(); } }
/** * <code>optional .alluxio.grpc.file.SetAttributePOptions options = 2;</code> */ public Builder setOptions( alluxio.grpc.SetAttributePOptions.Builder builderForValue) { if (optionsBuilder_ == null) { options_ = builderForValue.build(); onChanged(); } else { optionsBuilder_.setMessage(builderForValue.build()); } bitField0_ |= 0x00000002; return this; } /**
mFileSystem.setAttribute(uri, optionsBuilder.build()); } catch (AlluxioException e) { throw new IOException(e);
/** * Changes the replication level of directory or file with the path specified in args. * * @param path The {@link AlluxioURI} path as the input of the command * @param replicationMax the max replicas, null if not to set * @param replicationMin the min replicas, null if not to set * @param recursive Whether change the permission recursively * @throws AlluxioException when Alluxio exception occurs * @throws IOException when non-Alluxio exception occurs */ private void setReplication(AlluxioURI path, Integer replicationMax, Integer replicationMin, boolean recursive) throws AlluxioException, IOException { SetAttributePOptions.Builder optionsBuilder = SetAttributePOptions.newBuilder().setRecursive(recursive); String message = "Changed the replication level of " + path + "\n"; if (replicationMax != null) { optionsBuilder.setReplicationMax(replicationMax); message += "replicationMax was set to " + replicationMax + "\n"; } if (replicationMin != null) { optionsBuilder.setReplicationMin(replicationMin); message += "replicationMin was set to " + replicationMin + "\n"; } mFileSystem.setAttribute(path, optionsBuilder.build()); System.out.println(message); }
/** * Changes the mode of an Alluxio file. * * @param path the path of the file * @param mode the mode to change to * @return 0 on success, a negative value on error */ @Override public int chmod(String path, @mode_t long mode) { AlluxioURI uri = mPathResolverCache.getUnchecked(path); SetAttributePOptions options = SetAttributePOptions.newBuilder() .setMode(new alluxio.security.authorization.Mode((short) mode).toProto()).build(); try { mFileSystem.setAttribute(uri, options); } catch (Throwable t) { LOG.error("Failed to change {} to mode {}", path, mode, t); return AlluxioFuseUtils.getErrorCode(t); } return 0; }
/** * Changes permission of a path. * * @param path path to set permission * @param permission permission set to path */ @Override public void setPermission(Path path, FsPermission permission) throws IOException { LOG.debug("setMode({},{})", path, permission.toString()); AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path)); SetAttributePOptions options = SetAttributePOptions.newBuilder() .setMode(new Mode(permission.toShort()).toProto()).setRecursive(false).build(); try { mFileSystem.setAttribute(uri, options); } catch (AlluxioException e) { throw new IOException(e); } }
/** * 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) .setTtl(ttlMs).setTtlAction(ttlAction).build(); fs.setAttribute(path, options); }
/** * Changes the owner and group for the path specified in args. * * @param path the {@link AlluxioURI} path to update * @param owner the new owner * @param group the new group * @param recursive whether to change the owner and group recursively */ private void chown(AlluxioURI path, String owner, String group, boolean recursive) throws AlluxioException, IOException { SetAttributePOptions options = SetAttributePOptions.newBuilder().setOwner(owner).setGroup(group) .setRecursive(recursive).build(); mFileSystem.setAttribute(path, options); System.out.println("Changed owner:group of " + path + " to " + owner + ":" + group + "."); }
/** * 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())); }
/** * Changes the owner for 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 */ private void chown(AlluxioURI path, String owner, boolean recursive) throws AlluxioException, IOException { SetAttributePOptions options = SetAttributePOptions.newBuilder().setOwner(owner).setRecursive(recursive).build(); mFileSystem.setAttribute(path, options); System.out.println("Changed owner of " + path + " to " + owner); }
/** * 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 */ private void chgrp(AlluxioURI path, String group, boolean recursive) throws AlluxioException, IOException { SetAttributePOptions options = SetAttributePOptions.newBuilder().setGroup(group).setRecursive(recursive).build(); mFileSystem.setAttribute(path, options); System.out.println("Changed group of " + path + " to " + group); }
/** * 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 */ public static void setPinned(FileSystem fs, AlluxioURI path, boolean pinned) throws AlluxioException, IOException { SetAttributePOptions options = SetAttributePOptions.newBuilder().setPinned(pinned).build(); fs.setAttribute(path, options); } }
private SetAttributePOptions verifySetState(TestUser user, String path, SetAttributePOptions options) throws Exception { try (Closeable r = new AuthenticatedUserRule(user.getUser(), ServerConfiguration.global()).toResource()) { mFileSystemMaster.setAttribute(new AlluxioURI(path), SetAttributeContext.defaults(options.toBuilder())); FileInfo fileInfo = mFileSystemMaster.getFileInfo(new AlluxioURI(path), GetStatusContext.defaults()); return FileSystemMasterOptions.setAttributesDefaults().toBuilder() .setPinned(fileInfo.isPinned()).setTtl(fileInfo.getTtl()) .setPersisted(fileInfo.isPersisted()).build(); } }
@Override public boolean setReplication(Path path, short replication) throws IOException { AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path)); try { if (!mFileSystem.exists(uri) || mFileSystem.getStatus(uri).isFolder()) { return false; } mFileSystem.setAttribute(uri, (SetAttributePOptions) SetAttributePOptions.newBuilder() .setReplicationMin(replication).build()); return true; } catch (AlluxioException e) { throw new IOException(e); } }
private SetAttributePOptions getNonDefaultSetState() { return SetAttributePOptions.newBuilder().setPinned(true).setTtl(11) .setTtlAction(TtlAction.DELETE).build(); }
@Override public void apply(FileSystem fs) throws Exception { fs.createDirectory(DIR); Utils.createFile(fs, INNER_FILE); fs.setAttribute(INNER_FILE, SetAttributePOptions.newBuilder().setPersisted(true).build()); }
/** * @return Master side defaults for {@link SetAttributePOptions} */ public static SetAttributePOptions setAttributesDefaults() { return SetAttributePOptions.newBuilder() .setCommonOptions(commonDefaults()) .setTtlAction(TtlAction.DELETE) .setRecursive(false) .build(); }
/** * Merges and embeds the given {@link SetAttributePOptions} with the corresponding master options. * * @param optionsBuilder Builder for proto {@link SetAttributePOptions} to merge with defaults * @return the instance of {@link SetAttributeContext} with default values for master */ public static SetAttributeContext defaults(SetAttributePOptions.Builder optionsBuilder) { SetAttributePOptions masterOptions = FileSystemMasterOptions.setAttributesDefaults(); SetAttributePOptions.Builder mergedOptionsBuilder = masterOptions.toBuilder().mergeFrom(optionsBuilder.build()); return new SetAttributeContext(mergedOptionsBuilder); }