helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject git commit: refactor mock-participant test code
Date Wed, 06 Feb 2013 01:59:59 GMT
Updated Branches:
  refs/heads/master 1d3d90295 -> 6b8e3ca06


refactor mock-participant test code


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

Branch: refs/heads/master
Commit: 6b8e3ca064483f42148db4453f4093857ebacb50
Parents: 1d3d902
Author: zzhang <zzhang5@uci.edu>
Authored: Tue Feb 5 17:59:46 2013 -0800
Committer: zzhang <zzhang5@uci.edu>
Committed: Tue Feb 5 17:59:46 2013 -0800

----------------------------------------------------------------------
 .../TestAddStateModelFactoryAfterConnect.java      |    2 +-
 .../apache/helix/integration/TestBatchMessage.java |    2 +-
 .../org/apache/helix/integration/TestDrop.java     |    2 +-
 .../helix/integration/TestErrorPartition.java      |    2 +-
 .../helix/integration/TestNonOfflineInitState.java |    2 +-
 .../helix/integration/TestResetInstance.java       |    2 +-
 .../helix/integration/TestResetPartitionState.java |    2 +-
 .../helix/integration/TestResetResource.java       |    2 +-
 .../integration/TestStateTransitionTimeout.java    |    7 +-
 .../helix/mock/participant/ErrTransition.java      |   69 +++
 .../participant/MockBootstrapModelFactory.java     |   34 ++
 .../mock/participant/MockBootstrapStateModel.java  |   65 +++
 .../helix/mock/participant/MockMSModelFactory.java |   57 +++
 .../helix/mock/participant/MockMSStateModel.java   |  118 +++++
 .../helix/mock/participant/MockParticipant.java    |  379 ---------------
 .../mock/participant/MockSchemataModelFactory.java |   33 ++
 .../mock/participant/MockSchemataStateModel.java   |   58 +++
 .../helix/mock/participant/SleepTransition.java    |   41 ++
 .../participant/StoreAccessDiffNodeTransition.java |   86 ++++
 .../participant/StoreAccessOneNodeTransition.java  |   82 ++++
 20 files changed, 655 insertions(+), 390 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java b/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
index d3f560f..61f3de5 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
@@ -30,7 +30,7 @@ import org.apache.helix.manager.zk.ZKHelixDataAccessor;
 import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.mock.controller.ClusterController;
 import org.apache.helix.mock.participant.MockParticipant;
-import org.apache.helix.mock.participant.MockParticipant.MockMSModelFactory;
+import org.apache.helix.mock.participant.MockMSModelFactory;
 import org.apache.helix.model.CurrentState;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.IdealState;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java b/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
index cc9a4ce..145c2a3 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
@@ -35,7 +35,7 @@ import org.apache.helix.manager.zk.ZKHelixDataAccessor;
 import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.mock.controller.ClusterController;
 import org.apache.helix.mock.participant.MockParticipant;
-import org.apache.helix.mock.participant.MockParticipant.ErrTransition;
+import org.apache.helix.mock.participant.ErrTransition;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.tools.ClusterStateVerifier;
 import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java b/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
index eedf13b..c43e593 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java
@@ -31,7 +31,7 @@ import org.apache.helix.manager.zk.ZKHelixDataAccessor;
 import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.mock.controller.ClusterController;
 import org.apache.helix.mock.participant.MockParticipant;
-import org.apache.helix.mock.participant.MockParticipant.ErrTransition;
+import org.apache.helix.mock.participant.ErrTransition;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.tools.ClusterStateVerifier;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/integration/TestErrorPartition.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestErrorPartition.java b/helix-core/src/test/java/org/apache/helix/integration/TestErrorPartition.java
index 8d41f5f..05f9166 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestErrorPartition.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestErrorPartition.java
@@ -29,7 +29,7 @@ import org.apache.helix.TestHelper;
 import org.apache.helix.controller.HelixControllerMain;
 import org.apache.helix.manager.zk.ZKHelixAdmin;
 import org.apache.helix.mock.participant.MockParticipant;
-import org.apache.helix.mock.participant.MockParticipant.ErrTransition;
+import org.apache.helix.mock.participant.ErrTransition;
 import org.apache.helix.tools.ClusterStateVerifier;
 import org.testng.Assert;
 import org.testng.annotations.Test;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/integration/TestNonOfflineInitState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestNonOfflineInitState.java b/helix-core/src/test/java/org/apache/helix/integration/TestNonOfflineInitState.java
index c4d621d..2203190 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestNonOfflineInitState.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestNonOfflineInitState.java
@@ -25,7 +25,7 @@ import org.apache.helix.TestHelper;
 import org.apache.helix.controller.HelixControllerMain;
 import org.apache.helix.manager.zk.ZkClient;
 import org.apache.helix.mock.participant.MockParticipant;
