|
@@ -29,6 +29,8 @@ import org.apache.hadoop.yarn.api.records.QueueACL;
|
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSchedulerConfiguration;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights;
|
|
|
+import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
|
|
|
+import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
|
|
|
import org.apache.hadoop.yarn.util.resource.Resources;
|
|
|
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
@@ -36,7 +38,8 @@ import com.google.common.annotations.VisibleForTesting;
|
|
|
public class AllocationConfiguration extends ReservationSchedulerConfiguration {
|
|
|
private static final AccessControlList EVERYBODY_ACL = new AccessControlList("*");
|
|
|
private static final AccessControlList NOBODY_ACL = new AccessControlList(" ");
|
|
|
-
|
|
|
+ private static final ResourceCalculator RESOURCE_CALCULATOR =
|
|
|
+ new DefaultResourceCalculator();
|
|
|
// Minimum resource allocation for each queue
|
|
|
private final Map<String, Resource> minQueueResources;
|
|
|
// Maximum amount of resources per queue
|
|
@@ -53,6 +56,7 @@ public class AllocationConfiguration extends ReservationSchedulerConfiguration {
|
|
|
final Map<String, Integer> userMaxApps;
|
|
|
private final int userMaxAppsDefault;
|
|
|
private final int queueMaxAppsDefault;
|
|
|
+ private final Resource queueMaxResourcesDefault;
|
|
|
|
|
|
// Maximum resource share for each leaf queue that can be used to run AMs
|
|
|
final Map<String, Float> queueMaxAMShares;
|
|
@@ -99,7 +103,8 @@ public class AllocationConfiguration extends ReservationSchedulerConfiguration {
|
|
|
Map<String, Integer> queueMaxApps, Map<String, Integer> userMaxApps,
|
|
|
Map<String, ResourceWeights> queueWeights,
|
|
|
Map<String, Float> queueMaxAMShares, int userMaxAppsDefault,
|
|
|
- int queueMaxAppsDefault, float queueMaxAMShareDefault,
|
|
|
+ int queueMaxAppsDefault, Resource queueMaxResourcesDefault,
|
|
|
+ float queueMaxAMShareDefault,
|
|
|
Map<String, SchedulingPolicy> schedulingPolicies,
|
|
|
SchedulingPolicy defaultSchedulingPolicy,
|
|
|
Map<String, Long> minSharePreemptionTimeouts,
|
|
@@ -117,6 +122,7 @@ public class AllocationConfiguration extends ReservationSchedulerConfiguration {
|
|
|
this.queueMaxAMShares = queueMaxAMShares;
|
|
|
this.queueWeights = queueWeights;
|
|
|
this.userMaxAppsDefault = userMaxAppsDefault;
|
|
|
+ this.queueMaxResourcesDefault = queueMaxResourcesDefault;
|
|
|
this.queueMaxAppsDefault = queueMaxAppsDefault;
|
|
|
this.queueMaxAMShareDefault = queueMaxAMShareDefault;
|
|
|
this.defaultSchedulingPolicy = defaultSchedulingPolicy;
|
|
@@ -140,6 +146,7 @@ public class AllocationConfiguration extends ReservationSchedulerConfiguration {
|
|
|
queueMaxAMShares = new HashMap<String, Float>();
|
|
|
userMaxAppsDefault = Integer.MAX_VALUE;
|
|
|
queueMaxAppsDefault = Integer.MAX_VALUE;
|
|
|
+ queueMaxResourcesDefault = Resources.unbounded();
|
|
|
queueMaxAMShareDefault = 0.5f;
|
|
|
queueAcls = new HashMap<String, Map<QueueACL, AccessControlList>>();
|
|
|
minSharePreemptionTimeouts = new HashMap<String, Long>();
|
|
@@ -243,7 +250,18 @@ public class AllocationConfiguration extends ReservationSchedulerConfiguration {
|
|
|
|
|
|
public Resource getMaxResources(String queueName) {
|
|
|
Resource maxQueueResource = maxQueueResources.get(queueName);
|
|
|
- return (maxQueueResource == null) ? Resources.unbounded() : maxQueueResource;
|
|
|
+ if (maxQueueResource == null) {
|
|
|
+ Resource minQueueResource = minQueueResources.get(queueName);
|
|
|
+ if (minQueueResource != null &&
|
|
|
+ Resources.greaterThan(RESOURCE_CALCULATOR, Resources.unbounded(),
|
|
|
+ minQueueResource, queueMaxResourcesDefault)) {
|
|
|
+ return minQueueResource;
|
|
|
+ } else {
|
|
|
+ return queueMaxResourcesDefault;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return maxQueueResource;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public boolean hasAccess(String queueName, QueueACL acl,
|
|
@@ -337,4 +355,4 @@ public class AllocationConfiguration extends ReservationSchedulerConfiguration {
|
|
|
public void setAverageCapacity(int avgCapacity) {
|
|
|
globalReservationQueueConfig.setAverageCapacity(avgCapacity);
|
|
|
}
|
|
|
-}
|
|
|
+}
|