This commit is contained in:
Nunzio Andrea Galante 2017-07-24 10:32:18 +00:00
parent 8d9365b99d
commit 0d82f32a3b
4 changed files with 89 additions and 12 deletions

View File

@ -1,11 +1,18 @@
package org.gcube.dataanalysis.dataminer.poolmanager.service;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
***REMOVED***
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
***REMOVED***
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.util.NotificationHelper;
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
import org.gcube.dataanalysis.dataminer.poolmanager.util.SendMail;
public class ProductionPublishingJob extends DMPMJob {
@ -14,26 +21,33 @@ public class ProductionPublishingJob extends DMPMJob {
private String targetVREName;
private String targetVREToken;
public ProductionPublishingJob(SVNUpdater svnUpdater, Algorithm algorithm, /*Cluster prodCluster,*/ String targetVREName, String targetVREToken) {
public ProductionPublishingJob(SVNUpdater svnUpdater, Algorithm algorithm, /*Cluster prodCluster,*/ String targetVREName, String targetVREToken) throws FileNotFoundException, UnsupportedEncodingException {
super(svnUpdater);
this.algorithm = algorithm;
***REMOVED***this.prodCluster = prodCluster;
this.targetVREName = targetVREName;
this.targetVREToken = targetVREToken;
this.jobLogs = new File(System.getProperty("user.home") + File.separator + "dataminer-pool-manager" + File.separator + "jobs");
this.jobLogs.mkdirs();
***REMOVED***
@Override
protected void execute() {
SendMail sm = new SendMail();
NotificationHelper nh = new NotificationHelper();
try {
if (CheckPermission.apply(targetVREToken,targetVREName)){
***REMOVED***this.svnUpdater.updateProdDeps(this.algorithm);
this.svnUpdater.updateSVNProdAlgorithmList(this.algorithm, this.targetVREName, this.algorithm.getFullname(), "Prod");
this.getStatus(9);
sm.sendNotification(nh.getSuccessSubjectRelease() + " for "+this.algorithm.getName()+ " algorithm", nh.getSuccessBodyRelease(this.buildInfo()));
***REMOVED***
***REMOVED*** int ret = this.executeAnsibleWorker(
***REMOVED*** createWorker(this.algorithm, this.prodCluster, false, "gcube"));
@ -43,5 +57,34 @@ public class ProductionPublishingJob extends DMPMJob {
***REMOVED***
public String getStatus(int exitstatus) throws FileNotFoundException, UnsupportedEncodingException {
File m = new File(this.jobLogs + File.separator + this.id);
PrintWriter writer = new PrintWriter(m, "UTF-8");
String response = "";
if (exitstatus == 9) {
response = "SVN REPOSITORY CORRECTLY UPDATED; THE CRON JOB WILL INSTALL THE ALGORITHM "+ this.algorithm.getName() + " IN THE VRE" + targetVREName;
writer.println(response);
writer.close();
***REMOVED***
return response;
***REMOVED***
public String buildInfo(){
return
"\n"+
"\n"+
"User: "+this.algorithm.getFullname()+"\n"+
"Algorithm name: "+this.algorithm.getName()+"\n"+
"Caller VRE: "+ScopeProvider.instance.get()+"\n"+
"Target VRE: "+ targetVREToken;
***REMOVED***
***REMOVED***

View File

@ -66,7 +66,7 @@ public class StagingJob extends DMPMJob {
message += "\n" + n;
***REMOVED***
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody(message));
sm.sendNotification(nh.getFailedSubject() +" for "+this.algorithm.getName()+ " algorithm", nh.getFailedBody(this.buildInfo()+message));
return;
***REMOVED***
@ -75,7 +75,7 @@ public class StagingJob extends DMPMJob {
if (ret != 0) {
this.getStatus(2);
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody("Installation failed. Return code=" + ret));
sm.sendNotification(nh.getFailedSubject() + " for "+this.algorithm.getName()+ " algorithm", nh.getFailedBody(this.buildInfo()+"Installation failed. Return code=" + ret));
return;
***REMOVED***
@ -92,12 +92,13 @@ public class StagingJob extends DMPMJob {
this.algorithm.getFullname(), "Proto");
this.getStatus(9);
sm.sendNotification(nh.getSuccessSubject(), nh.getSuccessBody());
sm.sendNotification(nh.getSuccessSubject() + "for "+this.algorithm.getName()+ " algorithm", nh.getSuccessBody(this.buildInfo()));
return;
***REMOVED*** else
this.getStatus(2);
sm.sendNotification(nh.getFailedSubject(),
sm.sendNotification(nh.getFailedSubject() + " for "+this.algorithm.getName()+ " algorithm",
nh.getFailedBody(
this.buildInfo()+"\n"+
"Installation completed but DataMiner Interface not working correctly or files "
+ this.algorithm.getName() + ".jar and " + this.algorithm.getName()
+ "_interface.jar not availables at the expected path"));
@ -136,4 +137,17 @@ public class StagingJob extends DMPMJob {
return response;
***REMOVED***
public String buildInfo(){
ServiceConfiguration a = new ServiceConfiguration();
return
"\n"+
"\n"+
"User: "+this.algorithm.getFullname()+"\n"+
"Algorithm name: "+this.algorithm.getName()+"\n"+
"Staging DataMiner Host: "+ a.getStagingHost()+
"Caller VRE: "+rProtoVREName+
"Target VRE: "+rProtoVREName;
***REMOVED***
***REMOVED***

View File

@ -17,10 +17,10 @@ public class CheckPermission {
AuthorizationEntry entry = authorizationService().get(VREToken);
if (entry.getContext().equals(vre)) {
System.out.println("OK!");
System.out.println("Authorization OK!");
return true;
***REMOVED***
System.out.println("Not a valid token recognized for the VRE: "+vre);
return false;
***REMOVED***

View File

@ -17,6 +17,10 @@ public class NotificationHelper {
private String getSubjectHeader() {
return "[DataMinerGhostInstallationRequestReport]";
***REMOVED***
private String getSubjectHeaderRelease() {
return "[DataMinerReleaseInstallationRequestReport]";
***REMOVED***
private boolean isError() {
return this.executionException!=null;
@ -30,13 +34,23 @@ public class NotificationHelper {
return this.getSubjectHeader()+" is SUCCESS";
***REMOVED***
public String getSuccessSubjectRelease() {
return this.getSubjectHeaderRelease()+" is SUCCESS";
***REMOVED***
public String getFailedSubjectRelease() {
return this.getSubjectHeaderRelease()+" is FAILED";
***REMOVED***
public String getFailedSubject() {
return String.format(this.getSubjectHeader()+" is FAILED");
***REMOVED***
public String getSuccessBody() {
public String getSuccessBody(String info) {
String message = String.format("The installation of the algorithm in the ghost dataminer is completed successfully.");
message+="\n\nYou can retrieve experiment results under the '/DataMiner' e-Infrastructure Workspace folder or from the DataMiner interface.";
message+="\n\nYou can retrieve experiment results under the '/DataMiner' e-Infrastructure Workspace folder or from the DataMiner interface.\n\n"+ info;
return message;
***REMOVED***
@ -46,6 +60,12 @@ public class NotificationHelper {
return body;
***REMOVED***
public String getSuccessBodyRelease(String info) {
String message = String.format("SVN REPOSITORY CORRECTLY UPDATED.");
message+="\n\n The CRON job will install the algorithm in the target VRE \n\n"+ info;
return message;
***REMOVED***
***REMOVED*** public String getSubject() {
***REMOVED*** if(this.isError()) {
***REMOVED*** return this.getFailedSubject();