git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@151067 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3b7f4aefc4
commit
1be681a9bd
|
@ -8,6 +8,7 @@ import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -118,7 +119,6 @@ public class AnsibleWorker {
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int execute(PrintStream ps)
|
public int execute(PrintStream ps)
|
||||||
throws IOException, InterruptedException, SVNException {
|
throws IOException, InterruptedException, SVNException {
|
||||||
|
|
||||||
|
@ -130,6 +130,8 @@ public class AnsibleWorker {
|
||||||
inheritIO(p.getInputStream(), ps);
|
inheritIO(p.getInputStream(), ps);
|
||||||
inheritIO(p.getErrorStream(), ps);
|
inheritIO(p.getErrorStream(), ps);
|
||||||
|
|
||||||
|
***REMOVED*** writer.println(this.getStatus(p.waitFor()));
|
||||||
|
***REMOVED*** writer.close();
|
||||||
|
|
||||||
return p.waitFor();
|
return p.waitFor();
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,20 @@ public class RestPoolManager implements PoolManager {
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/monitor")
|
||||||
|
@Produces("text/plain")
|
||||||
|
public String getMonitorById(@QueryParam("logUrl") String logUrl) throws IOException {
|
||||||
|
***REMOVED*** TODO Auto-generated method stub
|
||||||
|
LOGGER.debug("Returning Log =" + logUrl);
|
||||||
|
return service.getMonitorById(logUrl);
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Algorithm extractAlgorithm(String url) throws IOException {
|
public Algorithm extractAlgorithm(String url) throws IOException {
|
||||||
***REMOVED*** TODO Auto-generated method stub
|
***REMOVED*** TODO Auto-generated method stub
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -16,6 +17,8 @@ import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
|
||||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
|
||||||
import org.tmatesoft.svn.core.SVNException;
|
import org.tmatesoft.svn.core.SVNException;
|
||||||
|
|
||||||
|
import Jampack.Print;
|
||||||
|
|
||||||
public abstract class DMPMJob {
|
public abstract class DMPMJob {
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,9 +72,14 @@ public abstract class DMPMJob {
|
||||||
protected int executeAnsibleWorker(AnsibleWorker worker) throws IOException, InterruptedException, SVNException{
|
protected int executeAnsibleWorker(AnsibleWorker worker) throws IOException, InterruptedException, SVNException{
|
||||||
File path = new File(worker.getWorkdir() + File.separator + "jobs");
|
File path = new File(worker.getWorkdir() + File.separator + "jobs");
|
||||||
path.mkdirs();
|
path.mkdirs();
|
||||||
|
|
||||||
File n = new File(this.jobLogs + File.separator + this.id);
|
File n = new File(this.jobLogs + File.separator + this.id);
|
||||||
FileOutputStream fos = new FileOutputStream(n, true);
|
FileOutputStream fos = new FileOutputStream(n, true);
|
||||||
PrintStream ps = new PrintStream(fos);
|
PrintStream ps = new PrintStream(fos);
|
||||||
|
|
||||||
|
***REMOVED*** File m = new File(this.jobLogs + File.separator + this.id + "_exitStatus");
|
||||||
|
***REMOVED*** PrintWriter fos2 = new PrintWriter(m, "UTF-8");
|
||||||
|
|
||||||
return worker.execute(ps);
|
return worker.execute(ps);
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
|
@ -56,4 +56,18 @@ public class DataminerPoolManager {
|
||||||
|
|
||||||
return new Scanner(path).useDelimiter("\\Z").next();
|
return new Scanner(path).useDelimiter("\\Z").next();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
public String getMonitorById(String id) throws FileNotFoundException{
|
||||||
|
|
||||||
|
***REMOVED***TODO: load dir from configuration file
|
||||||
|
File path = new File(System.getProperty("user.home") + File.separator + "dataminer-pool-manager/jobs/"
|
||||||
|
+ id + "_exitStatus");
|
||||||
|
|
||||||
|
return new Scanner(path).useDelimiter("\\Z").next();
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -2,6 +2,10 @@ package org.gcube.dataanalysis.dataminer.poolmanager.service;
|
||||||
|
|
||||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
|
@ -19,15 +23,20 @@ public class StagingJob extends DMPMJob {
|
||||||
|
|
||||||
private Algorithm algorithm;
|
private Algorithm algorithm;
|
||||||
private Cluster stagingCluster;
|
private Cluster stagingCluster;
|
||||||
***REMOVED***private Cluster rProtoCluster;
|
***REMOVED*** private Cluster rProtoCluster;
|
||||||
private String rProtoVREName;
|
private String rProtoVREName;
|
||||||
|
|
||||||
public StagingJob(SVNUpdater svnUpdater, Algorithm algorithm, Cluster stagingCluster, /*Cluster rProtoCluster,*/
|
public StagingJob(SVNUpdater svnUpdater, Algorithm algorithm,
|
||||||
|
Cluster stagingCluster, /* Cluster rProtoCluster, */
|
||||||
String rProtoVREName) {
|
String rProtoVREName) {
|
||||||
super(svnUpdater);
|
super(svnUpdater);
|
||||||
|
this.jobLogs = new File(
|
||||||
|
System.getProperty("user.home") + File.separator + "dataminer-pool-manager" + File.separator + "jobs");
|
||||||
|
this.jobLogs.mkdirs();
|
||||||
|
|
||||||
this.algorithm = algorithm;
|
this.algorithm = algorithm;
|
||||||
this.stagingCluster = stagingCluster;
|
this.stagingCluster = stagingCluster;
|
||||||
***REMOVED***this.rProtoCluster = rProtoCluster;
|
***REMOVED*** this.rProtoCluster = rProtoCluster;
|
||||||
this.rProtoVREName = rProtoVREName;
|
this.rProtoVREName = rProtoVREName;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
@ -41,7 +50,8 @@ public class StagingJob extends DMPMJob {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Collection<String> undefinedDependencies = this.svnUpdater.getUndefinedDependencies(
|
Collection<String> undefinedDependencies = this.svnUpdater.getUndefinedDependencies(
|
||||||
this.svnUpdater.getRProtoDependencyFile(this.algorithm.getLanguage()), this.algorithm.getDependencies());
|
this.svnUpdater.getRProtoDependencyFile(this.algorithm.getLanguage()),
|
||||||
|
this.algorithm.getDependencies());
|
||||||
|
|
||||||
if (!undefinedDependencies.isEmpty()) {
|
if (!undefinedDependencies.isEmpty()) {
|
||||||
|
|
||||||
|
@ -56,27 +66,67 @@ public class StagingJob extends DMPMJob {
|
||||||
|
|
||||||
int ret = this.executeAnsibleWorker(createWorker(this.algorithm, this.stagingCluster, false, "root"));
|
int ret = this.executeAnsibleWorker(createWorker(this.algorithm, this.stagingCluster, false, "root"));
|
||||||
|
|
||||||
|
Integer s = null;
|
||||||
|
s = Integer.valueOf(ret);
|
||||||
|
|
||||||
|
if (s == null) {
|
||||||
|
this.getStatus(0);
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
if (ret != 0) {
|
||||||
|
this.getStatus(2);
|
||||||
|
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody("Installation failed. Return code=" + ret));
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
this.getStatus(0);
|
||||||
|
|
||||||
if (b.checkMethod(a.getStagingHost(), SecurityTokenProvider.instance.get())
|
if (b.checkMethod(a.getStagingHost(), SecurityTokenProvider.instance.get())
|
||||||
&& (b.algoExists(this.algorithm))) {
|
&& (b.algoExists(this.algorithm))) {
|
||||||
|
|
||||||
sm.sendNotification(nh.getSuccessSubject(), nh.getSuccessBody());
|
|
||||||
***REMOVED*** this.svnUpdater.updateRPRotoDeps(this.algorithm);
|
|
||||||
|
|
||||||
this.svnUpdater.updateSVNRProtoAlgorithmList(this.algorithm, this.rProtoVREName,
|
this.svnUpdater.updateSVNRProtoAlgorithmList(this.algorithm, this.rProtoVREName,
|
||||||
this.algorithm.getFullname(), "Proto");
|
this.algorithm.getFullname(), "Proto");
|
||||||
|
|
||||||
***REMOVED*** int ret2 = this.executeAnsibleWorker(
|
this.getStatus(9);
|
||||||
***REMOVED*** createWorker(this.algorithm, this.rProtoCluster,
|
sm.sendNotification(nh.getSuccessSubject(), nh.getSuccessBody());
|
||||||
***REMOVED*** false, "gcube"));
|
***REMOVED*** else
|
||||||
***REMOVED***
|
this.getStatus(2);
|
||||||
***REMOVED*** else
|
sm.sendNotification(nh.getFailedSubject(),
|
||||||
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody("Installation failed. Return code=" + ret));
|
nh.getFailedBody("DataMiner Interface not working or files " + this.algorithm.getName()
|
||||||
|
+ ".jar and " + this.algorithm.getName()
|
||||||
|
+ "_interface.jar not available at the expected path"));
|
||||||
|
***REMOVED***
|
||||||
***REMOVED*** catch (Exception e) {
|
***REMOVED*** catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
public String getStatus(int exitstatus) throws FileNotFoundException, UnsupportedEncodingException {
|
||||||
|
|
||||||
|
File m = new File(this.jobLogs + File.separator + this.id + "_exitStatus");
|
||||||
|
|
||||||
|
PrintWriter writer = new PrintWriter(m, "UTF-8");
|
||||||
|
|
||||||
|
String response = "";
|
||||||
|
|
||||||
|
if (exitstatus == 0) {
|
||||||
|
response = "IN PROGRESS";
|
||||||
|
writer.println(response);
|
||||||
|
writer.close();
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
if (exitstatus == 9) {
|
||||||
|
response = "COMPLETED";
|
||||||
|
writer.println(response);
|
||||||
|
writer.close();
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
|
if (exitstatus == 2) {
|
||||||
|
response = "FAILED";
|
||||||
|
writer.println(response);
|
||||||
|
writer.close();
|
||||||
|
***REMOVED***
|
||||||
|
return response;
|
||||||
|
***REMOVED***
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -71,8 +71,8 @@ public class CheckMethod {
|
||||||
|
|
||||||
|
|
||||||
public boolean algoExists(Algorithm a){
|
public boolean algoExists(Algorithm a){
|
||||||
File file = new File("/home/gcube/wps_algorithms/algorithms/"+a.getName()+".jar");
|
File file = new File(System.getProperty("user.home")+File.separator+"wps_algorithms/algorithms/"+a.getName()+".jar");
|
||||||
File file2 = new File(" /home/gcube/wps_algorithms/algorithms/"+a.getName()+"interface_.jar");
|
File file2 = new File(System.getProperty("user.home")+File.separator+"wps_algorithms/algorithms/"+a.getName()+"interface_.jar");
|
||||||
|
|
||||||
if (file.exists()&&(file2.exists())){
|
if (file.exists()&&(file2.exists())){
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class SendMail extends StandardLocalInfraAlgorithm {
|
||||||
***REMOVED***String serviceAddress = ep.getResourceEntyName();***REMOVED***"https:***REMOVED***socialnetworking1.d4science.org/social-networking-library-ws/rest/";
|
***REMOVED***String serviceAddress = ep.getResourceEntyName();***REMOVED***"https:***REMOVED***socialnetworking1.d4science.org/social-networking-library-ws/rest/";
|
||||||
serviceAddress = serviceAddress.endsWith("/") ? serviceAddress : serviceAddress + "/";
|
serviceAddress = serviceAddress.endsWith("/") ? serviceAddress : serviceAddress + "/";
|
||||||
serviceAddress+= "2/users/get-usernames-by-global-role?";
|
serviceAddress+= "2/users/get-usernames-by-global-role?";
|
||||||
serviceAddress+= "role-name=Administrator" + "&gcube-token=" + SecurityTokenProvider.instance.get();
|
serviceAddress+= "role-name=DataMiner-Manager" + "&gcube-token=" + SecurityTokenProvider.instance.get();
|
||||||
|
|
||||||
System.out.println("Url is " + serviceAddress);
|
System.out.println("Url is " + serviceAddress);
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,13 @@ public class SVNTests {
|
||||||
|
|
||||||
SVNUpdater svnUpdater = new SVNUpdater(new ServiceConfiguration("/home/ngalante/workspace/dataminer-pool-manager/src/main/resources/service.properties"));
|
SVNUpdater svnUpdater = new SVNUpdater(new ServiceConfiguration("/home/ngalante/workspace/dataminer-pool-manager/src/main/resources/service.properties"));
|
||||||
|
|
||||||
Algorithm algo = AlgorithmBuilder.create("http:***REMOVED***data.d4science.org/R0ExYjFPVFBrOUlNdEhrTUQyQlZjbUJuQ20rbGFrZ0pHbWJQNStIS0N6Yz0");
|
Algorithm algo = AlgorithmBuilder.create("http:***REMOVED***data.d4science.org/cnFLNHYxR1ZDa1VNdEhrTUQyQlZjaWRBVVZlUHloUitHbWJQNStIS0N6Yz0");
|
||||||
***REMOVED***algo.setClazz(algo.getClazz() + "TEST");
|
***REMOVED***algo.setClazz(algo.getClazz() + "TEST");
|
||||||
|
System.out.println(algo.getAlgorithmType());
|
||||||
|
System.out.println(algo.getCategory());
|
||||||
|
System.out.println(algo.getSkipJava());
|
||||||
|
|
||||||
***REMOVED***svnUpdater.updateSVNRProtoAlgorithmList(algo, "/d4science.research-infrastructures.eu/gCubeApps/RPrototypingLab", "Dataminer Pool Manager", "Proto");
|
***REMOVED***svnUpdater.updateSVNRProtoAlgorithmList(algo, "/d4science.research-infrastructures.eu/gCubeApps/RPrototypingLab", "Dataminer Pool Manager", "Proto");
|
||||||
svnUpdater.readRPRotoDeps(algo);
|
***REMOVED***svnUpdater.readRPRotoDeps(algo);
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
Loading…
Reference in New Issue