/** * Check whether a resource object is empty (0 memory and 0 virtual cores). * @param other The resource to check * @return {@code true} if {@code other} has 0 memory and 0 virtual cores, * {@code false} otherwise */ public static boolean isNone(Resource other) { return NONE.equals(other); }
public static boolean equals(Resource lhs, Resource rhs) { return lhs.equals(rhs); }
public static boolean equals(Resource lhs, Resource rhs) { return lhs.equals(rhs); }
public static boolean equals(Resource lhs, Resource rhs) { return lhs.equals(rhs); }
private boolean isSameAsNext(Long key, Resource capacity) { Entry<Long, Resource> next = cumulativeCapacity.higherEntry(key); return (next != null && next.getValue().equals(capacity)); }
private boolean isSameAsPrevious(Long key, Resource capacity) { Entry<Long, Resource> previous = cumulativeCapacity.lowerEntry(key); return (previous != null && previous.getValue().equals(capacity)); }
private boolean isSameAsPrevious(Long key, Resource capacity) { Entry<Long, Resource> previous = cumulativeCapacity.lowerEntry(key); return (previous != null && previous.getValue().equals(capacity)); }
private boolean isSameAsNext(Long key, Resource capacity) { Entry<Long, Resource> next = cumulativeCapacity.higherEntry(key); return (next != null && next.getValue().equals(capacity)); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || !(other instanceof GetResourceProfileResponse)) { return false; } return this.getResource() .equals(((GetResourceProfileResponse) other).getResource()); }
public ResourceInfo getConfiguredMaxResource() { if (configuredMaxResource.getResource().equals(Resources.none())) { return null; } return configuredMaxResource; }
private void validateAbsoluteVsPercentageCapacityConfig( Resource minResource) { CapacityConfigType localType = CapacityConfigType.PERCENTAGE; if (!minResource.equals(Resources.none())) { localType = CapacityConfigType.ABSOLUTE_RESOURCE; } if (!queueName.equals("root") && !this.capacityConfigType.equals(localType)) { throw new IllegalArgumentException("Queue '" + getQueueName() + "' should use either percentage based capacity" + " configuration or absolute resource."); } }
public Resource getKillableResource(String queueName, String partition) { try { readLock.lock(); PreemptableQueue entity = entities.get(queueName); if (entity != null) { Resource res = entity.getTotalKillableResources().get(partition); if (res == null || res.equals(Resources.none())) { return Resources.none(); } return Resources.clone(res); } return Resources.none(); } finally { readLock.unlock(); } }
public Resource getGuaranteed() { if(!effMinRes.equals(Resources.none())) { return Resources.clone(effMinRes); } return Resources.multiply(totalPartitionResource, absCapacity); }
public Resource getMax() { if(!effMaxRes.equals(Resources.none())) { return Resources.clone(effMaxRes); } return Resources.multiply(totalPartitionResource, absMaxCapacity); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if(obj == null || getClass() != obj.getClass()) { return false; } ResourceSizing that = (ResourceSizing) obj; if(getNumAllocations() != that.getNumAllocations()) { return false; } if(!getResources().equals(that.getResources())) { return false; } return true; } }
@Override public Resource getMaximumContainerAllocation() { if (getName().equals("root")) { return maxContainerAllocation; } if (maxContainerAllocation.equals(Resources.unbounded()) && getParent() != null) { return getParent().getMaximumContainerAllocation(); } else { return maxContainerAllocation; } }
@Override public Resource getMaximumContainerAllocation() { if (maxContainerAllocation.equals(Resources.unbounded()) && getParent() != null) { return getParent().getMaximumContainerAllocation(); } else { return maxContainerAllocation; } }
@Override public Resource getResourceUsage() { // Here the getPreemptedResources() always return zero, except in // a preemption round // In the common case where preempted resource is zero, return the // current consumption Resource object directly without calling // Resources.subtract which creates a new Resource object for each call. return getPreemptedResources().equals(Resources.none()) ? getCurrentConsumption() : Resources.subtract(getCurrentConsumption(), getPreemptedResources()); }
@Override public Resource getResourceUsage() { // Here the getPreemptedResources() always return zero, except in // a preemption round // In the common case where preempted resource is zero, return the // current consumption Resource object directly without calling // Resources.subtract which creates a new Resource object for each call. return getPreemptedResources().equals(Resources.none()) ? getCurrentConsumption() : Resources.subtract(getCurrentConsumption(), getPreemptedResources()); }
private void setPreemptionAllowed(ResourceLimits limits, String nodePartition) { // Set preemption-allowed: // For leaf queue, only under-utilized queue is allowed to preempt resources from other queues if (!queueResourceQuotas.getEffectiveMinResource(nodePartition) .equals(Resources.none())) { limits.setIsAllowPreemption(Resources.lessThan(resourceCalculator, csContext.getClusterResource(), queueUsage.getUsed(nodePartition), queueResourceQuotas.getEffectiveMinResource(nodePartition))); return; } float usedCapacity = queueCapacities.getAbsoluteUsedCapacity(nodePartition); float guaranteedCapacity = queueCapacities.getAbsoluteCapacity(nodePartition); limits.setIsAllowPreemption(usedCapacity < guaranteedCapacity); }