public void initThresholdCalculator(float sigma, int limitMin, int limitMax) { this.thresholdCalculator = new QueueLimitCalculator(this, sigma, limitMin, limitMax); }
private int getThreshold() { int thres = determineThreshold(); return Math.min(rangeMax, Math.max(rangeMin, thres)); }
@Override public void run() { ReentrantReadWriteLock.WriteLock writeLock = sortedNodesLock.writeLock(); writeLock.lock(); try { try { List<NodeId> nodeIds = sortNodes(); sortedNodes.clear(); sortedNodes.addAll(nodeIds); } catch (Exception ex) { LOG.warn("Got Exception while sorting nodes..", ex); } if (thresholdCalculator != null) { thresholdCalculator.update(); } } finally { writeLock.unlock(); } } };
nodeHeartBeatResponse.setContainerQueuingLimit( this.rmContext.getNodeManagerQueueLimitCalculator() .createContainerQueuingLimit());
public ContainerQueuingLimit createContainerQueuingLimit() { ContainerQueuingLimit containerQueuingLimit = ContainerQueuingLimit.newInstance(); if (nodeSelector.getComparator() == LoadComparator.QUEUE_WAIT_TIME) { containerQueuingLimit.setMaxQueueWaitTimeInMs(getThreshold()); containerQueuingLimit.setMaxQueueLength(-1); } else { containerQueuingLimit.setMaxQueueWaitTimeInMs(-1); containerQueuingLimit.setMaxQueueLength(getThreshold()); } return containerQueuingLimit; } }
QueueLimitCalculator calculator = selector.getThresholdCalculator(); ContainerQueuingLimit containerQueuingLimit = calculator .createContainerQueuingLimit(); Assert.assertEquals(6, containerQueuingLimit.getMaxQueueLength()); Assert.assertEquals(-1, containerQueuingLimit.getMaxQueueWaitTimeInMs()); selector.computeTask.run(); containerQueuingLimit = calculator.createContainerQueuingLimit(); Assert.assertEquals(10, containerQueuingLimit.getMaxQueueLength()); Assert.assertEquals(-1, containerQueuingLimit.getMaxQueueWaitTimeInMs()); selector.updateNode(createRMNode("h6", 6, -1, 160)); selector.computeTask.run(); containerQueuingLimit = calculator.createContainerQueuingLimit(); Assert.assertEquals(100, containerQueuingLimit.getMaxQueueLength()); selector.updateNode(createRMNode("h6", 6, -1, 6)); selector.computeTask.run(); containerQueuingLimit = calculator.createContainerQueuingLimit(); Assert.assertEquals(6, containerQueuingLimit.getMaxQueueLength());