2017-05-12 17:32:14 +02:00
|
|
|
package org.gcube.dataanalysis.dataminer.poolmanager.util;
|
|
|
|
|
2017-05-15 18:44:37 +02:00
|
|
|
import java.io.FileNotFoundException;
|
2017-05-12 17:32:14 +02:00
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.clients.HAProxy;
|
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
|
|
|
|
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Host;
|
|
|
|
|
|
|
|
public class ClusterBuilder {
|
|
|
|
|
|
|
|
|
|
|
|
//1. to complete
|
2017-07-26 21:21:07 +02:00
|
|
|
public static Cluster getStagingDataminerCluster(String env) throws FileNotFoundException{
|
2017-05-12 17:32:14 +02:00
|
|
|
Cluster cluster = new Cluster();
|
2017-05-17 18:16:25 +02:00
|
|
|
ServiceConfiguration p = new ServiceConfiguration();
|
2017-07-26 21:21:07 +02:00
|
|
|
Host h = new Host();
|
|
|
|
|
|
|
|
if (env.equals("Dev")){
|
|
|
|
h.setName(p.getDevStagingHost());
|
|
|
|
cluster.addHost(h);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((env.equals("Prod")||(env.equals("Proto")))){
|
|
|
|
h.setName(p.getProtoProdStagingHost());
|
|
|
|
cluster.addHost(h);
|
|
|
|
}
|
|
|
|
|
2017-05-12 17:32:14 +02:00
|
|
|
return cluster;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Cluster getVRECluster(String targetVREToken, String targetVRE) throws IOException{
|
|
|
|
Cluster cluster = new Cluster();
|
|
|
|
for (Host h : new HAProxy().listDataMinersByCluster(targetVREToken,targetVRE)) {
|
|
|
|
cluster.addHost(h);
|
|
|
|
}
|
|
|
|
return cluster;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Cluster getRProtoCluster() throws IOException{
|
|
|
|
//Assumes the service is running in RPrototypingLab
|
|
|
|
|
|
|
|
String token = SecurityTokenProvider.instance.get();
|
|
|
|
String targetVRE = ScopeProvider.instance.get();
|
|
|
|
|
|
|
|
return getVRECluster(token, targetVRE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|