private AmbryPartition addPartitionIfAbsent(AmbryPartition partition, long capacityBytes) {
    AmbryPartition currentPartition = partitionNameToAmbryPartition.putIfAbsent(partition.toPathString(), partition);
    if (currentPartition == null) {
      // this means the map previously didn't contain this partition and passed-in partition is successfully added
      // into the map
      currentPartition = partition;
      // it doesn't really need to synchronize this method. "partitionNameToAmbryPartition" guarantees each thread
      // will get same instance of ambry partition. The first one that succeeds adding partition into
      // "partitionNameToAmbryPartition" will update "partitionMap".
      partitionMap.put(ByteBuffer.wrap(currentPartition.getBytes()), currentPartition);
      // update cluster-wide capacity
      clusterWideAllocatedUsableCapacityBytes.getAndAdd(capacityBytes);
    }
    ambryPartitionToAmbryReplicas.putIfAbsent(currentPartition, ConcurrentHashMap.newKeySet());
    return currentPartition;
  }
Add partition if it's not present in cluster-wide partition map and also update cluster-wide allocated usable
capacity. If the partition already exists, skip addition and return current partition.
@param partition the {@link AmbryPartition} to add (if not present)
@param capacityBytes the capacity of partition in bytes
@return the current {@link AmbryPartition} present in the map.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HelixClusterManager.java