org.apache.tez.dag.api.client.DAGStatus Java Examples

The following examples show how to use org.apache.tez.dag.api.client.DAGStatus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestLocalMode.java    From tez with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 20000)
public void testNoSysExitOnFailinglDAG() throws TezException, InterruptedException,
    IOException {
  TezConfiguration tezConf1 = createConf();
  // Run in non-session mode so that the AM terminates
  TezClient tezClient1 = TezClient.create("commonName", tezConf1, false);
  tezClient1.start();

  DAG dag1 = createSimpleDAG("dag1", FailingProcessor.class.getName());

  DAGClient dagClient1 = tezClient1.submitDAG(dag1);
  dagClient1.waitForCompletion();
  assertEquals(DAGStatus.State.FAILED, dagClient1.getDAGStatus(null).getState());

  // Sleep for more time than is required for the DAG to complete.
  Thread.sleep((long) (TezConstants.TEZ_DAG_SLEEP_TIME_BEFORE_EXIT * 1.5));

  dagClient1.close();
  tezClient1.stop();
}
 
Example #2
Source File: TestFaultTolerance.java    From tez with Apache License 2.0 6 votes vote down vote up
@Test (timeout=60000)
public void testBasicInputFailureWithoutExitDeadline() throws Exception {
  Configuration testConf = new Configuration(false);
  testConf.setInt(SimpleTestDAG.TEZ_SIMPLE_DAG_NUM_TASKS, 3); // 1 error < 0.4 fail fraction
  testConf.setBoolean(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_DO_FAIL, "v2"), true);
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_INDEX, "v2"), "2");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_ATTEMPT, "v2"), "0");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_INPUT_INDEX, "v2"), "0");
  
  DAG dag = SimpleTestDAG.createDAG("testBasicInputFailureWithoutExitDeadline", testConf);
  runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
 
Example #3
Source File: TestAnalyzer.java    From tez with Apache License 2.0 6 votes vote down vote up
/**
 * Test cascading input failure with exit. Expecting success.
 * v1 -- v2 -- v3
 * v3 all-tasks attempt0 input0 fails. v3 attempt0 exits. Triggering v2 rerun.
 * v2 task0 attempt1 input0 fails. v2 attempt1 exits. Triggering v1 rerun.
 * v1 attempt1 rerun and succeeds. v2 accepts v1 attempt1 output. v2 attempt2 succeeds.
 * v3 attempt1 accepts v2 attempt2 output.
 * 
 * AM vertex succeeded order is v1, v2, v3, v1, v2, v3.
 * @throws Exception
 */
private List<StepCheck[]> testCascadingInputFailureWithExitSuccess() throws Exception {
  Configuration testConf = new Configuration(false);
  setCascadingInputFailureConfig(testConf, true, 1);
  
  StepCheck[] check = {
      createStep("v1 : 000000_0", CriticalPathDependency.INIT_DEPENDENCY),
      createStep("v2 : 000000_0", CriticalPathDependency.DATA_DEPENDENCY),
      createStep("v3 : 000000_0", CriticalPathDependency.DATA_DEPENDENCY),
      createStep("v2 : 000000_1", CriticalPathDependency.OUTPUT_RECREATE_DEPENDENCY),
      createStep("v1 : 000000_1", CriticalPathDependency.OUTPUT_RECREATE_DEPENDENCY),
      createStep("v2 : 000000_2", CriticalPathDependency.DATA_DEPENDENCY),
      createStep("v3 : 000000_1", CriticalPathDependency.DATA_DEPENDENCY),
    };

  DAG dag = SimpleTestDAG3Vertices.createDAG(
            "testCascadingInputFailureWithExitSuccess", testConf);
  runDAG(dag, DAGStatus.State.SUCCEEDED);
  return Collections.singletonList(check);
}
 
Example #4
Source File: TestLocalMode.java    From tez with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 20000)
public void testNoSysExitOnSuccessfulDAG() throws TezException, InterruptedException,
    IOException {
  TezConfiguration tezConf1 = createConf();
  // Run in non-session mode so that the AM terminates
  TezClient tezClient1 = TezClient.create("commonName", tezConf1, false);
  tezClient1.start();

  DAG dag1 = createSimpleDAG("dag1", SleepProcessor.class.getName());

  DAGClient dagClient1 = tezClient1.submitDAG(dag1);
  dagClient1.waitForCompletion();
  assertEquals(DAGStatus.State.SUCCEEDED, dagClient1.getDAGStatus(null).getState());

  // Sleep for more time than is required for the DAG to complete.
  Thread.sleep((long) (TezConstants.TEZ_DAG_SLEEP_TIME_BEFORE_EXIT * 1.5));

  dagClient1.close();
  tezClient1.stop();
}
 
