private boolean adviseEldestGatewaySender() {
    Profile[] snapshot = profiles;

    // sender with minimum startTime is eldest. Find out the minimum start time
    // of remote senders.
    TreeSet<Long> senderStartTimes = new TreeSet<>();
    for (Profile profile : snapshot) {
      GatewaySenderProfile sp = (GatewaySenderProfile) profile;
      if (!sp.isParallel && sp.isRunning) {
        senderStartTimes.add(sp.startTime);
      }
    }

    // if none of the remote senders is running, then this sender should
    // volunteer for primary
    // if there are remote senders running and this sender is not running then
    // it should give up
    // and allow existing running senders to volunteer
    return (senderStartTimes.isEmpty())
        || (sender.isRunning() && (sender.startTime <= senderStartTimes.first()));
  }
Find out if this sender is the eldest in the DS. Returns true if: 1. No other sender is running
2. At least one sender is running in the system apart from this sender AND this sender's start
time is lesser of all (i.e. this sender is oldest)

@return boolean true if this eldest sender; false otherwise
geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java