Set<InternalDistributedMember> adviseAllEventsOrCached()
      throws IllegalStateException {
    getAdvisee().getCancelCriterion().checkCancelInProgress(null);

    // minimize volatile reads by copying ref to local var
    long tempProfilesVersion = profilesVersion; // volatile read
    long tempInRecoveryVersion = inRecoveryVersion; // volatile read

    if (adviseAllEventsVersion != tempProfilesVersion
        || adviseInRecoveryVersion != tempInRecoveryVersion) {
      synchronized (adviseSetforAllEvents) {
        if (adviseAllEventsVersion != tempProfilesVersion
            || adviseInRecoveryVersion != tempInRecoveryVersion) {

          adviseSetforAllEvents = Collections.unmodifiableSet(adviseFilter(profile -> {
            CacheProfile cp = (CacheProfile) profile;
            if (cp.getInRecovery()) {
              return false;
            }
            return cp.cachedOrAllEventsWithListener();
          }));
          adviseAllEventsVersion = tempProfilesVersion;
          adviseInRecoveryVersion = tempInRecoveryVersion;
        }
      }
    }
    return adviseSetforAllEvents;

  }
Returns a the set of members that either want all events or are caching data.
geode-core/src/main/java/org/apache/geode/internal/cache/CacheDistributionAdvisor.java