This commit is contained in:
Lucio Lelii 2017-09-19 15:19:34 +00:00
parent 359629e72b
commit 14d8dc7a68
14 changed files with 79 additions and 197 deletions

View File

@ -85,7 +85,7 @@ public class FileTools {
if (file.exists() && (file.isDirectory() || !file.canWrite()))
return false;
else
return true;
return true;
}
public static String loadString(String filename, String encoding) throws Exception {

View File

@ -16,7 +16,7 @@ import com.rapidminer.RapidMiner;
public class AlgorithmConfiguration extends LexicalEngineConfiguration implements Serializable{
private static final long serialVersionUID = 1L;
public static Properties getProperties(String absoluteFilePath) {
Properties props = new Properties();
FileInputStream fis = null;
@ -52,6 +52,8 @@ public class AlgorithmConfiguration extends LexicalEngineConfiguration implement
public static String StatisticalManagerClass = "Services";
public static String listSeparator="#";
private ClassLoader algorithmClassLoader;
public static String getListSeparator() {
return listSeparator;
}
@ -103,6 +105,14 @@ public class AlgorithmConfiguration extends LexicalEngineConfiguration implement
configPath+="/";
this.configPath = configPath;
}
public ClassLoader getAlgorithmClassLoader() {
return algorithmClassLoader;
}
public void setAlgorithmClassLoader(ClassLoader algorithmClassLoader) {
this.algorithmClassLoader = algorithmClassLoader;
}
public String getConfigPath() {
return configPath;

View File

@ -28,47 +28,4 @@ public abstract class ActorNode implements GenericAlgorithm{
// prostprocess after the whole calculation : reduce operation
public abstract void postProcess(boolean manageDuplicates, boolean manageFault);
public static void main(String[] args) throws Exception {
try {
System.out.println("Generic Node: Process Started ");
try {
for (int i = 0; i < args.length; i++) {
System.out.println("Generic Node: RECEIVED INPUT " + args[i]);
}
} catch (Exception e) {
}
System.out.println("Generic Node: checking arguments from " + args[0]);
String[] rargs = args[0].split("_");
int order = Integer.parseInt(rargs[0]);
System.out.println("Generic Node: order: " + order);
int chunksize = Integer.parseInt(rargs[1]);
System.out.println("Generic Node: chunk: " + chunksize);
int speciesOrder = Integer.parseInt(rargs[2]);
System.out.println("Generic Node: species: " + speciesOrder);
int speciesChunksize = Integer.parseInt(rargs[3]);
System.out.println("Generic Node: species chunk size: " + speciesChunksize);
String path = rargs[4];
System.out.println("Generic Node: path: " + path);
String algorithmClass = rargs[5];
System.out.println("Generic Node: algorithmClass: " + algorithmClass);
Boolean duplicate = Boolean.parseBoolean(rargs[6]);
System.out.println("Generic Node: duplicate message: " + duplicate);
String nodeConfiguration = rargs[7];
System.out.println("Generic Node: config: " + nodeConfiguration);
String logfile = args[1];
System.out.println("Generic Node: logfile: " + logfile);
System.out.println("Generic Node: executing class");
ActorNode node = (ActorNode) Class.forName(algorithmClass).newInstance();
node.executeNode(order, chunksize, speciesOrder, speciesChunksize, duplicate, path, nodeConfiguration, logfile);
} catch (Exception e) {
System.out.println("ERROR " + e.getMessage());
System.out.println(e);
}
}
}

View File

@ -1,8 +1,5 @@
package org.gcube.dataanalysis.ecoengine.interfaces;
import java.io.File;
import java.io.FileWriter;
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
public abstract class SpatialProbabilityDistributionNode implements GenericAlgorithm {
@ -34,47 +31,6 @@ public abstract class SpatialProbabilityDistributionNode implements GenericAlgor
//prostprocess after the whole calculation : reduce operation
public abstract void postProcess(boolean manageDuplicates, boolean manageFault);
public static void main(String[] args) throws Exception{
try{
System.out.println("Generic Node: Process Started ");
try {
for (int i = 0; i < args.length; i++) {
System.out.println("Generic Node: RECEIVED INPUT " + args[i]);
}
} catch (Exception e) {
}
System.out.println("Generic Node: checking arguments from "+args[0]);
String[] rargs = args[0].split("_");
int order = Integer.parseInt(rargs[0]);
System.out.println("Generic Node: order: " + order);
int chunksize = Integer.parseInt(rargs[1]);
System.out.println("Generic Node: chunk: " + chunksize);
int speciesOrder = Integer.parseInt(rargs[2]);
System.out.println("Generic Node: species: " + speciesOrder);
int speciesChunksize = Integer.parseInt(rargs[3]);
System.out.println("Generic Node: species chunk size: " + speciesChunksize);
String path = rargs[4];
System.out.println("Generic Node: path: " + path);
String algorithmClass = rargs[5];
System.out.println("Generic Node: algorithmClass: " + algorithmClass);
Boolean duplicate = Boolean.parseBoolean(rargs[6]);
System.out.println("Generic Node: duplicate message: " + duplicate);
String nodeConfiguration = rargs[7];
System.out.println("Generic Node: config: " + nodeConfiguration);
String logfile = args[1];
System.out.println("Generic Node: logfile: " + logfile);
System.out.println("Generic Node: executing class");
SpatialProbabilityDistributionNode node = (SpatialProbabilityDistributionNode) Class.forName(algorithmClass).newInstance();
node.executeNode(order, chunksize, speciesOrder, speciesChunksize, duplicate, path, nodeConfiguration, logfile);
}catch(Exception e){
System.out.println("ERROR "+e.getMessage());
System.out.println(e);
}
}
}

View File

@ -107,7 +107,7 @@ public class LocalSimpleSplitGenerator implements Generator {
protected void initModel() throws Exception {
Properties p = AlgorithmConfiguration.getProperties(config.getConfigPath() + AlgorithmConfiguration.algorithmsFile);
String objectclass = p.getProperty(config.getModel());
distributionModel = (SpatialProbabilityDistributionGeneric) Class.forName(objectclass).newInstance();
distributionModel = (SpatialProbabilityDistributionGeneric) Class.forName(objectclass, true, config.getAlgorithmClassLoader()).newInstance();
distributionModel.init(config);
}

View File

@ -137,7 +137,7 @@ public class LocalSplitGenerator implements Generator {
private void initModel() throws Exception {
Properties p = AlgorithmConfiguration.getProperties(config.getConfigPath() + AlgorithmConfiguration.algorithmsFile);
String objectclass = p.getProperty(config.getModel());
distributionModel = (SpatialProbabilityDistributionTable) Class.forName(objectclass).newInstance();
distributionModel = (SpatialProbabilityDistributionTable) Class.forName(objectclass, true, config.getAlgorithmClassLoader()).newInstance();
distributionModel.init(config, dbHibConnection);
}

View File

@ -7,12 +7,11 @@ import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
import org.gcube.dataanalysis.ecoengine.interfaces.Clusterer;
import org.gcube.dataanalysis.ecoengine.interfaces.ComputationalAgent;
import org.gcube.dataanalysis.ecoengine.interfaces.Generator;
public class ClusterersFactory {
public static Clusterer getClusterer(AlgorithmConfiguration config) throws Exception {
Clusterer clus = (Clusterer) ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.clusterersFile);
Clusterer clus = (Clusterer) ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.clusterersFile, config.getAlgorithmClassLoader());
return clus;
}
@ -21,18 +20,18 @@ public class ClusterersFactory {
return cluss;
}
public static List<StatisticalType> getClustererParameters(String configPath, String algorithmName) throws Exception {
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.clusterersFile, algorithmName);
public static List<StatisticalType> getClustererParameters(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception {
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.clusterersFile, algorithmName, config.getAlgorithmClassLoader());
return inputs;
}
public static StatisticalType getClustererOutput(String configPath, String algorithmName) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(configPath + AlgorithmConfiguration.clusterersFile, algorithmName);
public static StatisticalType getClustererOutput(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(configPath + AlgorithmConfiguration.clusterersFile, algorithmName, config.getAlgorithmClassLoader());
return output;
}
public static String getDescription(String configPath, String algorithmName) throws Exception{
String input = ProcessorsFactory.getDescription(configPath + AlgorithmConfiguration.clusterersFile, algorithmName);
public static String getDescription(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception{
String input = ProcessorsFactory.getDescription(configPath + AlgorithmConfiguration.clusterersFile, algorithmName, config.getAlgorithmClassLoader());
return input;
}

View File

@ -52,7 +52,7 @@ public class DynamicTransducerersFactory {
List<String> dynatransducers = getAllDynamicTransducerers(config);
Map<String,Transducerer> transducerList = new LinkedHashMap<String,Transducerer>();
for (String dynatransducer:dynatransducers){
Object algclass = Class.forName(dynatransducer).newInstance();
Object algclass = Class.forName(dynatransducer, true, config.getAlgorithmClassLoader()).newInstance();
DynamicTransducer g = (DynamicTransducer) algclass;
Map<String,Transducerer> subtrans = g.getTransducers(config);
if (subtrans!=null){
@ -67,8 +67,8 @@ public class DynamicTransducerersFactory {
return transducerList;
}
public static List<StatisticalType> getTransducerParameters(String configPath, String algorithmName) throws Exception {
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.transducererFile, algorithmName);
public static List<StatisticalType> getTransducerParameters(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception {
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.transducererFile, algorithmName, config.getAlgorithmClassLoader());
return inputs;
}

View File

@ -7,13 +7,12 @@ import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
import org.gcube.dataanalysis.ecoengine.interfaces.ComputationalAgent;
import org.gcube.dataanalysis.ecoengine.interfaces.Evaluator;
import org.gcube.dataanalysis.ecoengine.interfaces.Generator;
public class EvaluatorsFactory {
public static Evaluator getEvaluator(AlgorithmConfiguration config) throws Exception {
Evaluator evaler = (Evaluator) ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.evaluatorsFile);
Evaluator evaler = (Evaluator) ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.evaluatorsFile, config.getAlgorithmClassLoader());
return evaler;
}
@ -22,18 +21,18 @@ public class EvaluatorsFactory {
return evaluators;
}
public static List<StatisticalType> getEvaluatorParameters(String configPath, String algorithmName) throws Exception{
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.evaluatorsFile, algorithmName);
public static List<StatisticalType> getEvaluatorParameters(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception{
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.evaluatorsFile, algorithmName, config.getAlgorithmClassLoader());
return inputs;
}
public static StatisticalType getEvaluatorOutput(String configPath, String algorithmName) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(configPath + AlgorithmConfiguration.evaluatorsFile, algorithmName);
public static StatisticalType getEvaluatorOutput(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(configPath + AlgorithmConfiguration.evaluatorsFile, algorithmName, config.getAlgorithmClassLoader());
return output;
}
public static String getDescription(String configPath, String algorithmName) throws Exception{
String input = ProcessorsFactory.getDescription(configPath + AlgorithmConfiguration.evaluatorsFile, algorithmName);
public static String getDescription(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception{
String input = ProcessorsFactory.getDescription(configPath + AlgorithmConfiguration.evaluatorsFile, algorithmName, config.getAlgorithmClassLoader());
return input;
}

View File

@ -3,7 +3,6 @@ package org.gcube.dataanalysis.ecoengine.processing.factories;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.ServiceLoader;
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
import org.gcube.dataanalysis.ecoengine.configuration.ALG_PROPS;
@ -12,7 +11,6 @@ import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
import org.gcube.dataanalysis.ecoengine.interfaces.ComputationalAgent;
import org.gcube.dataanalysis.ecoengine.interfaces.Generator;
import org.gcube.dataanalysis.ecoengine.interfaces.GenericAlgorithm;
import org.gcube.dataanalysis.ecoengine.interfaces.SpatialProbabilityDistributionGeneric;
public class GeneratorsFactory {
@ -20,45 +18,6 @@ public class GeneratorsFactory {
}
public static void main(String[] args) throws Exception {
ServiceLoader<SpatialProbabilityDistributionGeneric> sp = ServiceLoader.load(SpatialProbabilityDistributionGeneric.class);
for (SpatialProbabilityDistributionGeneric distrib:sp){
System.out.println(distrib.getName());
}
/*
GenericConfiguration config = new GenericConfiguration();
config.setDistributionTable("hspec_suitable_remote_test");
config.setConfigPath("./cfg/");
config.setCsquarecodesTable("hcaf_d");
config.setEnvelopeTable("hspen_validation");
config.setCreateTable(true);
config.setNumberOfResources(20);
config.setDatabaseUserName("gcube");
config.setDatabasePassword("d4science2");
config.setDatabaseURL("jdbc:postgresql://146.48.87.169/testdb");
config.setRemoteCalculator("http://node1.d.venusc.research-infrastructures.eu:5942/api/");
config.setServiceUserName("gianpaolo.coro");
config.setRemoteEnvironment("windows azure");
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("property1", "value1");
properties.put("property2", "value2");
config.setModel("TEST");
List<Generator> gens = GeneratorsFactory.getGenerators(config);
for (int i=0;i<gens.size();i++){
System.out.println(gens.get(i).getClass());
gens.get(i).init();
}
*/
}
public static List<String> getProbabilityDistributionAlgorithms(String configPath) throws Exception{
List<String> algs = ProcessorsFactory.getClasses(configPath + AlgorithmConfiguration.algorithmsFile);
@ -71,23 +30,23 @@ public class GeneratorsFactory {
return gens;
}
public static String getDescription(String configPath, String algorithmName) throws Exception{
String input = ProcessorsFactory.getDescription(configPath + AlgorithmConfiguration.algorithmsFile, algorithmName);
public static String getDescription(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception{
String input = ProcessorsFactory.getDescription(configPath + AlgorithmConfiguration.algorithmsFile, algorithmName, config.getAlgorithmClassLoader());
return input;
}
public static List<StatisticalType> getAlgorithmParameters(String configPath, String algorithmName) throws Exception{
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.algorithmsFile, algorithmName);
public static List<StatisticalType> getAlgorithmParameters(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception{
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.algorithmsFile, algorithmName, config.getAlgorithmClassLoader());
return inputs;
}
public static StatisticalType getAlgorithmOutput(String configPath, String algorithmName) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(configPath + AlgorithmConfiguration.algorithmsFile, algorithmName);
public static StatisticalType getAlgorithmOutput(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(configPath + AlgorithmConfiguration.algorithmsFile, algorithmName, config.getAlgorithmClassLoader());
return output;
}
public static Generator getGenerator(AlgorithmConfiguration config) throws Exception {
return (Generator)ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.generatorsFile);
return (Generator)ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.generatorsFile, config.getAlgorithmClassLoader());
}
@ -103,7 +62,7 @@ public class GeneratorsFactory {
//take the algorithms list
Properties p = AlgorithmConfiguration.getProperties(config.getConfigPath() + AlgorithmConfiguration.algorithmsFile);
String algorithmclass = p.getProperty(algorithm);
Object algclass = Class.forName(algorithmclass).newInstance();
Object algclass = Class.forName(algorithmclass, true, config.getAlgorithmClassLoader()).newInstance();
//if the algorithm is a generator itself then execute it
if (algclass instanceof Generator){
Generator g = (Generator) algclass;
@ -119,7 +78,7 @@ public class GeneratorsFactory {
Properties pg = AlgorithmConfiguration.getProperties(config.getConfigPath() + AlgorithmConfiguration.generatorsFile);
//investigate on possible suitable generators
for (Object generatorName:pg.values()){
Generator gen = (Generator)Class.forName((String)generatorName).newInstance();
Generator gen = (Generator)Class.forName((String)generatorName, true, config.getAlgorithmClassLoader()).newInstance();
gen.setConfiguration(config);
ALG_PROPS[] supportedAlgs = gen.getSupportedAlgorithms();
boolean genSuitable = false;

View File

@ -16,7 +16,7 @@ public class ModelersFactory {
public static Modeler getModeler(AlgorithmConfiguration config) throws Exception {
Modeler modlr = (Modeler)ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.generatorsFile);
Modeler modlr = (Modeler)ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.generatorsFile, config.getAlgorithmClassLoader());
return modlr;
}
@ -30,22 +30,22 @@ public class ModelersFactory {
return modelers;
}
public static List<StatisticalType> getModelParameters(String configPath, String algorithmName) throws Exception{
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.modelsFile, algorithmName);
public static List<StatisticalType> getModelParameters(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception{
List<StatisticalType> inputs = ProcessorsFactory.getParameters(configPath + AlgorithmConfiguration.modelsFile, algorithmName, config.getAlgorithmClassLoader());
return inputs;
}
public static StatisticalType getModelOutput(String configPath, String algorithmName) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(configPath + AlgorithmConfiguration.modelsFile, algorithmName);
public static StatisticalType getModelOutput(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(configPath + AlgorithmConfiguration.modelsFile, algorithmName, config.getAlgorithmClassLoader());
return output;
}
public static String getDescription(String configPath, String algorithmName) throws Exception{
String input = ProcessorsFactory.getDescription(configPath + AlgorithmConfiguration.modelsFile, algorithmName);
public static String getDescription(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception{
String input = ProcessorsFactory.getDescription(configPath + AlgorithmConfiguration.modelsFile, algorithmName, config.getAlgorithmClassLoader());
return input;
}
}
public static List<ComputationalAgent> getModelers(AlgorithmConfiguration config) throws Exception {
public static List<ComputationalAgent> getModelers(AlgorithmConfiguration config) throws Exception {
//modify this class in order to manage generators weight and match algorithm vs generators
List<ComputationalAgent> modelers = new ArrayList<ComputationalAgent>();
@ -57,7 +57,7 @@ public static List<ComputationalAgent> getModelers(AlgorithmConfiguration config
//take the algorithms list
Properties p = AlgorithmConfiguration.getProperties(config.getConfigPath() + AlgorithmConfiguration.modelsFile);
String algorithmclass = p.getProperty(algorithm);
Object algclass = Class.forName(algorithmclass).newInstance();
Object algclass = Class.forName(algorithmclass,true, config.getAlgorithmClassLoader()).newInstance();
//if the algorithm is a generator itself then execute it
if (algclass instanceof Modeler){
Modeler g = (Modeler) algclass;
@ -73,7 +73,7 @@ public static List<ComputationalAgent> getModelers(AlgorithmConfiguration config
Properties pg = AlgorithmConfiguration.getProperties(config.getConfigPath() + AlgorithmConfiguration.modelersFile);
//investigate on possible suitable modelers
for (Object modelerName:pg.values()){
Modeler gen = (Modeler)Class.forName((String)modelerName).newInstance();
Modeler gen = (Modeler)Class.forName((String)modelerName, true,config.getAlgorithmClassLoader()).newInstance();
gen.setConfiguration(config);
ALG_PROPS[] supportedAlgs = gen.getSupportedModels();
boolean genSuitable = false;

View File

@ -46,12 +46,14 @@ public class ProcessorsFactory {
}
public static String getDescription(String file, String algorithmName) throws Exception {
public static String getDescription(String file, String algorithmName, ClassLoader cl) throws Exception {
Properties p = AlgorithmConfiguration.getProperties(file);
String algorithmclass = p.getProperty(algorithmName);
if (algorithmclass==null) return null;
Object algclass = Class.forName(algorithmclass).newInstance();
Object algclass;
algclass = Class.forName(algorithmclass, true, cl).newInstance();
// if the algorithm is a generator itself then take it
if (algclass instanceof Generator) {
return ((Generator) algclass).getDescription();
@ -74,12 +76,12 @@ public class ProcessorsFactory {
}
public static List<StatisticalType> getParameters(String file, String algorithmName) throws Exception {
public static List<StatisticalType> getParameters(String file, String algorithmName, ClassLoader cl) throws Exception {
Properties p = AlgorithmConfiguration.getProperties(file);
String algorithmclass = p.getProperty(algorithmName);
if (algorithmclass==null) return null;
Object algclass = Class.forName(algorithmclass).newInstance();
Object algclass = Class.forName(algorithmclass, true, cl).newInstance();
// if the algorithm is a generator itself then take it
if (algclass instanceof Generator) {
return ((Generator) algclass).getInputParameters();
@ -102,13 +104,13 @@ public class ProcessorsFactory {
}
public static StatisticalType getOutputDescriptions(String file, String algorithmName) {
public static StatisticalType getOutputDescriptions(String file, String algorithmName, ClassLoader cl) {
try{
Properties p = AlgorithmConfiguration.getProperties(file);
String algorithmclass = p.getProperty(algorithmName);
if (algorithmclass==null) return null;
Object algclass = Class.forName(algorithmclass).newInstance();
Object algclass = Class.forName(algorithmclass, true, cl).newInstance();
// if the algorithm is a generator itself then take it
if (algclass instanceof Generator) {
return ((Generator) algclass).getOutput();
@ -133,10 +135,10 @@ public class ProcessorsFactory {
}
}
public static ComputationalAgent getProcessor(AlgorithmConfiguration config, String file) throws Exception {
return getProcessor(config, file,null);
public static ComputationalAgent getProcessor(AlgorithmConfiguration config, String file, ClassLoader cl) throws Exception {
return getProcessor(config, file,null, cl);
}
public static ComputationalAgent getProcessor(AlgorithmConfiguration config, String file,String explicitAlgorithm) throws Exception {
public static ComputationalAgent getProcessor(AlgorithmConfiguration config, String file,String explicitAlgorithm, ClassLoader cl) throws Exception {
// modify this class in order to take the right generator algorithm
try {
// initialize the logger
@ -152,7 +154,7 @@ public class ProcessorsFactory {
String algorithmclass = p.getProperty(algorithm);
if (algorithmclass==null)
return null;
Object algclass = Class.forName(algorithmclass).newInstance();
Object algclass = Class.forName(algorithmclass, true, cl).newInstance();
if (algclass instanceof Generator) {
Generator g = (Generator) algclass;
g.setConfiguration(config);

View File

@ -16,7 +16,7 @@ public class TransducerersFactory {
}
public static Transducerer getTransducerer(AlgorithmConfiguration config) throws Exception {
ComputationalAgent ca = ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.transducererFile);
ComputationalAgent ca = ProcessorsFactory.getProcessor(config, config.getConfigPath() + AlgorithmConfiguration.transducererFile, config.getAlgorithmClassLoader());
if (ca != null){
ca.setConfiguration(config);
return (Transducerer) ca;
@ -33,7 +33,7 @@ public class TransducerersFactory {
}
public static List<StatisticalType> getTransducerParameters(AlgorithmConfiguration config, String algorithmName) throws Exception {
List<StatisticalType> inputs = ProcessorsFactory.getParameters(config.getConfigPath() + AlgorithmConfiguration.transducererFile, algorithmName);
List<StatisticalType> inputs = ProcessorsFactory.getParameters(config.getConfigPath() + AlgorithmConfiguration.transducererFile, algorithmName, config.getAlgorithmClassLoader());
if (inputs != null)
return inputs;
else {
@ -46,7 +46,7 @@ public class TransducerersFactory {
public static StatisticalType getTransducerOutput(AlgorithmConfiguration config, String algorithmName) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(config.getConfigPath()+ AlgorithmConfiguration.transducererFile, algorithmName);
StatisticalType output = ProcessorsFactory.getOutputDescriptions(config.getConfigPath()+ AlgorithmConfiguration.transducererFile, algorithmName, config.getAlgorithmClassLoader());
if (output != null)
return output;
else {
@ -57,14 +57,14 @@ public class TransducerersFactory {
}
}
public static StatisticalType getModelOutput(String configPath, String algorithmName) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(configPath + AlgorithmConfiguration.modelsFile, algorithmName);
public static StatisticalType getModelOutput(String configPath, String algorithmName, AlgorithmConfiguration config) throws Exception {
StatisticalType output = ProcessorsFactory.getOutputDescriptions(configPath + AlgorithmConfiguration.modelsFile, algorithmName, config.getAlgorithmClassLoader());
return output;
}
public static String getDescription(AlgorithmConfiguration config, String algorithmName) throws Exception {
String input = ProcessorsFactory.getDescription(config.getConfigPath()+ AlgorithmConfiguration.transducererFile, algorithmName);
String input = ProcessorsFactory.getDescription(config.getConfigPath()+ AlgorithmConfiguration.transducererFile, algorithmName, config.getAlgorithmClassLoader());
if (input!=null)
return input;
else{

View File

@ -31,18 +31,18 @@ public static void main(String[] args) throws Exception {
AlgorithmConfiguration config = new AlgorithmConfiguration();
config.setConfigPath("./cfg/");
StatisticalType type = GeneratorsFactory.getAlgorithmOutput("./cfg/","AQUAMAPS_SUITABLE");
StatisticalType type = GeneratorsFactory.getAlgorithmOutput("./cfg/","AQUAMAPS_SUITABLE",config);
System.out.println("output for AQUAMAPS_SUITABLE algorithm: "+type);
type = ModelersFactory.getModelOutput("./cfg/","HSPEN");
type = ModelersFactory.getModelOutput("./cfg/","HSPEN",config);
System.out.println("output for HSPEN algorithm: "+type);
type = EvaluatorsFactory.getEvaluatorOutput("./cfg/","HRS");
type = EvaluatorsFactory.getEvaluatorOutput("./cfg/","HRS",config);
System.out.println("output for HRS algorithm: "+type);
type = ClusterersFactory.getClustererOutput("./cfg/","DBSCAN");
type = ClusterersFactory.getClustererOutput("./cfg/","DBSCAN",config);
System.out.println("output for DBSCAN algorithm: "+type);
type = TransducerersFactory.getTransducerOutput(config,"BIOCLIMATE_HSPEC");
System.out.println("output for BIOCLIMATE_HSPEC algorithm: "+type);
map = GeneratorsFactory.getAlgorithmParameters("./cfg/","AQUAMAPS_SUITABLE");
map = GeneratorsFactory.getAlgorithmParameters("./cfg/","AQUAMAPS_SUITABLE",config);
System.out.println("input for AQUAMAPS_SUITABLE algorithm: "+map);
System.out.println("\n***TEST 2 - Get Generator***");
@ -62,7 +62,7 @@ public static void main(String[] args) throws Exception {
System.out.println("Models: "+ModelersFactory.getModelers("./cfg/"));
System.out.println("\n***TEST 7- Get Model parameters ***");
map = ModelersFactory.getModelParameters("./cfg/","HSPEN");
map = ModelersFactory.getModelParameters("./cfg/","HSPEN",config);
System.out.println("input for HSPEN algorithm: "+map);
System.out.println("\n***TEST 8- Get Database Default Parameters***");
@ -73,7 +73,7 @@ public static void main(String[] args) throws Exception {
System.out.println("Database Default Values: "+EvaluatorsFactory.getAllEvaluators("./cfg/"));
System.out.println("\n***TEST 10- Get Evaluator Parameters ***");
map = EvaluatorsFactory.getEvaluatorParameters("./cfg/","QUALITY_ANALYSIS");
map = EvaluatorsFactory.getEvaluatorParameters("./cfg/","QUALITY_ANALYSIS",config);
System.out.println("Database Default Values: "+map);
System.out.println("\n***TEST 11- Get Evaluators with a config***");
@ -89,7 +89,7 @@ public static void main(String[] args) throws Exception {
System.out.println("All Clusterers: "+ClusterersFactory.getAllClusterers("./cfg/"));
System.out.println("\n***TEST 14- Get Clusterer Parameters ***");
map = ClusterersFactory.getClustererParameters("./cfg/","DBSCAN");
map = ClusterersFactory.getClustererParameters("./cfg/","DBSCAN",config);
System.out.println("Clusterers Params: "+map);
System.out.println("\n***TEST 15- Get Clusterers with a config***");
@ -109,7 +109,7 @@ public static void main(String[] args) throws Exception {
System.out.println("\n***TEST 19- Get Agent Description***");
String desc = ClusterersFactory.getDescription("./cfg/","DBSCAN");
String desc = ClusterersFactory.getDescription("./cfg/","DBSCAN",config);
System.out.println("DESCRIPTION: "+desc);
System.out.println("\n***TEST 20- Get USER perspective***");