Example #5
Source File: TestAnalyzer.java    From tez with Apache License 2.0 6 votes vote down vote up
private List<StepCheck[]> testBasicInputFailureWithExit() throws Exception {
  Configuration testConf = new Configuration(false);
  testConf.setInt(SimpleTestDAG.TEZ_SIMPLE_DAG_NUM_TASKS, 1);
  testConf.setBoolean(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_DO_FAIL, "v2"), true);
  testConf.setBoolean(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_DO_FAIL_AND_EXIT, "v2"), true);
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_INDEX, "v2"), "0");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_ATTEMPT, "v2"), "0");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_INPUT_INDEX, "v2"), "0");

  StepCheck[] check = {
      createStep("v1 : 000000_0", CriticalPathDependency.INIT_DEPENDENCY),
      createStep("v2 : 000000_0", CriticalPathDependency.DATA_DEPENDENCY),
      createStep("v1 : 000000_1", CriticalPathDependency.OUTPUT_RECREATE_DEPENDENCY),
      createStep("v2 : 000000_1", CriticalPathDependency.DATA_DEPENDENCY),
    };
  
  DAG dag = SimpleTestDAG.createDAG("testBasicInputFailureWithExit", testConf);
  runDAG(dag, DAGStatus.State.SUCCEEDED);
  return Collections.singletonList(check);
}
 
Example #6
Source File: TestAnalyzer.java    From tez with Apache License 2.0 6 votes vote down vote up
/**
 * Downstream(v3) attempt failure of a vertex connected with 
 * 2 upstream vertices.. 
 *   v1  v2
 *    \ /
 *    v3
 * 
 * @throws Exception
 */
private List<StepCheck[]> testAttemptOfDownstreamVertexConnectedWithTwoUpstreamVerticesFailure() 
    throws Exception {
  Configuration testConf = new Configuration(false);
  testConf.setInt(SimpleVTestDAG.TEZ_SIMPLE_V_DAG_NUM_TASKS, 1);
  testConf.setBoolean(TestProcessor.getVertexConfName(
      TestProcessor.TEZ_FAILING_PROCESSOR_DO_FAIL, "v3"), true);
  testConf.set(TestProcessor.getVertexConfName(
      TestProcessor.TEZ_FAILING_PROCESSOR_FAILING_TASK_INDEX, "v3"), "0");
  testConf.setInt(TestProcessor.getVertexConfName(
      TestProcessor.TEZ_FAILING_PROCESSOR_FAILING_UPTO_TASK_ATTEMPT, "v3"), 1);
  
  StepCheck[] check = {
      // use regex for either vertices being possible on the path
      createStep("v[12] : 000000_0", CriticalPathDependency.INIT_DEPENDENCY),
      createStep("v3 : 000000_0", CriticalPathDependency.DATA_DEPENDENCY),
      createStep("v3 : 000000_1", CriticalPathDependency.RETRY_DEPENDENCY),
      createStep("v3 : 000000_2", CriticalPathDependency.RETRY_DEPENDENCY),
    };

  DAG dag = SimpleVTestDAG.createDAG(
          "testAttemptOfDownstreamVertexConnectedWithTwoUpstreamVerticesFailure", testConf);
  runDAG(dag, DAGStatus.State.SUCCEEDED);
  return Collections.singletonList(check);
}
 
Example #7
Source File: TestFaultTolerance.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
@Test (timeout=60000)
public void testBasicInputFailureWithoutExit() throws Exception {
  Configuration testConf = new Configuration(false);
  testConf.setBoolean(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_DO_FAIL, "v2"), true);
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_INDEX, "v2"), "1");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_ATTEMPT, "v2"), "0");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_INPUT_INDEX, "v2"), "0");
  
  testConf.set(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_TASK_INDEX, "v2"), "0,1");
  testConf.setInt(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_VALUE, "v2", 1), 4);
  testConf.setInt(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_VALUE, "v2", 0), 3);
  DAG dag = SimpleTestDAG.createDAG("testBasicInputFailureWithoutExit", testConf);
  runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
 
