helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject git commit: HELIX-47: when drop resource, remove resource-level config also
Date Wed, 20 Mar 2013 01:45:34 GMT
Updated Branches:
  refs/heads/master 62239a519 -> 34efecb24


HELIX-47: when drop resource, remove resource-level config also


Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/34efecb2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/34efecb2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/34efecb2

Branch: refs/heads/master
Commit: 34efecb24ca3bbaa184068ce86c52c7079ac18c8
Parents: 62239a5
Author: zzhang <zzhang5@uci.edu>
Authored: Tue Mar 19 18:45:27 2013 -0700
Committer: zzhang <zzhang5@uci.edu>
Committed: Tue Mar 19 18:45:27 2013 -0700

----------------------------------------------------------------------
 .../org/apache/helix/manager/zk/ZKHelixAdmin.java  |    1 +
 .../helix/tools/StateModelConfigGenerator.java     |   10 ++--
 .../apache/helix/manager/zk/TestZkHelixAdmin.java  |   39 ++++++++++++---
 .../org/apache/helix/model/TestIdealState.java     |    2 -
 4 files changed, 38 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/34efecb2/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
----------------------------------------------------------------------
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 3af4fbb..73e6045 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
@@ -812,6 +812,7 @@ public class ZKHelixAdmin implements HelixAdmin
     Builder keyBuilder = accessor.keyBuilder();
 
     accessor.removeProperty(keyBuilder.idealStates(resourceName));
+    accessor.removeProperty(keyBuilder.resourceConfig(resourceName));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/34efecb2/helix-core/src/main/java/org/apache/helix/tools/StateModelConfigGenerator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/StateModelConfigGenerator.java
b/helix-core/src/main/java/org/apache/helix/tools/StateModelConfigGenerator.java
index dada08a..02b843f 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/StateModelConfigGenerator.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/StateModelConfigGenerator.java
@@ -49,7 +49,7 @@ public class StateModelConfigGenerator
    * to last state
    */
 
-  public ZNRecord generateConfigForStorageSchemata()
+  public static ZNRecord generateConfigForStorageSchemata()
   {
     ZNRecord record = new ZNRecord("STORAGE_DEFAULT_SM_SCHEMATA");
     record.setSimpleField(StateModelDefinitionProperty.INITIAL_STATE.toString(),
@@ -118,7 +118,7 @@ public class StateModelConfigGenerator
     return record;
   }
 
-  public ZNRecord generateConfigForMasterSlave()
+  public static ZNRecord generateConfigForMasterSlave()
   {
     ZNRecord record = new ZNRecord("MasterSlave");
     record.setSimpleField(StateModelDefinitionProperty.INITIAL_STATE.toString(),
@@ -208,7 +208,7 @@ public class StateModelConfigGenerator
     // System.out.println(new String(serializer.serialize(record)));
   }
 
-  public ZNRecord generateConfigForLeaderStandby()
+  public static ZNRecord generateConfigForLeaderStandby()
   {
     ZNRecord record = new ZNRecord("LeaderStandby");
     record.setSimpleField(StateModelDefinitionProperty.INITIAL_STATE.toString(),
@@ -290,7 +290,7 @@ public class StateModelConfigGenerator
     // System.out.println(new String(serializer.serialize(record)));
   }
 
-  public ZNRecord generateConfigForOnlineOffline()
+  public static ZNRecord generateConfigForOnlineOffline()
   {
     ZNRecord record = new ZNRecord("OnlineOffline");
     record.setSimpleField(StateModelDefinitionProperty.INITIAL_STATE.toString(),
@@ -352,7 +352,7 @@ public class StateModelConfigGenerator
     // System.out.println(new String(serializer.serialize(record)));
   }
   
-  public ZNRecord generateConfigForScheduledTaskQueue()
+  public static ZNRecord generateConfigForScheduledTaskQueue()
   {
     ZNRecord record = new ZNRecord(DefaultSchedulerMessageHandlerFactory.SCHEDULER_TASK_QUEUE);
     record.setSimpleField(StateModelDefinitionProperty.INITIAL_STATE.toString(),

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/34efecb2/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 0c5ecaf..d5118c9 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
@@ -24,18 +24,13 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
-import org.apache.helix.HelixException;
-import org.apache.helix.PropertyPathConfig;
-import org.apache.helix.PropertyType;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.ZkUnitTestBase;
+import org.apache.helix.*;
 import org.apache.helix.manager.zk.ZKHelixAdmin;
 import org.apache.helix.manager.zk.ZKUtil;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.InstanceConfig;
 import org.apache.helix.model.StateModelDefinition;
+import org.apache.helix.tools.StateModelConfigGenerator;
 import org.testng.Assert;
 import org.testng.AssertJUnit;
 import org.testng.annotations.Test;
@@ -199,4 +194,34 @@ public class TestZkHelixAdmin extends ZkUnitTestBase
     System.out.println("END testZkHelixAdmin at " + new Date(System.currentTimeMillis()));
   }
 
+    @Test
+    public void testDropResource() {
+        String className = TestHelper.getTestClassName();
+        String methodName = TestHelper.getTestMethodName();
+        String clusterName = className + "_" + methodName;
+
+        System.out.println("START " + clusterName + " at "
+                + new Date(System.currentTimeMillis()));
+
+        ZKHelixAdmin tool = new ZKHelixAdmin(_gZkClient);
+        tool.addCluster(clusterName, true);
+        Assert.assertTrue(ZKUtil.isClusterSetup(clusterName, _gZkClient), "Cluster should
be setup");
+
+        tool.addStateModelDef(clusterName, "MasterSlave", new StateModelDefinition(StateModelConfigGenerator.generateConfigForMasterSlave()));
+        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);
+
+        PropertyKey.Builder keyBuilder = new PropertyKey.Builder(clusterName);
+        Assert.assertTrue(_gZkClient.exists(keyBuilder.idealStates("test-db").getPath()),
"test-db ideal-state should exist");
+        Assert.assertTrue(_gZkClient.exists(keyBuilder.resourceConfig("test-db").getPath()),
"test-db resource config should exist");
+
+        tool.dropResource(clusterName, "test-db");
+        Assert.assertFalse(_gZkClient.exists(keyBuilder.idealStates("test-db").getPath()),
"test-db ideal-state should be dropped");
+        Assert.assertFalse(_gZkClient.exists(keyBuilder.resourceConfig("test-db").getPath()),
"test-db resource config should be dropped");
+
+        System.out.println("END " + clusterName + " at "
+                + new Date(System.currentTimeMillis()));
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/34efecb2/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java b/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java
index 7b9688d..89b02ad 100644
--- a/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java
+++ b/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java
@@ -22,7 +22,6 @@ package org.apache.helix.model;
 import java.util.*;
 
 import org.apache.helix.TestHelper;
-import org.apache.helix.model.IdealState;
 import org.apache.helix.model.IdealState.IdealStateModeProperty;
 import org.testng.Assert;
 import org.testng.annotations.Test;
@@ -91,6 +90,5 @@ public class TestIdealState
       idealState.getRecord().setListField("test-db_0", preferenceList);
       Assert.assertTrue(idealState.isValid(), "should pass since replicas equals to preference-list
size");
 
-
   }
 }


Mime
View raw message