private static boolean isSameParameterizedCluster(Class<?> registryImpl, int numHedgedReqs) {
    // initialize() is called for every unit test, however we only want to reset the cluster state
    // at the end of every parameterized run.
    if (TEST_UTIL == null) {
      return false;
    }
    Configuration conf = TEST_UTIL.getConfiguration();
    Class<?> confClass = conf.getClass(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
      ZKConnectionRegistry.class);
    int hedgedReqConfig = conf.getInt(MasterRegistry.MASTER_REGISTRY_HEDGED_REQS_FANOUT_KEY,
      AbstractRpcBasedConnectionRegistry.HEDGED_REQS_FANOUT_DEFAULT);
    return confClass.getName().equals(registryImpl.getName()) && numHedgedReqs == hedgedReqConfig;
  }
JUnit does not provide an easy way to run a hook after each parameterized run. Without that
there is no easy way to restart the test cluster after each parameterized run. Annotation
BeforeParam does not work either because it runs before parameterization and hence does not
have access to the test parameters (which is weird). This *hack* checks if the current instance
of test cluster configuration has the passed parameterized configs. In such a case, we can just
reuse the cluster for test and do not need to initialize from scratch. While this is a hack, it
saves a ton of time for the full test and de-flakes it.
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java