Example #8
Source File: DAGClientRPCImpl.java    From tez with Apache License 2.0 6 votes vote down vote up
DAGStatus getDAGStatusViaAM(Set<StatusGetOpts> statusOptions, long timeout)
    throws IOException, TezException {
  if(LOG.isDebugEnabled()) {
    LOG.debug("GetDAGStatus via AM for app: " + appId + " dag:" + dagId);
  }
  GetDAGStatusRequestProto.Builder requestProtoBuilder =
      GetDAGStatusRequestProto.newBuilder()
        .setDagId(dagId).setTimeout(timeout);

  if (statusOptions != null) {
    requestProtoBuilder.addAllStatusOptions(
      DagTypeConverters.convertStatusGetOptsToProto(statusOptions));
  }

  try {
    return new DAGStatus(
      proxy.getDAGStatus(null,
        requestProtoBuilder.build()).getDagStatus(), DagStatusSource.AM);
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    // Should not reach here
    throw new TezException(e);
  }
}
 
Example #9
Source File: TestAMRecovery.java    From tez with Apache License 2.0 6 votes vote down vote up
/**
 * Fine-grained recovery task-level, In a vertex (v1), task 0 is done task 1
 * is not started. History flush happens. AM dies. Once AM is recovered, task 0 is
 * not re-run. Task 1 is re-run. (ONE_TO_ONE)
 *
 * @throws Exception
 */
@Test(timeout = 120000)
public void testVertexPartialFinished_One2One() throws Exception {
  DAG dag =
      createDAG("VertexPartialFinished_One2One", ControlledInputReadyVertexManager.class,
          DataMovementType.ONE_TO_ONE, true);
  TezCounters counters = runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
  assertEquals(4, counters.findCounter(DAGCounter.NUM_SUCCEEDED_TASKS).getValue());
  assertEquals(2, counters.findCounter(TestCounter.Counter_1).getValue());

  List<HistoryEvent> historyEvents1 = readRecoveryLog(1);
  List<HistoryEvent> historyEvents2 = readRecoveryLog(2);
  printHistoryEvents(historyEvents1, 1);
  printHistoryEvents(historyEvents1, 2);
  // task_0 of v1 is finished in attempt 1, task_1 of v1 is not finished in
  // attempt 1
  assertEquals(1, findTaskAttemptFinishedEvent(historyEvents1, 0, 0).size());
  assertEquals(0, findTaskAttemptFinishedEvent(historyEvents1, 0, 1).size());

  // task_0 of v1 is finished in attempt 1 and not rerun, task_1 of v1 is
  // finished in attempt 2
  assertEquals(1, findTaskAttemptFinishedEvent(historyEvents2, 0, 0).size());
  assertEquals(1, findTaskAttemptFinishedEvent(historyEvents2, 0, 1).size());

}
 
Example #10
Source File: TestMockDAGAppMaster.java    From tez with Apache License 2.0 6 votes vote down vote up
@Ignore
@Test (timeout = 60000)
public void testTaskEventsProcessingSpeed() throws Exception {
  Logger.getRootLogger().setLevel(Level.WARN);
  TezConfiguration tezconf = new TezConfiguration(defaultConf);
  tezconf.setBoolean(TezConfiguration.TEZ_AM_USE_CONCURRENT_DISPATCHER, true);
  MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true, null, null, null,
      null, false, false, 30, 1000);
  tezClient.start();

  final String vAName = "A";
  
  DAG dag = DAG.create("testTaskEventsProcessingSpeed");
  Vertex vA = Vertex.create(vAName, ProcessorDescriptor.create("Proc.class"), 50000);
  dag.addVertex(vA);

  MockDAGAppMaster mockApp = tezClient.getLocalClient().getMockApp();
  mockApp.doSleep = false;
  DAGClient dagClient = tezClient.submitDAG(dag);
  DAGStatus status = dagClient.waitForCompletion();
  Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
  tezClient.stop();
}
 
Example #11
Source File: TestFaultTolerance.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
/**
 * Test cascading input failure without exit. Expecting success.
 * v1 -- v2 -- v3
 * v3 all-tasks attempt0 input0 fails. Wait. Triggering v2 rerun.
 * v2 task0 attempt1 input0 fails. Wait. Triggering v1 rerun.
 * v1 attempt1 rerun and succeeds. v2 accepts v1 attempt1 output. v2 attempt1 succeeds.
 * v3 attempt0 accepts v2 attempt1 output.
 * 
 * AM vertex succeeded order is v1, v2, v1, v2, v3.
 * @throws Exception
 */
