private InstanceType matchHardwareDescriptionWithInstanceType(final HardwareDescription hardwareDescription) {

		// Assumes that the available instance types are ordered by number of CPU cores in descending order
		for (int i = 0; i < this.availableInstanceTypes.length; i++) {

			final InstanceType candidateInstanceType = this.availableInstanceTypes[i];
			// Check if number of CPU cores match
			if (candidateInstanceType.getNumberOfCores() > hardwareDescription.getNumberOfCPUCores()) {
				continue;
			}

			// Check if size of physical memory matches
			final int memoryInMB = (int) (hardwareDescription.getSizeOfPhysicalMemory() / (1024L * 1024L));
			if (candidateInstanceType.getMemorySize() > memoryInMB) {
				continue;
			}

			return candidateInstanceType;
		}

		LOG.error("Cannot find matching instance type for hardware description ("
			+ hardwareDescription.getNumberOfCPUCores() + " cores, " + hardwareDescription.getSizeOfPhysicalMemory()
			+ " bytes of memory)");

		return null;
	}
private InstanceType matchHardwareDescriptionWithInstanceType ( final HardwareDescription hardwareDescription ) { for ( int i = 0 ; i < this . availableInstanceTypes . length ; i ++ ) { final InstanceType candidateInstanceType = this . availableInstanceTypes [ i ] ; if ( candidateInstanceType . getNumberOfCores ( ) > hardwareDescription . getNumberOfCPUCores ( ) ) { continue ; } final int memoryInMB = ( int ) ( hardwareDescription . getSizeOfPhysicalMemory ( ) / ( 1024L * 1024L ) ) ; if ( candidateInstanceType . getMemorySize ( ) > memoryInMB ) { continue ; } return candidateInstanceType ; } LOG . error ( "Cannot find matching instance type for hardware description (" + hardwareDescription . getNumberOfCPUCores ( ) + " cores, " + hardwareDescription . getSizeOfPhysicalMemory ( ) + " bytes of memory)" ) ; return null ; }
Attempts to match the hardware characteristics provided by the {@link HardwareDescription} object with one
of the instance types set in the configuration. The matching is pessimistic, i.e. the hardware characteristics of
the chosen instance type never exceed the actually reported characteristics from the hardware description.

@param hardwareDescription
the hardware description as reported by the instance
@return the best matching instance type or <code>null</code> if no matching instance type can be found