You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ji...@apache.org on 2020/04/23 19:28:09 UTC
[helix] 23/23: use new ZNRecord and update test
This is an automated email from the ASF dual-hosted git repository.
jiajunwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
commit 4c65bfc8472a4b29747860109bd51e2b952b7f49
Author: Meng Zhang <mn...@linkedin.com>
AuthorDate: Mon Apr 13 13:53:18 2020 -0700
use new ZNRecord and update test
---
.../ResourceControllerDataProvider.java | 1 +
.../org/apache/helix/model/CustomizedView.java | 3 ++-
.../TestComputeAndCleanupCustomizedView.java | 2 +-
.../integration/TestCustomizedViewAggregation.java | 24 ++--------------------
.../apache/helix/manager/zk/TestZkHelixAdmin.java | 1 +
.../server/resources/helix/ClusterAccessor.java | 8 ++++----
.../helix/rest/server/TestClusterAccessor.java | 6 +++---
7 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java b/helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java
index a904e80..0f564fb 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java
@@ -19,6 +19,7 @@ package org.apache.helix.controller.dataproviders;
* under the License.
*/
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
diff --git a/helix-core/src/main/java/org/apache/helix/model/CustomizedView.java b/helix-core/src/main/java/org/apache/helix/model/CustomizedView.java
index 791829a..4e472ea 100644
--- a/helix-core/src/main/java/org/apache/helix/model/CustomizedView.java
+++ b/helix-core/src/main/java/org/apache/helix/model/CustomizedView.java
@@ -24,7 +24,8 @@ import java.util.Set;
import java.util.TreeMap;
import org.apache.helix.HelixProperty;
-import org.apache.helix.ZNRecord;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+
/**
* Customized view is an aggregation (across all instances)
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestComputeAndCleanupCustomizedView.java b/helix-core/src/test/java/org/apache/helix/integration/TestComputeAndCleanupCustomizedView.java
index 6de2521..061dfcf 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestComputeAndCleanupCustomizedView.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestComputeAndCleanupCustomizedView.java
@@ -26,7 +26,6 @@ import java.util.Map;
import org.apache.helix.PropertyKey;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
import org.apache.helix.ZkTestHelper;
import org.apache.helix.ZkUnitTestBase;
import org.apache.helix.integration.manager.ClusterControllerManager;
@@ -37,6 +36,7 @@ import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.model.CustomizedState;
import org.apache.helix.model.CustomizedStateConfig;
import org.apache.helix.model.CustomizedView;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
import org.testng.Assert;
import org.testng.annotations.Test;
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedViewAggregation.java b/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedViewAggregation.java
index e270e9f..45be8fe 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedViewAggregation.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedViewAggregation.java
@@ -18,7 +18,6 @@ import org.apache.helix.HelixManagerFactory;
import org.apache.helix.InstanceType;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
import org.apache.helix.ZkUnitTestBase;
import org.apache.helix.customizedstate.CustomizedStateProvider;
import org.apache.helix.customizedstate.CustomizedStateProviderFactory;
@@ -29,6 +28,7 @@ import org.apache.helix.model.CustomizedStateConfig;
import org.apache.helix.model.CustomizedView;
import org.apache.helix.spectator.RoutingTableProvider;
import org.apache.helix.spectator.RoutingTableSnapshot;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -322,17 +322,6 @@ public class TestCustomizedViewAggregation extends ZkUnitTestBase {
* Set the data sources (customized state types) for routing table provider
* @param customizedStateTypes list of customized state types that routing table provider will include in the snapshot shown to users
*/
- private void setRoutingTableProviderDataSources(List<CustomizedStateType> customizedStateTypes) {
- List<String> customizedViewSources = new ArrayList<>();
- _routingTableProviderDataSources.clear();
- for (CustomizedStateType type : customizedStateTypes) {
- customizedViewSources.add(type.name());
- _routingTableProviderDataSources.add(type.name());
- }
- Map<PropertyType, List<String>> dataSource = new HashMap<>();
- dataSource.put(PropertyType.CUSTOMIZEDVIEW, customizedViewSources);
- _routingTableProvider = new RoutingTableProvider(_spectator, dataSource);
- }
/**
* Set the customized view aggregation config in controller
@@ -394,15 +383,8 @@ public class TestCustomizedViewAggregation extends ZkUnitTestBase {
validateAggregationSnapshot();
- // Set the routing table provider data sources to only Type A and Type B, so users won't see Type C customized view
- // Aggregating: Type A, Type B, Type C
- // Routing table: Type A, Type B
- setRoutingTableProviderDataSources(
- Arrays.asList(CustomizedStateType.TYPE_A, CustomizedStateType.TYPE_B));
- validateAggregationSnapshot();
-
// Aggregating: Type A
- // Routing table: Type A, Type B
+ // Routing table: Type A, Type B, Type C
setAggregationEnabledTypes(Arrays.asList(CustomizedStateType.TYPE_A));
validateAggregationSnapshot();
@@ -450,8 +432,6 @@ public class TestCustomizedViewAggregation extends ZkUnitTestBase {
// Aggregating: Type A, Type B, Type C
// Routing table: Type A, Type B, Type C
- setRoutingTableProviderDataSources(Arrays
- .asList(CustomizedStateType.TYPE_A, CustomizedStateType.TYPE_B, CustomizedStateType.TYPE_C));
setAggregationEnabledTypes(Arrays.asList(CustomizedStateType.TYPE_A, CustomizedStateType.TYPE_B,
CustomizedStateType.TYPE_C));
validateAggregationSnapshot();
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
index ee64524..2cb8fa3 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
@@ -78,6 +78,7 @@ import org.testng.AssertJUnit;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+
public class TestZkHelixAdmin extends ZkUnitTestBase {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
diff --git a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
index a5800b2..cbdf82a 100644
--- a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
+++ b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
@@ -299,7 +299,7 @@ public class ClusterAccessor extends AbstractHelixResource {
@PUT
- @Path("{clusterId}/customized-state-aggregation-config")
+ @Path("{clusterId}/customized-state-config")
public Response addCustomizedStateConfig(@PathParam("clusterId") String clusterId,
String content) {
if (!doesClusterExist(clusterId)) {
@@ -328,7 +328,7 @@ public class ClusterAccessor extends AbstractHelixResource {
}
@DELETE
- @Path("{clusterId}/customized-state-aggregation-config")
+ @Path("{clusterId}/customized-state-config")
public Response removeCustomizedStateConfig(@PathParam("clusterId") String clusterId) {
if (!doesClusterExist(clusterId)) {
return notFound(String.format("Cluster %s does not exist", clusterId));
@@ -348,7 +348,7 @@ public class ClusterAccessor extends AbstractHelixResource {
}
@GET
- @Path("{clusterId}/customized-state-aggregation-config")
+ @Path("{clusterId}/customized-state-config")
public Response getCustomizedStateConfig(@PathParam("clusterId") String clusterId) {
if (!doesClusterExist(clusterId)) {
return notFound(String.format("Cluster %s does not exist", clusterId));
@@ -366,7 +366,7 @@ public class ClusterAccessor extends AbstractHelixResource {
}
@POST
- @Path("{clusterId}/customized-state-aggregation-config")
+ @Path("{clusterId}/customized-state-config")
public Response updateCustomizedStateConfig(@PathParam("clusterId") String clusterId,
@QueryParam("command") String commandStr, @QueryParam("type") String type) {
if (!doesClusterExist(clusterId)) {
diff --git a/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java b/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
index 279da84..555f094 100644
--- a/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
+++ b/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
@@ -1028,7 +1028,7 @@ public class TestClusterAccessor extends AbstractTestClass {
public void testAddCustomizedConfig() throws Exception {
System.out.println("Start test :" + TestHelper.getTestMethodName());
_gSetupTool.addCluster("TestClusterCustomized", true);
- String urlBase = "clusters/TestClusterCustomized/customizedstateconfig/";
+ String urlBase = "clusters/TestClusterCustomized/customized-state-config/";
ZNRecord record = new ZNRecord("TestCustomizedStateConfig");
List<String> testList = new ArrayList<String>();
testList.add("mockType1");
@@ -1071,7 +1071,7 @@ public class TestClusterAccessor extends AbstractTestClass {
public void testDeleteCustomizedConfig() throws IOException {
System.out.println("Start test :" + TestHelper.getTestMethodName());
_gSetupTool.addCluster("TestClusterCustomized", true);
- String urlBase = "clusters/TestClusterCustomized/customizedstateconfig/";
+ String urlBase = "clusters/TestClusterCustomized/customized-state-config/";
ZNRecord record = new ZNRecord("TestCustomizedStateConfig");
List<String> testList = new ArrayList<String>();
testList.add("mockType1");
@@ -1101,7 +1101,7 @@ public class TestClusterAccessor extends AbstractTestClass {
public void testUpdateCustomizedConfig() throws IOException {
System.out.println("Start test :" + TestHelper.getTestMethodName());
_gSetupTool.addCluster("TestClusterCustomized", true);
- String urlBase = "clusters/TestClusterCustomized/customizedstateconfig/";
+ String urlBase = "clusters/TestClusterCustomized/customized-state-config/";
ZNRecord record = new ZNRecord("TestCustomizedStateConfig");
List<String> testList = new ArrayList<String>();
testList.add("mockType1");