Source:
private void refreshCurrentStatesCache(HelixDataAccessor accessor, Map<String, LiveInstance> liveInstanceMap) { long start = System.currentTimeMillis(); PropertyKey.Builder keyBuilder = accessor.keyBuilder(); Set<PropertyKey> currentStateKeys = new HashSet<>(); for (String instanceName : liveInstanceMap.keySet()) { LiveInstance liveInstance = liveInstanceMap.get(instanceName); String sessionId = liveInstance.getEphemeralOwner(); List<String> currentStateNames = accessor.getChildNames(keyBuilder.currentStates(instanceName, sessionId)); for (String currentStateName : currentStateNames) { currentStateKeys.add(keyBuilder.currentState(instanceName, sessionId, currentStateName)); } } Set<PropertyKey> reloadKeys = new HashSet<>(currentStateKeys); reloadKeys.removeAll(_currentStateCache.keySet()); Set<PropertyKey> cachedKeys = new HashSet<>(_currentStateCache.keySet()); cachedKeys.retainAll(currentStateKeys); Map<PropertyKey, CurrentState> newStateCache = Collections.unmodifiableMap( refreshProperties(accessor, reloadKeys, new ArrayList<>(cachedKeys), _currentStateCache, reloadKeys)); if (_initialized) { _snapshot = new CurrentStateSnapshot(newStateCache, _currentStateCache, reloadKeys); } else { _snapshot = new CurrentStateSnapshot(newStateCache); _initialized = true; } _currentStateCache = newStateCache; if (LOG.isDebugEnabled()) { LogUtil.logDebug(LOG, genEventInfo(), "# of CurrentStates reload: " + reloadKeys.size() + ", skipped:" + ( currentStateKeys.size() - reloadKeys.size()) + ". took " + (System.currentTimeMillis() - start) + " ms to reload new current states for cluster: " + _controlContextProvider .getClusterName()); } }

Target:
private void refreshCurrentStatesCache(HelixDataAccessor accessor, Map<String, LiveInstance> liveInstanceMap) { long start = System.currentTimeMillis(); PropertyKey.Builder keyBuilder = accessor.keyBuilder(); Set<PropertyKey> currentStateKeys = new HashSet<>(); for (String instanceName : liveInstanceMap.keySet()) { LiveInstance liveInstance = liveInstanceMap.get(instanceName); String sessionId = liveInstance.getEphemeralOwner(); List<String> currentStateNames = accessor.getChildNames(keyBuilder.currentStates(instanceName, sessionId)); for (String currentStateName : currentStateNames) { currentStateKeys.add(keyBuilder.currentState(instanceName, sessionId, currentStateName)); } } Set<PropertyKey> reloadKeys = new HashSet<>(currentStateKeys); reloadKeys.removeAll(_currentStateCache.keySet()); Set<PropertyKey> cachedKeys = new HashSet<>(_currentStateCache.keySet()); cachedKeys.retainAll(currentStateKeys); Set<PropertyKey> reloadedKeys = new HashSet<>(); Map<PropertyKey, CurrentState> newStateCache = Collections.unmodifiableMap( refreshProperties(accessor, reloadKeys, new ArrayList<>(cachedKeys), _currentStateCache, reloadedKeys)); if (_initialized) { _snapshot = new CurrentStateSnapshot(newStateCache, _currentStateCache, reloadedKeys); } else { _snapshot = new CurrentStateSnapshot(newStateCache); _initialized = true; } _currentStateCache = newStateCache; if (LOG.isDebugEnabled()) { LogUtil.logDebug(LOG, genEventInfo(), "# of CurrentStates reload: " + reloadKeys.size() + ", skipped:" + ( currentStateKeys.size() - reloadKeys.size()) + ". took " + (System.currentTimeMillis() - start) + " ms to reload new current states for cluster: " + _controlContextProvider .getClusterName()); } }