This is an automated email from the ASF dual-hosted git repository. hulee pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/helix.git
commit 3e670ded2ece50e21b76fcab7fed7cb61a24eea1 Author: Hunter Lee <[email protected]> AuthorDate: Fri May 24 18:18:54 2019 -0700 Remove vestiges of cluster view aggregator While merging commits, some code got merged into the master branch accidentally, and this commit removes such code so that the project builds. --- .../java/org/apache/helix/model/ClusterConfig.java | 37 +---------- .../integration/manager/TestZkHelixAdmin.java | 74 ++++------------------ 2 files changed, 14 insertions(+), 97 deletions(-) diff --git a/helix-core/src/main/java/org/apache/helix/model/ClusterConfig.java b/helix-core/src/main/java/org/apache/helix/model/ClusterConfig.java index bbbaa72..713b18a 100644 --- a/helix-core/src/main/java/org/apache/helix/model/ClusterConfig.java +++ b/helix-core/src/main/java/org/apache/helix/model/ClusterConfig.java @@ -19,29 +19,23 @@ package org.apache.helix.model; * under the License. */ -import java.io.IOException; +import com.google.common.collect.Maps; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; - import org.apache.helix.HelixException; import org.apache.helix.HelixProperty; import org.apache.helix.ZNRecord; import org.apache.helix.api.config.HelixConfigProperty; import org.apache.helix.api.config.StateTransitionThrottleConfig; import org.apache.helix.api.config.StateTransitionTimeoutConfig; -import org.apache.helix.api.config.ViewClusterSourceConfig; - -import com.google.common.collect.Maps; /** * Cluster configurations */ public class ClusterConfig extends HelixProperty { - private static final String TOPOLOGY_SPLITTER = "/"; /** * Configurable characteristics of a cluster. * NOTE: Do NOT use this field name directly, use its corresponding getter/setter in the @@ -136,23 +130,6 @@ public class ClusterConfig extends HelixProperty { } /** - * Set a list of ViewClusterSourceConfig to ClusterConfig. Current source config will be - * overwritten - * @param sourceConfigList - */ - public void setViewClusterSourceConfigs(List<ViewClusterSourceConfig> sourceConfigList) { - List<String> sourceConfigs = new ArrayList<>(); - for (ViewClusterSourceConfig config : sourceConfigList) { - try { - sourceConfigs.add(config.toJson()); - } catch (IOException e) { - throw new IllegalArgumentException("Invalid source config. Error: " + e.toString()); - } - } - _record.setListField(ClusterConfigProperty.VIEW_CLUSTER_SOURCES.name(), sourceConfigs); - } - - /** * Set task quota type with the ratio of this quota. * @param quotaType String * @param quotaRatio int @@ -230,16 +207,6 @@ public class ClusterConfig extends HelixProperty { refreshPeriod); } - public List<ViewClusterSourceConfig> getViewClusterSourceConfigs() { - List<ViewClusterSourceConfig> sourceConfigList = new ArrayList<>(); - for (String configJSON : _record - .getListField(ClusterConfigProperty.VIEW_CLUSTER_SOURCES.name())) { - ViewClusterSourceConfig config = ViewClusterSourceConfig.fromJson(configJSON); - sourceConfigList.add(config); - } - return sourceConfigList; - } - public int getViewClusterRefershPeriod() { return _record.getIntField(ClusterConfigProperty.VIEW_CLUSTER_REFRESH_PERIOD.name(), DEFAULT_VIEW_CLUSTER_REFRESH_PERIOD); @@ -770,4 +737,4 @@ public class ClusterConfig extends HelixProperty { public String getClusterName() { return _record.getId(); } -} +} \ No newline at end of file diff --git a/helix-core/src/test/java/org/apache/helix/integration/manager/TestZkHelixAdmin.java b/helix-core/src/test/java/org/apache/helix/integration/manager/TestZkHelixAdmin.java index 89c9a48..5141a8d 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/manager/TestZkHelixAdmin.java +++ b/helix-core/src/test/java/org/apache/helix/integration/manager/TestZkHelixAdmin.java @@ -19,28 +19,22 @@ package org.apache.helix.integration.manager; * under the License. */ -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.apache.helix.ConfigAccessor; import org.apache.helix.HelixAdmin; -import org.apache.helix.PropertyType; import org.apache.helix.TestHelper; -import org.apache.helix.api.config.ViewClusterSourceConfig; import org.apache.helix.integration.task.MockTask; import org.apache.helix.integration.task.TaskTestBase; import org.apache.helix.integration.task.WorkflowGenerator; import org.apache.helix.manager.zk.ZKHelixAdmin; -import org.apache.helix.model.ClusterConfig; import org.apache.helix.model.IdealState; import org.apache.helix.task.JobConfig; import org.apache.helix.task.JobContext; import org.apache.helix.task.TaskPartitionState; -import org.apache.helix.task.TaskState; import org.apache.helix.task.TaskUtil; import org.apache.helix.task.Workflow; -import org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -63,79 +57,35 @@ public class TestZkHelixAdmin extends TaskTestBase { } @Test - public void testViewClusterOperations() { - String testCluster = "testViewCluster"; - List<ViewClusterSourceConfig> sourceConfigs = generateViewClusterSourceConfig(); - int refreshPeriod = 10; - - _admin.addCluster(testCluster); - ClusterConfig config = _configAccessor.getClusterConfig(testCluster); - config.setViewCluster(); - config.setViewClusterRefreshPeriod(refreshPeriod); - config.setViewClusterSourceConfigs(sourceConfigs); - _configAccessor.setClusterConfig(testCluster, config); - - ClusterConfig fetchedConfig = _configAccessor.getClusterConfig(testCluster); - Assert.assertTrue(fetchedConfig.isViewCluster()); - Assert.assertEquals(fetchedConfig.getViewClusterSourceConfigs().size(), sourceConfigs.size()); - Assert.assertEquals(fetchedConfig.getViewClusterRefershPeriod(), refreshPeriod); - _admin.dropCluster(testCluster); - } - - @Test public void testEnableDisablePartitions() throws InterruptedException { _admin.enablePartition(false, CLUSTER_NAME, (PARTICIPANT_PREFIX + "_" + _startPort), - WorkflowGenerator.DEFAULT_TGT_DB, Arrays.asList("TestDB_0", "TestDB_2")); + WorkflowGenerator.DEFAULT_TGT_DB, Arrays.asList(new String[] { "TestDB_0", "TestDB_2" })); _admin.enablePartition(false, CLUSTER_NAME, (PARTICIPANT_PREFIX + "_" + (_startPort + 1)), - WorkflowGenerator.DEFAULT_TGT_DB, Arrays.asList("TestDB_0", "TestDB_2")); + WorkflowGenerator.DEFAULT_TGT_DB, Arrays.asList(new String[] { "TestDB_0", "TestDB_2" })); IdealState idealState = _admin.getResourceIdealState(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB); - List<String> preferenceList = Arrays.asList("localhost_12919", "localhost_12918"); + List<String> preferenceList = + Arrays.asList(new String[] { "localhost_12919", "localhost_12918" }); for (String partitionName : idealState.getPartitionSet()) { idealState.setPreferenceList(partitionName, preferenceList); } idealState.setRebalanceMode(IdealState.RebalanceMode.SEMI_AUTO); _admin.setResourceIdealState(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB, idealState); - // Let the cluster rebalance - BestPossibleExternalViewVerifier verifier = - new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient) - .setZkAddr(ZK_ADDR).build(); - Assert.assertTrue(verifier.verifyByPolling()); - String workflowName = TestHelper.getTestMethodName(); Workflow.Builder builder = new Workflow.Builder(workflowName); - JobConfig.Builder jobBuilder = new JobConfig.Builder().setWorkflow(workflowName) - .setCommand(MockTask.TASK_COMMAND).setTargetResource(WorkflowGenerator.DEFAULT_TGT_DB) - .setTargetPartitionStates(Collections.singleton("SLAVE")); + JobConfig.Builder jobBuilder = + new JobConfig.Builder().setWorkflow(workflowName).setCommand(MockTask.TASK_COMMAND) + .setTargetResource(WorkflowGenerator.DEFAULT_TGT_DB) + .setTargetPartitionStates(Collections.singleton("SLAVE")); builder.addJob("JOB", jobBuilder); _driver.start(builder.build()); - _driver.pollForJobState(workflowName, TaskUtil.getNamespacedJobName(workflowName, "JOB"), - TaskState.IN_PROGRESS); - Thread.sleep(3000L); + Thread.sleep(2000L); JobContext jobContext = _driver.getJobContext(TaskUtil.getNamespacedJobName(workflowName, "JOB")); - Assert.assertNull(jobContext.getPartitionState(0)); + Assert.assertEquals(jobContext.getPartitionState(0), null); Assert.assertEquals(jobContext.getPartitionState(1), TaskPartitionState.COMPLETED); - Assert.assertNull(jobContext.getPartitionState(2)); - } - - private List<ViewClusterSourceConfig> generateViewClusterSourceConfig() { - String clusterNamePrefix = "mySourceCluster"; - String zkConnection = "zookeeper.test.com:2121"; - String testJsonTemplate = - "{\"name\": \"%s\", \"zkAddress\": \"%s\", \"properties\": [\"%s\", \"%s\", \"%s\"]}"; - - List<ViewClusterSourceConfig> sourceConfigs = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - String clusterName = clusterNamePrefix + i; - String configJSON = - String.format(testJsonTemplate, clusterName, zkConnection, PropertyType.INSTANCES.name(), - PropertyType.EXTERNALVIEW.name(), PropertyType.LIVEINSTANCES.name()); - - sourceConfigs.add(ViewClusterSourceConfig.fromJson(configJSON)); - } - return sourceConfigs; + Assert.assertEquals(jobContext.getPartitionState(2), null); } -} +} \ No newline at end of file
