Workaround for NoClassDefFound issue in Netty.

SimpleChannelInboundHandler generates `message` instance check code on the fly,
using JavaAssist. Which was not working, when a new Connection was created on the thread
outside of NettyMessagingManager bundle, which did not have access to netty classes.
- Implemented equivalent for SimpleChannelInboundHandler<InternaleMessage>
  without specifying type parameter, avoiding on the fly code generation.

Other changes:
- Add a method in IpAddress to return InetAddress instance.

Change-Id: Ie97294a5650683457b9395e773269c5232d8e602
diff --git a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
index 52a264e..a806c02 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
@@ -41,7 +41,6 @@
 import io.netty.channel.socket.SocketChannel;
 import io.netty.channel.socket.nio.NioServerSocketChannel;
 import io.netty.channel.socket.nio.NioSocketChannel;
-
 import org.apache.commons.pool.KeyedPoolableObjectFactory;
 import org.apache.commons.pool.impl.GenericKeyedObjectPool;
 import org.apache.felix.scr.annotations.Activate;
@@ -383,7 +382,7 @@
             }
             // Start the client.
             CompletableFuture<Channel> retFuture = new CompletableFuture<>();
-            ChannelFuture f = bootstrap.connect(ep.host().toString(), ep.port());
+            ChannelFuture f = bootstrap.connect(ep.host().toInetAddress(), ep.port());
 
             f.addListener(future -> {
                 if (future.isSuccess()) {
@@ -491,10 +490,13 @@
     }
 
     @ChannelHandler.Sharable
-    private class InboundMessageDispatcher extends SimpleChannelInboundHandler<InternalMessage> {
+    private class InboundMessageDispatcher extends SimpleChannelInboundHandler<Object> {
+     // Effectively SimpleChannelInboundHandler<InternalMessage>,
+     // had to specify <Object> to avoid Class Loader not being able to find some classes.
 
         @Override
-        protected void channelRead0(ChannelHandlerContext ctx, InternalMessage message) throws Exception {
+        protected void channelRead0(ChannelHandlerContext ctx, Object rawMessage) throws Exception {
+            InternalMessage message = (InternalMessage) rawMessage;
             try {
                 dispatchLocally(message);
             } catch (RejectedExecutionException e) {
@@ -507,7 +509,21 @@
             log.error("Exception inside channel handling pipeline.", cause);
             context.close();
         }
+
+        /**
+         * Returns true if the given message should be handled.
+         *
+         * @param msg inbound message
+         * @return true if {@code msg} is {@link InternalMessage} instance.
+         *
+         * @see SimpleChannelInboundHandler#acceptInboundMessage(Object)
+         */
+        @Override
+        public final boolean acceptInboundMessage(Object msg) {
+            return msg instanceof InternalMessage;
+        }
     }
+
     private void dispatchLocally(InternalMessage message) throws IOException {
         if (message.preamble() != preamble) {
             log.debug("Received {} with invalid preamble from {}", message.type(), message.sender());