YARN-4418. AM Resource Limit per partition can be updated to ResourceUsage as well. (Sunil G via wangda)

(cherry picked from commit 07b0fb996a)
This commit is contained in:
Wangda Tan 2015-12-14 11:24:30 -08:00
parent e02ad5a618
commit c915a658c8
6 changed files with 88 additions and 12 deletions

View File

@ -564,6 +564,9 @@ Release 2.8.0 - UNRELEASED
YARN-4309. Add container launch related debug information to container logs YARN-4309. Add container launch related debug information to container logs
when a container fails. (Varun Vasudev via wangda) when a container fails. (Varun Vasudev via wangda)
YARN-4418. AM Resource Limit per partition can be updated to ResourceUsage as well.
(Sunil G via wangda)
OPTIMIZATIONS OPTIMIZATIONS
YARN-3339. TestDockerContainerExecutor should pull a single image and not YARN-3339. TestDockerContainerExecutor should pull a single image and not

View File

@ -61,7 +61,7 @@ public class ResourceUsage {
//CACHED_USED and CACHED_PENDING may be read by anyone, but must only //CACHED_USED and CACHED_PENDING may be read by anyone, but must only
//be written by ordering policies //be written by ordering policies
USED(0), PENDING(1), AMUSED(2), RESERVED(3), CACHED_USED(4), USED(0), PENDING(1), AMUSED(2), RESERVED(3), CACHED_USED(4),
CACHED_PENDING(5); CACHED_PENDING(5), AMLIMIT(6);
private int idx; private int idx;
@ -92,6 +92,7 @@ public class ResourceUsage {
sb.append("pending=" + resArr[1] + "%, "); sb.append("pending=" + resArr[1] + "%, ");
sb.append("am_used=" + resArr[2] + "%, "); sb.append("am_used=" + resArr[2] + "%, ");
sb.append("reserved=" + resArr[3] + "%}"); sb.append("reserved=" + resArr[3] + "%}");
sb.append("am_limit=" + resArr[6] + "%, ");
return sb.toString(); return sb.toString();
} }
} }
@ -107,10 +108,18 @@ public class ResourceUsage {
return _get(label, ResourceType.USED); return _get(label, ResourceType.USED);
} }
public Resource getCachedUsed() {
return _get(NL, ResourceType.CACHED_USED);
}
public Resource getCachedUsed(String label) { public Resource getCachedUsed(String label) {
return _get(label, ResourceType.CACHED_USED); return _get(label, ResourceType.CACHED_USED);
} }
public Resource getCachedPending() {
return _get(NL, ResourceType.CACHED_PENDING);
}
public Resource getCachedPending(String label) { public Resource getCachedPending(String label) {
return _get(label, ResourceType.CACHED_PENDING); return _get(label, ResourceType.CACHED_PENDING);
} }
@ -154,10 +163,18 @@ public class ResourceUsage {
_set(label, ResourceType.CACHED_USED, res); _set(label, ResourceType.CACHED_USED, res);
} }
public void setCachedUsed(Resource res) {
_set(NL, ResourceType.CACHED_USED, res);
}
public void setCachedPending(String label, Resource res) { public void setCachedPending(String label, Resource res) {
_set(label, ResourceType.CACHED_PENDING, res); _set(label, ResourceType.CACHED_PENDING, res);
} }
public void setCachedPending(Resource res) {
_set(NL, ResourceType.CACHED_PENDING, res);
}
/* /*
* Pending * Pending
*/ */
@ -263,6 +280,41 @@ public class ResourceUsage {
_set(label, ResourceType.AMUSED, res); _set(label, ResourceType.AMUSED, res);
} }
/*
* AM-Resource Limit
*/
public Resource getAMLimit() {
return getAMLimit(NL);
}
public Resource getAMLimit(String label) {
return _get(label, ResourceType.AMLIMIT);
}
public void incAMLimit(String label, Resource res) {
_inc(label, ResourceType.AMLIMIT, res);
}
public void incAMLimit(Resource res) {
incAMLimit(NL, res);
}
public void decAMLimit(Resource res) {
decAMLimit(NL, res);
}
public void decAMLimit(String label, Resource res) {
_dec(label, ResourceType.AMLIMIT, res);
}
public void setAMLimit(Resource res) {
setAMLimit(NL, res);
}
public void setAMLimit(String label, Resource res) {
_set(label, ResourceType.AMLIMIT, res);
}
private static Resource normalize(Resource res) { private static Resource normalize(Resource res) {
if (res == null) { if (res == null) {
return Resources.none(); return Resources.none();

View File

@ -606,6 +606,7 @@ public class LeafQueue extends AbstractCSQueue {
minimumAllocation); minimumAllocation);
metrics.setAMResouceLimit(amResouceLimit); metrics.setAMResouceLimit(amResouceLimit);
queueUsage.setAMLimit(nodePartition, amResouceLimit);
return amResouceLimit; return amResouceLimit;
} }

View File

@ -217,6 +217,11 @@ public class QueueCapacities {
} }
/* Absolute Maximum AM resource percentage Getter and Setter */ /* Absolute Maximum AM resource percentage Getter and Setter */
public float getMaxAMResourcePercentage() {
return _get(NL, CapacityType.MAX_AM_PERC);
}
public float getMaxAMResourcePercentage(String label) { public float getMaxAMResourcePercentage(String label) {
return _get(label, CapacityType.MAX_AM_PERC); return _get(label, CapacityType.MAX_AM_PERC);
} }
@ -225,6 +230,10 @@ public class QueueCapacities {
_set(label, CapacityType.MAX_AM_PERC, value); _set(label, CapacityType.MAX_AM_PERC, value);
} }
public void setMaxAMResourcePercentage(float value) {
_set(NL, CapacityType.MAX_AM_PERC, value);
}
/** /**
* Clear configurable fields, like * Clear configurable fields, like
* (absolute)capacity/(absolute)maximum-capacity, this will be used by queue * (absolute)capacity/(absolute)maximum-capacity, this will be used by queue

View File

@ -37,8 +37,8 @@ public class TestResourceUsage {
@Parameterized.Parameters @Parameterized.Parameters
public static Collection<String[]> getParameters() { public static Collection<String[]> getParameters() {
return Arrays.asList(new String[][] { { "Pending" }, { "Used" }, return Arrays.asList(new String[][]{{"Pending"}, {"Used"}, {"Reserved"},
{ "Reserved" }, { "AMUsed" } }); {"AMUsed"}, {"AMLimit"}, {"CachedUsed"}, {"CachedPending"}});
} }
public TestResourceUsage(String suffix) { public TestResourceUsage(String suffix) {
@ -112,16 +112,26 @@ public class TestResourceUsage {
check(0, 0, res); check(0, 0, res);
// Add 1,1 should returns 1,1 // Add 1,1 should returns 1,1
inc(usage, suffix, Resource.newInstance(1, 1), label); try {
check(1, 1, get(usage, suffix, label)); inc(usage, suffix, Resource.newInstance(1, 1), label);
check(1, 1, get(usage, suffix, label));
} catch (NoSuchMethodException e) {
// Few operations need not have to be verified as some resources doesn't
// inc/dec apis exposed (For Eg: CachedUsed and CachedPending).
}
// Set 2,2 // Set 2,2
set(usage, suffix, Resource.newInstance(2, 2), label); set(usage, suffix, Resource.newInstance(2, 2), label);
check(2, 2, get(usage, suffix, label)); check(2, 2, get(usage, suffix, label));
// dec 2,2 // dec 2,2
dec(usage, suffix, Resource.newInstance(2, 2), label); try {
check(0, 0, get(usage, suffix, label)); dec(usage, suffix, Resource.newInstance(2, 2), label);
check(0, 0, get(usage, suffix, label));
} catch (NoSuchMethodException e) {
// Few operations need not have to be verified, as some resources doesn't
// inc/dec apis exposed (For Eg: CachedUsed and CachedPending).
}
} }
void check(int mem, int cpu, Resource res) { void check(int mem, int cpu, Resource res) {

View File

@ -43,7 +43,8 @@ public class TestQueueCapacities {
{ "UsedCapacity" }, { "UsedCapacity" },
{ "AbsoluteUsedCapacity" }, { "AbsoluteUsedCapacity" },
{ "MaximumCapacity" }, { "MaximumCapacity" },
{ "AbsoluteMaximumCapacity" } }); { "AbsoluteMaximumCapacity" },
{ "MaxAMResourcePercentage" } });
} }
public TestQueueCapacities(String suffix) { public TestQueueCapacities(String suffix) {