org.apache.hadoop.mapreduce.v2.util.MRApps.toString()

Here are the examples of the java api org.apache.hadoop.mapreduce.v2.util.MRApps.toString() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

129 Examples 7

19 Source : TestHsWebServicesJobs.java
with Apache License 2.0
from NJUJYB

public void verifyHsJobCountersXML(NodeList nodes, Job job) {
    for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        replacedertNotNull("Job not found - output incorrect", job);
        WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()), WebServicesTestUtils.getXmlString(element, "id"));
        // just do simple verification of fields - not data is correct
        // in the fields
        NodeList groups = element.getElementsByTagName("counterGroup");
        for (int j = 0; j < groups.getLength(); j++) {
            Element counters = (Element) groups.item(j);
            replacedertNotNull("should have counters in the web service info", counters);
            String name = WebServicesTestUtils.getXmlString(counters, "counterGroupName");
            replacedertTrue("name not set", (name != null && !name.isEmpty()));
            NodeList counterArr = counters.getElementsByTagName("counter");
            for (int z = 0; z < counterArr.getLength(); z++) {
                Element counter = (Element) counterArr.item(z);
                String counterName = WebServicesTestUtils.getXmlString(counter, "name");
                replacedertTrue("counter name not set", (counterName != null && !counterName.isEmpty()));
                long mapValue = WebServicesTestUtils.getXmlLong(counter, "mapCounterValue");
                replacedertTrue("mapCounterValue not >= 0", mapValue >= 0);
                long reduceValue = WebServicesTestUtils.getXmlLong(counter, "reduceCounterValue");
                replacedertTrue("reduceCounterValue  >= 0", reduceValue >= 0);
                long totalValue = WebServicesTestUtils.getXmlLong(counter, "totalCounterValue");
                replacedertTrue("totalCounterValue  >= 0", totalValue >= 0);
            }
        }
    }
}

19 Source : HsNavBlock.java
with Apache License 2.0
from NJUJYB

/*
   * (non-Javadoc)
   * @see org.apache.hadoop.yarn.webapp.view.HtmlBlock#render(org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block)
   */
@Override
protected void render(Block html) {
    DIV<Hamlet> nav = html.div("#nav").h3("Application").ul().li().a(url("about"), "About")._().li().a(url("app"), "Jobs")._()._();
    if (app.getJob() != null) {
        String jobid = MRApps.toString(app.getJob().getID());
        nav.h3("Job").ul().li().a(url("job", jobid), "Overview")._().li().a(url("jobcounters", jobid), "Counters")._().li().a(url("conf", jobid), "Configuration")._().li().a(url("tasks", jobid, "m"), "Map tasks")._().li().a(url("tasks", jobid, "r"), "Reduce tasks")._()._();
        if (app.getTask() != null) {
            String taskid = MRApps.toString(app.getTask().getID());
            nav.h3("Task").ul().li().a(url("task", taskid), "Task Overview")._().li().a(url("taskcounters", taskid), "Counters")._()._();
        }
    }
    nav.h3("Tools").ul().li().a("/conf", "Configuration")._().li().a("/logs", "Local logs")._().li().a("/stacks", "Server stacks")._().li().a("/metrics", "Server metrics")._()._()._();
}

19 Source : TestAMWebServicesJobs.java
with Apache License 2.0
from NJUJYB

public void verifyAMJobCountersXML(NodeList nodes, Job job) {
    for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        replacedertNotNull("Job not found - output incorrect", job);
        WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()), WebServicesTestUtils.getXmlString(element, "id"));
        // just do simple verification of fields - not data is correct
        // in the fields
        NodeList groups = element.getElementsByTagName("counterGroup");
        for (int j = 0; j < groups.getLength(); j++) {
            Element counters = (Element) groups.item(j);
            replacedertNotNull("should have counters in the web service info", counters);
            String name = WebServicesTestUtils.getXmlString(counters, "counterGroupName");
            replacedertTrue("name not set", (name != null && !name.isEmpty()));
            NodeList counterArr = counters.getElementsByTagName("counter");
            for (int z = 0; z < counterArr.getLength(); z++) {
                Element counter = (Element) counterArr.item(z);
                String counterName = WebServicesTestUtils.getXmlString(counter, "name");
                replacedertTrue("counter name not set", (counterName != null && !counterName.isEmpty()));
                long mapValue = WebServicesTestUtils.getXmlLong(counter, "mapCounterValue");
                replacedertTrue("mapCounterValue not >= 0", mapValue >= 0);
                long reduceValue = WebServicesTestUtils.getXmlLong(counter, "reduceCounterValue");
                replacedertTrue("reduceCounterValue  >= 0", reduceValue >= 0);
                long totalValue = WebServicesTestUtils.getXmlLong(counter, "totalCounterValue");
                replacedertTrue("totalCounterValue  >= 0", totalValue >= 0);
            }
        }
    }
}

19 Source : HsNavBlock.java
with Apache License 2.0
from naver

/*
   * (non-Javadoc)
   * @see org.apache.hadoop.yarn.webapp.view.HtmlBlock#render(org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block)
   */
