Revert and disable batch enable/disable functionality (#2134)
Revert and disable batch enable/disable functionality
Disable batch mode and remove related methods to fix backward compatibility issues introduced in 1.0.3
diff --git a/helix-core/src/main/java/org/apache/helix/HelixAdmin.java b/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
index 837cd2c..6c6d4be 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
@@ -303,20 +303,6 @@
void enableInstance(String clusterName, List<String> instances, boolean enabled);
/**
- * Batch enable/disable instances in a cluster
- * By default, all the instances are enabled
- * @param clusterName
- * @param instances
- * @param enabled
- * @param disabledType disabledType for disable operation. It is ignored when enabled is true.
- * Existing disabledType will be over write if instance is in disabled state.
- * @param reason human readable string explaining disabled reason. Ignored when enabled is true.
- * Existing disabled reason will be over write if instance is in disabled state.
- */
- void enableInstance(String clusterName, List<String> instances, boolean enabled,
- InstanceConstants.InstanceDisabledType disabledType, String reason);
-
- /**
* Disable or enable a resource
* @param clusterName
* @param resourceName
diff --git a/helix-core/src/main/java/org/apache/helix/cloud/event/helix/DefaultCloudEventCallbackImpl.java b/helix-core/src/main/java/org/apache/helix/cloud/event/helix/DefaultCloudEventCallbackImpl.java
index 98aab0e..d9aa3b2 100644
--- a/helix-core/src/main/java/org/apache/helix/cloud/event/helix/DefaultCloudEventCallbackImpl.java
+++ b/helix-core/src/main/java/org/apache/helix/cloud/event/helix/DefaultCloudEventCallbackImpl.java
@@ -19,19 +19,13 @@
* under the License.
*/
-import java.util.List;
-
-import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixManager;
-import org.apache.helix.util.InstanceValidationUtil;
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
/**
* A default callback implementation class to be used in {@link HelixCloudEventListener}
*/
public class DefaultCloudEventCallbackImpl {
- private final String _reason =
- "Cloud event callback %s in class %s triggered in listener HelixManager %s, at time %s .";
- protected final String _className = this.getClass().getSimpleName();
/**
* Disable the instance
@@ -39,13 +33,8 @@
* @param eventInfo Detailed information about the event
*/
public void disableInstance(HelixManager manager, Object eventInfo) {
- if (InstanceValidationUtil
- .isEnabled(manager.getHelixDataAccessor(), manager.getInstanceName())) {
- HelixEventHandlingUtil
- .enableInstanceForCloudEvent(manager.getClusterName(), manager.getInstanceName(), String
- .format(_reason, "disableInstance", _className, manager, System.currentTimeMillis()),
- false, manager.getHelixDataAccessor().getBaseDataAccessor());
- }
+ // To be implemented
+ throw new NotImplementedException();
}
/**
@@ -54,49 +43,27 @@
* @param eventInfo Detailed information about the event
*/
public void enableInstance(HelixManager manager, Object eventInfo) {
- String instanceName = manager.getInstanceName();
- HelixDataAccessor accessor = manager.getHelixDataAccessor();
- if (HelixEventHandlingUtil
- .IsInstanceDisabledForCloudEvent(manager.getClusterName(), instanceName, accessor.getBaseDataAccessor())) {
- HelixEventHandlingUtil
- .enableInstanceForCloudEvent(manager.getClusterName(), manager.getInstanceName(), String
- .format(_reason, "disableInstance", _className, manager, System.currentTimeMillis()),
- true, manager.getHelixDataAccessor().getBaseDataAccessor());
- }
+ // To be implemented
+ throw new NotImplementedException();
}
/**
- * Put cluster into maintenance mode if the cluster is not currently in maintenance mode
+ *
* @param manager The helix manager associated with the listener
* @param eventInfo Detailed information about the event
*/
public void enterMaintenanceMode(HelixManager manager, Object eventInfo) {
- if (!manager.getClusterManagmentTool().isInMaintenanceMode(manager.getClusterName())) {
- manager.getClusterManagmentTool()
- .manuallyEnableMaintenanceMode(manager.getClusterName(), true, String
- .format(_reason, "enterMaintenanceMode", _className, manager,
- System.currentTimeMillis()), null);
- }
+ // To be implemented
+ throw new NotImplementedException();
}
/**
- * Exit maintenance mode for the cluster, if there is no more live instances disabled for cloud event
+ *
* @param manager The helix manager associated with the listener
* @param eventInfo Detailed information about the event
*/
public void exitMaintenanceMode(HelixManager manager, Object eventInfo) {
- List<String> instances =
- manager.getClusterManagmentTool().getInstancesInCluster(manager.getClusterName());
- // Check if there is any disabled live instance that was disabled due to cloud event,
- // if none left, exit maintenance mode
- HelixDataAccessor accessor = manager.getHelixDataAccessor();
- if (instances.stream().noneMatch(instance -> HelixEventHandlingUtil
- .IsInstanceDisabledForCloudEvent(manager.getClusterName(), instance, accessor.getBaseDataAccessor())
- && InstanceValidationUtil.isAlive(accessor, instance))) {
- manager.getClusterManagmentTool()
- .manuallyEnableMaintenanceMode(manager.getClusterName(), false, String
- .format(_reason, "exitMaintenanceMode", _className, manager,
- System.currentTimeMillis()), null);
- }
+ // To be implemented
+ throw new NotImplementedException();
}
}
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
index 3e5f2da..63986e6 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
@@ -359,30 +359,19 @@
// Eventually we will have all instances' enable/disable information in clusterConfig. Now we
// update both instanceConfig and clusterConfig in transition period.
enableSingleInstance(clusterName, instanceName, enabled, baseAccessor, disabledType, reason);
- enableBatchInstances(clusterName, Collections.singletonList(instanceName), enabled,
- baseAccessor, disabledType, reason);
+// enableBatchInstances(clusterName, Collections.singletonList(instanceName), enabled,
+// baseAccessor, disabledType, reason);
}
@Override
- public void enableInstance(String clusterName, List<String> instances, boolean enabled,
- InstanceConstants.InstanceDisabledType disabledType, String reason) {
- logger.info("Batch {} instances {} in cluster {}.", enabled ? "enable" : "disable",
- HelixUtil.serializeByComma(instances), clusterName);
- BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<>(_zkClient);
- // Eventually we will have all instances' enable/disable information in clusterConfig. Now we
- // update both instanceConfig and clusterConfig in transition period.
- if (enabled) {
- for (String instance : instances) {
- enableSingleInstance(clusterName, instance, enabled, baseAccessor, disabledType, reason);
- }
- }
- enableBatchInstances(clusterName, instances, enabled, baseAccessor, disabledType, reason);
- }
-
- @Override
public void enableInstance(String clusterName, List<String> instances, boolean enabled) {
- enableInstance(clusterName, instances, enabled, null, null);
+ // TODO: batch enable/disable is breaking backward compatibility on instance enable with older library
+ // re-enable once batch enable/disable is ready
+ if (true) {
+ throw new HelixException("Batch enable/disable is not supported");
+ }
+ //enableInstance(clusterName, instances, enabled, null, null);
}
@Override
@@ -1918,6 +1907,11 @@
final boolean enabled, BaseDataAccessor<ZNRecord> baseAccessor,
InstanceConstants.InstanceDisabledType disabledType, String reason) {
+ // TODO: batch enable/disable is breaking backward compatibility on instance enable with older library
+ // re-enable once batch enable/disable is ready
+ if (true) {
+ throw new HelixException("enableBatchInstances is not supported.");
+ }
String path = PropertyPathBuilder.clusterConfig(clusterName);
if (!baseAccessor.exists(path, 0)) {
diff --git a/helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java b/helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
index fa23372..fdbf7dd 100644
--- a/helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
@@ -31,7 +31,6 @@
import org.apache.helix.HelixDefinedState;
import org.apache.helix.HelixException;
import org.apache.helix.PropertyKey;
-import org.apache.helix.constants.InstanceConstants;
import org.apache.helix.model.ClusterConfig;
import org.apache.helix.model.CurrentState;
import org.apache.helix.model.ExternalView;
@@ -83,37 +82,6 @@
}
- public static String getInstanceHelixDisabledType(HelixDataAccessor dataAccessor,
- String instanceName) {
- PropertyKey.Builder propertyKeyBuilder = dataAccessor.keyBuilder();
- ClusterConfig clusterConfig = dataAccessor.getProperty(propertyKeyBuilder.clusterConfig());
- if (clusterConfig == null) {
- throw new HelixException("ClusterConfig is NULL");
- }
-
- String instanceDisabledTypeBatchedMode =
- clusterConfig.getPlainInstanceHelixDisabledType(instanceName);
- if (instanceDisabledTypeBatchedMode != null) {
- return InstanceConstants.InstanceDisabledType.valueOf(instanceDisabledTypeBatchedMode)
- .toString();
- }
- // TODO deprecate reading instance level config once migrated the enable status to cluster config only
- InstanceConfig instanceConfig =
- dataAccessor.getProperty(propertyKeyBuilder.instanceConfig(instanceName));
- if (instanceConfig == null) {
- throw new HelixException("InstanceConfig is NULL");
- }
-
- if (isInstanceEnabled(instanceConfig, clusterConfig)) {
- return InstanceConstants.INSTANCE_NOT_DISABLED;
- }
- // It is possible that an instance is set disabled in cluster config but not in instance config.
- // This instance is considered disabled. We should return a default disabled type.
- return instanceConfig.getInstanceEnabled()
- ? InstanceConstants.InstanceDisabledType.DEFAULT_INSTANCE_DISABLE_TYPE.toString()
- : instanceConfig.getInstanceDisabledType();
- }
-
/**
* Check if the instance is enabled by configuration
* @param instanceConfig
@@ -125,12 +93,13 @@
throw new HelixException("InstanceConfig is NULL");
}
boolean enabledInInstanceConfig = instanceConfig.getInstanceEnabled();
- if (clusterConfig == null) {
+ // TODO: batch enable/disable in cluster config is breaking backward compatibility with older library
+ // re-enable once batch enable/disable is ready
+ if (true || clusterConfig == null) {
return enabledInInstanceConfig;
}
boolean enabledInClusterConfig =
- !clusterConfig.getDisabledInstances().containsKey(instanceConfig.getInstanceName())
- && !clusterConfig.getDisabledInstancesWithInfo().containsKey(instanceConfig.getInstanceName());
+ !clusterConfig.getDisabledInstances().containsKey(instanceConfig.getInstanceName());
return enabledInClusterConfig && enabledInInstanceConfig;
}
diff --git a/helix-core/src/test/java/org/apache/helix/cloud/event/TestDefaultCloudEventCallbackImpl.java b/helix-core/src/test/java/org/apache/helix/cloud/event/TestDefaultCloudEventCallbackImpl.java
deleted file mode 100644
index 89ae268..0000000
--- a/helix-core/src/test/java/org/apache/helix/cloud/event/TestDefaultCloudEventCallbackImpl.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package org.apache.helix.cloud.event;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.helix.HelixAdmin;
-import org.apache.helix.cloud.event.helix.DefaultCloudEventCallbackImpl;
-import org.apache.helix.constants.InstanceConstants;
-import org.apache.helix.integration.common.ZkStandAloneCMTestBase;
-import org.apache.helix.integration.manager.MockParticipantManager;
-import org.apache.helix.util.InstanceValidationUtil;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class TestDefaultCloudEventCallbackImpl extends ZkStandAloneCMTestBase {
- private final DefaultCloudEventCallbackImpl _impl =
- DefaultCloudEventCallbackImpl.class.newInstance();
- private MockParticipantManager _instanceManager;
- private HelixAdmin _admin;
-
- public TestDefaultCloudEventCallbackImpl() throws IllegalAccessException, InstantiationException {
- }
-
- @BeforeClass
- public void beforeClass() throws Exception {
- super.beforeClass();
- _instanceManager = _participants[0];
- _admin = _instanceManager.getClusterManagmentTool();
- }
-
- @Test (enabled = false)
- public void testDisableInstance() {
- Assert.assertTrue(InstanceValidationUtil
- .isEnabled(_manager.getHelixDataAccessor(), _instanceManager.getInstanceName()));
- _impl.disableInstance(_instanceManager, null);
- Assert.assertFalse(InstanceValidationUtil
- .isEnabled(_manager.getHelixDataAccessor(), _instanceManager.getInstanceName()));
- Assert.assertEquals(_manager.getConfigAccessor()
- .getInstanceConfig(CLUSTER_NAME, _instanceManager.getInstanceName())
- .getInstanceDisabledType(), InstanceConstants.InstanceDisabledType.CLOUD_EVENT.name());
-
- // Should not disable instance if it is already disabled due to other reasons
- // And disabled type should remain unchanged
- _admin.enableInstance(CLUSTER_NAME, _instanceManager.getInstanceName(), false);
- _impl.disableInstance(_instanceManager, null);
- Assert.assertFalse(InstanceValidationUtil
- .isEnabled(_manager.getHelixDataAccessor(), _instanceManager.getInstanceName()));
- Assert.assertEquals(InstanceValidationUtil
- .getInstanceHelixDisabledType(_manager.getHelixDataAccessor(),
- _instanceManager.getInstanceName()),
- InstanceConstants.InstanceDisabledType.DEFAULT_INSTANCE_DISABLE_TYPE.name());
-
- _admin.enableInstance(CLUSTER_NAME, _instanceManager.getInstanceName(), false,
- InstanceConstants.InstanceDisabledType.CLOUD_EVENT, null);
- }
-
- @Test/*(dependsOnMethods = "testDisableInstance")*/ (enabled = false)
- public void testEnableInstance() {
- Assert.assertFalse(InstanceValidationUtil
- .isEnabled(_manager.getHelixDataAccessor(), _instanceManager.getInstanceName()));
- // Should enable instance if the instance is disabled due to cloud event
- _impl.enableInstance(_instanceManager, null);
- Assert.assertTrue(InstanceValidationUtil
- .isEnabled(_manager.getHelixDataAccessor(), _instanceManager.getInstanceName()));
-
- // Should not enable instance if it is not disabled due to cloud event
- _admin.enableInstance(CLUSTER_NAME, _instanceManager.getInstanceName(), false);
- _impl.enableInstance(_instanceManager, null);
- Assert.assertFalse(InstanceValidationUtil
- .isEnabled(_manager.getHelixDataAccessor(), _instanceManager.getInstanceName()));
- _admin.enableInstance(_instanceManager.getClusterName(), _instanceManager.getInstanceName(),
- true);
- }
-
- @Test (enabled = false)
- public void testEnterMaintenanceMode() {
- Assert.assertFalse(_admin.isInMaintenanceMode(CLUSTER_NAME));
- _impl.enterMaintenanceMode(_instanceManager, null);
- Assert.assertTrue(_admin.isInMaintenanceMode(CLUSTER_NAME));
- }
-
- @Test(enabled = false) //(dependsOnMethods = "testEnterMaintenanceMode")
- public void testExitMaintenanceMode() {
- Assert.assertTrue(_admin.isInMaintenanceMode(CLUSTER_NAME));
- // Should not exit maintenance mode if there is remaining live instance that is disabled due to cloud event
- _admin.enableInstance(CLUSTER_NAME, _participants[1].getInstanceName(), false,
- InstanceConstants.InstanceDisabledType.CLOUD_EVENT, null);
- _impl.exitMaintenanceMode(_instanceManager, null);
- Assert.assertTrue(_admin.isInMaintenanceMode(CLUSTER_NAME));
-
- // Should exit maintenance mode if there is no remaining live instance that is disabled due to cloud event
- _admin.enableInstance(CLUSTER_NAME, _participants[1].getInstanceName(), false,
- InstanceConstants.InstanceDisabledType.USER_OPERATION, null);
- _impl.exitMaintenanceMode(_instanceManager, null);
- Assert.assertFalse(_admin.isInMaintenanceMode(CLUSTER_NAME));
- }
-}
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestBatchEnableInstances.java b/helix-core/src/test/java/org/apache/helix/integration/TestBatchEnableInstances.java
index 6e07a37..65c9472 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestBatchEnableInstances.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestBatchEnableInstances.java
@@ -20,24 +20,19 @@
*/
import java.util.Arrays;
+import java.util.Collections;
import java.util.Map;
import org.apache.helix.ConfigAccessor;
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.constants.InstanceConstants;
+import org.apache.helix.HelixException;
import org.apache.helix.integration.task.TaskTestBase;
import org.apache.helix.integration.task.WorkflowGenerator;
-import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.model.ClusterConfig;
import org.apache.helix.model.ExternalView;
-import org.apache.helix.util.InstanceValidationUtil;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class TestBatchEnableInstances extends TaskTestBase {
- private ConfigAccessor _accessor;
@BeforeClass
public void beforeClass() throws Exception {
@@ -46,10 +41,15 @@
_numNodes = 5;
_numPartitions = 4;
super.beforeClass();
- _accessor = new ConfigAccessor(_gZkClient);
}
- @Test
+ @Test(expectedExceptions = HelixException.class, expectedExceptionsMessageRegExp = "Batch.*is not supported")
+ public void testBatchModeNotSupported() {
+ // ensure batch enable/disable is not supported and shouldn't be used yet
+ _gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME, Collections.emptyList(), true);
+ }
+
+ @Test(enabled = false)
public void testOldEnableDisable() throws InterruptedException {
_gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME,
_participants[0].getInstanceName(), false);
@@ -61,17 +61,11 @@
for (Map<String, String> stateMap : externalView.getRecord().getMapFields().values()) {
Assert.assertTrue(!stateMap.keySet().contains(_participants[0].getInstanceName()));
}
- HelixDataAccessor dataAccessor =
- new ZKHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<>(_gZkClient));
- ClusterConfig clusterConfig = dataAccessor.getProperty(dataAccessor.keyBuilder().clusterConfig());
- Assert.assertEquals(Long.parseLong(
- clusterConfig.getInstanceHelixDisabledTimeStamp(_participants[0].getInstanceName())),
- Long.parseLong(clusterConfig.getDisabledInstances().get(_participants[0].getInstanceName())));
_gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME,
_participants[0].getInstanceName(), true);
}
- @Test
+ @Test(enabled = false)
public void testBatchEnableDisable() throws InterruptedException {
_gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME,
Arrays.asList(_participants[0].getInstanceName(), _participants[1].getInstanceName()),
@@ -85,21 +79,12 @@
Assert.assertTrue(!stateMap.keySet().contains(_participants[0].getInstanceName()));
Assert.assertTrue(!stateMap.keySet().contains(_participants[1].getInstanceName()));
}
- HelixDataAccessor dataAccessor =
- new ZKHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<>(_gZkClient));
- ClusterConfig clusterConfig = dataAccessor.getProperty(dataAccessor.keyBuilder().clusterConfig());
- Assert.assertEquals(Long.parseLong(
- clusterConfig.getInstanceHelixDisabledTimeStamp(_participants[1].getInstanceName())),
- Long.parseLong(clusterConfig.getDisabledInstances().get(_participants[1].getInstanceName())));
_gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME,
Arrays.asList(_participants[0].getInstanceName(), _participants[1].getInstanceName()),
true);
- Assert.assertEquals(Long.parseLong(
- clusterConfig.getInstanceHelixDisabledTimeStamp(_participants[0].getInstanceName())),
- Long.parseLong(clusterConfig.getDisabledInstances().get(_participants[0].getInstanceName())));
}
- @Test
+ @Test(enabled = false)
public void testOldDisableBatchEnable() throws InterruptedException {
_gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME,
_participants[0].getInstanceName(), false);
@@ -122,40 +107,13 @@
_participants[0].getInstanceName(), true);
}
- @Test
+ @Test(enabled = false)
public void testBatchDisableOldEnable() throws InterruptedException {
- // disable 2 instances
_gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME,
Arrays.asList(_participants[0].getInstanceName(), _participants[1].getInstanceName()),
- false, InstanceConstants.InstanceDisabledType.USER_OPERATION, "reason_1");
- // check disabled type from InstanceValidationUtil
- HelixDataAccessor dataAccessor =
- new ZKHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<>(_gZkClient));
- Assert.assertEquals(InstanceValidationUtil
- .getInstanceHelixDisabledType(dataAccessor, _participants[1].getInstanceName()),
- InstanceConstants.InstanceDisabledType.USER_OPERATION.toString());
- // check disabled reason from getter in clusterConfig
- ClusterConfig clusterConfig =
- dataAccessor.getProperty(dataAccessor.keyBuilder().clusterConfig());
- Assert.assertEquals(
- clusterConfig.getInstanceHelixDisabledReason(_participants[1].getInstanceName()),
- "reason_1");
- Assert.assertNotNull(
- clusterConfig.getInstanceHelixDisabledTimeStamp(_participants[0].getInstanceName()));
- // enable the second instance
- _gSetupTool.getClusterManagementTool()
- .enableInstance(CLUSTER_NAME, _participants[0].getInstanceName(), true);
- // check disabled type for second instance from InstanceValidationUtil and clusterConfig
- Assert.assertEquals(InstanceValidationUtil
- .getInstanceHelixDisabledType(dataAccessor, _participants[0].getInstanceName()),
- InstanceConstants.INSTANCE_NOT_DISABLED);
- clusterConfig = dataAccessor.getProperty(dataAccessor.keyBuilder().clusterConfig());
- Assert.assertEquals(
- clusterConfig.getInstanceHelixDisabledType(_participants[0].getInstanceName()),
- InstanceConstants.INSTANCE_NOT_DISABLED);
- Assert.assertNull(
- clusterConfig.getInstanceHelixDisabledTimeStamp(_participants[0].getInstanceName()));
-
+ false);
+ _gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME,
+ _participants[0].getInstanceName(), true);
Thread.sleep(2000);
ExternalView externalView = _gSetupTool.getClusterManagementTool()
@@ -173,5 +131,4 @@
Arrays.asList(_participants[0].getInstanceName(), _participants[1].getInstanceName()),
true);
}
-
}
diff --git a/helix-core/src/test/java/org/apache/helix/mock/MockHelixAdmin.java b/helix-core/src/test/java/org/apache/helix/mock/MockHelixAdmin.java
index 4063a58..ec25d42 100644
--- a/helix-core/src/test/java/org/apache/helix/mock/MockHelixAdmin.java
+++ b/helix-core/src/test/java/org/apache/helix/mock/MockHelixAdmin.java
@@ -28,6 +28,7 @@
import org.apache.helix.BaseDataAccessor;
import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixException;
import org.apache.helix.HelixManager;
import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
@@ -302,40 +303,7 @@
@Override
public void enableInstance(String clusterName, List<String> instances, boolean enabled) {
- enableInstance(clusterName, instances, enabled, null, null);
- }
- @Override
- public void enableInstance(String clusterName, List<String> instances, boolean enabled,
- InstanceConstants.InstanceDisabledType disabledType, String reason) {
-
- String path = PropertyPathBuilder.clusterConfig(clusterName);
-
- if (!_baseDataAccessor.exists(path, 0)) {
- _baseDataAccessor.create(path, new ZNRecord(clusterName), 0);
- }
-
- ZNRecord record = (ZNRecord) _baseDataAccessor.get(path, null, 0);
- ClusterConfig clusterConfig = new ClusterConfig(record);
-
- Map<String, String> disabledInstances = new TreeMap<>();
- Map<String, String> disabledInstancesWithInfo = new TreeMap<>();
- if (clusterConfig.getDisabledInstances() != null) {
- disabledInstances.putAll(clusterConfig.getDisabledInstances());
- disabledInstancesWithInfo.putAll(clusterConfig.getDisabledInstancesWithInfo());
- }
- if (enabled) {
- disabledInstances.keySet().removeAll(instances);
- } else {
- for (String disabledInstance : instances) {
- String timeStamp = String.valueOf(System.currentTimeMillis());
- disabledInstances.put(disabledInstance, timeStamp);
- disabledInstances
- .put(disabledInstance, assembleInstanceBatchedDisabledInfo(disabledType, reason, timeStamp));
- }
- }
- clusterConfig.setDisabledInstances(disabledInstances);
- clusterConfig.setDisabledInstancesWithInfo(disabledInstancesWithInfo);
}
@Override
diff --git a/helix-core/src/test/java/org/apache/helix/util/TestInstanceValidationUtil.java b/helix-core/src/test/java/org/apache/helix/util/TestInstanceValidationUtil.java
index fe04d5e..2c51fc9 100644
--- a/helix-core/src/test/java/org/apache/helix/util/TestInstanceValidationUtil.java
+++ b/helix-core/src/test/java/org/apache/helix/util/TestInstanceValidationUtil.java
@@ -70,7 +70,7 @@
};
}
- @Test(dataProvider = "isEnabledTestSuite")
+ @Test(dataProvider = "isEnabledTestSuite", enabled = false)
public void TestIsInstanceEnabled(boolean instanceConfigEnabled, boolean clusterConfigEnabled,
boolean expected) {
Mock mock = new Mock();
diff --git a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/InstancesAccessor.java b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/InstancesAccessor.java
index d5a64ea..076fe6d 100644
--- a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/InstancesAccessor.java
+++ b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/InstancesAccessor.java
@@ -44,7 +44,6 @@
import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixException;
-import org.apache.helix.constants.InstanceConstants;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
import org.apache.helix.model.ClusterConfig;
import org.apache.helix.model.InstanceConfig;
@@ -155,8 +154,6 @@
@QueryParam("command") String command,
@QueryParam("continueOnFailures") boolean continueOnFailures,
@QueryParam("skipZKRead") boolean skipZKRead,
- @QueryParam("instanceDisabledType") String disabledType,
- @QueryParam("instanceDisabledReason") String disabledReason,
String content) {
Command cmd;
try {
@@ -182,15 +179,7 @@
admin.enableInstance(clusterId, enableInstances, true);
break;
case disable:
- InstanceConstants.InstanceDisabledType disabledTypeEnum = null;
- if (disabledType != null) {
- try {
- disabledTypeEnum = InstanceConstants.InstanceDisabledType.valueOf(disabledType);
- } catch (IllegalArgumentException ex) {
- return badRequest("Invalid instanceDisabledType!");
- }
- }
- admin.enableInstance(clusterId, enableInstances, false, disabledTypeEnum, disabledReason);
+ admin.enableInstance(clusterId, enableInstances, false);
break;
case stoppable:
return batchGetStoppableInstances(clusterId, node, skipZKRead, continueOnFailures);
diff --git a/helix-rest/src/test/java/org/apache/helix/rest/server/TestInstancesAccessor.java b/helix-rest/src/test/java/org/apache/helix/rest/server/TestInstancesAccessor.java
index 87859ff..f0a97bb 100644
--- a/helix-rest/src/test/java/org/apache/helix/rest/server/TestInstancesAccessor.java
+++ b/helix-rest/src/test/java/org/apache/helix/rest/server/TestInstancesAccessor.java
@@ -137,7 +137,7 @@
System.out.println("End test :" + TestHelper.getTestMethodName());
}
- @Test
+ @Test(enabled = false)
public void testUpdateInstances() throws IOException {
// TODO: Reenable the test after storage node fix the problem
// Batch disable instances