@Test (timeout=60000)
public void testCascadingInputFailureWithoutExitSuccess() throws Exception {
  Configuration testConf = new Configuration(false);
  setCascadingInputFailureConfig(testConf, false);
  
  //v2 task0 attempt1 value = v1 task0 attempt1 (2) + v1 task1 attempt0 (1) + 2 = 5
  //v3 all-tasks attempt0 takes v2 task0 attempt1 value (5) + v2 task1 attempt0 (3) + 1 = 9
  testConf.set(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_TASK_INDEX, "v3"), "0,1");
  testConf.setInt(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_VALUE, "v3", 0), 9);
  testConf.setInt(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_VALUE, "v3", 1), 9);
  
  DAG dag = SimpleTestDAG3Vertices.createDAG(
            "testCascadingInputFailureWithoutExitSuccess", testConf);
  runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
 
Example #12
Source File: TestAnalyzer.java    From tez with Apache License 2.0 6 votes vote down vote up
private List<StepCheck[]> testBasicTaskFailure() throws Exception {
  Configuration testConf = new Configuration(false);
  testConf.setInt(SimpleTestDAG.TEZ_SIMPLE_DAG_NUM_TASKS, 1);
  testConf.setBoolean(TestProcessor.getVertexConfName(
      TestProcessor.TEZ_FAILING_PROCESSOR_DO_FAIL, "v1"), true);
  testConf.set(TestProcessor.getVertexConfName(
      TestProcessor.TEZ_FAILING_PROCESSOR_FAILING_TASK_INDEX, "v1"), "0");
  testConf.setInt(TestProcessor.getVertexConfName(
      TestProcessor.TEZ_FAILING_PROCESSOR_FAILING_UPTO_TASK_ATTEMPT, "v1"), 0);

  StepCheck[] check = {
      createStep("v1 : 000000_0", CriticalPathDependency.INIT_DEPENDENCY),
      createStep("v1 : 000000_1", CriticalPathDependency.RETRY_DEPENDENCY),
      createStep("v2 : 000000_0", CriticalPathDependency.DATA_DEPENDENCY),
  };
  DAG dag = SimpleTestDAG.createDAG("testBasicTaskFailure", testConf);
  runDAG(dag, DAGStatus.State.SUCCEEDED);
  return Collections.singletonList(check);
}
 
Example #13
Source File: TestFaultTolerance.java    From tez with Apache License 2.0 6 votes vote down vote up
/**
 * Downstream(v3) attempt failure of a vertex connected with 
 * 2 upstream vertices.. 
 *   v1  v2
 *    \ /
 *    v3
 * 
 * @throws Exception
 */
@Test (timeout=60000)
public void testAttemptOfDownstreamVertexConnectedWithTwoUpstreamVerticesFailure() throws Exception {
  Configuration testConf = new Configuration(false);
  
  testConf.setBoolean(TestProcessor.getVertexConfName(
      TestProcessor.TEZ_FAILING_PROCESSOR_DO_FAIL, "v3"), true);
  testConf.set(TestProcessor.getVertexConfName(
      TestProcessor.TEZ_FAILING_PROCESSOR_FAILING_TASK_INDEX, "v3"), "0,1");
  testConf.setInt(TestProcessor.getVertexConfName(
      TestProcessor.TEZ_FAILING_PROCESSOR_FAILING_UPTO_TASK_ATTEMPT, "v3"), 1);
  
  //v1 input = 2. v2 input = 2
  //v3 attempt2 value = 2 + 2 + 3 = 7
  testConf.set(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_TASK_INDEX, "v3"), "0,1");
  testConf.setInt(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_VALUE, "v3", 0), 7);
  testConf.setInt(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_VALUE, "v3", 1), 7);
  
  DAG dag = SimpleVTestDAG.createDAG(
          "testAttemptOfDownstreamVertexConnectedWithTwoUpstreamVerticesFailure", testConf);
  runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
 
Example #14
Source File: TestAnalyzer.java    From tez with Apache License 2.0 6 votes vote down vote up
/**
 * Test cascading input failure without exit. Expecting success.
 * v1 -- v2 -- v3
 * v3 all-tasks attempt0 input0 fails. Wait. Triggering v2 rerun.
 * v2 task0 attempt1 input0 fails. Wait. Triggering v1 rerun.
 * v1 attempt1 rerun and succeeds. v2 accepts v1 attempt1 output. v2 attempt1 succeeds.
 * v3 attempt0 accepts v2 attempt1 output.
 * 
 * AM vertex succeeded order is v1, v2, v1, v2, v3.
 * @throws Exception
 */