@Override
protected void render(Block html) {
    DIV<Hamlet> nav = html.div("#nav").h3("Application").ul().li().a(url("about"), "About")._().li().a(url("app"), "Jobs")._()._();
    if (app.getJob() != null) {
        String jobid = MRApps.toString(app.getJob().getID());
        nav.h3("Job").ul().li().a(url("job", jobid), "Overview")._().li().a(url("jobcounters", jobid), "Counters")._().li().a(url("conf", jobid), "Configuration")._().li().a(url("tasks", jobid, "m"), "Map tasks")._().li().a(url("tasks", jobid, "r"), "Reduce tasks")._()._();
        if (app.getTask() != null) {
            String taskid = MRApps.toString(app.getTask().getID());
            nav.h3("Task").ul().li().a(url("task", taskid), "Task Overview")._().li().a(url("taskcounters", taskid), "Counters")._()._();
        }
    }
    nav.h3("Tools").ul().li().a("/conf", "Configuration")._().li().a("/logs", "Local logs")._().li().a("/stacks", "Server stacks")._().li().a("/jmx?qry=Hadoop:*", "Server metrics")._()._()._();
}

18 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

public void verifyHsTaskCountersXML(NodeList nodes, Task task) {
    for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        WebServicesTestUtils.checkStringMatch("id", MRApps.toString(task.getID()), WebServicesTestUtils.getXmlString(element, "id"));
        // just do simple verification of fields - not data is correct
        // in the fields
        NodeList groups = element.getElementsByTagName("taskCounterGroup");
        for (int j = 0; j < groups.getLength(); j++) {
            Element counters = (Element) groups.item(j);
            replacedertNotNull("should have counters in the web service info", counters);
            String name = WebServicesTestUtils.getXmlString(counters, "counterGroupName");
            replacedertTrue("name not set", (name != null && !name.isEmpty()));
            NodeList counterArr = counters.getElementsByTagName("counter");
            for (int z = 0; z < counterArr.getLength(); z++) {
                Element counter = (Element) counterArr.item(z);
                String counterName = WebServicesTestUtils.getXmlString(counter, "name");
                replacedertTrue("counter name not set", (counterName != null && !counterName.isEmpty()));
                long value = WebServicesTestUtils.getXmlLong(counter, "value");
                replacedertTrue("value not >= 0", value >= 0);
            }
        }
    }
}

18 Source : TestHsWebServicesJobs.java
with Apache License 2.0
from NJUJYB

public void verifyHsJobCounters(JSONObject info, Job job) throws JSONException {
    replacedertEquals("incorrect number of elements", 2, info.length());
    WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()), info.getString("id"));
    // just do simple verification of fields - not data is correct
    // in the fields
    JSONArray counterGroups = info.getJSONArray("counterGroup");
    for (int i = 0; i < counterGroups.length(); i++) {
        JSONObject counterGroup = counterGroups.getJSONObject(i);
        String name = counterGroup.getString("counterGroupName");
        replacedertTrue("name not set", (name != null && !name.isEmpty()));
        JSONArray counters = counterGroup.getJSONArray("counter");
        for (int j = 0; j < counters.length(); j++) {
            JSONObject counter = counters.getJSONObject(j);
            String counterName = counter.getString("name");
            replacedertTrue("counter name not set", (counterName != null && !counterName.isEmpty()));
            long mapValue = counter.getLong("mapCounterValue");
            replacedertTrue("mapCounterValue  >= 0", mapValue >= 0);
            long reduceValue = counter.getLong("reduceCounterValue");
            replacedertTrue("reduceCounterValue  >= 0", reduceValue >= 0);
            long totalValue = counter.getLong("totalCounterValue");
            replacedertTrue("totalCounterValue  >= 0", totalValue >= 0);
        }
    }
}

18 Source : TestHsWebServicesAttempts.java
with Apache License 2.0
from NJUJYB

public void verifyHsTaskCountersXML(NodeList nodes, TaskAttempt att) {
    for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        WebServicesTestUtils.checkStringMatch("id", MRApps.toString(att.getID()), WebServicesTestUtils.getXmlString(element, "id"));
        // just do simple verification of fields - not data is correct
        // in the fields
        NodeList groups = element.getElementsByTagName("taskAttemptCounterGroup");
        for (int j = 0; j < groups.getLength(); j++) {
            Element counters = (Element) groups.item(j);
            replacedertNotNull("should have counters in the web service info", counters);
            String name = WebServicesTestUtils.getXmlString(counters, "counterGroupName");
            replacedertTrue("name not set", (name != null && !name.isEmpty()));
            NodeList counterArr = counters.getElementsByTagName("counter");
            for (int z = 0; z < counterArr.getLength(); z++) {
                Element counter = (Element) counterArr.item(z);
                String counterName = WebServicesTestUtils.getXmlString(counter, "name");
                replacedertTrue("counter name not set", (counterName != null && !counterName.isEmpty()));
                long value = WebServicesTestUtils.getXmlLong(counter, "value");
                replacedertTrue("value not >= 0", value >= 0);
            }
        }
    }
}

18 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

