Example usage for org.apache.hadoop.fs FileContext getDefaultFileSystem

List of usage examples for org.apache.hadoop.fs FileContext getDefaultFileSystem

Introduction

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

Prototype

@InterfaceAudience.Private
    @InterfaceStability.Unstable 
    public AbstractFileSystem getDefaultFileSystem() 

Source Link

Usage

From source file:com.ikanow.aleph2.core.shared.test_services.MockStorageService.java

License:Apache License

@SuppressWarnings("unchecked")
@Override/*from  w ww  .  j  a  v  a 2 s.c  o m*/
public <T> Optional<T> getUnderlyingPlatformDriver(Class<T> driver_class, Optional<String> driver_options) {
    T driver = null;
    try {
        if (driver_class != null) {
            if (driver_class.isAssignableFrom(FileContext.class)) {
                FileContext fs = FileContext.getLocalFSFileContext(new Configuration());
                return (Optional<T>) Optional.of(fs);
            } else if (driver_class.isAssignableFrom(RawLocalFileSystem.class)) {
                return Optional.of(driver_class.newInstance());
            } else if (driver_class.isAssignableFrom(AbstractFileSystem.class)) {
                FileContext fs = FileContext.getLocalFSFileContext(new Configuration());
                return (Optional<T>) Optional.of(fs.getDefaultFileSystem());
            }

        } // !=null
    } catch (Exception e) {
        _logger.error("Caught Exception:", e);
    }
    return Optional.ofNullable(driver);
}

From source file:org.apache.tajo.master.TaskRunnerLauncherImpl.java

License:Apache License

private LocalResource createApplicationResource(FileContext fs, Path p, LocalResourceType type)
        throws IOException {
    LocalResource rsrc = recordFactory.newRecordInstance(LocalResource.class);
    FileStatus rsrcStat = fs.getFileStatus(p);
    rsrc.setResource(//  w w  w. ja v  a2 s  .c o  m
            ConverterUtils.getYarnUrlFromPath(fs.getDefaultFileSystem().resolvePath(rsrcStat.getPath())));
    rsrc.setSize(rsrcStat.getLen());
    rsrc.setTimestamp(rsrcStat.getModificationTime());
    rsrc.setType(type);
    rsrc.setVisibility(LocalResourceVisibility.APPLICATION);
    return rsrc;
}

From source file:org.apache.tajo.master.YarnContainerProxy.java

License:Apache License

private static LocalResource createApplicationResource(FileContext fs, Path p, LocalResourceType type)
        throws IOException {
    LocalResource rsrc = recordFactory.newRecordInstance(LocalResource.class);
    FileStatus rsrcStat = fs.getFileStatus(p);
    rsrc.setResource(/*www  . j a  v a  2s .  co m*/
            ConverterUtils.getYarnUrlFromPath(fs.getDefaultFileSystem().resolvePath(rsrcStat.getPath())));
    rsrc.setSize(rsrcStat.getLen());
    rsrc.setTimestamp(rsrcStat.getModificationTime());
    rsrc.setType(type);
    rsrc.setVisibility(LocalResourceVisibility.APPLICATION);
    return rsrc;
}

From source file:org.apache.tez.mapreduce.client.YARNRunner.java

License:Apache License

private LocalResource createApplicationResource(FileContext fs, Path p, LocalResourceType type)
        throws IOException {
    LocalResource rsrc = Records.newRecord(LocalResource.class);
    FileStatus rsrcStat = fs.getFileStatus(p);
    rsrc.setResource(//from  w  ww  .  ja va  2 s  . c  o  m
            ConverterUtils.getYarnUrlFromPath(fs.getDefaultFileSystem().resolvePath(rsrcStat.getPath())));
    rsrc.setSize(rsrcStat.getLen());
    rsrc.setTimestamp(rsrcStat.getModificationTime());
    rsrc.setType(type);
    rsrc.setVisibility(LocalResourceVisibility.APPLICATION);
    return rsrc;
}