Example usage for org.apache.hadoop.fs FsUrlStreamHandlerFactory FsUrlStreamHandlerFactory

List of usage examples for org.apache.hadoop.fs FsUrlStreamHandlerFactory FsUrlStreamHandlerFactory

Introduction

In this page you can find the example usage for org.apache.hadoop.fs FsUrlStreamHandlerFactory FsUrlStreamHandlerFactory.

Prototype

public FsUrlStreamHandlerFactory() 

Source Link

Usage

From source file:com.asakusafw.bulkloader.common.UrlStreamHandlerFactoryRegisterer.java

License:Apache License

/**
 * {@link URLStreamHandlerFactory}???// w  w w  .  j ava  2  s  .com
 */
public static synchronized void register() {
    if (registered) {
        return;
    }
    FsUrlStreamHandlerFactory factory = new FsUrlStreamHandlerFactory();
    try {
        URL.setURLStreamHandlerFactory(factory);
    } catch (Error e) {
        if (e.getClass().equals(Error.class)) {
            // ok.
            return;
        }
        throw e;
    }
    registered = true;
}

From source file:de.tiqsolutions.hdfs.Handler.java

License:Apache License

public Handler() {
    base = new FsUrlStreamHandlerFactory().createURLStreamHandler(HadoopFileSystem.SCHEME);
}

From source file:io.apigee.lembos.utils.RunnerUtils.java

License:Apache License

/**
 * Loads the {@link FsUrlStreamHandlerFactory}.
 *
 * @param conf the configuration to use//from   w w w .  j av  a2 s  . c  om
 *
 * @throws IOException if something goes wrong
 */
public static void loadFsUrlStreamHandler(final Configuration conf) throws IOException {
    // Here to avoid https://issues.apache.org/jira/browse/HADOOP-9041
    FileSystem.get(conf);

    // Hook up the HDFS URL scheme handler
    // noinspection ErrorNotRethrown
    try {
        URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
    } catch (final Error e) {
        // This can happen if the handler has already been loaded so ignore
        System.err.println("The HDFS URL scheme handler has already been loaded");
    }
}

From source file:org.apache.camel.component.hdfs.HdfsComponent.java

License:Apache License

protected void initHdfs() {
    try {//from w w  w . j a v a 2 s. c  o m
        URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
    } catch (Throwable e) {
        // ignore as its most likely already set
        LOG.debug("Cannot set URLStreamHandlerFactory due " + e.getMessage()
                + ". This exception will be ignored.", e);
    }
}

From source file:org.hadoop.tdg.TestPseudoHadoop.java

License:Apache License

@Test
@Ignore("StackOverflowError with *-site.xml")
public void readWithURLHandler() throws IOException {
    URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
    printStream(new URL(fs.getUri() + DST_FILE).openStream());
}