private List<StepCheck[]> testCascadingInputFailureWithoutExitSuccess() throws Exception {
  Configuration testConf = new Configuration(false);
  setCascadingInputFailureConfig(testConf, false, 1);

  StepCheck[] check = {
      createStep("v1 : 000000_0", CriticalPathDependency.INIT_DEPENDENCY),
      createStep("v2 : 000000_0", CriticalPathDependency.DATA_DEPENDENCY),
      createStep("v3 : 000000_0", CriticalPathDependency.DATA_DEPENDENCY),
      createStep("v2 : 000000_1", CriticalPathDependency.OUTPUT_RECREATE_DEPENDENCY),
      createStep("v1 : 000000_1", CriticalPathDependency.OUTPUT_RECREATE_DEPENDENCY),
      createStep("v2 : 000000_1", CriticalPathDependency.DATA_DEPENDENCY),
      createStep("v3 : 000000_0", CriticalPathDependency.DATA_DEPENDENCY),
  };
  
  DAG dag = SimpleTestDAG3Vertices.createDAG(
            "testCascadingInputFailureWithoutExitSuccess", testConf);
  runDAG(dag, DAGStatus.State.SUCCEEDED);
  return Collections.singletonList(check);
}
 
Example #15
Source File: DAGImpl.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
private DAGStatus.State getDAGStatusFromState(DAGState finalState) {
  switch (finalState) {
    case NEW:
      return DAGStatus.State.INITING;
    case INITED:
      return DAGStatus.State.INITING;
    case RUNNING:
      return DAGStatus.State.RUNNING;
    case SUCCEEDED:
      return DAGStatus.State.SUCCEEDED;
    case FAILED:
      return DAGStatus.State.FAILED;
    case KILLED:
      return DAGStatus.State.KILLED;
    case ERROR:
      return DAGStatus.State.ERROR;
    case TERMINATING:
      return DAGStatus.State.KILLED;
    default:
      throw new TezUncheckedException("Unknown DAGState: " + finalState);
  }
}
 
Example #16
Source File: TestFaultTolerance.java    From tez with Apache License 2.0 6 votes vote down vote up
@Test (timeout=60000)
public void testBasicInputFailureWithoutExit() throws Exception {
  Configuration testConf = new Configuration(false);
  testConf.setBoolean(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_DO_FAIL, "v2"), true);
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_INDEX, "v2"), "1");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_ATTEMPT, "v2"), "0");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_INPUT_INDEX, "v2"), "0");
  
  testConf.set(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_TASK_INDEX, "v2"), "0,1");
  testConf.setInt(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_VALUE, "v2", 1), 4);
  testConf.setInt(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_VALUE, "v2", 0), 3);
  DAG dag = SimpleTestDAG.createDAG("testBasicInputFailureWithoutExit", testConf);
  runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
 
Example #17
Source File: TestTaskErrorsUsingLocalMode.java    From tez with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 20000)
public void testSelfKillReported() throws IOException, TezException, InterruptedException {

  TezClient tezClient = getTezClient("testSelfKillReported");
  DAGClient dagClient = null;

  try {
    FailingProcessor.configureForKilled(10);
    DAG dag = DAG.create("testSelfKillReported").addVertex(
        Vertex
            .create(VERTEX_NAME, ProcessorDescriptor.create(FailingProcessor.class.getName()), 1));

    dagClient = tezClient.submitDAG(dag);
    dagClient.waitForCompletion();
    assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
    assertEquals(10, dagClient.getVertexStatus(VERTEX_NAME, null).getProgress().getKilledTaskAttemptCount());
  } finally {
    if (dagClient != null) {
      dagClient.close();
    }
    tezClient.stop();
  }
}
 
Example #18
Source File: TezPigScriptStats.java    From spork with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the statistics after a DAG is finished.
 */
