kaisun2000 commented on issue #1336:
URL: https://github.com/apache/helix/issues/1336#issuecomment-707508719


   The code path from static analysis seems to be:
   
   computeBestPossibleAssignment -->
   globalRebalance -->
   ResourceChangeDetector.updateSnapshots --> 
   ResourceChangeSnapshot(ResourceControllerDataProvider dataProvider,
         boolean ignoreNonTopologyChange) -->
   
ClusterConfigTrimmer.getInstance().trimProperty(dataProvider.getClusterConfig())
 -->
   HelixPropertyTrimmer.doTrim -->
    copyNonTrimmableInfo(originalZNRecord, trimmedZNRecord, 
getNonTrimmableFields(originalProperty),
           false) -->
     protected Map<FieldType, Set<String>> getNonTrimmableFields(ClusterConfig 
property) {
       return STATIC_TOPOLOGY_RELATED_FIELD_MAP;
     } -->
   
     private static final Map<FieldType, Set<String>> 
STATIC_TOPOLOGY_RELATED_FIELD_MAP = ImmutableMap
         .of(FieldType.SIMPLE_FIELD, ImmutableSet
                 .of(ClusterConfigProperty.TOPOLOGY.name(),
                     ClusterConfigProperty.FAULT_ZONE_TYPE.name(),
                     ClusterConfigProperty.TOPOLOGY_AWARE_ENABLED.name(),
                     ClusterConfigProperty.MAX_PARTITIONS_PER_INSTANCE.name()),
             FieldType.LIST_FIELD, ImmutableSet
                 .of(ClusterConfigProperty.INSTANCE_CAPACITY_KEYS.name()),
             FieldType.MAP_FIELD, ImmutableSet
                 .of(ClusterConfigProperty.DEFAULT_INSTANCE_CAPACITY_MAP.name(),
                 ClusterConfigProperty.DEFAULT_PARTITION_WEIGHT_MAP.name(),
                 ClusterConfigProperty.REBALANCE_PREFERENCE.name()));
   
   Note 
   
   ```
   private void copyNonTrimmableInfo(ZNRecord originalZNRecord, ZNRecord 
trimmedZNRecord,
         Map<FieldType, Set<String>> nonTrimmableFields, boolean trimValue) {
       for (Map.Entry<FieldType, Set<String>> fieldEntry : 
nonTrimmableFields.entrySet()) {
         FieldType fieldType = fieldEntry.getKey();
         Set<String> fieldKeySet = fieldEntry.getValue();
         if (null == fieldKeySet || fieldKeySet.isEmpty()) {
           continue;
         }
         switch (fieldType) {
           case SIMPLE_FIELD:
             fieldKeySet.stream().forEach(fieldKey -> {
               if (originalZNRecord.getSimpleFields().containsKey(fieldKey)) {
                 trimmedZNRecord.getSimpleFields().putIfAbsent(fieldKey,
                     trimValue ? null : 
originalZNRecord.getSimpleField(fieldKey));
               }
             });
             break;
           case LIST_FIELD:
             fieldKeySet.stream().forEach(fieldKey -> {
               if (originalZNRecord.getListFields().containsKey(fieldKey)) {
                 trimmedZNRecord.getListFields().putIfAbsent(fieldKey,
                     trimValue ? **Collections.EMPTY_LIST** : 
originalZNRecord.getListField(fieldKey));
               }
             });
             break;
   
   ```
   This would add an empty INSTANCE_CAPACITY_KEYS=[]


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to