HBASE-25611 ExportSnapshot chmod flag uses value as decimal (#3003)

Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
This commit is contained in:
Peter Somogyi 2021-03-02 11:23:10 +01:00 committed by GitHub
parent d5df99999a
commit b24bd4095a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -233,16 +233,24 @@ public abstract class AbstractHBaseTool implements Tool {
} }
public int getOptionAsInt(CommandLine cmd, String opt, int defaultValue) { public int getOptionAsInt(CommandLine cmd, String opt, int defaultValue) {
return getOptionAsInt(cmd, opt, defaultValue, 10);
}
public int getOptionAsInt(CommandLine cmd, String opt, int defaultValue, int radix) {
if (cmd.hasOption(opt)) { if (cmd.hasOption(opt)) {
return Integer.parseInt(cmd.getOptionValue(opt)); return Integer.parseInt(cmd.getOptionValue(opt), radix);
} else { } else {
return defaultValue; return defaultValue;
} }
} }
public long getOptionAsLong(CommandLine cmd, String opt, int defaultValue) { public long getOptionAsLong(CommandLine cmd, String opt, int defaultValue) {
return getOptionAsLong(cmd, opt, defaultValue, 10);
}
public long getOptionAsLong(CommandLine cmd, String opt, int defaultValue, int radix) {
if (cmd.hasOption(opt)) { if (cmd.hasOption(opt)) {
return Long.parseLong(cmd.getOptionValue(opt)); return Long.parseLong(cmd.getOptionValue(opt), radix);
} else { } else {
return defaultValue; return defaultValue;
} }

View File

@ -927,7 +927,7 @@ public class ExportSnapshot extends AbstractHBaseTool implements Tool {
mappers = getOptionAsInt(cmd, Options.MAPPERS.getLongOpt(), mappers); mappers = getOptionAsInt(cmd, Options.MAPPERS.getLongOpt(), mappers);
filesUser = cmd.getOptionValue(Options.CHUSER.getLongOpt(), filesUser); filesUser = cmd.getOptionValue(Options.CHUSER.getLongOpt(), filesUser);
filesGroup = cmd.getOptionValue(Options.CHGROUP.getLongOpt(), filesGroup); filesGroup = cmd.getOptionValue(Options.CHGROUP.getLongOpt(), filesGroup);
filesMode = getOptionAsInt(cmd, Options.CHMOD.getLongOpt(), filesMode); filesMode = getOptionAsInt(cmd, Options.CHMOD.getLongOpt(), filesMode, 8);
bandwidthMB = getOptionAsInt(cmd, Options.BANDWIDTH.getLongOpt(), bandwidthMB); bandwidthMB = getOptionAsInt(cmd, Options.BANDWIDTH.getLongOpt(), bandwidthMB);
overwrite = cmd.hasOption(Options.OVERWRITE.getLongOpt()); overwrite = cmd.hasOption(Options.OVERWRITE.getLongOpt());
// And verifyChecksum and verifyTarget with values read from old args in processOldArgs(...). // And verifyChecksum and verifyTarget with values read from old args in processOldArgs(...).