This commit is contained in:
Nunzio Andrea Galante 2017-02-23 14:28:31 +00:00
parent c5851b3366
commit c2a5b0c9e5
7 changed files with 55 additions and 33 deletions

View File

@ -43,7 +43,7 @@ public class AnsibleBridge {
private String dpmRoot;
public AnsibleBridge() {
this("/tmp/dataminer-pool-manager");
this(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
}
public AnsibleBridge(String root) {

View File

@ -18,7 +18,7 @@ public class Algorithm {
private String skipJava;
private String packageURL;
private Collection<Action> actions;
private Collection<Dependency> dependencies;
@ -113,4 +113,6 @@ public class Algorithm {
this.skipJava = skipJava;
}
}

View File

@ -1,5 +1,6 @@
package org.gcube.dataanalysis.dataminer.poolmanager.rest;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@ -12,11 +13,12 @@ import javax.ws.rs.QueryParam;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
import org.gcube.dataanalysis.dataminer.poolmanager.process.AddAlgorithmCommand;
import org.gcube.dataanalysis.dataminer.poolmanager.service.DataminerPoolManager;
import org.gcube.dataanalysis.dataminerpoolmanager.AlgorithmPackageParserTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Path("/")
public class RestPoolManager implements PoolManager {
@ -24,18 +26,52 @@ public class RestPoolManager implements PoolManager {
private PoolManager service = new DataminerPoolManager();
@GET
@Path("/add")
@Produces("text/plain")
public String addAlgorithmToVRE(@QueryParam("algorithm") String algorithm, @QueryParam("vre") String vre) throws IOException, InterruptedException {
public String addAlgorithmToVRE(@QueryParam("algorithm") String algorithm, @QueryParam("vre") String vre,
@QueryParam("name") String name, @QueryParam("description") String description,
@QueryParam("category") String category, @QueryParam("algorithmType") String algorithmType,
@QueryParam("skipJava") String skipJava) throws IOException, InterruptedException {
// TODO Auto-generated method stub
LOGGER.debug("Adding algorithm =" + algorithm + " to VRE =" + vre);
Algorithm algo = service.extractAlgorithm(algorithm);
if (algo.getCategory() == null) {
algo.setCategory(category);
} else
category = algo.getCategory();
System.out.println("category is: " + category);
if (algo.getAlgorithmType() == null) {
algo.setAlgorithmType(algorithmType);
} else
algorithmType = algo.getCategory();
System.out.println("algorithmType is: " + algorithmType);
if (algo.getSkipJava() == null) {
algo.setSkipJava(skipJava);
} else
skipJava = algo.getSkipJava();
System.out.println("skipJava is: " + skipJava);
if (algo.getName() == null) {
algo.setCategory(name);
} else
name = algo.getName();
System.out.println("name is: " + name);
if (algo.getDescription() == null) {
algo.setDescription(description);
;
} else
description = algo.getDescription();
System.out.println("description is: " + description);
return service.addAlgorithmToVRE(algo, vre);
}
@GET
@Path("/log")
@Produces("text/plain")
@ -44,10 +80,6 @@ public class RestPoolManager implements PoolManager {
LOGGER.debug("Returning Log =" + logUrl);
return service.getScriptFromURL(service.getURLfromWorkerLog(logUrl));
}
@Override
public Algorithm extractAlgorithm(String url) throws IOException {
@ -55,21 +87,20 @@ public class RestPoolManager implements PoolManager {
return null;
}
public static void main(String[] args) throws IOException, InterruptedException {
RestPoolManager a = new RestPoolManager();
// System.out.println(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
ScopeProvider.instance.set("/gcube/devNext/NextNext");
a.addAlgorithmToVRE("http://data.d4science.org/am84enRYYkZ3dGRjZk9qTytQTndqaFpTOFJtT3RQeGhHbWJQNStIS0N6Yz0", "/gcube/devNext/NextNext");
//System.out.println(a.getLogById("dadcb059-69e5-48c3-aa58-3b290ae0419d"));
a.addAlgorithmToVRE("http://data.d4science.org/am84enRYYkZ3dGRjZk9qTytQTndqaFpTOFJtT3RQeGhHbWJQNStIS0N6Yz0",
"/gcube/devNext/NextNext", null, null, "ICHTHYOP_MODEL", "transducerers", "N");
// System.out.println(a.getLogById("dadcb059-69e5-48c3-aa58-3b290ae0419d"));
}
@Override
public void getLogId(Algorithm algo, String vre) {
// TODO Auto-generated method stub
}
}
@Override
public String getScriptFromURL(URL logId) throws IOException {
@ -77,27 +108,16 @@ public class RestPoolManager implements PoolManager {
return null;
}
@Override
public String addAlgorithmToVRE(Algorithm algo, String vre) throws IOException, InterruptedException {
// TODO Auto-generated method stub
return null;
}
@Override
public URL getURLfromWorkerLog(String logUrl) throws MalformedURLException, UnknownHostException {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -214,7 +214,7 @@ public class DataminerPoolManager implements PoolManager {
public URL getURLfromWorkerLog(String a) throws MalformedURLException, UnknownHostException{
File path = new File("/tmp/dataminer-pool-manager/work/" + File.separator + a+File.separator +"logs");
File path = new File(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager/work");
path.mkdirs();
File n = new File(path + File.separator +a);

View File

@ -17,7 +17,7 @@ public class AlgorithmPackageParserTest {
private static int BUFFER_SIZE = 2048;
private void extractAllAlgorithms() throws IOException {
public void extractAllAlgorithms() throws IOException {
String url = "http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/DataMinerConfiguration/algorithms/dev/algorithms";
List<String> commands = this.extractAddAlgorithmCommands(url);
AlgorithmSet algorithms = new AlgorithmSet();
@ -110,8 +110,8 @@ public class AlgorithmPackageParserTest {
}
public static void main(String[] args) throws Exception {
ProxySelector.setDefault(new PropertiesBasedProxySelector(
"/home/ngalante/.proxy-settings"));
// ProxySelector.setDefault(new PropertiesBasedProxySelector(
// "/home/ngalante/.proxy-settings"));
new AlgorithmPackageParserTest().extractAllAlgorithms();
}

View File

@ -13,7 +13,7 @@ import org.gcube.dataanalysis.dataminer.poolmanager.ansible.model.RoleFile;
public class AnsibleWorkerTest {
public static void main(String[] args) throws IOException {
AnsibleWorker worker = new AnsibleWorker(new File("/tmp/dataminer-pool-manager/work/"+UUID.randomUUID().toString()));
AnsibleWorker worker = new AnsibleWorker(new File("/home/nagalante/gcube/dataminer-pool-manager/work/"+UUID.randomUUID().toString()));
System.out.println("created worker named " + worker.getWorkerId());

View File

@ -211,7 +211,7 @@ public class DataminerPoolManagerTest {
ensemble.setAlgorithmType("transducerers");
ensemble.setPackageURL("http://data.d4science.org/R0FqV2lNOW1jMkxuUEIrWXY4aUhvSENHSmVMQks4NjdHbWJQNStIS0N6Yz0");
ensemble.setClazz("org.gcube.dataanalysis.executor.rscripts.Ichthyopmodelonebyone");
ensemble.setSkipJava("test");
ensemble.setSkipJava("N");
ensemble.setDescription("test");
Dependency d = new Dependency();