YARN-2978. Fixed potential NPE while getting queue info. Contributed by Varun Saxena

(cherry picked from commit dd57c2047b)
This commit is contained in:
Jian He 2015-01-06 14:15:57 -08:00
parent 2b408d8dc7
commit c61e8a7bfa
4 changed files with 21 additions and 20 deletions

View File

@ -287,6 +287,9 @@ Release 2.7.0 - UNRELEASED
YARN-2958. Made RMStateStore not update the last sequence number when updating the YARN-2958. Made RMStateStore not update the last sequence number when updating the
delegation token. (Varun Saxena via zjshen) delegation token. (Varun Saxena via zjshen)
YARN-2978. Fixed potential NPE while getting queue info. (Varun Saxena via
jianhe)
Release 2.6.0 - 2014-11-18 Release 2.6.0 - 2014-11-18
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -65,7 +65,6 @@ public abstract class AbstractCSQueue implements CSQueue {
RMNodeLabelsManager labelManager; RMNodeLabelsManager labelManager;
String defaultLabelExpression; String defaultLabelExpression;
Resource usedResources = Resources.createResource(0, 0); Resource usedResources = Resources.createResource(0, 0);
QueueInfo queueInfo;
Map<String, Float> absoluteCapacityByNodeLabels; Map<String, Float> absoluteCapacityByNodeLabels;
Map<String, Float> capacitiyByNodeLabels; Map<String, Float> capacitiyByNodeLabels;
Map<String, Resource> usedResourcesByNodeLabels = new HashMap<String, Resource>(); Map<String, Resource> usedResourcesByNodeLabels = new HashMap<String, Resource>();
@ -87,7 +86,6 @@ public abstract class AbstractCSQueue implements CSQueue {
this.parent = parent; this.parent = parent;
this.queueName = queueName; this.queueName = queueName;
this.resourceCalculator = cs.getResourceCalculator(); this.resourceCalculator = cs.getResourceCalculator();
this.queueInfo = recordFactory.newRecordInstance(QueueInfo.class);
// must be called after parent and queueName is set // must be called after parent and queueName is set
this.metrics = old != null ? old.getMetrics() : this.metrics = old != null ? old.getMetrics() :
@ -100,8 +98,6 @@ public abstract class AbstractCSQueue implements CSQueue {
this.defaultLabelExpression = cs.getConfiguration() this.defaultLabelExpression = cs.getConfiguration()
.getDefaultNodeLabelExpression(getQueuePath()); .getDefaultNodeLabelExpression(getQueuePath());
this.queueInfo.setQueueName(queueName);
// inherit from parent if labels not set // inherit from parent if labels not set
if (this.accessibleLabels == null && parent != null) { if (this.accessibleLabels == null && parent != null) {
this.accessibleLabels = parent.getAccessibleNodeLabels(); this.accessibleLabels = parent.getAccessibleNodeLabels();
@ -281,12 +277,6 @@ public abstract class AbstractCSQueue implements CSQueue {
this.maxCapacityByNodeLabels = this.maxCapacityByNodeLabels =
new HashMap<String, Float>(maximumNodeLabelCapacities); new HashMap<String, Float>(maximumNodeLabelCapacities);
this.queueInfo.setAccessibleNodeLabels(this.accessibleLabels);
this.queueInfo.setCapacity(this.capacity);
this.queueInfo.setMaximumCapacity(this.maximumCapacity);
this.queueInfo.setQueueState(this.state);
this.queueInfo.setDefaultNodeLabelExpression(this.defaultLabelExpression);
// Update metrics // Update metrics
CSQueueUtils.updateQueueStatistics( CSQueueUtils.updateQueueStatistics(
resourceCalculator, this, parent, clusterResource, minimumAllocation); resourceCalculator, this, parent, clusterResource, minimumAllocation);
@ -330,6 +320,18 @@ public abstract class AbstractCSQueue implements CSQueue {
this.reservationsContinueLooking = reservationContinueLooking; this.reservationsContinueLooking = reservationContinueLooking;
} }
protected QueueInfo getQueueInfo() {
QueueInfo queueInfo = recordFactory.newRecordInstance(QueueInfo.class);
queueInfo.setQueueName(queueName);
queueInfo.setAccessibleNodeLabels(accessibleLabels);
queueInfo.setCapacity(capacity);
queueInfo.setMaximumCapacity(maximumCapacity);
queueInfo.setQueueState(state);
queueInfo.setDefaultNodeLabelExpression(defaultLabelExpression);
queueInfo.setCurrentCapacity(getUsedCapacity());
return queueInfo;
}
@Private @Private
public Resource getMaximumAllocation() { public Resource getMaximumAllocation() {
return maximumAllocation; return maximumAllocation;

View File

@ -163,8 +163,6 @@ public class LeafQueue extends AbstractCSQueue {
CSQueueUtils.computeMaxActiveApplicationsPerUser( CSQueueUtils.computeMaxActiveApplicationsPerUser(
maxActiveAppsUsingAbsCap, userLimit, userLimitFactor); maxActiveAppsUsingAbsCap, userLimit, userLimitFactor);
this.queueInfo.setChildQueues(new ArrayList<QueueInfo>());
QueueState state = cs.getConfiguration().getState(getQueuePath()); QueueState state = cs.getConfiguration().getState(getQueuePath());
Map<QueueACL, AccessControlList> acls = Map<QueueACL, AccessControlList> acls =
@ -235,14 +233,14 @@ public class LeafQueue extends AbstractCSQueue {
this.defaultLabelExpression)) { this.defaultLabelExpression)) {
throw new IOException("Invalid default label expression of " throw new IOException("Invalid default label expression of "
+ " queue=" + " queue="
+ queueInfo.getQueueName() + getQueueName()
+ " doesn't have permission to access all labels " + " doesn't have permission to access all labels "
+ "in default label expression. labelExpression of resource request=" + "in default label expression. labelExpression of resource request="
+ (this.defaultLabelExpression == null ? "" + (this.defaultLabelExpression == null ? ""
: this.defaultLabelExpression) : this.defaultLabelExpression)
+ ". Queue labels=" + ". Queue labels="
+ (queueInfo.getAccessibleNodeLabels() == null ? "" : StringUtils.join(queueInfo + (getAccessibleNodeLabels() == null ? "" : StringUtils.join(
.getAccessibleNodeLabels().iterator(), ','))); getAccessibleNodeLabels().iterator(), ',')));
} }
this.nodeLocalityDelay = nodeLocalityDelay; this.nodeLocalityDelay = nodeLocalityDelay;
@ -433,7 +431,7 @@ public class LeafQueue extends AbstractCSQueue {
@Override @Override
public synchronized QueueInfo getQueueInfo( public synchronized QueueInfo getQueueInfo(
boolean includeChildQueues, boolean recursive) { boolean includeChildQueues, boolean recursive) {
queueInfo.setCurrentCapacity(usedCapacity); QueueInfo queueInfo = getQueueInfo();
return queueInfo; return queueInfo;
} }

View File

@ -110,8 +110,6 @@ public class ParentQueue extends AbstractCSQueue {
Map<QueueACL, AccessControlList> acls = Map<QueueACL, AccessControlList> acls =
cs.getConfiguration().getAcls(getQueuePath()); cs.getConfiguration().getAcls(getQueuePath());
this.queueInfo.setChildQueues(new ArrayList<QueueInfo>());
setupQueueConfigs(cs.getClusterResource(), capacity, absoluteCapacity, setupQueueConfigs(cs.getClusterResource(), capacity, absoluteCapacity,
maximumCapacity, absoluteMaxCapacity, state, acls, accessibleLabels, maximumCapacity, absoluteMaxCapacity, state, acls, accessibleLabels,
defaultLabelExpression, capacitiyByNodeLabels, maxCapacityByNodeLabels, defaultLabelExpression, capacitiyByNodeLabels, maxCapacityByNodeLabels,
@ -206,7 +204,7 @@ public class ParentQueue extends AbstractCSQueue {
@Override @Override
public synchronized QueueInfo getQueueInfo( public synchronized QueueInfo getQueueInfo(
boolean includeChildQueues, boolean recursive) { boolean includeChildQueues, boolean recursive) {
queueInfo.setCurrentCapacity(usedCapacity); QueueInfo queueInfo = getQueueInfo();
List<QueueInfo> childQueuesInfo = new ArrayList<QueueInfo>(); List<QueueInfo> childQueuesInfo = new ArrayList<QueueInfo>();
if (includeChildQueues) { if (includeChildQueues) {