@InterfaceAudience.LimitedPrivate(value="management tools") @InterfaceStability.Evolving public abstract class S3GuardTool extends org.apache.hadoop.conf.Configured implements org.apache.hadoop.util.Tool, Closeable
| 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 |
CMK_FLAG |
static String |
DAYS_FLAG |
static String |
HOURS_FLAG |
static String |
META_FLAG |
static String |
MINUTES_FLAG |
static String |
READ_FLAG |
static String |
REGION_FLAG |
static String |
SECONDS_FLAG |
static String |
SSE_FLAG |
static String |
TAG_FLAG |
static String |
VERBOSE |
static String |
WRITE_FLAG |
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,
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.
|
protected void |
checkBucketNameOrDDBTableNameProvided(List<String> paths)
Check if bucket or DDB table name is set.
|
protected void |
checkIfS3BucketIsGuarded(List<String> paths) |
void |
close()
Close the FS and metastore.
|
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.
|
MetadataStore |
getStore() |
abstract String |
getUsage() |
protected MetadataStore |
initMetadataStore(boolean forceCreate)
Parse metadata store from command line option or HDFS configuration.
|
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 List<String> |
parseArgs(String[] args)
Parse CLI arguments and returns the position arguments.
|
protected void |
parseDynamoDBRegion(List<String> paths)
Parse DynamoDB region from either -m option or a S3 path.
|
protected static void |
println(PrintStream out,
String format,
Object... args)
Print a formatted string followed by a newline to the output stream.
|
protected static void |
printStoreDiagnostics(PrintStream out,
MetadataStore store)
Retrieve and Print store diagnostics.
|
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 void |
setStore(MetadataStore store) |
protected static org.apache.hadoop.util.ExitUtil.ExitException |
storeNotFound(FileNotFoundException e)
Handle store not found by converting to an exit exception
with specific error code.
|
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.
|
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 REGION_FLAG
public static final String READ_FLAG
public static final String WRITE_FLAG
public static final String SSE_FLAG
public static final String CMK_FLAG
public static final String TAG_FLAG
public static final String VERBOSE
protected S3GuardTool(org.apache.hadoop.conf.Configuration conf,
String... opts)
conf - Configuration.opts - 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 void parseDynamoDBRegion(List<String> paths) throws IOException
filesystem will no longer
be null.paths - remaining parameters from CLI.IOException - on I/O errors.ExitUtil.ExitException - on validation errorsprotected void addAgeOptions()
protected void checkIfS3BucketIsGuarded(List<String> paths) throws IOException
IOExceptionprotected void checkBucketNameOrDDBTableNameProvided(List<String> paths)
paths - position arguments in which S3 path is provided.protected MetadataStore initMetadataStore(boolean forceCreate) throws IOException
forceCreate - override the auto-creation setting to true.IOException - on unsupported metadata store.protected void initS3AFileSystem(String path) throws IOException
Configuration.get() calls are critical.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 S3AFileSystem getFilesystem()
protected S3AFileSystem bindFilesystem(org.apache.hadoop.fs.FileSystem bindingFS)
bindingFS - filesystem to bind toExitUtil.ExitException - if the FS is not an S3 FSpublic MetadataStore getStore()
protected void setStore(MetadataStore store)
protected void resetBindings()
protected 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 void printStoreDiagnostics(PrintStream out, MetadataStore store) throws IOException
out - output streamstore - storeIOException - Failure to retrieve the data.protected static org.apache.hadoop.util.ExitUtil.ExitException storeNotFound(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 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–2022 Apache Software Foundation. All rights reserved.