public AsyncDriver(String resource, String uuid, OpMode op) throws Exception { this.opMode = op; this.localConfig = ConfigurationLoader.load(resource); if (opMode == OpMode.PRODUCER || opMode == OpMode.REPORT) { resource += "-producer"; this.config = ConfigurationLoader.load(resource); } else { resource += "-consumer"; this.config = ConfigurationLoader.load(resource); } TypeSystemDescription typeSystem = TypeSystemDescriptionFactory.createTypeSystemDescription(); this.builder = new BaseExperimentBuilder(uuid, resource, typeSystem); this.asyncConfig = builder.initializeResource(config, "async-configuration", AsyncConfiguration.class); }
@Deprecated public static <C> Class<? extends C> loadFromClassOrInherit(String handle, Class<C> ifaceClass, Map<String, Object> tuples) throws Exception { String[] name = handle.split("!"); if (name[0].equals("class")) { return Class.forName(name[1]).asSubclass(ifaceClass); } else { if (name[0].equals("inherit")) { AnyObject yaml = ConfigurationLoader.load(name[1]); return getFromClassOrInherit(yaml, ifaceClass, tuples); } else { throw new IllegalArgumentException( "Illegal experiment descriptor, must contain one node of type <class> or <inherit>"); } } }
public BaseExperimentBuilder(String experimentUuid, String resource, TypeSystemDescription typeSystem) throws Exception { this.typeSystem = typeSystem; this.experimentUuid = experimentUuid; this.configuration = ConfigurationLoader.load(resource); this.persistence = newPersistenceProvider(configuration); insertExperiment(configuration, resource); }
public static <C> Class<? extends C> loadFromClassOrInherit(ResourceHandle resource, Class<C> ifaceClass, Map<String, Object> tuples) throws Exception { if (resource.getType() == HandleType.CLASS) { return Class.forName(resource.resource).asSubclass(ifaceClass); } else { if (resource.getType() == HandleType.INHERIT) { AnyObject yaml = ConfigurationLoader.load(resource.resource); return getFromClassOrInherit(yaml, ifaceClass, tuples); } else { throw new IllegalArgumentException( "Illegal experiment descriptor, must contain one node of type <class> or <inherit>"); } } }
private String[] getFromListOrInherit(AnyObject descriptor, String listName) throws IOException { Iterable<String> iterable = descriptor.getIterable(listName); if (iterable != null) { ArrayList<String> typePrioritiesList = new ArrayList<String>(); for (String type : iterable) { typePrioritiesList.add(type); System.out.println("Loaded type priorities: " + type); } return typePrioritiesList.toArray(new String[0]); } else { String resource = descriptor.getString("inherit"); if (resource != null) { AnyObject yaml = ConfigurationLoader.load(resource); return getFromListOrInherit(yaml, listName); } else { throw new IllegalArgumentException( "Illegal experiment descriptor, must contain one list of type <" + listName + "> or <inherit>"); } } }
public static <C> Class<? extends C> getFromClassOrInherit(AnyObject descriptor, Class<C> ifaceClass, Map<String, Object> tuples) throws Exception { for (AnyTuple tuple : descriptor.getTuples()) { if (!FILTER.contains(tuple.getKey())) { if (!tuples.containsKey(tuple.getKey())) { tuples.put(tuple.getKey(), tuple.getObject()); } } } String name = descriptor.getString("class"); if (name != null) { return Class.forName(name).asSubclass(ifaceClass); } else { String resource = descriptor.getString("inherit"); if (resource != null) { AnyObject yaml = ConfigurationLoader.load(resource); return getFromClassOrInherit(yaml, ifaceClass, tuples); } else { throw new IllegalArgumentException( "Illegal experiment descriptor, must contain one node of type <class> or <inherit>"); } } }