示例#1
0
  public void verifyClusterMetrics(
      int submittedApps,
      int completedApps,
      int reservedMB,
      int availableMB,
      int allocMB,
      int containersAlloc,
      int totalMB,
      int totalNodes,
      int lostNodes,
      int unhealthyNodes,
      int decommissionedNodes,
      int rebootedNodes,
      int activeNodes)
      throws JSONException, Exception {

    ResourceScheduler rs = rm.getResourceScheduler();
    QueueMetrics metrics = rs.getRootQueueMetrics();
    ClusterMetrics clusterMetrics = ClusterMetrics.getMetrics();

    long totalMBExpect = metrics.getAvailableMB() + metrics.getAllocatedMB();

    assertEquals("appsSubmitted doesn't match", metrics.getAppsSubmitted(), submittedApps);
    assertEquals("appsCompleted doesn't match", metrics.getAppsCompleted(), completedApps);
    assertEquals("reservedMB doesn't match", metrics.getReservedMB(), reservedMB);
    assertEquals("availableMB doesn't match", metrics.getAvailableMB(), availableMB);
    assertEquals("allocatedMB doesn't match", metrics.getAllocatedMB(), allocMB);
    assertEquals("containersAllocated doesn't match", 0, containersAlloc);
    assertEquals("totalMB doesn't match", totalMBExpect, totalMB);
    assertEquals(
        "totalNodes doesn't match",
        clusterMetrics.getNumActiveNMs()
            + clusterMetrics.getNumLostNMs()
            + clusterMetrics.getNumDecommisionedNMs()
            + clusterMetrics.getNumRebootedNMs()
            + clusterMetrics.getUnhealthyNMs(),
        totalNodes);
    assertEquals("lostNodes doesn't match", clusterMetrics.getNumLostNMs(), lostNodes);
    assertEquals("unhealthyNodes doesn't match", clusterMetrics.getUnhealthyNMs(), unhealthyNodes);
    assertEquals(
        "decommissionedNodes doesn't match",
        clusterMetrics.getNumDecommisionedNMs(),
        decommissionedNodes);
    assertEquals("rebootedNodes doesn't match", clusterMetrics.getNumRebootedNMs(), rebootedNodes);
    assertEquals("activeNodes doesn't match", clusterMetrics.getNumActiveNMs(), activeNodes);
  }
示例#2
0
  @Test
  public void testAppAttemptMetrics() throws Exception {
    AsyncDispatcher dispatcher = new InlineDispatcher();
    RMContext rmContext = new RMContextImpl(null, dispatcher, null, null, null, null, null);

    FifoScheduler schedular = new FifoScheduler();
    schedular.reinitialize(new Configuration(), null, rmContext);

    ApplicationId appId = BuilderUtils.newApplicationId(200, 1);
    ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(appId, 1);

    SchedulerEvent event = new AppAddedSchedulerEvent(appAttemptId, "queue", "user");
    schedular.handle(event);

    appAttemptId = BuilderUtils.newApplicationAttemptId(appId, 2);

    event = new AppAddedSchedulerEvent(appAttemptId, "queue", "user");
    schedular.handle(event);

    QueueMetrics metrics = schedular.getRootQueueMetrics();
    Assert.assertEquals(1, metrics.getAppsSubmitted());
  }