public static int getNumberOfReplicaInStateFromMetric(String state, MetricRegistry metricRegistry) {
    String mkey = metricRegistry.getGauges()
        .keySet()
        .stream()
        .filter(key -> key.startsWith(HelixParticipant.class.getName() + "." + state))
        .findFirst()
        .get();
    return ((Integer) metricRegistry.getGauges().get(mkey).getValue()).intValue();
  }
Return the number of replicas at the given state from the metric;
@param state The state
@param metricRegistry The metric registry
@return
ambry-clustermap/src/test/java/com/github/ambry/clustermap/TestUtils.java