kaisun2000 commented on a change in pull request #1451:
URL: https://github.com/apache/helix/pull/1451#discussion_r510529616
##########
File path:
helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
##########
@@ -259,7 +259,15 @@ public void testUpdateConfigFields() throws IOException {
record.getSimpleFields().clear();
record.setSimpleField(key, value + "--updated");
- key = record.getListFields().keySet().iterator().next();
+ // skip INSTANCE_CAPACITY_KEYS which can be added by waged rebalancer in
global run
Review comment:
That said, this is not guess. See the analysis in #1336. Basically, the
only code path is following:
>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> getNonTrimmableFields(ClusterConfig property) {
return STATIC_TOPOLOGY_RELATED_FIELD_MAP;
} -->
private static final Map<FieldType, Set> 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]