Java Code Examples for org.apache.tez.client.TezClient#getAppMasterApplicationId()
The following examples show how to use
org.apache.tez.client.TezClient#getAppMasterApplicationId() .
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: TestTezJobs.java From tez with Apache License 2.0 | 4 votes |
@Test(timeout = 60000) public void testAMClientHeartbeatTimeout() throws Exception { Path stagingDirPath = new Path("/tmp/timeout-staging-dir"); remoteFs.mkdirs(stagingDirPath); YarnClient yarnClient = YarnClient.createYarnClient(); try { yarnClient.init(mrrTezCluster.getConfig()); yarnClient.start(); List<ApplicationReport> apps = yarnClient.getApplications(); int appsBeforeCount = apps != null ? apps.size() : 0; TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig()); tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, stagingDirPath.toString()); tezConf.setInt(TezConfiguration.TEZ_AM_CLIENT_HEARTBEAT_TIMEOUT_SECS, 5); TezClient tezClient = TezClient.create("testAMClientHeartbeatTimeout", tezConf, true); tezClient.start(); tezClient.cancelAMKeepAlive(true); ApplicationId appId = tezClient.getAppMasterApplicationId(); apps = yarnClient.getApplications(); int appsAfterCount = apps != null ? apps.size() : 0; // Running in session mode. So should only create 1 more app. Assert.assertEquals(appsBeforeCount + 1, appsAfterCount); ApplicationReport report; while (true) { report = yarnClient.getApplicationReport(appId); if (report.getYarnApplicationState() == YarnApplicationState.FINISHED || report.getYarnApplicationState() == YarnApplicationState.FAILED || report.getYarnApplicationState() == YarnApplicationState.KILLED) { break; } Thread.sleep(1000); } // Add a sleep because YARN is not consistent in terms of reporting uptodate diagnostics Thread.sleep(2000); report = yarnClient.getApplicationReport(appId); LOG.info("App Report for appId=" + appId + ", report=" + report); Assert.assertTrue("Actual diagnostics: " + report.getDiagnostics(), report.getDiagnostics().contains("Client-to-AM Heartbeat timeout interval expired")); } finally { remoteFs.delete(stagingDirPath, true); if (yarnClient != null) { yarnClient.stop(); } } }
Example 2
Source File: TestTezJobs.java From tez with Apache License 2.0 | 4 votes |
@Test(timeout = 60000) public void testSessionTimeout() throws Exception { Path stagingDirPath = new Path("/tmp/sessiontimeout-staging-dir"); remoteFs.mkdirs(stagingDirPath); YarnClient yarnClient = YarnClient.createYarnClient(); try { yarnClient.init(mrrTezCluster.getConfig()); yarnClient.start(); List<ApplicationReport> apps = yarnClient.getApplications(); int appsBeforeCount = apps != null ? apps.size() : 0; TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig()); tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, stagingDirPath.toString()); tezConf.setInt(TezConfiguration.TEZ_SESSION_AM_DAG_SUBMIT_TIMEOUT_SECS, 5); TezClient tezClient = TezClient.create("testSessionTimeout", tezConf, true); tezClient.start(); ApplicationId appId = tezClient.getAppMasterApplicationId(); apps = yarnClient.getApplications(); int appsAfterCount = apps != null ? apps.size() : 0; // Running in session mode. So should only create 1 more app. Assert.assertEquals(appsBeforeCount + 1, appsAfterCount); ApplicationReport report; while (true) { report = yarnClient.getApplicationReport(appId); if (report.getYarnApplicationState() == YarnApplicationState.FINISHED || report.getYarnApplicationState() == YarnApplicationState.FAILED || report.getYarnApplicationState() == YarnApplicationState.KILLED) { break; } Thread.sleep(1000); } // Add a sleep because YARN is not consistent in terms of reporting uptodate diagnostics Thread.sleep(2000); report = yarnClient.getApplicationReport(appId); LOG.info("App Report for appId=" + appId + ", report=" + report); Assert.assertTrue("Actual diagnostics: " + report.getDiagnostics(), report.getDiagnostics().contains("Session timed out")); } finally { remoteFs.delete(stagingDirPath, true); if (yarnClient != null) { yarnClient.stop(); } } }
Example 3
Source File: TestATSHistoryV15.java From tez with Apache License 2.0 | 4 votes |
@Test(timeout=50000) public void testSimpleDAG() 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(YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_SUMMARY_ENTITY_TYPES, "TEZ_DAG_ID"); tezConf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewAcls); tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, ATSV15HistoryLoggingService.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()); // Verify HDFS data int count = verifyATSDataOnHDFS(atsActivePath, applicationId); Assert.assertEquals("Count is: " + count, 2, count); } finally { if (tezSession != null) { tezSession.stop(); } } }
Example 4
Source File: TestATSHistoryV15.java From tez with Apache License 2.0 | 4 votes |
@Test public void testATSLogLevelNone() 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(YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_SUMMARY_ENTITY_TYPES, "TEZ_DAG_ID"); tezConf.set(TezConfiguration.TEZ_AM_VIEW_ACLS, viewAcls); tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, ATSV15HistoryLoggingService.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(); dag.setHistoryLogLevel(HistoryLogLevel.NONE); 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()); // Verify HDFS data int count = verifyATSDataOnHDFS(atsActivePath, applicationId); Assert.assertEquals("Count is: " + count, 1, count); } finally { if (tezSession != null) { tezSession.stop(); } } }
Example 5
Source File: TestHistoryParser.java From tez with Apache License 2.0 | 4 votes |
private String runWordCount(String tokenizerProcessor, String summationProcessor, String dagName, boolean withTimeline) throws Exception { //HDFS path Path outputLoc = new Path("/tmp/outPath_" + System.currentTimeMillis()); DataSourceDescriptor dataSource = MRInput.createConfigBuilder(conf, TextInputFormat.class, inputLoc.toString()).build(); DataSinkDescriptor dataSink = MROutput.createConfigBuilder(conf, TextOutputFormat.class, outputLoc.toString()).build(); Vertex tokenizerVertex = Vertex.create(TOKENIZER, ProcessorDescriptor.create( tokenizerProcessor)).addDataSource(INPUT, dataSource); OrderedPartitionedKVEdgeConfig edgeConf = OrderedPartitionedKVEdgeConfig .newBuilder(Text.class.getName(), IntWritable.class.getName(), HashPartitioner.class.getName()).build(); Vertex summationVertex = Vertex.create(SUMMATION, ProcessorDescriptor.create(summationProcessor), 1).addDataSink(OUTPUT, dataSink); // Create DAG and add the vertices. Connect the producer and consumer vertices via the edge DAG dag = DAG.create(dagName); dag.addVertex(tokenizerVertex).addVertex(summationVertex).addEdge( Edge.create(tokenizerVertex, summationVertex, edgeConf.createDefaultEdgeProperty())); TezClient tezClient = getTezClient(withTimeline); // Update Caller Context CallerContext callerContext = CallerContext.create("TezExamples", "Tez WordCount Example Job"); ApplicationId appId = tezClient.getAppMasterApplicationId(); if (appId == null) { appId = ApplicationId.newInstance(1001l, 1); } callerContext.setCallerIdAndType(appId.toString(), "TezApplication"); dag.setCallerContext(callerContext); DAGClient client = tezClient.submitDAG(dag); client.waitForCompletionWithStatusUpdates(Sets.newHashSet(StatusGetOpts.GET_COUNTERS)); TezDAGID tezDAGID = TezDAGID.getInstance(tezClient.getAppMasterApplicationId(), 1); if (tezClient != null) { tezClient.stop(); } return tezDAGID.toString(); }
Example 6
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 7
Source File: TestATSHistoryWithACLs.java From tez with Apache License 2.0 | 4 votes |
@Test (timeout=50000) public void testDAGACls() 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); 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(); 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")); timelineDomain = getDomain(ATSHistoryACLPolicyManager.DOMAIN_ID_PREFIX + applicationId.toString() + "_1"); verifyDomainACLs(timelineDomain, Sets.newHashSet("nobody", "nobody2"), Sets.newHashSet("nobody_group", "nobody_group2")); verifyEntityDomains(applicationId, false); }