use of org.apache.tez.dag.api.SessionNotRunning in project hive by apache.
the class TezTask method submit.
DAGClient submit(JobConf conf, DAG dag, Path scratchDir, LocalResource appJarLr, TezSessionState sessionState, List<LocalResource> additionalLr, String[] inputOutputJars, Map<String, LocalResource> inputOutputLocalResources) throws Exception {
perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.TEZ_SUBMIT_DAG);
DAGClient dagClient = null;
Map<String, LocalResource> resourceMap = new HashMap<String, LocalResource>();
if (additionalLr != null) {
for (LocalResource lr : additionalLr) {
if (lr.getType() == LocalResourceType.FILE) {
// TEZ AM will only localize FILE (no script operators in the AM)
resourceMap.put(utils.getBaseName(lr), lr);
}
}
}
try {
try {
// ready to start execution on the cluster
sessionState.getSession().addAppMasterLocalFiles(resourceMap);
dagClient = sessionState.getSession().submitDAG(dag);
} catch (SessionNotRunning nr) {
console.printInfo("Tez session was closed. Reopening...");
// close the old one, but keep the tmp files around
// TODO Why is the session being create using a conf instance belonging to TezTask
// - instead of the session conf instance.
TezSessionPoolManager.getInstance().reopenSession(sessionState, this.conf, inputOutputJars, true);
console.printInfo("Session re-established.");
dagClient = sessionState.getSession().submitDAG(dag);
}
} catch (Exception e) {
// In case of any other exception, retry. If this also fails, report original error and exit.
try {
console.printInfo("Dag submit failed due to " + e.getMessage() + " stack trace: " + Arrays.toString(e.getStackTrace()) + " retrying...");
TezSessionPoolManager.getInstance().reopenSession(sessionState, this.conf, inputOutputJars, true);
dagClient = sessionState.getSession().submitDAG(dag);
} catch (Exception retryException) {
// we failed to submit after retrying. Destroy session and bail.
TezSessionPoolManager.getInstance().destroySession(sessionState);
throw retryException;
}
}
perfLogger.PerfLogEnd(CLASS_NAME, PerfLogger.TEZ_SUBMIT_DAG);
return new SyncDagClient(dagClient);
}
use of org.apache.tez.dag.api.SessionNotRunning in project hive by apache.
the class TezTask method submit.
DAGClient submit(JobConf conf, DAG dag, Ref<TezSessionState> sessionStateRef) throws Exception {
perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.TEZ_SUBMIT_DAG);
DAGClient dagClient = null;
TezSessionState sessionState = sessionStateRef.value;
try {
try {
// ready to start execution on the cluster
dagClient = sessionState.getSession().submitDAG(dag);
} catch (SessionNotRunning nr) {
console.printInfo("Tez session was closed. Reopening...");
sessionStateRef.value = null;
sessionStateRef.value = sessionState = getNewTezSessionOnError(sessionState);
console.printInfo("Session re-established.");
dagClient = sessionState.getSession().submitDAG(dag);
}
} catch (Exception e) {
// In case of any other exception, retry. If this also fails, report original error and exit.
try {
console.printInfo("Dag submit failed due to " + e.getMessage() + " stack trace: " + Arrays.toString(e.getStackTrace()) + " retrying...");
sessionStateRef.value = null;
sessionStateRef.value = sessionState = getNewTezSessionOnError(sessionState);
dagClient = sessionState.getSession().submitDAG(dag);
} catch (Exception retryException) {
// we failed to submit after retrying. Destroy session and bail.
sessionStateRef.value = null;
sessionState.destroy();
throw retryException;
}
}
perfLogger.PerfLogEnd(CLASS_NAME, PerfLogger.TEZ_SUBMIT_DAG);
return new SyncDagClient(dagClient);
}
use of org.apache.tez.dag.api.SessionNotRunning in project tez by apache.
the class TestTezJobs method testInvalidQueueSubmissionToSession.
@Test(timeout = 60000)
public void testInvalidQueueSubmissionToSession() throws Exception {
TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
YarnClient yarnClient = YarnClient.createYarnClient();
try {
yarnClient.init(mrrTezCluster.getConfig());
yarnClient.start();
SimpleSessionExample job = new SimpleSessionExample();
tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, true);
tezConf.set(TezConfiguration.TEZ_QUEUE_NAME, "nonexistent");
String[] inputPaths = new String[1];
String[] outputPaths = new String[1];
String inputDirStr = "/tmp/owc-input";
inputPaths[0] = inputDirStr;
Path inputDir = new Path(inputDirStr);
remoteFs.mkdirs(inputDir);
String outputDirStr = "/tmp/owc-output";
outputPaths[0] = outputDirStr;
job.run(tezConf, new String[] { StringUtils.join(",", inputPaths), StringUtils.join(",", outputPaths), "2" }, null);
fail("Job submission should have failed");
} catch (SessionNotRunning e) {
// Expected
LOG.info("Session not running", e);
} catch (TezException e) {
Assert.assertTrue(e.getMessage().contains("Failed to submit application"));
} finally {
if (yarnClient != null) {
yarnClient.stop();
}
}
}
use of org.apache.tez.dag.api.SessionNotRunning in project hive by apache.
the class TestTezTask method setUp.
@Before
public void setUp() throws Exception {
utils = mock(DagUtils.class);
fs = mock(FileSystem.class);
path = mock(Path.class);
when(path.getFileSystem(any())).thenReturn(fs);
when(utils.getTezDir(any())).thenReturn(path);
when(utils.createVertex(any(), any(BaseWork.class), any(Path.class), any(TezWork.class), anyMap())).thenAnswer(new Answer<Vertex>() {
@Override
public Vertex answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
return Vertex.create(((BaseWork) args[1]).getName(), mock(ProcessorDescriptor.class), 0, mock(Resource.class));
}
});
when(utils.createEdge(any(), any(Vertex.class), any(Vertex.class), any(TezEdgeProperty.class), any(BaseWork.class), any(TezWork.class))).thenAnswer(new Answer<Edge>() {
@Override
public Edge answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
return Edge.create((Vertex) args[1], (Vertex) args[2], mock(EdgeProperty.class));
}
});
work = new TezWork("", null);
mws = new MapWork[] { new MapWork(), new MapWork() };
rws = new ReduceWork[] { new ReduceWork(), new ReduceWork() };
work.addAll(mws);
work.addAll(rws);
int i = 0;
for (BaseWork w : work.getAllWork()) {
w.setName("Work " + (++i));
}
op = mock(Operator.class);
Map<String, Operator<? extends OperatorDesc>> map = new LinkedHashMap<String, Operator<? extends OperatorDesc>>();
map.put("foo", op);
mws[0].setAliasToWork(map);
mws[1].setAliasToWork(map);
Map<Path, List<String>> pathMap = new LinkedHashMap<>();
List<String> aliasList = new ArrayList<String>();
aliasList.add("foo");
pathMap.put(new Path("foo"), aliasList);
mws[0].setPathToAliases(pathMap);
mws[1].setPathToAliases(pathMap);
rws[0].setReducer(op);
rws[1].setReducer(op);
TezEdgeProperty edgeProp = new TezEdgeProperty(EdgeType.SIMPLE_EDGE);
work.connect(mws[0], rws[0], edgeProp);
work.connect(mws[1], rws[0], edgeProp);
work.connect(rws[0], rws[1], edgeProp);
task = new TezTask(utils);
task.setWork(work);
task.setConsole(mock(LogHelper.class));
QueryPlan mockQueryPlan = mock(QueryPlan.class);
doReturn(UUID.randomUUID().toString()).when(mockQueryPlan).getQueryId();
task.setQueryPlan(mockQueryPlan);
conf = new JobConf();
appLr = createResource("foo.jar");
HiveConf hiveConf = new HiveConf();
hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
SessionState.start(hiveConf);
session = mock(TezClient.class);
sessionState = mock(TezSessionState.class);
when(sessionState.getSession()).thenReturn(session);
when(sessionState.reopen()).thenReturn(sessionState);
when(session.submitDAG(any(DAG.class))).thenThrow(new SessionNotRunning("")).thenReturn(mock(DAGClient.class));
}
use of org.apache.tez.dag.api.SessionNotRunning in project tez by apache.
the class TezClientUtils method getAMProxy.
static DAGClientAMProtocolBlockingPB getAMProxy(FrameworkClient yarnClient, Configuration conf, ApplicationId applicationId) throws TezException, IOException {
ApplicationReport appReport;
try {
appReport = yarnClient.getApplicationReport(applicationId);
if (appReport == null) {
throw new TezUncheckedException("Could not retrieve application report" + " from YARN, applicationId=" + applicationId);
}
YarnApplicationState appState = appReport.getYarnApplicationState();
if (appState != YarnApplicationState.RUNNING) {
if (appState == YarnApplicationState.FINISHED || appState == YarnApplicationState.KILLED || appState == YarnApplicationState.FAILED) {
String msg = "Application not running" + ", applicationId=" + applicationId + ", yarnApplicationState=" + appReport.getYarnApplicationState() + ", finalApplicationStatus=" + appReport.getFinalApplicationStatus() + ", trackingUrl=" + appReport.getTrackingUrl() + ", diagnostics=" + (appReport.getDiagnostics() != null ? appReport.getDiagnostics() : TezClient.NO_CLUSTER_DIAGNOSTICS_MSG);
LOG.info(msg);
throw new SessionNotRunning(msg);
}
return null;
}
} catch (ApplicationNotFoundException e) {
throw new SessionNotRunning(e);
} catch (YarnException e) {
throw new TezException(e);
}
return getAMProxy(conf, appReport.getHost(), appReport.getRpcPort(), appReport.getClientToAMToken());
}
Aggregations