public void verifyAMTaskCountersXML(NodeList nodes, Task task) {
    for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        WebServicesTestUtils.checkStringMatch("id", MRApps.toString(task.getID()), WebServicesTestUtils.getXmlString(element, "id"));
        // just do simple verification of fields - not data is correct
        // in the fields
        NodeList groups = element.getElementsByTagName("taskCounterGroup");
        for (int j = 0; j < groups.getLength(); j++) {
            Element counters = (Element) groups.item(j);
            replacedertNotNull("should have counters in the web service info", counters);
            String name = WebServicesTestUtils.getXmlString(counters, "counterGroupName");
            replacedertTrue("name not set", (name != null && !name.isEmpty()));
            NodeList counterArr = counters.getElementsByTagName("counter");
            for (int z = 0; z < counterArr.getLength(); z++) {
                Element counter = (Element) counterArr.item(z);
                String counterName = WebServicesTestUtils.getXmlString(counter, "name");
                replacedertTrue("counter name not set", (counterName != null && !counterName.isEmpty()));
                long value = WebServicesTestUtils.getXmlLong(counter, "value");
                replacedertTrue("value not >= 0", value >= 0);
            }
        }
    }
}

18 Source : TestAMWebServicesJobs.java
with Apache License 2.0
from NJUJYB

public void verifyAMJobCounters(JSONObject info, Job job) throws JSONException {
    replacedertEquals("incorrect number of elements", 2, info.length());
    WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()), info.getString("id"));
    // just do simple verification of fields - not data is correct
    // in the fields
    JSONArray counterGroups = info.getJSONArray("counterGroup");
    for (int i = 0; i < counterGroups.length(); i++) {
        JSONObject counterGroup = counterGroups.getJSONObject(i);
        String name = counterGroup.getString("counterGroupName");
        replacedertTrue("name not set", (name != null && !name.isEmpty()));
        JSONArray counters = counterGroup.getJSONArray("counter");
        for (int j = 0; j < counters.length(); j++) {
            JSONObject counter = counters.getJSONObject(j);
            String counterName = counter.getString("name");
            replacedertTrue("counter name not set", (counterName != null && !counterName.isEmpty()));
            long mapValue = counter.getLong("mapCounterValue");
            replacedertTrue("mapCounterValue  >= 0", mapValue >= 0);
            long reduceValue = counter.getLong("reduceCounterValue");
            replacedertTrue("reduceCounterValue  >= 0", reduceValue >= 0);
            long totalValue = counter.getLong("totalCounterValue");
            replacedertTrue("totalCounterValue  >= 0", totalValue >= 0);
        }
    }
}

18 Source : TestAMWebServicesAttempts.java
with Apache License 2.0
from NJUJYB

public void verifyAMTaskCountersXML(NodeList nodes, TaskAttempt att) {
    for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        WebServicesTestUtils.checkStringMatch("id", MRApps.toString(att.getID()), WebServicesTestUtils.getXmlString(element, "id"));
        // just do simple verification of fields - not data is correct
        // in the fields
        NodeList groups = element.getElementsByTagName("taskAttemptCounterGroup");
        for (int j = 0; j < groups.getLength(); j++) {
            Element counters = (Element) groups.item(j);
            replacedertNotNull("should have counters in the web service info", counters);
            String name = WebServicesTestUtils.getXmlString(counters, "counterGroupName");
            replacedertTrue("name not set", (name != null && !name.isEmpty()));
            NodeList counterArr = counters.getElementsByTagName("counter");
            for (int z = 0; z < counterArr.getLength(); z++) {
                Element counter = (Element) counterArr.item(z);
                String counterName = WebServicesTestUtils.getXmlString(counter, "name");
                replacedertTrue("counter name not set", (counterName != null && !counterName.isEmpty()));
                long value = WebServicesTestUtils.getXmlLong(counter, "value");
                replacedertTrue("value not >= 0", value >= 0);
            }
        }
    }
}

18 Source : TestAMWebApp.java
with Apache License 2.0
from NJUJYB

public static Map<String, String> getJobParams(AppContext appContext) {
    JobId jobId = appContext.getAllJobs().entrySet().iterator().next().getKey();
    Map<String, String> params = new HashMap<String, String>();
    params.put(AMParams.JOB_ID, MRApps.toString(jobId));
    return params;
}

18 Source : NavBlock.java
with Apache License 2.0
from NJUJYB

@Override
protected void render(Block html) {
    String rmweb = $(RM_WEB);
    DIV<Hamlet> nav = html.div("#nav").h3("Cluster").ul().li().a(url(rmweb, "cluster", "cluster"), "About")._().li().a(url(rmweb, "cluster", "apps"), "Applications")._().li().a(url(rmweb, "cluster", "scheduler"), "Scheduler")._()._().h3("Application").ul().li().a(url("app/info"), "About")._().li().a(url("app"), "Jobs")._()._();
    if (app.getJob() != null) {
        String jobid = MRApps.toString(app.getJob().getID());
        List<AMInfo> amInfos = app.getJob().getAMInfos();
        AMInfo thisAmInfo = amInfos.get(amInfos.size() - 1);
        String nodeHttpAddress = thisAmInfo.getNodeManagerHost() + ":" + thisAmInfo.getNodeManagerHttpPort();
        nav.h3("Job").ul().li().a(url("job", jobid), "Overview")._().li().a(url("jobcounters", jobid), "Counters")._().li().a(url("conf", jobid), "Configuration")._().li().a(url("tasks", jobid, "m"), "Map tasks")._().li().a(url("tasks", jobid, "r"), "Reduce tasks")._().li().a(".logslink", url(MRWebAppUtil.getYARNWebappScheme(), nodeHttpAddress, "node", "containerlogs", thisAmInfo.getContainerId().toString(), app.getJob().getUserName()), "AM Logs")._()._();
        if (app.getTask() != null) {
            String taskid = MRApps.toString(app.getTask().getID());
            nav.h3("Task").ul().li().a(url("task", taskid), "Task Overview")._().li().a(url("taskcounters", taskid), "Counters")._()._();
        }
    }
    nav.h3("Tools").ul().li().a("/conf", "Configuration")._().li().a("/logs", "Local logs")._().li().a("/stacks", "Server stacks")._().li().a("/metrics", "Server metrics")._()._()._();
}

