This commit is contained in:
Nunzio Andrea Galante 2017-05-09 15:10:03 +00:00
parent feebe094ab
commit 6315560648
5 changed files with 88 additions and 420 deletions

View File

@ -25,6 +25,7 @@ import org.gcube.dataanalysis.dataminer.poolmanager.ansiblebridge.AnsibleSeriali
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.AlgorithmSet;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Dependency;
***REMOVED***
***REMOVED***
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.wc.SVNFileUtil;
@ -118,7 +119,7 @@ public class AnsibleWorker ***REMOVED***
public void apply(AlgorithmSet as, PrintStream ps, boolean updateSVN)
public void apply(AlgorithmSet as, PrintStream ps, boolean test)
throws IOException, InterruptedException, SVNException ***REMOVED***
***REMOVED*** TODO execute the playbook and return output
System.out.println(this.getWorkdir());
@ -128,43 +129,70 @@ public class AnsibleWorker ***REMOVED***
inheritIO(p.getInputStream(), ps);
inheritIO(p.getErrorStream(), ps);
if (updateSVN) ***REMOVED***
int exitValue = p.waitFor();
if (exitValue == 0) ***REMOVED***
int exitValue = p.waitFor();
if (exitValue == 0) ***REMOVED***
if (test) ***REMOVED***
for (Algorithm algo : as.getAlgorithms()) ***REMOVED***
for (Dependency d : algo.getDependencies()) ***REMOVED***
if (d.getType().equals("os")) ***REMOVED***
List<String> ls = new LinkedList<String>();
ls.add(d.getName());
this.updateSVN("r_deb_pkgs.txt", ls);
this.updateSVN("test_r_deb_pkgs.txt", ls);
***REMOVED***
if (d.getType().equals("cran")) ***REMOVED***
List<String> ls = new LinkedList<String>();
ls.add(d.getName());
this.updateSVN("r_cran_pkgs.txt", ls);
this.updateSVN("test_r_cran_pkgs.txt", ls);
***REMOVED***
if (d.getType().equals("github")) ***REMOVED***
List<String> ls = new LinkedList<String>();
ls.add(d.getName());
this.updateSVN("r_github_pkgs.txt", ls);
this.updateSVN("test_r_github_pkgs.txt", ls);
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
else if(!test)***REMOVED***
for (Algorithm algo : as.getAlgorithms()) ***REMOVED***
for (Dependency d : algo.getDependencies()) ***REMOVED***
if (d.getType().equals("os")) ***REMOVED***
List<String> ls = new LinkedList<String>();
ls.add(d.getName());
this.updateSVN("r_deb_pkgs.txt", ls);
***REMOVED***
if (d.getType().equals("cran")) ***REMOVED***
List<String> ls = new LinkedList<String>();
ls.add(d.getName());
this.updateSVN("r_cran_pkgs.txt", ls);
***REMOVED***
if (d.getType().equals("github")) ***REMOVED***
List<String> ls = new LinkedList<String>();
ls.add(d.getName());
this.updateSVN("r_github_pkgs.txt", ls);
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
for (Algorithm algo : as.getAlgorithms()) ***REMOVED***
DataminerPoolManager a = new DataminerPoolManager();
a.addAlgToIs(algo);
***REMOVED***
***REMOVED***
***REMOVED*** catch (IOException e) ***REMOVED***
e.printStackTrace();
***REMOVED***
***REMOVED*** System.out.println("TODO: execute: ansible-playbook -v -i " +
***REMOVED*** this.getInventoryFile().getName() + " " +
***REMOVED*** this.getPlaybookFile().getName());
***REMOVED***

View File

