bookkeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject bookkeeper git commit: BOOKKEEPER-917: LocalBookKeeperTest seems to be silently failing
Date Sun, 10 Apr 2016 03:59:11 GMT
Repository: bookkeeper
Updated Branches:
  refs/heads/master f2bc62b85 -> b42d8db2b


BOOKKEEPER-917: LocalBookKeeperTest seems to be silently failing

Fixing the `AuthHandler` to use localhost address when passed a `LocalChannel`

Author: Matteo Merli <mmerli@apache.org>

Reviewers: Sijie Guo <sijie@apache.org>

Closes #34 from merlimat/bk-917


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

Branch: refs/heads/master
Commit: b42d8db2b03079ce65d603d808442297ad759433
Parents: f2bc62b
Author: Matteo Merli <mmerli@apache.org>
Authored: Sat Apr 9 20:58:40 2016 -0700
Committer: Sijie Guo <sijie@apache.org>
Committed: Sat Apr 9 20:58:40 2016 -0700

----------------------------------------------------------------------
 .../apache/bookkeeper/proto/AuthHandler.java    | 39 ++++++++++++--------
 1 file changed, 23 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/b42d8db2/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/AuthHandler.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/AuthHandler.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/AuthHandler.java
index 522bc0b..ab49da7 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/AuthHandler.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/AuthHandler.java
@@ -21,29 +21,25 @@
 package org.apache.bookkeeper.proto;
 
 import java.io.IOException;
+import java.net.Inet4Address;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.jboss.netty.channel.SimpleChannelHandler;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.DefaultExceptionEvent;
-import org.jboss.netty.channel.ExceptionEvent;
-
 import org.apache.bookkeeper.auth.BookieAuthProvider;
 import org.apache.bookkeeper.auth.ClientAuthProvider;
 import org.apache.bookkeeper.client.BKException;
-import org.apache.bookkeeper.proto.BookkeeperProtocol.AddRequest;
-import org.apache.bookkeeper.proto.BookkeeperProtocol.AddResponse;
-import org.apache.bookkeeper.proto.BookkeeperProtocol.AuthMessage;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
-import org.apache.bookkeeper.proto.BookkeeperProtocol.OperationType;
-import org.apache.bookkeeper.proto.BookkeeperProtocol.StatusCode;
+import org.apache.bookkeeper.proto.BookkeeperProtocol.AuthMessage;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelStateEvent;
+import org.jboss.netty.channel.DefaultExceptionEvent;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelHandler;
+import org.jboss.netty.channel.local.LocalChannel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -68,8 +64,12 @@ class AuthHandler {
             if (remote instanceof InetSocketAddress) {
                 authProvider = authProviderFactory.newProvider((InetSocketAddress)remote,
                         new AuthHandshakeCompleteCallback());
+            } else if (ctx.getChannel() instanceof LocalChannel) {
+                authProvider = authProviderFactory.newProvider(new InetSocketAddress(Inet4Address.getLocalHost(),
0),
+                        new AuthHandshakeCompleteCallback());
             } else {
-                LOG.error("Unknown socket type {} for {}", remote.getClass(), remote);
+                LOG.error("Unknown channel ({}) or socket type {} for {}",
+                        new Object[] { ctx.getChannel(), remote != null ? remote.getClass()
: null, remote });
             }
             super.channelOpen(ctx, e);
         }
@@ -229,9 +229,16 @@ class AuthHandler {
             if (remote instanceof InetSocketAddress) {
                 authProvider = authProviderFactory.newProvider((InetSocketAddress)remote,
                         new AuthHandshakeCompleteCallback(ctx));
-                authProvider.init(new AuthRequestCallback(ctx));
+            } else if (ctx.getChannel() instanceof LocalChannel) {
+                authProvider = authProviderFactory.newProvider(new InetSocketAddress(Inet4Address.getLocalHost(),
0),
+                        new AuthHandshakeCompleteCallback(ctx));
             } else {
-                LOG.error("Unknown socket type {} for {}", remote.getClass(), remote);
+                LOG.error("Unknown channel ({}) or socket type {} for {}",
+                        new Object[] { ctx.getChannel(), remote != null ? remote.getClass()
: null, remote });
+            }
+
+            if (authProvider != null) {
+                authProvider.init(new AuthRequestCallback(ctx));
             }
             super.channelConnected(ctx, e);
         }


Mime
View raw message