@Override public void returnAfterUse(TezSessionPoolSession session) throws Exception { returnSession(session); }
public void returnToSessionManager() throws Exception { // By default, TezSessionPoolManager handles this for both pool and non-pool session. TezSessionPoolManager.getInstance().returnSession(this); }
@Override public void run() { try { HiveConf tmpConf = new HiveConf(conf); if (random.nextDouble() > 0.5) { tmpConf.set("tez.queue.name", "default"); } else { tmpConf.set("tez.queue.name", ""); } TezSessionState session = poolManager.getSession(null, tmpConf, true, llap); Thread.sleep((random.nextInt(9) % 10) * 1000); session.setLegacyLlapMode(llap); poolManager.returnSession(session); } catch (Exception e) { e.printStackTrace(); } } }
poolManager.returnSession(sessionState); poolManager.returnSession(sessionState); assertEquals("a", first.getQueueName()); assertEquals("b", second.getQueueName()); poolManager.returnSession(first); poolManager.returnSession(second); TezSessionState third = poolManager.getSession(null, conf, true, false); assertEquals("b", third.getQueueName()); poolManager.returnSession(third); assertEquals("c", third.getQueueName()); poolManager.returnSession(first); poolManager.returnSession(second); poolManager.returnSession(third); poolManager.returnSession(first);
@Test public void testSessionPoolThreads() { // Make sure we get a correct number of sessions in each queue and that we don't crash. try { conf.setBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS, false); conf.setVar(ConfVars.HIVE_SERVER2_TEZ_DEFAULT_QUEUES, "0,1,2"); conf.setIntVar(ConfVars.HIVE_SERVER2_TEZ_SESSIONS_PER_DEFAULT_QUEUE, 4); conf.setIntVar(ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS, 16); poolManager = new TestTezSessionPoolManager(); poolManager.setupPool(conf); poolManager.startPool(conf, null); TezSessionState[] sessions = new TezSessionState[12]; int[] queueCounts = new int[3]; for (int i = 0; i < sessions.length; ++i) { sessions[i] = poolManager.getSession(null, conf, true, false); queueCounts[Integer.parseInt(sessions[i].getQueueName())] += 1; } for (int i = 0; i < queueCounts.length; ++i) { assertEquals(4, queueCounts[i]); } for (int i = 0; i < sessions.length; ++i) { poolManager.returnSession(sessions[i]); } } catch (Exception e) { e.printStackTrace(); fail(); } }
.returnSession(session, getWork().getLlapMode()); } catch (Exception e) { LOG.error("Failed to return session: {} to pool", session, e);
TezSessionPoolManager.getInstance().returnSession(session);