@Override
    public int compareTo(ResourceDescription o) {
        if (o.getResourceUsage().size() > resourceUsageByName.size()) {
            return -1;
        }

        if (exactlyEquals(o.getResourceUsage())) {
            return 0;
        }

        for (Map.Entry<String, ResourceUsage> entry : o.getResourceUsage().entrySet()) {
            // if we don't have any entry which is in other but not in our set, we fail
            String resourceName = entry.getKey();
            // check if we have this resource, if not clearly we are lesser
            if (resourceUsageByName.containsKey(resourceName)) {
                int less = resourceUsageByName.get(resourceName).compareTo(entry.getValue());
                // not using the resource till its last shred, so <= 0 is failure
                if (less <= 0) {
                    return -1;
                }
            } else {
                return -1;
            }
        }
        return 1;
    }
@Test
    public void compareTo() {
        PulsarResourceDescription one = new PulsarResourceDescription();
        one.put("cpu", new ResourceUsage(0.1, 0.2));
        PulsarResourceDescription two = new PulsarResourceDescription();
        two.put("cpu", new ResourceUsage(0.1, 0.2));
        assertEquals(0, one.compareTo(two));
    }