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
2e168fc082
commit
64a7d37a20
|
@ -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
|
***REMOVED*** TODO execute the playbook and return output
|
||||||
System.out.println(this.getWorkdir());
|
System.out.println(this.getWorkdir());
|
||||||
try {
|
try {
|
||||||
Process p = Runtime.getRuntime().exec("ansible-playbook -v -i " + this.getInventoryFile().getAbsolutePath() + " " + this.getPlaybookFile().getAbsolutePath());
|
Process p = Runtime.getRuntime().exec("ansible-playbook -v -i " + this.getInventoryFile().getAbsolutePath() + " " + this.getPlaybookFile().getAbsolutePath());
|
||||||
|
|
||||||
inheritIO(p.getInputStream(), System.out);
|
inheritIO(p.getInputStream(), ps);
|
||||||
inheritIO(p.getErrorStream(), System.err);
|
inheritIO(p.getErrorStream(), ps);
|
||||||
|
|
||||||
***REMOVED*** catch (IOException e) {
|
***REMOVED*** catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -44,6 +44,8 @@ public class AnsibleBridge {
|
||||||
|
|
||||||
public AnsibleBridge() {
|
public AnsibleBridge() {
|
||||||
this(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
|
this(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
|
||||||
|
***REMOVED***this(System.getProperty("/home/gcube/dataminer-pool-manager"));
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
public AnsibleBridge(String root) {
|
public AnsibleBridge(String root) {
|
||||||
|
@ -196,17 +198,16 @@ public class AnsibleBridge {
|
||||||
worker.setPlaybook(playbook);
|
worker.setPlaybook(playbook);
|
||||||
|
|
||||||
***REMOVED*** execute and save log locally
|
***REMOVED*** execute and save log locally
|
||||||
PrintStream console = System.out;
|
***REMOVED***PrintStream console = System.out;
|
||||||
File path = new File(worker.getWorkdir() + File.separator + "logs");
|
File path = new File(worker.getWorkdir() + File.separator + "logs");
|
||||||
path.mkdirs();
|
path.mkdirs();
|
||||||
File n = new File(path + File.separator + worker.getWorkerId());
|
File n = new File(path + File.separator + worker.getWorkerId());
|
||||||
FileOutputStream fos = new FileOutputStream(n);
|
FileOutputStream fos = new FileOutputStream(n);
|
||||||
PrintStream ps = new PrintStream(fos);
|
PrintStream ps = new PrintStream(fos);
|
||||||
System.setOut(ps);
|
|
||||||
System.setErr(ps);
|
|
||||||
***REMOVED***System.setErr(console);
|
***REMOVED***System.setErr(console);
|
||||||
|
|
||||||
worker.apply();
|
worker.apply(ps);
|
||||||
***REMOVED***System.setOut(console);
|
***REMOVED***System.setOut(console);
|
||||||
***REMOVED***worker.apply();
|
***REMOVED***worker.apply();
|
||||||
System.out.println("Log stored to to " + n.getAbsolutePath());
|
System.out.println("Log stored to to " + n.getAbsolutePath());
|
||||||
|
|
|
@ -4,33 +4,10 @@ import java.util.Collection;
|
||||||
import java.util.Vector;
|
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;
|
private String name;
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,5 @@ public interface PoolManager {
|
||||||
|
|
||||||
Set<Algorithm> getAlgoFromIs();
|
Set<Algorithm> getAlgoFromIs();
|
||||||
|
|
||||||
Algorithm getAlgoById(String id);
|
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class RestPoolManager implements PoolManager {
|
||||||
@QueryParam("algorithmType") String algorithmType,
|
@QueryParam("algorithmType") String algorithmType,
|
||||||
@QueryParam("skipJava") String skipJava) throws IOException, InterruptedException {
|
@QueryParam("skipJava") String skipJava) throws IOException, InterruptedException {
|
||||||
Algorithm algo= this.getAlgorithm(algorithm, null, hostname, name, description, category, algorithmType, skipJava);
|
Algorithm algo= this.getAlgorithm(algorithm, null, hostname, name, description, category, algorithmType, skipJava);
|
||||||
service.addAlgToIs(algo);
|
***REMOVED***service.addAlgToIs(algo);
|
||||||
return service.addAlgorithmToHost(algo, hostname);
|
return service.addAlgorithmToHost(algo, hostname);
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
|
@ -224,8 +224,8 @@ public class RestPoolManager implements PoolManager {
|
||||||
***REMOVED*** TODO Auto-generated method stub
|
***REMOVED*** TODO Auto-generated method stub
|
||||||
LOGGER.debug("Adding algorithm =" + algorithm + " to VRE =" + vre);
|
LOGGER.debug("Adding algorithm =" + algorithm + " to VRE =" + vre);
|
||||||
Algorithm algo = service.extractAlgorithm(algorithm);
|
Algorithm algo = service.extractAlgorithm(algorithm);
|
||||||
UUID uuid = UUID.randomUUID();
|
***REMOVED*** UUID uuid = UUID.randomUUID();
|
||||||
algo.setId(name+"@"+uuid);
|
***REMOVED*** algo.setId(name+"@"+uuid);
|
||||||
|
|
||||||
if (algo.getCategory() == null){
|
if (algo.getCategory() == null){
|
||||||
algo.setCategory(category);
|
algo.setCategory(category);
|
||||||
|
@ -240,8 +240,8 @@ public class RestPoolManager implements PoolManager {
|
||||||
***REMOVED*** else algo.setSkipJava(algo.getSkipJava());
|
***REMOVED*** else algo.setSkipJava(algo.getSkipJava());
|
||||||
|
|
||||||
if (algo.getName() == null){
|
if (algo.getName() == null){
|
||||||
algo.setName(name+"@"+uuid);
|
algo.setName(name);
|
||||||
***REMOVED*** else algo.setName(algo.getName()+"@"+uuid);
|
***REMOVED*** else algo.setName(algo.getName());
|
||||||
|
|
||||||
if (algo.getDescription() == null){
|
if (algo.getDescription() == null){
|
||||||
algo.setDescription(description);;
|
algo.setDescription(description);;
|
||||||
|
@ -328,7 +328,7 @@ public class RestPoolManager implements PoolManager {
|
||||||
***REMOVED***null, null, "test", "transducerers", "N");
|
***REMOVED***null, null, "test", "transducerers", "N");
|
||||||
|
|
||||||
a.addAlgorithmToHost(
|
a.addAlgorithmToHost(
|
||||||
"http:***REMOVED***data.d4science.org/S2h1RHZGd0JpWnBjZk9qTytQTndqcDRLVHNrQUt6QjhHbWJQNStIS0N6Yz0",
|
"http:***REMOVED***data.d4science.org/YkErc2drUFRZUlV1ZkdqVnlhVW1mNjYvZ1ZiSHRGTUFHbWJQNStIS0N6Yz0",
|
||||||
"dataminer1-devnext.d4science.org",
|
"dataminer1-devnext.d4science.org",
|
||||||
"ICHTHYOP_MODEL_ONE_BY_ONE", null, "ICHTHYOP_MODEL", "transducerers", "N");
|
"ICHTHYOP_MODEL_ONE_BY_ONE", null, "ICHTHYOP_MODEL", "transducerers", "N");
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
@ -380,11 +380,6 @@ public class RestPoolManager implements PoolManager {
|
||||||
return null;
|
return null;
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
@Override
|
|
||||||
public Algorithm getAlgoById(String id) {
|
|
||||||
***REMOVED*** TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
***REMOVED***
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -596,7 +596,7 @@ public class DataminerPoolManager implements PoolManager {
|
||||||
@Override
|
@Override
|
||||||
public void addAlgToIs(Algorithm algo) {
|
public void addAlgToIs(Algorithm algo) {
|
||||||
GenericResource a = new GenericResource();
|
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));
|
a.profile().newBody(this.getAlgoBody(algo));
|
||||||
try {
|
try {
|
||||||
publishScopedResource(a, Arrays.asList(new String[] { ScopeProvider.instance.get() ***REMOVED***));
|
publishScopedResource(a, Arrays.asList(new String[] { ScopeProvider.instance.get() ***REMOVED***));
|
||||||
|
@ -606,11 +606,11 @@ public class DataminerPoolManager implements PoolManager {
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
private String getAlgoBody(Algorithm algo) {
|
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()
|
+ "<clazz>" + algo.getClazz() + "</clazz>" + "\n" + "<algorithmType>" + algo.getAlgorithmType()
|
||||||
+ "</algorithmType>" + "\n" + "<skipJava>" + algo.getSkipJava() + "</skipJava>" + "\n" + "<packageURL>"
|
+ "</algorithmType>" + "\n" + "<skipJava>" + algo.getSkipJava() + "</skipJava>" + "\n" + "<packageURL>"
|
||||||
+ algo.getPackageURL() + "</packageURL>" + "\n" + "<dependencies>"
|
+ algo.getPackageURL() + "</packageURL>" + "\n" + "<dependencies>"
|
||||||
+ algo.getDependencies().iterator().next().getName() + "</dependencies>";
|
+ algo.getDependencies() + "</dependencies>";
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
public void updateAlg(Algorithm algo) {
|
public void updateAlg(Algorithm algo) {
|
||||||
|
@ -636,7 +636,7 @@ public class DataminerPoolManager implements PoolManager {
|
||||||
private Algorithm convertAlgo(GenericResource a) {
|
private Algorithm convertAlgo(GenericResource a) {
|
||||||
Algorithm out = new Algorithm();
|
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.setAlgorithmType(a.profile().body().getElementsByTagName("algorithmType").item(0).getTextContent());
|
||||||
out.setCategory(a.profile().body().getElementsByTagName("category").item(0).getTextContent());
|
out.setCategory(a.profile().body().getElementsByTagName("category").item(0).getTextContent());
|
||||||
out.setClazz(a.profile().body().getElementsByTagName("clazz").item(0).getTextContent());
|
out.setClazz(a.profile().body().getElementsByTagName("clazz").item(0).getTextContent());
|
||||||
|
@ -655,14 +655,14 @@ public class DataminerPoolManager implements PoolManager {
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
public Algorithm getAlgoById(String id) {
|
***REMOVED*** public Algorithm getAlgoById(String id) {
|
||||||
for (Algorithm aa : this.getAlgoFromIs()) {
|
***REMOVED*** for (Algorithm aa : this.getAlgoFromIs()) {
|
||||||
if (aa.getId().equals(id)) {
|
***REMOVED*** if (aa.getId().equals(id)) {
|
||||||
return aa;
|
***REMOVED*** return aa;
|
||||||
***REMOVED***
|
***REMOVED*** ***REMOVED***
|
||||||
***REMOVED***
|
***REMOVED*** ***REMOVED***
|
||||||
return null;
|
***REMOVED*** return null;
|
||||||
***REMOVED***
|
***REMOVED******REMOVED***
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Algorithm> getAlgoFromIs() {
|
public Set<Algorithm> getAlgoFromIs() {
|
||||||
|
@ -670,7 +670,7 @@ public class DataminerPoolManager implements PoolManager {
|
||||||
|
|
||||||
Set<Algorithm> out = new HashSet<Algorithm>();
|
Set<Algorithm> out = new HashSet<Algorithm>();
|
||||||
SimpleQuery query = queryFor(GenericResource.class);
|
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);
|
DiscoveryClient<GenericResource> client = clientFor(GenericResource.class);
|
||||||
List<GenericResource> ds = client.submit(query);
|
List<GenericResource> ds = client.submit(query);
|
||||||
for (GenericResource a : ds) {
|
for (GenericResource a : ds) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class AnsibleWorkerTest {
|
||||||
r.addTaskFile(tf);
|
r.addTaskFile(tf);
|
||||||
worker.addRole(r);
|
worker.addRole(r);
|
||||||
|
|
||||||
worker.apply();
|
***REMOVED***worker.apply();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class AnsibleWorkerTest {
|
||||||
r.addTaskFile(tf);
|
r.addTaskFile(tf);
|
||||||
worker.addRole(r);
|
worker.addRole(r);
|
||||||
|
|
||||||
worker.apply();
|
***REMOVED***worker.apply();
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
||||||
***REMOVED***
|
***REMOVED***
|
||||||
|
|
Loading…
Reference in New Issue