当前位置: 首页>>代码示例>>Java>>正文


Java MockNM类代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.resourcemanager.MockNM的典型用法代码示例。如果您正苦于以下问题:Java MockNM类的具体用法?Java MockNM怎么用?Java MockNM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MockNM类属于org.apache.hadoop.yarn.server.resourcemanager包,在下文中一共展示了MockNM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNodesQueryNew

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testNodesQueryNew() throws JSONException, Exception {
  WebResource r = resource();
  MockNM nm1 = rm.registerNode("h1:1234", 5120);
  MockNM nm2 = rm.registerNode("h2:1235", 5121);
  rm.sendNodeStarted(nm1);
  rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING);
  rm.NMwaitForState(nm2.getNodeId(), NodeState.NEW);

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("nodes").queryParam("states", NodeState.NEW.toString())
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);

  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject nodes = json.getJSONObject("nodes");
  assertEquals("incorrect number of elements", 1, nodes.length());
  JSONArray nodeArray = nodes.getJSONArray("node");
  assertEquals("incorrect number of elements", 1, nodeArray.length());
  JSONObject info = nodeArray.getJSONObject(0);

  verifyNodeInfo(info, nm2);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestRMWebServicesNodes.java

示例2: testNodesQueryRunning

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testNodesQueryRunning() throws JSONException, Exception {
  WebResource r = resource();
  MockNM nm1 = rm.registerNode("h1:1234", 5120);
  MockNM nm2 = rm.registerNode("h2:1235", 5121);
  rm.sendNodeStarted(nm1);
  rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING);
  rm.NMwaitForState(nm2.getNodeId(), NodeState.NEW);
  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("nodes").queryParam("states", "running")
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject nodes = json.getJSONObject("nodes");
  assertEquals("incorrect number of elements", 1, nodes.length());
  JSONArray nodeArray = nodes.getJSONArray("node");
  assertEquals("incorrect number of elements", 1, nodeArray.length());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestRMWebServicesNodes.java

示例3: testNodesQueryHealthyFalse

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testNodesQueryHealthyFalse() throws JSONException, Exception {
  WebResource r = resource();
  MockNM nm1 = rm.registerNode("h1:1234", 5120);
  MockNM nm2 = rm.registerNode("h2:1235", 5121);
  rm.sendNodeStarted(nm1);
  rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING);
  rm.NMwaitForState(nm2.getNodeId(), NodeState.NEW);
  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("nodes").queryParam("states", "UNHEALTHY")
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  assertEquals("nodes is not null", JSONObject.NULL, json.get("nodes"));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestRMWebServicesNodes.java

