helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject [1/5] [HELIX-484] Remove CallbackHandler/ZkCallbackHandler code duplication, [HELIX-486] Remove StateModelFactory/HelixStateModelFactory code duplication, rb=24332
Date Thu, 07 Aug 2014 20:46:38 GMT
Repository: helix
Updated Branches:
  refs/heads/master 8ba16a8e2 -> d35e29ad0


http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/Lock.java
----------------------------------------------------------------------
diff --git a/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/Lock.java
b/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/Lock.java
index 2ca3153..a4c65d2 100644
--- a/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/Lock.java
+++ b/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/Lock.java
@@ -20,15 +20,15 @@ package org.apache.helix.lockmanager;
  */
 
 import org.apache.helix.NotificationContext;
+import org.apache.helix.api.TransitionHandler;
 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;
 
 @StateModelInfo(initialState = "OFFLINE", states = {
     "OFFLINE", "ONLINE"
 })
-public class Lock extends StateModel {
+public class Lock extends TransitionHandler {
   private String lockName;
 
   public Lock(String lockName) {

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockFactory.java
----------------------------------------------------------------------
diff --git a/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockFactory.java
b/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockFactory.java
index ab423f4..27df916 100644
--- a/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockFactory.java
+++ b/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockFactory.java
@@ -19,12 +19,12 @@ package org.apache.helix.lockmanager;
  * under the License.
  */
 
+import org.apache.helix.api.StateTransitionHandlerFactory;
 import org.apache.helix.api.id.PartitionId;
-import org.apache.helix.participant.statemachine.HelixStateModelFactory;
 
-public class LockFactory extends HelixStateModelFactory<Lock> {
+public class LockFactory extends StateTransitionHandlerFactory<Lock> {
   @Override
-  public Lock createNewStateModel(PartitionId lockName) {
+  public Lock createStateTransitionHandler(PartitionId lockName) {
     return new Lock(lockName.toString());
   }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/Consumer.java
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/Consumer.java
b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/Consumer.java
index 0b164b3..de56171 100644
--- a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/Consumer.java
+++ b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/Consumer.java
@@ -52,10 +52,10 @@ public class Consumer {
               InstanceType.PARTICIPANT, _zkAddr);
 
       StateMachineEngine stateMach = _manager.getStateMachineEngine();
-      ConsumerStateModelFactory modelFactory =
-          new ConsumerStateModelFactory(_consumerId, _mqServer);
+      ConsumerStateTransitionHandlerFactory transitionHandlerFactory =
+          new ConsumerStateTransitionHandlerFactory(_consumerId, _mqServer);
       stateMach.registerStateModelFactory(
-          StateModelDefId.from(SetupConsumerCluster.DEFAULT_STATE_MODEL), modelFactory);
+          StateModelDefId.from(SetupConsumerCluster.DEFAULT_STATE_MODEL), transitionHandlerFactory);
 
       _manager.connect();
 

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateModel.java
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateModel.java
b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateModel.java
index 24e4a40..b41ccf7 100644
--- a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateModel.java
+++ b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateModel.java
@@ -20,17 +20,16 @@ package org.apache.helix.recipes.rabbitmq;
  */
 
 import org.apache.log4j.Logger;
-
 import org.apache.helix.NotificationContext;
+import org.apache.helix.api.TransitionHandler;
 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;
 
 @StateModelInfo(initialState = "OFFLINE", states = {
     "ONLINE", "ERROR"
 })
-public class ConsumerStateModel extends StateModel {
+public class ConsumerStateModel extends TransitionHandler {
   private static Logger LOG = Logger.getLogger(ConsumerStateModel.class);
 
   private final String _consumerId;

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateModelFactory.java
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateModelFactory.java
b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateModelFactory.java
deleted file mode 100644
index 98cce35..0000000
--- a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateModelFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.helix.recipes.rabbitmq;
-
-/*
- * 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.api.id.PartitionId;
-import org.apache.helix.participant.statemachine.HelixStateModelFactory;
-
-public class ConsumerStateModelFactory extends HelixStateModelFactory<ConsumerStateModel>
{
-  private final String _consumerId;
-  private final String _mqServer;
-
-  public ConsumerStateModelFactory(String consumerId, String msServer) {
-    _consumerId = consumerId;
-    _mqServer = msServer;
-  }
-
-  @Override
-  public ConsumerStateModel createNewStateModel(PartitionId partition) {
-    ConsumerStateModel model =
-        new ConsumerStateModel(_consumerId, partition.stringify(), _mqServer);
-    return model;
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateTransitionHandlerFactory.java
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateTransitionHandlerFactory.java
b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateTransitionHandlerFactory.java
new file mode 100644
index 0000000..a0d11f8
--- /dev/null
+++ b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerStateTransitionHandlerFactory.java
@@ -0,0 +1,40 @@
+package org.apache.helix.recipes.rabbitmq;
+
+/*
+ * 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.api.StateTransitionHandlerFactory;
+import org.apache.helix.api.id.PartitionId;
+
+public class ConsumerStateTransitionHandlerFactory extends StateTransitionHandlerFactory<ConsumerStateModel>
{
+  private final String _consumerId;
+  private final String _mqServer;
+
+  public ConsumerStateTransitionHandlerFactory(String consumerId, String msServer) {
+    _consumerId = consumerId;
+    _mqServer = msServer;
+  }
+
+  @Override
+  public ConsumerStateModel createStateTransitionHandler(PartitionId partition) {
+    ConsumerStateModel model =
+        new ConsumerStateModel(_consumerId, partition.stringify(), _mqServer);
+    return model;
+  }
+}

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModel.java
----------------------------------------------------------------------
diff --git a/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModel.java
b/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModel.java
index 6eaf808..e41e52b 100644
--- a/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModel.java
+++ b/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModel.java
@@ -24,9 +24,9 @@ import org.apache.helix.AccessOption;
 import org.apache.helix.HelixManager;
 import org.apache.helix.NotificationContext;
 import org.apache.helix.ZNRecord;
+import org.apache.helix.api.TransitionHandler;
 import org.apache.helix.model.InstanceConfig;
 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.helix.store.zk.ZkHelixPropertyStore;
@@ -36,7 +36,7 @@ import org.apache.zookeeper.data.Stat;
 @StateModelInfo(initialState = "OFFLINE", states = {
     "OFFLINE", "MASTER", "SLAVE"
 })
-public class FileStoreStateModel extends StateModel {
+public class FileStoreStateModel extends TransitionHandler {
   private final class HighWaterMarkUpdater implements DataUpdater<ZNRecord> {
     private final Message message;
     private final ChangeRecord lastRecordProcessed;

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModelFactory.java
----------------------------------------------------------------------
diff --git a/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModelFactory.java
b/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModelFactory.java
index 7e1938c..b1b3e44 100644
--- a/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModelFactory.java
+++ b/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModelFactory.java
@@ -20,10 +20,10 @@ package org.apache.helix.filestore;
  */
 
 import org.apache.helix.HelixManager;
+import org.apache.helix.api.StateTransitionHandlerFactory;
 import org.apache.helix.api.id.PartitionId;
-import org.apache.helix.participant.statemachine.HelixStateModelFactory;
 
-public class FileStoreStateModelFactory extends HelixStateModelFactory<FileStoreStateModel>
{
+public class FileStoreStateModelFactory extends StateTransitionHandlerFactory<FileStoreStateModel>
{
   private final HelixManager manager;
 
   public FileStoreStateModelFactory(HelixManager manager) {
@@ -31,7 +31,7 @@ public class FileStoreStateModelFactory extends HelixStateModelFactory<FileStore
   }
 
   @Override
-  public FileStoreStateModel createNewStateModel(PartitionId partition) {
+  public FileStoreStateModel createStateTransitionHandler(PartitionId partition) {
     FileStoreStateModel model;
     model =
         new FileStoreStateModel(manager, partition.toString().split("_")[0], partition.toString());

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModel.java
----------------------------------------------------------------------
diff --git a/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModel.java
b/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModel.java
index 3c1cab4..025af38 100644
--- a/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModel.java
+++ b/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModel.java
@@ -24,12 +24,12 @@ import java.util.Set;
 import org.apache.helix.ConfigAccessor;
 import org.apache.helix.HelixManager;
 import org.apache.helix.NotificationContext;
+import org.apache.helix.api.TransitionHandler;
 import org.apache.helix.api.id.ResourceId;
 import org.apache.helix.model.HelixConfigScope;
 import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
 import org.apache.helix.model.Message;
 import org.apache.helix.model.builder.HelixConfigScopeBuilder;
-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;
@@ -37,7 +37,7 @@ import org.apache.log4j.Logger;
 @StateModelInfo(initialState = "OFFLINE", states = {
     "ONLINE", "ERROR"
 })
-public class TaskStateModel extends StateModel {
+public class TaskStateModel extends TransitionHandler {
   private static Logger LOG = Logger.getLogger(TaskStateModel.class);
 
   private final String _workerId;

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModelFactory.java
----------------------------------------------------------------------
diff --git a/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModelFactory.java
b/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModelFactory.java
index 6948237..9d6b978 100644
--- a/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModelFactory.java
+++ b/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModelFactory.java
@@ -19,10 +19,10 @@ package org.apache.helix.taskexecution;
  * under the License.
  */
 
+import org.apache.helix.api.StateTransitionHandlerFactory;
 import org.apache.helix.api.id.PartitionId;
-import org.apache.helix.participant.statemachine.HelixStateModelFactory;
 
-public class TaskStateModelFactory extends HelixStateModelFactory<TaskStateModel> {
+public class TaskStateModelFactory extends StateTransitionHandlerFactory<TaskStateModel>
{
   private final String _workerId;
   private final TaskFactory _taskFactory;
   private TaskResultStore _taskResultStore;
@@ -35,7 +35,7 @@ public class TaskStateModelFactory extends HelixStateModelFactory<TaskStateModel
   }
 
   @Override
-  public TaskStateModel createNewStateModel(PartitionId partition) {
+  public TaskStateModel createStateTransitionHandler(PartitionId partition) {
     TaskStateModel model =
         new TaskStateModel(_workerId, partition.toString(), _taskFactory, _taskResultStore);
     return model;

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/Lock.java
----------------------------------------------------------------------
diff --git a/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/Lock.java
b/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/Lock.java
index 308ae14..a185363 100644
--- a/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/Lock.java
+++ b/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/Lock.java
@@ -20,15 +20,15 @@ package org.apache.helix.userdefinedrebalancer;
  */
 
 import org.apache.helix.NotificationContext;
+import org.apache.helix.api.TransitionHandler;
 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;
 
 @StateModelInfo(initialState = "RELEASED", states = {
     "RELEASED", "LOCKED"
 })
-public class Lock extends StateModel {
+public class Lock extends TransitionHandler {
   private String lockName;
 
   public Lock(String lockName) {

http://git-wip-us.apache.org/repos/asf/helix/blob/4ae1ff79/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/LockFactory.java
----------------------------------------------------------------------
diff --git a/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/LockFactory.java
b/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/LockFactory.java
index c607b1b..de0d5aa 100644
--- a/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/LockFactory.java
+++ b/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/LockFactory.java
@@ -19,17 +19,17 @@ package org.apache.helix.userdefinedrebalancer;
  * under the License.
  */
 
+import org.apache.helix.api.StateTransitionHandlerFactory;
 import org.apache.helix.api.id.PartitionId;
-import org.apache.helix.participant.statemachine.HelixStateModelFactory;
 
 /**
  * This factory allows a participant to get the appropriate state model callbacks for the
lock
  * manager state model. This is used exactly once per participant to get a valid instance
of a Lock,
  * and then the same Lock instance is used for all state transition callbacks.
  */
-public class LockFactory extends HelixStateModelFactory<Lock> {
+public class LockFactory extends StateTransitionHandlerFactory<Lock> {
   @Override
-  public Lock createNewStateModel(PartitionId partitionId) {
+  public Lock createStateTransitionHandler(PartitionId partitionId) {
     // TODO Auto-generated method stub
     return new Lock(partitionId.stringify());
   }


Mime
View raw message