public void accumulateStats(TezJob tezJob) throws IOException {
    DAGStatus dagStatus = tezJob.getDAGStatus();
    TezDAGStats tezDAGStats = tezDAGStatsMap.get(tezJob.getName());
    if (dagStatus == null) {
        tezDAGStats.setSuccessful(false);
        tezScriptState.emitJobFailedNotification(tezDAGStats);
        return;
    } else {
        tezDAGStats.accumulateStats(tezJob);
        for(OutputStats output: tezDAGStats.getOutputs()) {
            tezScriptState.emitOutputCompletedNotification(output);
        }
        if (dagStatus.getState() == DAGStatus.State.SUCCEEDED) {
            tezDAGStats.setSuccessful(true);
            tezScriptState.emitjobFinishedNotification(tezDAGStats);
        } else if (dagStatus.getState() == DAGStatus.State.FAILED) {
            tezDAGStats.setSuccessful(false);
            tezDAGStats.setErrorMsg(tezJob.getDiagnostics());
            tezScriptState.emitJobFailedNotification(tezDAGStats);
        }
        tezScriptState.dagCompletedNotification(tezJob.getName(), tezDAGStats);
    }
}
 
Example #19
Source File: TestAnalyzer.java    From tez with Apache License 2.0 6 votes vote down vote up
private List<StepCheck[]> testBasicInputFailureWithoutExit() throws Exception {
  Configuration testConf = new Configuration(false);
  testConf.setInt(SimpleTestDAG.TEZ_SIMPLE_DAG_NUM_TASKS, 1);
  testConf.setBoolean(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_DO_FAIL, "v2"), true);
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_INDEX, "v2"), "0");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_ATTEMPT, "v2"), "0");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_INPUT_INDEX, "v2"), "0");

  StepCheck[] check = {
      createStep("v1 : 000000_0", CriticalPathDependency.INIT_DEPENDENCY),
      createStep("v2 : 000000_0", CriticalPathDependency.DATA_DEPENDENCY),
      createStep("v1 : 000000_1", CriticalPathDependency.OUTPUT_RECREATE_DEPENDENCY),
      createStep("v2 : 000000_0", CriticalPathDependency.DATA_DEPENDENCY),
    };

  DAG dag = SimpleTestDAG.createDAG("testBasicInputFailureWithoutExit", testConf);
  runDAG(dag, DAGStatus.State.SUCCEEDED);
  return Collections.singletonList(check);
}
 
Example #20
Source File: TestFaultTolerance.java    From tez with Apache License 2.0 5 votes vote down vote up
@Test (timeout=60000)
public void testMultiVersionInputFailureWithoutExit() throws Exception {
  Configuration testConf = new Configuration(false);
  testConf.setBoolean(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_DO_FAIL, "v2"), true);
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_INDEX, "v2"), "1");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_TASK_ATTEMPT, "v2"), "0");
  testConf.set(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_INPUT_INDEX, "v2"), "0");
  testConf.setInt(TestInput.getVertexConfName(
      TestInput.TEZ_FAILING_INPUT_FAILING_UPTO_INPUT_ATTEMPT, "v2"), 1);
  
  //v2 task1 attempt0 input0 input-attempt0 fails. Wait. v1 task0 attempt1 reruns.
  //v2 task1 attempt0 input0 input-attempt1 fails. Wait. v1 task0 attempt2 reruns.
  //v2 task1 attempt0 input0 input-attempt2 succeeds.
  //input values (3 + 1) + 1 = 5 
  testConf.set(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_TASK_INDEX, "v2"), "0,1");
  testConf.setInt(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_VALUE, "v2", 1), 5);
  testConf.setInt(TestProcessor.getVertexConfName(
          TestProcessor.TEZ_FAILING_PROCESSOR_VERIFY_VALUE, "v2", 0), 3);
  
  DAG dag = SimpleTestDAG.createDAG("testMultiVersionInputFailureWithoutExit", testConf);
  runDAGAndVerify(dag, DAGStatus.State.SUCCEEDED);
}
 
Example #21
Source File: DAGJobStatus.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized float getSetupProgress() {
  if (dagStatus.getState() == DAGStatus.State.RUNNING) {
    return 1.0f;
  }
  return 0.0f;
}
 
Example #22
Source File: DAGJobStatus.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized float getCleanupProgress() {
  if (dagStatus.getState() == DAGStatus.State.SUCCEEDED ||
      dagStatus.getState() == DAGStatus.State.FAILED ||
      dagStatus.getState() == DAGStatus.State.KILLED ||
      dagStatus.getState() == DAGStatus.State.ERROR) {
    return 1.0f;
  }
  return 0.0f;
}
 
