This commit is contained in:
Nunzio Andrea Galante 2017-04-03 12:35:03 +00:00
parent d167792fc9
commit 5144646ca3
7 changed files with 25 additions and 48 deletions

View File

@ -96,14 +96,14 @@ public class AnsibleWorker ***REMOVED***
public void apply() throws IOException ***REMOVED***
public void apply(PrintStream ps) throws IOException ***REMOVED***
***REMOVED*** TODO execute the playbook and return output
System.out.println(this.getWorkdir());
try ***REMOVED***
Process p = Runtime.getRuntime().exec("ansible-playbook -v -i " + this.getInventoryFile().getAbsolutePath() + " " + this.getPlaybookFile().getAbsolutePath());
inheritIO(p.getInputStream(), System.out);
inheritIO(p.getErrorStream(), System.err);
inheritIO(p.getInputStream(), ps);
inheritIO(p.getErrorStream(), ps);
***REMOVED*** catch (IOException e) ***REMOVED***
e.printStackTrace();

View File

@ -44,6 +44,8 @@ public class AnsibleBridge ***REMOVED***
public AnsibleBridge() ***REMOVED***
this(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
***REMOVED***this(System.getProperty("/home/gcube/dataminer-pool-manager"));
***REMOVED***
public AnsibleBridge(String root) ***REMOVED***
@ -196,17 +198,16 @@ public class AnsibleBridge ***REMOVED***
worker.setPlaybook(playbook);
***REMOVED*** execute and save log locally
PrintStream console = System.out;
***REMOVED***PrintStream console = System.out;
File path = new File(worker.getWorkdir() + File.separator + "logs");
path.mkdirs();
File n = new File(path + File.separator + worker.getWorkerId());
FileOutputStream fos = new FileOutputStream(n);
PrintStream ps = new PrintStream(fos);
System.setOut(ps);
System.setErr(ps);
***REMOVED***System.setErr(console);
worker.apply();
worker.apply(ps);
***REMOVED***System.setOut(console);
***REMOVED***worker.apply();
System.out.println("Log stored to to " + n.getAbsolutePath());

View File

@ -4,33 +4,10 @@ import java.util.Collection;
import java.util.Vector;
public class Algorithm extends AlgoResource ***REMOVED***
public class Algorithm ***REMOVED***
***REMOVED***
public int hashCode() ***REMOVED***
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
***REMOVED***
***REMOVED***
public boolean equals(Object obj) ***REMOVED***
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Algorithm other = (Algorithm) obj;
if (id == null) ***REMOVED***
if (other.id != null)
return false;
***REMOVED*** else if (!id.equals(other.id))
return false;
return true;
***REMOVED***
private String name;

View File

@ -54,6 +54,5 @@ public interface PoolManager ***REMOVED***
Set<Algorithm> getAlgoFromIs();
Algorithm getAlgoById(String id);
***REMOVED***

View File

@ -596,7 +596,7 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
***REMOVED***
public void addAlgToIs(Algorithm algo) ***REMOVED***
GenericResource a = new GenericResource();
a.newProfile().name(algo.getName()).type("DataMinerAlgorithms").description(algo.getDescription());
a.newProfile().name(algo.getName()).type("StatisticalManagerAlgorithm").description(algo.getDescription());
a.profile().newBody(this.getAlgoBody(algo));
try ***REMOVED***
publishScopedResource(a, Arrays.asList(new String[] ***REMOVED*** ScopeProvider.instance.get() ***REMOVED***));
@ -606,11 +606,11 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
***REMOVED***
private String getAlgoBody(Algorithm algo) ***REMOVED***
return "<id>" + algo.getId() + "</id>" + "\n" + "<category>" + algo.getCategory() + "</category>" + "\n"
return "<category>" + algo.getCategory() + "</category>" + "\n"
+ "<clazz>" + algo.getClazz() + "</clazz>" + "\n" + "<algorithmType>" + algo.getAlgorithmType()
+ "</algorithmType>" + "\n" + "<skipJava>" + algo.getSkipJava() + "</skipJava>" + "\n" + "<packageURL>"
+ algo.getPackageURL() + "</packageURL>" + "\n" + "<dependencies>"
+ algo.getDependencies().iterator().next().getName() + "</dependencies>";
+ algo.getDependencies() + "</dependencies>";
***REMOVED***
public void updateAlg(Algorithm algo) ***REMOVED***
@ -636,7 +636,7 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
private Algorithm convertAlgo(GenericResource a) ***REMOVED***
Algorithm out = new Algorithm();
out.setId(a.profile().body().getElementsByTagName("id").item(0).getTextContent());
***REMOVED***out.setId(a.profile().body().getElementsByTagName("id").item(0).getTextContent());
out.setAlgorithmType(a.profile().body().getElementsByTagName("algorithmType").item(0).getTextContent());
out.setCategory(a.profile().body().getElementsByTagName("category").item(0).getTextContent());
out.setClazz(a.profile().body().getElementsByTagName("clazz").item(0).getTextContent());
@ -655,14 +655,14 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
return out;
***REMOVED***
public Algorithm getAlgoById(String id) ***REMOVED***
for (Algorithm aa : this.getAlgoFromIs()) ***REMOVED***
if (aa.getId().equals(id)) ***REMOVED***
return aa;
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED***
***REMOVED*** public Algorithm getAlgoById(String id) ***REMOVED***
***REMOVED*** for (Algorithm aa : this.getAlgoFromIs()) ***REMOVED***
***REMOVED*** if (aa.getId().equals(id)) ***REMOVED***
***REMOVED*** return aa;
***REMOVED*** ***REMOVED***
***REMOVED*** ***REMOVED***
***REMOVED******REMOVED***
***REMOVED******REMOVED***
***REMOVED***
public Set<Algorithm> getAlgoFromIs() ***REMOVED***
@ -670,7 +670,7 @@ public class DataminerPoolManager implements PoolManager ***REMOVED***
Set<Algorithm> out = new HashSet<Algorithm>();
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'DataMinerAlgorithms'").setResult("$resource");
query.addCondition("$resource/Profile/SecondaryType/text() eq 'StatisticalManagerAlgorithm'").setResult("$resource");
DiscoveryClient<GenericResource> client = clientFor(GenericResource.class);
List<GenericResource> ds = client.submit(query);
for (GenericResource a : ds) ***REMOVED***

View File

@ -27,7 +27,7 @@ public class AnsibleWorkerTest ***REMOVED***
r.addTaskFile(tf);
worker.addRole(r);
worker.apply();
***REMOVED***worker.apply();
***REMOVED***
***REMOVED***

View File

@ -27,7 +27,7 @@ public class AnsibleWorkerTest ***REMOVED***
r.addTaskFile(tf);
worker.addRole(r);
worker.apply();
***REMOVED***worker.apply();
***REMOVED***
***REMOVED***