18 Source : NavBlock.java
with Apache License 2.0
from naver

@Override
protected void render(Block html) {
    String rmweb = $(RM_WEB);
    DIV<Hamlet> nav = html.div("#nav").h3("Cluster").ul().li().a(url(rmweb, "cluster", "cluster"), "About")._().li().a(url(rmweb, "cluster", "apps"), "Applications")._().li().a(url(rmweb, "cluster", "scheduler"), "Scheduler")._()._().h3("Application").ul().li().a(url("app/info"), "About")._().li().a(url("app"), "Jobs")._()._();
    if (app.getJob() != null) {
        String jobid = MRApps.toString(app.getJob().getID());
        List<AMInfo> amInfos = app.getJob().getAMInfos();
        AMInfo thisAmInfo = amInfos.get(amInfos.size() - 1);
        String nodeHttpAddress = thisAmInfo.getNodeManagerHost() + ":" + thisAmInfo.getNodeManagerHttpPort();
        nav.h3("Job").ul().li().a(url("job", jobid), "Overview")._().li().a(url("jobcounters", jobid), "Counters")._().li().a(url("conf", jobid), "Configuration")._().li().a(url("tasks", jobid, "m"), "Map tasks")._().li().a(url("tasks", jobid, "r"), "Reduce tasks")._().li().a(".logslink", url(MRWebAppUtil.getYARNWebappScheme(), nodeHttpAddress, "node", "containerlogs", thisAmInfo.getContainerId().toString(), app.getJob().getUserName()), "AM Logs")._()._();
        if (app.getTask() != null) {
            String taskid = MRApps.toString(app.getTask().getID());
            nav.h3("Task").ul().li().a(url("task", taskid), "Task Overview")._().li().a(url("taskcounters", taskid), "Counters")._()._();
        }
    }
    nav.h3("Tools").ul().li().a("/conf", "Configuration")._().li().a("/logs", "Local logs")._().li().a("/stacks", "Server stacks")._().li().a("/jmx?qry=Hadoop:*", "Server metrics")._()._()._();
}

17 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

public void verifyHsJobTaskCounters(JSONObject info, Task task) throws JSONException {
    replacedertEquals("incorrect number of elements", 2, info.length());
    WebServicesTestUtils.checkStringMatch("id", MRApps.toString(task.getID()), info.getString("id"));
    // just do simple verification of fields - not data is correct
    // in the fields
    JSONArray counterGroups = info.getJSONArray("taskCounterGroup");
    for (int i = 0; i < counterGroups.length(); i++) {
        JSONObject counterGroup = counterGroups.getJSONObject(i);
        String name = counterGroup.getString("counterGroupName");
        replacedertTrue("name not set", (name != null && !name.isEmpty()));
        JSONArray counters = counterGroup.getJSONArray("counter");
        for (int j = 0; j < counters.length(); j++) {
            JSONObject counter = counters.getJSONObject(j);
            String counterName = counter.getString("name");
            replacedertTrue("name not set", (counterName != null && !counterName.isEmpty()));
            long value = counter.getLong("value");
            replacedertTrue("value  >= 0", value >= 0);
        }
    }
}

17 Source : TestHsWebServicesJobs.java
with Apache License 2.0
from NJUJYB

public void verifyHsJobAttemptsGeneric(Job job, String nodeHttpAddress, String nodeId, int id, long startTime, String containerId, String logsLink) {
    boolean attemptFound = false;
    for (AMInfo amInfo : job.getAMInfos()) {
        if (amInfo.getAppAttemptId().getAttemptId() == id) {
            attemptFound = true;
            String nmHost = amInfo.getNodeManagerHost();
            int nmHttpPort = amInfo.getNodeManagerHttpPort();
            int nmPort = amInfo.getNodeManagerPort();
            WebServicesTestUtils.checkStringMatch("nodeHttpAddress", nmHost + ":" + nmHttpPort, nodeHttpAddress);
            WebServicesTestUtils.checkStringMatch("nodeId", NodeId.newInstance(nmHost, nmPort).toString(), nodeId);
            replacedertTrue("startime not greater than 0", startTime > 0);
            WebServicesTestUtils.checkStringMatch("containerId", amInfo.getContainerId().toString(), containerId);
            String localLogsLink = join("hsmockwebapp", ujoin("logs", nodeId, containerId, MRApps.toString(job.getID()), job.getUserName()));
            replacedertTrue("logsLink", logsLink.contains(localLogsLink));
        }
    }
    replacedertTrue("attempt: " + id + " was not found", attemptFound);
}

