/** * @return The engine name we are built on, e.g., "spark" or "java_collections" */ public String getEngine() { return this.getManager().getEngine(); }
@SuppressWarnings("unchecked") private DDF newDDF(Class<?>[] argTypes, Object[] argValues) throws DDFException { String className = Config.getValueWithGlobalDefault(this.getEngine(), ConfigConstant.FIELD_DDF); if (Strings.isNullOrEmpty(className)) throw new DDFException(String.format( "Cannot determine class name for [%s] %s", this.getEngine(), "DDF")); try { Constructor<DDF> cons = (Constructor<DDF>) Class.forName(className).getDeclaredConstructor(argTypes); if (cons == null) throw new DDFException("Cannot get constructor for " + className); cons.setAccessible(true); // make sure we can use it whether it's // private, protected, or public DDF ddf = cons.newInstance(argValues); if (ddf == null) throw new DDFException("Cannot instantiate a new instance of " + className); this.addDDF(ddf); return ddf; } catch (Exception e) { throw new DDFException(String.format( "While instantiating a new %s DDF of class %s with argTypes %s and argValues %s", this.getEngine(), className, Arrays.toString(argTypes), Arrays.toString(argValues)), e); } }
public String getEngine() { return (this.getManager() != null ? this.getManager().getEngine() : null); }
@Test public void testDDFConfig() throws Exception { Assert.assertEquals("spark", manager.getEngine()); }
@Test public void testReadConfig() throws Exception { DDFManager manager = DDFManager.get(DDFManager.EngineType.BASIC); // this will trigger a configuration loading Assert.assertEquals("basic", manager.getEngine()); Configuration config = Config.getConfigHandler().getConfig(); Assert.assertNotNull(config); Map<String, Section> sections = config.getSections(); Assert.assertNotNull(sections); for (String sectionName : sections.keySet()) { Map<String, String> settings = config.getSettings(sectionName); Assert.assertNotNull(settings); } }
@Test public void testLoadConfig() throws Exception { DDFManager manager = DDFManager.get(DDFManager.EngineType.BASIC); // this will trigger a configuration loading Assert.assertEquals("basic", manager.getEngine()); Assert.assertNotNull(Config.getConfigHandler()); Assert.assertNotNull(Config.getConfigHandler().loadConfig()); }