From c2a5b0c9e5c176a79f86452c02ece3bf8f09dde6 Mon Sep 17 00:00:00 2001 From: Nunzio Andrea Galante Date: Thu, 23 Feb 2017 14:28:31 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@144197 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../ansiblebridge/AnsibleBridge.java | 2 +- .../poolmanager/datamodel/Algorithm.java | 4 +- .../poolmanager/rest/RestPoolManager.java | 70 ++++++++++++------- .../service/DataminerPoolManager.java | 2 +- .../AlgorithmPackageParserTest.java | 6 +- .../AnsibleWorkerTest.java | 2 +- .../DataminerPoolManagerTest.java | 2 +- 7 files changed, 55 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/ansiblebridge/AnsibleBridge.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/ansiblebridge/AnsibleBridge.java index 0134b1e..2dee222 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/ansiblebridge/AnsibleBridge.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/ansiblebridge/AnsibleBridge.java @@ -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) { diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/datamodel/Algorithm.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/datamodel/Algorithm.java index 20d4d1b..da57d44 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/datamodel/Algorithm.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/datamodel/Algorithm.java @@ -18,7 +18,7 @@ public class Algorithm { private String skipJava; private String packageURL; - + private Collection actions; private Collection dependencies; @@ -113,4 +113,6 @@ public class Algorithm { this.skipJava = skipJava; } + + } diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/rest/RestPoolManager.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/rest/RestPoolManager.java index afe9f51..2bcf338 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/rest/RestPoolManager.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/rest/RestPoolManager.java @@ -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; } - - - - - - - - - } \ No newline at end of file diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/DataminerPoolManager.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/DataminerPoolManager.java index 578ccee..1c00c69 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/DataminerPoolManager.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/DataminerPoolManager.java @@ -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); diff --git a/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/AlgorithmPackageParserTest.java b/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/AlgorithmPackageParserTest.java index 29a5eab..1094598 100644 --- a/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/AlgorithmPackageParserTest.java +++ b/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/AlgorithmPackageParserTest.java @@ -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 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(); } diff --git a/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/AnsibleWorkerTest.java b/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/AnsibleWorkerTest.java index 5bd76d9..77f02b5 100644 --- a/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/AnsibleWorkerTest.java +++ b/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/AnsibleWorkerTest.java @@ -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()); diff --git a/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/DataminerPoolManagerTest.java b/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/DataminerPoolManagerTest.java index 3fcee78..d2af50f 100644 --- a/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/DataminerPoolManagerTest.java +++ b/src/test/java/org/gcube/dataanalysis/dataminerpoolmanager/DataminerPoolManagerTest.java @@ -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();