package org.gcube.dataanalysis.dataminer.poolmanager.util;

import java.io.FileNotFoundException;
***REMOVED***

***REMOVED***
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.clients.HAProxy;
import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.DMPMClientConfiguratorManager;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Cluster;
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Host;

public class ClusterBuilder ***REMOVED***

	
	***REMOVED***1. to complete
	public static Cluster getStagingDataminerCluster() throws FileNotFoundException***REMOVED***
		Cluster cluster = new Cluster();
		
		Host h = new Host();
		h.setName(DMPMClientConfiguratorManager.getInstance().getStagingConfiguration().getHost());
		cluster.addHost(h);
		
***REMOVED***		if (env.equals("Dev"))***REMOVED***
***REMOVED***			h.setName(p.getDevStagingHost());
***REMOVED***			cluster.addHost(h);
***REMOVED***	***REMOVED***
***REMOVED***		
***REMOVED***		if ((env.equals("Prod")||(env.equals("Proto"))))***REMOVED***
***REMOVED***			h.setName(p.getProtoProdStagingHost());
***REMOVED***			cluster.addHost(h);
***REMOVED***	***REMOVED***
		
		return cluster;
***REMOVED***
	
	
	public static Cluster getProdDataminerCluster() throws FileNotFoundException***REMOVED***
		Cluster cluster = new Cluster();

		Host h = new Host();
		h.setName(DMPMClientConfiguratorManager.getInstance().getProductionConfiguration().getHost());
		cluster.addHost(h);
		
***REMOVED***		if (env.equals("Dev"))***REMOVED***
***REMOVED***			h.setName(p.getDevStagingHost());
***REMOVED***			cluster.addHost(h);
***REMOVED***	***REMOVED***
***REMOVED***		
***REMOVED***		if ((env.equals("Prod")||(env.equals("Proto"))))***REMOVED***
***REMOVED***			h.setName(p.getProtoProdStagingHost());
***REMOVED***			cluster.addHost(h);
***REMOVED***	***REMOVED***
		
		return cluster;
***REMOVED***
	
	
	
	public static Cluster getVRECluster(String targetVREToken, String targetVRE) throws IOException***REMOVED***
		Cluster cluster = new Cluster();
		for (Host h : new HAProxy().listDataMinersByCluster(targetVREToken,targetVRE)) ***REMOVED***
			cluster.addHost(h);
	***REMOVED***
		return  cluster;
***REMOVED***
	
	public static Cluster getRProtoCluster() throws IOException***REMOVED***
		***REMOVED***Assumes the service is running in RPrototypingLab

		String token = SecurityTokenProvider.instance.get();
		String targetVRE = ScopeProvider.instance.get();
		
		return getVRECluster(token, targetVRE);
***REMOVED***
	
	
	
***REMOVED***
