junkaixue commented on code in PR #2380:
URL: https://github.com/apache/helix/pull/2380#discussion_r1122150815


##########
helix-core/src/main/java/org/apache/helix/model/Message.java:
##########
@@ -966,4 +966,45 @@ public boolean isValid() {
     }
     return true;
   }
+
+  /**
+   * This class is for categorizing state transition messages based on certain 
properties, and generating
+   */
+  public static class MessageInfo {
+    public String _msgType;
+    public String _resourceName;
+    public String _fromState;
+    public String _toState;
+
+    public enum MessageIdentifierBase {
+      PER_RESOURCE,
+      PER_STATE_TRANSITION_TYPE
+    }
+
+    public MessageInfo(Message message) {
+      _msgType = message.getMsgType();
+      _resourceName = message.getResourceName();
+      _fromState = message.getFromState();
+      _toState = message.getToState();
+    }
+
+    public String getMessageIdentifier(MessageIdentifierBase basis) {
+      String delimiter = ".";
+      if (basis == null || _msgType == null) {
+        return null;
+      }
+      String identifier = _msgType;
+      if (_resourceName == null) {
+        return null;
+      }
+      identifier = String.join(delimiter, identifier, _resourceName);
+      if (basis == MessageIdentifierBase.PER_STATE_TRANSITION_TYPE) {
+        if (_fromState == null || _toState == null) {
+          return null;
+        }
+        identifier = String.join(delimiter, identifier, _fromState, _toState);
+      }

Review Comment:
   Let's restructure it as switch case for enum. So if we have more other 
types, it can help.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to