17 Source : TestHsWebServicesAttempts.java
with Apache License 2.0
from NJUJYB

public void verifyHsJobTaskAttemptCounters(JSONObject info, TaskAttempt att) throws JSONException {
    replacedertEquals("incorrect number of elements", 2, info.length());
    WebServicesTestUtils.checkStringMatch("id", MRApps.toString(att.getID()), info.getString("id"));
    // just do simple verification of fields - not data is correct
    // in the fields
    JSONArray counterGroups = info.getJSONArray("taskAttemptCounterGroup");
    for (int i = 0; i < counterGroups.length(); i++) {
        JSONObject counterGroup = counterGroups.getJSONObject(i);
        String name = counterGroup.getString("counterGroupName");
        replacedertTrue("name not set", (name != null && !name.isEmpty()));
        JSONArray counters = counterGroup.getJSONArray("counter");
        for (int j = 0; j < counters.length(); j++) {
            JSONObject counter = counters.getJSONObject(j);
            String counterName = counter.getString("name");
            replacedertTrue("name not set", (counterName != null && !counterName.isEmpty()));
            long value = counter.getLong("value");
            replacedertTrue("value  >= 0", value >= 0);
        }
    }
}

17 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

public void verifyAMJobTaskCounters(JSONObject info, Task task) throws JSONException {
    replacedertEquals("incorrect number of elements", 2, info.length());
    WebServicesTestUtils.checkStringMatch("id", MRApps.toString(task.getID()), info.getString("id"));
    // just do simple verification of fields - not data is correct
    // in the fields
    JSONArray counterGroups = info.getJSONArray("taskCounterGroup");
    for (int i = 0; i < counterGroups.length(); i++) {
        JSONObject counterGroup = counterGroups.getJSONObject(i);
        String name = counterGroup.getString("counterGroupName");
        replacedertTrue("name not set", (name != null && !name.isEmpty()));
        JSONArray counters = counterGroup.getJSONArray("counter");
        for (int j = 0; j < counters.length(); j++) {
            JSONObject counter = counters.getJSONObject(j);
            String counterName = counter.getString("name");
            replacedertTrue("name not set", (counterName != null && !counterName.isEmpty()));
            long value = counter.getLong("value");
            replacedertTrue("value  >= 0", value >= 0);
        }
    }
}

17 Source : TestAMWebServicesAttempts.java
with Apache License 2.0
from NJUJYB

public void verifyAMJobTaskAttemptCounters(JSONObject info, TaskAttempt att) throws JSONException {
    replacedertEquals("incorrect number of elements", 2, info.length());
    WebServicesTestUtils.checkStringMatch("id", MRApps.toString(att.getID()), info.getString("id"));
    // just do simple verification of fields - not data is correct
    // in the fields
    JSONArray counterGroups = info.getJSONArray("taskAttemptCounterGroup");
    for (int i = 0; i < counterGroups.length(); i++) {
        JSONObject counterGroup = counterGroups.getJSONObject(i);
        String name = counterGroup.getString("counterGroupName");
        replacedertTrue("name not set", (name != null && !name.isEmpty()));
        JSONArray counters = counterGroup.getJSONArray("counter");
        for (int j = 0; j < counters.length(); j++) {
            JSONObject counter = counters.getJSONObject(j);
            String counterName = counter.getString("name");
            replacedertTrue("name not set", (counterName != null && !counterName.isEmpty()));
            long value = counter.getLong("value");
            replacedertTrue("value  >= 0", value >= 0);
        }
    }
}

17 Source : AppController.java
with Apache License 2.0
from NJUJYB

/**
 * Ensure that a TASK_ID was preplaceded into the page.
 */
public void requireTask() {
    if ($(TASK_ID).isEmpty()) {
        badRequest("missing task ID");
        throw new RuntimeException("missing task ID");
    }
    TaskId taskID = MRApps.toTaskID($(TASK_ID));
    Job job = app.context.getJob(taskID.getJobId());
    app.setJob(job);
    if (app.getJob() == null) {
        notFound(MRApps.toString(taskID.getJobId()));
        throw new RuntimeException("Not Found: " + $(JOB_ID));
    } else {
        app.setTask(app.getJob().getTask(taskID));
        if (app.getTask() == null) {
            notFound($(TASK_ID));
            throw new RuntimeException("Not Found: " + $(TASK_ID));
        }
    }
    if (!checkAccess(job)) {
        accessDenied("User " + request().getRemoteUser() + " does not have " + " permission to view job " + $(JOB_ID));
        throw new RuntimeException("Access denied: User " + request().getRemoteUser() + " does not have permission to view job " + $(JOB_ID));
    }
}

16 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdInvalid2() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        String tid = "task_0000_m_000000";
        try {
            r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: TaskId string : " + "task_0000_m_000000 is not properly formed", message);
            WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.NotFoundException", clreplacedname);
        }
    }
}

16 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

public void verifyHsTask(JSONArray arr, Job job, String type) throws JSONException {
    for (Task task : job.getTasks().values()) {
        TaskId id = task.getID();
        String tid = MRApps.toString(id);
        Boolean found = false;
        if (type != null && task.getType() == MRApps.taskType(type)) {
            for (int i = 0; i < arr.length(); i++) {
                JSONObject info = arr.getJSONObject(i);
                if (tid.matches(info.getString("id"))) {
                    found = true;
                    verifyHsSingleTask(info, task);
                }
            }
            replacedertTrue("task with id: " + tid + " not in web service output", found);
        }
    }
}

