/** * 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()); }
/** * Calculate the average percentage used. * @see NormalizedResources#calculateAveragePercentageUsedBy(org.apache.storm.scheduler.resource.normalization.NormalizedResources, * double, double) */ public double calculateAveragePercentageUsedBy(NormalizedResourceOffer used) { return normalizedResources.calculateAveragePercentageUsedBy( used.getNormalizedResources(), getTotalMemoryMb(), used.getTotalMemoryMb()); }
/** * If a node or rack has a kind of resource not in a request, make that resource negative so when sorting that node or rack will * be less likely to be selected. * @param requestedResources the requested resources. */ public void updateForRareResourceAffinity(NormalizedResourceRequest requestedResources) { normalizedResources.updateForRareResourceAffinity(requestedResources.getNormalizedResources()); }
/** * Calculate the min percentage used of the resource. * @see NormalizedResources#calculateMinPercentageUsedBy(org.apache.storm.scheduler.resource.normalization.NormalizedResources, double, * double) */ public double calculateMinPercentageUsedBy(NormalizedResourceOffer used) { return normalizedResources.calculateMinPercentageUsedBy(used.getNormalizedResources(), getTotalMemoryMb(), used.getTotalMemoryMb()); }
public void add(NormalizedResourcesWithMemory other) { normalizedResources.add(other.getNormalizedResources()); totalMemoryMb += other.getTotalMemoryMb(); }
public AllResources(String identifier) { this.identifier = identifier; this.availableResourcesOverall = new NormalizedResourceOffer(); this.totalResourcesOverall = new NormalizedResourceOffer(); }
/** * Copy Constructor. * @param other what to copy. */ public NormalizedResourceOffer(NormalizedResourceOffer other) { this.totalMemoryMb = other.totalMemoryMb; this.normalizedResources = new NormalizedResources(other.normalizedResources); }
/** * Add the resources in other to this. * * @param other the other Request to add to this. */ public void add(NormalizedResourceRequest other) { this.normalizedResources.add(other.normalizedResources); onHeap += other.onHeap; offHeap += other.offHeap; }
/** * Get the total Memory on this supervisor in MB. */ public double getTotalMemory() { return totalResources.getTotalMemoryMb(); }
/** * Get the total CPU on this supervisor in % CPU. */ public double getTotalCpu() { return totalResources.getTotalCpu(); }
@Override public boolean areAnyOverZero() { return onHeap > 0 || offHeap > 0 || normalizedResources.areAnyOverZero(); } }
@Override public void clear() { normalizedResources.clear(); offHeap = 0.0; onHeap = 0.0; }
private boolean remove(double[] resourceArray) { boolean ret = false; int otherLength = resourceArray.length; zeroPadOtherResourcesIfNecessary(otherLength); for (int i = 0; i < otherLength; i++) { otherResources[i] -= resourceArray[i]; if (otherResources[i] < 0) { ret = true; } } return ret; }
/** * Create an empty NormalizedResources. */ NormalizedResources() { cpu = 0.0; otherResources = RESOURCE_MAP_ARRAY_BRIDGE.empty(); }
@Override public Statement apply(Statement statement, Description description) { return new NRStatement(statement); } }
public ObjectResources(String id) { this.id = id; this.availableResources = new NormalizedResourceOffer(); this.totalResources = new NormalizedResourceOffer(); }
/** * Create an offer with all resources set to 0. */ public NormalizedResourceOffer() { normalizedResources = new NormalizedResources(); totalMemoryMb = 0.0; }
@Override public boolean areAnyOverZero() { return totalMemoryMb > 0 || normalizedResources.areAnyOverZero(); } }
@Override public void clear() { this.totalMemoryMb = 0.0; this.normalizedResources.clear(); }
private void add(double[] resourceArray) { int otherLength = resourceArray.length; zeroPadOtherResourcesIfNecessary(otherLength); for (int i = 0; i < otherLength; i++) { otherResources[i] += resourceArray[i]; } }