2017-03-03 19:10:02 +01:00
|
|
|
package org.gcube.dataanalysis.dataminer.poolmanager.service;
|
|
|
|
|
2017-05-12 17:32:14 +02:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
2017-05-17 18:16:25 +02:00
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
2017-05-12 17:32:14 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
|
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
|
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.ClusterBuilder;
|
2017-05-17 18:16:25 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.ServiceConfiguration;
|
2017-05-09 18:46:52 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
|
2017-04-05 17:14:18 +02:00
|
|
|
import org.tmatesoft.svn.core.SVNException;
|
2017-05-09 18:38:15 +02:00
|
|
|
|
|
|
|
public class DataminerPoolManager {
|
2017-03-03 19:10:02 +01:00
|
|
|
|
|
|
|
|
2017-05-09 18:46:52 +02:00
|
|
|
private SVNUpdater svnUpdater;
|
|
|
|
|
2017-05-15 18:44:37 +02:00
|
|
|
public DataminerPoolManager() {
|
2017-05-09 18:46:52 +02:00
|
|
|
try {
|
2017-05-15 18:44:37 +02:00
|
|
|
//TODO: read this from configuration
|
2017-05-17 18:16:25 +02:00
|
|
|
this.svnUpdater = new SVNUpdater(new ServiceConfiguration());
|
2017-05-09 18:46:52 +02:00
|
|
|
} catch (SVNException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-20 18:51:21 +02:00
|
|
|
public String stageAlgorithm(Algorithm algo,String targetVRE, String category, String algorithm_type/*,String env*/) throws IOException, InterruptedException {
|
2017-07-26 21:21:07 +02:00
|
|
|
|
2017-09-20 18:51:21 +02:00
|
|
|
Cluster stagingCluster = ClusterBuilder.getStagingDataminerCluster();
|
2017-05-09 18:38:15 +02:00
|
|
|
|
2017-07-26 21:21:07 +02:00
|
|
|
|
2017-07-06 18:44:03 +02:00
|
|
|
//Cluster rProtoCluster = ClusterBuilder.getRProtoCluster();
|
2017-05-12 17:32:14 +02:00
|
|
|
|
2017-09-20 18:51:21 +02:00
|
|
|
DMPMJob job = new StagingJob(this.svnUpdater, algo, stagingCluster, /*rProtoCluster,*/ targetVRE, category, algorithm_type/*,env*/);
|
2017-05-12 17:32:14 +02:00
|
|
|
String id = job.start();
|
|
|
|
return id;
|
2017-05-09 18:38:15 +02:00
|
|
|
}
|
|
|
|
|
2017-09-20 18:51:21 +02:00
|
|
|
public String publishAlgorithm(Algorithm algo, String targetVRE, String category, String algorithm_type/*, String env*/) throws IOException, InterruptedException {
|
2017-05-12 17:32:14 +02:00
|
|
|
|
2017-10-27 19:18:42 +02:00
|
|
|
Cluster prodCluster = ClusterBuilder.getProdDataminerCluster();
|
2017-05-12 17:32:14 +02:00
|
|
|
|
2017-10-27 19:18:42 +02:00
|
|
|
DMPMJob job = new ProductionPublishingJob(this.svnUpdater, algo, prodCluster, targetVRE, category, algorithm_type/*,env*/);
|
2017-05-12 17:32:14 +02:00
|
|
|
String id = job.start();
|
|
|
|
return id;
|
2017-05-09 18:38:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-05-12 17:32:14 +02:00
|
|
|
public String getLogById(String id) throws FileNotFoundException{
|
|
|
|
|
|
|
|
//TODO: load dir from configuration file
|
|
|
|
File path = new File(System.getProperty("user.home") + File.separator + "dataminer-pool-manager/jobs/"
|
|
|
|
+ id);
|
|
|
|
|
|
|
|
return new Scanner(path).useDelimiter("\\Z").next();
|
2017-05-09 18:38:15 +02:00
|
|
|
}
|
2017-07-13 18:13:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
public String getMonitorById(String id) throws FileNotFoundException{
|
|
|
|
|
|
|
|
//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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-29 16:06:46 +02:00
|
|
|
}
|