helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [2/2] helix git commit: Fix message intialization logics and failed tests
Date Fri, 20 Apr 2018 00:40:57 GMT
Fix message intialization logics and failed tests

RB=1282113
G=helix-reviewers
A=lxia


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

Branch: refs/heads/master
Commit: a8af64b2f193524e5fcd1fa7e348a9e1b3430f1d
Parents: b8355b9
Author: Junkai Xue <jxue@linkedin.com>
Authored: Fri Apr 13 15:51:34 2018 -0700
Committer: Junkai Xue <jxue@linkedin.com>
Committed: Thu Apr 19 17:40:30 2018 -0700

----------------------------------------------------------------------
 helix-core/src/main/java/org/apache/helix/model/Message.java  | 7 +++++--
 .../src/main/java/org/apache/helix/util/StatusUpdateUtil.java | 3 ++-
 .../helix/participant/TestDistControllerStateModel.java       | 3 ++-
 .../participant/TestDistControllerStateModelFactory.java      | 4 +++-
 4 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/a8af64b2/helix-core/src/main/java/org/apache/helix/model/Message.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/Message.java b/helix-core/src/main/java/org/apache/helix/model/Message.java
index 9f0054c..8195092 100644
--- a/helix-core/src/main/java/org/apache/helix/model/Message.java
+++ b/helix-core/src/main/java/org/apache/helix/model/Message.java
@@ -313,8 +313,11 @@ public class Message extends HelixProperty {
    */
   public MessageState getMsgState() {
     // HACK: The "toUpperCase()" call is to make the change backward compatible
-    return MessageState.valueOf(_record.getSimpleField(Attributes.MSG_STATE.toString())
-        .toUpperCase());
+    if (_record.getSimpleField(Attributes.MSG_STATE.toString()) != null) {
+      return MessageState
+          .valueOf(_record.getSimpleField(Attributes.MSG_STATE.toString()).toUpperCase());
+    }
+    return null;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/helix/blob/a8af64b2/helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java b/helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
index 90e0d24..b7a422a 100644
--- a/helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
@@ -289,7 +289,8 @@ public class StatusUpdateUtil {
     ZNRecord result = createEmptyStatusUpdateRecord(getStatusUpdateRecordName(message));
     Map<String, String> contentMap = new TreeMap<String, String>();
 
-    contentMap.put("Message state", message.getMsgState().toString());
+    contentMap.put("Message state",
+        (message.getMsgState() == null ? "NULL" : message.getMsgState().toString()));
     contentMap.put("AdditionalInfo", additionalInfo);
     contentMap.put("Class", classInfo.toString());
     contentMap.put("MSG_ID", message.getMsgId());

http://git-wip-us.apache.org/repos/asf/helix/blob/a8af64b2/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerStateModel.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerStateModel.java
b/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerStateModel.java
index 689c51b..0642d67 100644
--- a/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerStateModel.java
+++ b/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerStateModel.java
@@ -21,6 +21,7 @@ package org.apache.helix.participant;
 
 import org.apache.helix.NotificationContext;
 import org.apache.helix.TestHelper;
+import org.apache.helix.ZNRecord;
 import org.apache.helix.ZkUnitTestBase;
 import org.apache.helix.model.Message;
 import org.apache.helix.model.Message.MessageType;
@@ -47,7 +48,7 @@ public class TestDistControllerStateModel extends ZkUnitTestBase {
 
   @Test()
   public void testOnBecomeStandbyFromOffline() {
-    stateModel.onBecomeStandbyFromOffline(null, null);
+    stateModel.onBecomeStandbyFromOffline(new Message(new ZNRecord("test")), null);
   }
 
   @Test()

http://git-wip-us.apache.org/repos/asf/helix/blob/a8af64b2/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerStateModelFactory.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerStateModelFactory.java
b/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerStateModelFactory.java
index b062bf3..6b49591 100644
--- a/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerStateModelFactory.java
+++ b/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerStateModelFactory.java
@@ -19,8 +19,10 @@ package org.apache.helix.participant;
  * under the License.
  */
 
+import org.apache.helix.ZNRecord;
 import org.apache.helix.ZkUnitTestBase;
 
+import org.apache.helix.model.Message;
 import org.testng.annotations.Test;
 
 public class TestDistControllerStateModelFactory {
@@ -31,6 +33,6 @@ public class TestDistControllerStateModelFactory {
     DistClusterControllerStateModelFactory factory =
         new DistClusterControllerStateModelFactory(zkAddr);
     DistClusterControllerStateModel stateModel = factory.createNewStateModel("name", "key");
-    stateModel.onBecomeStandbyFromOffline(null, null);
+    stateModel.onBecomeStandbyFromOffline(new Message(new ZNRecord("Test")), null);
   }
 }


Mime
View raw message