This commit is contained in:
Nunzio Andrea Galante 2017-08-29 15:43:31 +00:00
parent 2c4ee18a2b
commit bf15cee6bc
7 changed files with 69 additions and 44 deletions

View File

@ -2,15 +2,11 @@
xmlns="http:***REMOVED***maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns="http:***REMOVED***maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http:***REMOVED***www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http:***REMOVED***www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http:***REMOVED***maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http:***REMOVED***maven.apache.org/xsd/assembly-1.1.0.xsd"> xsi:schemaLocation="http:***REMOVED***maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http:***REMOVED***maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id> <id>servicearchive</id>
<formats> <formats>
<format>tar.gz</format> <format>tar.gz</format>
</formats> </formats>
<baseDirectory>/</baseDirectory> <baseDirectory>/</baseDirectory>
<fileSets> <fileSets>
<fileSet> <fileSet>
<directory>${distroDirectory***REMOVED***</directory> <directory>${distroDirectory***REMOVED***</directory>
@ -19,18 +15,16 @@
<includes> <includes>
<include>README</include> <include>README</include>
<include>LICENSE</include> <include>LICENSE</include>
<include>profile.xml</include> <include>changelog.xml</include>
</includes> </includes>
<fileMode>755</fileMode> <fileMode>755</fileMode>
<filtered>true</filtered> <filtered>true</filtered>
</fileSet> </fileSet>
</fileSets> </fileSets>
<files> <files>
<file> <file>
<source>target/${build.finalName***REMOVED***.war</source> <source>target/${build.finalName***REMOVED***.war</source>
<outputDirectory>/${artifactId***REMOVED***</outputDirectory> <outputDirectory>/${artifactId***REMOVED***</outputDirectory>
</file> </file>
</files> </files>
</assembly> </assembly>

View File

@ -11,8 +11,8 @@
<groupId>org.gcube.dataAnalysis</groupId> <groupId>org.gcube.dataAnalysis</groupId>
<artifactId>dataminer-pool-manager</artifactId> <artifactId>dataminer-pool-manager</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<version>2.0.0-SNAPSHOT</version>
<name>dataminer-pool-manager</name> <name>dataminer-pool-manager</name>
<description> <description>

View File

@ -51,11 +51,12 @@ public class RestPoolManager implements PoolManager {
@Produces("text/plain") @Produces("text/plain")
public String stageAlgorithm( public String stageAlgorithm(
@QueryParam("algorithmPackageURL") String algorithmPackageURL, @QueryParam("algorithmPackageURL") String algorithmPackageURL,
@QueryParam("targetVRE") String targetVRE @QueryParam("targetVRE") String targetVRE,
/*@QueryParam("category") String category*/) throws IOException, InterruptedException { @QueryParam("category") String category,
@QueryParam("algorithm_type") String algorithm_type) throws IOException, InterruptedException {
Algorithm algo = AlgorithmBuilder.create(algorithmPackageURL); Algorithm algo = AlgorithmBuilder.create(algorithmPackageURL);
String env = context.application().getInitParameter("Environment"); String env = context.application().getInitParameter("Environment");
return this.service.stageAlgorithm(algo,env,targetVRE); return this.service.stageAlgorithm(algo,targetVRE,category,algorithm_type,env);
***REMOVED*** ***REMOVED***
@ -64,12 +65,13 @@ public class RestPoolManager implements PoolManager {
@Produces("text/plain") @Produces("text/plain")
public String publishAlgorithm( public String publishAlgorithm(
@QueryParam("algorithmPackageURL") String algorithmPackageURL, @QueryParam("algorithmPackageURL") String algorithmPackageURL,
@QueryParam("targetVREToken") String targetVREToken, ***REMOVED***@QueryParam("targetVREToken") String targetVREToken,
@QueryParam("targetVRE") String targetVRE @QueryParam("targetVRE") String targetVRE,
/*@QueryParam("category") String category*/) throws IOException, InterruptedException { @QueryParam("category") String category,
@QueryParam("algorithm_type") String algorithm_type) throws IOException, InterruptedException {
Algorithm algo = AlgorithmBuilder.create(algorithmPackageURL); Algorithm algo = AlgorithmBuilder.create(algorithmPackageURL);
String env = context.application().getInitParameter("Environment"); String env = context.application().getInitParameter("Environment");
return this.service.publishAlgorithm(algo, targetVREToken, targetVRE,env); return this.service.publishAlgorithm(algo, /*targetVREToken,*/ targetVRE,category,algorithm_type,env);
***REMOVED*** ***REMOVED***
/* /*
@ -225,6 +227,17 @@ public class RestPoolManager implements PoolManager {
***REMOVED*** ***REMOVED***
@Override
public String publishAlgorithm(String algorithmPackageURL, String targetVREToken, String targetVRE)
throws IOException, InterruptedException {
***REMOVED*** TODO Auto-generated method stub
return null;
***REMOVED***

View File

@ -28,23 +28,23 @@ public class DataminerPoolManager {
***REMOVED*** ***REMOVED***
public String stageAlgorithm(Algorithm algo, String env, String targetVRE) throws IOException, InterruptedException { public String stageAlgorithm(Algorithm algo,String targetVRE, String category, String algorithm_type,String env) throws IOException, InterruptedException {
Cluster stagingCluster = ClusterBuilder.getStagingDataminerCluster(env); Cluster stagingCluster = ClusterBuilder.getStagingDataminerCluster(env);
***REMOVED***Cluster rProtoCluster = ClusterBuilder.getRProtoCluster(); ***REMOVED***Cluster rProtoCluster = ClusterBuilder.getRProtoCluster();
DMPMJob job = new StagingJob(this.svnUpdater, algo, stagingCluster, /*rProtoCluster,*/ targetVRE, env); DMPMJob job = new StagingJob(this.svnUpdater, algo, stagingCluster, /*rProtoCluster,*/ targetVRE, category, algorithm_type,env);
String id = job.start(); String id = job.start();
return id; return id;
***REMOVED*** ***REMOVED***
public String publishAlgorithm(Algorithm algo, String targetVREToken, String targetVRE, String env) throws IOException, InterruptedException { public String publishAlgorithm(Algorithm algo, String targetVRE, String category, String algorithm_type, String env) throws IOException, InterruptedException {
***REMOVED***Cluster prodCluster = ClusterBuilder.getVRECluster(targetVREToken, targetVRE); ***REMOVED***Cluster prodCluster = ClusterBuilder.getVRECluster(targetVREToken, targetVRE);
DMPMJob job = new ProductionPublishingJob(this.svnUpdater, algo, /*prodCluster,*/ targetVRE, targetVREToken,env); DMPMJob job = new ProductionPublishingJob(this.svnUpdater, algo, /*prodCluster,*/ targetVRE, category, algorithm_type,env);
String id = job.start(); String id = job.start();
return id; return id;
***REMOVED*** ***REMOVED***

View File

@ -19,16 +19,21 @@ public class ProductionPublishingJob extends DMPMJob {
private Algorithm algorithm; private Algorithm algorithm;
***REMOVED***private Cluster prodCluster; ***REMOVED***private Cluster prodCluster;
private String targetVREName; private String targetVREName;
private String targetVREToken; private String category;
private String algorithm_type;
***REMOVED***private String targetVREToken;
private String env; private String env;
public ProductionPublishingJob(SVNUpdater svnUpdater, Algorithm algorithm, /*Cluster prodCluster,*/ String targetVREName, String targetVREToken, String env) throws FileNotFoundException, UnsupportedEncodingException { public ProductionPublishingJob(SVNUpdater svnUpdater, Algorithm algorithm,
/*Cluster prodCluster,*/ String targetVREName, String category,String algorithm_type, String env) throws FileNotFoundException, UnsupportedEncodingException {
super(svnUpdater); super(svnUpdater);
this.algorithm = algorithm; this.algorithm = algorithm;
***REMOVED***this.prodCluster = prodCluster; ***REMOVED***this.prodCluster = prodCluster;
this.targetVREName = targetVREName; this.targetVREName = targetVREName;
this.targetVREToken = targetVREToken; this.category = category;
this.algorithm_type = algorithm_type;
***REMOVED***this.targetVREToken = targetVREToken;
this.env= env; this.env= env;
@ -42,21 +47,30 @@ public class ProductionPublishingJob extends DMPMJob {
NotificationHelper nh = new NotificationHelper(); NotificationHelper nh = new NotificationHelper();
try { try {
if (CheckPermission.apply(targetVREToken,targetVREName)){ ***REMOVED***if (CheckPermission.apply(targetVREToken,targetVREName)){
***REMOVED***this.svnUpdater.updateProdDeps(this.algorithm); ***REMOVED***this.svnUpdater.updateProdDeps(this.algorithm);
this.svnUpdater.updateSVNAlgorithmList(this.algorithm, this.targetVREName, this.algorithm.getFullname(), env); this.svnUpdater.updateSVNAlgorithmList(this.algorithm, this.targetVREName, this.category,this.algorithm_type, this.algorithm.getFullname(), env);
this.getStatus(9); this.getStatus(9);
sm.sendNotification(nh.getSuccessSubjectRelease() + " for "+this.algorithm.getName()+ " algorithm", nh.getSuccessBodyRelease("\n\n"+this.buildInfo())); sm.sendNotification(nh.getSuccessSubjectRelease() + " for "+this.algorithm.getName()+ " algorithm", nh.getSuccessBodyRelease("\n\n"+this.buildInfo()));
return; return;
***REMOVED*** ***REMOVED******REMOVED***
else this.getStatus(0); ***REMOVED***else this.getStatus(0);
sm.sendNotification(nh.getFailedSubjectRelease() + " for "+this.algorithm.getName()+ " algorithm", nh.getFailedBodyRelease(" The user "+this.algorithm.getFullname()+ " is not authorized to access to the "+ targetVREName+ " VRE"+"\n\n"+this.buildInfo())); ***REMOVED***sm.sendNotification(nh.getFailedSubjectRelease() + " for "+this.algorithm.getName()+ " algorithm", nh.getFailedBodyRelease(" The user "+this.algorithm.getFullname()+ " is not authorized to access to the "+ targetVREName+ " VRE"+"\n\n"+this.buildInfo()));
return; ***REMOVED***return;
***REMOVED*** int ret = this.executeAnsibleWorker( ***REMOVED*** int ret = this.executeAnsibleWorker(
***REMOVED*** createWorker(this.algorithm, this.prodCluster, false, "gcube")); ***REMOVED*** createWorker(this.algorithm, this.prodCluster, false, "gcube"));
***REMOVED*** catch (Exception e) { ***REMOVED*** catch (Exception e) {
try {
this.getStatus(0);
***REMOVED*** catch (FileNotFoundException e1) {
***REMOVED*** TODO Auto-generated catch block
e1.printStackTrace();
***REMOVED*** catch (UnsupportedEncodingException e1) {
***REMOVED*** TODO Auto-generated catch block
e1.printStackTrace();
***REMOVED***
e.printStackTrace(); e.printStackTrace();
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
@ -70,12 +84,12 @@ public class ProductionPublishingJob extends DMPMJob {
String response = ""; String response = "";
if (exitstatus == 9) { if (exitstatus == 9) {
response = "SVN REPOSITORY CORRECTLY UPDATED; THE CRON JOB WILL INSTALL THE ALGORITHM "+ this.algorithm.getName() + " IN THE VRE " + targetVREName; response = "COMPLETED";
writer.println(response); writer.println(response);
***REMOVED*** ***REMOVED***
if (exitstatus == 0) { if (exitstatus == 0) {
response = "SVN REPOSITORY UPDATE FAI; THE CRON JOB WILL NOT BE ABLE TO INSTALL THE ALGORITHM "+this.algorithm.getName()+" IN THE VRE " + targetVREName;; response = "FAILED";
writer.println(response); writer.println(response);
***REMOVED***writer.close(); ***REMOVED***writer.close();
***REMOVED*** ***REMOVED***

View File

@ -28,11 +28,13 @@ public class StagingJob extends DMPMJob {
***REMOVED*** private Cluster rProtoCluster; ***REMOVED*** private Cluster rProtoCluster;
private String rProtoVREName; private String rProtoVREName;
private String env; private String env;
private String category;
private String algorithm_type;
public StagingJob(SVNUpdater svnUpdater, Algorithm algorithm, public StagingJob(SVNUpdater svnUpdater, Algorithm algorithm,
Cluster stagingCluster, /* Cluster rProtoCluster, */ Cluster stagingCluster, /* Cluster rProtoCluster, */
String rProtoVREName, String env) throws FileNotFoundException, UnsupportedEncodingException { String rProtoVREName, String category, String algorithm_type, String env) throws FileNotFoundException, UnsupportedEncodingException {
super(svnUpdater); super(svnUpdater);
this.jobLogs = new File( this.jobLogs = new File(
System.getProperty("user.home") + File.separator + "dataminer-pool-manager" + File.separator + "jobs"); System.getProperty("user.home") + File.separator + "dataminer-pool-manager" + File.separator + "jobs");
@ -43,6 +45,8 @@ public class StagingJob extends DMPMJob {
***REMOVED*** this.rProtoCluster = rProtoCluster; ***REMOVED*** this.rProtoCluster = rProtoCluster;
this.rProtoVREName = rProtoVREName; this.rProtoVREName = rProtoVREName;
this.env = env; this.env = env;
this.category = category;
this.algorithm_type = algorithm_type;
***REMOVED***File m = new File(this.jobLogs + File.separator + this.id + "_exitStatus"); ***REMOVED***File m = new File(this.jobLogs + File.separator + this.id + "_exitStatus");
@ -101,7 +105,7 @@ public class StagingJob extends DMPMJob {
System.out.println("Interface check ok!"); System.out.println("Interface check ok!");
System.out.println("Both the files exist at the correct path!"); System.out.println("Both the files exist at the correct path!");
this.svnUpdater.updateSVNAlgorithmList(this.algorithm, this.rProtoVREName, this.svnUpdater.updateSVNAlgorithmList(this.algorithm, this.rProtoVREName,this.category, this.algorithm_type,
this.algorithm.getFullname(), env); this.algorithm.getFullname(), env);
this.getStatus(9); this.getStatus(9);
@ -160,7 +164,7 @@ public class StagingJob extends DMPMJob {
"User: "+this.algorithm.getFullname()+"\n"+ "User: "+this.algorithm.getFullname()+"\n"+
"Algorithm name: "+this.algorithm.getName()+"\n"+ "Algorithm name: "+this.algorithm.getName()+"\n"+
"Staging DataMiner Host: "+ a.getHost(this.env)+"\n"+ "Staging DataMiner Host: "+ a.getHost(this.env)+"\n"+
"Caller VRE: "+rProtoVREName+"\n"+ "Caller VRE: "+ScopeProvider.instance.get()+"\n"+
"Target VRE: "+rProtoVREName+"\n"; "Target VRE: "+rProtoVREName+"\n";
***REMOVED*** ***REMOVED***

View File

@ -249,23 +249,23 @@ public class SVNUpdater {
***REMOVED*** this.updateSVN(this.configuration.getSVNRProdGitHubDepsList(), algorithm.getGitHubDependencies()); ***REMOVED*** this.updateSVN(this.configuration.getSVNRProdGitHubDepsList(), algorithm.getGitHubDependencies());
***REMOVED******REMOVED*** ***REMOVED******REMOVED***
public void updateSVNAlgorithmList(Algorithm algorithm, String targetVRE, String user, String env) { public void updateSVNAlgorithmList(Algorithm algorithm, String targetVRE, String category, String algorithm_type, String user, String env) {
if (env.equals("Dev")){ if (env.equals("Dev")){
this.updateSVNAlgorithmList(this.configuration.getSVNDevAlgorithmsList(), algorithm, targetVRE, user, env); this.updateSVNAlgorithmList(this.configuration.getSVNDevAlgorithmsList(), algorithm, targetVRE, category,algorithm_type, user, env);
***REMOVED*** ***REMOVED***
if (env.equals("Prod")){ if (env.equals("Prod")){
this.updateSVNAlgorithmList(this.configuration.getSVNProdAlgorithmsList(), algorithm, targetVRE, user, env); this.updateSVNAlgorithmList(this.configuration.getSVNProdAlgorithmsList(), algorithm, targetVRE, category, algorithm_type, user, env);
***REMOVED*** ***REMOVED***
if (env.equals("Proto")){ if (env.equals("Proto")){
this.updateSVNAlgorithmList(this.configuration.getSVNRProtoAlgorithmsList(), algorithm, targetVRE, user, env); this.updateSVNAlgorithmList(this.configuration.getSVNRProtoAlgorithmsList(), algorithm, targetVRE, category, algorithm_type, user, env);
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
public void updateSVNProdAlgorithmList(Algorithm algorithm, String targetVRE, String user, String env) { public void updateSVNProdAlgorithmList(Algorithm algorithm, String targetVRE, String category, String algorithm_type, String user, String env) {
this.updateSVNAlgorithmList(this.configuration.getSVNProdAlgorithmsList(), algorithm, targetVRE, user, env); this.updateSVNAlgorithmList(this.configuration.getSVNProdAlgorithmsList(), algorithm, targetVRE, category, algorithm_type, user, env);
***REMOVED*** ***REMOVED***
@ -371,7 +371,7 @@ public class SVNUpdater {
***REMOVED*** ***REMOVED***
public void updateSVNAlgorithmList(String file, Algorithm algorithm, String targetVRE, String user, String env) { public void updateSVNAlgorithmList(String file, Algorithm algorithm, String targetVRE, String category, String algorithm_type, String user, String env) {
try { try {
System.out.println("Updating algorithm list: " + file); System.out.println("Updating algorithm list: " + file);
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
@ -389,7 +389,7 @@ public class SVNUpdater {
***REMOVED*** the algorithm is not in the list. Add it ***REMOVED*** the algorithm is not in the list. Add it
List<String> newContent = new LinkedList<>(Arrays.asList(lines)); List<String> newContent = new LinkedList<>(Arrays.asList(lines));
newContent.add(this.generateAlgorithmEntry(algorithm, targetVRE, env)); newContent.add(this.generateAlgorithmEntry(algorithm, targetVRE, category,algorithm_type, env));
***REMOVED*** Collections.sort(newContent); ***REMOVED*** Collections.sort(newContent);
final SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator(); final SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
@ -424,14 +424,14 @@ public class SVNUpdater {
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
public String generateAlgorithmEntry(Algorithm algorithm, String targetVRE, String env) { public String generateAlgorithmEntry(Algorithm algorithm, String targetVRE, String category, String algorithm_type,String env) {
StringBuffer sb = new StringBuffer("| "); StringBuffer sb = new StringBuffer("| ");
sb.append(algorithm.getName() + " | "); sb.append(algorithm.getName() + " | ");
sb.append(algorithm.getFullname() + " | "); sb.append(algorithm.getFullname() + " | ");
sb.append(algorithm.getCategory() + " | "); sb.append(category + " | ");
sb.append(env + " | "); sb.append(env + " | ");
sb.append("<notextile>./addAlgorithm.sh " + algorithm.getName() + " " + algorithm.getCategory() + " " sb.append("<notextile>./addAlgorithm.sh " + algorithm.getName() + " " + algorithm.getCategory() + " "
+ algorithm.getClazz() + " " + targetVRE + " " + algorithm.getAlgorithmType() + " N " + algorithm.getClazz() + " " + targetVRE + " " + algorithm_type + " N "
+ algorithm.getPackageURL() + " \"" + algorithm.getDescription() + "\" </notextile> | "); + algorithm.getPackageURL() + " \"" + algorithm.getDescription() + "\" </notextile> | ");
sb.append("none |"); sb.append("none |");
return sb.toString(); return sb.toString();