Example #23
Source File: DAGJobStatus.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized float getMapProgress() {
  if(dagStatus.getVertexProgress() != null) {
    return getProgress(MultiStageMRConfigUtil.getInitialMapVertexName());
  }
  if (dagStatus.getState() == DAGStatus.State.SUCCEEDED) {
    return 1.0f;
  }
  return 0.0f;
}
 
Example #24
Source File: TestMRRJobsDAGApi.java    From tez with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 120000)
public void testAMRelocalizationConflict() throws Exception {
  Path relocPath = new Path("/tmp/relocalizationfilefound");
  if (remoteFs.exists(relocPath)) {
    remoteFs.delete(relocPath, true);
  }

  // Run a DAG w/o a file.
  TezClient tezSession = createTezSession();
  State finalState = testMRRSleepJobDagSubmitCore(true, false, false,
      tezSession, true, MRInputAMSplitGeneratorRelocalizationTest.class, null);
  Assert.assertEquals(DAGStatus.State.SUCCEEDED, finalState);
  Assert.assertFalse(remoteFs.exists(relocPath));

  // Create a bogus TezAppJar directly to HDFS
  LOG.info("Creating jar for relocalization test");
  Path tezAppJar = new Path(MiniTezCluster.APPJAR);
  Path tezAppJarRemote = remoteFs.makeQualified(new Path("/tmp/" + tezAppJar.getName()));
  OutputStream os = remoteFs.create(tezAppJarRemote, true);
  createTestJar(os, RELOCALIZATION_TEST_CLASS_NAME);

  Map<String, LocalResource> additionalResources = new HashMap<String, LocalResource>();
  additionalResources.put("TezAppJar.jar", createLrObjFromPath(tezAppJarRemote));

  try {
    testMRRSleepJobDagSubmitCore(true, false, false,
      tezSession, true, MRInputAMSplitGeneratorRelocalizationTest.class, additionalResources);
    Assert.fail("should have failed");
  } catch (Exception ex) {
    // expected
  }

  stopAndVerifyYarnApp(tezSession);
}
 
Example #25
Source File: IntersectExample.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
private int execute(String[] args, TezConfiguration tezConf, TezClient tezSession)
    throws IOException, TezException, InterruptedException {
  LOG.info("Running IntersectExample");

  UserGroupInformation.setConfiguration(tezConf);

  String streamInputDir = args[0];
  String hashInputDir = args[1];
  int numPartitions = Integer.parseInt(args[2]);
  String outputDir = args[3];

  Path streamInputPath = new Path(streamInputDir);
  Path hashInputPath = new Path(hashInputDir);
  Path outputPath = new Path(outputDir);

  // Verify output path existence
  FileSystem fs = FileSystem.get(tezConf);
  if (fs.exists(outputPath)) {
    System.err.println("Output directory: " + outputDir + " already exists");
    return 3;
  }
  if (numPartitions <= 0) {
    System.err.println("NumPartitions must be > 0");
    return 4;
  }

  DAG dag = createDag(tezConf, streamInputPath, hashInputPath, outputPath, numPartitions);
  setupURIsForCredentials(dag, streamInputPath, hashInputPath, outputPath);

  tezSession.waitTillReady();
  DAGClient dagClient = tezSession.submitDAG(dag);
  DAGStatus dagStatus = dagClient.waitForCompletionWithAllStatusUpdates(null);
  if (dagStatus.getState() != DAGStatus.State.SUCCEEDED) {
    LOG.info("DAG diagnostics: " + dagStatus.getDiagnostics());
    return -1;
  }
  return 0;

}
 
