public int compare(HostData o1, HostData o2) { double compare = o1.getCurrentStatus().getResourcesInUse().getCpu() - o2.getCurrentStatus().getResourcesInUse().getCpu(); if (compare < 0) return -1; else if (compare > 0) return 1; return 0; }
public int compare(HostData o1, HostData o2) { double compare = o1.getHostDescription().getPowerEfficiency() - o2.getHostDescription().getPowerEfficiency(); if (compare < 0) return -1; else if (compare > 0) return 1; return 0; }
public int compare(HostData o1, HostData o2) { double compare = o1.getHostDescription().getResourceCapacity().getBandwidth() - o2.getHostDescription().getResourceCapacity().getBandwidth(); if (compare < 0) return -1; else if (compare > 0) return 1; return 0; }
public int compare(HostData o1, HostData o2) { double compare = (o1.getCurrentStatus().getResourcesInUse().getCpu() / o1.getHostDescription().getResourceCapacity().getCpu()) - (o2.getCurrentStatus().getResourcesInUse().getCpu() / o2.getHostDescription().getResourceCapacity().getCpu()); if (compare < 0) return -1; else if (compare > 0) return 1; return 0; }
public int compare(HostData o1, HostData o2) { int o1State; int o2State; if (o1.getCurrentStatus().getState() == Host.HostState.ON) o1State = 2; else if (o1.getCurrentStatus().getState() == Host.HostState.SUSPENDED) o1State = 1; else o1State = 0; // ranks off and transition states lowest if (o2.getCurrentStatus().getState() == Host.HostState.ON) o2State = 2; else if (o2.getCurrentStatus().getState() == Host.HostState.SUSPENDED) o2State = 1; else o2State = 0; // ranks off and transition states lowest return o1State - o2State; }
public double calculate(HostData host) { ArrayList<VmAllocation> vms = new ArrayList<VmAllocation>(host.getHost().getVMAllocations()); vms.add(host.getHost().getPrivDomainAllocation()); int cpu = 0; int mem = 0; double bw = 0; for (VmAllocation vm : vms) { // If the VMAllocation has an associated VM, record its resource allocation. if (vm.getVm() != null) cpu += vm.getCpu(); mem += vm.getMemory(); bw += vm.getBandwidth(); } Resources res = host.getHostDescription().getResourceCapacity(); return (cpu * mem * bw) / (res.getCpu() * res.getMemory() * res.getBandwidth()); }
/** Test the hexadecimal string representation of the host data. */ public void testToHexString() { assertTrue(null == HostData.toHexString(null)); try { assertTrue(null == HostData.toHexString(new byte[0], 5, 10)); fail("Length error not detected"); } catch (IllegalArgumentException e) { assertEquals("Invalid start or length parameter", e.getMessage()); } assertEquals("00", HostData.toHexString(new byte[] {0x00})); assertEquals("0001", HostData.toHexString(new byte[] {0x00, 0x01})); assertEquals("0001ff", HostData.toHexString(new byte[] {0x00, 0x01, -0x01})); assertEquals("", HostData.toHexString(new byte[] {0x00, 0x01}, 0, 0)); assertEquals("00", HostData.toHexString(new byte[] {0x00, 0x01}, 0, 1)); assertEquals("01", HostData.toHexString(new byte[] {0x00, 0x01}, 1, 1)); }
public int compare(HostData o1, HostData o2) { return o1.getHostDescription().getResourceCapacity().getMemory() - o2.getHostDescription().getResourceCapacity().getMemory(); }
public int compare(HostData o1, HostData o2) { return o1.getHostDescription().getCoreCapacity() - o2.getHostDescription().getCoreCapacity(); }
public int compare(HostData o1, HostData o2) { return o1.getHostDescription().getCpuCount() * o1.getHostDescription().getCoreCount() - o2.getHostDescription().getCpuCount() * o2.getHostDescription().getCoreCount(); }
/** Test the hexadecimal string representation of the host data with maximum. */ public void testToHexStringWithMax() { assertTrue(null == HostData.toHexString(null, 100)); try { assertTrue(null == HostData.toHexString(new byte[0], 5, 10, 100)); fail("Length error not detected"); } catch (IllegalArgumentException e) { assertEquals("Invalid start or length parameter", e.getMessage()); } try { assertEquals("0001", HostData.toHexString(new byte[] {0x00, 0x01}, 1)); fail("Length error not detected"); } catch (IllegalArgumentException e) { assertEquals("maxBytes cannot be smaller than 2", e.getMessage()); } assertEquals("0001", HostData.toHexString(new byte[] {0x00, 0x01}, 2)); assertEquals("0001", HostData.toHexString(new byte[] {0x00, 0x01}, 3)); assertEquals("00....02", HostData.toHexString(new byte[] {0x00, 0x01, 0x02}, 2)); assertEquals("00....03", HostData.toHexString(new byte[] {0x00, 0x01, 0x02, 0x03}, 2)); assertEquals("00....03", HostData.toHexString(new byte[] {0x00, 0x01, 0x02, 0x03}, 3)); assertEquals("00010203", HostData.toHexString(new byte[] {0x00, 0x01, 0x02, 0x03}, 4)); assertEquals( "00....04", HostData.toHexString(new byte[] {0x00, 0x01, 0x02, 0x03, 0x04}, 0, 5, 2)); assertEquals( "00....03", HostData.toHexString(new byte[] {0x00, 0x01, 0x02, 0x03, 0x04}, 0, 4, 2)); assertEquals( "01....04", HostData.toHexString(new byte[] {0x00, 0x01, 0x02, 0x03, 0x04}, 1, 4, 2)); assertEquals( "01020304", HostData.toHexString(new byte[] {0x00, 0x01, 0x02, 0x03, 0x04}, 1, 4, 4)); }