This commit is contained in:
Gianpaolo Coro 2011-12-15 16:49:55 +00:00
parent cf7696b8cd
commit 1bb9d82767
3 changed files with 82 additions and 6 deletions

View File

@ -0,0 +1,77 @@
package org.gcube.dataanalysis.ecoengine.test;
import java.util.List;
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
import org.gcube.dataanalysis.ecoengine.interfaces.Generator;
import org.gcube.dataanalysis.ecoengine.processing.factories.GeneratorsFactory;
public class TestsDUMMYGeneration {
/**
* example of parallel processing on a single machine the procedure will generate a new table for a distribution on suitable species
*
*/
public static void main(String[] args) throws Exception {
System.out.println("TEST 1");
List<Generator> generators = GeneratorsFactory.getGenerators(testConfig());
generators.get(0).init();
generate(generators.get(0));
generators = null;
}
private static void generate(Generator generator) throws Exception {
if (generator != null) {
TestsDUMMYGeneration tgs = new TestsDUMMYGeneration();
ThreadCalculator tc = tgs.new ThreadCalculator(generator);
Thread t = new Thread(tc);
t.start();
while (generator.getStatus() < 100) {
String resLoad = generator.getResourceLoad();
String ress = generator.getResources();
String species = generator.getLoad();
System.out.println("LOAD: " + resLoad);
System.out.println("RESOURCES: " + ress);
System.out.println("SPECIES: " + species);
System.out.println("STATUS: " + generator.getStatus());
Thread.sleep(1000);
}
} else
AnalysisLogger.getLogger().trace("Generator Algorithm Not Supported");
}
public class ThreadCalculator implements Runnable {
Generator dg;
public ThreadCalculator(Generator dg) {
this.dg = dg;
}
public void run() {
try {
dg.generate();
} catch (Exception e) {
}
}
}
private static AlgorithmConfiguration testConfig() {
AlgorithmConfiguration config = new AlgorithmConfiguration();
config.setConfigPath("./cfg/");
config.setPersistencePath("./");
config.setNumberOfResources(10);
config.setModel("DUMMY");
return config;
}
}

View File

@ -19,6 +19,7 @@ public static void main(String[] args) throws Exception {
System.out.println("***TEST 1 - Get Algorithm Information***");
HashMap<String, String> map = GeneratorsFactory.getAlgorithmParameters("./cfg/","DUMMY");
System.out.println("input for DUMMY algorithm: "+map);
map = GeneratorsFactory.getAlgorithmParameters("./cfg/","AQUAMAPS_SUITABLE");
System.out.println("input for AQUAMAPS_SUITABLE algorithm: "+map);
@ -85,7 +86,9 @@ public static void main(String[] args) throws Exception {
config.setPersistencePath("./");
config.setNumberOfResources(2);
config.setModel("TEST");
config.setGenerator("SIMPLE_LOCAL");
return config;
}

View File

@ -19,7 +19,7 @@ public static void main(String[] args) throws Exception {
System.out.println("TEST 1");
List<Generator> generators = GeneratorsFactory.getGenerators(testConfigRemote());
generators.get(0).init();
generate(generators.get(0));
// generate(generators.get(0));
generators = null;
System.out.println("TEST 2");
@ -92,6 +92,7 @@ public static void main(String[] args) throws Exception {
config.setParam("RemoteCalculator","http://node1.d.venusc.research-infrastructures.eu:5942/api/");
config.setParam("ServiceUserName","gianpaolo.coro");
config.setParam("RemoteEnvironment","windows azure");
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("property1", "value1");
properties.put("property2", "value2");
@ -119,11 +120,6 @@ public static void main(String[] args) throws Exception {
config.setParam("DatabaseURL","jdbc:postgresql://localhost/testdb");
config.setParam("DatabaseDriver","org.postgresql.Driver");
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("property1", "value1");
properties.put("property2", "value2");
config.addGeneralProperties(properties);
return config;
}
}