Example #26
Source File: TestPreemption.java    From tez with Apache License 2.0 5 votes vote down vote up
@Test (timeout = 5000)
public void testPreemptionWithoutSession() throws Exception {
  System.out.println("TestPreemptionWithoutSession");
  TezConfiguration tezconf = new TezConfiguration(defaultConf);
  tezconf.setInt(TezConfiguration.TEZ_AM_TASK_MAX_FAILED_ATTEMPTS, 0);
  AtomicBoolean mockAppLauncherGoFlag = new AtomicBoolean(false);
  MockTezClient tezClient = new MockTezClient("testPreemption", tezconf, false, null, null,
      null, mockAppLauncherGoFlag, false, false, 2, 2);
  tezClient.start();
  
  DAGClient dagClient = tezClient.submitDAG(createDAG(DataMovementType.SCATTER_GATHER));
  // now the MockApp has been started. sync with it to get the launcher
  syncWithMockAppLauncher(false, mockAppLauncherGoFlag, tezClient);

  DAGImpl dagImpl;
  do {
    Thread.sleep(100); // usually needs to sleep 2-3 times
  } while ((dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG()) == null);

  int vertexIndex = 0;
  int upToTaskVersion = 3;
  TezVertexID vertexId = TezVertexID.getInstance(dagImpl.getID(), vertexIndex);
  TezTaskAttemptID taId = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), 0);

  mockLauncher.preemptContainerForTask(taId.getTaskID(), upToTaskVersion);
  mockLauncher.startScheduling(true);
  
  dagClient.waitForCompletion();
  Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());

  for (int i=0; i<=upToTaskVersion; ++i) {
    TezTaskAttemptID testTaId = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId, 0), i);      
    TaskAttemptImpl taImpl = dagImpl.getTaskAttempt(testTaId);
    Assert.assertEquals(TaskAttemptStateInternal.KILLED, taImpl.getInternalState());
  }
  
  tezClient.stop();
}
 
Example #27
Source File: TezExampleBase.java    From tez with Apache License 2.0 5 votes vote down vote up
/**
 * @param dag           the dag to execute
 * @param printCounters whether to print counters or not
 * @param logger        the logger to use while printing diagnostics
 * @return Zero indicates success, non-zero indicates failure
 * @throws TezException
 * @throws InterruptedException
 * @throws IOException
 */
public int runDag(DAG dag, boolean printCounters, Logger logger) throws TezException,
    InterruptedException, IOException {
  tezClientInternal.waitTillReady();

  CallerContext callerContext = CallerContext.create("TezExamples",
      "Tez Example DAG: " + dag.getName());
  ApplicationId appId = tezClientInternal.getAppMasterApplicationId();
  if (hadoopShim == null) {
    Configuration conf = (getConf() == null ? new Configuration(false) : getConf());
    hadoopShim = new HadoopShimsLoader(conf).getHadoopShim();
  }

  if (appId != null) {
    TezUtilsInternal.setHadoopCallerContext(hadoopShim, appId);
    callerContext.setCallerIdAndType(appId.toString(), "TezExampleApplication");
  }
  dag.setCallerContext(callerContext);

  DAGClient dagClient = tezClientInternal.submitDAG(dag);
  Set<StatusGetOpts> getOpts = Sets.newHashSet();
  if (printCounters) {
    getOpts.add(StatusGetOpts.GET_COUNTERS);
  }

  DAGStatus dagStatus;
  dagStatus = dagClient.waitForCompletionWithStatusUpdates(getOpts);

  if (dagStatus.getState() != DAGStatus.State.SUCCEEDED) {
    logger.info("DAG diagnostics: " + dagStatus.getDiagnostics());
    return -1;
  }
  return 0;
}
 
Example #28
Source File: TestMRRJobsDAGApi.java    From tez with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 60000)
public void testMRRSleepJobDagSubmitAndKillViaRPC() throws IOException,
InterruptedException, TezException, ClassNotFoundException, YarnException {
  State finalState = testMRRSleepJobDagSubmitCore(true, true, false, false);

  Assert.assertEquals(DAGStatus.State.KILLED, finalState);
  // TODO Add additional checks for tracking URL etc. - once it's exposed by
  // the DAG API.
}
 
Example #29
Source File: TestDAGRecovery.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
void runDAGAndVerify(DAG dag, DAGStatus.State finalState) throws Exception {
  tezSession.waitTillReady();
  DAGClient dagClient = tezSession.submitDAG(dag);
  DAGStatus dagStatus = dagClient.getDAGStatus(null);
  while (!dagStatus.isCompleted()) {
    LOG.info("Waiting for dag to complete. Sleeping for 500ms."
        + " DAG name: " + dag.getName()
        + " DAG appId: " + dagClient.getApplicationId()
        + " Current state: " + dagStatus.getState());
    Thread.sleep(100);
    dagStatus = dagClient.getDAGStatus(null);
  }

  Assert.assertEquals(finalState, dagStatus.getState());
}
 
Example #30
Source File: DAGJobStatus.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized float getReduceProgress() {
  if(dagStatus.getVertexProgress() != null) {
    return getProgress(MultiStageMRConfigUtil.getFinalReduceVertexName());
  }
  if (dagStatus.getState() == DAGStatus.State.SUCCEEDED) {
    return 1.0f;
  }
  return 0.0f;
}