/** * Gets the pes number. * * @return the pes number */ public int getNumberOfPes() { return getPeList().size(); }
/** * Gets the total number of PEs for all Hosts. * * @param <T> the generic type * @param hostList the list of existing hosts * @return total number of PEs for all PMs * @pre $none * @post $result >= 0 */ public static <T extends Host> int getNumberOfPes(List<T> hostList) { int numberOfPes = 0; for (T host : hostList) { numberOfPes += host.getPeList().size(); } return numberOfPes; }
/** * Gets the total mips. * * @return the total mips */ public int getTotalMips() { return PeList.getTotalMips(getPeList()); }
/** * Gets the free pes number. * * @return the free pes number */ public int getNumberOfFreePes() { return PeList.getNumberOfFreePes(getPeList()); }
/** * Sets the PEs of the host to a FAILED status. * * @param failed the failed * @return <tt>true</tt> if successful, <tt>false</tt> otherwise */ public boolean setFailed(boolean failed) { // all the PEs are failed (or recovered, depending on fail) this.failed = failed; PeList.setStatusFailed(getPeList(), failed); return true; }
/** * Sets the particular Pe status on the host. * * @param peId the pe id * @param status Pe status, either <tt>Pe.FREE</tt> or <tt>Pe.BUSY</tt> * @return <tt>true</tt> if the Pe status has changed, <tt>false</tt> otherwise (Pe id might not * be exist) * @pre peID >= 0 * @post $none */ public boolean setPeStatus(int peId, int status) { return PeList.setPeStatus(getPeList(), peId, status); }
/** * Gets the total number of <tt>BUSY</tt> PEs for all Hosts. * * @param <T> the generic type * @param hostList the list of existing hosts * @return total number of busy PEs * @pre $none * @post $result >= 0 */ public static <T extends Host> int getNumberOfBusyPes(List<T> hostList) { int numberOfBusyPes = 0; for (T host : hostList) { numberOfBusyPes += PeList.getNumberOfBusyPes(host.getPeList()); } return numberOfBusyPes; }
/** * Gets the total number of <tt>FREE</tt> (non-busy) PEs for all Hosts. * * @param <T> the generic type * @param hostList the list of existing hosts * @return total number of free PEs * @pre $none * @post $result >= 0 */ public static <T extends Host> int getNumberOfFreePes(List<T> hostList) { int numberOfFreePes = 0; for (T host : hostList) { numberOfFreePes += PeList.getNumberOfFreePes(host.getPeList()); } return numberOfFreePes; }
/** * Gets the first Host with a specified number of free PEs. * * @param <T> the generic type * @param hostList the list of existing hosts * @param pesNumber the pes number * @return a Host object or <tt>null</tt> if not found * @pre $none * @post $none */ public static <T extends Host> T getHostWithFreePe(List<T> hostList, int pesNumber) { for (T host : hostList) { if (PeList.getNumberOfFreePes(host.getPeList()) >= pesNumber) { return host; } } return null; }
/** * Sets the PEs of the host to a FAILED status. NOTE: <tt>resName</tt> is used for debugging * purposes, which is <b>ON</b> by default. Use {@link #setFailed(boolean)} if you do not want * this information. * * @param resName the name of the resource * @param failed the failed * @return <tt>true</tt> if successful, <tt>false</tt> otherwise */ public boolean setFailed(String resName, boolean failed) { // all the PEs are failed (or recovered, depending on fail) this.failed = failed; PeList.setStatusFailed(getPeList(), resName, getId(), failed); return true; }
/** * Gets the Million Instructions Per Second (MIPS) Rating of the first Processing Element (Pe) * of the first PM. * <tt>NOTE:</tt>It is assumed all PEs' rating is same in a given machine. * * * @return the MIPS Rating or -1 if no PEs exists * * @pre $none * @post $result >= -1 * @todo It considers that all PEs of all PM have the same MIPS capacity, * what is not ensured because it is possible to add PMs of different configurations * to a datacenter. Even for the {@link Host} it is possible * to add Pe's of different capacities through the {@link Host#peList} attribute. */ public int getMipsOfOnePe() { if (getHostList().size() == 0) { return -1; } /*@todo Why is it always get the MIPS of the first host in the datacenter? The note in the method states that it is considered that all PEs into a PM have the same MIPS capacity, but different PM can have different PEs' MIPS.*/ return PeList.getMips(getHostList().get(0).getPeList(), 0); }
/** * Gets Millions Instructions Per Second (MIPS) Rating of a Processing Element (Pe). It is * essential to use this method when a datacenter is made up of heterogenous PEs per PMs. * * @param id the machine ID * @param peId the Pe ID * @return the MIPS Rating or -1 if no PEs are exists. * * @pre id >= 0 * @pre peID >= 0 * @post $result >= -1 * * @todo The id parameter would be renamed to pmId to be clear. */ public int getMipsOfOnePe(int id, int peId) { if (getHostList().size() == 0) { return -1; } return PeList.getMips(HostList.getById(getHostList(), id).getPeList(), peId); }