16 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdInvalid3() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        String tid = "task_0_0000_m";
        try {
            r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: TaskId string : " + "task_0_0000_m is not properly formed", message);
            WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.NotFoundException", clreplacedname);
        }
    }
}

16 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdNonExist() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        String tid = "task_0_0000_m_000000";
        try {
            r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: task not found with id task_0_0000_m_000000", message);
            WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.NotFoundException", clreplacedname);
        }
    }
}

16 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdInvalid() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        String tid = "task_0_0000_d_000000";
        try {
            r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: Bad TaskType identifier. TaskId string : " + "task_0_0000_d_000000 is not properly formed.", message);
            WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.NotFoundException", clreplacedname);
        }
    }
}

16 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdBogus() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        String tid = "bogustaskid";
        try {
            r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: TaskId string : " + "bogustaskid is not properly formed", message);
            WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.NotFoundException", clreplacedname);
        }
    }
}

16 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

public void verifyHsTaskXML(NodeList nodes, Job job) {
    replacedertEquals("incorrect number of elements", 2, nodes.getLength());
    for (Task task : job.getTasks().values()) {
        TaskId id = task.getID();
        String tid = MRApps.toString(id);
        Boolean found = false;
        for (int i = 0; i < nodes.getLength(); i++) {
            Element element = (Element) nodes.item(i);
            if (tid.matches(WebServicesTestUtils.getXmlString(element, "id"))) {
                found = true;
                verifyHsSingleTaskXML(element, task);
            }
        }
        replacedertTrue("task with id: " + tid + " not in web service output", found);
    }
}

16 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdBogus() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        String tid = "bogustaskid";
        try {
            r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: TaskId string : " + "bogustaskid is not properly formed", message);
            WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.NotFoundException", clreplacedname);
        }
    }
}

16 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdInvalid2() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        String tid = "task_0_m_000000";
        try {
            r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: TaskId string : " + "task_0_m_000000 is not properly formed", message);
            WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.NotFoundException", clreplacedname);
        }
    }
}

16 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdInvalid() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        String tid = "task_0_0000_d_000000";
        try {
            r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: Bad TaskType identifier. TaskId string : " + "task_0_0000_d_000000 is not properly formed.", message);
            WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.NotFoundException", clreplacedname);
        }
    }
}

16 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

public void verifyAMTaskXML(NodeList nodes, Job job) {
    replacedertEquals("incorrect number of elements", 2, nodes.getLength());
    for (Task task : job.getTasks().values()) {
        TaskId id = task.getID();
        String tid = MRApps.toString(id);
        Boolean found = false;
        for (int i = 0; i < nodes.getLength(); i++) {
            Element element = (Element) nodes.item(i);
            if (tid.matches(WebServicesTestUtils.getXmlString(element, "id"))) {
                found = true;
                verifyAMSingleTaskXML(element, task);
            }
        }
        replacedertTrue("task with id: " + tid + " not in web service output", found);
    }
}

16 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

public void verifyAMTask(JSONArray arr, Job job, String type) throws JSONException {
    for (Task task : job.getTasks().values()) {
        TaskId id = task.getID();
        String tid = MRApps.toString(id);
        Boolean found = false;
        if (type != null && task.getType() == MRApps.taskType(type)) {
            for (int i = 0; i < arr.length(); i++) {
                JSONObject info = arr.getJSONObject(i);
                if (tid.matches(info.getString("id"))) {
                    found = true;
                    verifyAMSingleTask(info, task);
                }
            }
            replacedertTrue("task with id: " + tid + " not in web service output", found);
        }
    }
}

16 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdNonExist() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        String tid = "task_0_0000_m_000000";
        try {
            r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: task not found with id task_0_0000_m_000000", message);
            WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.NotFoundException", clreplacedname);
        }
    }
}

16 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdInvalid3() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        String tid = "task_0_0000_m";
        try {
            r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: TaskId string : " + "task_0_0000_m is not properly formed", message);
            WebServicesTestUtils.checkStringMatch("exception type", "NotFoundException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.NotFoundException", clreplacedname);
        }
    }
}

15 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTasksQueryInvalid() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        // tasktype must be exactly either "m" or "r"
        String tasktype = "reduce";
        try {
            r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("tasks").queryParam("type", tasktype).accept(MediaType.APPLICATION_JSON).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: tasktype must be either m or r", message);
            WebServicesTestUtils.checkStringMatch("exception type", "BadRequestException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.BadRequestException", clreplacedname);
        }
    }
}

15 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTasksDefault() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("tasks").get(ClientResponse.clreplaced);
        replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
        replacedertEquals("incorrect number of elements", 1, json.length());
        JSONObject tasks = json.getJSONObject("tasks");
        JSONArray arr = tasks.getJSONArray("task");
        replacedertEquals("incorrect number of elements", 2, arr.length());
        verifyHsTask(arr, jobsMap.get(id), null);
    }
}

15 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

