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;
|
2017-03-03 19:10:02 +01:00
|
|
|
***REMOVED***
|
2017-05-12 17:32:14 +02:00
|
|
|
import java.util.Scanner;
|
|
|
|
|
2017-03-29 16:06:46 +02:00
|
|
|
***REMOVED***
|
2017-05-12 17:32:14 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
|
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.ClusterBuilder;
|
2017-05-09 18:46:52 +02:00
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
|
2017-04-05 17:14:18 +02:00
|
|
|
***REMOVED***
|
2017-11-08 16:12:38 +01:00
|
|
|
***REMOVED***
|
|
|
|
***REMOVED***
|
|
|
|
|
2017-05-09 18:38:15 +02:00
|
|
|
|
|
|
|
public class DataminerPoolManager ***REMOVED***
|
2017-03-03 19:10:02 +01:00
|
|
|
|
2017-11-08 16:12:38 +01:00
|
|
|
private Logger logger;
|
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() ***REMOVED***
|
2017-11-08 16:12:38 +01:00
|
|
|
this.logger = LoggerFactory.getLogger(this.getClass());
|
2017-05-09 18:46:52 +02:00
|
|
|
try ***REMOVED***
|
2017-05-15 18:44:37 +02:00
|
|
|
***REMOVED***TODO: read this from configuration
|
2017-11-08 16:12:38 +01:00
|
|
|
this.svnUpdater = new SVNUpdater();
|
2017-05-09 18:46:52 +02:00
|
|
|
***REMOVED*** catch (SVNException e) ***REMOVED***
|
|
|
|
e.printStackTrace();
|
|
|
|
***REMOVED***
|
|
|
|
***REMOVED***
|
|
|
|
|
|
|
|
|
2017-11-08 16:12:38 +01:00
|
|
|
***REMOVED***Algorithm algo,String targetVRE, String category, String algorithm_type/*,String env*/) throws IOException, InterruptedException
|
|
|
|
***REMOVED***
|
|
|
|
this.logger.debug("Stage algorithm");
|
|
|
|
this.logger.debug("Algo "+algo);
|
|
|
|
this.logger.debug("Category "+category);
|
|
|
|
this.logger.debug("Algo type "+algorithm_type);
|
2017-09-20 18:51:21 +02:00
|
|
|
Cluster stagingCluster = ClusterBuilder.getStagingDataminerCluster();
|
2017-07-06 18:44:03 +02:00
|
|
|
***REMOVED***Cluster rProtoCluster = ClusterBuilder.getRProtoCluster();
|
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
|
|
|
***REMOVED***
|
|
|
|
|
2017-11-08 16:12:38 +01:00
|
|
|
***REMOVED***Algorithm algo, String targetVRE, String category, String algorithm_type/*, String env*/) throws IOException, InterruptedException
|
|
|
|
***REMOVED***
|
|
|
|
this.logger.debug("publish algorithm");
|
|
|
|
this.logger.debug("Algo "+algo);
|
|
|
|
this.logger.debug("Category "+category);
|
|
|
|
this.logger.debug("Algo type "+algorithm_type);
|
2017-10-27 19:18:42 +02:00
|
|
|
Cluster prodCluster = ClusterBuilder.getProdDataminerCluster();
|
|
|
|
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-03-03 19:10:02 +01:00
|
|
|
***REMOVED***
|
2017-03-29 16:06:46 +02:00
|
|
|
|
2017-05-10 11:31:28 +02:00
|
|
|
|
2017-05-12 17:32:14 +02:00
|
|
|
public String getLogById(String id) throws FileNotFoundException***REMOVED***
|
|
|
|
|
|
|
|
***REMOVED***TODO: load dir from configuration file
|
2017-11-08 16:12:38 +01:00
|
|
|
this.logger.debug("Getting log by id "+id);
|
2017-05-12 17:32:14 +02:00
|
|
|
File path = new File(System.getProperty("user.home") + File.separator + "dataminer-pool-manager/jobs/"
|
|
|
|
+ id);
|
|
|
|
|
2017-11-08 16:12:38 +01:00
|
|
|
Scanner scanner = new Scanner(path);
|
|
|
|
String response = scanner.useDelimiter("\\Z").next();
|
|
|
|
this.logger.debug("Response "+response);
|
|
|
|
scanner.close();
|
|
|
|
return response;
|
2017-03-03 19:10:02 +01:00
|
|
|
***REMOVED***
|
2017-07-13 18:13:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
public String getMonitorById(String id) throws FileNotFoundException***REMOVED***
|
|
|
|
|
2017-11-08 16:12:38 +01:00
|
|
|
this.logger.debug("Getting monitor by id "+id);
|
2017-07-13 18:13:18 +02:00
|
|
|
***REMOVED***TODO: load dir from configuration file
|
|
|
|
File path = new File(System.getProperty("user.home") + File.separator + "dataminer-pool-manager/jobs/"
|
|
|
|
+ id + "_exitStatus");
|
2017-11-08 16:12:38 +01:00
|
|
|
Scanner scanner = new Scanner(path);
|
|
|
|
String response= scanner.useDelimiter("\\Z").next();
|
|
|
|
this.logger.debug("Response "+response);
|
|
|
|
scanner.close();
|
|
|
|
return response;
|
2017-07-13 18:13:18 +02:00
|
|
|
***REMOVED***
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-29 16:06:46 +02:00
|
|
|
***REMOVED***
|