-import org.apache.helix.mock.participant.MockParticipant.MockBootstrapModelFactory;
+import org.apache.helix.mock.participant.MockBootstrapModelFactory;
 import org.apache.helix.participant.StateMachineEngine;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.tools.ClusterStateVerifier;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/integration/TestResetInstance.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestResetInstance.java b/helix-core/src/test/java/org/apache/helix/integration/TestResetInstance.java
index 337c5d8..103559b 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestResetInstance.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestResetInstance.java
@@ -27,7 +27,7 @@ import java.util.Set;
 import org.apache.helix.TestHelper;
 import org.apache.helix.mock.controller.ClusterController;
 import org.apache.helix.mock.participant.MockParticipant;
-import org.apache.helix.mock.participant.MockParticipant.ErrTransition;
+import org.apache.helix.mock.participant.ErrTransition;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.tools.ClusterStateVerifier;
 import org.testng.Assert;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/integration/TestResetPartitionState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestResetPartitionState.java b/helix-core/src/test/java/org/apache/helix/integration/TestResetPartitionState.java
index 380ca62..d1751ba 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestResetPartitionState.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestResetPartitionState.java
@@ -32,7 +32,7 @@ import org.apache.helix.manager.zk.ZKHelixDataAccessor;
 import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.mock.controller.ClusterController;
 import org.apache.helix.mock.participant.MockParticipant;
-import org.apache.helix.mock.participant.MockParticipant.ErrTransition;
+import org.apache.helix.mock.participant.ErrTransition;
 import org.apache.helix.model.LiveInstance;
 import org.apache.helix.model.Message;
 import org.apache.helix.tools.ClusterSetup;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/integration/TestResetResource.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestResetResource.java b/helix-core/src/test/java/org/apache/helix/integration/TestResetResource.java
index db6d388..6daece8 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestResetResource.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestResetResource.java
@@ -27,7 +27,7 @@ import java.util.Set;
 import org.apache.helix.TestHelper;
 import org.apache.helix.mock.controller.ClusterController;
 import org.apache.helix.mock.participant.MockParticipant;
-import org.apache.helix.mock.participant.MockParticipant.ErrTransition;
+import org.apache.helix.mock.participant.ErrTransition;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.tools.ClusterStateVerifier;
 import org.testng.Assert;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java b/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java
index f014284..0a786d7 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java
@@ -36,9 +36,10 @@ import org.apache.helix.manager.zk.ZNRecordSerializer;
 import org.apache.helix.manager.zk.ZkClient;
 import org.apache.helix.messaging.handling.MessageHandler.ErrorCode;
 import org.apache.helix.mock.participant.MockJobIntf;
+import org.apache.helix.mock.participant.MockMSStateModel;
 import org.apache.helix.mock.participant.MockParticipant;
 import org.apache.helix.mock.participant.MockTransition;
-import org.apache.helix.mock.participant.MockParticipant.MockMSStateModel;
+import org.apache.helix.mock.participant.SleepTransition;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.Message;
@@ -96,7 +97,7 @@ public class TestStateTransitionTimeout extends ZkStandAloneCMTestBase
   }
   
   @StateModelInfo(initialState = "OFFLINE", states = { "MASTER", "SLAVE", "ERROR" })
