package schedframe.resources; import gridsim.gssim.resource.ResourceProcessors; import org.qcg.broker.schemas.exception.NoSuchParamException; import org.qcg.broker.schemas.hostparams.ComputingResourceParameterType; import org.qcg.broker.schemas.hostparams.Property; import org.qcg.broker.schemas.hostparams.types.ComputingParameterName; import org.qcg.broker.schemas.hostparams.wrapper.impl.ComputingResourceParamExplorerImpl; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import schedframe.resources.units.Processor; import schedframe.scheduling.Queue; import schedframe.scheduling.TaskInterface; /** * * @author Marcin Krystek * */ public abstract class ExecutingResourceDescription extends ResourceDescription { private Log log = LogFactory.getLog(ExecutingResourceDescription.class); protected List>> accesQueues; protected Map nodesPowerProfilesMap; public ExecutingResourceDescription(){ this.accesQueues = new ArrayList>>(); this.nodesPowerProfilesMap = new HashMap(); } /** * * @return list of queues. These are the queues in which tasks submitted * to this resource are waiting for local scheduling decision */ public List>> getAccessQueues(){ return this.accesQueues; } protected int getCorecountParameterValue(ComputingResourceParamExplorerImpl explorer){ try { ComputingResourceParameterType paramType = explorer.getHostParam(ComputingParameterName.CPUCOUNT); Property properties[] = paramType.getProperty(); for(int j = 0; j < properties.length; j++){ Property p = properties[j]; String name = p.getName(); if("corecount".equalsIgnoreCase(name)){ int count = Integer.parseInt(p.getValue(0)); System.out.println("corecount: " + count); return count; } } } catch (NoSuchParamException e) { log.error(e.getMessage()); } return 1; } protected String getPropertyValue(ComputingResourceParameterType paramType, String propertyName){ Property properties[] = paramType.getProperty(); for(int j = 0; j < properties.length; j++){ Property p = properties[j]; String name = p.getName(); if(propertyName.equalsIgnoreCase(name)){ return p.getValue(0); } } return null; } public Map getNodePowerProfiles(){ return this.nodesPowerProfilesMap; } public abstract boolean supportReservation(); protected class ExecResourceProcessors extends ResourceProcessors{ public ExecResourceProcessors(String resId, Processor p, int cpuCnt, int coreCnt, boolean uniqe) { super(resId); this.areUnique = uniqe; this.processors = new ArrayList(cpuCnt * coreCnt); for(int i = 0; i < cpuCnt; i++){ for(int j = 0; j < coreCnt; j++){ Processor cpu = new Processor(i, j); cpu.setComputingNodeId(p.getComputingNodeId()); cpu.accept(p.getPowerProfile().clone()); this.processors.add(cpu); } } } } }