You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2021/11/25 03:09:43 UTC
[GitHub] [helix] junkaixue commented on a change in pull request #1913: Implement RestSnapShot and substitute the kv maps in HelixDataAccessorWrapper to a RestSnapShot object
junkaixue commented on a change in pull request #1913:
URL: https://github.com/apache/helix/pull/1913#discussion_r756540805
##########
File path: helix-rest/src/main/java/org/apache/helix/rest/common/HelixDataAccessorWrapper.java
##########
@@ -205,25 +210,62 @@ public HelixDataAccessorWrapper(ZKHelixDataAccessor dataAccessor,
}
}
+ public RestSnapShot getRestSnapShot() {
+ return _restSnapShot;
+ }
+
@Override
public <T extends HelixProperty> T getProperty(PropertyKey key) {
- if (_propertyCache.containsKey(key)) {
- return (T) _propertyCache.get(key);
+ T property = _restSnapShot.getProperty(key);
+ if (property == null) {
+ property = super.getProperty(key);
+ _restSnapShot.updateProperty(key, property);
}
- T property = super.getProperty(key);
- _propertyCache.put(key, property);
+
return property;
}
@Override
public List<String> getChildNames(PropertyKey key) {
- if (_batchNameCache.containsKey(key)) {
- return _batchNameCache.get(key);
+ List<String> names = _restSnapShot.getChildNames(key);
+ if (names == null) {
+ names = super.getChildNames(key);
+ _restSnapShot.updateChildNames(key, names);
}
+ return names;
+ }
- List<String> names = super.getChildNames(key);
- _batchNameCache.put(key, names);
+ public void fetchIdealStatesExternalViewStateModel() {
Review comment:
Let's make comments for the user would like to implement these functions.
##########
File path: helix-rest/src/main/java/org/apache/helix/rest/common/datamodel/RestSnapShot.java
##########
@@ -19,18 +18,69 @@
* under the License.
*/
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.PropertyType;
+
/* This Snapshot can extend Snapshot from common/core module
* once there is more generic snapshot.
+ * An Snapshot object should contain all the Helix related info that an implementation of
+ * OperationAbstractClass would need.
*/
+
+// TODO: Future: Support hierarchical Snapshot type for other services besides cluster MaintenanceService.
+
public class RestSnapShot {
- /* An Snapshot object should contain all the Helix related info that an implementation of
- * OperationAbstractClass would need.
- */
+ private final Map<PropertyKey, HelixProperty> _propertyCache;
+ private final Map<PropertyKey, List<String>> _childNodesCache;
+ private Set<PropertyType> _propertyTypes;
+ private String _clusterName;
+
+ public RestSnapShot(String clusterName) {
+ _propertyCache = new HashMap<>();
+ _childNodesCache = new HashMap<>();
+ _propertyTypes = new HashSet<>();
+ _clusterName = clusterName;
+ }
+
+ public <T extends HelixProperty> T getProperty(PropertyKey key) {
Review comment:
Do we support this kind of return type in SNAPSHOT for RoutingTable? If yes, let's keep this convention. Otherwise, this is more specific for snapshot public API.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org