directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject directory-kerby git commit: DIRKRB-552 Fail to restart KdcServer.
Date Mon, 23 May 2016 08:53:20 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/trunk a41240706 -> 3ed0e7cd3


DIRKRB-552 Fail to restart KdcServer.


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/3ed0e7cd
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/3ed0e7cd
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/3ed0e7cd

Branch: refs/heads/trunk
Commit: 3ed0e7cd3b8a0c3ce29293153e4e72f422f0637f
Parents: a412407
Author: plusplusjiajia <jiajia.li@intel.com>
Authored: Mon May 23 16:58:23 2016 +0800
Committer: plusplusjiajia <jiajia.li@intel.com>
Committed: Mon May 23 16:58:23 2016 +0800

----------------------------------------------------------------------
 .../kerberos/kdc/impl/NettyKdcNetwork.java      | 10 +++++
 .../kerberos/kdc/impl/NettyKdcServerImpl.java   | 14 ++++++-
 kerby-kerb/kerb-kdc-test/pom.xml                |  6 +++
 .../RepeatLoginWithDefaultKdcNetworkTest.java   | 34 ++++++++++++++++
 .../RepeatLoginWithNettyKdcNetworkTest.java     | 43 ++++++++++++++++++++
 .../impl/DefaultInternalKdcServerImpl.java      | 19 ++++++++-
 6 files changed, 124 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/3ed0e7cd/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/impl/NettyKdcNetwork.java
----------------------------------------------------------------------
diff --git a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/impl/NettyKdcNetwork.java
b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/impl/NettyKdcNetwork.java
index cfa4adb..1740432 100644
--- a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/impl/NettyKdcNetwork.java
+++ b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/impl/NettyKdcNetwork.java
@@ -126,5 +126,15 @@ public class NettyKdcNetwork {
         if (udpAddress != null) {
             group.shutdownGracefully();
         }
+
+        try {
+            bossGroup.terminationFuture().sync();
+            workerGroup.terminationFuture().sync();
+            if (udpAddress != null) {
+                group.terminationFuture().sync();
+            }
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/3ed0e7cd/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/impl/NettyKdcServerImpl.java
----------------------------------------------------------------------
diff --git a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/impl/NettyKdcServerImpl.java
b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/impl/NettyKdcServerImpl.java
index 9a795f0..5c527f1 100644
--- a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/impl/NettyKdcServerImpl.java
+++ b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/impl/NettyKdcServerImpl.java
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
 import java.net.InetSocketAddress;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 /**
  * A Netty based KDC server implementation.
@@ -81,7 +82,18 @@ public class NettyKdcServerImpl extends AbstractInternalKdcServer {
 
         network.stop();
 
-        executor.shutdownNow();
+        executor.shutdown();
+
+        try {
+            boolean terminated = false;
+            do {
+                // wait until the pool has terminated
+                terminated = executor.awaitTermination(60, TimeUnit.SECONDS);
+            } while (!terminated);
+        } catch (InterruptedException e) {
+            executor.shutdownNow();
+            LOG.warn("waitForTermination interrupted");
+        }
         LOG.info("Netty kdc server stopped.");
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/3ed0e7cd/kerby-kerb/kerb-kdc-test/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/pom.xml b/kerby-kerb/kerb-kdc-test/pom.xml
index 3f01e59..b471f3a 100644
--- a/kerby-kerb/kerb-kdc-test/pom.xml
+++ b/kerby-kerb/kerb-kdc-test/pom.xml
@@ -63,6 +63,12 @@
       <version>${slf4j.version}</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.kerby</groupId>
+      <artifactId>kerby-kdc</artifactId>
+      <version>1.0.0-RC3-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/3ed0e7cd/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/RepeatLoginWithDefaultKdcNetworkTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/RepeatLoginWithDefaultKdcNetworkTest.java
b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/RepeatLoginWithDefaultKdcNetworkTest.java
new file mode 100644
index 0000000..8ce8e71
--- /dev/null
+++ b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/RepeatLoginWithDefaultKdcNetworkTest.java
@@ -0,0 +1,34 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.kerberos.kerb.server;
+
+import org.junit.Test;
+
+public class RepeatLoginWithDefaultKdcNetworkTest extends LoginTestBase {
+    @Test
+    public void testLogin() throws Exception {
+        checkSubject(super.loginServiceUsingKeytab());
+    }
+
+    @Test
+    public void testLoginSecondTime() throws Exception {
+        checkSubject(super.loginServiceUsingKeytab());
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/3ed0e7cd/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/RepeatLoginWithNettyKdcNetworkTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/RepeatLoginWithNettyKdcNetworkTest.java
b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/RepeatLoginWithNettyKdcNetworkTest.java
new file mode 100644
index 0000000..e82db7b
--- /dev/null
+++ b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/RepeatLoginWithNettyKdcNetworkTest.java
@@ -0,0 +1,43 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.kerberos.kerb.server;
+
+import org.apache.kerby.kerberos.kdc.impl.NettyKdcServerImpl;
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.junit.Test;
+
+public class RepeatLoginWithNettyKdcNetworkTest extends LoginTestBase {
+    @Override
+    protected void prepareKdc() throws KrbException {
+        getKdcServer().setInnerKdcImpl(
+            new NettyKdcServerImpl(getKdcServer().getKdcSetting()));
+        super.prepareKdc();
+    }
+
+    @Test
+    public void testLogin() throws Exception {
+        checkSubject(super.loginServiceUsingKeytab());
+    }
+
+    @Test
+    public void testLoginSecondTime() throws Exception {
+        checkSubject(super.loginServiceUsingKeytab());
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/3ed0e7cd/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/impl/DefaultInternalKdcServerImpl.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/impl/DefaultInternalKdcServerImpl.java
b/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/impl/DefaultInternalKdcServerImpl.java
index dec1221..3ffd877 100644
--- a/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/impl/DefaultInternalKdcServerImpl.java
+++ b/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/impl/DefaultInternalKdcServerImpl.java
@@ -26,14 +26,18 @@ import org.apache.kerby.kerberos.kerb.server.preauth.PreauthHandler;
 import org.apache.kerby.kerberos.kerb.transport.KdcNetwork;
 import org.apache.kerby.kerberos.kerb.transport.KrbTransport;
 import org.apache.kerby.kerberos.kerb.transport.TransportPair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 /**
  * A default KDC server implementation.
  */
 public class DefaultInternalKdcServerImpl extends AbstractInternalKdcServer {
+    private static final Logger LOG = LoggerFactory.getLogger(DefaultInternalKdcServerImpl.class);
     private ExecutorService executor;
     private KdcContext kdcContext;
     private KdcNetwork network;
@@ -78,6 +82,19 @@ public class DefaultInternalKdcServerImpl extends AbstractInternalKdcServer
{
 
         network.stop();
 
-        executor.shutdownNow();
+        executor.shutdown();
+
+        try {
+            boolean terminated = false;
+            do {
+                // wait until the pool has terminated
+                terminated = executor.awaitTermination(60, TimeUnit.SECONDS);
+            } while (!terminated);
+        } catch (InterruptedException e) {
+            executor.shutdownNow();
+            LOG.warn("waitForTermination interrupted");
+        }
+
+        LOG.info("Default Internal kdc server stopped.");
     }
 }


Mime
View raw message