45 lines
1.3 KiB
Java
45 lines
1.3 KiB
Java
|
package org.gcube.dataanalysis.dataminer.poolmanager.util;
|
||
|
|
||
|
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
|
||
|
public static Cluster getStagingDataminerCluster(){
|
||
|
Cluster cluster = new Cluster();
|
||
|
Props p = new Props();
|
||
|
Host h = new Host(p.getStagingHost());
|
||
|
//TODO: read this from configuration or IS?
|
||
|
h.setName(p.getStagingHost());
|
||
|
cluster.addHost(h);
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|