示例4: testNodesXML

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testNodesXML() throws JSONException, Exception {
  rm.start();
  WebResource r = resource();
  MockNM nm1 = rm.registerNode("h1:1234", 5120);
  // MockNM nm2 = rm.registerNode("h2:1235", 5121);
  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("nodes").accept(MediaType.APPLICATION_XML)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
  String xml = response.getEntity(String.class);
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  InputSource is = new InputSource();
  is.setCharacterStream(new StringReader(xml));
  Document dom = db.parse(is);
  NodeList nodesApps = dom.getElementsByTagName("nodes");
  assertEquals("incorrect number of elements", 1, nodesApps.getLength());
  NodeList nodes = dom.getElementsByTagName("node");
  assertEquals("incorrect number of elements", 1, nodes.getLength());
  verifyNodesXML(nodes, nm1);
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestRMWebServicesNodes.java

示例5: testSingleNodesXML

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testSingleNodesXML() throws JSONException, Exception {
  rm.start();
  WebResource r = resource();
  MockNM nm1 = rm.registerNode("h1:1234", 5120);
  // MockNM nm2 = rm.registerNode("h2:1235", 5121);
  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("nodes").path("h1:1234").accept(MediaType.APPLICATION_XML)
      .get(ClientResponse.class);

  assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
  String xml = response.getEntity(String.class);

  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("node");
  assertEquals("incorrect number of elements", 1, nodes.getLength());
  verifyNodesXML(nodes, nm1);
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestRMWebServicesNodes.java

示例6: testQueryAll

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testQueryAll() throws Exception {
  WebResource r = resource();
  MockNM nm1 = rm.registerNode("h1:1234", 5120);
  MockNM nm2 = rm.registerNode("h2:1235", 5121);
  MockNM nm3 = rm.registerNode("h3:1236", 5122);
  rm.sendNodeStarted(nm1);
  rm.sendNodeStarted(nm3);
  rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING);
  rm.NMwaitForState(nm2.getNodeId(), NodeState.NEW);
  rm.sendNodeLost(nm3);

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("nodes")
      .queryParam("states", Joiner.on(',').join(EnumSet.allOf(NodeState.class)))
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);

  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  JSONObject nodes = json.getJSONObject("nodes");
  assertEquals("incorrect number of elements", 1, nodes.length());
  JSONArray nodeArray = nodes.getJSONArray("node");
  assertEquals("incorrect number of elements", 3, nodeArray.length());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestRMWebServicesNodes.java

示例7: verifyNodesXML

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
public void verifyNodesXML(NodeList nodes, MockNM nm) throws JSONException,
    Exception {
  for (int i = 0; i < nodes.getLength(); i++) {
    Element element = (Element) nodes.item(i);
    verifyNodeInfoGeneric(nm,
        WebServicesTestUtils.getXmlString(element, "state"),
        WebServicesTestUtils.getXmlString(element, "rack"),
        WebServicesTestUtils.getXmlString(element, "id"),
        WebServicesTestUtils.getXmlString(element, "nodeHostName"),
        WebServicesTestUtils.getXmlString(element, "nodeHTTPAddress"),
        WebServicesTestUtils.getXmlLong(element, "lastHealthUpdate"),
        WebServicesTestUtils.getXmlString(element, "healthReport"),
        WebServicesTestUtils.getXmlInt(element, "numContainers"),
        WebServicesTestUtils.getXmlLong(element, "usedMemoryMB"),
        WebServicesTestUtils.getXmlLong(element, "availMemoryMB"),
        WebServicesTestUtils.getXmlLong(element, "usedVirtualCores"),
        WebServicesTestUtils.getXmlLong(element,  "availableVirtualCores"),
        WebServicesTestUtils.getXmlLong(element, "usedGpuCores"),
        WebServicesTestUtils.getXmlLong(element, "availableGpuCores"),
        WebServicesTestUtils.getXmlString(element, "version"));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRMWebServicesNodes.java

示例8: verifyNodeInfo

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
public void verifyNodeInfo(JSONObject nodeInfo, MockNM nm)
    throws JSONException, Exception {
  assertEquals("incorrect number of elements", 15, nodeInfo.length());

  verifyNodeInfoGeneric(nm, nodeInfo.getString("state"),
      nodeInfo.getString("rack"),
      nodeInfo.getString("id"), nodeInfo.getString("nodeHostName"),
      nodeInfo.getString("nodeHTTPAddress"),
      nodeInfo.getLong("lastHealthUpdate"),
      nodeInfo.getString("healthReport"), nodeInfo.getInt("numContainers"),
      nodeInfo.getLong("usedMemoryMB"), nodeInfo.getLong("availMemoryMB"),
      nodeInfo.getLong("usedVirtualCores"), nodeInfo.getLong("availableVirtualCores"),
      nodeInfo.getLong("usedGpuCores"), nodeInfo.getLong("availableGpuCores"),
      nodeInfo.getString("version"));

}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestRMWebServicesNodes.java

示例9: testSingleAppState

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testSingleAppState() throws Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  String[] mediaTypes =
      { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML };
  for (String mediaType : mediaTypes) {
    RMApp app = rm.submitApp(CONTAINER_MB, "", webserviceUserName);
    amNodeManager.nodeHeartbeat(true);
    ClientResponse response =
        this
          .constructWebResource("apps", app.getApplicationId().toString(),
            "state").accept(mediaType).get(ClientResponse.class);
    assertEquals(Status.OK, response.getClientResponseStatus());
    if (mediaType.equals(MediaType.APPLICATION_JSON)) {
      verifyAppStateJson(response, RMAppState.ACCEPTED);
    } else if (mediaType.equals(MediaType.APPLICATION_XML)) {
      verifyAppStateXML(response, RMAppState.ACCEPTED);
    }
  }
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRMWebServicesAppsModification.java

示例10: testSingleAppKillInvalidId

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testSingleAppKillInvalidId() throws Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  amNodeManager.nodeHeartbeat(true);
  String[] testAppIds = { "application_1391705042196_0001", "random_string" };
  for (String testAppId : testAppIds) {
    AppState info = new AppState("KILLED");
    ClientResponse response =
        this.constructWebResource("apps", testAppId, "state")
          .accept(MediaType.APPLICATION_XML)
          .entity(info, MediaType.APPLICATION_XML).put(ClientResponse.class);
    if (!isAuthenticationEnabled()) {
      assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus());
      continue;
    }
    assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
  }
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestRMWebServicesAppsModification.java

示例11: testAppsXML

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testAppsXML() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  RMApp app1 = rm.submitApp(CONTAINER_MB, "testwordcount", "user1");
  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps").accept(MediaType.APPLICATION_XML)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
  String xml = response.getEntity(String.class);
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  InputSource is = new InputSource();
  is.setCharacterStream(new StringReader(xml));
  Document dom = db.parse(is);
  NodeList nodesApps = dom.getElementsByTagName("apps");
  assertEquals("incorrect number of elements", 1, nodesApps.getLength());
  NodeList nodes = dom.getElementsByTagName("app");
  assertEquals("incorrect number of elements", 1, nodes.getLength());
  verifyAppsXML(nodes, app1);
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestRMWebServicesApps.java

示例12: testAppsXMLMulti

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testAppsXMLMulti() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  rm.submitApp(CONTAINER_MB, "testwordcount", "user1");
  rm.submitApp(2048, "testwordcount2", "user1");

  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps").accept(MediaType.APPLICATION_XML)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
  String xml = response.getEntity(String.class);
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  InputSource is = new InputSource();
  is.setCharacterStream(new StringReader(xml));
  Document dom = db.parse(is);
  NodeList nodesApps = dom.getElementsByTagName("apps");
  assertEquals("incorrect number of elements", 1, nodesApps.getLength());
  NodeList nodes = dom.getElementsByTagName("app");
  assertEquals("incorrect number of elements", 2, nodes.getLength());
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestRMWebServicesApps.java

示例13: testAppsQueryState

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testAppsQueryState() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  RMApp app1 = rm.submitApp(CONTAINER_MB);
  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps")
      .queryParam("state", YarnApplicationState.ACCEPTED.toString())
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject apps = json.getJSONObject("apps");
  assertEquals("incorrect number of elements", 1, apps.length());
  JSONArray array = apps.getJSONArray("app");
  assertEquals("incorrect number of elements", 1, array.length());
  verifyAppInfo(array.getJSONObject(0), app1);
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRMWebServicesApps.java

示例14: testAppsQueryStatesNone

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testAppsQueryStatesNone() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  rm.submitApp(CONTAINER_MB);
  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps")
      .queryParam("states", YarnApplicationState.RUNNING.toString())
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  assertEquals("apps is not null", JSONObject.NULL, json.get("apps"));
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestRMWebServicesApps.java

示例15: testAppsQueryStateNone

import org.apache.hadoop.yarn.server.resourcemanager.MockNM; //导入依赖的package包/类
@Test
public void testAppsQueryStateNone() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  rm.submitApp(CONTAINER_MB);
  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps")
      .queryParam("state", YarnApplicationState.RUNNING.toString())
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  assertEquals("apps is not null", JSONObject.NULL, json.get("apps"));
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestRMWebServicesApps.java


注:本文中的org.apache.hadoop.yarn.server.resourcemanager.MockNM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。