Source:
HelixParticipantMetrics(MetricRegistry metricRegistry, String zkConnectStr, Map<String, ReplicaState> localPartitionAndState) { String zkSuffix = zkConnectStr == null ? "" : "-" + zkConnectStr; Gauge<Integer> bootstrapPartitionCount = () -> Collections.frequency(localPartitionAndState.values(), ReplicaState.BOOTSTRAP); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "bootstrapPartitionCount" + zkSuffix), bootstrapPartitionCount); Gauge<Integer> standbyPartitionCount = () -> Collections.frequency(localPartitionAndState.values(), ReplicaState.STANDBY); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "standbyPartitionCount" + zkSuffix), standbyPartitionCount); Gauge<Integer> leaderPartitionCount = () -> Collections.frequency(localPartitionAndState.values(), ReplicaState.LEADER); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "leaderPartitionCount" + zkSuffix), leaderPartitionCount); Gauge<Integer> inactivePartitionCount = () -> Collections.frequency(localPartitionAndState.values(), ReplicaState.INACTIVE); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "inactivePartitionCount" + zkSuffix), inactivePartitionCount); Gauge<Integer> offlinePartitionCount = () -> Collections.frequency(localPartitionAndState.values(), ReplicaState.OFFLINE); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "offlinePartitionCount" + zkSuffix), offlinePartitionCount); Gauge<Integer> errorStatePartitionCount = () -> Collections.frequency(localPartitionAndState.values(), ReplicaState.ERROR); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "errorStatePartitionCount" + zkSuffix), errorStatePartitionCount); partitionDroppedCount = metricRegistry.counter(MetricRegistry.name(HelixParticipant.class, "partitionDroppedCount" + zkSuffix)); }

Target:
HelixParticipantMetrics(MetricRegistry metricRegistry, String zkConnectStr, Map<String, ReplicaState> localPartitionAndState) { String zkSuffix = zkConnectStr == null ? "" : "-" + zkConnectStr; this.localPartitionAndState = localPartitionAndState; EnumSet.complementOf(EnumSet.of(ReplicaState.DROPPED)).forEach(state -> replicaCountByState.put(state, 0)); Gauge<Integer> bootstrapPartitionCount = () -> getReplicaCountInState(ReplicaState.BOOTSTRAP); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "bootstrapPartitionCount" + zkSuffix), bootstrapPartitionCount); Gauge<Integer> standbyPartitionCount = () -> getReplicaCountInState(ReplicaState.STANDBY); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "standbyPartitionCount" + zkSuffix), standbyPartitionCount); Gauge<Integer> leaderPartitionCount = () -> getReplicaCountInState(ReplicaState.LEADER); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "leaderPartitionCount" + zkSuffix), leaderPartitionCount); Gauge<Integer> inactivePartitionCount = () -> getReplicaCountInState(ReplicaState.INACTIVE); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "inactivePartitionCount" + zkSuffix), inactivePartitionCount); Gauge<Integer> offlinePartitionCount = () -> getReplicaCountInState(ReplicaState.OFFLINE); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "offlinePartitionCount" + zkSuffix), offlinePartitionCount); Gauge<Integer> errorStatePartitionCount = () -> getReplicaCountInState(ReplicaState.ERROR); metricRegistry.register(MetricRegistry.name(HelixParticipant.class, "errorStatePartitionCount" + zkSuffix), errorStatePartitionCount); partitionDroppedCount = metricRegistry.counter(MetricRegistry.name(HelixParticipant.class, "partitionDroppedCount" + zkSuffix)); }