@Override
    public void onDataNodeRemoved(DataNodeId removedDataNode) {
      logger.info("DataNode: {} is removed from clustermap", removedDataNode);
      if (config.enableRemoveHostFromAccountStatsStore && accountStatsStore != null
          && removedDataNode.getDatacenterName().equals(currentNode.getDatacenterName())) {
        // 1. There are many other server nodes that received this message and are taking action now, we have to
        // use a distributed lock so there will be only one server node who is deleting this data node
        // 2. Start a new thread for this task so that we don't block the listener.
        logger.info(
            "Receive a data node removal message for {}_{}, schedule a task to remove account stats for this host",
            removedDataNode.getHostname(), removedDataNode.getPort());
        scheduler.submit(() -> this.tryRemoveHostFromAccountStatsStore(removedDataNode));
      }
    }
An implementation of {@link ClusterMapChangeListener} to listen on the data node removal.
ambry-server/src/main/java/com/github/ambry/server/StatsManager.java