i need to check if a bucket exist on S3, and have following code:
public static final String S3_URI = "s3n://accessKey:secretKey";
FileSystem fs = new NativeS3FileSystem(new Jets3tNativeFileSystemStore(S3_URI, null));
if (!fs.exists(bucket)) {
getLogger().error("The input directory '{}' does not exists.", bucket);
return false;
}
but eclipse complained cannot resolve Jets3tNativeFileSystemStore to a type, and the imports statements complained org.apache.hadoop.fs.s3native.Jets3tNativeFileSystemStore is not visible. checked the source code for Jets3tNativeFileSystemStore, it’s
class Jets3tNativeFileSystemStore implements NativeFileSystemStore {
private S3Service s3Service;
private S3Bucket bucket;
...
does that mean it’s a private class? what’s the right way to check if bucket exist on S3? Thanks.
It is package-private. You can only access it from the same java package. Although nothing prevents you from declaring things in that package, it is an ugly hack. Isn’t there a static method on
FileSystemthat can serve up the appropriate file system for any URL, including s3n://?