void handleDataNodeDelete(String instanceName) {
      synchronized (notificationLock) {
        AmbryDataNode datanode = instanceNameToAmbryDataNode.get(instanceName);
        if (datanode != null) {
          // Remove disks and replicas on this node.
          List<ReplicaId> removedReplicas = new ArrayList<>();
          for (AmbryDisk disk : ambryDataNodeToAmbryDisks.get(datanode)) {
            clusterWideRawCapacityBytes.getAndAdd(-disk.getRawCapacityInBytes());
          }
          for (AmbryReplica replica : ambryDataNodeToAmbryReplicas.get(datanode).values()) {
            removeReplicasFromPartition(replica.getPartitionId(), Collections.singletonList(replica));
            removedReplicas.add(replica);
          }
          ambryDataNodeToAmbryDisks.remove(datanode);
          ambryDataNodeToAmbryReplicas.remove(datanode);
          // Remove datanode
          dcToNodes.getOrDefault(datanode.getDatacenterName(), Collections.emptySet()).remove(datanode);
          instanceNameToAmbryDataNode.remove(instanceName);
          allInstances.remove(instanceName);
          // Inform about removed replicas to cluster map change listeners
          if (!removedReplicas.isEmpty()) {
            for (ClusterMapChangeListener listener : clusterMapChangeListeners) {
              listener.onReplicaAddedOrRemoved(Collections.emptyList(), removedReplicas);
            }
          }
          for (ClusterMapChangeListener listener : clusterMapChangeListeners) {
            listener.onDataNodeRemoved(datanode);
          }
          logger.info("Removed {} and its {} replicas from cluster map", instanceName, removedReplicas.size());
          // Since the replicas on deleted hosts could be sealed, increase the sealed change counter so that latest
          // partition state (RO or RW) is queried again in AmbryPartition#resolvePartitionState().
          long counter = sealedStateChangeCounter.incrementAndGet();
          logger.trace("SealedStateChangeCounter increase to {}", counter);
        } else {
          logger.info("Node {} already removed from cluster map", instanceName);
        }
        helixClusterManagerMetrics.instanceDeleteTriggerCount.inc();
      }
    }
Handle deletion of a node from cluster.
@param instanceName instance that was deleted
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HelixClusterManager.java