Skip to content

Commit

Permalink
Revert "Add ChangeDetector interface and ResourceChangeDetector imple…
Browse files Browse the repository at this point in the history
…mentation (apache#388)"

This reverts commit e0c1c66.
  • Loading branch information
narendly committed Aug 21, 2019
1 parent 7f8cb36 commit 50cadad
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 705 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.Map;
import java.util.Set;

import java.util.concurrent.ConcurrentHashMap;
import org.apache.helix.HelixConstants;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.PropertyKey;
Expand Down Expand Up @@ -66,9 +65,6 @@ public class ResourceControllerDataProvider extends BaseControllerDataProvider {
private Map<String, Map<String, MissingTopStateRecord>> _missingTopStateMap;
private Map<String, Map<String, String>> _lastTopStateLocationMap;

// Maintain a set of all ChangeTypes for change detection
private Set<HelixConstants.ChangeType> _refreshedChangeTypes;

public ResourceControllerDataProvider() {
this(AbstractDataCache.UNKNOWN_CLUSTER);
}
Expand Down Expand Up @@ -111,21 +107,19 @@ public String getObjName(ExternalView obj) {
_idealMappingCache = new HashMap<>();
_missingTopStateMap = new HashMap<>();
_lastTopStateLocationMap = new HashMap<>();
_refreshedChangeTypes = ConcurrentHashMap.newKeySet();
}

public synchronized void refresh(HelixDataAccessor accessor) {
long startTime = System.currentTimeMillis();

// Refresh base
Set<HelixConstants.ChangeType> changedTypes = super.doRefresh(accessor);
_refreshedChangeTypes.addAll(changedTypes);
Set<HelixConstants.ChangeType> propertyRefreshed = super.doRefresh(accessor);

// Invalidate cached information if any of the important data has been refreshed
if (changedTypes.contains(HelixConstants.ChangeType.IDEAL_STATE)
|| changedTypes.contains(HelixConstants.ChangeType.LIVE_INSTANCE)
|| changedTypes.contains(HelixConstants.ChangeType.INSTANCE_CONFIG)
|| changedTypes.contains(HelixConstants.ChangeType.RESOURCE_CONFIG)) {
if (propertyRefreshed.contains(HelixConstants.ChangeType.IDEAL_STATE)
|| propertyRefreshed.contains(HelixConstants.ChangeType.LIVE_INSTANCE)
|| propertyRefreshed.contains(HelixConstants.ChangeType.INSTANCE_CONFIG)
|| propertyRefreshed.contains(HelixConstants.ChangeType.RESOURCE_CONFIG)) {
clearCachedResourceAssignments();
}

Expand Down Expand Up @@ -268,23 +262,6 @@ public void setCachedIdealMapping(String resource, ZNRecord mapping) {
_idealMappingCache.put(resource, mapping);
}

/**
* Return the set of all PropertyTypes that changed prior to this round of rebalance. The caller
* should clear this set by calling {@link #clearRefreshedChangeTypes()}.
* @return
*/
public Set<HelixConstants.ChangeType> getRefreshedChangeTypes() {
return _refreshedChangeTypes;
}

/**
* Clears the set of all PropertyTypes that changed. The caller will have consumed all change
* types by calling {@link #getRefreshedChangeTypes()}.
*/
public void clearRefreshedChangeTypes() {
_refreshedChangeTypes.clear();
}

public void clearCachedResourceAssignments() {
_resourceAssignmentCache.clear();
_idealMappingCache.clear();
Expand Down
Loading

0 comments on commit 50cadad

Please sign in to comment.