private void recoverSingleRegion(LocalRegion r, Map<Object, InterestResultPolicy> keys,
      final @NotNull InterestType interestType,
      Connection recoveredConnection, boolean isDurable, boolean receiveValues,
      boolean isFirstNewConnection) {

    if (logger.isDebugEnabled()) {
      logger.debug("{}.recoverSingleRegion starting kind={} region={}: {}", this,
          InterestType.getString(interestType), r.getFullPath(), keys);
    }

    // build a HashMap, key is policy, value is list
    HashMap<InterestResultPolicy, LinkedList<Object>> policyMap = new HashMap<>();
    for (Map.Entry<Object, InterestResultPolicy> me : keys.entrySet()) {
      // restore and commit an interest
      Object key = me.getKey();
      InterestResultPolicy pol = me.getValue();

      if (interestType == InterestType.KEY) {
        // Gester: we only consolidate the key into list for InterestType.KEY
        LinkedList<Object> keyList = policyMap.get(pol);
        if (keyList == null) {

          keyList = new LinkedList<>();
        }
        keyList.add(key);
        policyMap.put(pol, keyList);
      } else {
        // for other Interest type, do it one by one
        recoverSingleKey(r, key, pol, interestType, recoveredConnection, isDurable, receiveValues,
            isFirstNewConnection);
      }
    }

    // Process InterestType.KEY: Iterator list for each each policy
    for (Map.Entry<InterestResultPolicy, LinkedList<Object>> me : policyMap.entrySet()) {
      LinkedList<Object> keyList = me.getValue();
      InterestResultPolicy pol = me.getKey();
      recoverSingleKey(r, keyList, pol, interestType, recoveredConnection, isDurable, receiveValues,
          isFirstNewConnection);
    }
  }
Find a new primary, adding any failed servers we encounter to the excluded servers list

First we try to make a backup server the primary, but if run out of backup servers we will try
to find a new server.
geode-core/src/main/java/org/apache/geode/cache/client/internal/QueueManagerImpl.java