use of alluxio.exception.status.InvalidArgumentException in project alluxio by Alluxio.
the class DefaultFileSystemMaster method updateMountInternal.
private void updateMountInternal(Supplier<JournalContext> journalContext, LockedInodePath inodePath, AlluxioURI ufsPath, MountInfo mountInfo, MountContext context) throws FileAlreadyExistsException, InvalidPathException, IOException {
long newMountId = IdUtils.createMountId();
// lock sync manager to ensure no sync point is added before the mount point is removed
try (LockResource r = new LockResource(mSyncManager.getLock())) {
List<AlluxioURI> syncPoints = mSyncManager.getFilterList(mountInfo.getMountId());
if (syncPoints != null && !syncPoints.isEmpty()) {
throw new InvalidArgumentException("Updating a mount point with ActiveSync enabled is not" + " supported. Please remove all sync'ed paths from the mount point and try again.");
}
AlluxioURI alluxioPath = inodePath.getUri();
// validate new UFS client before updating the mount table
mUfsManager.addMount(newMountId, new AlluxioURI(ufsPath.toString()), UnderFileSystemConfiguration.defaults(ServerConfiguration.global()).setReadOnly(context.getOptions().getReadOnly()).setShared(context.getOptions().getShared()).createMountSpecificConf(context.getOptions().getPropertiesMap()));
prepareForMount(ufsPath, newMountId, context);
// old ufsClient is removed as part of the mount table update process
mMountTable.update(journalContext, alluxioPath, newMountId, context.getOptions().build());
} catch (FileAlreadyExistsException | InvalidPathException | IOException e) {
// revert everything
mUfsManager.removeMount(newMountId);
throw e;
}
}
use of alluxio.exception.status.InvalidArgumentException in project alluxio by Alluxio.
the class ValidateEnv method validate.
/**
* Validates environment.
*
* @param argv list of arguments
* @return 0 on success, -1 on validation failures, -2 on invalid arguments
*/
public static int validate(String... argv) throws InterruptedException {
if (argv.length < 1) {
printHelp("Target not specified.");
return -2;
}
String command = argv[0];
String name = null;
String[] args;
int argsLength = 0;
// Find all non-option command line arguments.
while (argsLength < argv.length && !argv[argsLength].startsWith("-")) {
argsLength++;
}
if (argsLength > 1) {
name = argv[1];
args = Arrays.copyOfRange(argv, 2, argv.length);
} else {
args = Arrays.copyOfRange(argv, 1, argv.length);
}
CommandLine cmd;
try {
cmd = parseArgsAndOptions(OPTIONS, args);
} catch (InvalidArgumentException e) {
System.err.format("Invalid argument: %s.%n", e.getMessage());
return -1;
}
if (command.equals("list")) {
// Validate against root path
AlluxioConfiguration conf = InstancedConfiguration.defaults();
String rootPath = conf.getString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS);
ValidateEnv task = new ValidateEnv(rootPath, conf);
task.printTasks();
return 0;
}
return runTasks(command, name, cmd);
}
use of alluxio.exception.status.InvalidArgumentException in project alluxio by Alluxio.
the class ValidateEnv method parseArgsAndOptions.
/**
* Parses the command line arguments and options in {@code args}.
*
* After successful execution of this method, command line arguments can be
* retrieved by invoking {@link CommandLine#getArgs()}, and options can be
* retrieved by calling {@link CommandLine#getOptions()}.
*
* @param args command line arguments to parse
* @return {@link CommandLine} object representing the parsing result
* @throws InvalidArgumentException if command line contains invalid argument(s)
*/
private static CommandLine parseArgsAndOptions(Options options, String... args) throws InvalidArgumentException {
CommandLineParser parser = new DefaultParser();
CommandLine cmd;
try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
throw new InvalidArgumentException("Failed to parse args for validateEnv", e);
}
return cmd;
}
use of alluxio.exception.status.InvalidArgumentException in project alluxio by Alluxio.
the class DoctorCommand method run.
@Override
public int run(CommandLine cl) throws IOException {
String[] args = cl.getArgs();
if (cl.hasOption(HELP_OPTION_NAME)) {
System.out.println(getUsage());
System.out.println(getDescription());
return 0;
}
FileSystemAdminShellUtils.checkMasterClientService(mConf);
// Get the doctor category
Command command = Command.ALL;
if (args.length == 1) {
switch(args[0]) {
case "configuration":
command = Command.CONFIGURATION;
break;
case "storage":
command = Command.STORAGE;
break;
default:
System.out.println(getUsage());
System.out.println(getDescription());
throw new InvalidArgumentException("doctor category is invalid.");
}
}
if (command.equals(Command.CONFIGURATION) || command.equals(Command.ALL)) {
ConfigurationCommand configurationCommand = new ConfigurationCommand(mMetaClient, System.out);
configurationCommand.run();
}
if (command.equals(Command.STORAGE) || command.equals(Command.ALL)) {
StorageCommand storageCommand = new StorageCommand(mBlockClient, System.out);
storageCommand.run();
}
return 0;
}
use of alluxio.exception.status.InvalidArgumentException in project alluxio by Alluxio.
the class SetTtlCommand method validateArgs.
@Override
public void validateArgs(CommandLine cl) throws InvalidArgumentException {
CommandUtils.checkNumOfArgsEquals(this, cl, 2);
String operation = cl.getOptionValue(TTL_ACTION);
if (operation != null) {
try {
mAction = TtlAction.valueOf(operation.toUpperCase());
} catch (Exception e) {
throw new InvalidArgumentException(String.format("TTL action should be %s OR %s, not %s", TtlAction.DELETE, TtlAction.FREE, operation));
}
}
}
Aggregations