Java Code Examples for org.apache.tez.client.TezClient#start()
The following examples show how to use
org.apache.tez.client.TezClient#start() .
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: TezSessionManager.java From spork with Apache License 2.0 | 6 votes |
private static SessionInfo createSession(Configuration conf, Map<String, LocalResource> requestedAMResources, Credentials creds, TezJobConfig tezJobConf) throws TezException, IOException, InterruptedException { TezConfiguration amConf = MRToTezHelper.getDAGAMConfFromMRConf(conf); TezScriptState ss = TezScriptState.get(); ss.addDAGSettingsToConf(amConf); adjustAMConfig(amConf, tezJobConf); String jobName = conf.get(PigContext.JOB_NAME, "pig"); TezClient tezClient = TezClient.create(jobName, amConf, true, requestedAMResources, creds); tezClient.start(); TezAppMasterStatus appMasterStatus = tezClient.getAppMasterStatus(); if (appMasterStatus.equals(TezAppMasterStatus.SHUTDOWN)) { throw new RuntimeException("TezSession has already shutdown"); } tezClient.waitTillReady(); return new SessionInfo(tezClient, requestedAMResources); }
Example 2
Source File: TestExternalTezServicesErrors.java From tez with Apache License 2.0 | 6 votes |
@Test (timeout = 150000) public void testNonFatalErrors() throws IOException, TezException, InterruptedException { String methodName = "testNonFatalErrors"; TezConfiguration tezClientConf = new TezConfiguration(extServiceTestHelper.getConfForJobs()); TezClient tezClient = TezClient .newBuilder(TestExternalTezServicesErrors.class.getSimpleName() + methodName + "_session", tezClientConf) .setIsSession(true).setServicePluginDescriptor(servicePluginsDescriptor).build(); try { tezClient.start(); LOG.info("TezSessionStarted for " + methodName); tezClient.waitTillReady(); LOG.info("TezSession ready for submission for " + methodName); runAndVerifyForNonFatalErrors(tezClient, SUFFIX_LAUNCHER, EXECUTION_CONTEXT_LAUNCHER_REPORT_NON_FATAL); runAndVerifyForNonFatalErrors(tezClient, SUFFIX_TASKCOMM, EXECUTION_CONTEXT_TASKCOMM_REPORT_NON_FATAL); runAndVerifyForNonFatalErrors(tezClient, SUFFIX_SCHEDULER, EXECUTION_CONTEXT_SCHEDULER_REPORT_NON_FATAL); } finally { tezClient.stop(); } }
Example 3
Source File: TestDAGRecovery2.java From incubator-tez with Apache License 2.0 | 6 votes |
@Test(timeout=120000) public void testSessionDisableMultiAttempts() throws Exception { tezSession.stop(); Path remoteStagingDir = remoteFs.makeQualified(new Path(TEST_ROOT_DIR, String .valueOf(new Random().nextInt(100000)))); TezClientUtils.ensureStagingDirExists(conf, remoteStagingDir); TezConfiguration tezConf = createSessionConfig(remoteStagingDir); tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, true); tezConf.setBoolean(TezConfiguration.DAG_RECOVERY_ENABLED, false); TezClient session = new TezClient("TestDAGRecovery2SingleAttemptOnly", tezConf); session.start(); // DAG should fail as it never completes on the first attempt DAG dag = MultiAttemptDAG.createDAG("TestSingleAttemptDAG", null); runDAGAndVerify(dag, State.FAILED, session); session.stop(); }
Example 4
Source File: TestTezJobs.java From tez with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testInputInitializerEvents() throws TezException, InterruptedException, IOException { TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig()); TezClient tezClient = TezClient.create("TestInputInitializerEvents", tezConf); tezClient.start(); try { DAG dag = DAG.create("TestInputInitializerEvents"); Vertex vertex1 = Vertex.create(VERTEX_WITH_INITIALIZER_NAME, ProcessorDescriptor.create( SleepProcessor.class.getName()) .setUserPayload(new SleepProcessor.SleepProcessorConfig(1).toUserPayload()), 1) .addDataSource(INPUT1_NAME, DataSourceDescriptor .create(InputDescriptor.create(MultiAttemptDAG.NoOpInput.class.getName()), InputInitializerDescriptor.create(InputInitializerForTest.class.getName()), null)); Vertex vertex2 = Vertex.create(EVENT_GENERATING_VERTEX_NAME, ProcessorDescriptor.create(InputInitializerEventGeneratingProcessor.class.getName()), 5); dag.addVertex(vertex1).addVertex(vertex2); DAGClient dagClient = tezClient.submitDAG(dag); dagClient.waitForCompletion(); Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState()); } finally { tezClient.stop(); } }
Example 5
Source File: TestMRRJobsDAGApi.java From tez with Apache License 2.0 | 5 votes |
private TezClient createTezSession() throws IOException, TezException { Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String .valueOf(new Random().nextInt(100000)))); remoteFs.mkdirs(remoteStagingDir); TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig()); tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString()); TezClient tezSession = TezClient.create("testrelocalizationsession", tezConf, true); tezSession.start(); Assert.assertEquals(TezAppMasterStatus.INITIALIZING, tezSession.getAppMasterStatus()); return tezSession; }
Example 6
Source File: TestMRRJobsDAGApi.java From tez with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testSleepJob() throws TezException, IOException, InterruptedException { SleepProcessorConfig spConf = new SleepProcessorConfig(1); DAG dag = DAG.create("TezSleepProcessor"); Vertex vertex = Vertex.create("SleepVertex", ProcessorDescriptor.create( SleepProcessor.class.getName()).setUserPayload(spConf.toUserPayload()), 1, Resource.newInstance(1024, 1)); dag.addVertex(vertex); TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig()); Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String.valueOf(random .nextInt(100000)))); remoteFs.mkdirs(remoteStagingDir); tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString()); TezClient tezSession = TezClient.create("TezSleepProcessor", tezConf, false); tezSession.start(); DAGClient dagClient = tezSession.submitDAG(dag); DAGStatus dagStatus = dagClient.getDAGStatus(null); while (!dagStatus.isCompleted()) { LOG.info("Waiting for job to complete. Sleeping for 500ms." + " Current state: " + dagStatus.getState()); Thread.sleep(500l); dagStatus = dagClient.getDAGStatus(null); } dagStatus = dagClient.getDAGStatus(Sets.newHashSet(StatusGetOpts.GET_COUNTERS)); assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState()); assertNotNull(dagStatus.getDAGCounters()); assertNotNull(dagStatus.getDAGCounters().getGroup(FileSystemCounter.class.getName())); assertNotNull(dagStatus.getDAGCounters().findCounter(TaskCounter.GC_TIME_MILLIS)); ExampleDriver.printDAGStatus(dagClient, new String[] { "SleepVertex" }, true, true); tezSession.stop(); }
Example 7
Source File: TezExampleBase.java From tez with Apache License 2.0 | 5 votes |
private TezClient createTezClient(TezConfiguration tezConf) throws IOException, TezException { TezClient tezClient = TezClient.create("TezExampleApplication", tezConf); if(reconnectAppId != null) { ApplicationId appId = TezClient.appIdfromString(reconnectAppId); tezClient.getClient(appId); } else { tezClient.start(); } return tezClient; }
Example 8
Source File: TestTezJobs.java From tez with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testVertexFailuresMaxPercent() throws TezException, InterruptedException, IOException { TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig()); tezConf.set(TezConfiguration.TEZ_VERTEX_FAILURES_MAXPERCENT, "50.0f"); tezConf.setInt(TezConfiguration.TEZ_AM_TASK_MAX_FAILED_ATTEMPTS, 1); TezClient tezClient = TezClient.create("TestVertexFailuresMaxPercent", tezConf); tezClient.start(); try { DAG dag = DAG.create("TestVertexFailuresMaxPercent"); Vertex vertex1 = Vertex.create("Parent", ProcessorDescriptor.create( FailingAttemptProcessor.class.getName()), 2); Vertex vertex2 = Vertex.create("Child", ProcessorDescriptor.create(FailingAttemptProcessor.class.getName()), 2); OrderedPartitionedKVEdgeConfig edgeConfig = OrderedPartitionedKVEdgeConfig .newBuilder(Text.class.getName(), IntWritable.class.getName(), HashPartitioner.class.getName()) .setFromConfiguration(tezConf) .build(); dag.addVertex(vertex1) .addVertex(vertex2) .addEdge(Edge.create(vertex1, vertex2, edgeConfig.createDefaultEdgeProperty())); DAGClient dagClient = tezClient.submitDAG(dag); dagClient.waitForCompletion(); Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState()); } finally { tezClient.stop(); } }
Example 9
Source File: TestATSHistoryWithMiniCluster.java From tez with Apache License 2.0 | 5 votes |
@Test (timeout=50000) public void testDisabledACls() throws Exception { TezClient tezSession = null; try { SleepProcessorConfig spConf = new SleepProcessorConfig(1); DAG dag = DAG.create("TezSleepProcessor"); Vertex vertex = Vertex.create("SleepVertex", ProcessorDescriptor.create( SleepProcessor.class.getName()).setUserPayload(spConf.toUserPayload()), 1, Resource.newInstance(256, 1)); dag.addVertex(vertex); TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig()); tezConf.setBoolean(TezConfiguration.TEZ_AM_ALLOW_DISABLED_TIMELINE_DOMAINS, true); tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, ATSHistoryLoggingService.class.getName()); Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String.valueOf(random .nextInt(100000)))); remoteFs.mkdirs(remoteStagingDir); tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString()); tezSession = TezClient.create("TezSleepProcessor", tezConf, true); tezSession.start(); DAGClient dagClient = tezSession.submitDAG(dag); DAGStatus dagStatus = dagClient.getDAGStatus(null); while (!dagStatus.isCompleted()) { LOG.info("Waiting for job to complete. Sleeping for 500ms." + " Current state: " + dagStatus.getState()); Thread.sleep(500l); dagStatus = dagClient.getDAGStatus(null); } Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState()); } finally { if (tezSession != null) { tezSession.stop(); } } }
Example 10
Source File: TestLocalMode.java From tez with Apache License 2.0 | 5 votes |
@Test(timeout = 10000) public void testMultipleClientsWithoutSession() throws TezException, InterruptedException, IOException { TezConfiguration tezConf1 = createConf(); 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()); dagClient1.close(); tezClient1.stop(); TezConfiguration tezConf2 = createConf(); DAG dag2 = createSimpleDAG("dag2", SleepProcessor.class.getName()); TezClient tezClient2 = TezClient.create("commonName", tezConf2, false); tezClient2.start(); DAGClient dagClient2 = tezClient2.submitDAG(dag2); dagClient2.waitForCompletion(); assertEquals(DAGStatus.State.SUCCEEDED, dagClient2.getDAGStatus(null).getState()); assertFalse(dagClient1.getExecutionContext().equals(dagClient2.getExecutionContext())); dagClient2.close(); tezClient2.stop(); }
Example 11
Source File: TestTaskErrorsUsingLocalMode.java From tez with Apache License 2.0 | 5 votes |
private TezClient getTezClient(String name) throws IOException, TezException { TezConfiguration tezConf1 = new TezConfiguration(); tezConf1.setBoolean(TezConfiguration.TEZ_LOCAL_MODE, true); tezConf1.set("fs.defaultFS", "file:///"); tezConf1.set(TezConfiguration.TEZ_AM_STAGING_DIR, STAGING_DIR.getAbsolutePath()); tezConf1.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH, true); tezConf1.setLong(TezConfiguration.TEZ_AM_SLEEP_TIME_BEFORE_EXIT_MILLIS, 500); TezClient tezClient1 = TezClient.create(name, tezConf1, true); tezClient1.start(); return tezClient1; }
Example 12
Source File: TestFaultTolerance.java From incubator-tez with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws Exception { LOG.info("Starting mini clusters"); FileSystem remoteFs = null; try { conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEST_ROOT_DIR); dfsCluster = new MiniDFSCluster.Builder(conf).numDataNodes(1) .format(true).racks(null).build(); remoteFs = dfsCluster.getFileSystem(); } catch (IOException io) { throw new RuntimeException("problem starting mini dfs cluster", io); } if (miniTezCluster == null) { miniTezCluster = new MiniTezCluster(TestFaultTolerance.class.getName(), 4, 1, 1); Configuration miniTezconf = new Configuration(conf); miniTezconf.set("fs.defaultFS", remoteFs.getUri().toString()); // use HDFS miniTezCluster.init(miniTezconf); miniTezCluster.start(); Path remoteStagingDir = remoteFs.makeQualified(new Path(TEST_ROOT_DIR, String .valueOf(new Random().nextInt(100000)))); TezClientUtils.ensureStagingDirExists(conf, remoteStagingDir); TezConfiguration tezConf = new TezConfiguration(miniTezCluster.getConfig()); tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString()); tezConf.setBoolean(TezConfiguration.TEZ_AM_NODE_BLACKLISTING_ENABLED, false); tezSession = new TezClient("TestFaultTolerance", tezConf, true); tezSession.start(); } }
Example 13
Source File: TestATSHistoryWithACLs.java From tez with Apache License 2.0 | 4 votes |
/** * Test Disable Logging for all dags in a session * due to failure to create domain in session start * @throws Exception */ @Test (timeout=50000) public void testDisableSessionLogging() throws Exception { TezClient tezSession = null; String viewAcls = "nobody nobody_group"; SleepProcessorConfig spConf = new SleepProcessorConfig(1); DAG dag = DAG.create("TezSleepProcessor"); Vertex vertex = Vertex.create("SleepVertex", ProcessorDescriptor.create( SleepProcessor.class.getName()).setUserPayload(spConf.toUserPayload()), 1, Resource.newInstance(256, 1)); dag.addVertex(vertex); DAGAccessControls accessControls = new DAGAccessControls(); accessControls.setUsersWithViewACLs(Collections.singleton("nobody2")); accessControls.setGroupsWithViewACLs(Collections.singleton("nobody_group2")); dag.setAccessControls(accessControls); TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig()); tezConf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewAcls); tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, ATSHistoryLoggingService.class.getName()); Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String.valueOf(random .nextInt(100000)))); remoteFs.mkdirs(remoteStagingDir); tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString()); tezSession = TezClient.create("TezSleepProcessor", tezConf, true); tezSession.start(); //////submit first dag ////// DAGClient dagClient = tezSession.submitDAG(dag); DAGStatus dagStatus = dagClient.getDAGStatus(null); while (!dagStatus.isCompleted()) { LOG.info("Waiting for job to complete. Sleeping for 500ms." + " Current state: " + dagStatus.getState()); Thread.sleep(500l); dagStatus = dagClient.getDAGStatus(null); } assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState()); //////submit second dag////// DAG dag2 = DAG.create("TezSleepProcessor2"); vertex = Vertex.create("SleepVertex", ProcessorDescriptor.create( SleepProcessor.class.getName()).setUserPayload(spConf.toUserPayload()), 1, Resource.newInstance(256, 1)); dag2.addVertex(vertex); accessControls = new DAGAccessControls(); accessControls.setUsersWithViewACLs(Collections.singleton("nobody3")); accessControls.setGroupsWithViewACLs(Collections.singleton("nobody_group3")); dag2.setAccessControls(accessControls); dagClient = tezSession.submitDAG(dag2); dagStatus = dagClient.getDAGStatus(null); while (!dagStatus.isCompleted()) { LOG.info("Waiting for job to complete. Sleeping for 500ms." + " Current state: " + dagStatus.getState()); Thread.sleep(500l); dagStatus = dagClient.getDAGStatus(null); } tezSession.stop(); }
Example 14
Source File: TestTezJobs.java From incubator-tez with Apache License 2.0 | 4 votes |
@Test(timeout = 60000) public void testHistoryLogging() throws IOException, InterruptedException, TezException, ClassNotFoundException, YarnException { SleepProcessorConfig spConf = new SleepProcessorConfig(1); DAG dag = new DAG("TezSleepProcessorHistoryLogging"); Vertex vertex = new Vertex("SleepVertex", new ProcessorDescriptor( SleepProcessor.class.getName()).setUserPayload(spConf.toUserPayload()), 2, Resource.newInstance(1024, 1)); dag.addVertex(vertex); TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig()); Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String.valueOf(random .nextInt(100000)))); remoteFs.mkdirs(remoteStagingDir); tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString()); FileSystem localFs = FileSystem.getLocal(tezConf); Path historyLogDir = new Path(TEST_ROOT_DIR, "testHistoryLogging"); localFs.mkdirs(historyLogDir); tezConf.set(TezConfiguration.TEZ_SIMPLE_HISTORY_LOGGING_DIR, localFs.makeQualified(historyLogDir).toString()); tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, false); TezClient tezSession = new TezClient("TezSleepProcessorHistoryLogging", tezConf); tezSession.start(); DAGClient dagClient = tezSession.submitDAG(dag); DAGStatus dagStatus = dagClient.getDAGStatus(null); while (!dagStatus.isCompleted()) { LOG.info("Waiting for job to complete. Sleeping for 500ms." + " Current state: " + dagStatus.getState()); Thread.sleep(500l); dagStatus = dagClient.getDAGStatus(null); } assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState()); FileStatus historyLogFileStatus = null; for (FileStatus fileStatus : localFs.listStatus(historyLogDir)) { if (fileStatus.isDirectory()) { continue; } Path p = fileStatus.getPath(); if (p.getName().startsWith(SimpleHistoryLoggingService.LOG_FILE_NAME_PREFIX)) { historyLogFileStatus = fileStatus; break; } } Assert.assertNotNull(historyLogFileStatus); Assert.assertTrue(historyLogFileStatus.getLen() > 0); tezSession.stop(); }
Example 15
Source File: IntersectValidate.java From incubator-tez with Apache License 2.0 | 4 votes |
private TezClient createTezSession(TezConfiguration tezConf) throws TezException, IOException { TezClient tezSession = new TezClient("IntersectValidateSession", tezConf); tezSession.start(); return tezSession; }
Example 16
Source File: IntersectExample.java From incubator-tez with Apache License 2.0 | 4 votes |
private TezClient createTezSession(TezConfiguration tezConf) throws TezException, IOException { TezClient tezSession = new TezClient("IntersectExampleSession", tezConf); tezSession.start(); return tezSession; }
Example 17
Source File: IntersectDataGen.java From incubator-tez with Apache License 2.0 | 4 votes |
private TezClient createTezSession(TezConfiguration tezConf) throws TezException, IOException { TezClient tezSession = new TezClient("IntersectDataGenSession", tezConf); tezSession.start(); return tezSession; }
Example 18
Source File: TestATSHistoryWithACLs.java From tez with Apache License 2.0 | 4 votes |
@Test (timeout=50000) public void testSimpleAMACls() throws Exception { TezClient tezSession = null; ApplicationId applicationId; String viewAcls = "nobody nobody_group"; try { SleepProcessorConfig spConf = new SleepProcessorConfig(1); DAG dag = DAG.create("TezSleepProcessor"); Vertex vertex = Vertex.create("SleepVertex", ProcessorDescriptor.create( SleepProcessor.class.getName()).setUserPayload(spConf.toUserPayload()), 1, Resource.newInstance(256, 1)); dag.addVertex(vertex); TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig()); tezConf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewAcls); tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, ATSHistoryLoggingService.class.getName()); Path remoteStagingDir = remoteFs.makeQualified(new Path("/tmp", String.valueOf(random .nextInt(100000)))); remoteFs.mkdirs(remoteStagingDir); tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, remoteStagingDir.toString()); tezSession = TezClient.create("TezSleepProcessor", tezConf, true); tezSession.start(); applicationId = tezSession.getAppMasterApplicationId(); DAGClient dagClient = tezSession.submitDAG(dag); DAGStatus dagStatus = dagClient.getDAGStatus(null); while (!dagStatus.isCompleted()) { LOG.info("Waiting for job to complete. Sleeping for 500ms." + " Current state: " + dagStatus.getState()); Thread.sleep(500l); dagStatus = dagClient.getDAGStatus(null); } assertEquals(DAGStatus.State.SUCCEEDED, dagStatus.getState()); } finally { if (tezSession != null) { tezSession.stop(); } } TimelineDomain timelineDomain = getDomain( ATSHistoryACLPolicyManager.DOMAIN_ID_PREFIX + applicationId.toString()); verifyDomainACLs(timelineDomain, Collections.singleton("nobody"), Collections.singleton("nobody_group")); verifyEntityDomains(applicationId, true); }
Example 19
Source File: TestPipelinedShuffle.java From tez with Apache License 2.0 | 4 votes |
@Override public int run(String[] args) throws Exception { this.tezConf = new TezConfiguration(getConf()); String dagName = "pipelinedShuffleTest"; DAG dag = DAG.create(dagName); Vertex m1_Vertex = Vertex.create("mapper1", ProcessorDescriptor.create(DataGenerator.class.getName()), 1); Vertex m2_Vertex = Vertex.create("mapper2", ProcessorDescriptor.create(DataGenerator.class.getName()), 1); Vertex reducerVertex = Vertex.create("reducer", ProcessorDescriptor.create(SimpleReduceProcessor.class.getName()), 1); Edge mapper1_to_reducer = Edge.create(m1_Vertex, reducerVertex, OrderedPartitionedKVEdgeConfig .newBuilder(Text.class.getName(), Text.class.getName(), HashPartitioner.class.getName()) .setFromConfiguration(tezConf).build().createDefaultEdgeProperty()); Edge mapper2_to_reducer = Edge.create(m2_Vertex, reducerVertex, OrderedPartitionedKVEdgeConfig .newBuilder(Text.class.getName(), Text.class.getName(), HashPartitioner.class.getName()) .setFromConfiguration(tezConf).build().createDefaultEdgeProperty()); dag.addVertex(m1_Vertex); dag.addVertex(m2_Vertex); dag.addVertex(reducerVertex); dag.addEdge(mapper1_to_reducer).addEdge(mapper2_to_reducer); TezClient client = TezClient.create(dagName, tezConf); client.start(); client.waitTillReady(); DAGClient dagClient = client.submitDAG(dag); Set<StatusGetOpts> getOpts = Sets.newHashSet(); getOpts.add(StatusGetOpts.GET_COUNTERS); DAGStatus dagStatus = dagClient.waitForCompletionWithStatusUpdates(getOpts); System.out.println(dagStatus.getDAGCounters()); TezCounters counters = dagStatus.getDAGCounters(); //Ensure that atleast 10 spills were there in this job. assertTrue(counters.findCounter(TaskCounter.SHUFFLE_CHUNK_COUNT).getValue() > 10); if (dagStatus.getState() != DAGStatus.State.SUCCEEDED) { System.out.println("DAG diagnostics: " + dagStatus.getDiagnostics()); return -1; } return 0; }
Example 20
Source File: TestLocalMode.java From tez with Apache License 2.0 | 4 votes |
@Test(timeout=30000) public void testMultiDAGsOnSession() throws IOException, TezException, InterruptedException { int dags = 2;//two dags will be submitted to session String[] inputPaths = new String[dags]; String[] outputPaths = new String[dags]; DAGClient[] dagClients = new DAGClient[dags]; TezConfiguration tezConf = createConf(); TezClient tezClient = TezClient.create("testMultiDAGOnSession", tezConf, true); tezClient.start(); //create inputs and outputs FileSystem fs = FileSystem.get(tezConf); for(int i = 0; i < dags; i++) { inputPaths[i] = new Path(STAGING_DIR.getAbsolutePath(), "in-" + i).toString(); createInputFile(fs, inputPaths[i]); outputPaths[i] = new Path(STAGING_DIR.getAbsolutePath(), "out-" + i).toString(); } //start testing try { for (int i=0; i<inputPaths.length; ++i) { DAG dag = OrderedWordCount.createDAG(tezConf, inputPaths[i], outputPaths[i], 1, false, false, ("DAG-Iteration-" + i)); // the names of the DAGs must be unique in a session tezClient.waitTillReady(); System.out.println("Running dag number " + i); dagClients[i] = tezClient.submitDAG(dag); // wait to finish DAGStatus dagStatus = dagClients[i].waitForCompletion(); if (dagStatus.getState() != DAGStatus.State.SUCCEEDED) { fail("Iteration " + i + " failed with diagnostics: " + dagStatus.getDiagnostics()); } //verify all dags sharing the same execution context if(i>0) { assertTrue(dagClients[i-1].getExecutionContext().equals(dagClients[i].getExecutionContext())); } } } finally { tezClient.stop(); } }