helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject git commit: [HELIX-221] Can't find default error->dropped transition method using name convention, rb=13700
Date Wed, 21 Aug 2013 04:47:17 GMT
Updated Branches:
  refs/heads/master f904a6883 -> 8592340ff


[HELIX-221] Can't find default error->dropped transition method using name convention,
rb=13700


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

Branch: refs/heads/master
Commit: 8592340ffa84e92602e1345d0d6e53caa87f7683
Parents: f904a68
Author: zzhang <zzhang5@uci.edu>
Authored: Tue Aug 20 21:47:07 2013 -0700
Committer: zzhang <zzhang5@uci.edu>
Committed: Tue Aug 20 21:47:07 2013 -0700

----------------------------------------------------------------------
 .../participant/statemachine/StateModel.java    |  2 +-
 .../statemachine/TestStateModelParser.java      | 57 ++++++++++++++------
 2 files changed, 42 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/8592340f/helix-core/src/main/java/org/apache/helix/participant/statemachine/StateModel.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/participant/statemachine/StateModel.java
b/helix-core/src/main/java/org/apache/helix/participant/statemachine/StateModel.java
index 014dce9..01890f8 100644
--- a/helix-core/src/main/java/org/apache/helix/participant/statemachine/StateModel.java
+++ b/helix-core/src/main/java/org/apache/helix/participant/statemachine/StateModel.java
@@ -84,7 +84,7 @@ public abstract class StateModel
 	 * @throws InterruptedException
 	 */
   @Transition(to = "DROPPED", from = "ERROR")
-  public void defaultOnBecomeDroppedFromError(Message message, NotificationContext context)
+  public void onBecomeDroppedFromError(Message message, NotificationContext context)
   {
     logger.info("Default ERROR->DROPPED transition invoked.");
   }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/8592340f/helix-core/src/test/java/org/apache/helix/participant/statemachine/TestStateModelParser.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/participant/statemachine/TestStateModelParser.java
b/helix-core/src/test/java/org/apache/helix/participant/statemachine/TestStateModelParser.java
index 0be990e..8cbab46 100644
--- a/helix-core/src/test/java/org/apache/helix/participant/statemachine/TestStateModelParser.java
+++ b/helix-core/src/test/java/org/apache/helix/participant/statemachine/TestStateModelParser.java
@@ -32,61 +32,86 @@ public class TestStateModelParser {
   private static Logger LOG = Logger.getLogger(TestStateModelParser.class);
 
   @StateModelInfo(initialState = "OFFLINE", states = { "MASTER", "SLAVE", "ERROR" })
-  class TestStateModel extends StateModel {
+  class StateModelUsingAnnotation extends StateModel {
     @Transition(to = "SLAVE", from = "OFFLINE")
     public void onBecomeSlaveFromOffline(Message message, NotificationContext context) {
       LOG.info("Become SLAVE from OFFLINE");
     }
-    
+
+    @Override
     @Transition(to = "DROPPED", from = "ERROR")
     public void onBecomeDroppedFromError(Message message, NotificationContext context) {
       LOG.info("Become DROPPED from ERROR");
     }
 
   }
-  
+
   @StateModelInfo(initialState = "OFFLINE", states = { "MASTER", "SLAVE", "ERROR" })
-  class DerivedTestStateModel extends TestStateModel {
+  class DerivedStateModelUsingAnnotation extends StateModelUsingAnnotation {
     @Transition(to = "SLAVE", from = "OFFLINE")
     public void derivedOnBecomeSlaveFromOffline(Message message, NotificationContext context)
{
       LOG.info("Derived Become SLAVE from OFFLINE");
     }
   }
-  
+
+  class StateModelUsingNameConvention extends StateModel
+  {
+    // empty state model
+  }
+
   @Test
-  public void test() {
+  public void testUsingAnnotation() {
     StateModelParser parser = new StateModelParser();
-    TestStateModel testModel = new TestStateModel();
-    
+    StateModelUsingAnnotation testModel = new StateModelUsingAnnotation();
+
     Method method = parser.getMethodForTransitionUsingAnnotation(testModel.getClass(),
         "offline",
         "slave",
         new Class[] { Message.class, NotificationContext.class});
-    
+
     // System.out.println("method-name: " + method.getName());
+    Assert.assertNotNull(method);
     Assert.assertEquals(method.getName(), "onBecomeSlaveFromOffline");
   }
-  
+
   @Test
-  public void testDerived() {
+  public void testDerivedUsingAnnotation() {
     StateModelParser parser = new StateModelParser();
-    DerivedTestStateModel testModel = new DerivedTestStateModel();
-    
+    DerivedStateModelUsingAnnotation testModel = new DerivedStateModelUsingAnnotation();
+
     Method method = parser.getMethodForTransitionUsingAnnotation(testModel.getClass(),
         "offline",
         "slave",
         new Class[] { Message.class, NotificationContext.class});
-    
+
     // System.out.println("method-name: " + method.getName());
+    Assert.assertNotNull(method);
     Assert.assertEquals(method.getName(), "derivedOnBecomeSlaveFromOffline");
-    
-    
+
+
     method = parser.getMethodForTransitionUsingAnnotation(testModel.getClass(),
         "error",
         "dropped",
         new Class[] { Message.class, NotificationContext.class});
 
     // System.out.println("method: " + method);
+    Assert.assertNotNull(method);
+    Assert.assertEquals(method.getName(), "onBecomeDroppedFromError");
+
+  }
+
+
+  @Test
+  public void testUsingNameConvention()
+  {
+    StateModelParser parser = new StateModelParser();
+    StateModelUsingNameConvention testModel = new StateModelUsingNameConvention();
+
+    Method method = parser.getMethodForTransition(testModel.getClass(),
+                                                 "error",
+                                                 "dropped",
+                                                 new Class[] { Message.class, NotificationContext.class});
+    Assert.assertNotNull(method);
     Assert.assertEquals(method.getName(), "onBecomeDroppedFromError");
 
   }


Mime
View raw message