MCPcopy
hub / github.com/Alluxio/alluxio / UfsCommand

Class UfsCommand

shell/src/main/java/alluxio/cli/fsadmin/command/UfsCommand.java:34–112  ·  view source on GitHub ↗

Update attributes for an existing mount point.

Source from the content-addressed store, hash-verified

32 * Update attributes for an existing mount point.
33 */
34@ThreadSafe
35@PublicApi
36public final class UfsCommand extends AbstractFsAdminCommand {
37 private static final Option MODE_OPTION =
38 Option.builder()
39 .longOpt("mode")
40 .required(false)
41 .hasArg(true)
42 .desc("Set maintenance mode for a ufs path under one or more Alluxio mount points.")
43 .build();
44
45 /**
46 * @param context fsadmin command context
47 * @param alluxioConf Alluxio configuration
48 */
49 public UfsCommand(Context context, AlluxioConfiguration alluxioConf) {
50 super(context);
51 }
52
53 @Override
54 public String getCommandName() {
55 return "ufs";
56 }
57
58 @Override
59 public void validateArgs(CommandLine cl) throws InvalidArgumentException {
60 CommandUtils.checkNumOfArgsEquals(this, cl, 1);
61 }
62
63 @Override
64 public Options getOptions() {
65 return new Options().addOption(MODE_OPTION);
66 }
67
68 @Override
69 public int run(CommandLine cl) throws AlluxioException, IOException {
70 String[] args = cl.getArgs();
71 String ufsPath = args[0];
72 AlluxioURI ufsUri = new AlluxioURI(ufsPath);
73 if (!PathUtils.normalizePath(ufsUri.getPath(), AlluxioURI.SEPARATOR)
74 .equals(AlluxioURI.SEPARATOR)) {
75 System.out.println("The ufs path should have only scheme and authority but no path.");
76 return -1;
77 }
78 if (cl.hasOption(MODE_OPTION.getLongOpt())) {
79 UfsPMode mode;
80 switch (cl.getOptionValue(MODE_OPTION.getLongOpt())) {
81 case "noAccess":
82 mode = UfsPMode.NO_ACCESS;
83 break;
84 case "readOnly":
85 mode = UfsPMode.READ_ONLY;
86 break;
87 case "readWrite":
88 mode = UfsPMode.READ_WRITE;
89 break;
90 default:
91 System.out.println("Unrecognized mode");

Callers

nothing calls this directly

Calls 2

buildMethod · 0.45
builderMethod · 0.45

Tested by

no test coverage detected