desaikomal commented on code in PR #2106:
URL: https://github.com/apache/helix/pull/2106#discussion_r888587126


##########
helix-core/src/test/java/org/apache/helix/integration/controller/TestControllerLeadershipChange.java:
##########
@@ -74,6 +82,51 @@ public void afterClass() {
   }
 
   @Test
+  public void testControllerCleanUpClusterConfig() {

Review Comment:
   there are 3 testcases: 1. we don't have DISABLED_INSTANCES at all. before 
the pipeline and after the pipeline config should match as no update should 
have happened. 2. this test scenario.   3. original DISABLE_INSTANCE related 
test-case verifying that it remains same.



##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java:
##########
@@ -241,21 +241,64 @@ private void refreshClusterConfig(final HelixDataAccessor 
accessor,
     if 
(_propertyDataChangedMap.get(HelixConstants.ChangeType.CLUSTER_CONFIG).getAndSet(false))
 {
       _clusterConfig = 
accessor.getProperty(accessor.keyBuilder().clusterConfig());
       refreshedType.add(HelixConstants.ChangeType.CLUSTER_CONFIG);
+      // TODO: This is a temp function to clean up incompatible batched 
disabled instances format.
+      // Remove in later version.
+      if (_clusterConfig!=null && 
needCleanUpBatchedDisabledInstance(_clusterConfig.getRecord())
+          && cleanBatchDisableMapField(accessor)) {
+        LogUtil.logInfo(logger, getClusterEventId(), String
+            .format("Clean ClusterConfig mapField for cluster %s, pipeline 
%s", _clusterName,
+                getPipelineName()));
+      }
       refreshAbnormalStateResolverMap(_clusterConfig);
     } else {
-      LogUtil.logInfo(logger, getClusterEventId(), String.format(
-          "No ClusterConfig change for cluster %s, pipeline %s", _clusterName, 
getPipelineName()));
+      LogUtil.logDebug(logger, getClusterEventId(), String
+          .format("No ClusterConfig change for cluster %s, pipeline %s", 
_clusterName,
+              getPipelineName()));
     }
   }
 
+  // TODO: This function is used to clean up batched disabled instances for
+  // "DISABLED_INSTANCES" introduced in 1.0.3.0. This temp change should be 
reverted after 1.0.5.0 \
+  // or later version.
+  private boolean cleanBatchDisableMapField(final HelixDataAccessor accessor) {
+    boolean successful =
+        accessor.updateProperty(accessor.keyBuilder().clusterConfig(), new 
DataUpdater<ZNRecord>() {
+          @Override
+          public ZNRecord update(ZNRecord currentData) {
+            if (currentData == null) {
+              throw new HelixException(
+                  "Cluster: " + _clusterConfig.getClusterName() + ": cluster 
config is null");
+            }
+            ZNRecord newRecord = new ZNRecord(currentData);
+            String batchDisabledInstanceMapFieldKey =
+                ClusterConfig.ClusterConfigProperty.DISABLED_INSTANCES.name();
+            if (needCleanUpBatchedDisabledInstance(currentData)) {

Review Comment:
   you are calling needCleanUpBatchedDisabledInstance() twice.
   first on line:246 and here too..  any particular reason



-- 
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: [email protected]

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