hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestNodeManager.java
@Test
  public void testScmCanHandleScale() throws IOException,
      InterruptedException, TimeoutException {
    final int healthyCount = 3000;
    final int staleCount = 3000;
    OzoneConfiguration conf = getConf();
    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 100,
        MILLISECONDS);
    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_INTERVAL, 1,
        SECONDS);
    conf.setTimeDuration(OZONE_SCM_STALENODE_INTERVAL, 3 * 1000,
        MILLISECONDS);
    conf.setTimeDuration(OZONE_SCM_DEADNODE_INTERVAL, 6 * 1000,
        MILLISECONDS);

    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
      List<DatanodeDetails> healthyList = createNodeSet(nodeManager,
          healthyCount);
      List<DatanodeDetails> staleList = createNodeSet(nodeManager,
          staleCount);

      Runnable healthyNodeTask = () -> {
        try {
          heartbeatNodeSet(nodeManager, healthyList, 2 * 1000);
        } catch (InterruptedException ignored) {

        }
      };

      Runnable staleNodeTask = () -> {
        try {
          heartbeatNodeSet(nodeManager, staleList, 4 * 1000);
        } catch (InterruptedException ignored) {
        }
      };

      Thread thread1 = new Thread(healthyNodeTask);
      thread1.setDaemon(true);
      thread1.start();

      Thread thread2 = new Thread(staleNodeTask);
      thread2.setDaemon(true);
      thread2.start();
      Thread.sleep(3 * 1000);

      GenericTestUtils.waitFor(() -> findNodes(nodeManager, staleCount, STALE),
          500, 20 * 1000);
      assertEquals("Node count mismatch",
          healthyCount + staleCount, nodeManager.getAllNodes().size());

      thread1.interrupt();
      thread2.interrupt();
    }
  }
/**
   * Asserts that we can handle 6000+ nodes heartbeating SCM.
   *
   * @throws IOException
   * @throws InterruptedException
   * @throws TimeoutException
   */
Asserts that we can handle 6000+ nodes heartbeating SCM.
Asserts that we can handle 6000 + nodes heartbeating SCM .
@Test
  public void testScmCanHandleScale() throws IOException,
      InterruptedException, TimeoutException {
    final int healthyCount = 3000;
    final int staleCount = 3000;
    OzoneConfiguration conf = getConf();
    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 100,
        MILLISECONDS);
    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_INTERVAL, 1,
        SECONDS);
    conf.setTimeDuration(OZONE_SCM_STALENODE_INTERVAL, 3 * 1000,
        MILLISECONDS);
    conf.setTimeDuration(OZONE_SCM_DEADNODE_INTERVAL, 6 * 1000,
        MILLISECONDS);
    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
      List<DatanodeDetails> healthyList = createNodeSet(nodeManager,
          healthyCount);
      List<DatanodeDetails> staleList = createNodeSet(nodeManager,
          staleCount);
      Runnable healthyNodeTask = () -> {
        try {
          heartbeatNodeSet(nodeManager, healthyList, 2 * 1000);
        } catch (InterruptedException ignored) {
        }
      };
      Runnable staleNodeTask = () -> {
        try {
          heartbeatNodeSet(nodeManager, staleList, 4 * 1000);
        } catch (InterruptedException ignored) {
        }
      };
      Thread thread1 = new Thread(healthyNodeTask);
      thread1.setDaemon(true);
      thread1.start();
      Thread thread2 = new Thread(staleNodeTask);
      thread2.setDaemon(true);
      thread2.start();
      Thread.sleep(3 * 1000);
      GenericTestUtils.waitFor(() -> findNodes(nodeManager, staleCount, STALE),
          500, 20 * 1000);
      assertEquals("Node count mismatch",
          healthyCount + staleCount, nodeManager.getAllNodes().size());
      thread1.interrupt();
      thread2.interrupt();
    }
  }
@ Test public void testScmCanHandleScale ( ) throws IOException , InterruptedException , TimeoutException { final int healthyCount = 3000 ; final int staleCount = 3000 ; OzoneConfiguration conf = getConf ( ) ; conf . setTimeDuration ( OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL , 100 , MILLISECONDS ) ; conf . setTimeDuration ( OZONE_SCM_HEARTBEAT_INTERVAL , 1 , SECONDS ) ; conf . setTimeDuration ( OZONE_SCM_STALENODE_INTERVAL , 3 * 1000 , MILLISECONDS ) ; conf . setTimeDuration ( OZONE_SCM_DEADNODE_INTERVAL , 6 * 1000 , MILLISECONDS ) ; try ( SCMNodeManager nodeManager = createNodeManager ( conf ) ) { List < DatanodeDetails > healthyList = createNodeSet ( nodeManager , healthyCount ) ; List < DatanodeDetails > staleList = createNodeSet ( nodeManager , staleCount ) ; Runnable healthyNodeTask = ( ) -> { try { heartbeatNodeSet ( nodeManager , healthyList , 2 * 1000 ) ; } catch ( InterruptedException ignored ) { } } ; Runnable staleNodeTask = ( ) -> { try { heartbeatNodeSet ( nodeManager , staleList , 4 * 1000 ) ; } catch ( InterruptedException ignored ) { } } ; Thread thread1 = new Thread ( healthyNodeTask ) ; thread1 . setDaemon ( true ) ; thread1 . start ( ) ; Thread thread2 = new Thread ( staleNodeTask ) ; thread2 . setDaemon ( true ) ; thread2 . start ( ) ; Thread . sleep ( 3 * 1000 ) ; GenericTestUtils . waitFor ( ( ) -> findNodes ( nodeManager , staleCount , STALE ) , 500 , 20 * 1000 ) ; assertEquals ( "Node count mismatch" , healthyCount + staleCount , nodeManager . getAllNodes ( ) . size ( ) ) ; thread1 . interrupt ( ) ; thread2 . interrupt ( ) ; } }
Asserts that we can handle 6000+ nodes heartbeating SCM.
Asserts that we can handle 6000 + nodes heartbeating SCM .