git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/dataminer-pool-manager@146518 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b35083da4f
commit
7958aeecfa
|
@ -96,14 +96,14 @@ public class AnsibleWorker {
|
|||
|
||||
|
||||
|
||||
public void apply() throws IOException {
|
||||
public void apply(PrintStream ps) throws IOException {
|
||||
// TODO execute the playbook and return output
|
||||
System.out.println(this.getWorkdir());
|
||||
try {
|
||||
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);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -44,6 +44,8 @@ public class AnsibleBridge {
|
|||
|
||||
public AnsibleBridge() {
|
||||
this(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
|
||||
//this(System.getProperty("/home/gcube/dataminer-pool-manager"));
|
||||
|
||||
}
|
||||
|
||||
public AnsibleBridge(String root) {
|
||||
|
@ -196,17 +198,16 @@ public class AnsibleBridge {
|
|||
worker.setPlaybook(playbook);
|
||||
|
||||
// execute and save log locally
|
||||
PrintStream console = System.out;
|
||||
//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);
|
||||
|
||||
//System.setErr(console);
|
||||
|
||||
worker.apply();
|
||||
worker.apply(ps);
|
||||
//System.setOut(console);
|
||||
//worker.apply();
|
||||
System.out.println("Log stored to to " + n.getAbsolutePath());
|
||||
|
|
|
@ -4,33 +4,10 @@ import java.util.Collection;
|
|||
import java.util.Vector;
|
||||
|
||||
|
||||
public class Algorithm extends AlgoResource {
|
||||
public class Algorithm {
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Algorithm other = (Algorithm) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
|
@ -54,6 +54,5 @@ public interface PoolManager {
|
|||
|
||||
Set<Algorithm> getAlgoFromIs();
|
||||
|
||||
Algorithm getAlgoById(String id);
|
||||
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ public class RestPoolManager implements PoolManager {
|
|||
@QueryParam("algorithmType") String algorithmType,
|
||||
@QueryParam("skipJava") String skipJava) throws IOException, InterruptedException {
|
||||
Algorithm algo= this.getAlgorithm(algorithm, null, hostname, name, description, category, algorithmType, skipJava);
|
||||
service.addAlgToIs(algo);
|
||||
//service.addAlgToIs(algo);
|
||||
return service.addAlgorithmToHost(algo, hostname);
|
||||
}
|
||||
|
||||
|
@ -224,8 +224,8 @@ public class RestPoolManager implements PoolManager {
|
|||
// TODO Auto-generated method stub
|
||||
LOGGER.debug("Adding algorithm =" + algorithm + " to VRE =" + vre);
|
||||
Algorithm algo = service.extractAlgorithm(algorithm);
|
||||
UUID uuid = UUID.randomUUID();
|
||||
algo.setId(name+"@"+uuid);
|
||||
// UUID uuid = UUID.randomUUID();
|
||||
// algo.setId(name+"@"+uuid);
|
||||
|
||||
if (algo.getCategory() == null){
|
||||
algo.setCategory(category);
|
||||
|
@ -240,8 +240,8 @@ public class RestPoolManager implements PoolManager {
|
|||
} else algo.setSkipJava(algo.getSkipJava());
|
||||
|
||||
if (algo.getName() == null){
|
||||
algo.setName(name+"@"+uuid);
|
||||
} else algo.setName(algo.getName()+"@"+uuid);
|
||||
algo.setName(name);
|
||||
} else algo.setName(algo.getName());
|
||||
|
||||
if (algo.getDescription() == null){
|
||||
algo.setDescription(description);;
|
||||
|
@ -328,7 +328,7 @@ public class RestPoolManager implements PoolManager {
|
|||
//null, null, "test", "transducerers", "N");
|
||||
|
||||
a.addAlgorithmToHost(
|
||||
"http://data.d4science.org/S2h1RHZGd0JpWnBjZk9qTytQTndqcDRLVHNrQUt6QjhHbWJQNStIS0N6Yz0",
|
||||
"http://data.d4science.org/YkErc2drUFRZUlV1ZkdqVnlhVW1mNjYvZ1ZiSHRGTUFHbWJQNStIS0N6Yz0",
|
||||
"dataminer1-devnext.d4science.org",
|
||||
"ICHTHYOP_MODEL_ONE_BY_ONE", null, "ICHTHYOP_MODEL", "transducerers", "N");
|
||||
}
|
||||
|
@ -380,12 +380,7 @@ public class RestPoolManager implements PoolManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Algorithm getAlgoById(String id) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -596,7 +596,7 @@ public class DataminerPoolManager implements PoolManager {
|
|||
@Override
|
||||
public void addAlgToIs(Algorithm algo) {
|
||||
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 {
|
||||
publishScopedResource(a, Arrays.asList(new String[] { ScopeProvider.instance.get() }));
|
||||
|
@ -606,11 +606,11 @@ public class DataminerPoolManager implements PoolManager {
|
|||
}
|
||||
|
||||
private String getAlgoBody(Algorithm algo) {
|
||||
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>";
|
||||
}
|
||||
|
||||
public void updateAlg(Algorithm algo) {
|
||||
|
@ -636,7 +636,7 @@ public class DataminerPoolManager implements PoolManager {
|
|||
private Algorithm convertAlgo(GenericResource a) {
|
||||
Algorithm out = new Algorithm();
|
||||
|
||||
out.setId(a.profile().body().getElementsByTagName("id").item(0).getTextContent());
|
||||
//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 {
|
|||
return out;
|
||||
}
|
||||
|
||||
public Algorithm getAlgoById(String id) {
|
||||
for (Algorithm aa : this.getAlgoFromIs()) {
|
||||
if (aa.getId().equals(id)) {
|
||||
return aa;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// public Algorithm getAlgoById(String id) {
|
||||
// for (Algorithm aa : this.getAlgoFromIs()) {
|
||||
// if (aa.getId().equals(id)) {
|
||||
// return aa;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Set<Algorithm> getAlgoFromIs() {
|
||||
|
@ -670,7 +670,7 @@ public class DataminerPoolManager implements PoolManager {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -27,7 +27,7 @@ public class AnsibleWorkerTest {
|
|||
r.addTaskFile(tf);
|
||||
worker.addRole(r);
|
||||
|
||||
worker.apply();
|
||||
//worker.apply();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class AnsibleWorkerTest {
|
|||
r.addTaskFile(tf);
|
||||
worker.addRole(r);
|
||||
|
||||
worker.apply();
|
||||
//worker.apply();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue