hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestNodeManager.java
@Test
  public void testScmLogsHeartbeatFlooding() throws IOException,
      InterruptedException, TimeoutException {
    final int healthyCount = 3000;

    // Make the HB process thread run slower.
    OzoneConfiguration conf = getConf();
    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 500,
        TimeUnit.MILLISECONDS);
    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_INTERVAL, 1, SECONDS);
    conf.setInt(OZONE_SCM_MAX_HB_COUNT_TO_PROCESS, 500);

    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
      List<DatanodeDetails> healthyList = createNodeSet(nodeManager,
          healthyCount);
      GenericTestUtils.LogCapturer logCapturer =
          GenericTestUtils.LogCapturer.captureLogs(SCMNodeManager.LOG);
      Runnable healthyNodeTask = () -> {
        try {
          // No wait in the HB sending loop.
          heartbeatNodeSet(nodeManager, healthyList, 0);
        } catch (InterruptedException ignored) {
        }
      };
      Thread thread1 = new Thread(healthyNodeTask);
      thread1.setDaemon(true);
      thread1.start();

      GenericTestUtils.waitFor(() -> logCapturer.getOutput()
          .contains("SCM is being "
              + "flooded by heartbeats. Not able to keep up"
              + " with the heartbeat counts."),
          500, 20 * 1000);

      thread1.interrupt();
      logCapturer.stopCapturing();
    }
  }
/**
   * Asserts that SCM backs off from HB processing instead of going into an
   * infinite loop if SCM is flooded with too many heartbeats. This many not be
   * the best thing to do, but SCM tries to protect itself and logs an error
   * saying that it is getting flooded with heartbeats. In real world this can
   * lead to many nodes becoming stale or dead due to the fact that SCM is not
   * able to keep up with heartbeat processing. This test just verifies that SCM
   * will log that information.
   * @throws TimeoutException
   */
Asserts that SCM backs off from HB processing instead of going into an
infinite loop if SCM is flooded with too many heartbeats. This many not be
the best thing to do, but SCM tries to protect itself and logs an error
saying that it is getting flooded with heartbeats. In real world this can
lead to many nodes becoming stale or dead due to the fact that SCM is not
able to keep up with heartbeat processing. This test just verifies that SCM
will log that information.
Asserts that SCM backs off from HB processing instead of going into an infinite loop if SCM is flooded with too many heartbeats . This many not be the best thing to do but SCM tries to protect itself and logs an error saying that it is getting flooded with heartbeats . In real world this can lead to many nodes becoming stale or dead due to the fact that SCM is not able to keep up with heartbeat processing . This test just verifies that SCM will log that information .
@Test
  public void testScmLogsHeartbeatFlooding() throws IOException,
      InterruptedException, TimeoutException {
    final int healthyCount = 3000;
    OzoneConfiguration conf = getConf();
    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 500,
        TimeUnit.MILLISECONDS);
    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_INTERVAL, 1, SECONDS);
    conf.setInt(OZONE_SCM_MAX_HB_COUNT_TO_PROCESS, 500);
    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
      List<DatanodeDetails> healthyList = createNodeSet(nodeManager,
          healthyCount);
      GenericTestUtils.LogCapturer logCapturer =
          GenericTestUtils.LogCapturer.captureLogs(SCMNodeManager.LOG);
      Runnable healthyNodeTask = () -> {
        try {
          heartbeatNodeSet(nodeManager, healthyList, 0);
        } catch (InterruptedException ignored) {
        }
      };
      Thread thread1 = new Thread(healthyNodeTask);
      thread1.setDaemon(true);
      thread1.start();
      GenericTestUtils.waitFor(() -> logCapturer.getOutput()
          .contains("SCM is being "
              + "flooded by heartbeats. Not able to keep up"
              + " with the heartbeat counts."),
          500, 20 * 1000);
      thread1.interrupt();
      logCapturer.stopCapturing();
    }
  }
@ Test public void testScmLogsHeartbeatFlooding ( ) throws IOException , InterruptedException , TimeoutException { final int healthyCount = 3000 ; OzoneConfiguration conf = getConf ( ) ; conf . setTimeDuration ( OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL , 500 , TimeUnit . MILLISECONDS ) ; conf . setTimeDuration ( OZONE_SCM_HEARTBEAT_INTERVAL , 1 , SECONDS ) ; conf . setInt ( OZONE_SCM_MAX_HB_COUNT_TO_PROCESS , 500 ) ; try ( SCMNodeManager nodeManager = createNodeManager ( conf ) ) { List < DatanodeDetails > healthyList = createNodeSet ( nodeManager , healthyCount ) ; GenericTestUtils . LogCapturer logCapturer = GenericTestUtils . LogCapturer . captureLogs ( SCMNodeManager . LOG ) ; Runnable healthyNodeTask = ( ) -> { try { heartbeatNodeSet ( nodeManager , healthyList , 0 ) ; } catch ( InterruptedException ignored ) { } } ; Thread thread1 = new Thread ( healthyNodeTask ) ; thread1 . setDaemon ( true ) ; thread1 . start ( ) ; GenericTestUtils . waitFor ( ( ) -> logCapturer . getOutput ( ) . contains ( "SCM is being " + "flooded by heartbeats. Not able to keep up" + " with the heartbeat counts." ) , 500 , 20 * 1000 ) ; thread1 . interrupt ( ) ; logCapturer . stopCapturing ( ) ; } }
Asserts that SCM backs off from HB processing instead of going into an
 infinite loop if SCM is flooded with too many heartbeats.
Asserts that SCM backs off from HB processing instead of going into an infinite loop if SCM is flooded with too many heartbeats .
// Make the HB process thread run slower. // No wait in the HB sending loop.