Search in sources :

Example 1 with Bzip2FileProvider

use of org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider in project spoofax by metaborg.

the class DefaultFileSystemManagerProvider method addProviders.

protected void addProviders(DefaultFileSystemManager manager) throws FileSystemException {
    manager.addProvider("tmp", new TemporaryFileProvider());
    manager.addProvider("res", new ResourceFileProvider());
    manager.addProvider("ram", new RamFileProvider());
    manager.addProvider("zip", new ZipFileProvider());
    manager.addProvider("jar", new JarFileProvider());
    manager.addProvider("tar", new TarFileProvider());
    manager.addProvider("tgz", new TgzFileProvider());
    manager.addProvider("tbz2", new Tbz2FileProvider());
    manager.addProvider("gz", new GzipFileProvider());
    manager.addProvider("bz2", new Bzip2FileProvider());
    manager.addProvider("http", new HttpFileProvider());
    manager.addProvider("https", new HttpsFileProvider());
    manager.addProvider("ftp", new FtpFileProvider());
    manager.addProvider("ftps", new FtpsFileProvider());
}
Also used : JarFileProvider(org.apache.commons.vfs2.provider.jar.JarFileProvider) FtpFileProvider(org.apache.commons.vfs2.provider.ftp.FtpFileProvider) ZipFileProvider(org.apache.commons.vfs2.provider.zip.ZipFileProvider) Bzip2FileProvider(org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider) TarFileProvider(org.apache.commons.vfs2.provider.tar.TarFileProvider) TemporaryFileProvider(org.apache.commons.vfs2.provider.temp.TemporaryFileProvider) HttpFileProvider(org.apache.commons.vfs2.provider.http.HttpFileProvider) Tbz2FileProvider(org.apache.commons.vfs2.provider.tar.Tbz2FileProvider) GzipFileProvider(org.apache.commons.vfs2.provider.gzip.GzipFileProvider) HttpsFileProvider(org.apache.commons.vfs2.provider.https.HttpsFileProvider) TgzFileProvider(org.apache.commons.vfs2.provider.tar.TgzFileProvider) FtpsFileProvider(org.apache.commons.vfs2.provider.ftps.FtpsFileProvider) ResourceFileProvider(org.apache.commons.vfs2.provider.res.ResourceFileProvider) RamFileProvider(org.apache.commons.vfs2.provider.ram.RamFileProvider)

Example 2 with Bzip2FileProvider

use of org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider in project accumulo by apache.

the class AccumuloDFSBase method miniDfsClusterSetup.

