List of usage examples for org.apache.hadoop.fs FileSystem getFileSystemClass
public static Class<? extends FileSystem> getFileSystemClass(String scheme, Configuration conf) throws IOException
From source file:alluxio.checker.CheckerUtils.java
License:Apache License
/** * @return if the current node can recognize Alluxio classes and filesystem *///from w ww . j a v a 2 s.c o m public static Status performIntegrationChecks() { // Check if the current node can recognize Alluxio classes try { // Check if the current node can recognize Alluxio common classes Class.forName("alluxio.AlluxioURI"); // Check if current node can recognize Alluxio core client classes Class.forName("alluxio.client.file.BaseFileSystem"); Class.forName("alluxio.hadoop.AlluxioFileSystem"); } catch (ClassNotFoundException e) { LOG.error("Failed to find Alluxio classes on classpath", e); return Status.FAIL_TO_FIND_CLASS; } // Check if the current node can recognize Alluxio filesystem try { FileSystem.getFileSystemClass("alluxio", new Configuration()); } catch (Exception e) { LOG.error("Failed to find Alluxio filesystem", e); return Status.FAIL_TO_FIND_FS; } return Status.SUCCESS; }
From source file:alluxio.checker.SparkIntegrationChecker.java
License:Apache License
/** * @return if this Spark driver or executors can recognize Alluxio classes and filesystem *//*w w w . ja v a 2 s. c om*/ private Status performIntegrationChecks() { // Checks if Spark driver or executors can recognize Alluxio classes try { // Checks if Spark driver or executors can recognize Alluxio common classes Class.forName("alluxio.AlluxioURI"); // Checks if Spark driver or executors can recognize Alluxio core client classes Class.forName("alluxio.client.file.BaseFileSystem"); Class.forName("alluxio.hadoop.AlluxioFileSystem"); } catch (ClassNotFoundException e) { LOG.error("Failed to find Alluxio classes on classpath ", e); return Status.FAIL_TO_FIND_CLASS; } // Checks if Spark driver or executors can recognize Alluxio filesystem try { FileSystem.getFileSystemClass("alluxio", new Configuration()); } catch (Exception e) { LOG.error("Failed to find Alluxio filesystem ", e); return Status.FAIL_TO_FIND_FS; } return Status.SUCCESS; }
From source file:gobblin.util.filesystem.FileSystemFactory.java
License:Apache License
@Override public SharedResourceFactoryResponse<FileSystem> createResource(SharedResourcesBroker<S> broker, ScopedConfigView<S, FileSystemKey> config) throws NotConfiguredException { try {//from ww w. ja v a 2s. com FileSystemKey key = config.getKey(); URI uri = key.getUri(); Configuration hadoopConf = key.getConfiguration(); log.info("Creating instrumented FileSystem for uri " + uri); Class<? extends FileSystem> fsClass = FileSystem.getFileSystemClass(uri.getScheme(), hadoopConf); if (InstrumentedFileSystem.class.isAssignableFrom(fsClass)) { InstrumentedFileSystem tmpfs = (InstrumentedFileSystem) fsClass.newInstance(); hadoopConf = new Configuration(hadoopConf); String schemeKey = "fs." + uri.getScheme() + ".impl"; hadoopConf.set(schemeKey, tmpfs.underlyingFs.getClass().getName()); } FileSystem fs = FileSystem.newInstance(uri, hadoopConf); ServiceLoader<FileSystemInstrumentationFactory> loader = ServiceLoader .load(FileSystemInstrumentationFactory.class); for (FileSystemInstrumentationFactory instrumentationFactory : loader) { fs = instrumentationFactory.instrumentFileSystem(fs, broker, config); } return new ResourceInstance<>(fs); } catch (IOException | ReflectiveOperationException ioe) { throw new RuntimeException(ioe); } }
From source file:org.hypertable.DfsBroker.hadoop.HadoopBroker.java
License:Open Source License
/** * Returns a brand new instance of the FileSystem * /*from ww w. jav a2 s . c o m*/ * @return A new instance of the filesystem */ private FileSystem newInstanceFileSystem() throws IOException { URI uri = FileSystem.getDefaultUri(mConf); Class<?> clazz = FileSystem.getFileSystemClass(uri.getScheme(), mConf); if (clazz == null) throw new IOException("HdfsBroker: No FileSystem for scheme: " + uri.getScheme()); FileSystem fs = (FileSystem) ReflectionUtils.newInstance(clazz, mConf); fs.initialize(uri, mConf); return fs; }