From d07cf6c2b4b6dbdd6d9d2022f03181d9d235e60a Mon Sep 17 00:00:00 2001 From: Nunzio Andrea Galante Date: Fri, 30 Jun 2017 13:49:04 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@150673 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../poolmanager/rest/RestPoolManager.java | 3 +- .../poolmanager/service/StagingJob.java | 14 +++- .../poolmanager/util/CheckMethod.java | 79 +++++++++++++++++++ src/main/resources/service.properties | 4 +- 4 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java 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 4e45f4d..efb43e4 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 @@ -80,8 +80,7 @@ public class RestPoolManager implements PoolManager { ***REMOVED*** - - ***REMOVED*** ***REMOVED*** System.out.println(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager"); + ***REMOVED*** System.out.println(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager"); ***REMOVED*** ***REMOVED*** ProxySelector.setDefault(new ***REMOVED*** ***REMOVED*** PropertiesBasedProxySelector("/home/ngalante/.proxy-settings")); ***REMOVED*** diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java index c6df4c5..7e6ce40 100644 --- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java @@ -4,9 +4,12 @@ import static org.gcube.common.authorization.client.Constants.authorizationServi import org.gcube.common.authorization.library.AuthorizationEntry; ***REMOVED*** +***REMOVED*** import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm; ***REMOVED*** +import org.gcube.dataanalysis.dataminer.poolmanager.util.CheckMethod; import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater; +import org.gcube.dataanalysis.dataminer.poolmanager.util.ServiceConfiguration; public class StagingJob extends DMPMJob { @@ -31,24 +34,27 @@ public class StagingJob extends DMPMJob { @Override protected void execute() { + ServiceConfiguration a = new ServiceConfiguration(); + CheckMethod b = new CheckMethod(); + try { int ret = this.executeAnsibleWorker( createWorker(this.algorithm, this.stagingCluster, true, "root")); if(ret == 0){ - + + if (b.checkMethod(a.getStagingHost(), SecurityTokenProvider.instance.get())){ + this.svnUpdater.updateRPRotoDeps(this.algorithm); this.svnUpdater.updateSVNRProtoAlgorithmList(this.algorithm, this.rProtoVREName, "DataMiner Pool Manager", "Proto"); ***REMOVED*** int ret2 = this.executeAnsibleWorker( ***REMOVED*** createWorker(this.algorithm, this.rProtoCluster, false, "gcube")); - + ***REMOVED*** ***REMOVED*** - - ***REMOVED*** catch (Exception e) { e.printStackTrace(); ***REMOVED*** diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java new file mode 100644 index 0000000..726242d --- /dev/null +++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/CheckMethod.java @@ -0,0 +1,79 @@ +package org.gcube.dataanalysis.dataminer.poolmanager.util; + +***REMOVED*** +import java.io.FileWriter; +***REMOVED*** +***REMOVED*** + +public class CheckMethod { + + public CheckMethod() { + +***REMOVED*** + + public boolean checkMethod(String machine, String token) throws Exception { + try { + System.out.println("Machine: " + machine); + String getCapabilitesRequest = new String(); + String getCapabilitesResponse = new String(); + System.out.println(" Token: " + token); + String request = "http:***REMOVED***" + machine + + "/wps/WebProcessingService?Request=GetCapabilities&Service=WPS&gcube-token=" + token; + String response = machine + "___" + token + ".xml"; + getCapabilitesRequest = request; + getCapabilitesResponse = response; + String baseDescriptionRequest = "http:***REMOVED***" + machine + + "/wps/WebProcessingService?Request=DescribeProcess&Service=WPS&Version=1.0.0" + "&gcube-token=" + + token + "&Identifier="; + URL requestURL = new URL(request); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(requestURL.openStream())); + FileWriter fileWriter = new FileWriter(response); + String line; + boolean flag = true; + while (flag && (line = bufferedReader.readLine()) != null) { + fileWriter.write(line); + fileWriter.write(System.lineSeparator()); + if (line.contains("ows:Identifier")) { + String operatorName = line.substring(line.indexOf(">") + 1); + operatorName = operatorName.substring(0, operatorName.indexOf("<")); + System.out.println(" " + operatorName); + URL innerRequestURL = new URL(baseDescriptionRequest + operatorName); + BufferedReader innerBufferedReader = new BufferedReader( + new InputStreamReader(innerRequestURL.openStream())); + String innerLine = innerBufferedReader.readLine(); + boolean innerFlag = true; + while (innerFlag && (innerLine = innerBufferedReader.readLine()) != null) { + if (innerLine.contains("ows:Abstract")) { + String operatorDescription = innerLine.substring(innerLine.indexOf(">") + 1); + operatorDescription = operatorDescription.substring(0, operatorDescription.indexOf("<")); + System.out.println(" " + operatorDescription); + innerFlag = false; + ***REMOVED*** else if (innerLine.contains("ows:ExceptionText")) { + System.out.println(" " + "error retrieving operator description"); + innerFlag = false; + flag = false; + ***REMOVED*** else + innerLine = innerBufferedReader.readLine(); + ***REMOVED*** + ***REMOVED*** + ***REMOVED*** + fileWriter.close(); + ***REMOVED*** catch (Exception a) { + a.getMessage(); + return false; + ***REMOVED*** + return true; +***REMOVED*** + + + public static void main(String[] args) throws Exception { +***REMOVED*** ServiceConfiguration a = new ServiceConfiguration(); +***REMOVED*** System.out.println(a.getStagingHost()); + + CheckMethod a = new CheckMethod(); + if (!a.checkMethod("dataminer1-proto.d4science.org", "254c2e2d-7f48-47aa-9fc1-5e6453a41f78-843339462")){ + System.out.println("ciao");***REMOVED*** + +***REMOVED*** + +***REMOVED*** diff --git a/src/main/resources/service.properties b/src/main/resources/service.properties index d4f49f2..498c796 100644 --- a/src/main/resources/service.properties +++ b/src/main/resources/service.properties @@ -1,6 +1,6 @@ #YML node file -STAGING_HOST: dataminer-proto-ghost.d4science.org -#STAGING_HOST: dataminer1-devnext.d4science.org +#STAGING_HOST: dataminer-proto-ghost.d4science.org +STAGING_HOST: dataminer1-devnext.d4science.org SVN_REPO: https:***REMOVED***svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/RConfiguration/RPackagesManagement/ #HAPROXY_CSV: http:***REMOVED***data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0