git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@160581 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7362d8efb9
commit
961a980369
|
@ -15,14 +15,15 @@ import org.gcube.dataanalysis.dataminer.poolmanager.ansiblebridge.AnsibleBridge;
|
|||
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration;
|
||||
***REMOVED***
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.service.exceptions.AnsibleException;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.service.exceptions.UndefinedDependenciesException;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.CheckMethod;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.NotificationHelper;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.SendMail;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.AlgorithmException;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.DMPMException;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.EMailException;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.SVNCommitException;
|
||||
***REMOVED***
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.GenericException;
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
|
||||
|
@ -144,7 +145,7 @@ public abstract class DMPMJob ***REMOVED***
|
|||
|
||||
protected abstract void execute ();
|
||||
|
||||
private boolean preInstallation (SendMail sm,NotificationHelper nh, File logFile ) throws SVNException, EMailException
|
||||
private void preInstallation (SendMail sm,NotificationHelper nh, File logFile ) throws GenericException, EMailException,UndefinedDependenciesException
|
||||
***REMOVED***
|
||||
|
||||
this.logger.debug("Checking dependencies...");
|
||||
|
@ -155,123 +156,104 @@ public abstract class DMPMJob ***REMOVED***
|
|||
if (!undefinedDependencies.isEmpty())
|
||||
***REMOVED***
|
||||
this.logger.debug("Some dependencies are not defined");
|
||||
String message = "Following dependencies are not defined:\n";
|
||||
for (String n : undefinedDependencies) ***REMOVED***
|
||||
message += "\n" + n +"\n";
|
||||
***REMOVED***
|
||||
this.setStatusInformation(STATUS.FAILED);
|
||||
String errorMessage = nh.getFailedBody(message+"\n\n"+this.buildInfo());
|
||||
this.updateLogFile(logFile, errorMessage);
|
||||
sm.sendNotification(nh.getFailedSubject() +" for "+this.algorithm.getName()+ " algorithm", errorMessage);
|
||||
return false;
|
||||
throw new UndefinedDependenciesException(undefinedDependencies);
|
||||
|
||||
***REMOVED***
|
||||
else return true;
|
||||
|
||||
***REMOVED***
|
||||
|
||||
private void installation (SendMail sm,NotificationHelper nh,CheckMethod methodChecker,File logFile ) throws Exception
|
||||
private String installation (SendMail sm,NotificationHelper nh,CheckMethod methodChecker,File logFile ) throws DMPMException
|
||||
***REMOVED***
|
||||
this.logger.debug("Installation process started");
|
||||
methodChecker.deleteFiles(this.algorithm/*, env*/);
|
||||
int ret = this.executeAnsibleWorker(createWorker(this.algorithm, this.cluster, false, "root"),logFile);
|
||||
System.out.println("Return code= "+ret);
|
||||
this.logger.debug("Return code= "+ret);
|
||||
|
||||
if (ret != 0)
|
||||
***REMOVED***
|
||||
this.logger.debug("Ansible work failed, return code "+ret);
|
||||
this.setStatusInformation(STATUS.FAILED);
|
||||
String errorMessage = nh.getFailedBody("Installation failed. Return code=" + ret)+"\n\n"+this.buildInfo();
|
||||
sm.sendNotification(nh.getFailedSubject() + " for "+this.algorithm.getName()+ " algorithm",errorMessage);
|
||||
***REMOVED***
|
||||
if (ret != 0) throw new AnsibleException(ret);
|
||||
|
||||
else if (ret == 0)
|
||||
else
|
||||
***REMOVED***
|
||||
this.logger.debug("Operation completed");
|
||||
***REMOVED***this.setStatusInformation(STATUS.PROGRESS);
|
||||
this.logger.debug("Checking the method...");
|
||||
|
||||
try
|
||||
***REMOVED***
|
||||
methodChecker.checkMethod(this.configuration.getHost(), SecurityTokenProvider.instance.get());
|
||||
methodChecker.copyAlgorithms(this.algorithm);
|
||||
this.logger.debug("Method OK and algo exists");
|
||||
this.logger.debug("Interface check ok!");
|
||||
this.logger.debug("Both the files exist at the correct path!");
|
||||
boolean algorithmListResult = this.svnUpdater.updateSVNAlgorithmList(this.algorithm, this.vREName,this.category, this.algorithm_type,
|
||||
this.algorithm.getFullname());
|
||||
this.setStatusInformation(STATUS.COMPLETED);
|
||||
|
||||
String bodyResponse = algorithmListResult ? nh.getSuccessBody("\n\n"+this.buildInfo()) : nh.getSuccessBody("\n\n"+this.buildInfo())+"\nWARNING: algorithm list could not be updated on SVN";
|
||||
|
||||
sm.sendNotification(nh.getSuccessSubject() + " for "+this.algorithm.getName()+ " algorithm", bodyResponse);
|
||||
|
||||
***REMOVED*** catch (SVNCommitException e)
|
||||
***REMOVED***
|
||||
this.logger.error("Unable to complete the commit operation: "+e.getMessage());
|
||||
this.setStatusInformation(STATUS.FAILED);
|
||||
sm.sendNotification(nh.getFailedSubject() + " for "+this.algorithm.getName()+ " algorithm",
|
||||
nh.getFailedBody(
|
||||
"\n"+
|
||||
"Commit operation failed for "+e.getFileName()
|
||||
+ "the message of the SVN Server is the following:\n"+e.getSvnErrorMessage().getMessage()+"\n\n"
|
||||
+this.buildInfo()));
|
||||
|
||||
|
||||
***REMOVED*** catch (AlgorithmException ae)
|
||||
***REMOVED***
|
||||
this.logger.debug("Operation failed");
|
||||
this.setStatusInformation(STATUS.FAILED);
|
||||
sm.sendNotification(nh.getFailedSubject() + " for "+this.algorithm.getName()+ " algorithm",
|
||||
nh.getFailedBody(
|
||||
"\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")+"\n\n"+this.buildInfo());
|
||||
***REMOVED***
|
||||
|
||||
methodChecker.checkMethod(this.configuration.getHost(), SecurityTokenProvider.instance.get());
|
||||
methodChecker.copyAlgorithms(this.algorithm);
|
||||
this.logger.debug("Method OK and algo exists");
|
||||
this.logger.debug("Interface check ok!");
|
||||
this.logger.debug("Both the files exist at the correct path!");
|
||||
boolean algorithmListResult = this.svnUpdater.updateSVNAlgorithmList(this.algorithm, this.vREName,this.category, this.algorithm_type,
|
||||
this.algorithm.getFullname());
|
||||
this.setStatusInformation(STATUS.COMPLETED);
|
||||
return algorithmListResult ?"":"\nWARNING: algorithm list could not be updated on SVN";
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
|
||||
protected void execute(NotificationHelper nh, CheckMethod methodChecker)
|
||||
***REMOVED***
|
||||
SendMail sm = new SendMail();
|
||||
try ***REMOVED***
|
||||
|
||||
this.logger.debug("Pre installation operations");
|
||||
File logFile = new File(this.jobLogs,this.id);
|
||||
***REMOVED***File logFile = new File(this.jobLogs + File.separator + this.id);
|
||||
boolean preInstallationResponse = preInstallation(sm, nh, logFile);
|
||||
this.logger.debug("Pre installation operation completed with result "+preInstallationResponse);
|
||||
if (preInstallationResponse)
|
||||
***REMOVED***
|
||||
this.logger.debug("Installation...");
|
||||
installation(sm, nh, methodChecker, logFile);
|
||||
this.logger.debug("Installation completed");
|
||||
|
||||
SendMail sm = new SendMail();
|
||||
File logFile = new File(this.jobLogs,this.id);
|
||||
|
||||
try
|
||||
***REMOVED***
|
||||
|
||||
try ***REMOVED***
|
||||
|
||||
this.logger.debug("Pre installation operations");
|
||||
preInstallation(sm, nh, logFile);
|
||||
this.logger.debug("Pre installation operation completed");
|
||||
this.logger.debug("Installation...");
|
||||
String warning = installation(sm, nh, methodChecker, logFile);
|
||||
this.logger.debug("Installation completed");
|
||||
this.logger.debug("Warning message "+warning);
|
||||
this.setStatusInformation(STATUS.COMPLETED);
|
||||
String bodyResponse = NotificationHelper.getSuccessBody(warning+"\n\n"+this.buildInfo());
|
||||
sm.sendNotification(nh.getSuccessSubject() + " for "+this.algorithm.getName()+ " algorithm", bodyResponse);
|
||||
|
||||
|
||||
|
||||
***REMOVED*** catch (DMPMException dmpme)
|
||||
***REMOVED***
|
||||
this.logger.error("Operation failed: "+dmpme.getMessage());
|
||||
this.logger.error("Exception: ",dmpme);
|
||||
this.setStatusInformation(STATUS.FAILED);
|
||||
String errorMessage = "\n"+NotificationHelper.getFailedBody(dmpme.getErrorMessage()+"\n\n"+this.buildInfo());
|
||||
this.updateLogFile(logFile, errorMessage);
|
||||
sm.sendNotification(nh.getFailedSubject() +" for "+this.algorithm.getName()+ " algorithm", errorMessage);
|
||||
|
||||
***REMOVED***
|
||||
|
||||
***REMOVED*** catch (EMailException eme)
|
||||
***REMOVED***
|
||||
this.logger.error("Operation failed and unable to send notification email",eme);
|
||||
this.logger.error("Unable to send notification email",eme);
|
||||
***REMOVED***
|
||||
|
||||
catch (Exception e) ***REMOVED***
|
||||
e.printStackTrace();
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
||||
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
||||
protected int executeAnsibleWorker(AnsibleWorker worker, File logFile) throws IOException, InterruptedException, SVNException***REMOVED***
|
||||
FileOutputStream fos = new FileOutputStream(logFile, true);
|
||||
PrintStream ps = new PrintStream(fos);
|
||||
protected int executeAnsibleWorker(AnsibleWorker worker, File logFile) throws GenericException
|
||||
***REMOVED***
|
||||
try
|
||||
***REMOVED***
|
||||
FileOutputStream fos = new FileOutputStream(logFile, true);
|
||||
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);
|
||||
***REMOVED*** catch (Exception e)
|
||||
***REMOVED***
|
||||
throw new GenericException(e);
|
||||
***REMOVED***
|
||||
|
||||
***REMOVED*** File m = new File(this.jobLogs + File.separator + this.id + "_exitStatus");
|
||||
***REMOVED*** PrintWriter fos2 = new PrintWriter(m, "UTF-8");
|
||||
|
||||
return worker.execute(ps);
|
||||
***REMOVED***
|
||||
|
||||
public String buildInfo() ***REMOVED***
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package org.gcube.dataanalysis.dataminer.poolmanager.service.exceptions;
|
||||
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.DMPMException;
|
||||
|
||||
public class AnsibleException extends DMPMException ***REMOVED***
|
||||
|
||||
***REMOVED****
|
||||
*
|
||||
***REMOVED***
|
||||
private static final long serialVersionUID = 6772009633547404120L;
|
||||
private int returnCode;
|
||||
|
||||
|
||||
|
||||
public AnsibleException(int returnCode) ***REMOVED***
|
||||
super ("Ansible work failed");
|
||||
this.returnCode =returnCode;
|
||||
***REMOVED***
|
||||
|
||||
***REMOVED***
|
||||
public String getErrorMessage() ***REMOVED***
|
||||
return "Installation failed. Return code=" + this.returnCode;
|
||||
***REMOVED***
|
||||
|
||||
***REMOVED***
|
|
@ -0,0 +1,29 @@
|
|||
package org.gcube.dataanalysis.dataminer.poolmanager.service.exceptions;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.DMPMException;
|
||||
|
||||
public class UndefinedDependenciesException extends DMPMException ***REMOVED***
|
||||
|
||||
private String message;
|
||||
|
||||
***REMOVED****
|
||||
*
|
||||
***REMOVED***
|
||||
private static final long serialVersionUID = 4504593796352609191L;
|
||||
|
||||
public UndefinedDependenciesException(Collection<String> undefinedDependencies) ***REMOVED***
|
||||
super ("Some dependencies are not defined");
|
||||
this.message = "Following dependencies are not defined:\n";
|
||||
for (String n : undefinedDependencies) ***REMOVED***
|
||||
message += "\n" + n +"\n";
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
|
||||
***REMOVED***
|
||||
public String getErrorMessage() ***REMOVED***
|
||||
return this.message;
|
||||
***REMOVED***
|
||||
|
||||
***REMOVED***
|
|
@ -14,6 +14,7 @@ import java.util.Properties;
|
|||
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration;
|
||||
***REMOVED***
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.AlgorithmException;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.GenericException;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.SVNCommitException;
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
|
@ -41,6 +42,7 @@ public abstract class CheckMethod ***REMOVED***
|
|||
public CheckMethod(Configuration configuration)
|
||||
***REMOVED***
|
||||
this.logger = LoggerFactory.getLogger(CheckMethod.class);
|
||||
this.configuration = configuration;
|
||||
sshConfig = new java.util.Properties();
|
||||
sshConfig.put("StrictHostKeyChecking", "no");
|
||||
***REMOVED***
|
||||
|
@ -124,20 +126,39 @@ public abstract class CheckMethod ***REMOVED***
|
|||
|
||||
|
||||
|
||||
public void copyAlgorithms(Algorithm algo/*, String env*/) throws SVNCommitException, Exception***REMOVED***
|
||||
public void copyAlgorithms(Algorithm algo/*, String env*/) throws SVNCommitException, GenericException, AlgorithmException
|
||||
***REMOVED***
|
||||
|
||||
this.logger.debug("Looking if algo "+algo.getName()+ " exists");
|
||||
File file = new File(this.configuration.getGhostAlgoDirectory()+"/"+algo.getName()+".jar");
|
||||
File file2 = new File(this.configuration.getGhostAlgoDirectory()+"/"+algo.getName()+"_interface.jar");
|
||||
this.logger.debug("Looking for files "+file.getPath()+ " "+file.getPath());
|
||||
boolean fileExists = false;
|
||||
|
||||
|
||||
if ((this.doesExist(file.getPath()/*,env*/)) && (this.doesExist(file2.getPath()/*,env*/)))
|
||||
try
|
||||
***REMOVED***
|
||||
this.logger.debug("Files found");
|
||||
this.copyFromDmToSVN(file/*,env*/);
|
||||
this.copyFromDmToSVN(file2/*,env*/);
|
||||
this.logger.debug("Files have been copied to SVN");
|
||||
fileExists = (this.doesExist(file.getPath()/*,env*/)) && (this.doesExist(file2.getPath()/*,env*/));
|
||||
|
||||
***REMOVED*** catch (Exception e)
|
||||
***REMOVED***
|
||||
throw new GenericException(e);
|
||||
***REMOVED***
|
||||
|
||||
|
||||
if (fileExists)
|
||||
***REMOVED***
|
||||
|
||||
try
|
||||
***REMOVED***
|
||||
this.logger.debug("Files found");
|
||||
this.copyFromDmToSVN(file/*,env*/);
|
||||
this.copyFromDmToSVN(file2/*,env*/);
|
||||
this.logger.debug("Files have been copied to SVN");
|
||||
***REMOVED*** catch (Exception e)
|
||||
***REMOVED***
|
||||
throw new GenericException(e);
|
||||
***REMOVED***
|
||||
|
||||
***REMOVED***
|
||||
else
|
||||
***REMOVED***
|
||||
|
@ -150,39 +171,47 @@ public abstract class CheckMethod ***REMOVED***
|
|||
|
||||
|
||||
|
||||
public void deleteFiles(Algorithm a/*,String env*/) throws Exception
|
||||
public void deleteFiles(Algorithm a/*,String env*/) throws GenericException
|
||||
***REMOVED***
|
||||
Session session = generateSession();
|
||||
System.out.println("checking existing in env: " + this.configuration.getHost());
|
||||
try
|
||||
***REMOVED***
|
||||
Session session = generateSession();
|
||||
this.logger.debug("checking existing in env: " + this.configuration.getHost());
|
||||
|
||||
File file = new File(this.configuration.getGhostAlgoDirectory()+"/"+a.getName()+".jar");
|
||||
File file2 = new File(this.configuration.getGhostAlgoDirectory()+"/"+a.getName()+"_interface.jar");
|
||||
File file = new File(this.configuration.getGhostAlgoDirectory()+"/"+a.getName()+".jar");
|
||||
File file2 = new File(this.configuration.getGhostAlgoDirectory()+"/"+a.getName()+"_interface.jar");
|
||||
|
||||
|
||||
System.out.println("First file is located to: "+file.getPath());
|
||||
System.out.println("Second file is located to: "+file2.getPath());
|
||||
this.logger.debug("First file is located to: "+file.getPath());
|
||||
this.logger.debug("Second file is located to: "+file2.getPath());
|
||||
|
||||
|
||||
System.out.println("session created.");
|
||||
session.setConfig(this.sshConfig);
|
||||
session.connect();
|
||||
this.logger.debug("session created.");
|
||||
session.setConfig(this.sshConfig);
|
||||
session.connect();
|
||||
|
||||
Channel channel = session.openChannel(SFTP_PROTOCOL);
|
||||
channel.connect();
|
||||
System.out.println("shell channel connected....");
|
||||
Channel channel = session.openChannel(SFTP_PROTOCOL);
|
||||
channel.connect();
|
||||
this.logger.debug("shell channel connected....");
|
||||
|
||||
ChannelSftp c = (ChannelSftp) channel;
|
||||
ChannelSftp c = (ChannelSftp) channel;
|
||||
|
||||
if(doesExist(file.getPath()/*,env*/)&&(doesExist(file2.getPath()/*,env*/)))***REMOVED***
|
||||
if(doesExist(file.getPath()/*,env*/)&&(doesExist(file2.getPath()/*,env*/)))***REMOVED***
|
||||
|
||||
c.rm(file.getPath());
|
||||
c.rm(file2.getPath());
|
||||
System.out.println("Both the files have been deleted");
|
||||
c.rm(file.getPath());
|
||||
c.rm(file2.getPath());
|
||||
this.logger.debug("Both the files have been deleted");
|
||||
***REMOVED***
|
||||
else this.logger.debug("Files not found");
|
||||
channel.disconnect();
|
||||
c.disconnect();
|
||||
session.disconnect();
|
||||
***REMOVED*** catch (Exception e)
|
||||
***REMOVED***
|
||||
throw new GenericException(e);
|
||||
***REMOVED***
|
||||
else System.out.println("Files not found");
|
||||
channel.disconnect();
|
||||
c.disconnect();
|
||||
session.disconnect();
|
||||
|
||||
|
||||
|
||||
***REMOVED***
|
||||
|
||||
|
|
|
@ -36,13 +36,13 @@ public abstract class NotificationHelper ***REMOVED***
|
|||
***REMOVED***
|
||||
|
||||
|
||||
public String getSuccessBody(String info) ***REMOVED***
|
||||
public static String getSuccessBody(String info) ***REMOVED***
|
||||
String message = String.format("The installation of the algorithm is completed successfully.");
|
||||
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***
|
||||
|
||||
public String getFailedBody(String message) ***REMOVED***
|
||||
public static String getFailedBody(String message) ***REMOVED***
|
||||
String body = String.format("An error occurred while deploying your algorithm");
|
||||
body+= "\n\nHere are the error details:\n\n" + message;
|
||||
return body;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.TimeZone;
|
|||
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.Configuration;
|
||||
***REMOVED***
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.GenericException;
|
||||
import org.gcube.dataanalysis.dataminer.poolmanager.util.exception.SVNCommitException;
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
|
@ -162,9 +163,7 @@ public abstract class SVNUpdater ***REMOVED***
|
|||
if (errorMessage != null)
|
||||
***REMOVED***
|
||||
this.logger.error("Operation failed: "+errorMessage.getFullMessage());
|
||||
SVNCommitException exception = new SVNCommitException(errorMessage);
|
||||
exception.setFileName(fileName);
|
||||
throw exception;
|
||||
throw new SVNCommitException(errorMessage,fileName);
|
||||
***REMOVED***
|
||||
|
||||
this.logger.debug("Operation completed");
|
||||
|
@ -195,9 +194,8 @@ public abstract class SVNUpdater ***REMOVED***
|
|||
if (errorMessage != null)
|
||||
***REMOVED***
|
||||
this.logger.error("Operation failed: "+errorMessage.getFullMessage());
|
||||
SVNCommitException exception = new SVNCommitException(errorMessage);
|
||||
exception.setFileName(fileName+" to be updated");
|
||||
throw exception;
|
||||
|
||||
throw new SVNCommitException(errorMessage,fileName+" to be updated");
|
||||
***REMOVED***
|
||||
|
||||
this.logger.debug("Operation completed");
|
||||
|
@ -318,91 +316,100 @@ public abstract class SVNUpdater ***REMOVED***
|
|||
***REMOVED***
|
||||
|
||||
|
||||
public Collection<String> getUndefinedDependencies(String file, Collection<Dependency> deps) throws SVNException ***REMOVED***
|
||||
***REMOVED*** SendMail sm = new SendMail();
|
||||
***REMOVED*** NotificationHelper nh = new NotificationHelper();
|
||||
|
||||
List<String> undefined = new LinkedList<String>();
|
||||
|
||||
***REMOVED***to fix in next release: if the file is not present for that language in the service.properties then skip and return null list of string
|
||||
***REMOVED***just to uncomment the following lines
|
||||
|
||||
if(file.isEmpty())***REMOVED***
|
||||
return undefined;
|
||||
public Collection<String> getUndefinedDependencies(String file, Collection<Dependency> deps) throws GenericException
|
||||
***REMOVED***
|
||||
|
||||
|
||||
System.out.println("Checking dependencies list: " + file);
|
||||
|
||||
|
||||
List<String> validDependencies = new LinkedList<String>();
|
||||
|
||||
for (String singlefile: CheckMethod.getFiles(file))***REMOVED***
|
||||
|
||||
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
svnRepository.getFile(singlefile, SVNRepository.INVALID_REVISION, null, byteArrayOutputStream);
|
||||
|
||||
for(String l: byteArrayOutputStream.toString().split("\\r?\\n"))***REMOVED***
|
||||
validDependencies.add(l.trim());
|
||||
***REMOVED******REMOVED***
|
||||
|
||||
System.out.println("Valid dependencies are: "+validDependencies);
|
||||
for(Dependency d: deps)***REMOVED***
|
||||
String depName = d.getName();
|
||||
if(!validDependencies.contains(depName))***REMOVED***
|
||||
undefined.add(depName);
|
||||
try
|
||||
***REMOVED***
|
||||
***REMOVED*** SendMail sm = new SendMail();
|
||||
***REMOVED*** NotificationHelper nh = new NotificationHelper();
|
||||
|
||||
List<String> undefined = new LinkedList<String>();
|
||||
|
||||
***REMOVED***to fix in next release: if the file is not present for that language in the service.properties then skip and return null list of string
|
||||
***REMOVED***just to uncomment the following lines
|
||||
|
||||
if(file.isEmpty())***REMOVED***
|
||||
return undefined;
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
|
||||
|
||||
return undefined;
|
||||
this.logger.debug("Checking dependencies list: " + file);
|
||||
|
||||
|
||||
List<String> validDependencies = new LinkedList<String>();
|
||||
|
||||
for (String singlefile: CheckMethod.getFiles(file))***REMOVED***
|
||||
|
||||
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
svnRepository.getFile(singlefile, SVNRepository.INVALID_REVISION, null, byteArrayOutputStream);
|
||||
|
||||
for(String l: byteArrayOutputStream.toString().split("\\r?\\n"))***REMOVED***
|
||||
validDependencies.add(l.trim());
|
||||
***REMOVED******REMOVED***
|
||||
|
||||
this.logger.debug("Valid dependencies are: "+validDependencies);
|
||||
for(Dependency d: deps)***REMOVED***
|
||||
String depName = d.getName();
|
||||
if(!validDependencies.contains(depName))***REMOVED***
|
||||
undefined.add(depName);
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
|
||||
|
||||
return undefined;
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
***REMOVED*** for (String a : lines) ***REMOVED***
|
||||
***REMOVED*** for (String b : ldep) ***REMOVED***
|
||||
***REMOVED*** if (b.equals(a)) ***REMOVED***
|
||||
***REMOVED*** System.out.println("The following dependency is correctly written: " + b);
|
||||
***REMOVED*** ***REMOVED*** else
|
||||
***REMOVED***
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED***
|
||||
***REMOVED*** boolean check = false;
|
||||
***REMOVED*** try ***REMOVED***
|
||||
***REMOVED*** System.out.println("Checking dependencies list: " + file);
|
||||
***REMOVED*** final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
***REMOVED*** svnRepository.getFile(file, SVNRepository.INVALID_REVISION, null, byteArrayOutputStream);
|
||||
***REMOVED*** String lines[] = byteArrayOutputStream.toString().split("\\r?\\n");
|
||||
***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** if(deps.isEmpty())***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody());
|
||||
***REMOVED*** ***REMOVED*** Exception e = new Exception("No dependency specified for this
|
||||
***REMOVED*** ***REMOVED*** algorithm");
|
||||
***REMOVED*** ***REMOVED*** throw e;
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** ***REMOVED***
|
||||
***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** else if (!deps.isEmpty()) ***REMOVED***
|
||||
***REMOVED*** List<String> ldep = new LinkedList<>();
|
||||
***REMOVED*** for (Dependency d : deps) ***REMOVED***
|
||||
***REMOVED*** ldep.add(d.getName());
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** for (String a : lines) ***REMOVED***
|
||||
***REMOVED*** for (String b : ldep) ***REMOVED***
|
||||
***REMOVED*** if (b.equals(a)) ***REMOVED***
|
||||
***REMOVED*** System.out.println("The following dependency is correctly written: " + b);
|
||||
***REMOVED*** check = true;
|
||||
***REMOVED*** ***REMOVED*** else
|
||||
***REMOVED*** check = false;
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** catch (Exception a) ***REMOVED***
|
||||
***REMOVED*** a.getMessage();
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED***
|
||||
***REMOVED*** return check;
|
||||
***REMOVED*** boolean check = false;
|
||||
***REMOVED*** try ***REMOVED***
|
||||
***REMOVED*** System.out.println("Checking dependencies list: " + file);
|
||||
***REMOVED*** final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
***REMOVED*** svnRepository.getFile(file, SVNRepository.INVALID_REVISION, null, byteArrayOutputStream);
|
||||
***REMOVED*** String lines[] = byteArrayOutputStream.toString().split("\\r?\\n");
|
||||
***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** if(deps.isEmpty())***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody());
|
||||
***REMOVED*** ***REMOVED*** Exception e = new Exception("No dependency specified for this
|
||||
***REMOVED*** ***REMOVED*** algorithm");
|
||||
***REMOVED*** ***REMOVED*** throw e;
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** ***REMOVED***
|
||||
***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** else if (!deps.isEmpty()) ***REMOVED***
|
||||
***REMOVED*** List<String> ldep = new LinkedList<>();
|
||||
***REMOVED*** for (Dependency d : deps) ***REMOVED***
|
||||
***REMOVED*** ldep.add(d.getName());
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** for (String a : lines) ***REMOVED***
|
||||
***REMOVED*** for (String b : ldep) ***REMOVED***
|
||||
***REMOVED*** if (b.equals(a)) ***REMOVED***
|
||||
***REMOVED*** System.out.println("The following dependency is correctly written: " + b);
|
||||
***REMOVED*** check = true;
|
||||
***REMOVED*** ***REMOVED*** else
|
||||
***REMOVED*** check = false;
|
||||
***REMOVED***
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** ***REMOVED***
|
||||
***REMOVED*** ***REMOVED*** catch (Exception a) ***REMOVED***
|
||||
***REMOVED*** a.getMessage();
|
||||
***REMOVED*** ***REMOVED***
|
||||
***REMOVED***
|
||||
***REMOVED*** return check;
|
||||
***REMOVED*** catch (SVNException e)
|
||||
***REMOVED***
|
||||
throw new GenericException(e);
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
||||
***REMOVED***
|
||||
|
||||
|
|
|
@ -144,6 +144,7 @@ public class SendMail ***REMOVED***
|
|||
|
||||
public String sendPostRequest(String endpoint, String requestParameters) ***REMOVED***
|
||||
|
||||
this.logger.debug("Sending post request");
|
||||
***REMOVED*** Build parameter string
|
||||
String data = requestParameters;
|
||||
try ***REMOVED***
|
||||
|
@ -169,13 +170,17 @@ public class SendMail ***REMOVED***
|
|||
writer.close();
|
||||
reader.close();
|
||||
|
||||
this.logger.debug("Operation completed");
|
||||
String response = answer.toString();
|
||||
this.logger.debug("Response "+response);
|
||||
***REMOVED*** Output the response
|
||||
return answer.toString();
|
||||
return response;
|
||||
|
||||
***REMOVED*** catch (MalformedURLException ex) ***REMOVED***
|
||||
ex.printStackTrace();
|
||||
this.logger.error("Invalid URL",ex);
|
||||
***REMOVED*** catch (IOException ex) ***REMOVED***
|
||||
ex.printStackTrace();
|
||||
|
||||
this.logger.error("Error in the IO process",ex);
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
***REMOVED***
|
||||
|
|
|
@ -1,25 +1,34 @@
|
|||
package org.gcube.dataanalysis.dataminer.poolmanager.util.exception;
|
||||
|
||||
public class AlgorithmException extends Exception ***REMOVED***
|
||||
public class AlgorithmException extends DMPMException***REMOVED***
|
||||
|
||||
***REMOVED****
|
||||
*
|
||||
***REMOVED***
|
||||
private static final long serialVersionUID = -5678597187512954288L;
|
||||
private String algorithmName;
|
||||
|
||||
public AlgorithmException ()
|
||||
public AlgorithmException (String algorithmName)
|
||||
***REMOVED***
|
||||
super ();
|
||||
super ("Algorithm exception");
|
||||
this.algorithmName = algorithmName;
|
||||
|
||||
***REMOVED***
|
||||
|
||||
public AlgorithmException (String message)
|
||||
|
||||
|
||||
public AlgorithmException (String algorithmName, Throwable cause)
|
||||
***REMOVED***
|
||||
super (message);
|
||||
super ("Algorithm exception", cause);
|
||||
this.algorithmName = algorithmName;
|
||||
***REMOVED***
|
||||
|
||||
public AlgorithmException (String message, Throwable cause)
|
||||
***REMOVED***
|
||||
super (message, cause);
|
||||
***REMOVED***
|
||||
public String getErrorMessage() ***REMOVED***
|
||||
|
||||
return "Installation completed but DataMiner Interface not working correctly or files "
|
||||
+ this.algorithmName + ".jar and " + this.algorithmName
|
||||
+ "_interface.jar not availables at the expected path";
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.dataanalysis.dataminer.poolmanager.util.exception;
|
||||
|
||||
public abstract class DMPMException extends Exception***REMOVED***
|
||||
|
||||
***REMOVED****
|
||||
*
|
||||
***REMOVED***
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public DMPMException (String errorMessage)
|
||||
***REMOVED***
|
||||
super (errorMessage);
|
||||
***REMOVED***
|
||||
|
||||
public DMPMException(String errorMessage,Throwable cause) ***REMOVED***
|
||||
super (errorMessage,cause);
|
||||
***REMOVED***
|
||||
|
||||
public abstract String getErrorMessage ();
|
||||
***REMOVED***
|
|
@ -3,6 +3,7 @@ package org.gcube.dataanalysis.dataminer.poolmanager.util.exception;
|
|||
public class EMailException extends Exception ***REMOVED***
|
||||
|
||||
|
||||
private static final String MESSAGE = "Unable to send email notification";
|
||||
|
||||
***REMOVED****
|
||||
*
|
||||
|
@ -10,10 +11,14 @@ public class EMailException extends Exception ***REMOVED***
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public EMailException() ***REMOVED***
|
||||
super ("Unable to send email notification");
|
||||
super (MESSAGE);
|
||||
***REMOVED***
|
||||
|
||||
public EMailException(Throwable cause) ***REMOVED***
|
||||
super ("Unable to send email notification",cause);
|
||||
super (MESSAGE,cause);
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
||||
|
||||
***REMOVED***
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package org.gcube.dataanalysis.dataminer.poolmanager.util.exception;
|
||||
|
||||
public class GenericException extends DMPMException ***REMOVED***
|
||||
|
||||
***REMOVED****
|
||||
*
|
||||
***REMOVED***
|
||||
private static final long serialVersionUID = 6772009633547404120L;
|
||||
|
||||
|
||||
|
||||
public GenericException(Throwable cause) ***REMOVED***
|
||||
super ("Generic exception",cause);
|
||||
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
||||
***REMOVED***
|
||||
public String getErrorMessage() ***REMOVED***
|
||||
return this.getCause().getMessage();
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
||||
***REMOVED***
|
|
@ -2,7 +2,7 @@ package org.gcube.dataanalysis.dataminer.poolmanager.util.exception;
|
|||
|
||||
import org.tmatesoft.svn.core.SVNErrorMessage;
|
||||
|
||||
public class SVNCommitException extends Exception ***REMOVED***
|
||||
public class SVNCommitException extends DMPMException ***REMOVED***
|
||||
|
||||
***REMOVED****
|
||||
*
|
||||
|
@ -13,28 +13,31 @@ public class SVNCommitException extends Exception ***REMOVED***
|
|||
|
||||
private String fileName;
|
||||
|
||||
public SVNCommitException(SVNErrorMessage errorMessage) ***REMOVED***
|
||||
public SVNCommitException(SVNErrorMessage errorMessage, String fileName) ***REMOVED***
|
||||
super ("Unable to commit");
|
||||
this.svnErrorMessage = errorMessage;
|
||||
this.fileName = fileName;
|
||||
***REMOVED***
|
||||
|
||||
public SVNCommitException(String message,SVNErrorMessage errorMessage) ***REMOVED***
|
||||
public SVNCommitException(String message,SVNErrorMessage errorMessage,String fileName) ***REMOVED***
|
||||
super (message);
|
||||
this.svnErrorMessage = errorMessage;
|
||||
this.fileName = fileName;
|
||||
***REMOVED***
|
||||
|
||||
public SVNErrorMessage getSvnErrorMessage() ***REMOVED***
|
||||
return svnErrorMessage;
|
||||
|
||||
***REMOVED***
|
||||
|
||||
public void setFileName (String fileName)
|
||||
***REMOVED***
|
||||
this.fileName = fileName;
|
||||
***REMOVED***
|
||||
|
||||
public String getFileName ()
|
||||
***REMOVED***
|
||||
return this.fileName;
|
||||
|
||||
***REMOVED***
|
||||
public String getErrorMessage() ***REMOVED***
|
||||
|
||||
return "Commit operation failed for "+this.fileName
|
||||
+ "the message of the SVN Server is the following:\n"+this.svnErrorMessage.getMessage();
|
||||
|
||||
***REMOVED***
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue