gpt4 book ai didi

org.apache.hadoop.yarn.webapp.WebServicesTestUtils类的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 20:39:05 26 4
gpt4 key购买 nike

本文整理了Java中org.apache.hadoop.yarn.webapp.WebServicesTestUtils类的一些代码示例,展示了WebServicesTestUtils类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebServicesTestUtils类的具体详情如下:
包路径:org.apache.hadoop.yarn.webapp.WebServicesTestUtils
类名称:WebServicesTestUtils

WebServicesTestUtils介绍

暂无

代码示例

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

public void verifyAppsXML(NodeList nodes, RMApp app) throws JSONException,
  Exception {
  for (int i = 0; i < nodes.getLength(); i++) {
  Element element = (Element) nodes.item(i);
  verifyAppInfoGeneric(app,
    WebServicesTestUtils.getXmlString(element, "id"),
    WebServicesTestUtils.getXmlString(element, "user"),
    WebServicesTestUtils.getXmlString(element, "name"),
    WebServicesTestUtils.getXmlString(element, "applicationType"),
    WebServicesTestUtils.getXmlString(element, "queue"),
    WebServicesTestUtils.getXmlString(element, "state"),
    WebServicesTestUtils.getXmlString(element, "finalStatus"),
    WebServicesTestUtils.getXmlFloat(element, "progress"),
    WebServicesTestUtils.getXmlString(element, "trackingUI"),
    WebServicesTestUtils.getXmlString(element, "diagnostics"),
    WebServicesTestUtils.getXmlLong(element, "clusterId"),
    WebServicesTestUtils.getXmlLong(element, "startedTime"),
    WebServicesTestUtils.getXmlLong(element, "finishedTime"),
    WebServicesTestUtils.getXmlLong(element, "elapsedTime"),
    WebServicesTestUtils.getXmlString(element, "amHostHttpAddress"),
    WebServicesTestUtils.getXmlString(element, "amContainerLogs"),
    WebServicesTestUtils.getXmlInt(element, "allocatedMB"),
    WebServicesTestUtils.getXmlInt(element, "allocatedVCores"),
    WebServicesTestUtils.getXmlInt(element, "runningContainers"),
    WebServicesTestUtils.getXmlInt(element, "preemptedResourceMB"),
    WebServicesTestUtils.getXmlInt(element, "preemptedResourceVCores"),
    WebServicesTestUtils.getXmlInt(element, "numNonAMContainerPreempted"),
    WebServicesTestUtils.getXmlInt(element, "numAMContainerPreempted"));
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

public static void assertResponseStatusCode(StatusType expected,
  StatusType actual) {
 assertResponseStatusCode(null, expected, actual);
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

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);
   assertNotNull("should have counters in the web service info", counters);
   String name = WebServicesTestUtils.getXmlString(counters,
     "counterGroupName");
   assertTrue("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");
    assertTrue("counter name not set",
      (counterName != null && !counterName.isEmpty()));
    long value = WebServicesTestUtils.getXmlLong(counter, "value");
    assertTrue("value not >= 0", value >= 0);
   }
  }
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

public void verifyAMSingleTaskXML(Element element, Task task) {
 verifyTaskGeneric(task, WebServicesTestUtils.getXmlString(element, "id"),
   WebServicesTestUtils.getXmlString(element, "state"),
   WebServicesTestUtils.getXmlString(element, "type"),
   WebServicesTestUtils.getXmlString(element, "successfulAttempt"),
   WebServicesTestUtils.getXmlLong(element, "startTime"),
   WebServicesTestUtils.getXmlLong(element, "finishTime"),
   WebServicesTestUtils.getXmlLong(element, "elapsedTime"),
   WebServicesTestUtils.getXmlFloat(element, "progress"),
   WebServicesTestUtils.getXmlString(element, "status"));
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private void verifyAppAttemptsXML(NodeList nodes, RMAppAttempt appAttempt,
    String user) {
 for (int i = 0; i < nodes.getLength(); i++) {
  Element element = (Element) nodes.item(i);
  verifyAppAttemptInfoGeneric(appAttempt,
      WebServicesTestUtils.getXmlInt(element, "id"),
      WebServicesTestUtils.getXmlLong(element, "startTime"),
      WebServicesTestUtils.getXmlString(element, "containerId"),
      WebServicesTestUtils.getXmlString(element, "nodeHttpAddress"),
      WebServicesTestUtils.getXmlString(element, "nodeId"),
      WebServicesTestUtils.getXmlString(element, "logsLink"), user);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

public void verifyClusterInfoXML(String xml) throws Exception {
 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
 DocumentBuilder db = dbf.newDocumentBuilder();
 InputSource is = new InputSource();
 is.setCharacterStream(new StringReader(xml));
 Document dom = db.parse(is);
 NodeList nodes = dom.getElementsByTagName("clusterInfo");
 assertEquals("incorrect number of elements", 1, nodes.getLength());
 for (int i = 0; i < nodes.getLength(); i++) {
  Element element = (Element) nodes.item(i);
  verifyClusterGeneric(WebServicesTestUtils.getXmlLong(element, "id"),
    WebServicesTestUtils.getXmlLong(element, "startedOn"),
    WebServicesTestUtils.getXmlString(element, "state"),
    WebServicesTestUtils.getXmlString(element, "haState"),
    WebServicesTestUtils.getXmlString(
      element, "haZooKeeperConnectionState"),
    WebServicesTestUtils.getXmlString(element, "hadoopVersionBuiltOn"),
    WebServicesTestUtils.getXmlString(element, "hadoopBuildVersion"),
    WebServicesTestUtils.getXmlString(element, "hadoopVersion"),
    WebServicesTestUtils.getXmlString(element,
                     "resourceManagerVersionBuiltOn"),
    WebServicesTestUtils.getXmlString(element,
                     "resourceManagerBuildVersion"),
    WebServicesTestUtils.getXmlString(element, "resourceManagerVersion"));
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Test
public void testInvalidUri2() throws JSONException, Exception {
 WebResource r = resource();
 String responseStr = "";
 try {
  responseStr = r.accept(MediaType.APPLICATION_JSON).get(String.class);
  fail("should have thrown exception on invalid uri");
 } catch (UniformInterfaceException ue) {
  ClientResponse response = ue.getResponse();
  assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
  WebServicesTestUtils.checkStringMatch(
    "error string exists and shouldn't", "", responseStr);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

public static int getXmlInt(Element element, String name) {
 String val = getXmlString(element, name);
 return Integer.parseInt(val);
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

} catch (UniformInterfaceException ue) {
 ClientResponse response = ue.getResponse();
 assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
 assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
   response.getType().toString());
 String type = exception.getString("exception");
 String classname = exception.getString("javaClassName");
 WebServicesTestUtils.checkStringEqual("exception message",
   "java.lang.Exception: TaskId string : "
     + "task_0_0000_d_000000 is not properly formed"
     + "\nReason: java.util.regex.Matcher[pattern=" +
     TaskID.TASK_ID_REGEX + " region=0,20 lastmatch=]", message);
 WebServicesTestUtils.checkStringMatch("exception type",
   "NotFoundException", type);
 WebServicesTestUtils.checkStringMatch("exception classname",
   "org.apache.hadoop.yarn.webapp.NotFoundException", classname);

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

ClientResponse response = ue.getResponse();
assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo());
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
  response.getType().toString());
String classname = exception.getString("javaClassName");
WebServicesTestUtils
  .checkStringContains(
    "exception message",
    "org.apache.hadoop.yarn.api.records.NodeState.BOGUSSTATE",
    message);
WebServicesTestUtils.checkStringMatch("exception type",
  "IllegalArgumentException", type);
WebServicesTestUtils.checkStringMatch("exception classname",
  "java.lang.IllegalArgumentException", classname);

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

public void verifySchedulerFifoXML(String xml) throws JSONException,
  Exception {
 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
 DocumentBuilder db = dbf.newDocumentBuilder();
 InputSource is = new InputSource();
 is.setCharacterStream(new StringReader(xml));
 Document dom = db.parse(is);
 NodeList nodesSched = dom.getElementsByTagName("scheduler");
 assertEquals("incorrect number of elements", 1, nodesSched.getLength());
 NodeList nodes = dom.getElementsByTagName("schedulerInfo");
 assertEquals("incorrect number of elements", 1, nodes.getLength());
 for (int i = 0; i < nodes.getLength(); i++) {
  Element element = (Element) nodes.item(i);
  verifyClusterSchedulerFifoGeneric(
    WebServicesTestUtils.getXmlAttrString(element, "xsi:type"),
    WebServicesTestUtils.getXmlString(element, "qstate"),
    WebServicesTestUtils.getXmlFloat(element, "capacity"),
    WebServicesTestUtils.getXmlFloat(element, "usedCapacity"),
    WebServicesTestUtils.getXmlInt(element, "minQueueMemoryCapacity"),
    WebServicesTestUtils.getXmlInt(element, "maxQueueMemoryCapacity"),
    WebServicesTestUtils.getXmlInt(element, "numNodes"),
    WebServicesTestUtils.getXmlInt(element, "usedNodeCapacity"),
    WebServicesTestUtils.getXmlInt(element, "availNodeCapacity"),
    WebServicesTestUtils.getXmlInt(element, "totalNodeCapacity"),
    WebServicesTestUtils.getXmlInt(element, "numContainers"));
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

qi.capacity = WebServicesTestUtils.getXmlFloat(qElem, "capacity");
qi.usedCapacity =
  WebServicesTestUtils.getXmlFloat(qElem, "usedCapacity");
qi.maxCapacity = WebServicesTestUtils.getXmlFloat(qElem, "maxCapacity");
qi.absoluteCapacity = WebServicesTestUtils.getXmlFloat(qElem, "absoluteCapacity");
qi.absoluteMaxCapacity =
  WebServicesTestUtils.getXmlFloat(qElem, "absoluteMaxCapacity");
qi.absoluteUsedCapacity =
 WebServicesTestUtils.getXmlFloat(qElem, "absoluteUsedCapacity");
qi.numApplications =
  WebServicesTestUtils.getXmlInt(qElem, "numApplications");
qi.queueName = WebServicesTestUtils.getXmlString(qElem, "queueName");
qi.state = WebServicesTestUtils.getXmlString(qElem, "state");
verifySubQueueGeneric(q, qi, parentAbsCapacity, parentAbsMaxCapacity);
if (hasSubQueues) {
   for (int k = 0; k < qListInfos.getLength(); k++) {
    Element qElem3 = (Element) qListInfos.item(k);
    String qName3 = WebServicesTestUtils.getXmlString(qElem3, "queueName");
    String q3 = q + "." + qName3;
    verifySubQueueXML(qElem3, q3, qi.absoluteCapacity, qi.absoluteMaxCapacity);
 LeafQueueInfo lqi = (LeafQueueInfo) qi;
 lqi.numActiveApplications =
   WebServicesTestUtils.getXmlInt(qElem, "numActiveApplications");
 lqi.numPendingApplications =
   WebServicesTestUtils.getXmlInt(qElem, "numPendingApplications");
 lqi.numContainers =
   WebServicesTestUtils.getXmlInt(qElem, "numContainers");

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

public void verifyClusterGeneric(long clusterid, long startedon,
  String state, String haState, String haZooKeeperConnectionState,
  String hadoopVersionBuiltOn,
  String hadoopBuildVersion, String hadoopVersion,
  String resourceManagerVersionBuiltOn, String resourceManagerBuildVersion,
  String resourceManagerVersion) {
 assertEquals("clusterId doesn't match: ",
   ResourceManager.getClusterTimeStamp(), clusterid);
 assertEquals("startedOn doesn't match: ",
   ResourceManager.getClusterTimeStamp(), startedon);
 assertTrue("stated doesn't match: " + state,
   state.matches(STATE.INITED.toString()));
 assertTrue("HA state doesn't match: " + haState,
   haState.matches("INITIALIZING"));
 WebServicesTestUtils.checkStringMatch("hadoopVersionBuiltOn",
   VersionInfo.getDate(), hadoopVersionBuiltOn);
 WebServicesTestUtils.checkStringEqual("hadoopBuildVersion",
   VersionInfo.getBuildVersion(), hadoopBuildVersion);
 WebServicesTestUtils.checkStringMatch("hadoopVersion",
   VersionInfo.getVersion(), hadoopVersion);
 WebServicesTestUtils.checkStringMatch("resourceManagerVersionBuiltOn",
   YarnVersionInfo.getDate(), resourceManagerVersionBuiltOn);
 WebServicesTestUtils.checkStringEqual("resourceManagerBuildVersion",
   YarnVersionInfo.getBuildVersion(), resourceManagerBuildVersion);
 WebServicesTestUtils.checkStringMatch("resourceManagerVersion",
   YarnVersionInfo.getVersion(), resourceManagerVersion);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

public void verifyClusterSchedulerXML(NodeList nodes) throws Exception {
 for (int i = 0; i < nodes.getLength(); i++) {
  Element element = (Element) nodes.item(i);
  verifyClusterSchedulerGeneric(
    WebServicesTestUtils.getXmlAttrString(element, "xsi:type"),
    WebServicesTestUtils.getXmlFloat(element, "usedCapacity"),
    WebServicesTestUtils.getXmlFloat(element, "capacity"),
    WebServicesTestUtils.getXmlFloat(element, "maxCapacity"),
    WebServicesTestUtils.getXmlString(element, "queueName"));
  NodeList children = element.getChildNodes();
  for (int j = 0; j < children.getLength(); j++) {
   Element qElem = (Element) children.item(j);
   if(qElem.getTagName().equals("queues")) {
    NodeList qListInfos = qElem.getChildNodes();
    for (int k = 0; k < qListInfos.getLength(); k++) {
     Element qElem2 = (Element) qListInfos.item(k);
     String qName2 = WebServicesTestUtils.getXmlString(qElem2, "queueName");
     String q2 = CapacitySchedulerConfiguration.ROOT + "." + qName2;
     verifySubQueueXML(qElem2, q2, 100, 100);
    }
   }
  }
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

public void verifyAMJobConfXML(NodeList nodes, Job job) {
 assertEquals("incorrect number of elements", 1, nodes.getLength());
 for (int i = 0; i < nodes.getLength(); i++) {
  Element element = (Element) nodes.item(i);
  WebServicesTestUtils.checkStringMatch("path", job.getConfFile()
    .toString(), WebServicesTestUtils.getXmlString(element, "path"));
  // just do simple verification of fields - not data is correct
  // in the fields
  NodeList properties = element.getElementsByTagName("property");
  for (int j = 0; j < properties.getLength(); j++) {
   Element property = (Element) properties.item(j);
   assertNotNull("should have counters in the web service info", property);
   String name = WebServicesTestUtils.getXmlString(property, "name");
   String value = WebServicesTestUtils.getXmlString(property, "value");
   assertTrue("name not set", (name != null && !name.isEmpty()));
   assertTrue("name not set", (value != null && !value.isEmpty()));
  }
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private void validateJsonExceptionContent(ClientResponse response,
  String expectedmessage)
  throws JSONException {
 Assert.assertEquals(BAD_REQUEST_CODE, response.getStatus());
 JSONObject msg = response.getEntity(JSONObject.class);
 JSONObject exception = msg.getJSONObject("RemoteException");
 String message = exception.getString("message");
 assertEquals("incorrect number of elements", 3, exception.length());
 String type = exception.getString("exception");
 String classname = exception.getString("javaClassName");
 WebServicesTestUtils.checkStringMatch("exception type",
   "BadRequestException", type);
 WebServicesTestUtils.checkStringMatch("exception classname",
   "org.apache.hadoop.yarn.webapp.BadRequestException", classname);
 WebServicesTestUtils.checkStringContains("exception message",
   expectedmessage, message);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

.path("apps").queryParam("deSelects", "INVALIED_deSelectsParam")
   .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
 assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo());
 assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
   response.getType().toString());
 String type = exception.getString("exception");
 String classname = exception.getString("javaClassName");
 WebServicesTestUtils.checkStringContains("exception message",
   "java.lang.Exception: Invalid deSelects string"
     + " INVALIED_deSelectsParam " + "specified. It should be one of",
   message);
 WebServicesTestUtils.checkStringEqual("exception type",
   "BadRequestException", type);
 WebServicesTestUtils.checkStringEqual("exception classname",
   "org.apache.hadoop.yarn.webapp.BadRequestException", classname);
} finally {

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

private void verifyJobIdInvalid(String message, String type, String classname) {
 WebServicesTestUtils.checkStringMatch("exception message",
   "java.lang.Exception: JobId string : job_foo is not properly formed",
   message);
 WebServicesTestUtils.checkStringMatch("exception type",
   "NotFoundException", type);
 WebServicesTestUtils.checkStringMatch("exception classname",
   "org.apache.hadoop.yarn.webapp.NotFoundException", classname);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

WebServicesTestUtils.getXmlInt(element, "appsSubmitted"),
WebServicesTestUtils.getXmlInt(element, "appsCompleted"),
WebServicesTestUtils.getXmlInt(element, "reservedMB"),
WebServicesTestUtils.getXmlInt(element, "availableMB"),
WebServicesTestUtils.getXmlInt(element, "allocatedMB"),
WebServicesTestUtils.getXmlInt(element, "reservedVirtualCores"),
WebServicesTestUtils.getXmlInt(element, "availableVirtualCores"),
WebServicesTestUtils.getXmlInt(element, "allocatedVirtualCores"),
WebServicesTestUtils.getXmlInt(element, "totalVirtualCores"),
WebServicesTestUtils.getXmlInt(element, "containersAllocated"),
WebServicesTestUtils.getXmlInt(element, "totalMB"),
WebServicesTestUtils.getXmlInt(element, "totalNodes"),
WebServicesTestUtils.getXmlInt(element, "lostNodes"),
WebServicesTestUtils.getXmlInt(element, "unhealthyNodes"),
WebServicesTestUtils.getXmlInt(element, "decommissionedNodes"),
WebServicesTestUtils.getXmlInt(element, "rebootedNodes"),
WebServicesTestUtils.getXmlInt(element, "activeNodes"),
WebServicesTestUtils.getXmlInt(element, "shutdownNodes"));

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

String type = exception.getString("exception");
 String className = exception.getString("javaClassName");
 WebServicesTestUtils.checkStringContains("exception message",
   "we temporarily support at most one applicationType", message);
 WebServicesTestUtils.checkStringEqual("exception type",
   "BadRequestException", type);
 WebServicesTestUtils.checkStringEqual("exception className",
   "org.apache.hadoop.yarn.webapp.BadRequestException", className);
 type = exception.getString("exception");
 className = exception.getString("javaClassName");
 WebServicesTestUtils.checkStringContains("exception message",
   "Invalid application-state wrong_state", message);
 WebServicesTestUtils.checkStringEqual("exception type",
   "BadRequestException", type);
 WebServicesTestUtils.checkStringEqual("exception className",
   "org.apache.hadoop.yarn.webapp.BadRequestException", className);
} finally {

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com