2012-07-23 126 views
0

我需要检查,如果一个桶上存在S3,并有下面的代码:如何初始化Jets3tNativeFileSystemStore

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; 
} 

但是Eclipse抱怨解决不了Jets3tNativeFileSystemStore的类型,和进口报表抱怨org.apache.hadoop .fs.s3native.Jets3tNativeFileSystemStore不可见。检查了Jets3tNativeFileSystemStore的源代码,这是

class Jets3tNativeFileSystemStore implements NativeFileSystemStore { 

    private S3Service s3Service; 
    private S3Bucket bucket; 
    ... 

这是否意味着它是一个私人类?什么是正确的方法来检查存在S3上的存储桶?谢谢。

回答

1

它是包私有的。您只能从相同的Java包中访问它。虽然没有什么能够阻止你在这个包中声明事物,但这是一个丑陋的黑客。 FileSystem上没有静态方法可以为任何URL提供适当的文件系统,包括s3n://?

+0

是的,改为使用NativeS3FileSystem并直接调用exists(),它的工作原理。谢谢 – user468587 2012-07-23 20:47:45