private void initializeResourceToHistogramMap(ClusterMap clusterMap, RouterConfig routerConfig) {
    String localDatacenterName = clusterMap.getDatacenterName(clusterMap.getLocalDatacenterId());
    switch (routerConfig.routerOperationTrackerMetricScope) {
      case Partition:
        for (PartitionId partitionId : clusterMap.getAllPartitionIds(null)) {
          getBlobLocalDcResourceToLatency.put(partitionId, createHistogram(routerConfig, false));
          getBlobInfoLocalDcResourceToLatency.put(partitionId, createHistogram(routerConfig, false));
          getBlobCrossDcResourceToLatency.put(partitionId, createHistogram(routerConfig, false));
          getBlobInfoCrossDcResourceToLatency.put(partitionId, createHistogram(routerConfig, false));
          putBlobResourceToLatency.put(partitionId, createHistogram(routerConfig, false));
        }
        break;
      case DataNode:
        List<? extends DataNodeId> dataNodeIds = clusterMap.getDataNodeIds();
        for (DataNodeId dataNodeId : dataNodeIds) {
          if (dataNodeId.getDatacenterName().equals(localDatacenterName)) {
            getBlobLocalDcResourceToLatency.put(dataNodeId, createHistogram(routerConfig, false));
            getBlobInfoLocalDcResourceToLatency.put(dataNodeId, createHistogram(routerConfig, false));
            // Put blob only cares abou local db data nodes.
            putBlobResourceToLatency.put(dataNodeId, createHistogram(routerConfig, false));
          } else {
            getBlobCrossDcResourceToLatency.put(dataNodeId, createHistogram(routerConfig, false));
            getBlobInfoCrossDcResourceToLatency.put(dataNodeId, createHistogram(routerConfig, false));
          }
        }
        break;
      case Disk:
        for (PartitionId partitionId : clusterMap.getAllPartitionIds(null)) {
          for (ReplicaId replicaId : partitionId.getReplicaIds()) {
            DiskId diskId = replicaId.getDiskId();
            if (getBlobLocalDcResourceToLatency.containsKey(diskId) || getBlobCrossDcResourceToLatency.containsKey(
                diskId)) {
              continue;
            }
            if (replicaId.getDataNodeId().getDatacenterName().equals(localDatacenterName)) {
              getBlobLocalDcResourceToLatency.put(diskId, createHistogram(routerConfig, false));
              getBlobInfoLocalDcResourceToLatency.put(diskId, createHistogram(routerConfig, false));
              putBlobResourceToLatency.put(diskId, createHistogram(routerConfig, false));
            } else {
              getBlobCrossDcResourceToLatency.put(diskId, createHistogram(routerConfig, false));
              getBlobInfoCrossDcResourceToLatency.put(diskId, createHistogram(routerConfig, false));
            }
          }
        }
      default:
        // if routerOperationTrackerMetricScope = Datacenter, do nothing in this method because datacenter-level
        // histograms and pastDueCounter are always instantiated.
    }
  }
Initialize resource-to-latency-histogram maps based on given resource type. Here resource can be {@link PartitionId},
{@link DataNodeId}, etc. The resource type is defined by {@link RouterConfig#routerOperationTrackerMetricScope}.
@param clusterMap the {@link ClusterMap} that contains info of all resources.
@param routerConfig the {@link RouterConfig} that specifies histogram parameters.
ambry-router/src/main/java/com/github/ambry/router/NonBlockingRouterMetrics.java