hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestNodeManager.java
@Test
  public void testScmStatsFromNodeReport() throws IOException,
      InterruptedException, TimeoutException {
    OzoneConfiguration conf = getConf();
    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 1000,
        MILLISECONDS);
    final int nodeCount = 10;
    final long capacity = 2000;
    final long used = 100;
    final long remaining = capacity - used;

    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
      for (int x = 0; x < nodeCount; x++) {
        DatanodeDetails datanodeDetails = TestUtils.getDatanodeDetails(
            nodeManager);

        SCMNodeReport.Builder nrb = SCMNodeReport.newBuilder();
        SCMStorageReport.Builder srb = SCMStorageReport.newBuilder();
        srb.setStorageUuid(UUID.randomUUID().toString());
        srb.setCapacity(capacity).setScmUsed(used).
            setRemaining(capacity - used).build();
        nodeManager.sendHeartbeat(datanodeDetails.getProtoBufMessage(),
            nrb.addStorageReport(srb).build(), reportState);
      }
      GenericTestUtils.waitFor(() -> nodeManager.waitForHeartbeatProcessed(),
          100, 4 * 1000);
      assertEquals(nodeCount, nodeManager.getNodeCount(HEALTHY));
      assertEquals(capacity * nodeCount, (long) nodeManager.getStats()
          .getCapacity().get());
      assertEquals(used * nodeCount, (long) nodeManager.getStats()
          .getScmUsed().get());
      assertEquals(remaining * nodeCount, (long) nodeManager.getStats()
          .getRemaining().get());
    }
  }
/**
   * Test multiple nodes sending initial heartbeat with their node report.
   *
   * @throws IOException
   * @throws InterruptedException
   * @throws TimeoutException
   */
Test multiple nodes sending initial heartbeat with their node report.
Test multiple nodes sending initial heartbeat with their node report .
@Test
  public void testScmStatsFromNodeReport() throws IOException,
      InterruptedException, TimeoutException {
    OzoneConfiguration conf = getConf();
    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 1000,
        MILLISECONDS);
    final int nodeCount = 10;
    final long capacity = 2000;
    final long used = 100;
    final long remaining = capacity - used;
    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
      for (int x = 0; x < nodeCount; x++) {
        DatanodeDetails datanodeDetails = TestUtils.getDatanodeDetails(
            nodeManager);
        SCMNodeReport.Builder nrb = SCMNodeReport.newBuilder();
        SCMStorageReport.Builder srb = SCMStorageReport.newBuilder();
        srb.setStorageUuid(UUID.randomUUID().toString());
        srb.setCapacity(capacity).setScmUsed(used).
            setRemaining(capacity - used).build();
        nodeManager.sendHeartbeat(datanodeDetails.getProtoBufMessage(),
            nrb.addStorageReport(srb).build(), reportState);
      }
      GenericTestUtils.waitFor(() -> nodeManager.waitForHeartbeatProcessed(),
          100, 4 * 1000);
      assertEquals(nodeCount, nodeManager.getNodeCount(HEALTHY));
      assertEquals(capacity * nodeCount, (long) nodeManager.getStats()
          .getCapacity().get());
      assertEquals(used * nodeCount, (long) nodeManager.getStats()
          .getScmUsed().get());
      assertEquals(remaining * nodeCount, (long) nodeManager.getStats()
          .getRemaining().get());
    }
  }
@ Test public void testScmStatsFromNodeReport ( ) throws IOException , InterruptedException , TimeoutException { OzoneConfiguration conf = getConf ( ) ; conf . setTimeDuration ( OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL , 1000 , MILLISECONDS ) ; final int nodeCount = 10 ; final long capacity = 2000 ; final long used = 100 ; final long remaining = capacity - used ; try ( SCMNodeManager nodeManager = createNodeManager ( conf ) ) { for ( int x = 0 ; x < nodeCount ; x ++ ) { DatanodeDetails datanodeDetails = TestUtils . getDatanodeDetails ( nodeManager ) ; SCMNodeReport . Builder nrb = SCMNodeReport . newBuilder ( ) ; SCMStorageReport . Builder srb = SCMStorageReport . newBuilder ( ) ; srb . setStorageUuid ( UUID . randomUUID ( ) . toString ( ) ) ; srb . setCapacity ( capacity ) . setScmUsed ( used ) . setRemaining ( capacity - used ) . build ( ) ; nodeManager . sendHeartbeat ( datanodeDetails . getProtoBufMessage ( ) , nrb . addStorageReport ( srb ) . build ( ) , reportState ) ; } GenericTestUtils . waitFor ( ( ) -> nodeManager . waitForHeartbeatProcessed ( ) , 100 , 4 * 1000 ) ; assertEquals ( nodeCount , nodeManager . getNodeCount ( HEALTHY ) ) ; assertEquals ( capacity * nodeCount , ( long ) nodeManager . getStats ( ) . getCapacity ( ) . get ( ) ) ; assertEquals ( used * nodeCount , ( long ) nodeManager . getStats ( ) . getScmUsed ( ) . get ( ) ) ; assertEquals ( remaining * nodeCount , ( long ) nodeManager . getStats ( ) . getRemaining ( ) . get ( ) ) ; } }
Test multiple nodes sending initial heartbeat with their node report.
Test multiple nodes sending initial heartbeat with their node report .