public void verifyTaskGeneric(Task task, String id, String state, String type, String successfulAttempt, long startTime, long finishTime, long elapsedTime, float progress) {
    TaskId taskid = task.getID();
    String tid = MRApps.toString(taskid);
    TaskReport report = task.getReport();
    WebServicesTestUtils.checkStringMatch("id", tid, id);
    WebServicesTestUtils.checkStringMatch("type", task.getType().toString(), type);
    WebServicesTestUtils.checkStringMatch("state", report.getTaskState().toString(), state);
    // not easily checked without duplicating logic, just make sure its here
    replacedertNotNull("successfulAttempt null", successfulAttempt);
    replacedertEquals("startTime wrong", report.getStartTime(), startTime);
    replacedertEquals("finishTime wrong", report.getFinishTime(), finishTime);
    replacedertEquals("elapsedTime wrong", finishTime - startTime, elapsedTime);
    replacedertEquals("progress wrong", report.getProgress() * 100, progress, 1e-3f);
}

15 Source : TestHsWebServicesJobs.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobAttemptsDefault() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("jobattempts").get(ClientResponse.clreplaced);
        replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
        replacedertEquals("incorrect number of elements", 1, json.length());
        JSONObject info = json.getJSONObject("jobAttempts");
        verifyHsJobAttempts(info, appContext.getJob(id));
    }
}

15 Source : TestHsWebServicesJobs.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobCountersDefault() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("counters/").get(ClientResponse.clreplaced);
        replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
        replacedertEquals("incorrect number of elements", 1, json.length());
        JSONObject info = json.getJSONObject("jobCounters");
        verifyHsJobCounters(info, appContext.getJob(id));
    }
}

15 Source : TestHsWebServicesJobs.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobIdDefault() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).get(ClientResponse.clreplaced);
        replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
        replacedertEquals("incorrect number of elements", 1, json.length());
        JSONObject info = json.getJSONObject("job");
        VerifyJobsUtils.verifyHsJob(info, appContext.getJob(id));
    }
}

15 Source : TestHsWebServicesJobs.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobCountersForKilledJob() throws Exception {
    WebResource r = resource();
    appContext = new MockHistoryContext(0, 1, 1, 1, true);
    injector = Guice.createInjector(new ServletModule() {

        @Override
        protected void configureServlets() {
            webApp = mock(HsWebApp.clreplaced);
            when(webApp.name()).thenReturn("hsmockwebapp");
            bind(JAXBContextResolver.clreplaced);
            bind(HsWebServices.clreplaced);
            bind(GenericExceptionHandler.clreplaced);
            bind(WebApp.clreplaced).toInstance(webApp);
            bind(AppContext.clreplaced).toInstance(appContext);
            bind(HistoryContext.clreplaced).toInstance(appContext);
            bind(Configuration.clreplaced).toInstance(conf);
            serve("/*").with(GuiceContainer.clreplaced);
        }
    });
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("counters/").accept(MediaType.APPLICATION_JSON).get(ClientResponse.clreplaced);
        replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
        replacedertEquals("incorrect number of elements", 1, json.length());
        JSONObject info = json.getJSONObject("jobCounters");
        WebServicesTestUtils.checkStringMatch("id", MRApps.toString(id), info.getString("id"));
        replacedertTrue("Job shouldn't contain any counters", info.length() == 1);
    }
}

15 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTasksQueryInvalid() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        // tasktype must be exactly either "m" or "r"
        String tasktype = "reduce";
        try {
            r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks").queryParam("type", tasktype).accept(MediaType.APPLICATION_JSON).get(JSONObject.clreplaced);
            fail("should have thrown exception on invalid uri");
        } catch (UniformInterfaceException ue) {
            ClientResponse response = ue.getResponse();
            replacedertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
            JSONObject exception = msg.getJSONObject("RemoteException");
            replacedertEquals("incorrect number of elements", 3, exception.length());
            String message = exception.getString("message");
            String type = exception.getString("exception");
            String clreplacedname = exception.getString("javaClreplacedName");
            WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: tasktype must be either m or r", message);
            WebServicesTestUtils.checkStringMatch("exception type", "BadRequestException", type);
            WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.BadRequestException", clreplacedname);
        }
    }
}

15 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTasksDefault() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        ClientResponse response = r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks").get(ClientResponse.clreplaced);
        replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
        replacedertEquals("incorrect number of elements", 1, json.length());
        JSONObject tasks = json.getJSONObject("tasks");
        JSONArray arr = tasks.getJSONArray("task");
        replacedertEquals("incorrect number of elements", 2, arr.length());
        verifyAMTask(arr, jobsMap.get(id), null);
    }
}

15 Source : TestAMWebServicesTasks.java
with Apache License 2.0
from NJUJYB

public void verifyTaskGeneric(Task task, String id, String state, String type, String successfulAttempt, long startTime, long finishTime, long elapsedTime, float progress, String status) {
    TaskId taskid = task.getID();
    String tid = MRApps.toString(taskid);
    TaskReport report = task.getReport();
    WebServicesTestUtils.checkStringMatch("id", tid, id);
    WebServicesTestUtils.checkStringMatch("type", task.getType().toString(), type);
    WebServicesTestUtils.checkStringMatch("state", report.getTaskState().toString(), state);
    // not easily checked without duplicating logic, just make sure its here
    replacedertNotNull("successfulAttempt null", successfulAttempt);
    replacedertEquals("startTime wrong", report.getStartTime(), startTime);
    replacedertEquals("finishTime wrong", report.getFinishTime(), finishTime);
    replacedertEquals("elapsedTime wrong", finishTime - startTime, elapsedTime);
    replacedertEquals("progress wrong", report.getProgress() * 100, progress, 1e-3f);
    replacedertEquals("status wrong", report.getStatus(), status);
}

