@InterfaceAudience.LimitedPrivate(value="management tools") @InterfaceStability.Evolving public abstract class S3GuardTool extends org.apache.hadoop.conf.Configured implements org.apache.hadoop.util.Tool, Closeable
Some management tools invoke this class directly.
| Modifier and Type | Class and Description |
|---|---|
static class |
S3GuardTool.BucketInfo
Get info about a bucket and its S3Guard integration status.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
AGE_OPTIONS_USAGE |
static String |
DAYS_FLAG |
static String |
HOURS_FLAG |
static String |
META_FLAG |
static String |
MINUTES_FLAG |
static String |
SECONDS_FLAG |
static String |
VERBOSE |
static String |
WRONG_FILESYSTEM
Error String when the wrong FS is used for binding: "Wrong filesystem for ".
|
| Modifier | Constructor and Description |
|---|---|
protected |
S3GuardTool(org.apache.hadoop.conf.Configuration conf,
int min,
int max,
String... opts)
Constructor a S3Guard tool with HDFS configuration.
|
protected |
S3GuardTool(org.apache.hadoop.conf.Configuration conf,
String... opts)
Constructor a S3Guard tool with HDFS configuration.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAgeOptions() |
protected static org.apache.hadoop.util.ExitUtil.ExitException |
badState(String format,
Object... args)
Build the exception to raise on a bad store/bucket state.
|
protected S3AFileSystem |
bindFilesystem(org.apache.hadoop.fs.FileSystem bindingFS)
Sets the filesystem; it must be an S3A FS instance, or a FilterFS
around an S3A Filesystem.
|
void |
close()
Close the FS.
|
protected void |
dumpFileSystemStatistics(PrintStream stream)
Dump the filesystem Storage Statistics if the FS is not null.
|
protected static void |
errorln() |
protected static void |
errorln(String x) |
protected static void |
exit(int status,
String text) |
protected static org.apache.hadoop.util.ExitUtil.ExitException |
exitException(int exitCode,
String format,
Object... args)
Build a exception to throw with a formatted message.
|
protected org.apache.hadoop.fs.shell.CommandFormat |
getCommandFormat() |
protected S3AFileSystem |
getFilesystem() |
abstract String |
getName()
Return sub-command name.
|
abstract String |
getUsage() |
protected void |
initS3AFileSystem(String path)
Create and initialize a new S3A FileSystem instance.
|
protected static org.apache.hadoop.util.ExitUtil.ExitException |
invalidArgs(String format,
Object... args)
Build the exception to raise on invalid arguments.
|
static void |
main(String[] args)
Main entry point.
|
protected static org.apache.hadoop.util.ExitUtil.ExitException |
notFound(FileNotFoundException e)
Handle FileNotFoundException by converting to an exit exception
with specific error code.
|
protected List<String> |
parseArgs(String[] args)
Parse CLI arguments and returns the position arguments.
|
protected List<String> |
parseArgsWithErrorReporting(String[] args)
Process the arguments.
|
protected static void |
println(PrintStream out,
String format,
Object... args)
Print a formatted string followed by a newline to the output stream.
|
protected void |
resetBindings()
Reset the store and filesystem bindings.
|
static int |
run(org.apache.hadoop.conf.Configuration conf,
String... args)
Execute the command with the given arguments.
|
int |
run(String[] args) |
abstract int |
run(String[] args,
PrintStream out)
Run the tool, capturing the output (if the tool supports that).
|
protected static org.apache.hadoop.util.ExitUtil.ExitException |
s3guardUnsupported()
Crate an exception declaring S3Guard is unsupported.
|
protected static URI |
toUri(String s3Path)
Convert a path to a URI, catching any
URISyntaxException
and converting to an invalid args exception. |
protected static org.apache.hadoop.util.ExitUtil.ExitException |
userAborted(String format,
Object... args)
Build the exception to raise on user-aborted action.
|
@VisibleForTesting public static final String WRONG_FILESYSTEM
public static final String META_FLAG
public static final String DAYS_FLAG
public static final String HOURS_FLAG
public static final String MINUTES_FLAG
public static final String SECONDS_FLAG
public static final String AGE_OPTIONS_USAGE
public static final String VERBOSE
protected S3GuardTool(org.apache.hadoop.conf.Configuration conf,
String... opts)
conf - Configuration.opts - any boolean options to supportprotected S3GuardTool(org.apache.hadoop.conf.Configuration conf,
int min,
int max,
String... opts)
conf - Configuration.min - min number of argsmax - max number of argsopts - any boolean options to supportpublic abstract String getUsage()
public abstract String getName()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOException - on failure.protected final void addAgeOptions()
protected void initS3AFileSystem(String path) throws IOException
path - s3a URIIOException - failure to init filesystemExitUtil.ExitException - if the FS is not an S3A FSprotected List<String> parseArgs(String[] args)
commandFormat.args - command line arguments.protected List<String> parseArgsWithErrorReporting(String[] args) throws org.apache.hadoop.util.ExitUtil.ExitException
args - raw argsExitUtil.ExitException - if there's an unknown option.protected S3AFileSystem getFilesystem()
protected S3AFileSystem bindFilesystem(org.apache.hadoop.fs.FileSystem bindingFS)
bindingFS - filesystem to bind toExitUtil.ExitException - if the FS is not an S3 FSprotected void resetBindings()
protected final org.apache.hadoop.fs.shell.CommandFormat getCommandFormat()
public final int run(String[] args) throws Exception
run in interface org.apache.hadoop.util.ToolExceptionpublic abstract int run(String[] args, PrintStream out) throws Exception, org.apache.hadoop.util.ExitUtil.ExitException
ExitUtil.ExitException with their exit
code set to the desired exit value. The exit code of such an exception
is used for the tool's exit code, and the stack trace only logged at
debug.args - argument listout - output streamException - on any failureorg.apache.hadoop.util.ExitUtil.ExitExceptionprotected void dumpFileSystemStatistics(PrintStream stream)
stream - output streamprotected static URI toUri(String s3Path)
URISyntaxException
and converting to an invalid args exception.s3Path - path to convert to a URIExitUtil.ExitException - INVALID_ARGUMENT if the URI is invalidprotected static void errorln()
protected static void errorln(String x)
protected static void println(PrintStream out, String format, Object... args)
out - destinationformat - format stringargs - optional argumentsprotected static org.apache.hadoop.util.ExitUtil.ExitException notFound(FileNotFoundException e)
e - exceptionprotected static org.apache.hadoop.util.ExitUtil.ExitException invalidArgs(String format, Object... args)
format - string formatargs - optional arguments for the stringprotected static org.apache.hadoop.util.ExitUtil.ExitException badState(String format, Object... args)
format - string formatargs - optional arguments for the stringprotected static org.apache.hadoop.util.ExitUtil.ExitException s3guardUnsupported()
protected static org.apache.hadoop.util.ExitUtil.ExitException userAborted(String format, Object... args)
format - string formatargs - optional arguments for the stringprotected static org.apache.hadoop.util.ExitUtil.ExitException exitException(int exitCode,
String format,
Object... args)
exitCode - exit code to useformat - string formatargs - optional arguments for the stringpublic static int run(org.apache.hadoop.conf.Configuration conf,
String... args)
throws Exception
conf - Hadoop configuration.args - command specific arguments.Exception - on I/O errors.public static void main(String[] args)
System.exit() on all execution paths.args - argument listprotected static void exit(int status,
String text)
Copyright © 2008–2024 Apache Software Foundation. All rights reserved.