This commit is contained in:
Nunzio Andrea Galante 2017-04-19 14:21:39 +00:00
parent 899299f7ec
commit 0002e935e8
3 changed files with 88 additions and 12 deletions

View File

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

View File

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

View File

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