helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject [1/2] refactor config accessor. deprecate ConfigAccessor. Add HelixConfigAccessor
Date Mon, 08 Apr 2013 06:58:25 GMT
Updated Branches:
  refs/heads/master f3e325510 -> 1b686456c


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/1b686456/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
----------------------------------------------------------------------
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 7e4af44..bbe71d0 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
@@ -19,6 +19,7 @@ package org.apache.helix.manager.zk;
  * under the License.
  */
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -28,13 +29,16 @@ import org.apache.helix.*;
 import org.apache.helix.model.ClusterConstraints;
 import org.apache.helix.model.ClusterConstraints.ConstraintAttribute;
 import org.apache.helix.model.ClusterConstraints.ConstraintType;
+import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
 import org.apache.helix.model.ConfigScope;
 import org.apache.helix.model.ConstraintItem;
 import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.HelixConfigScope;
 import org.apache.helix.model.InstanceConfig;
 import org.apache.helix.model.StateModelDefinition;
 import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.model.builder.ConstraintItemBuilder;
+import org.apache.helix.model.builder.HelixConfigScopeBuilder;
 import org.apache.helix.tools.StateModelConfigGenerator;
 import org.testng.Assert;
 import org.testng.AssertJUnit;
@@ -187,8 +191,14 @@ public class TestZkHelixAdmin extends ZkUnitTestBase
     AssertJUnit.assertNull(resourceExternalView);
 
     // test config support
-    ConfigScope scope = new ConfigScopeBuilder().forCluster(clusterName)
-        .forResource("testResource").forPartition("testPartition").build();
+//    ConfigScope scope = new ConfigScopeBuilder().forCluster(clusterName)
+//        .forResource("testResource").forPartition("testPartition").build();
+    HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTITION)
+                                  .forCluster(clusterName)
+                                  .forResource("testResource")
+                                  .forPartition("testPartition")
+                                  .build();
+  
     Map<String, String> properties = new HashMap<String, String>();
     properties.put("pKey1", "pValue1");
     properties.put("pKey2", "pValue2");
@@ -198,7 +208,7 @@ public class TestZkHelixAdmin extends ZkUnitTestBase
     for (int i = 0; i < 100; i++)
     {
       tool.setConfig(scope, properties);
-      Map<String, String> newProperties = tool.getConfig(scope, properties.keySet());
+      Map<String, String> newProperties = tool.getConfig(scope, new ArrayList<String>(properties.keySet()));
       Assert.assertEquals(newProperties.size(), 2);
       Assert.assertEquals(newProperties.get("pKey1"), "pValue1");
       Assert.assertEquals(newProperties.get("pKey2"), "pValue2");
@@ -226,7 +236,11 @@ public class TestZkHelixAdmin extends ZkUnitTestBase
         tool.addResource(clusterName, "test-db", 4, "MasterSlave");
         Map<String, String> resourceConfig = new HashMap<String, String>();
         resourceConfig.put("key1", "value1");
-        tool.setConfig(new ConfigScopeBuilder().forCluster(clusterName).forResource("test-db").build(),
resourceConfig);
+        tool.setConfig(new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE)
+                                .forCluster(clusterName)
+                                .forResource("test-db")
+                                .build(), 
+                       resourceConfig);
 
         PropertyKey.Builder keyBuilder = new PropertyKey.Builder(clusterName);
         Assert.assertTrue(_gZkClient.exists(keyBuilder.idealStates("test-db").getPath()),
"test-db ideal-state should exist");

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/1b686456/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
b/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
index 51b04da..32eeece 100644
--- a/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
+++ b/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
@@ -24,7 +24,6 @@ import java.util.UUID;
 import org.apache.helix.ClusterMessagingService;
 import org.apache.helix.ConfigAccessor;
 import org.apache.helix.ConfigChangeListener;
-import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.ControllerChangeListener;
 import org.apache.helix.CurrentStateChangeListener;
 import org.apache.helix.ExternalViewChangeListener;
@@ -46,6 +45,7 @@ import org.apache.helix.healthcheck.ParticipantHealthReportCollector;
 import org.apache.helix.manager.zk.ZKHelixDataAccessor;
 import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.manager.zk.ZkClient;
+import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
 import org.apache.helix.store.zk.ZkHelixPropertyStore;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/1b686456/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java b/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java
index 08254ea..5322d66 100644
--- a/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java
+++ b/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java
@@ -36,6 +36,7 @@ import org.apache.helix.manager.zk.ZNRecordSerializer;
 import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.manager.zk.ZkClient;
 import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.util.HelixUtil;
 import org.apache.log4j.Logger;
@@ -378,15 +379,16 @@ public class TestClusterSetup extends ZkUnitTestBase
     // basic
     _clusterSetup.addCluster(clusterName, true);
     _clusterSetup.addInstanceToCluster(clusterName, "localhost", 0);
-    String scopesStr = "CLUSTER=" + clusterName + ",PARTICIPANT=localhost_0";
-    String propertiesStr = "key1=value1,key2=value2";
-    String keysStr = "key1,key2";
-    _clusterSetup.setConfig(scopesStr, propertiesStr);
-    String valuesStr = _clusterSetup.getConfig(scopesStr, keysStr);
+    String scopeArgs = clusterName + ",localhost_0";
+    String keyValueMap = "key1=value1,key2=value2";
+    String keys = "key1,key2";
+    _clusterSetup.setConfig(ConfigScopeProperty.PARTICIPANT, scopeArgs, keyValueMap);
+    String valuesStr = _clusterSetup.getConfig(ConfigScopeProperty.PARTICIPANT, scopeArgs,
keys);
     
     // getConfig returns json-formatted key-value pairs
-    ZNRecord record = new ZNRecord(scopesStr);
-    record.setMapField(scopesStr,HelixUtil.parseCsvFormatedKeyValuePairs(propertiesStr));
+    ZNRecord record = new ZNRecord(ConfigScopeProperty.PARTICIPANT.toString());
+    // record.setMapField(scopesStr,HelixUtil.parseCsvFormatedKeyValuePairs(propertiesStr));
+    record.getSimpleFields().putAll(HelixUtil.parseCsvFormatedKeyValuePairs(keyValueMap));
     ZNRecordSerializer serializer = new ZNRecordSerializer();
     Assert.assertEquals(valuesStr, new String(serializer.serialize(record)));
 


Mime
View raw message