List<RemoteReplicaGroup> enqueue() {
      processFinishedGroups();

      if (!shouldEnqueue()) {
        logger.trace("Thread name: {} Not creating any new groups", threadName);
        return getInflightGroups();
      }

      fillActiveGroups();
      fillStandByGroups();
      List<RemoteReplicaGroup> inflightGroups = getInflightGroups();

      // if we are not able to create any new group and no groups are remaining, all replicas caught up early
      if (inflightGroups.isEmpty()) {
        allReplicasCaughtUpEarly = true;
        logger.trace("Thread name: {} All replicas marked to caught up early", threadName);
      }
      return inflightGroups;
    }
Tries to update remote replica groups currently in progress and
creates new remote replica groups
ambry-replication/src/main/java/com/github/ambry/replication/ReplicaThread.java