/*
 * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
 * (the "License"). You may not use this work except in compliance with the License, which is
 * available at www.apache.org/licenses/LICENSE-2.0
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied, as more fully set forth in the License.
 *
 * See the NOTICE file distributed with this work for information regarding copyright ownership.
 */

package alluxio.client.block;

import io.netty.util.internal.chmv8.ConcurrentHashMapV8;
import org.powermock.reflect.Whitebox;

import java.net.InetSocketAddress;

/**
 * Test utils for {@link BlockStoreContext}.
 */
public class BlockStoreContextTestUtils {
  /**
   * Resets the {@link BlockStoreContext#BLOCK_WORKER_THRIFT_CLIENT_POOL}.
   */
  public static void resetPool() {
    ConcurrentHashMapV8<InetSocketAddress, BlockWorkerThriftClientPool> poolMap =
        Whitebox.getInternalState(BlockStoreContext.class, "BLOCK_WORKER_THRIFT_CLIENT_POOL");
    for (BlockWorkerThriftClientPool pool : poolMap.values()) {
      pool.close();
    }
    poolMap.clear();
  }
}

@@ -1175,15 +1175,342 @@
 clear();
+%0A%0A    ConcurrentHashMapV8%3CInetSocketAddress, BlockWorkerThriftClientPool%3E heartbeatPoolMap = Whitebox%0A        .getInternalState(BlockStoreContext.class, %22BLOCK_WORKER_THRIFT_CLIENT_HEARTBEAT_POOL%22);%0A    for (BlockWorkerThriftClientPool pool : heartbeatPoolMap.values()) %7B%0A      pool.close();%0A    %7D%0A    heartbeatPoolMap.clear();
 %0A  %7D%0A%7D%0A

update whitebox