JobExecutionStatus state = sparkJobStatus.getState(); if (LOG.isDebugEnabled()) { console.printInfo("state = " + state); Map<SparkStage, SparkStageProgress> progressMap = sparkJobStatus.getSparkStageProgress(); + sparkJobStatus.getJobId() + "] stages:"); for (int stageId : sparkJobStatus.getStageIds()) { console.printInfo(Integer.toString(stageId)); + sparkJobStatus.getJobId() + "])"); running = true; msg = "Failed to monitor Job[ " + sparkJobStatus.getJobId() + "]" + msg; rc = 1; done = true; sparkJobStatus.setMonitorError(e); } finally { if (done) {
Throwable sparkJobException = sparkJobStatus.getSparkJobException(); if (sparkJobException != null) { HiveException he; Throwable monitorError = sparkJobStatus.getMonitorError(); if (monitorError != null) { if ((monitorError instanceof InterruptedException) ||
private void getSparkJobInfo(SparkJobStatus sparkJobStatus) { try { stageIds = new ArrayList<Integer>(); int[] ids = sparkJobStatus.getStageIds(); if (ids != null) { for (int stageId : ids) { stageIds.add(stageId); } } Map<SparkStage, SparkStageProgress> progressMap = sparkJobStatus.getSparkStageProgress(); int sumTotal = 0; int sumComplete = 0; int sumFailed = 0; for (SparkStage s : progressMap.keySet()) { SparkStageProgress progress = progressMap.get(s); final int complete = progress.getSucceededTaskCount(); final int total = progress.getTotalTaskCount(); final int failed = progress.getFailedTaskCount(); sumTotal += total; sumComplete += complete; sumFailed += failed; } succeededTaskCount = sumComplete; totalTaskCount = sumTotal; failedTaskCount = sumFailed; } catch (Exception e) { LOG.error("Failed to get Spark job information", e); } }
private void getSparkJobInfo(SparkJobStatus sparkJobStatus, int rc) { try { stageIds = new ArrayList<Integer>(); int[] ids = sparkJobStatus.getStageIds(); if (ids != null) { for (int stageId : ids) { Map<String, SparkStageProgress> progressMap = sparkJobStatus.getSparkStageProgress(); int sumTotal = 0; int sumComplete = 0; failedTaskCount = sumFailed; if (rc != 0) { Throwable error = sparkJobStatus.getError(); if (error != null) { setException(error);
jobID = jobRef.getSparkJobStatus().getAppID(); sparkJobID = jobRef.getSparkJobStatus().getJobId(); sparkStatistics = sparkJobStatus.getSparkStatistics(); if (SessionState.get() != null) { SparkCounters counters = sparkJobStatus.getCounter(); if (counters != null) { SparkCounter counter = counters.getCounter(HiveConf.getVar(conf, HiveConf.ConfVars.HIVECOUNTERGROUP), this.jobID = sparkJobStatus.getAppID(); sparkJobStatus.cleanup(); } catch (Exception e) { LOG.error("Failed to execute Spark task \"" + getId() + "\"", e);
this.jobID = jobRef.getSparkJobStatus().getAppID(); rc = jobRef.monitorJob(); SparkJobStatus sparkJobStatus = jobRef.getSparkJobStatus(); getSparkJobInfo(sparkJobStatus, rc); if (rc == 0) { sparkStatistics = sparkJobStatus.getSparkStatistics(); if (LOG.isInfoEnabled() && sparkStatistics != null) { LOG.info(String.format("=====Spark Job[%s] statistics=====", jobRef.getJobId())); this.jobID = sparkJobStatus.getAppID(); sparkJobStatus.cleanup(); } catch (Exception e) { String msg = "Failed to execute spark task, with exception '" + Utilities.getNameMessage(e) + "'";
SparkJobStatus sparkJobStatus = jobRef.getSparkJobStatus(); if (rc == 0) { sparkCounters = sparkJobStatus.getCounter(); SparkStatistics sparkStatistics = sparkJobStatus.getSparkStatistics(); if (LOG.isInfoEnabled() && sparkStatistics != null) { LOG.info(String.format("=====Spark Job[%s] statistics=====", jobRef.getJobId())); jobRef.cancelJob(); sparkJobStatus.cleanup(); } catch (Exception e) { String msg = "Failed to execute spark task, with exception '" + Utilities.getNameMessage(e) + "'";
@Test public void testSetSparkExceptionWithOOMError() { SparkTask sparkTask = new SparkTask(); SparkJobStatus mockSparkJobStatus = mock(SparkJobStatus.class); ExecutionException jobError = new ExecutionException( new SparkException("Container killed by YARN for exceeding memory limits")); when(mockSparkJobStatus.getSparkJobException()).thenReturn(jobError); sparkTask.setSparkException(mockSparkJobStatus, 3); Assert.assertTrue(sparkTask.getException() instanceof HiveException); Assert.assertEquals(((HiveException) sparkTask.getException()).getCanonicalErrorMsg(), ErrorMsg.SPARK_RUNTIME_OOM); }
@Test public void testHandleInterruptedException() throws Exception { HiveConf hiveConf = new HiveConf(); SparkTask sparkTask = new SparkTask(); sparkTask.setWork(mock(SparkWork.class)); DriverContext mockDriverContext = mock(DriverContext.class); QueryState mockQueryState = mock(QueryState.class); when(mockQueryState.getConf()).thenReturn(hiveConf); sparkTask.initialize(mockQueryState, null, mockDriverContext, null); SparkJobStatus mockSparkJobStatus = mock(SparkJobStatus.class); when(mockSparkJobStatus.getMonitorError()).thenReturn(new InterruptedException()); SparkSession mockSparkSession = mock(SparkSession.class); SparkJobRef mockSparkJobRef = mock(SparkJobRef.class); when(mockSparkJobRef.monitorJob()).thenReturn(2); when(mockSparkJobRef.getSparkJobStatus()).thenReturn(mockSparkJobStatus); when(mockSparkSession.submit(any(), any())).thenReturn(mockSparkJobRef); SessionState.start(hiveConf); SessionState.get().setSparkSession(mockSparkSession); sparkTask.execute(mockDriverContext); verify(mockSparkJobRef, atLeastOnce()).cancelJob(); when(mockSparkJobStatus.getMonitorError()).thenReturn( new HiveException(new InterruptedException())); sparkTask.execute(mockDriverContext); verify(mockSparkJobRef, atLeastOnce()).cancelJob(); }
@Test public void testSetSparkExceptionWithJobError() { SparkTask sparkTask = new SparkTask(); SparkJobStatus mockSparkJobStatus = mock(SparkJobStatus.class); ExecutionException ee = new ExecutionException("Exception thrown by job", new SparkException("Job aborted due to stage failure: Not a task or OOM error")); when(mockSparkJobStatus.getSparkJobException()).thenReturn(ee); sparkTask.setSparkException(mockSparkJobStatus, 3); Assert.assertTrue(sparkTask.getException() instanceof HiveException); Assert.assertEquals(((HiveException) sparkTask.getException()).getCanonicalErrorMsg(), ErrorMsg.SPARK_JOB_RUNTIME_ERROR); Assert.assertTrue(sparkTask.getException().getMessage().contains("Not a task or OOM error")); }
@Test public void testSetSparkExceptionWithTimeoutError() { SparkTask sparkTask = new SparkTask(); SparkJobStatus mockSparkJobStatus = mock(SparkJobStatus.class); when(mockSparkJobStatus.getMonitorError()).thenReturn(new HiveException(ErrorMsg .SPARK_JOB_MONITOR_TIMEOUT, Long.toString(60))); sparkTask.setSparkException(mockSparkJobStatus, 3); Assert.assertTrue(sparkTask.getException() instanceof HiveException); Assert.assertEquals(((HiveException) sparkTask.getException()).getCanonicalErrorMsg(), ErrorMsg.SPARK_JOB_MONITOR_TIMEOUT); Assert.assertTrue(sparkTask.getException().getMessage().contains("60s")); }
JobExecutionStatus state = sparkJobStatus.getState(); if (LOG.isDebugEnabled()) { console.printInfo("state = " + state); Map<String, SparkStageProgress> progressMap = sparkJobStatus.getSparkStageProgress(); + sparkJobStatus.getJobId() + "] stages:"); for (int stageId : sparkJobStatus.getStageIds()) { console.printInfo(Integer.toString(stageId)); + sparkJobStatus.getJobId() + "])"); running = true; msg = "Failed to monitor Job[ " + sparkJobStatus.getJobId() + "]" + msg; rc = 1; done = true; sparkJobStatus.setError(e); } finally { if (done) {
@Test public void testSparkExceptionAndMonitorError() { SparkTask sparkTask = new SparkTask(); SparkJobStatus mockSparkJobStatus = mock(SparkJobStatus.class); when(mockSparkJobStatus.getMonitorError()).thenReturn(new RuntimeException()); when(mockSparkJobStatus.getSparkJobException()).thenReturn( new ExecutionException(new SparkException(""))); sparkTask.setSparkException(mockSparkJobStatus, 3); Assert.assertTrue(sparkTask.getException() instanceof HiveException); Assert.assertEquals(((HiveException) sparkTask.getException()).getCanonicalErrorMsg(), ErrorMsg.SPARK_JOB_RUNTIME_ERROR); }
JobExecutionStatus state = sparkJobStatus.getState(); if (LOG.isDebugEnabled()) { console.printInfo("state = " + state); Map<String, SparkStageProgress> progressMap = sparkJobStatus.getSparkStageProgress(); + sparkJobStatus.getJobId() + "] stages:"); for (int stageId : sparkJobStatus.getStageIds()) { console.printInfo(Integer.toString(stageId)); + sparkJobStatus.getJobId() + "])"); running = true; msg = "Failed to monitor Job[ " + sparkJobStatus.getJobId() + "]" + msg;