/** @return the configured factory. */ public static Factory<?> getFactory(Configuration conf) { @SuppressWarnings("rawtypes") final Class<? extends Factory> clazz = conf.getClass( DFSConfigKeys.DFS_DATANODE_FSDATASET_FACTORY_KEY, FsDatasetFactory.class, Factory.class); return ReflectionUtils.newInstance(clazz, conf); }
@Test public void testFSDatasetFactory() { final Configuration conf = new Configuration(); FsDatasetSpi.Factory<?> f = FsDatasetSpi.Factory.getFactory(conf); assertEquals(FsDatasetFactory.class, f.getClass()); assertFalse(f.isSimulated()); SimulatedFSDataset.setFactory(conf); FsDatasetSpi.Factory<?> s = FsDatasetSpi.Factory.getFactory(conf); assertEquals(SimulatedFSDataset.Factory.class, s.getClass()); assertTrue(s.isSimulated()); }
/** * By default, it returns FsDatasetImplTestUtilsFactory. * * @return The configured Factory. */ public static Factory<?> getFactory(Configuration conf) { String className = conf.get( DFSConfigKeys.DFS_DATANODE_FSDATASET_FACTORY_KEY, FsDatasetFactory.class.getName()); Preconditions.checkState(className.contains("Factory")); className = className.replaceFirst("(\\$)?Factory$", "TestUtilsFactory"); final Class<? extends Factory> clazz = conf.getClass( className, FsDatasetImplTestUtilsFactory.class, Factory.class); return ReflectionUtils.newInstance(clazz, conf); }
/** * @return the configured factory. */ public static Factory<?> getFactory(Configuration conf) { @SuppressWarnings("rawtypes") final Class<? extends Factory> clazz = conf.getClass(DFSConfigKeys.DFS_DATANODE_FSDATASET_FACTORY_KEY, FsDatasetFactory.class, Factory.class); return ReflectionUtils.newInstance(clazz, conf); }