@ -158,13 +158,13 @@ public class AnsibleBridge ***REMOVED***
***REMOVED***
***REMOVED***
public AnsibleWorker applyAlgorithmSetToCluster(AlgorithmSet as, Cluster cluster, boolean updateSVN) throws IOException, InterruptedException, SVNException ***REMOVED***
public AnsibleWorker applyAlgorithmSetToCluster(AlgorithmSet as, Cluster cluster, /*boolean updateSVN,*/ boolean test) throws IOException, InterruptedException, SVNException ***REMOVED***
return applyAlgorithmSetToCluster (as,cluster,UUID.randomUUID().toString(),updateSVN);
return applyAlgorithmSetToCluster (as,cluster,UUID.randomUUID().toString(),/*updateSVN,*/ test);
***REMOVED***
public AnsibleWorker applyAlgorithmSetToCluster(AlgorithmSet as, Cluster cluster,String uuid, boolean updateSVN) throws IOException, InterruptedException, SVNException ***REMOVED***
public AnsibleWorker applyAlgorithmSetToCluster(AlgorithmSet as, Cluster cluster,String uuid, /*boolean updateSVN,*/ boolean test) throws IOException, InterruptedException, SVNException ***REMOVED***
AnsibleWorker worker = new AnsibleWorker(new File(this.getWorkDir(), uuid));
@ -176,11 +176,14 @@ public class AnsibleBridge ***REMOVED***
algoRoles.add(r);
worker.addRole(r);
***REMOVED***
***REMOVED***to comment the for in case of just install algo
if(test)***REMOVED***
for (Dependency d : a.getDependencies()) ***REMOVED***
for (Role r : this.generateRoles(d)) ***REMOVED***
worker.addRole(r);
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED*** add static roles
@ -199,7 +202,9 @@ public class AnsibleBridge ***REMOVED***
***REMOVED*** generate the playbook
Playbook playbook = new Playbook();
playbook.setRemote_user("root");
if(test)***REMOVED***
playbook.setRemote_user("root");***REMOVED***
playbook.setRemote_user("gcube");
playbook.applyTo("universe");
for(Role r:algoRoles) ***REMOVED***
***REMOVED*** add only 'add' roles
@ -220,7 +225,7 @@ public class AnsibleBridge ***REMOVED***
***REMOVED***System.setErr(console);
worker.apply(as,ps,updateSVN);
worker.apply(as,ps,test);
***REMOVED***System.setOut(console);
***REMOVED***worker.apply();
System.out.println("Log stored to to " + n.getAbsolutePath());

View File

@ -72,6 +72,7 @@ public class ISClient ***REMOVED***
***REMOVED***
return h;
***REMOVED***
***REMOVED*** return the HProxy hostname in the VRE
public static String getHProxy() ***REMOVED***

View File

@ -35,12 +35,13 @@
***REMOVED***
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.AlgorithmSet;
***REMOVED***
public interface PoolManager ***REMOVED***
String addAlgorithmToVRE(Algorithm algo, String vre, boolean svn ) throws IOException, InterruptedException;
String addAlgorithmToHost(Algorithm algo, String host, boolean svn) throws IOException, InterruptedException;
String addAlgorithmToVRE(Algorithm algo, String vre, boolean test ) throws IOException, InterruptedException;
String addAlgorithmToHost(Algorithm algo, String host,boolean test) throws IOException, InterruptedException;
Algorithm extractAlgorithm(String url) throws IOException;
@ -57,5 +58,5 @@ public interface PoolManager ***REMOVED***
Set<Algorithm> getAlgoFromIs();
List<String> updateSVN(String file, List<String> ldep) throws SVNException, IOException;
***REMOVED***

View File

