@Override public Integer getValue() { return queue.getResourceUsage().getVirtualCores(); } }
@Override public Integer getValue() { return queue.getResourceUsage().getMemory(); } }
@Override public Resource getResourceUsage() { Resource usage = Resources.createResource(0); for (FSQueue child : childQueues) { Resources.addTo(usage, child.getResourceUsage()); } return usage; }
@Override public Resource getResourceUsage() { Resource usage = Resources.createResource(0); for (FSQueue child : childQueues) { Resources.addTo(usage, child.getResourceUsage()); } return usage; }
/** Convenient toString implementation for debugging. */ @Override public String toString() { return String.format("[%s, demand=%s, running=%s, share=%s, w=%s]", getName(), getDemand(), getResourceUsage(), fairShare, getWeights()); }
/** Convenient toString implementation for debugging. */ @Override public String toString() { return String.format("[%s, demand=%s, running=%s, share=%s, w=%s]", getName(), getDemand(), getResourceUsage(), fairShare, getWeight()); }
/** Convenient toString implementation for debugging. */ @Override public String toString() { return String.format("[%s, demand=%s, running=%s, share=%s, w=%s]", getName(), getDemand(), getResourceUsage(), fairShare, getWeights()); }
/** * Helper method to check if the queue should attempt assigning resources * * @return true if check passes (can assign) or false otherwise */ boolean assignContainerPreCheck(FSSchedulerNode node) { if (node.getReservedContainer() != null) { if (LOG.isDebugEnabled()) { LOG.debug("Assigning container failed on node '" + node.getNodeName() + " because it has reserved containers."); } return false; } else if (!Resources.fitsIn(getResourceUsage(), getMaxShare())) { if (LOG.isDebugEnabled()) { LOG.debug("Assigning container failed on node '" + node.getNodeName() + " because queue resource usage is larger than MaxShare: " + dumpState()); } return false; } else { return true; } }
boolean fitsInMaxShare(Resource additionalResource) { Resource usagePlusAddition = Resources.add(getResourceUsage(), additionalResource); if (!Resources.fitsIn(usagePlusAddition, getMaxShare())) { if (LOG.isDebugEnabled()) { LOG.debug("Resource usage plus resource request: " + usagePlusAddition + " exceeds maximum resource allowed:" + getMaxShare() + " in queue " + getName()); } return false; } FSQueue parentQueue = getParent(); if (parentQueue != null) { return parentQueue.fitsInMaxShare(additionalResource); } return true; }
static boolean fitsInMaxShare(FSQueue queue, Resource additionalResource) { Resource usagePlusAddition = Resources.add(queue.getResourceUsage(), additionalResource); if (!Resources.fitsIn(usagePlusAddition, queue.getMaxShare())) { return false; } FSQueue parentQueue = queue.getParent(); if (parentQueue != null) { return fitsInMaxShare(parentQueue, additionalResource); } return true; }
/** * Helper method to check if the queue should attempt assigning resources * * @return true if check passes (can assign) or false otherwise */ protected boolean assignContainerPreCheck(FSSchedulerNode node) { if (!Resources.fitsIn(getResourceUsage(), scheduler.getAllocationConfiguration().getMaxResources(getName())) || node.getReservedContainer() != null) { return false; } return true; }
static boolean fitsInMaxShare(FSQueue queue, Resource additionalResource) { Resource usagePlusAddition = Resources.add(queue.getResourceUsage(), additionalResource); if (!Resources.fitsIn(usagePlusAddition, queue.getMaxShare())) { return false; } FSQueue parentQueue = queue.getParent(); if (parentQueue != null) { return fitsInMaxShare(parentQueue, additionalResource); } return true; }
/** * Helper method to check if the queue should attempt assigning resources * * @return true if check passes (can assign) or false otherwise */ protected boolean assignContainerPreCheck(FSSchedulerNode node) { if (!Resources.fitsIn(getResourceUsage(), scheduler.getAllocationConfiguration().getMaxResources(getName())) || node.getReservedContainer() != null) { return false; } return true; }
Resource queueUsage = queue.getResourceUsage(); Resource clusterResource = this.scheduler.getClusterResource(); Resource clusterUsage = this.scheduler.getRootQueueMetrics()
@Test public void testResourceUsageByMoveApp() throws Exception { scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); RMNode node1 = MockNodes.newNodeInfo( 1, Resources.createResource(1 * GB, 4), 1, "127.0.0.1"); NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1); scheduler.handle(nodeEvent1); ApplicationAttemptId appAttId = createSchedulingRequest(1 * GB, 2, "parent1.queue1", "user1", 2); scheduler.update(); NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node1); scheduler.handle(updateEvent); QueueManager queueMgr = scheduler.getQueueManager(); FSQueue parent1 = queueMgr.getParentQueue("parent1", true); FSQueue parent2 = queueMgr.getParentQueue("parent2", true); FSQueue queue2 = queueMgr.getLeafQueue("parent2.queue2", true); FSQueue queue1 = queueMgr.getLeafQueue("parent1.queue1", true); Assert.assertEquals(parent2.getResourceUsage().getMemorySize(), 0); Assert.assertEquals(queue2.getResourceUsage().getMemorySize(), 0); Assert.assertEquals(parent1.getResourceUsage().getMemorySize(), 1 * GB); Assert.assertEquals(queue1.getResourceUsage().getMemorySize(), 1 * GB); scheduler.moveApplication(appAttId.getApplicationId(), "parent2.queue2"); Assert.assertEquals(parent2.getResourceUsage().getMemorySize(), 1 * GB); Assert.assertEquals(queue2.getResourceUsage().getMemorySize(), 1 * GB); Assert.assertEquals(parent1.getResourceUsage().getMemorySize(), 0); Assert.assertEquals(queue1.getResourceUsage().getMemorySize(), 0); }
@Override public QueueInfo getQueueInfo(boolean includeChildQueues, boolean recursive) { QueueInfo queueInfo = recordFactory.newRecordInstance(QueueInfo.class); queueInfo.setQueueName(getQueueName()); if (scheduler.getClusterResource().getMemory() == 0) { queueInfo.setCapacity(0.0f); } else { queueInfo.setCapacity((float) getFairShare().getMemory() / scheduler.getClusterResource().getMemory()); } if (getFairShare().getMemory() == 0) { queueInfo.setCurrentCapacity(0.0f); } else { queueInfo.setCurrentCapacity((float) getResourceUsage().getMemory() / getFairShare().getMemory()); } ArrayList<QueueInfo> childQueueInfos = new ArrayList<QueueInfo>(); if (includeChildQueues) { Collection<FSQueue> childQueues = getChildQueues(); for (FSQueue child : childQueues) { childQueueInfos.add(child.getQueueInfo(recursive, recursive)); } } queueInfo.setChildQueues(childQueueInfos); queueInfo.setQueueState(QueueState.RUNNING); return queueInfo; }
@Override public QueueInfo getQueueInfo(boolean includeChildQueues, boolean recursive) { QueueInfo queueInfo = recordFactory.newRecordInstance(QueueInfo.class); queueInfo.setQueueName(getQueueName()); if (scheduler.getClusterResource().getMemory() == 0) { queueInfo.setCapacity(0.0f); } else { queueInfo.setCapacity((float) getFairShare().getMemory() / scheduler.getClusterResource().getMemory()); } if (getFairShare().getMemory() == 0) { queueInfo.setCurrentCapacity(0.0f); } else { queueInfo.setCurrentCapacity((float) getResourceUsage().getMemory() / getFairShare().getMemory()); } ArrayList<QueueInfo> childQueueInfos = new ArrayList<QueueInfo>(); if (includeChildQueues) { Collection<FSQueue> childQueues = getChildQueues(); for (FSQueue child : childQueues) { childQueueInfos.add(child.getQueueInfo(recursive, recursive)); } } queueInfo.setChildQueues(childQueueInfos); queueInfo.setQueueState(QueueState.RUNNING); return queueInfo; }
@Override public QueueInfo getQueueInfo(boolean includeChildQueues, boolean recursive) { QueueInfo queueInfo = recordFactory.newRecordInstance(QueueInfo.class); queueInfo.setQueueName(getQueueName()); if (scheduler.getClusterResource().getMemorySize() == 0) { queueInfo.setCapacity(0.0f); } else { queueInfo.setCapacity((float) getFairShare().getMemorySize() / scheduler.getClusterResource().getMemorySize()); } if (getFairShare().getMemorySize() == 0) { queueInfo.setCurrentCapacity(0.0f); } else { queueInfo.setCurrentCapacity((float) getResourceUsage().getMemorySize() / getFairShare().getMemorySize()); } ArrayList<QueueInfo> childQueueInfos = new ArrayList<QueueInfo>(); if (includeChildQueues) { Collection<FSQueue> childQueues = getChildQueues(); for (FSQueue child : childQueues) { childQueueInfos.add(child.getQueueInfo(recursive, recursive)); } } queueInfo.setChildQueues(childQueueInfos); queueInfo.setQueueState(QueueState.RUNNING); queueInfo.setQueueStatistics(getQueueStatistics()); return queueInfo; }
if (!Resources.fitsIn(Resources.add(cur.getResourceUsage(), consumption), cur.getMaxShare())) { throw new YarnException("Moving app attempt " + appAttId + " to queue "
getResourceUsage().getMemorySize());