private void dumpPoolState(PoolState ps, List<String> set) { StringBuilder sb = new StringBuilder(); sb.append("POOL ").append(ps.fullName).append(": qp ").append(ps.queryParallelism) .append(", %% ").append(ps.finalFraction).append(", sessions: ").append(ps.sessions.size()) .append(", initializing: ").append(ps.initializingSessions.size()).append(", queued: ") .append(ps.queue.size()); set.add(sb.toString()); sb.setLength(0); for (WmTezSession session : ps.sessions) { double cf = session.hasClusterFraction() ? session.getClusterFraction() : 0; sb.append("RUNNING: ").append(cf).append(" (") .append(session.getAllocationState()) .append(") => ").append(session.getSessionId()); set.add(sb.toString()); sb.setLength(0); } for (SessionInitContext session : ps.initializingSessions) { sb.append("INITIALIZING: state ").append(session.state); set.add(sb.toString()); sb.setLength(0); } for (GetRequest session : ps.queue) { sb.append("QUEUED: from ").append(session.mappingInput); set.add(sb.toString()); sb.setLength(0); } }
WmTezSessionInfo(WmTezSession wmTezSession) { this.poolName = wmTezSession.getPoolName(); this.sessionId = wmTezSession.getSessionId(); this.clusterPercent = wmTezSession.hasClusterFraction() ? wmTezSession.getClusterFraction() * 100.0 : 0; }
assert session.hasClusterFraction(); double fraction = session.getClusterFraction(); double allocation = fraction * totalCount + lastDelta;
private void updateSessionAllocationWithEvent(WmTezSession session, double allocation) { WmEvent event = null; WmContext ctx = session.getWmContext(); if (ctx != null && session.hasClusterFraction() && !DoubleMath.fuzzyEquals(session.getClusterFraction(), allocation, 0.0001f)) { event = new WmEvent(EventType.UPDATE); } session.setClusterFraction(allocation); if (event != null) { event.endEvent(session); } }
private void assertKilledByWm(WmTezSession session) { assertNull(session.getPoolName()); assertFalse(session.hasClusterFraction()); assertTrue(session.isIrrelevantForWm()); }
assertEquals(0, allSessionProviders.get("B.y").getSessions().size()); assertEquals(0, allSessionProviders.get("C").getSessions().size()); assertFalse(sessionA1.hasClusterFraction()); assertFalse(allSessionProviders.get("A").getSessions().contains(sessionA1));
@Test(timeout = 10000) public void testReopen() throws Exception { // We should always get a different object, and cluster fraction should be propagated. HiveConf conf = createConf(); MockQam qam = new MockQam(); WorkloadManager wm = new WorkloadManagerForTest("test", conf, 1, qam); wm.start(); WmTezSession session = (WmTezSession) wm.getSession( null, mappingInput("user"), conf); assertEquals(1.0, session.getClusterFraction(), EPSILON); qam.assertWasCalledAndReset(); WmTezSession session2 = (WmTezSession) session.reopen(); assertNotSame(session, session2); wm.addTestEvent().get(); assertEquals(session2.toString(), 1.0, session2.getClusterFraction(), EPSILON); assertFalse(session.hasClusterFraction()); qam.assertWasCalledAndReset(); }
@Test(timeout = 10000) public void testDestroyAndReturn() throws Exception { // Session should not be lost; however the fraction should be discarded. HiveConf conf = createConf(); MockQam qam = new MockQam(); WorkloadManager wm = new WorkloadManagerForTest("test", conf, 2, qam); wm.start(); WmTezSession session = (WmTezSession) wm.getSession(null, mappingInput("user"), conf); assertEquals(1.0, session.getClusterFraction(), EPSILON); qam.assertWasCalledAndReset(); WmTezSession session2 = (WmTezSession) wm.getSession(null, mappingInput("user"), conf); assertEquals(0.5, session.getClusterFraction(), EPSILON); assertEquals(0.5, session2.getClusterFraction(), EPSILON); qam.assertWasCalledAndReset(); assertNotSame(session, session2); session.destroy(); // Destroy before returning to the pool. assertEquals(1.0, session2.getClusterFraction(), EPSILON); assertFalse(session.hasClusterFraction()); qam.assertWasCalledAndReset(); // We never lose pool session, so we should still be able to get. session = (WmTezSession) wm.getSession(null, mappingInput("user"), conf); session.returnToSessionManager(); assertEquals(1.0, session2.getClusterFraction(), EPSILON); assertFalse(session.hasClusterFraction()); qam.assertWasCalledAndReset(); }