This commit is contained in:
Nunzio Andrea Galante 2017-04-19 14:21:39 +00:00
parent 1d004af37d
commit a7215f24a3
4 changed files with 96 additions and 14 deletions

View File

@ -145,13 +145,40 @@ public class ISClient {
public String getHProxy(){
Host h = new Host();
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Platform/Name/text() eq 'DataMinerAlone'");
query.addCondition("$resource/Profile/Platform/Name/text() eq 'DataMiner'");
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> resources = client.submit(query);
h.setName(resources.get(0).profile().runtime().hostedOn());
return h.getName();
}
//return the Cluster hostname from the IS
//to develop
public Cluster getCluster(){
Cluster cl = new Cluster();
String HProxy = this.getHProxy();
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Platform/Name/text() eq 'DataMiner'");
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> resources = client.submit(query);
cl.setName(resources.get(0).profile().runtime().hostedOn());
return null;
}
//return the dataminer hostnames from the IS
//to develop
public List<Host> getDM(){
Cluster cl = new Cluster();
String HProxy = this.getHProxy();
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Platform/Name/text() eq 'DataMiner'");
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> resources = client.submit(query);
cl.setName(resources.get(0).profile().runtime().hostedOn());
return null;
}
public Cluster getClusterByHProxy() throws IOException {
Cluster cl = new Cluster();
@ -171,14 +198,60 @@ public Cluster getClusterByHProxy() throws IOException {
}
public List<Host> listDataMinersByCluster() throws IOException {
Cluster cluster = this.getClusterByHProxy();
public Cluster MapCluster() throws IOException {
Cluster cl = new Cluster();
String HProxy = this.getHProxy();
if (HProxy.equals("dataminer-cluster1.d4science.org")) {
cl.setName("dataminer_cluster1");
}
if (HProxy.equals("dataminer-bigdata.d4science.org")) {
cl.setName("bigdata");
}
if (HProxy.equals("dataminer-cluster1.d4science.org")) {
cl.setName("dataminer_cluster1");
}
if (HProxy.equals("dataminer-cloud1.d4science.org")) {
cl.setName("dataminer_cloud1");
}
if (HProxy.equals("dataminer-prototypes.d4science.org")) {
cl.setName("prototypes");
}
if (HProxy.equals("dataminer.d4science.org")) {
cl.setName("gcubeapps");
}
if (HProxy.equals("dataminer-genericworkers.d4science.org")) {
cl.setName("genericworkers");
}
if (HProxy.equals("dataminer-genericworkers-proto.d4science.org")) {
cl.setName("genericworkers_proto");
}
if (HProxy.equals("dataminer-d-workers.d4science.org")) {
cl.setName("devnext_backend");
}
return cl;
}
public List<Host> listDataMinersByCluster() throws IOException {
//next op to use when Cluster info available in the IS
//Cluster cluster = this.getClusterByHProxy();
Cluster cluster = this.MapCluster();
List<Host> out = new LinkedList<Host>();
URL stockURL = new URL("http://data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0");
//prod
//URL stockURL = new URL("http://data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0");
//dev
URL stockURL = new URL("http://data.d4science.org/c29KTUluTkZnRlB0WXE5NVNaZnRoR0dtYThUSmNTVlhHbWJQNStIS0N6Yz0");
BufferedReader in = new BufferedReader(new InputStreamReader(stockURL.openStream()));
reader = new CSVReader(in, ',');
String[] nextLine;
while ((nextLine = reader.readNext()) != null) {
if (nextLine[1].equals("BACKEND")||(nextLine[1].equals("FRONTEND"))){
continue;
}
if (nextLine[0].equals(cluster.getName())) {
Host a = new Host();
a.setName(nextLine[1]);
@ -190,8 +263,6 @@ public Cluster getClusterByHProxy() throws IOException {
}
/**
* Return the list of hosts (dataminers) in a given VRE
*
@ -238,7 +309,8 @@ public Cluster getClusterByHProxy() throws IOException {
ISClient a = new ISClient();
ScopeProvider.instance.set("/gcube/devNext/NextNext");
//System.out.println(a.getHProxy());
//System.out.println(a.getClusterByHProxy());
//System.out.println(a.MapCluster());
System.out.println(a.listDataMinersByCluster());
//System.out.println(a.listDataMinersByCluster());

View File

@ -32,8 +32,12 @@ public class Host {
this.domain = domain;
}
public String toString() {
return this.name + "@" + this.domain;
}
// public String toString() {
// return this.name + "@" + this.domain;
// }
public String toString() {
return this.name;
}
}

View File

@ -338,7 +338,12 @@ public class RestPoolManager implements PoolManager {
a.addAlgorithmToVRE(
"http://data.d4science.org/TVc0TW9Ud1FjYlppK0NHd2pvU0owNmRFWHE4OW4xSGNHbWJQNStIS0N6Yz0",
"test",
null, null, "N", "transducerers", true, false);
null,
null,
"N",
"transducerers",
true,
false);
// a.addAlgorithmToHost(
// "http://data.d4science.org/dENQTTMxdjNZcGRpK0NHd2pvU0owMFFzN0VWemw3Zy9HbWJQNStIS0N6Yz0",
@ -404,5 +409,6 @@ public class RestPoolManager implements PoolManager {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -540,8 +540,8 @@ public class DataminerPoolManager implements PoolManager {
// create the cluster (dataminers in the vre)
Cluster cluster = new Cluster();
// for (Host h : new ISClient().listDataMinersByCluster()) {
for (Host h : new ISClient().listDataminersInVRE()) {
for (Host h : new ISClient().listDataMinersByCluster()) {
//for (Host h : new ISClient().listDataminersInVRE()) {
cluster.addHost(h);
}