@BeforeClass
public static void miniDfsClusterSetup() {
    System.setProperty("java.io.tmpdir", System.getProperty("user.dir") + "/target");
    // System.setProperty("org.apache.commons.logging.Log",
    // "org.apache.commons.logging.impl.NoOpLog");
    // Logger.getRootLogger().setLevel(Level.ERROR);
    // Put the MiniDFSCluster directory in the target directory
    System.setProperty("test.build.data", "target/build/test/data");
    // Setup HDFS
    conf = new Configuration();
    conf.set("hadoop.security.token.service.use_ip", "true");
    conf.set("dfs.datanode.data.dir.perm", MiniDFSUtil.computeDatanodeDirectoryPermission());
    // 1M blocksize
    conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, 1024 * 1024);
    try {
        cluster = new MiniDFSCluster.Builder(conf).build();
        cluster.waitClusterUp();
        // We can't assume that the hostname of "localhost" will still be "localhost" after
        // starting up the NameNode. We may get mapped into a FQDN via settings in /etc/hosts.
        HDFS_URI = cluster.getFileSystem().getUri();
    } catch (IOException e) {
        throw new RuntimeException("Error setting up mini cluster", e);
    }
    // Set up the VFS
    vfs = new DefaultFileSystemManager();
    try {
        vfs.setFilesCache(new DefaultFilesCache());
        vfs.addProvider("res", new org.apache.commons.vfs2.provider.res.ResourceFileProvider());
        vfs.addProvider("zip", new org.apache.commons.vfs2.provider.zip.ZipFileProvider());
        vfs.addProvider("gz", new org.apache.commons.vfs2.provider.gzip.GzipFileProvider());
        vfs.addProvider("ram", new org.apache.commons.vfs2.provider.ram.RamFileProvider());
        vfs.addProvider("file", new org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider());
        vfs.addProvider("jar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        vfs.addProvider("http", new org.apache.commons.vfs2.provider.http.HttpFileProvider());
        vfs.addProvider("https", new org.apache.commons.vfs2.provider.https.HttpsFileProvider());
        vfs.addProvider("ftp", new org.apache.commons.vfs2.provider.ftp.FtpFileProvider());
        vfs.addProvider("ftps", new org.apache.commons.vfs2.provider.ftps.FtpsFileProvider());
        vfs.addProvider("war", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        vfs.addProvider("par", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        vfs.addProvider("ear", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        vfs.addProvider("sar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        vfs.addProvider("ejb3", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        vfs.addProvider("tmp", new org.apache.commons.vfs2.provider.temp.TemporaryFileProvider());
        vfs.addProvider("tar", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
        vfs.addProvider("tbz2", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
        vfs.addProvider("tgz", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
        vfs.addProvider("bz2", new org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider());
        vfs.addProvider("hdfs", new HdfsFileProvider());
        vfs.addExtensionMap("jar", "jar");
        vfs.addExtensionMap("zip", "zip");
        vfs.addExtensionMap("gz", "gz");
        vfs.addExtensionMap("tar", "tar");
        vfs.addExtensionMap("tbz2", "tar");
        vfs.addExtensionMap("tgz", "tar");
        vfs.addExtensionMap("bz2", "bz2");
        vfs.addMimeTypeMap("application/x-tar", "tar");
        vfs.addMimeTypeMap("application/x-gzip", "gz");
        vfs.addMimeTypeMap("application/zip", "zip");
        vfs.setFileContentInfoFactory(new FileContentInfoFilenameFactory());
        vfs.setFilesCache(new SoftRefFilesCache());
        vfs.setReplicator(new DefaultFileReplicator(new File(System.getProperty("java.io.tmpdir"), "accumulo-vfs-cache-" + System.getProperty("user.name", "nouser"))));
        vfs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
        vfs.init();
    } catch (FileSystemException e) {
        throw new RuntimeException("Error setting up VFS", e);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HdfsFileProvider(org.apache.commons.vfs2.provider.hdfs.HdfsFileProvider) FileSystemException(org.apache.commons.vfs2.FileSystemException) FileContentInfoFilenameFactory(org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory) SoftRefFilesCache(org.apache.commons.vfs2.cache.SoftRefFilesCache) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) DefaultFilesCache(org.apache.commons.vfs2.cache.DefaultFilesCache) IOException(java.io.IOException) DefaultFileReplicator(org.apache.commons.vfs2.impl.DefaultFileReplicator) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 3 with Bzip2FileProvider

use of org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider in project accumulo by apache.

the class AccumuloVFSClassLoader method generateVfs.

public static FileSystemManager generateVfs() throws FileSystemException {
    DefaultFileSystemManager vfs = new DefaultFileSystemManager();
    vfs.addProvider("res", new org.apache.commons.vfs2.provider.res.ResourceFileProvider());
    vfs.addProvider("zip", new org.apache.commons.vfs2.provider.zip.ZipFileProvider());
    vfs.addProvider("gz", new org.apache.commons.vfs2.provider.gzip.GzipFileProvider());
    vfs.addProvider("ram", new org.apache.commons.vfs2.provider.ram.RamFileProvider());
    vfs.addProvider("file", new org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider());
    vfs.addProvider("jar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("http", new org.apache.commons.vfs2.provider.http.HttpFileProvider());
    vfs.addProvider("https", new org.apache.commons.vfs2.provider.https.HttpsFileProvider());
    vfs.addProvider("ftp", new org.apache.commons.vfs2.provider.ftp.FtpFileProvider());
    vfs.addProvider("ftps", new org.apache.commons.vfs2.provider.ftps.FtpsFileProvider());
    vfs.addProvider("war", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("par", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("ear", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("sar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("ejb3", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("tmp", new org.apache.commons.vfs2.provider.temp.TemporaryFileProvider());
    vfs.addProvider("tar", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
    vfs.addProvider("tbz2", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
    vfs.addProvider("tgz", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
    vfs.addProvider("bz2", new org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider());
    vfs.addProvider("hdfs", new HdfsFileProvider());
    vfs.addExtensionMap("jar", "jar");
    vfs.addExtensionMap("zip", "zip");
    vfs.addExtensionMap("gz", "gz");
    vfs.addExtensionMap("tar", "tar");
    vfs.addExtensionMap("tbz2", "tar");
    vfs.addExtensionMap("tgz", "tar");
    vfs.addExtensionMap("bz2", "bz2");
    vfs.addMimeTypeMap("application/x-tar", "tar");
    vfs.addMimeTypeMap("application/x-gzip", "gz");
    vfs.addMimeTypeMap("application/zip", "zip");
    vfs.setFileContentInfoFactory(new FileContentInfoFilenameFactory());
    vfs.setFilesCache(new SoftRefFilesCache());
    File cacheDir = computeTopCacheDir();
    vfs.setReplicator(new UniqueFileReplicator(cacheDir));
    vfs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
    vfs.init();
    vfsInstances.add(new WeakReference<>(vfs));
    return vfs;
}
Also used : HdfsFileProvider(org.apache.commons.vfs2.provider.hdfs.HdfsFileProvider) FileContentInfoFilenameFactory(org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory) SoftRefFilesCache(org.apache.commons.vfs2.cache.SoftRefFilesCache) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) File(java.io.File)

Example 4 with Bzip2FileProvider

use of org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider in project hop by apache.

the class HopVfs method createFileSystemManager.

/**
 * Make sure to close when done using!
 *
 * @return A new standard file system manager
 * @throws HopException
 */
private static DefaultFileSystemManager createFileSystemManager() throws HopException {
    try {
        DefaultFileSystemManager fsm = new DefaultFileSystemManager();
        fsm.addProvider("ram", new org.apache.commons.vfs2.provider.ram.RamFileProvider());
        fsm.addProvider("file", new org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider());
        fsm.addProvider("res", new org.apache.commons.vfs2.provider.res.ResourceFileProvider());
        fsm.addProvider("zip", new org.apache.commons.vfs2.provider.zip.ZipFileProvider());
        fsm.addProvider("gz", new org.apache.commons.vfs2.provider.gzip.GzipFileProvider());
        fsm.addProvider("jar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        fsm.addProvider("http", new org.apache.commons.vfs2.provider.http.HttpFileProvider());
        fsm.addProvider("https", new org.apache.commons.vfs2.provider.https.HttpsFileProvider());
        fsm.addProvider("ftp", new org.apache.commons.vfs2.provider.ftp.FtpFileProvider());
        fsm.addProvider("ftps", new org.apache.commons.vfs2.provider.ftps.FtpsFileProvider());
        fsm.addProvider("war", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        fsm.addProvider("par", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        fsm.addProvider("ear", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        fsm.addProvider("sar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        fsm.addProvider("ejb3", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
        fsm.addProvider("tmp", new org.apache.commons.vfs2.provider.temp.TemporaryFileProvider());
        fsm.addProvider("tar", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
        fsm.addProvider("tbz2", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
        fsm.addProvider("tgz", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
        fsm.addProvider("bz2", new org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider());
        fsm.addProvider("files-cache", new org.apache.commons.vfs2.provider.temp.TemporaryFileProvider());
        fsm.addExtensionMap("jar", "jar");
        fsm.addExtensionMap("zip", "zip");
        fsm.addExtensionMap("gz", "gz");
        fsm.addExtensionMap("tar", "tar");
        fsm.addExtensionMap("tbz2", "tar");
        fsm.addExtensionMap("tgz", "tar");
        fsm.addExtensionMap("bz2", "bz2");
        fsm.addMimeTypeMap("application/x-tar", "tar");
        fsm.addMimeTypeMap("application/x-gzip", "gz");
        fsm.addMimeTypeMap("application/zip", "zip");
        fsm.setFileContentInfoFactory(new FileContentInfoFilenameFactory());
        fsm.setReplicator(new DefaultFileReplicator());
        fsm.setFilesCache(new SoftRefFilesCache());
        fsm.setCacheStrategy(CacheStrategy.ON_RESOLVE);
        // Here are extra VFS plugins to register
        // 
        PluginRegistry registry = PluginRegistry.getInstance();
        List<IPlugin> plugins = registry.getPlugins(VfsPluginType.class);
        for (IPlugin plugin : plugins) {
            IVfs iVfs = registry.loadClass(plugin, IVfs.class);
            try {
                fsm.addProvider(iVfs.getUrlSchemes(), iVfs.getProvider());
            } catch (Exception e) {
                throw new HopException("Error registering provider for VFS plugin " + plugin.getIds()[0] + " : " + plugin.getName() + " : ", e);
            }
        }
        fsm.init();
        return fsm;
    } catch (Exception e) {
        throw new HopException("Error creating file system manager", e);
    }
}
Also used : IPlugin(org.apache.hop.core.plugins.IPlugin) FileContentInfoFilenameFactory(org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory) SoftRefFilesCache(org.apache.commons.vfs2.cache.SoftRefFilesCache) IVfs(org.apache.hop.core.vfs.plugin.IVfs) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) HopException(org.apache.hop.core.exception.HopException) HopException(org.apache.hop.core.exception.HopException) HopFileException(org.apache.hop.core.exception.HopFileException) PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) org.apache.commons.vfs2(org.apache.commons.vfs2) DefaultFileReplicator(org.apache.commons.vfs2.impl.DefaultFileReplicator)

Example 5 with Bzip2FileProvider

use of org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider in project metron by apache.

the class VFSClassloaderUtil method generateVfs.

/**
 * Create a FileSystem manager suitable for our purposes.
 * This manager supports files of the following types:
 * * res - resource files
 * * jar
 * * tar
 * * bz2
 * * tgz
 * * zip
 * * HDFS
 * * FTP
 * * HTTP/S
 * * file
 * @return vfs
 * @throws FileSystemException
 */
public static FileSystemManager generateVfs() throws FileSystemException {
    DefaultFileSystemManager vfs = new DefaultFileSystemManager();
    vfs.addProvider("res", new org.apache.commons.vfs2.provider.res.ResourceFileProvider());
    vfs.addProvider("zip", new org.apache.commons.vfs2.provider.zip.ZipFileProvider());
    vfs.addProvider("gz", new org.apache.commons.vfs2.provider.gzip.GzipFileProvider());
    vfs.addProvider("ram", new org.apache.commons.vfs2.provider.ram.RamFileProvider());
    vfs.addProvider("file", new org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider());
    vfs.addProvider("jar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("http", new org.apache.commons.vfs2.provider.http.HttpFileProvider());
    vfs.addProvider("https", new org.apache.commons.vfs2.provider.https.HttpsFileProvider());
    vfs.addProvider("ftp", new org.apache.commons.vfs2.provider.ftp.FtpFileProvider());
    vfs.addProvider("ftps", new org.apache.commons.vfs2.provider.ftps.FtpsFileProvider());
    vfs.addProvider("war", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("par", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("ear", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("sar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("ejb3", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
    vfs.addProvider("tmp", new org.apache.commons.vfs2.provider.temp.TemporaryFileProvider());
    vfs.addProvider("tar", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
    vfs.addProvider("tbz2", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
    vfs.addProvider("tgz", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
    vfs.addProvider("bz2", new org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider());
    vfs.addProvider("hdfs", new HdfsFileProvider());
    vfs.addExtensionMap("jar", "jar");
    vfs.addExtensionMap("zip", "zip");
    vfs.addExtensionMap("gz", "gz");
    vfs.addExtensionMap("tar", "tar");
    vfs.addExtensionMap("tbz2", "tar");
    vfs.addExtensionMap("tgz", "tar");
    vfs.addExtensionMap("bz2", "bz2");
    vfs.addMimeTypeMap("application/x-tar", "tar");
    vfs.addMimeTypeMap("application/x-gzip", "gz");
    vfs.addMimeTypeMap("application/zip", "zip");
    vfs.setFileContentInfoFactory(new FileContentInfoFilenameFactory());
    vfs.setFilesCache(new SoftRefFilesCache());
    vfs.setReplicator(new UniqueFileReplicator(new File(System.getProperty("java.io.tmpdir"))));
    vfs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
    vfs.init();
    return vfs;
}
Also used : HdfsFileProvider(org.apache.commons.vfs2.provider.hdfs.HdfsFileProvider) UniqueFileReplicator(org.apache.accumulo.start.classloader.vfs.UniqueFileReplicator) FileContentInfoFilenameFactory(org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory) SoftRefFilesCache(org.apache.commons.vfs2.cache.SoftRefFilesCache) DefaultFileSystemManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager) File(java.io.File)

Aggregations

SoftRefFilesCache (org.apache.commons.vfs2.cache.SoftRefFilesCache)4 DefaultFileSystemManager (org.apache.commons.vfs2.impl.DefaultFileSystemManager)4 FileContentInfoFilenameFactory (org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory)4 File (java.io.File)3 HdfsFileProvider (org.apache.commons.vfs2.provider.hdfs.HdfsFileProvider)3 DefaultFileReplicator (org.apache.commons.vfs2.impl.DefaultFileReplicator)2 IOException (java.io.IOException)1 UniqueFileReplicator (org.apache.accumulo.start.classloader.vfs.UniqueFileReplicator)1 org.apache.commons.vfs2 (org.apache.commons.vfs2)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 DefaultFilesCache (org.apache.commons.vfs2.cache.DefaultFilesCache)1 Bzip2FileProvider (org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider)1 FtpFileProvider (org.apache.commons.vfs2.provider.ftp.FtpFileProvider)1 FtpsFileProvider (org.apache.commons.vfs2.provider.ftps.FtpsFileProvider)1 GzipFileProvider (org.apache.commons.vfs2.provider.gzip.GzipFileProvider)1 HttpFileProvider (org.apache.commons.vfs2.provider.http.HttpFileProvider)1 HttpsFileProvider (org.apache.commons.vfs2.provider.https.HttpsFileProvider)1 JarFileProvider (org.apache.commons.vfs2.provider.jar.JarFileProvider)1 RamFileProvider (org.apache.commons.vfs2.provider.ram.RamFileProvider)1 ResourceFileProvider (org.apache.commons.vfs2.provider.res.ResourceFileProvider)1