Search in sources :

Example 1 with HdfsFileObject

use of org.apache.commons.vfs2.provider.hdfs.HdfsFileObject in project accumulo by apache.

the class AccumuloVFSClassLoader method getClassLoader.

public static ClassLoader getClassLoader() throws IOException {
    ReloadingClassLoader localLoader = loader;
    while (null == localLoader) {
        synchronized (lock) {
            if (null == loader) {
                FileSystemManager vfs = generateVfs();
                // Set up the 2nd tier class loader
                if (null == parent) {
                    parent = AccumuloClassLoader.getClassLoader();
                }
                FileObject[] vfsCP = resolve(vfs, AccumuloClassLoader.getAccumuloProperty(VFS_CLASSLOADER_SYSTEM_CLASSPATH_PROPERTY, ""));
                if (vfsCP.length == 0) {
                    localLoader = createDynamicClassloader(parent);
                    loader = localLoader;
                    return localLoader.getClassLoader();
                }
                // Create the Accumulo Context ClassLoader using the DEFAULT_CONTEXT
                localLoader = createDynamicClassloader(new VFSClassLoader(vfsCP, vfs, parent));
                loader = localLoader;
                // and SequenceFile$Reader was trying to instantiate the key class via WritableName.getClass(String, Configuration)
                for (FileObject fo : vfsCP) {
                    if (fo instanceof HdfsFileObject) {
                        String uri = fo.getName().getRootURI();
                        Configuration c = new Configuration(true);
                        c.set(FileSystem.FS_DEFAULT_NAME_KEY, uri);
                        FileSystem fs = FileSystem.get(c);
                        fs.getConf().setClassLoader(loader.getClassLoader());
                    }
                }
            }
        }
    }
    return localLoader.getClassLoader();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HdfsFileObject(org.apache.commons.vfs2.provider.hdfs.HdfsFileObject) FileSystem(org.apache.hadoop.fs.FileSystem) VFSClassLoader(org.apache.commons.vfs2.impl.VFSClassLoader) FileObject(org.apache.commons.vfs2.FileObject) HdfsFileObject(org.apache.commons.vfs2.provider.hdfs.HdfsFileObject) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) FileSystemManager(org.apache.commons.vfs2.FileSystemManager)

Aggregations

FileObject (org.apache.commons.vfs2.FileObject)1 FileSystemManager (org.apache.commons.vfs2.FileSystemManager)1 DefaultFileSystemManager (org.apache.commons.vfs2.impl.DefaultFileSystemManager)1 VFSClassLoader (org.apache.commons.vfs2.impl.VFSClassLoader)1 HdfsFileObject (org.apache.commons.vfs2.provider.hdfs.HdfsFileObject)1 Configuration (org.apache.hadoop.conf.Configuration)1 FileSystem (org.apache.hadoop.fs.FileSystem)1