Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unmount and remount in one atomic operation #17984

Merged
merged 4 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3608,6 +3608,11 @@ public void mount(AlluxioURI alluxioPath, AlluxioURI ufsPath, MountContext conte
}
mMountTable.checkUnderWritableMountPoint(alluxioPath);

if (context.getOptions().getRemount()) {
jiacheliu3 marked this conversation as resolved.
Show resolved Hide resolved
LOG.info("Mount {} with remount options, so it will be unmounted first.",
inodePath.getUri());
unmountInternal(rpcContext, inodePath);
jiacheliu3 marked this conversation as resolved.
Show resolved Hide resolved
}
mountInternal(rpcContext, inodePath, ufsPath, context);
auditContext.setSucceeded(true);
Metrics.PATHS_MOUNTED.inc();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ message MountPOptions {
map<string, string> properties = 2;
optional bool shared = 3;
optional FileSystemMasterCommonPOptions commonOptions = 4;
optional bool remount = 5;
}
message MountPRequest {
/** the path of alluxio mount point */
Expand Down
5 changes: 5 additions & 0 deletions core/transport/src/main/proto/proto.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3276,6 +3276,11 @@
"id": 4,
"name": "commonOptions",
"type": "FileSystemMasterCommonPOptions"
},
{
"id": 5,
"name": "remount",
"type": "bool"
}
],
"maps": [
Expand Down
14 changes: 12 additions & 2 deletions shell/src/main/java/alluxio/cli/fs/command/MountCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public final class MountCommand extends AbstractFileSystemCommand {
.hasArg(false)
.desc("mount point is shared")
.build();
private static final Option REMOUNT_OPTION =
Option.builder()
.longOpt("remount")
.required(false)
.hasArg(false)
.desc("unmount and remount in one locked operation, with atomicity")
.build();
private static final Option OPTION_OPTION =
Option.builder()
.longOpt("option")
Expand All @@ -77,7 +84,7 @@ public String getCommandName() {
@Override
public Options getOptions() {
return new Options().addOption(READONLY_OPTION).addOption(SHARED_OPTION)
.addOption(OPTION_OPTION);
.addOption(REMOUNT_OPTION).addOption(OPTION_OPTION);
}

@Override
Expand All @@ -98,6 +105,9 @@ public int run(CommandLine cl) throws AlluxioException, IOException {
if (cl.hasOption(SHARED_OPTION.getLongOpt())) {
optionsBuilder.setShared(true);
}
if (cl.hasOption(REMOUNT_OPTION.getLongOpt())) {
optionsBuilder.setRemount(true);
}
if (cl.hasOption(OPTION_OPTION.getLongOpt())) {
Properties properties = cl.getOptionProperties(OPTION_OPTION.getLongOpt());
optionsBuilder.putAllProperties(Maps.fromProperties(properties));
Expand All @@ -109,7 +119,7 @@ public int run(CommandLine cl) throws AlluxioException, IOException {

@Override
public String getUsage() {
return "mount [--readonly] [--shared] [--option <key=val>] <alluxioPath> <ufsURI>";
return "mount [--readonly] [--shared] [--remount] [--option <key=val>] <alluxioPath> <ufsURI>";
}

@Override
Expand Down
Loading