From 79f612e263530c15b3be6ae5d76001e9105f532b 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/service/StagingJob.java | 14 +++- .../poolmanager/util/CheckMethod.java | 79 +++++++++++++++++++ src/main/resources/service.properties | 4 +- 3 files changed, 91 insertions(+), 6 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/service/StagingJob.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java index 2ee73c1..707cbf2 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 @@ -5,8 +5,11 @@ import static org.gcube.common.authorization.client.Constants.authorizationServi import org.gcube.common.authorization.library.AuthorizationEntry; ***REMOVED*** ***REMOVED*** +***REMOVED*** import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster; +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 ***REMOVED*** @@ -31,24 +34,27 @@ public class StagingJob extends DMPMJob ***REMOVED*** ***REMOVED*** protected void execute() ***REMOVED*** + ServiceConfiguration a = new ServiceConfiguration(); + CheckMethod b = new CheckMethod(); + try ***REMOVED*** int ret = this.executeAnsibleWorker( createWorker(this.algorithm, this.stagingCluster, true, "root")); if(ret == 0)***REMOVED*** - + + if (b.checkMethod(a.getStagingHost(), SecurityTokenProvider.instance.get()))***REMOVED*** + 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) ***REMOVED*** 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..9d6e329 --- /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; + +import java.io.BufferedReader; +import java.io.FileWriter; +import java.io.InputStreamReader; +***REMOVED*** + +public class CheckMethod ***REMOVED*** + + public CheckMethod() ***REMOVED*** + +***REMOVED*** + + public boolean checkMethod(String machine, String token) throws Exception ***REMOVED*** + try ***REMOVED*** + 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) ***REMOVED*** + fileWriter.write(line); + fileWriter.write(System.lineSeparator()); + if (line.contains("ows:Identifier")) ***REMOVED*** + 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) ***REMOVED*** + if (innerLine.contains("ows:Abstract")) ***REMOVED*** + 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")) ***REMOVED*** + 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) ***REMOVED*** + a.getMessage(); + return false; + ***REMOVED*** + return true; +***REMOVED*** + + + public static void main(String[] args) throws Exception ***REMOVED*** +***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"))***REMOVED*** + 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