private void waitNonSessionTillReady() throws IOException, TezException { Preconditions.checkArgument(!isSession, "It is supposed to be only called in non-session mode"); while (true) { TezAppMasterStatus status = getAppMasterStatus(); // DAGClient will handle the AM SHUTDOWN case if (status.equals(TezAppMasterStatus.RUNNING) || status.equals(TezAppMasterStatus.SHUTDOWN)) { return; } try { Thread.sleep(SLEEP_FOR_READY); } catch (InterruptedException e) { throw new TezException("TezClient is interrupted"); } } } @VisibleForTesting
String timeStamp = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); if (session.getAppMasterStatus().equals( TezAppMasterStatus.SHUTDOWN)) { log.info("Tez session is already shutdown "
synchronized (sessionInfo) { TezAppMasterStatus appMasterStatus = sessionInfo.session .getAppMasterStatus(); if (appMasterStatus.equals(TezAppMasterStatus.SHUTDOWN)) { sessionsToRemove.add(sessionInfo);
long timeLimit = startTime + timeout; while (true) { TezAppMasterStatus status = getAppMasterStatus(); if (status.equals(TezAppMasterStatus.SHUTDOWN)) { throw new SessionNotRunning("TezSession has already shutdown. "
private static SessionInfo createSession(TezConfiguration amConf, Map<String, LocalResource> requestedAMResources, Credentials creds, TezJobConfig tezJobConf) throws TezException, IOException, InterruptedException { MRToTezHelper.translateMRSettingsForTezAM(amConf); TezScriptState ss = TezScriptState.get(); ss.addDAGSettingsToConf(amConf); if (amConf.getBoolean(PigConfiguration.PIG_TEZ_CONFIGURE_AM_MEMORY, true)) { adjustAMConfig(amConf, tezJobConf); } String jobName = amConf.get(PigContext.JOB_NAME, "pig"); TezClient tezClient = TezClient.create(jobName, amConf, true, requestedAMResources, creds); try { tezClient.start(); TezAppMasterStatus appMasterStatus = tezClient.getAppMasterStatus(); if (appMasterStatus.equals(TezAppMasterStatus.SHUTDOWN)) { throw new RuntimeException("TezSession has already shutdown"); } tezClient.waitTillReady(); } catch (Throwable e) { log.error("Exception while waiting for Tez client to be ready", e); tezClient.stop(); throw new RuntimeException(e); } return new SessionInfo(tezClient, amConf, requestedAMResources); }