Java Code Examples for org.apache.hadoop.mapreduce.v2.app.AppContext#getJob()
The following examples show how to use
org.apache.hadoop.mapreduce.v2.app.AppContext#getJob() .
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: TestAMWebApp.java From hadoop with Apache License 2.0 | 6 votes |
@Test public void testSingleTaskCounterView() { AppContext appContext = new MockAppContext(0, 1, 1, 2); Map<String, String> params = getTaskParams(appContext); params.put(AMParams.COUNTER_GROUP, "org.apache.hadoop.mapreduce.FileSystemCounter"); params.put(AMParams.COUNTER_NAME, "HDFS_WRITE_OPS"); // remove counters from one task attempt // to test handling of missing counters TaskId taskID = MRApps.toTaskID(params.get(AMParams.TASK_ID)); Job job = appContext.getJob(taskID.getJobId()); Task task = job.getTask(taskID); TaskAttempt attempt = task.getAttempts().values().iterator().next(); attempt.getReport().setCounters(null); WebAppTests.testPage(SingleCounterPage.class, AppContext.class, appContext, params); }
Example 2
Source File: TestAMWebApp.java From big-c with Apache License 2.0 | 6 votes |
@Test public void testSingleTaskCounterView() { AppContext appContext = new MockAppContext(0, 1, 1, 2); Map<String, String> params = getTaskParams(appContext); params.put(AMParams.COUNTER_GROUP, "org.apache.hadoop.mapreduce.FileSystemCounter"); params.put(AMParams.COUNTER_NAME, "HDFS_WRITE_OPS"); // remove counters from one task attempt // to test handling of missing counters TaskId taskID = MRApps.toTaskID(params.get(AMParams.TASK_ID)); Job job = appContext.getJob(taskID.getJobId()); Task task = job.getTask(taskID); TaskAttempt attempt = task.getAttempts().values().iterator().next(); attempt.getReport().setCounters(null); WebAppTests.testPage(SingleCounterPage.class, AppContext.class, appContext, params); }
Example 3
Source File: TaskSpeculationPredicate.java From hadoop with Apache License 2.0 | 5 votes |
boolean canSpeculate(AppContext context, TaskId taskID) { // This class rejects speculating any task that already has speculations, // or isn't running. // Subclasses should call TaskSpeculationPredicate.canSpeculate(...) , but // can be even more restrictive. JobId jobID = taskID.getJobId(); Job job = context.getJob(jobID); Task task = job.getTask(taskID); return task.getAttempts().size() == 1; }
Example 4
Source File: TestHsWebServicesJobs.java From hadoop with Apache License 2.0 | 5 votes |
public void verifyHsJobXML(NodeList nodes, AppContext appContext) { assertEquals("incorrect number of elements", 1, nodes.getLength()); for (int i = 0; i < nodes.getLength(); i++) { Element element = (Element) nodes.item(i); Job job = appContext.getJob(MRApps.toJobID(WebServicesTestUtils .getXmlString(element, "id"))); assertNotNull("Job not found - output incorrect", job); VerifyJobsUtils.verifyHsJobGeneric(job, WebServicesTestUtils.getXmlString(element, "id"), WebServicesTestUtils.getXmlString(element, "user"), WebServicesTestUtils.getXmlString(element, "name"), WebServicesTestUtils.getXmlString(element, "state"), WebServicesTestUtils.getXmlString(element, "queue"), WebServicesTestUtils.getXmlLong(element, "startTime"), WebServicesTestUtils.getXmlLong(element, "finishTime"), WebServicesTestUtils.getXmlInt(element, "mapsTotal"), WebServicesTestUtils.getXmlInt(element, "mapsCompleted"), WebServicesTestUtils.getXmlInt(element, "reducesTotal"), WebServicesTestUtils.getXmlInt(element, "reducesCompleted")); // restricted access fields - if security and acls set VerifyJobsUtils.verifyHsJobGenericSecure(job, WebServicesTestUtils.getXmlBoolean(element, "uberized"), WebServicesTestUtils.getXmlString(element, "diagnostics"), WebServicesTestUtils.getXmlLong(element, "avgMapTime"), WebServicesTestUtils.getXmlLong(element, "avgReduceTime"), WebServicesTestUtils.getXmlLong(element, "avgShuffleTime"), WebServicesTestUtils.getXmlLong(element, "avgMergeTime"), WebServicesTestUtils.getXmlInt(element, "failedReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "killedReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "successfulReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "failedMapAttempts"), WebServicesTestUtils.getXmlInt(element, "killedMapAttempts"), WebServicesTestUtils.getXmlInt(element, "successfulMapAttempts")); } }
Example 5
Source File: TaskSpeculationPredicate.java From big-c with Apache License 2.0 | 5 votes |
boolean canSpeculate(AppContext context, TaskId taskID) { // This class rejects speculating any task that already has speculations, // or isn't running. // Subclasses should call TaskSpeculationPredicate.canSpeculate(...) , but // can be even more restrictive. JobId jobID = taskID.getJobId(); Job job = context.getJob(jobID); Task task = job.getTask(taskID); return task.getAttempts().size() == 1; }
Example 6
Source File: TestHsWebServicesJobs.java From big-c with Apache License 2.0 | 5 votes |
public void verifyHsJobXML(NodeList nodes, AppContext appContext) { assertEquals("incorrect number of elements", 1, nodes.getLength()); for (int i = 0; i < nodes.getLength(); i++) { Element element = (Element) nodes.item(i); Job job = appContext.getJob(MRApps.toJobID(WebServicesTestUtils .getXmlString(element, "id"))); assertNotNull("Job not found - output incorrect", job); VerifyJobsUtils.verifyHsJobGeneric(job, WebServicesTestUtils.getXmlString(element, "id"), WebServicesTestUtils.getXmlString(element, "user"), WebServicesTestUtils.getXmlString(element, "name"), WebServicesTestUtils.getXmlString(element, "state"), WebServicesTestUtils.getXmlString(element, "queue"), WebServicesTestUtils.getXmlLong(element, "startTime"), WebServicesTestUtils.getXmlLong(element, "finishTime"), WebServicesTestUtils.getXmlInt(element, "mapsTotal"), WebServicesTestUtils.getXmlInt(element, "mapsCompleted"), WebServicesTestUtils.getXmlInt(element, "reducesTotal"), WebServicesTestUtils.getXmlInt(element, "reducesCompleted")); // restricted access fields - if security and acls set VerifyJobsUtils.verifyHsJobGenericSecure(job, WebServicesTestUtils.getXmlBoolean(element, "uberized"), WebServicesTestUtils.getXmlString(element, "diagnostics"), WebServicesTestUtils.getXmlLong(element, "avgMapTime"), WebServicesTestUtils.getXmlLong(element, "avgReduceTime"), WebServicesTestUtils.getXmlLong(element, "avgShuffleTime"), WebServicesTestUtils.getXmlLong(element, "avgMergeTime"), WebServicesTestUtils.getXmlInt(element, "failedReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "killedReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "successfulReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "failedMapAttempts"), WebServicesTestUtils.getXmlInt(element, "killedMapAttempts"), WebServicesTestUtils.getXmlInt(element, "successfulMapAttempts")); } }
Example 7
Source File: TestAMWebServicesJobs.java From hadoop with Apache License 2.0 | 4 votes |
public void verifyAMJobXML(NodeList nodes, AppContext appContext) { assertEquals("incorrect number of elements", 1, nodes.getLength()); for (int i = 0; i < nodes.getLength(); i++) { Element element = (Element) nodes.item(i); Job job = appContext.getJob(MRApps.toJobID(WebServicesTestUtils .getXmlString(element, "id"))); assertNotNull("Job not found - output incorrect", job); verifyAMJobGeneric(job, WebServicesTestUtils.getXmlString(element, "id"), WebServicesTestUtils.getXmlString(element, "user"), WebServicesTestUtils.getXmlString(element, "name"), WebServicesTestUtils.getXmlString(element, "state"), WebServicesTestUtils.getXmlLong(element, "startTime"), WebServicesTestUtils.getXmlLong(element, "finishTime"), WebServicesTestUtils.getXmlLong(element, "elapsedTime"), WebServicesTestUtils.getXmlInt(element, "mapsTotal"), WebServicesTestUtils.getXmlInt(element, "mapsCompleted"), WebServicesTestUtils.getXmlInt(element, "reducesTotal"), WebServicesTestUtils.getXmlInt(element, "reducesCompleted"), WebServicesTestUtils.getXmlFloat(element, "reduceProgress"), WebServicesTestUtils.getXmlFloat(element, "mapProgress")); // restricted access fields - if security and acls set verifyAMJobGenericSecure(job, WebServicesTestUtils.getXmlInt(element, "mapsPending"), WebServicesTestUtils.getXmlInt(element, "mapsRunning"), WebServicesTestUtils.getXmlInt(element, "reducesPending"), WebServicesTestUtils.getXmlInt(element, "reducesRunning"), WebServicesTestUtils.getXmlBoolean(element, "uberized"), WebServicesTestUtils.getXmlString(element, "diagnostics"), WebServicesTestUtils.getXmlInt(element, "newReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "runningReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "failedReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "killedReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "successfulReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "newMapAttempts"), WebServicesTestUtils.getXmlInt(element, "runningMapAttempts"), WebServicesTestUtils.getXmlInt(element, "failedMapAttempts"), WebServicesTestUtils.getXmlInt(element, "killedMapAttempts"), WebServicesTestUtils.getXmlInt(element, "successfulMapAttempts")); Map<JobACL, AccessControlList> allacls = job.getJobACLs(); if (allacls != null) { for (Map.Entry<JobACL, AccessControlList> entry : allacls.entrySet()) { String expectName = entry.getKey().getAclName(); String expectValue = entry.getValue().getAclString(); Boolean found = false; // make sure ws includes it NodeList id = element.getElementsByTagName("acls"); if (id != null) { for (int j = 0; j < id.getLength(); j++) { Element aclElem = (Element) id.item(j); if (aclElem == null) { fail("should have acls in the web service info"); } if (expectName.matches(WebServicesTestUtils.getXmlString(aclElem, "name"))) { found = true; WebServicesTestUtils.checkStringMatch("value", expectValue, WebServicesTestUtils.getXmlString(aclElem, "value")); } } } else { fail("should have acls in the web service info"); } assertTrue("acl: " + expectName + " not found in webservice output", found); } } } }
Example 8
Source File: TestAMWebServicesJobs.java From big-c with Apache License 2.0 | 4 votes |
public void verifyAMJobXML(NodeList nodes, AppContext appContext) { assertEquals("incorrect number of elements", 1, nodes.getLength()); for (int i = 0; i < nodes.getLength(); i++) { Element element = (Element) nodes.item(i); Job job = appContext.getJob(MRApps.toJobID(WebServicesTestUtils .getXmlString(element, "id"))); assertNotNull("Job not found - output incorrect", job); verifyAMJobGeneric(job, WebServicesTestUtils.getXmlString(element, "id"), WebServicesTestUtils.getXmlString(element, "user"), WebServicesTestUtils.getXmlString(element, "name"), WebServicesTestUtils.getXmlString(element, "state"), WebServicesTestUtils.getXmlLong(element, "startTime"), WebServicesTestUtils.getXmlLong(element, "finishTime"), WebServicesTestUtils.getXmlLong(element, "elapsedTime"), WebServicesTestUtils.getXmlInt(element, "mapsTotal"), WebServicesTestUtils.getXmlInt(element, "mapsCompleted"), WebServicesTestUtils.getXmlInt(element, "reducesTotal"), WebServicesTestUtils.getXmlInt(element, "reducesCompleted"), WebServicesTestUtils.getXmlFloat(element, "reduceProgress"), WebServicesTestUtils.getXmlFloat(element, "mapProgress")); // restricted access fields - if security and acls set verifyAMJobGenericSecure(job, WebServicesTestUtils.getXmlInt(element, "mapsPending"), WebServicesTestUtils.getXmlInt(element, "mapsRunning"), WebServicesTestUtils.getXmlInt(element, "reducesPending"), WebServicesTestUtils.getXmlInt(element, "reducesRunning"), WebServicesTestUtils.getXmlBoolean(element, "uberized"), WebServicesTestUtils.getXmlString(element, "diagnostics"), WebServicesTestUtils.getXmlInt(element, "newReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "runningReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "failedReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "killedReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "successfulReduceAttempts"), WebServicesTestUtils.getXmlInt(element, "newMapAttempts"), WebServicesTestUtils.getXmlInt(element, "runningMapAttempts"), WebServicesTestUtils.getXmlInt(element, "failedMapAttempts"), WebServicesTestUtils.getXmlInt(element, "killedMapAttempts"), WebServicesTestUtils.getXmlInt(element, "successfulMapAttempts")); Map<JobACL, AccessControlList> allacls = job.getJobACLs(); if (allacls != null) { for (Map.Entry<JobACL, AccessControlList> entry : allacls.entrySet()) { String expectName = entry.getKey().getAclName(); String expectValue = entry.getValue().getAclString(); Boolean found = false; // make sure ws includes it NodeList id = element.getElementsByTagName("acls"); if (id != null) { for (int j = 0; j < id.getLength(); j++) { Element aclElem = (Element) id.item(j); if (aclElem == null) { fail("should have acls in the web service info"); } if (expectName.matches(WebServicesTestUtils.getXmlString(aclElem, "name"))) { found = true; WebServicesTestUtils.checkStringMatch("value", expectValue, WebServicesTestUtils.getXmlString(aclElem, "value")); } } } else { fail("should have acls in the web service info"); } assertTrue("acl: " + expectName + " not found in webservice output", found); } } } }