public void add(NormalizedResourcesWithMemory other) { normalizedResources.add(other.getNormalizedResources()); totalMemoryMb += other.getTotalMemoryMb(); }
/** * Check if resources might be able to fit. * @see NormalizedResources#couldHoldIgnoringSharedMemory(org.apache.storm.scheduler.resource.normalization.NormalizedResources, double, * double) */ public boolean couldHoldIgnoringSharedMemory(NormalizedResourcesWithMemory other) { return normalizedResources.couldHoldIgnoringSharedMemory( other.getNormalizedResources(), getTotalMemoryMb(), other.getTotalMemoryMb()); }
/** * Remove the resources in other from this. * @param other the resources to be removed. * @param resourceMetrics The resource related metrics * @return true if one or more resources in other were larger than available resources in this, else false. */ public boolean remove(NormalizedResourcesWithMemory other, ResourceMetrics resourceMetrics) { boolean negativeResources = normalizedResources.remove(other.getNormalizedResources(), resourceMetrics); totalMemoryMb -= other.getTotalMemoryMb(); if (totalMemoryMb < 0.0) { negativeResources = true; resourceMetrics.getNegativeResourceEventsMeter().mark(); totalMemoryMb = 0.0; } return negativeResources; }