2017-04-19 16:59:36 +02:00
|
|
|
package org.gcube.dataanalysis.dataminer.poolmanager.clients;
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
***REMOVED***
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
***REMOVED***
|
|
|
|
import java.util.LinkedList;
|
|
|
|
***REMOVED***
|
|
|
|
***REMOVED***
|
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
|
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Host;
|
|
|
|
***REMOVED***
|
|
|
|
import au.com.bytecode.opencsv.CSVReader;
|
|
|
|
|
|
|
|
public class HAProxy ***REMOVED***
|
|
|
|
|
|
|
|
private CSVReader reader;
|
|
|
|
|
2017-04-19 17:01:21 +02:00
|
|
|
public Cluster getClusterByHProxy() throws IOException ***REMOVED***
|
|
|
|
Cluster cl = new Cluster();
|
|
|
|
String HProxy = ISClient.getHProxy();
|
|
|
|
URL stockURL = new URL("http:***REMOVED***data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0");
|
|
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(stockURL.openStream()));
|
|
|
|
reader = new CSVReader(in);
|
|
|
|
String[] nextLine;
|
|
|
|
while ((nextLine = reader.readNext()) != null) ***REMOVED***
|
|
|
|
***REMOVED*** rules to add
|
|
|
|
if (HProxy.contains(nextLine[0])) ***REMOVED***
|
|
|
|
cl.setName(nextLine[0]);
|
|
|
|
***REMOVED***
|
|
|
|
***REMOVED***
|
|
|
|
return cl;
|
2017-04-19 16:59:36 +02:00
|
|
|
|
|
|
|
***REMOVED***
|
|
|
|
|
2017-04-19 17:01:21 +02:00
|
|
|
public Cluster MapCluster() throws IOException ***REMOVED***
|
2017-04-19 16:59:36 +02:00
|
|
|
Cluster cl = new Cluster();
|
|
|
|
String HProxy = ISClient.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***
|
2017-04-19 17:01:21 +02:00
|
|
|
|
2017-04-19 16:59:36 +02:00
|
|
|
return cl;
|
|
|
|
|
|
|
|
***REMOVED***
|
|
|
|
|
2017-04-19 17:01:21 +02:00
|
|
|
public List<Host> listDataMinersByCluster() throws IOException ***REMOVED***
|
|
|
|
***REMOVED*** next op to use when Cluster info available in the IS
|
|
|
|
***REMOVED*** Cluster cluster = this.getClusterByHProxy();
|
2017-04-19 16:59:36 +02:00
|
|
|
Cluster cluster = this.MapCluster();
|
|
|
|
List<Host> out = new LinkedList<Host>();
|
2017-04-19 17:01:21 +02:00
|
|
|
***REMOVED*** prod
|
2017-04-19 16:59:36 +02:00
|
|
|
URL stockURL = new URL("http:***REMOVED***data.d4science.org/Yk4zSFF6V3JOSytNd3JkRDlnRFpDUUR5TnRJZEw2QjRHbWJQNStIS0N6Yz0");
|
2017-04-19 17:01:21 +02:00
|
|
|
|
|
|
|
***REMOVED*** dev
|
|
|
|
***REMOVED*** URL stockURL = new
|
|
|
|
***REMOVED*** URL("http:***REMOVED***data.d4science.org/c29KTUluTkZnRlB0WXE5NVNaZnRoR0dtYThUSmNTVlhHbWJQNStIS0N6Yz0");
|
2017-04-19 16:59:36 +02:00
|
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(stockURL.openStream()));
|
|
|
|
reader = new CSVReader(in, ',');
|
|
|
|
String[] nextLine;
|
|
|
|
while ((nextLine = reader.readNext()) != null) ***REMOVED***
|
2017-04-19 17:01:21 +02:00
|
|
|
if (nextLine[1].equals("BACKEND") || (nextLine[1].equals("FRONTEND"))) ***REMOVED***
|
2017-04-19 16:59:36 +02:00
|
|
|
continue;
|
|
|
|
***REMOVED***
|
|
|
|
|
|
|
|
if (nextLine[0].equals(cluster.getName())) ***REMOVED***
|
|
|
|
Host a = new Host();
|
|
|
|
a.setName(nextLine[1]);
|
|
|
|
out.add(a);
|
|
|
|
System.out.println(a.getFullyQualifiedName());
|
|
|
|
***REMOVED***
|
|
|
|
***REMOVED***
|
|
|
|
return out;
|
|
|
|
|
2017-04-19 17:01:21 +02:00
|
|
|
***REMOVED***
|
2017-04-19 16:59:36 +02:00
|
|
|
|
2017-04-19 17:01:21 +02:00
|
|
|
public static void main(String[] args) throws IOException, SVNException ***REMOVED***
|
|
|
|
HAProxy a = new HAProxy();
|
|
|
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
|
|
|
***REMOVED*** System.out.println(a.getHProxy());
|
|
|
|
***REMOVED*** System.out.println(a.MapCluster());
|
|
|
|
System.out.println(a.listDataMinersByCluster());
|
|
|
|
***REMOVED*** System.out.println(a.listDataMinersByCluster());
|
|
|
|
|
|
|
|
***REMOVED*** List<Dependency> list = new LinkedList<Dependency>();
|
|
|
|
***REMOVED*** Dependency aa = new Dependency();
|
|
|
|
***REMOVED*** aa.setName("testnunzio");
|
|
|
|
***REMOVED*** aa.setType("cran:");
|
|
|
|
***REMOVED*** list.add(aa);
|
|
|
|
|
|
|
|
***REMOVED*** a.checkSVNdep();
|
|
|
|
***REMOVED*** System.out.println(a.getDataminer("dataminer1-devnext.d4science.org").getDomain());
|
|
|
|
***REMOVED*** System.out.println(a.listDataminersInVRE());
|
2017-04-19 16:59:36 +02:00
|
|
|
***REMOVED***
|
|
|
|
***REMOVED***
|