This commit is contained in:
Nunzio Andrea Galante 2017-04-03 12:35:03 +00:00
parent 2e168fc082
commit 64a7d37a20
8 changed files with 32 additions and 60 deletions

View File

@ -96,14 +96,14 @@ public class AnsibleWorker {
public void apply() throws IOException {
public void apply(PrintStream ps) throws IOException {
***REMOVED*** 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);
***REMOVED*** catch (IOException e) {
e.printStackTrace();

View File

@ -44,6 +44,8 @@ public class AnsibleBridge {
public AnsibleBridge() {
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) {
@ -196,17 +198,16 @@ public class AnsibleBridge {
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 {
public class Algorithm {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
***REMOVED***
@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;
***REMOVED*** else if (!id.equals(other.id))
return false;
return true;
***REMOVED***
private String name;

View File

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

View File

@ -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);
***REMOVED***service.addAlgToIs(algo);
return service.addAlgorithmToHost(algo, hostname);
***REMOVED***
@ -224,8 +224,8 @@ public class RestPoolManager implements PoolManager {
***REMOVED*** 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);
***REMOVED*** UUID uuid = UUID.randomUUID();
***REMOVED*** algo.setId(name+"@"+uuid);
if (algo.getCategory() == null){
algo.setCategory(category);
@ -240,8 +240,8 @@ public class RestPoolManager implements PoolManager {
***REMOVED*** else algo.setSkipJava(algo.getSkipJava());
if (algo.getName() == null){
algo.setName(name+"@"+uuid);
***REMOVED*** else algo.setName(algo.getName()+"@"+uuid);
algo.setName(name);
***REMOVED*** else algo.setName(algo.getName());
if (algo.getDescription() == null){
algo.setDescription(description);;
@ -328,7 +328,7 @@ public class RestPoolManager implements PoolManager {
***REMOVED***null, null, "test", "transducerers", "N");
a.addAlgorithmToHost(
"http:***REMOVED***data.d4science.org/S2h1RHZGd0JpWnBjZk9qTytQTndqcDRLVHNrQUt6QjhHbWJQNStIS0N6Yz0",
"http:***REMOVED***data.d4science.org/YkErc2drUFRZUlV1ZkdqVnlhVW1mNjYvZ1ZiSHRGTUFHbWJQNStIS0N6Yz0",
"dataminer1-devnext.d4science.org",
"ICHTHYOP_MODEL_ONE_BY_ONE", null, "ICHTHYOP_MODEL", "transducerers", "N");
***REMOVED***
@ -380,12 +380,7 @@ public class RestPoolManager implements PoolManager {
return null;
***REMOVED***
@Override
public Algorithm getAlgoById(String id) {
***REMOVED*** TODO Auto-generated method stub
return null;
***REMOVED***
***REMOVED***

View File

@ -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() ***REMOVED***));
@ -606,11 +606,11 @@ public class DataminerPoolManager implements PoolManager {
***REMOVED***
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>";
***REMOVED***
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());
***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***
***REMOVED***
public Algorithm getAlgoById(String id) {
for (Algorithm aa : this.getAlgoFromIs()) {
if (aa.getId().equals(id)) {
return aa;
***REMOVED***
***REMOVED***
return null;
***REMOVED***
***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*** return null;
***REMOVED******REMOVED***
@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) {

View File

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

View File

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