[ONOS-6868] Improve Netty message encoder/decoder performance

Change-Id: I6b4e2490fecb15bb20d9a8bb19fede3b53327bc1
diff --git a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/InternalMessage.java b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/InternalMessage.java
index 0ab7c31..646a20d 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/InternalMessage.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/InternalMessage.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * Copyright 2017-present Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,76 +15,47 @@
  */
 package org.onosproject.store.cluster.messaging.impl;
 
-import com.google.common.base.MoreObjects;
-
-import org.onlab.util.ByteArraySizeHashPrinter;
 import org.onosproject.core.HybridLogicalTime;
-import org.onosproject.store.cluster.messaging.Endpoint;
 
 /**
- * Internal message representation with additional attributes
- * for supporting, synchronous request/reply behavior.
+ * Base class for internal messages.
  */
-public final class InternalMessage {
+public abstract class InternalMessage {
 
     /**
-     * Message status.
+     * Internal message type.
      */
-    public enum Status {
-
-        // NOTE: For backwards compatibility enum constant IDs should not be changed.
-
-        /**
-         * All ok.
-         */
-        OK(0),
-
-        /**
-         * Response status signifying no registered handler.
-         */
-        ERROR_NO_HANDLER(1),
-
-        /**
-         * Response status signifying an exception handling the message.
-         */
-        ERROR_HANDLER_EXCEPTION(2),
-
-        /**
-         * Response status signifying invalid message structure.
-         */
-        PROTOCOL_EXCEPTION(3);
+    public enum Type {
+        REQUEST(1),
+        REPLY(2);
 
         private final int id;
 
-        Status(int id) {
+        Type(int id) {
             this.id = id;
         }
 
         /**
-         * Returns the unique status ID.
+         * Returns the unique message type ID.
          *
-         * @return the unique status ID.
+         * @return the unique message type ID.
          */
         public int id() {
             return id;
         }
 
         /**
-         * Returns the status enum associated with the given ID.
+         * Returns the message type enum associated with the given ID.
          *
-         * @param id the status ID.
-         * @return the status enum for the given ID.
+         * @param id the type ID.
+         * @return the type enum for the given ID.
          */
-        public static Status forId(int id) {
+        public static Type forId(int id) {
             switch (id) {
-                case 0:
-                    return OK;
                 case 1:
-                    return ERROR_NO_HANDLER;
+                    return REQUEST;
                 case 2:
-                    return ERROR_HANDLER_EXCEPTION;
-                case 3:
-                    return PROTOCOL_EXCEPTION;
+                    return REPLY;
                 default:
                     throw new IllegalArgumentException("Unknown status ID " + id);
             }
@@ -94,51 +65,26 @@
     private final int preamble;
     private final HybridLogicalTime time;
     private final long id;
-    private final Endpoint sender;
-    private final String type;
     private final byte[] payload;
-    private final Status status;
 
-    public InternalMessage(int preamble,
-                           HybridLogicalTime time,
-                           long id,
-                           Endpoint sender,
-                           String type,
-                           byte[] payload) {
-        this(preamble, time, id, sender, type, payload, null);
-    }
-
-    public InternalMessage(int preamble,
+    protected InternalMessage(int preamble,
             HybridLogicalTime time,
             long id,
-            Endpoint sender,
-            byte[] payload,
-            Status status) {
-        this(preamble, time, id, sender, "", payload, status);
-    }
-
-    InternalMessage(int preamble,
-                           HybridLogicalTime time,
-                           long id,
-                           Endpoint sender,
-                           String type,
-                           byte[] payload,
-                           Status status) {
+            byte[] payload) {
         this.preamble = preamble;
         this.time = time;
         this.id = id;
-        this.sender = sender;
-        this.type = type;
         this.payload = payload;
-        this.status = status;
     }
 
+    public abstract Type type();
+
     public boolean isRequest() {
-        return status == null;
+        return type() == Type.REQUEST;
     }
 
     public boolean isReply() {
-        return status != null;
+        return type() == Type.REPLY;
     }
 
     public HybridLogicalTime time() {
@@ -153,31 +99,7 @@
         return id;
     }
 
-    public String type() {
-        return type;
-    }
-
-    public Endpoint sender() {
-        return sender;
-    }
-
     public byte[] payload() {
         return payload;
     }
-
-    public Status status() {
-        return status;
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(this)
-                .add("time", time)
-                .add("id", id)
-                .add("type", type)
-                .add("sender", sender)
-                .add("status", status)
-                .add("payload", ByteArraySizeHashPrinter.of(payload))
-                .toString();
-    }
-}
+}
\ No newline at end of file