15 Source : TestAMWebServicesJobs.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobAttemptsDefault() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        ClientResponse response = r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("jobattempts").get(ClientResponse.clreplaced);
        replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
        replacedertEquals("incorrect number of elements", 1, json.length());
        JSONObject info = json.getJSONObject("jobAttempts");
        verifyJobAttempts(info, jobsMap.get(id));
    }
}

15 Source : TestAMWebServicesJobs.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobIdDefault() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        ClientResponse response = r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).get(ClientResponse.clreplaced);
        replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
        replacedertEquals("incorrect number of elements", 1, json.length());
        JSONObject info = json.getJSONObject("job");
        verifyAMJob(info, jobsMap.get(id));
    }
}

15 Source : TestAMWebServicesJobs.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobCountersDefault() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        ClientResponse response = r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("counters/").get(ClientResponse.clreplaced);
        replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
        replacedertEquals("incorrect number of elements", 1, json.length());
        JSONObject info = json.getJSONObject("jobCounters");
        verifyAMJobCounters(info, jobsMap.get(id));
    }
}

15 Source : TestAMWebApp.java
with Apache License 2.0
from NJUJYB

public static Map<String, String> getTaskParams(AppContext appContext) {
    JobId jobId = appContext.getAllJobs().entrySet().iterator().next().getKey();
    Entry<TaskId, Task> e = appContext.getJob(jobId).getTasks().entrySet().iterator().next();
    e.getValue().getType();
    Map<String, String> params = new HashMap<String, String>();
    params.put(AMParams.JOB_ID, MRApps.toString(jobId));
    params.put(AMParams.TASK_ID, MRApps.toString(e.getKey()));
    params.put(AMParams.TASK_TYPE, MRApps.taskSymbol(e.getValue().getType()));
    return params;
}

15 Source : SingleCounterBlock.java
with Apache License 2.0
from NJUJYB

private void populateMembers(AppContext ctx) {
    JobId jobID = null;
    TaskId taskID = null;
    String tid = $(TASK_ID);
    if (!tid.isEmpty()) {
        taskID = MRApps.toTaskID(tid);
        jobID = taskID.getJobId();
    } else {
        String jid = $(JOB_ID);
        if (!jid.isEmpty()) {
            jobID = MRApps.toJobID(jid);
        }
    }
    if (jobID == null) {
        return;
    }
    job = ctx.getJob(jobID);
    if (job == null) {
        return;
    }
    if (taskID != null) {
        task = job.getTask(taskID);
        if (task == null) {
            return;
        }
        for (Map.Entry<TaskAttemptId, TaskAttempt> entry : task.getAttempts().entrySet()) {
            long value = 0;
            Counters counters = entry.getValue().getCounters();
            CounterGroup group = (counters != null) ? counters.getGroup($(COUNTER_GROUP)) : null;
            if (group != null) {
                Counter c = group.findCounter($(COUNTER_NAME));
                if (c != null) {
                    value = c.getValue();
                }
            }
            values.put(MRApps.toString(entry.getKey()), value);
        }
        return;
    }
    // Get all types of counters
    Map<TaskId, Task> tasks = job.getTasks();
    for (Map.Entry<TaskId, Task> entry : tasks.entrySet()) {
        long value = 0;
        Counters counters = entry.getValue().getCounters();
        CounterGroup group = (counters != null) ? counters.getGroup($(COUNTER_GROUP)) : null;
        if (group != null) {
            Counter c = group.findCounter($(COUNTER_NAME));
            if (c != null) {
                value = c.getValue();
            }
        }
        values.put(MRApps.toString(entry.getKey()), value);
    }
}

14 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTasksSlash() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("tasks/").accept(MediaType.APPLICATION_JSON).get(ClientResponse.clreplaced);
        replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
        replacedertEquals("incorrect number of elements", 1, json.length());
        JSONObject tasks = json.getJSONObject("tasks");
        JSONArray arr = tasks.getJSONArray("task");
        replacedertEquals("incorrect number of elements", 2, arr.length());
        verifyHsTask(arr, jobsMap.get(id), null);
    }
}

14 Source : TestHsWebServicesTasks.java
with Apache License 2.0
from NJUJYB

@Test
public void testTaskIdCountersDefault() throws JSONException, Exception {
    WebResource r = resource();
    Map<JobId, Job> jobsMap = appContext.getAllJobs();
    for (JobId id : jobsMap.keySet()) {
        String jobId = MRApps.toString(id);
        for (Task task : jobsMap.get(id).getTasks().values()) {
            String tid = MRApps.toString(task.getID());
            ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid).path("counters").get(ClientResponse.clreplaced);
            replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
            JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
            replacedertEquals("incorrect number of elements", 1, json.length());
            JSONObject info = json.getJSONObject("jobTaskCounters");
            verifyHsJobTaskCounters(info, task);
        }
    }
}

See More Examples