@Override public void run() { while (!Thread.currentThread().isInterrupted()) { try { continuousSchedulingAttempt(); Thread.sleep(getContinuousSchedulingSleepMs()); } catch (InterruptedException e) { LOG.warn("Continuous scheduling thread interrupted. Exiting.", e); return; } } } }
@Override public void run() { while (!Thread.currentThread().isInterrupted()) { try { continuousSchedulingAttempt(); Thread.sleep(getContinuousSchedulingSleepMs()); } catch (InterruptedException e) { LOG.warn("Continuous scheduling thread interrupted. Exiting.", e); return; } } } }
@Override public void run() { while (!Thread.currentThread().isInterrupted()) { try { continuousSchedulingAttempt(); Thread.sleep(getContinuousSchedulingSleepMs()); } catch (InterruptedException e) { LOG.warn("Continuous scheduling thread interrupted. Exiting.", e); return; } } } }
@SuppressWarnings("deprecation") @Test public void TestNodeAvailableResourceComparatorTransitivity() { ClusterNodeTracker<FSSchedulerNode> clusterNodeTracker = scheduler.getNodeTracker(); List<RMNode> rmNodes = MockNodes.newNodes(2, 4000, Resource.newInstance(4096, 4)); for (RMNode rmNode : rmNodes) { clusterNodeTracker.addNode(new FSSchedulerNode(rmNode, false)); } // To simulate unallocated resource changes new Thread() { @Override public void run() { for (int j = 0; j < 100; j++) { for (FSSchedulerNode node : clusterNodeTracker.getAllNodes()) { int i = ThreadLocalRandom.current().nextInt(-30, 30); synchronized (scheduler) { node.deductUnallocatedResource(Resource.newInstance(i * 1024, i)); } } } } }.start(); try { scheduler.continuousSchedulingAttempt(); } catch (Exception e) { fail(e.getMessage()); } }
@Test public void testContinuousSchedulingInterruptedException() throws Exception { scheduler.init(conf); scheduler.start(); FairScheduler spyScheduler = spy(scheduler); Assert.assertTrue("Continuous scheduling should be disabled.", !spyScheduler.isContinuousSchedulingEnabled()); // Add one nodes RMNode node1 = MockNodes.newNodeInfo(1, Resources.createResource(8 * 1024, 8), 1, "127.0.0.1"); NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1); spyScheduler.handle(nodeEvent1); Assert.assertEquals("We should have one alive node.", 1, spyScheduler.getNumClusterNodes()); InterruptedException ie = new InterruptedException(); doThrow(new YarnRuntimeException(ie)).when(spyScheduler). attemptScheduling(isA(FSSchedulerNode.class)); // Invoke the continuous scheduling once try { spyScheduler.continuousSchedulingAttempt(); fail("Expected InterruptedException to stop schedulingThread"); } catch (InterruptedException e) { Assert.assertEquals(ie, e); } }
spyScheduler.continuousSchedulingAttempt(); fail("Expected InterruptedException to stop schedulingThread"); } catch (InterruptedException e) {
scheduler.continuousSchedulingAttempt(); } catch (Exception e) { fail("Exception happened when doing continuous scheduling. " +
scheduler.continuousSchedulingAttempt(); } catch (Exception e) { fail("Exception happened when doing continuous scheduling. " +