This commit is contained in:
Nunzio Andrea Galante 2017-06-30 13:49:04 +00:00
parent 58bae45a76
commit de161f8153
4 changed files with 92 additions and 8 deletions

View File

@ -80,8 +80,7 @@ public class RestPoolManager implements PoolManager {
public static void main(String[] args) throws ObjectNotFound, Exception {
// // System.out.println(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
// System.out.println(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
// // ProxySelector.setDefault(new
// // PropertiesBasedProxySelector("/home/ngalante/.proxy-settings"));
//

View File

@ -4,9 +4,12 @@ import static org.gcube.common.authorization.client.Constants.authorizationServi
import org.gcube.common.authorization.library.AuthorizationEntry;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
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 {
@ -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");
// int ret2 = this.executeAnsibleWorker(
// createWorker(this.algorithm, this.rProtoCluster, false, "gcube"));
}
}
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -0,0 +1,79 @@
package org.gcube.dataanalysis.dataminer.poolmanager.util;
import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.net.URL;
public class CheckMethod {
public CheckMethod() {
}
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://" + machine
+ "/wps/WebProcessingService?Request=GetCapabilities&Service=WPS&gcube-token=" + token;
String response = machine + "___" + token + ".xml";
getCapabilitesRequest = request;
getCapabilitesResponse = response;
String baseDescriptionRequest = "http://" + 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;
} else if (innerLine.contains("ows:ExceptionText")) {
System.out.println(" " + "error retrieving operator description");
innerFlag = false;
flag = false;
} else
innerLine = innerBufferedReader.readLine();
}
}
}
fileWriter.close();
} catch (Exception a) {
a.getMessage();
return false;
}
return true;
}
public static void main(String[] args) throws Exception {
// ServiceConfiguration a = new ServiceConfiguration();
// 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"); }
}
}

View File

@ -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://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/RConfiguration/RPackagesManagement/
#HAPROXY_CSV: http://data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0