-  public static class TimeOutStateModel extends MockParticipant.MockMSStateModel
+  public static class TimeOutStateModel extends MockMSStateModel
   {
     boolean _sleep = false;
     StateTransitionError _error;
@@ -175,7 +176,7 @@ public class TestStateTransitionTimeout extends ZkStandAloneCMTestBase
     @Override
     public TimeOutStateModel createNewStateModel(String stateUnitKey)
     {
-      return new TimeOutStateModel(new MockParticipant.SleepTransition(_sleepTime), partitionsToSleep.contains(stateUnitKey));
+      return new TimeOutStateModel(new SleepTransition(_sleepTime), partitionsToSleep.contains(stateUnitKey));
     }
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/ErrTransition.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/ErrTransition.java b/helix-core/src/test/java/org/apache/helix/mock/participant/ErrTransition.java
new file mode 100644
index 0000000..e7a2f0f
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/ErrTransition.java
@@ -0,0 +1,69 @@
+package org.apache.helix.mock.participant;
+
+/*
+ * 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 java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.helix.NotificationContext;
+import org.apache.helix.model.Message;
+
+// simulate error transition
+public class ErrTransition extends MockTransition
+{
+  private final Map<String, Set<String>> _errPartitions;
+
+  public ErrTransition(Map<String, Set<String>> errPartitions)
+  {
+    if (errPartitions != null)
+    {
+      // change key to upper case
+      _errPartitions = new HashMap<String, Set<String>>();
+      for (String key : errPartitions.keySet())
+      {
+        String upperKey = key.toUpperCase();
+        _errPartitions.put(upperKey, errPartitions.get(key));
+      }
+    }
+    else
+    {
+      _errPartitions = Collections.emptyMap();
+    }
+  }
+
+  @Override
+  public void doTransition(Message message, NotificationContext context)
+  {
+    String fromState = message.getFromState();
+    String toState = message.getToState();
+    String partition = message.getPartitionName();
+
+    String key = (fromState + "-" + toState).toUpperCase();
+    if (_errPartitions.containsKey(key) && _errPartitions.get(key).contains(partition))
+    {
+      String errMsg =
+          "IGNORABLE: test throw exception in msgId: " + message.getId() + " for " + partition + " transit from "
+              + fromState + " to " + toState;
+      throw new RuntimeException(errMsg);
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapModelFactory.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapModelFactory.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapModelFactory.java
new file mode 100644
index 0000000..7b95dd9
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapModelFactory.java
@@ -0,0 +1,34 @@
+package org.apache.helix.mock.participant;
+
+/*
+ * 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.participant.statemachine.StateModelFactory;
+
+// mock Bootstrap state model factory
+public class MockBootstrapModelFactory extends
+    StateModelFactory<MockBootstrapStateModel>
+{
+  @Override
+  public MockBootstrapStateModel createNewStateModel(String partitionKey)
+  {
+    MockBootstrapStateModel model = new MockBootstrapStateModel();
+    return model;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapStateModel.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapStateModel.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapStateModel.java
new file mode 100644
index 0000000..4da9bdb
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapStateModel.java
@@ -0,0 +1,65 @@
+package org.apache.helix.mock.participant;
+
+/*
+ * 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.NotificationContext;
+import org.apache.helix.model.Message;
+import org.apache.helix.participant.statemachine.StateModel;
+import org.apache.helix.participant.statemachine.StateModelInfo;
+import org.apache.helix.participant.statemachine.Transition;
+import org.apache.log4j.Logger;
+
+// mock Bootstrap state model
+@StateModelInfo(initialState = "OFFLINE", states = { "ONLINE", "BOOTSTRAP", "OFFLINE",
+    "IDLE" })
+public class MockBootstrapStateModel extends StateModel
+{
+  private static Logger LOG = Logger.getLogger(MockBootstrapStateModel.class);
+
+  // Overwrite the default value of intial state
+  MockBootstrapStateModel()
+  {
+    _currentState = "IDLE";
+  }
+
+  @Transition(to = "OFFLINE", from = "IDLE")
+  public void onBecomeOfflineFromIdle(Message message, NotificationContext context)
+  {
+    LOG.info("Become OFFLINE from IDLE");
+  }
+
+  @Transition(to = "BOOTSTRAP", from = "OFFLINE")
+  public void onBecomeBootstrapFromOffline(Message message, NotificationContext context)
+  {
+    LOG.info("Become BOOTSTRAP from OFFLINE");
+  }
+
+  @Transition(to = "ONLINE", from = "BOOSTRAP")
+  public void onBecomeOnlineFromBootstrap(Message message, NotificationContext context)
+  {
+    LOG.info("Become ONLINE from BOOTSTRAP");
+  }
+
+  @Transition(to = "OFFLINE", from = "ONLINE")
+  public void onBecomeOfflineFromOnline(Message message, NotificationContext context)
+  {
+    LOG.info("Become OFFLINE from ONLINE");
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSModelFactory.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSModelFactory.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSModelFactory.java
new file mode 100644
index 0000000..02bfb46
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSModelFactory.java
@@ -0,0 +1,57 @@
+package org.apache.helix.mock.participant;
+
+/*
+ * 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 java.util.Map;
+
+import org.apache.helix.participant.statemachine.StateModelFactory;
+
+// mock master slave state model factory
+public class MockMSModelFactory extends StateModelFactory<MockMSStateModel>
+{
+  private final MockTransition _transition;
+
+  public MockMSModelFactory()
+  {
+    this(null);
+  }
+
+  public MockMSModelFactory(MockTransition transition)
+  {
+    _transition = transition;
+  }
+
+  public void setTrasition(MockTransition transition)
+  {
+    Map<String, MockMSStateModel> stateModelMap = getStateModelMap();
+    for (MockMSStateModel stateModel : stateModelMap.values())
+    {
+      stateModel.setTransition(transition);
+    }
+  }
+
+  @Override
+  public MockMSStateModel createNewStateModel(String partitionKey)
+  {
+    MockMSStateModel model = new MockMSStateModel(_transition);
+
+    return model;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSStateModel.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSStateModel.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSStateModel.java
new file mode 100644
index 0000000..3ed6e6d
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSStateModel.java
@@ -0,0 +1,118 @@
+package org.apache.helix.mock.participant;
+
+/*
+ * 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.NotificationContext;
+import org.apache.helix.model.Message;
+import org.apache.helix.participant.statemachine.StateModel;
+import org.apache.helix.participant.statemachine.StateModelInfo;
+import org.apache.helix.participant.statemachine.Transition;
+import org.apache.log4j.Logger;
+
+// mock master-slave state model
+@StateModelInfo(initialState = "OFFLINE", states = { "MASTER", "SLAVE", "ERROR" })
+public class MockMSStateModel extends StateModel
+{
+  private static Logger LOG = Logger.getLogger(MockMSStateModel.class);
+
+  protected MockTransition _transition;
+
+  public MockMSStateModel(MockTransition transition)
+  {
+    _transition = transition;
+  }
+
+  public void setTransition(MockTransition transition)
+  {
+    _transition = transition;
+  }
+
+  @Transition(to = "SLAVE", from = "OFFLINE")
+  public void onBecomeSlaveFromOffline(Message message, NotificationContext context) throws InterruptedException
+  {
+    LOG.info("Become SLAVE from OFFLINE");
+    if (_transition != null)
+    {
+      _transition.doTransition(message, context);
+
+    }
+  }
+
+  @Transition(to = "MASTER", from = "SLAVE")
+  public void onBecomeMasterFromSlave(Message message, NotificationContext context) throws InterruptedException
+  {
+    LOG.info("Become MASTER from SLAVE");
+    if (_transition != null)
+    {
+      _transition.doTransition(message, context);
+    }
+  }
+
+  @Transition(to = "SLAVE", from = "MASTER")
+  public void onBecomeSlaveFromMaster(Message message, NotificationContext context) throws InterruptedException
+  {
+    LOG.info("Become SLAVE from MASTER");
+    if (_transition != null)
+    {
+      _transition.doTransition(message, context);
+    }
+  }
+
+  @Transition(to = "OFFLINE", from = "SLAVE")
+  public void onBecomeOfflineFromSlave(Message message, NotificationContext context) throws InterruptedException
+  {
+    LOG.info("Become OFFLINE from SLAVE");
+    if (_transition != null)
+    {
+      _transition.doTransition(message, context);
+    }
+  }
+
+  @Transition(to = "DROPPED", from = "OFFLINE")
+  public void onBecomeDroppedFromOffline(Message message, NotificationContext context) throws InterruptedException
+  {
+    LOG.info("Become DROPPED from OFFLINE");
+    if (_transition != null)
+    {
+      _transition.doTransition(message, context);
+    }
+  }
+
+  @Transition(to = "OFFLINE", from = "ERROR")
+  public void onBecomeOfflineFromError(Message message, NotificationContext context) throws InterruptedException
+  {
+    LOG.info("Become OFFLINE from ERROR");
+    // System.err.println("Become OFFLINE from ERROR");
+    if (_transition != null)
+    {
+      _transition.doTransition(message, context);
+    }
+  }
+
+  @Override
+  public void reset()
+  {
+    LOG.info("Default MockMSStateModel.reset() invoked");
+    if (_transition != null)
+    {
+      _transition.doReset();
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/MockParticipant.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockParticipant.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockParticipant.java
index 0482488..6923b5f 100644
--- a/helix-core/src/test/java/org/apache/helix/mock/participant/MockParticipant.java
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/MockParticipant.java
@@ -62,385 +62,6 @@ public class MockParticipant extends Thread
   private final StateModelFactory _msModelFactory;
   private final MockJobIntf       _job;
 
-  // mock master-slave state model
-  @StateModelInfo(initialState = "OFFLINE", states = { "MASTER", "SLAVE", "ERROR" })
-  public static class MockMSStateModel extends StateModel
-  {
-    protected MockTransition _transition;
-
-    public MockMSStateModel(MockTransition transition)
-    {
-      _transition = transition;
-    }
-
-    public void setTransition(MockTransition transition)
-    {
-      _transition = transition;
-    }
-
-    @Transition(to = "SLAVE", from = "OFFLINE")
-    public void onBecomeSlaveFromOffline(Message message, NotificationContext context) throws InterruptedException
-    {
-      LOG.info("Become SLAVE from OFFLINE");
-      if (_transition != null)
-      {
-        _transition.doTransition(message, context);
-
-      }
-    }
-
-    @Transition(to = "MASTER", from = "SLAVE")
-    public void onBecomeMasterFromSlave(Message message, NotificationContext context) throws InterruptedException
-    {
-      LOG.info("Become MASTER from SLAVE");
-      if (_transition != null)
-      {
-        _transition.doTransition(message, context);
-      }
-    }
-
-    @Transition(to = "SLAVE", from = "MASTER")
-    public void onBecomeSlaveFromMaster(Message message, NotificationContext context) throws InterruptedException
-    {
-      LOG.info("Become SLAVE from MASTER");
-      if (_transition != null)
-      {
-        _transition.doTransition(message, context);
-      }
-    }
-
-    @Transition(to = "OFFLINE", from = "SLAVE")
-    public void onBecomeOfflineFromSlave(Message message, NotificationContext context) throws InterruptedException
-    {
-      LOG.info("Become OFFLINE from SLAVE");
-      if (_transition != null)
-      {
-        _transition.doTransition(message, context);
-      }
-    }
-
-    @Transition(to = "DROPPED", from = "OFFLINE")
-    public void onBecomeDroppedFromOffline(Message message, NotificationContext context) throws InterruptedException
-    {
-      LOG.info("Become DROPPED from OFFLINE");
-      if (_transition != null)
-      {
-        _transition.doTransition(message, context);
-      }
-    }
-
-    @Transition(to = "OFFLINE", from = "ERROR")
-    public void onBecomeOfflineFromError(Message message, NotificationContext context) throws InterruptedException
-    {
-      LOG.info("Become OFFLINE from ERROR");
-      // System.err.println("Become OFFLINE from ERROR");
-      if (_transition != null)
-      {
-        _transition.doTransition(message, context);
-      }
-    }
-
-    @Override
-    public void reset()
-    {
-      LOG.info("Default MockMSStateModel.reset() invoked");
-      if (_transition != null)
-      {
-        _transition.doReset();
-      }
-    }
-  }
-
-  // mock master slave state model factory
-  public static class MockMSModelFactory extends StateModelFactory<MockMSStateModel>
-  {
-    private final MockTransition _transition;
-
-    public MockMSModelFactory()
-    {
-      this(null);
-    }
-
-    public MockMSModelFactory(MockTransition transition)
-    {
-      _transition = transition;
-    }
-
-    public void setTrasition(MockTransition transition)
-    {
-      Map<String, MockMSStateModel> stateModelMap = getStateModelMap();
-      for (MockMSStateModel stateModel : stateModelMap.values())
-      {
-        stateModel.setTransition(transition);
-      }
-    }
-
-    @Override
-    public MockMSStateModel createNewStateModel(String partitionKey)
-    {
-      MockMSStateModel model = new MockMSStateModel(_transition);
-
-      return model;
-    }
-  }
-
-  // mock STORAGE_DEFAULT_SM_SCHEMATA state model
-  @StateModelInfo(initialState = "OFFLINE", states = { "MASTER", "DROPPED", "ERROR" })
-  public class MockSchemataStateModel extends StateModel
-  {
-    @Transition(to = "MASTER", from = "OFFLINE")
-    public void onBecomeMasterFromOffline(Message message, NotificationContext context)
-    {
-      LOG.info("Become MASTER from OFFLINE");
-    }
-
-    @Transition(to = "OFFLINE", from = "MASTER")
-    public void onBecomeOfflineFromMaster(Message message, NotificationContext context)
-    {
-      LOG.info("Become OFFLINE from MASTER");
-    }
-
-    @Transition(to = "DROPPED", from = "OFFLINE")
-    public void onBecomeDroppedFromOffline(Message message, NotificationContext context)
-    {
-      LOG.info("Become DROPPED from OFFLINE");
-    }
-
-    @Transition(to = "OFFLINE", from = "ERROR")
-    public void onBecomeOfflineFromError(Message message, NotificationContext context)
-    {
-      LOG.info("Become OFFLINE from ERROR");
-    }
-  }
-
-  // mock Bootstrap state model
-  @StateModelInfo(initialState = "OFFLINE", states = { "ONLINE", "BOOTSTRAP", "OFFLINE",
-      "IDLE" })
-  public static class MockBootstrapStateModel extends StateModel
-  {
-    // Overwrite the default value of intial state
-    MockBootstrapStateModel()
-    {
-      _currentState = "IDLE";
-    }
-
-    @Transition(to = "OFFLINE", from = "IDLE")
-    public void onBecomeOfflineFromIdle(Message message, NotificationContext context)
-    {
-      LOG.info("Become OFFLINE from IDLE");
-    }
-
-    @Transition(to = "BOOTSTRAP", from = "OFFLINE")
-    public void onBecomeBootstrapFromOffline(Message message, NotificationContext context)
-    {
-      LOG.info("Become BOOTSTRAP from OFFLINE");
-    }
-
-    @Transition(to = "ONLINE", from = "BOOSTRAP")
-    public void onBecomeOnlineFromBootstrap(Message message, NotificationContext context)
-    {
-      LOG.info("Become ONLINE from BOOTSTRAP");
-    }
-
-    @Transition(to = "OFFLINE", from = "ONLINE")
-    public void onBecomeOfflineFromOnline(Message message, NotificationContext context)
-    {
-      LOG.info("Become OFFLINE from ONLINE");
-    }
-  }
-
-  // mock STORAGE_DEFAULT_SM_SCHEMATA state model factory
-  public class MockSchemataModelFactory extends StateModelFactory<MockSchemataStateModel>
-  {
-    @Override
-    public MockSchemataStateModel createNewStateModel(String partitionKey)
-    {
-      MockSchemataStateModel model = new MockSchemataStateModel();
-      return model;
-    }
-  }
-
-  // mock Bootstrap state model factory
-  public static class MockBootstrapModelFactory extends
-      StateModelFactory<MockBootstrapStateModel>
-  {
-    @Override
-    public MockBootstrapStateModel createNewStateModel(String partitionKey)
-    {
-      MockBootstrapStateModel model = new MockBootstrapStateModel();
-      return model;
-    }
-  }
-
-  // simulate error transition
-  public static class ErrTransition extends MockTransition
-  {
-    private final Map<String, Set<String>> _errPartitions;
-
-    public ErrTransition(Map<String, Set<String>> errPartitions)
-    {
-      if (errPartitions != null)
-      {
-        // change key to upper case
-        _errPartitions = new HashMap<String, Set<String>>();
-        for (String key : errPartitions.keySet())
-        {
-          String upperKey = key.toUpperCase();
-          _errPartitions.put(upperKey, errPartitions.get(key));
-        }
-      }
-      else
-      {
-        _errPartitions = Collections.emptyMap();
-      }
-    }
-
-    @Override
-    public void doTransition(Message message, NotificationContext context)
-    {
-      String fromState = message.getFromState();
-      String toState = message.getToState();
-      String partition = message.getPartitionName();
-
-      String key = (fromState + "-" + toState).toUpperCase();
-      if (_errPartitions.containsKey(key) && _errPartitions.get(key).contains(partition))
-      {
-        String errMsg =
-            "IGNORABLE: test throw exception in msgId: " + message.getId() + " for " + partition + " transit from "
-                + fromState + " to " + toState;
-        throw new RuntimeException(errMsg);
-      }
-    }
-  }
-
-  // simulate long transition
-  public static class SleepTransition extends MockTransition
-  {
-    private final long _delay;
-
-    public SleepTransition(long delay)
-    {
-      _delay = delay > 0 ? delay : 0;
-    }
-
-    @Override
-    public void doTransition(Message message, NotificationContext context) throws InterruptedException
-    {
-      Thread.sleep(_delay);
-
-    }
-  }
-
-  // simulate access property store and update one znode
-  public static class StoreAccessOneNodeTransition extends MockTransition
-  {
-    @Override
-    public void doTransition(Message message, NotificationContext context) throws InterruptedException
-    {
-      HelixManager manager = context.getManager();
-      ZkHelixPropertyStore<ZNRecord> store = manager.getHelixPropertyStore();
-      final String setPath = "/TEST_PERF/set";
-      final String updatePath = "/TEST_PERF/update";
-      final String key = message.getPartitionName();
-      try
-      {
-        // get/set once
-        ZNRecord record = null;
-        try
-        {
-          record = store.get(setPath, null, 0);
-        }
-        catch (ZkNoNodeException e)
-        {
-          record = new ZNRecord(setPath);
-        }
-        record.setSimpleField("setTimestamp", "" + System.currentTimeMillis());
-        store.set(setPath, record, AccessOption.PERSISTENT);
-
-        // update once
-        store.update(updatePath, new DataUpdater<ZNRecord>()
-        {
-
-          @Override
-          public ZNRecord update(ZNRecord currentData)
-          {
-            if (currentData == null)
-            {
-              currentData = new ZNRecord(updatePath);
-            }
-            currentData.setSimpleField(key, "" + System.currentTimeMillis());
-
-            return currentData;
-          }
-
-        }, AccessOption.PERSISTENT);
-      }
-      catch (Exception e)
-      {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
-      }
-
-    }
-  }
-
-  // simulate access property store and update different znodes
-  public static class StoreAccessDiffNodeTransition extends MockTransition
-  {
-    @Override
-    public void doTransition(Message message, NotificationContext context) throws InterruptedException
-    {
-      HelixManager manager = context.getManager();
-      ZkHelixPropertyStore<ZNRecord> store = manager.getHelixPropertyStore();
-      final String setPath = "/TEST_PERF/set/" + message.getPartitionName();
-      final String updatePath = "/TEST_PERF/update/" + message.getPartitionName();
-      // final String key = message.getPartitionName();
-      try
-      {
-        // get/set once
-        ZNRecord record = null;
-        try
-        {
-          record = store.get(setPath, null, 0);
-        }
-        catch (ZkNoNodeException e)
-        {
-          // record = new ZNRecord(setPath);
-        }
-        if (record == null)
-        {
-            record = new ZNRecord(setPath);
-        }
-        record.setSimpleField("setTimestamp", "" + System.currentTimeMillis());
-        store.set(setPath, record, AccessOption.PERSISTENT);
-
-        // update once
-        store.update(updatePath, new DataUpdater<ZNRecord>()
-        {
-
-          @Override
-          public ZNRecord update(ZNRecord currentData)
-          {
-            if (currentData == null)
-            {
-              currentData = new ZNRecord(updatePath);
-            }
-            currentData.setSimpleField("updateTimestamp", "" + System.currentTimeMillis());
-
-            return currentData;
-          }
-
-        }, AccessOption.PERSISTENT);
-      }
-      catch (Exception e)
-      {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
-      }
-
-    }
-  }
-  
   public MockParticipant(String clusterName, String instanceName, String zkAddr) throws Exception
   {
     this(clusterName, instanceName, zkAddr, null, null);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataModelFactory.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataModelFactory.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataModelFactory.java
new file mode 100644
index 0000000..8a2c024
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataModelFactory.java
@@ -0,0 +1,33 @@
+package org.apache.helix.mock.participant;
+
+/*
+ * 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.participant.statemachine.StateModelFactory;
+
+// mock STORAGE_DEFAULT_SM_SCHEMATA state model factory
+public class MockSchemataModelFactory extends StateModelFactory<MockSchemataStateModel>
+{
+  @Override
+  public MockSchemataStateModel createNewStateModel(String partitionKey)
+  {
+    MockSchemataStateModel model = new MockSchemataStateModel();
+    return model;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataStateModel.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataStateModel.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataStateModel.java
new file mode 100644
index 0000000..68c0c8e
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataStateModel.java
@@ -0,0 +1,58 @@
+package org.apache.helix.mock.participant;
+
+/*
+ * 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.NotificationContext;
+import org.apache.helix.model.Message;
+import org.apache.helix.participant.statemachine.StateModel;
+import org.apache.helix.participant.statemachine.StateModelInfo;
+import org.apache.helix.participant.statemachine.Transition;
+import org.apache.log4j.Logger;
+
+// mock STORAGE_DEFAULT_SM_SCHEMATA state model
+@StateModelInfo(initialState = "OFFLINE", states = { "MASTER", "DROPPED", "ERROR" })
+public class MockSchemataStateModel extends StateModel
+{
+  private static Logger LOG = Logger.getLogger(MockSchemataStateModel.class);
+
+  @Transition(to = "MASTER", from = "OFFLINE")
+  public void onBecomeMasterFromOffline(Message message, NotificationContext context)
+  {
+    LOG.info("Become MASTER from OFFLINE");
+  }
+
+  @Transition(to = "OFFLINE", from = "MASTER")
+  public void onBecomeOfflineFromMaster(Message message, NotificationContext context)
+  {
+    LOG.info("Become OFFLINE from MASTER");
+  }
+
+  @Transition(to = "DROPPED", from = "OFFLINE")
+  public void onBecomeDroppedFromOffline(Message message, NotificationContext context)
+  {
+    LOG.info("Become DROPPED from OFFLINE");
+  }
+
+  @Transition(to = "OFFLINE", from = "ERROR")
+  public void onBecomeOfflineFromError(Message message, NotificationContext context)
+  {
+    LOG.info("Become OFFLINE from ERROR");
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/SleepTransition.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/SleepTransition.java b/helix-core/src/test/java/org/apache/helix/mock/participant/SleepTransition.java
new file mode 100644
index 0000000..fc6d0a1
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/SleepTransition.java
@@ -0,0 +1,41 @@
+package org.apache.helix.mock.participant;
+
+/*
+ * 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.NotificationContext;
+import org.apache.helix.model.Message;
+
+// simulate long transition
+public class SleepTransition extends MockTransition
+{
+  private final long _delay;
+
+  public SleepTransition(long delay)
+  {
+    _delay = delay > 0 ? delay : 0;
+  }
+
+  @Override
+  public void doTransition(Message message, NotificationContext context) throws InterruptedException
+  {
+    Thread.sleep(_delay);
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/StoreAccessDiffNodeTransition.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/StoreAccessDiffNodeTransition.java b/helix-core/src/test/java/org/apache/helix/mock/participant/StoreAccessDiffNodeTransition.java
new file mode 100644
index 0000000..d3bba54
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/StoreAccessDiffNodeTransition.java
@@ -0,0 +1,86 @@
+package org.apache.helix.mock.participant;
+
+/*
+ * 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.I0Itec.zkclient.DataUpdater;
+import org.I0Itec.zkclient.exception.ZkNoNodeException;
+import org.apache.helix.AccessOption;
+import org.apache.helix.HelixManager;
+import org.apache.helix.NotificationContext;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.model.Message;
+import org.apache.helix.store.zk.ZkHelixPropertyStore;
+
+// simulate access property store and update different znodes
+public class StoreAccessDiffNodeTransition extends MockTransition
+{
+  @Override
+  public void doTransition(Message message, NotificationContext context) throws InterruptedException
+  {
+    HelixManager manager = context.getManager();
+    ZkHelixPropertyStore<ZNRecord> store = manager.getHelixPropertyStore();
+    final String setPath = "/TEST_PERF/set/" + message.getPartitionName();
+    final String updatePath = "/TEST_PERF/update/" + message.getPartitionName();
+    // final String key = message.getPartitionName();
+    try
+    {
+      // get/set once
+      ZNRecord record = null;
+      try
+      {
+        record = store.get(setPath, null, 0);
+      }
+      catch (ZkNoNodeException e)
+      {
+        // record = new ZNRecord(setPath);
+      }
+      if (record == null)
+      {
+          record = new ZNRecord(setPath);
+      }
+      record.setSimpleField("setTimestamp", "" + System.currentTimeMillis());
+      store.set(setPath, record, AccessOption.PERSISTENT);
+
+      // update once
+      store.update(updatePath, new DataUpdater<ZNRecord>()
+      {
+
+        @Override
+        public ZNRecord update(ZNRecord currentData)
+        {
+          if (currentData == null)
+          {
+            currentData = new ZNRecord(updatePath);
+          }
+          currentData.setSimpleField("updateTimestamp", "" + System.currentTimeMillis());
+
+          return currentData;
+        }
+
+      }, AccessOption.PERSISTENT);
+    }
+    catch (Exception e)
+    {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6b8e3ca0/helix-core/src/test/java/org/apache/helix/mock/participant/StoreAccessOneNodeTransition.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/StoreAccessOneNodeTransition.java b/helix-core/src/test/java/org/apache/helix/mock/participant/StoreAccessOneNodeTransition.java
new file mode 100644
index 0000000..44d8f0e
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/mock/participant/StoreAccessOneNodeTransition.java
@@ -0,0 +1,82 @@
+package org.apache.helix.mock.participant;
+
+/*
+ * 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.I0Itec.zkclient.DataUpdater;
+import org.I0Itec.zkclient.exception.ZkNoNodeException;
+import org.apache.helix.AccessOption;
+import org.apache.helix.HelixManager;
+import org.apache.helix.NotificationContext;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.model.Message;
+import org.apache.helix.store.zk.ZkHelixPropertyStore;
+
+// simulate access property store and update one znode
+public class StoreAccessOneNodeTransition extends MockTransition
+{
+  @Override
+  public void doTransition(Message message, NotificationContext context) throws InterruptedException
+  {
+    HelixManager manager = context.getManager();
+    ZkHelixPropertyStore<ZNRecord> store = manager.getHelixPropertyStore();
+    final String setPath = "/TEST_PERF/set";
+    final String updatePath = "/TEST_PERF/update";
+    final String key = message.getPartitionName();
+    try
+    {
+      // get/set once
+      ZNRecord record = null;
+      try
+      {
+        record = store.get(setPath, null, 0);
+      }
+      catch (ZkNoNodeException e)
+      {
+        record = new ZNRecord(setPath);
+      }
+      record.setSimpleField("setTimestamp", "" + System.currentTimeMillis());
+      store.set(setPath, record, AccessOption.PERSISTENT);
+
+      // update once
+      store.update(updatePath, new DataUpdater<ZNRecord>()
+      {
+
+        @Override
+        public ZNRecord update(ZNRecord currentData)
+        {
+          if (currentData == null)
+          {
+            currentData = new ZNRecord(updatePath);
+          }
+          currentData.setSimpleField(key, "" + System.currentTimeMillis());
+
+          return currentData;
+        }
+
+      }, AccessOption.PERSISTENT);
+    }
+    catch (Exception e)
+    {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+
+  }
+}
\ No newline at end of file


Mime
View raw message