package stubs;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.bench4q.master.domain.RunningAgentInterface;
import org.bench4q.master.domain.RunningScriptInterface;
import org.bench4q.master.domain.entity.Agent;
import org.bench4q.master.infrastructure.highavailable.CurrentLoadObserver;
import org.bench4q.master.infrastructure.highavailable.HighAvailablePool;
import org.bench4q.share.models.agent.ServerStatusModel;

public class HighAvailableImpl implements HighAvailablePool {

	private Map<String, Agent> pool = new HashMap<String, Agent>();

	public HighAvailableImpl() {
		String hostName = "127.0.0.1";
		this.pool
				.put(hostName, Agent.createAgentWithoutId(hostName, 6565, 500));
	}

	@Override
	public Map<String, Agent> getPool() {
		return this.pool;
	}

	@Override
	public Long getMaxAvailableLoad() {
		Long result = 0L;
		for (Agent agent : this.pool.values()) {
			result += agent.getMaxLoad();
		}
		return result;
	}

	@Override
	public int getCurrentAvailableLoad() {
		int result = 0;
		for (Agent agent : this.pool.values()) {
			result += agent.getRemainLoad();
		}
		return result;
	}

	@Override
	public void checkAllHeartBeat() {

	}

	@Override
	public void checkHeartBeat(Agent agent) {

	}

	@Override
	public void cleanUpAboutTestPlan(
			Collection<? extends RunningScriptInterface> runningScripts) {

	}

	@Override
	public ServerStatusModel queryAgentStatus(Agent agent) {
		return null;
	}

	@Override
	public void add(Agent agent) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setObserver(CurrentLoadObserver currentLoadObserver) {
		// TODO Auto-generated method stub

	}

	@Override
	public Map<UUID, RunningAgentInterface> getAgentRunBlotters() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int blotterSize() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void remove(Agent agent) {
		// TODO Auto-generated method stub

	}

	@Override
	public List<RunningAgentInterface> applyFor(int load) {
		// TODO Auto-generated method stub
		return null;
	}

}
