@Override public void run() { while (true) { // This should not start the actual Tez AM. SessionState ss = DriverUtils.setUpSessionState(conf, user, false); // Wait for the first item to arrive at the queue and process it. try { runOneWorkerIteration(ss, user, conf, true); } catch (InterruptedException e) { closeSession(ss); LOG.info("Worker thread was interrupted and will now exit"); return; } // Keep draining the queue in the same session. try { while (runOneWorkerIteration(ss, user, conf, false)) {} } catch (InterruptedException e) { closeSession(ss); LOG.info("Worker thread was interrupted unexpectedly and will now exit"); return; }; // Close the session before we have to wait again. closeSession(ss); SessionState.detachSession(); } } }
private void drainWorkQueue(StatsUpdaterThread su) throws InterruptedException { while (su.runOneWorkerIteration(ss, ss.getUserName(), ss.getConf(), false)) {} }
private void drainWorkQueue(StatsUpdaterThread su, int expectedReqs) throws InterruptedException { int actualReqs = 0; while (su.runOneWorkerIteration(ss, ss.getUserName(), ss.getConf(), false)) { ++actualReqs; } assertEquals(expectedReqs, actualReqs); }