@ -1,265 +1,3 @@
***REMOVED***package org.gcube.dataanalysis.dataminer.poolmanager.service;
***REMOVED***
***REMOVED***import java.io.BufferedReader;
***REMOVED***import java.io.File;
***REMOVED******REMOVED***
***REMOVED***import java.io.InputStreamReader;
***REMOVED******REMOVED***
***REMOVED******REMOVED***
***REMOVED***import java.net.URLConnection;
***REMOVED******REMOVED***
***REMOVED***import java.util.UUID;
***REMOVED***
***REMOVED***import org.gcube.dataanalysis.dataminer.poolmanager.ansiblebridge.AnsibleBridge;
***REMOVED***import org.gcube.dataanalysis.dataminer.poolmanager.clients.ISClient;
***REMOVED******REMOVED***
***REMOVED***import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.AlgorithmSet;
***REMOVED***import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
***REMOVED***import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Host;
***REMOVED***import org.gcube.dataanalysis.dataminer.poolmanager.process.AlgorithmPackageParser;
***REMOVED***import org.gcube.dataanalysis.dataminer.poolmanager.rest.PoolManager;
***REMOVED******REMOVED***
***REMOVED******REMOVED***
***REMOVED***
***REMOVED***public class DataminerPoolManager implements PoolManager ***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED*** private static final Logger LOGGER = LoggerFactory.getLogger(DataminerPoolManager.class);
***REMOVED***
***REMOVED***
***REMOVED******REMOVED*** static Collection<Algorithm> algorithms;
***REMOVED******REMOVED***
***REMOVED******REMOVED*** static Collection<AlgorithmSet> sets;
***REMOVED******REMOVED***
***REMOVED******REMOVED*** static ***REMOVED***
***REMOVED******REMOVED*** algorithms = new Vector<>();
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED***
***REMOVED******REMOVED*** public DataminerPoolManager() ***REMOVED***
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED***
***REMOVED******REMOVED*** /**
***REMOVED******REMOVED*** * Add a new algorithm to the set of known ones. No further action is expected
***REMOVED******REMOVED*** * on the pool.
***REMOVED******REMOVED*** */
***REMOVED******REMOVED*** public void publishAlgorithm(Algorithm algorithm) ***REMOVED***
***REMOVED******REMOVED*** algorithms.add(algorithm);
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED***
***REMOVED******REMOVED*** /**
***REMOVED******REMOVED*** * Re-deploy the given algorithm wherever it's installed
***REMOVED******REMOVED*** *
***REMOVED******REMOVED*** * @param algorithm
***REMOVED******REMOVED*** */
***REMOVED******REMOVED*** /*
***REMOVED******REMOVED*** * public void updateAlgorithm(Algorithm algorithm) ***REMOVED*** ***REMOVED*** TODO implement this ***REMOVED***
***REMOVED******REMOVED*** */
***REMOVED******REMOVED***
***REMOVED******REMOVED*** /**
***REMOVED******REMOVED*** * Add the give algorithm to the given set
***REMOVED******REMOVED*** *
***REMOVED******REMOVED*** * @param algorithmId
***REMOVED******REMOVED*** * @param setId
***REMOVED******REMOVED*** */
***REMOVED******REMOVED*** public void addAlgorithmToSet(String algorithmName, String setName) ***REMOVED***
***REMOVED******REMOVED*** AlgorithmSet set = this.getAlgorithmSet(setName);
***REMOVED******REMOVED*** Algorithm algorithm = this.getAlgorithm(algorithmName);
***REMOVED******REMOVED*** if (set != null && algorithm != null) ***REMOVED***
***REMOVED******REMOVED*** set.addAlgorithm(algorithm);
***REMOVED******REMOVED*** this.updateClusters();
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED***
***REMOVED******REMOVED*** /**
***REMOVED******REMOVED*** * Apply the given set of algorithms to the given cluster
***REMOVED******REMOVED*** *
***REMOVED******REMOVED*** * @param setId
***REMOVED******REMOVED*** * @param clusterId
***REMOVED******REMOVED*** */
***REMOVED******REMOVED*** public void applyAlgorithmSetToCluster(String setName, String clusterName) ***REMOVED***
***REMOVED******REMOVED*** AlgorithmSet set = this.getAlgorithmSet(setName);
***REMOVED******REMOVED*** Cluster cluster = new ISClient().getCluster(clusterName);
***REMOVED******REMOVED*** if (set != null && cluster != null) ***REMOVED***
***REMOVED******REMOVED*** cluster.addAlgorithmSet(set);
***REMOVED******REMOVED*** this.updateClusters();
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED***
***REMOVED******REMOVED*** private AlgorithmSet getAlgorithmSet(String name) ***REMOVED***
***REMOVED******REMOVED*** for (AlgorithmSet set : sets) ***REMOVED***
***REMOVED******REMOVED*** if (name.equals(set.getName())) ***REMOVED***
***REMOVED******REMOVED*** return set;
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** return null;
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED***
***REMOVED******REMOVED*** private Algorithm getAlgorithm(String name) ***REMOVED***
***REMOVED******REMOVED*** for (Algorithm a : algorithms) ***REMOVED***
***REMOVED******REMOVED*** if (name.equals(a.getName())) ***REMOVED***
***REMOVED******REMOVED*** return a;
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** return null;
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED******REMOVED***
***REMOVED******REMOVED*** public void getLogId(final Algorithm algorithm, final String vre) ***REMOVED***
***REMOVED******REMOVED*** new Thread() ***REMOVED***
***REMOVED******REMOVED*** public void run() ***REMOVED***
***REMOVED******REMOVED*** while (true) ***REMOVED***
***REMOVED******REMOVED*** try ***REMOVED***
***REMOVED******REMOVED*** addAlgorithmToVRE(algorithm, vre);
***REMOVED******REMOVED*** ***REMOVED*** catch (Exception e) ***REMOVED***
***REMOVED******REMOVED*** ***REMOVED***log here
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** ***REMOVED***.start();
***REMOVED******REMOVED******REMOVED***
***REMOVED******REMOVED***
***REMOVED******REMOVED***
***REMOVED***
***REMOVED******REMOVED*** public String getLogId()***REMOVED***
***REMOVED******REMOVED*** PrintStream console = System.out;
***REMOVED******REMOVED*** File path = new File(worker.getWorkdir() + File.separator + "logs");
***REMOVED******REMOVED*** path.mkdirs();
***REMOVED******REMOVED*** File n = new File(path + File.separator + worker.getWorkerId());
***REMOVED******REMOVED*** FileOutputStream fos = new FileOutputStream(n);
***REMOVED******REMOVED*** PrintStream ps = new PrintStream(fos);
***REMOVED******REMOVED*** System.setOut(ps);
***REMOVED******REMOVED*** worker.apply();
***REMOVED******REMOVED*** System.setOut(console);
***REMOVED******REMOVED*** worker.apply();
***REMOVED******REMOVED*** System.out.println("Log stored to to " + n.getAbsolutePath());
***REMOVED******REMOVED******REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED******REMOVED*** public String getLogById(String id) throws IOException ***REMOVED***
***REMOVED******REMOVED*** String strLine = null;
***REMOVED******REMOVED*** try***REMOVED***
***REMOVED******REMOVED*** FileInputStream fstream = new FileInputStream("/tmp/dataminer-pool-manager/work/"+id+"/logs/"+id);
***REMOVED******REMOVED*** BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
***REMOVED******REMOVED*** /* read log line by line */
***REMOVED******REMOVED*** while ((strLine = br.readLine()) != null) ***REMOVED***
***REMOVED******REMOVED*** /* parse strLine to obtain what you want */
***REMOVED******REMOVED*** System.out.println (strLine);
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** br.close();
***REMOVED******REMOVED*** ***REMOVED*** catch (Exception e) ***REMOVED***
***REMOVED******REMOVED*** System.err.println("Error: " + e.getMessage());
***REMOVED******REMOVED*** ***REMOVED***
***REMOVED******REMOVED*** return strLine;
***REMOVED******REMOVED******REMOVED***
***REMOVED***
***REMOVED***
***REMOVED*** public String getScriptFromURL(URL url) throws IOException ***REMOVED***
***REMOVED*** if (url == null) ***REMOVED***
***REMOVED*** return null;
***REMOVED*** ***REMOVED***
***REMOVED*** URLConnection yc = url.openConnection();
***REMOVED*** BufferedReader input = new BufferedReader(new InputStreamReader(
***REMOVED*** yc.getInputStream()));
***REMOVED*** String line;
***REMOVED*** StringBuffer buffer = new StringBuffer();
***REMOVED*** while ((line = input.readLine()) != null) ***REMOVED***
***REMOVED*** buffer.append(line + "\n");
***REMOVED*** ***REMOVED***
***REMOVED*** String bufferScript = buffer.substring(0, buffer.length());
***REMOVED*** input.close();
***REMOVED*** return bufferScript;
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED*** /**
***REMOVED*** * Publish the given algorithm in the given VRE
***REMOVED*** *
***REMOVED*** * @param algorithmName
***REMOVED*** * @param vre
***REMOVED*** *
***REMOVED*** */
***REMOVED*** public String addAlgorithmToVRE(Algorithm algorithm, final String vre) throws IOException ***REMOVED***
***REMOVED*** ***REMOVED*** create a fake algorithm set
***REMOVED*** final AlgorithmSet algoSet = new AlgorithmSet();
***REMOVED*** algoSet.setName("fake");
***REMOVED*** algoSet.addAlgorithm(algorithm);
***REMOVED*** final String uuid = UUID.randomUUID().toString();
***REMOVED***
***REMOVED*** new Thread(new Runnable() ***REMOVED***
***REMOVED******REMOVED***
***REMOVED*** public void run() ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** try ***REMOVED***
***REMOVED*** addAlgorithmsToVRE(algoSet, vre, uuid);
***REMOVED*** ***REMOVED*** catch (IOException e) ***REMOVED***
***REMOVED*** ***REMOVED*** TODO Auto-generated catch block
***REMOVED*** e.printStackTrace();
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED******REMOVED***).start();
***REMOVED*** ***REMOVED***this line will execute immediately, not waiting for your task to complete
***REMOVED*** System.out.println(uuid);
***REMOVED*** return uuid;
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED*** public URL getURLfromWorkerLog(String a) throws MalformedURLException, UnknownHostException***REMOVED***
***REMOVED***
***REMOVED*** File path = new File(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager/work/"+a+File.separator+"logs");
***REMOVED*** path.mkdirs();
***REMOVED*** File n = new File(path + File.separator +a);
***REMOVED*** ***REMOVED***String addr = InetAddress.getLocalHost().getHostAddress();
***REMOVED***
***REMOVED*** return new File(n.getPath()).toURI().toURL();
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED*** public String addAlgorithmsToVRE(AlgorithmSet algorithms, String vre, String uuid) throws IOException ***REMOVED***
***REMOVED***
***REMOVED*** ***REMOVED*** create the cluster (dataminers in the vre)
***REMOVED*** Cluster cluster = new Cluster();
***REMOVED*** for(Host h:new ISClient().listDataminersInVRE()) ***REMOVED***
***REMOVED*** cluster.addHost(h);
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** ***REMOVED*** apply the changes
***REMOVED*** AnsibleBridge a = new AnsibleBridge();
***REMOVED*** return a.applyAlgorithmSetToCluster(algorithms, cluster,uuid).getWorkerId();
***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** public Algorithm extractAlgorithm(String url) throws IOException ***REMOVED***
***REMOVED*** return new AlgorithmPackageParser().parsePackage(url);
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***@Override
***REMOVED***public void getLogId(Algorithm algo, String vre) ***REMOVED***
***REMOVED*** ***REMOVED*** TODO Auto-generated method stub
***REMOVED***
***REMOVED******REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***@Override
***REMOVED***public String getLogById(String logId) throws IOException ***REMOVED***
***REMOVED*** ***REMOVED*** TODO Auto-generated method stub
***REMOVED*** return null;
***REMOVED******REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED******REMOVED***
package org.gcube.dataanalysis.dataminer.poolmanager.service;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
@ -325,134 +63,7 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
private static final Logger LOGGER = LoggerFactory.getLogger(DataminerPoolManager.class);
***REMOVED*** static Collection<Algorithm> algorithms;
***REMOVED***
***REMOVED*** static Collection<AlgorithmSet> sets;
***REMOVED***
***REMOVED*** static ***REMOVED***
***REMOVED*** algorithms = new Vector<>();
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** public DataminerPoolManager() ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** /**
***REMOVED*** * Add a new algorithm to the set of known ones. No further action is
***REMOVED*** expected
***REMOVED*** * on the pool.
***REMOVED*** */
***REMOVED*** public void publishAlgorithm(Algorithm algorithm) ***REMOVED***
***REMOVED*** algorithms.add(algorithm);
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** /**
***REMOVED*** * Re-deploy the given algorithm wherever it's installed
***REMOVED*** *
***REMOVED*** * @param algorithm
***REMOVED*** */
***REMOVED*** /*
***REMOVED*** * public void updateAlgorithm(Algorithm algorithm) ***REMOVED*** ***REMOVED*** TODO implement
***REMOVED*** this ***REMOVED***
***REMOVED*** */
***REMOVED***
***REMOVED*** /**
***REMOVED*** * Add the give algorithm to the given set
***REMOVED*** *
***REMOVED*** * @param algorithmId
***REMOVED*** * @param setId
***REMOVED*** */
***REMOVED*** public void addAlgorithmToSet(String algorithmName, String setName) ***REMOVED***
***REMOVED*** AlgorithmSet set = this.getAlgorithmSet(setName);
***REMOVED*** Algorithm algorithm = this.getAlgorithm(algorithmName);
***REMOVED*** if (set != null && algorithm != null) ***REMOVED***
***REMOVED*** set.addAlgorithm(algorithm);
***REMOVED*** this.updateClusters();
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** /**
***REMOVED*** * Apply the given set of algorithms to the given cluster
***REMOVED*** *
***REMOVED*** * @param setId
***REMOVED*** * @param clusterId
***REMOVED*** */
***REMOVED*** public void applyAlgorithmSetToCluster(String setName, String
***REMOVED*** clusterName) ***REMOVED***
***REMOVED*** AlgorithmSet set = this.getAlgorithmSet(setName);
***REMOVED*** Cluster cluster = new ISClient().getCluster(clusterName);
***REMOVED*** if (set != null && cluster != null) ***REMOVED***
***REMOVED*** cluster.addAlgorithmSet(set);
***REMOVED*** this.updateClusters();
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** private AlgorithmSet getAlgorithmSet(String name) ***REMOVED***
***REMOVED*** for (AlgorithmSet set : sets) ***REMOVED***
***REMOVED*** if (name.equals(set.getName())) ***REMOVED***
***REMOVED*** return set;
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** return null;
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** private Algorithm getAlgorithm(String name) ***REMOVED***
***REMOVED*** for (Algorithm a : algorithms) ***REMOVED***
***REMOVED*** if (name.equals(a.getName())) ***REMOVED***
***REMOVED*** return a;
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** return null;
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED*** public void getLogId(final Algorithm algorithm, final String vre) ***REMOVED***
***REMOVED*** new Thread() ***REMOVED***
***REMOVED*** public void run() ***REMOVED***
***REMOVED*** while (true) ***REMOVED***
***REMOVED*** try ***REMOVED***
***REMOVED*** addAlgorithmToVRE(algorithm, vre);
***REMOVED*** ***REMOVED*** catch (Exception e) ***REMOVED***
***REMOVED*** ***REMOVED***log here
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***.start();
***REMOVED*** ***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED*** public String getLogId()***REMOVED***
***REMOVED*** PrintStream console = System.out;
***REMOVED*** File path = new File(worker.getWorkdir() + File.separator + "logs");
***REMOVED*** path.mkdirs();
***REMOVED*** File n = new File(path + File.separator + worker.getWorkerId());
***REMOVED*** FileOutputStream fos = new FileOutputStream(n);
***REMOVED*** PrintStream ps = new PrintStream(fos);
***REMOVED*** System.setOut(ps);
***REMOVED*** worker.apply();
***REMOVED*** System.setOut(console);
***REMOVED*** worker.apply();
***REMOVED*** System.out.println("Log stored to to " + n.getAbsolutePath());
***REMOVED*** ***REMOVED***
***REMOVED*** public String getLogById(String id) throws IOException ***REMOVED***
***REMOVED*** String strLine = null;
***REMOVED*** try***REMOVED***
***REMOVED*** FileInputStream fstream = new
***REMOVED*** FileInputStream("/tmp/dataminer-pool-manager/work/"+id+"/logs/"+id);
***REMOVED*** BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
***REMOVED*** /* read log line by line */
***REMOVED*** while ((strLine = br.readLine()) != null) ***REMOVED***
***REMOVED*** /* parse strLine to obtain what you want */
***REMOVED*** System.out.println (strLine);
***REMOVED*** ***REMOVED***
***REMOVED*** br.close();
***REMOVED*** ***REMOVED*** catch (Exception e) ***REMOVED***
***REMOVED*** System.err.println("Error: " + e.getMessage());
***REMOVED*** ***REMOVED***
***REMOVED*** return strLine;
***REMOVED*** ***REMOVED***
public String getScriptFromURL(URL url) throws IOException ***REMOVED***
if (url == null) ***REMOVED***
***REMOVED***
@ -476,7 +87,7 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
* @param vre
*
***REMOVED***
public String addAlgorithmToVRE(Algorithm algorithm, final String vre, final boolean updateSVN) throws IOException ***REMOVED***
public String addAlgorithmToVRE(Algorithm algorithm, final String vre, /*final boolean updateSVN*/ final boolean test) throws IOException ***REMOVED***
***REMOVED*** create a fake algorithm set
final AlgorithmSet algoSet = new AlgorithmSet();
algoSet.setName("fake");
@ -489,7 +100,7 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
***REMOVED***
try ***REMOVED***
try ***REMOVED***
addAlgorithmsToVRE(algoSet, vre, uuid, updateSVN);
addAlgorithmsToVRE(algoSet, vre, uuid, /*updateSVN*/test);
***REMOVED*** catch (SVNException e) ***REMOVED***
***REMOVED*** TODO Auto-generated catch block
e.printStackTrace();
@ -503,13 +114,13 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***).start();
***REMOVED*** this line will execute immediately, not waiting for your task to
***REMOVED*** this line will execute immediately, not waiting for task to
***REMOVED*** complete
System.out.println(uuid);
return uuid;
***REMOVED***
public String addAlgorithmToHost(Algorithm algorithm, final String hostname, final boolean updateSVN) throws IOException ***REMOVED***
public String addAlgorithmToHost(Algorithm algorithm, final String hostname, /*final boolean updateSVN*/ final boolean test) throws IOException ***REMOVED***
***REMOVED*** create a fake algorithm set
final AlgorithmSet algoSet = new AlgorithmSet();
algoSet.setName("fake");
@ -521,7 +132,8 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
public void run() ***REMOVED***
***REMOVED***
try ***REMOVED***
addAlgorithmsToHost(algoSet, hostname, uuid, updateSVN);
if(test)***REMOVED***
addAlgorithmsToStagingHost(algoSet, hostname, uuid, /*updateSVN,*/test);***REMOVED***
***REMOVED*** catch (IOException e) ***REMOVED***
***REMOVED*** TODO Auto-generated catch block
e.printStackTrace();
@ -551,7 +163,7 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
return new File(n.getPath()).toURI().toURL();
***REMOVED***
public String addAlgorithmsToVRE(AlgorithmSet algorithms, String vre, String uuid, boolean updateSVN) throws IOException, InterruptedException, SVNException ***REMOVED***
public String addAlgorithmsToVRE(AlgorithmSet algorithms, String vre, String uuid, /*boolean updateSVN,*/ boolean test) throws IOException, InterruptedException, SVNException ***REMOVED***
***REMOVED*** create the cluster (dataminers in the vre)
Cluster cluster = new Cluster();
@ -562,11 +174,11 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
***REMOVED*** apply the changes
AnsibleBridge a = new AnsibleBridge();
return a.applyAlgorithmSetToCluster(algorithms, cluster, uuid, updateSVN).getWorkerId();
return a.applyAlgorithmSetToCluster(algorithms, cluster, uuid, /*updateSVN,*/ test).getWorkerId();
***REMOVED***
public String addAlgorithmsToHost(AlgorithmSet algorithms, String hostname, String uuid, boolean updateSVN)
public String addAlgorithmsToHost(AlgorithmSet algorithms, String hostname, String uuid, /*boolean updateSVN,*/boolean test)
throws IOException, InterruptedException, SVNException ***REMOVED***
***REMOVED*** create the cluster (dataminers in the vre)
@ -581,11 +193,23 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED*** apply the changes
AnsibleBridge a = new AnsibleBridge();
return a.applyAlgorithmSetToCluster(algorithms, cluster, uuid, updateSVN).getWorkerId();
return a.applyAlgorithmSetToCluster(algorithms, cluster, uuid, /*updateSVN,*/test).getWorkerId();
***REMOVED***
public String addAlgorithmsToStagingHost(AlgorithmSet algorithms, String hostname, String uuid, /*boolean updateSVN,*/boolean test)
throws IOException, InterruptedException, SVNException ***REMOVED***
Cluster cluster = new Cluster();
Host h = new Host();
h.setName(hostname);
cluster.addHost(h);
AnsibleBridge a = new AnsibleBridge();
return a.applyAlgorithmSetToCluster(algorithms, cluster, uuid, /*updateSVN,*/test).getWorkerId();
***REMOVED***
public Algorithm extractAlgorithm(String url) throws IOException ***REMOVED***
return new AlgorithmPackageParser().parsePackage(url);
@ -726,4 +350,13 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***