directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject [1/2] directory-kerby git commit: DIRKRB-645 Start KerbyKdcServer should be failed if kdc_port already in use. Contributed by Lin Zeng.
Date Tue, 08 Aug 2017 01:21:47 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/1.0.x-fixes 0d92a5eed -> ffc5ddbd4


DIRKRB-645 Start KerbyKdcServer should be failed if kdc_port already in use. Contributed by
Lin Zeng.


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

Branch: refs/heads/1.0.x-fixes
Commit: 802c4f826a53d97d4c2f6f6608def9e5d171e483
Parents: f9261f9
Author: plusplusjiajia <jiajia.li@intel.com>
Authored: Tue Aug 8 09:19:19 2017 +0800
Committer: plusplusjiajia <jiajia.li@intel.com>
Committed: Tue Aug 8 09:21:03 2017 +0800

----------------------------------------------------------------------
 benchmark/pom.xml                                       |  5 -----
 .../org/apache/kerby/kerberos/kdc/KerbyKdcServer.java   |  9 +++++++--
 .../apache/kerby/kerberos/kdc/impl/NettyKdcNetwork.java | 12 +++++++-----
 3 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/802c4f82/benchmark/pom.xml
----------------------------------------------------------------------
diff --git a/benchmark/pom.xml b/benchmark/pom.xml
index 3993aaf..6147281 100644
--- a/benchmark/pom.xml
+++ b/benchmark/pom.xml
@@ -73,11 +73,6 @@
       <artifactId>json-backend</artifactId>
       <version>${project.version}</version>
     </dependency>
-    <dependency>
-      <groupId>org.apache.kerby</groupId>
-      <artifactId>zookeeper-backend</artifactId>
-      <version>${project.version}</version>
-    </dependency>
   </dependencies>
 
  <profiles>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/802c4f82/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/KerbyKdcServer.java
----------------------------------------------------------------------
diff --git a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/KerbyKdcServer.java b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/KerbyKdcServer.java
index 79cc46a..d315751 100644
--- a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/KerbyKdcServer.java
+++ b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/KerbyKdcServer.java
@@ -87,7 +87,12 @@ public class KerbyKdcServer extends KdcServer {
             System.exit(4);
         }
 
-        server.start();
-        System.out.println("KDC started.");
+        try {
+            server.start();
+            System.out.println("KDC started.");
+        } catch (KrbException e) {
+            System.err.println("Errors occurred when start kdc server:  " + e.getMessage());
+            System.exit(5);
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/802c4f82/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 50fbcf8..c230635 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
@@ -34,6 +34,7 @@ import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
 import io.netty.handler.logging.LogLevel;
 import io.netty.handler.logging.LoggingHandler;
 import io.netty.util.concurrent.DefaultEventExecutorGroup;
+import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.server.KdcContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -68,11 +69,12 @@ public class NettyKdcNetwork {
         this.udpAddress = udpAddress;
     }
 
-    public void start() {
+    public void start() throws Exception {
         try {
             doStart();
         } catch (Exception e) {
-            LOG.error("Error occurred while starting the netty kdc network.");
+            LOG.error("Error occurred while starting the netty kdc network. " + e.toString());
+            throw new KrbException("Error occurred while starting the netty kdc network.
", e);
         }
     }
 
@@ -85,19 +87,19 @@ public class NettyKdcNetwork {
                 .childHandler(createChannelInitializer());
 
         // Start the server.
-        b.bind(tcpAddress.getPort());
+        b.bind(tcpAddress.getPort()).sync();
         if (udpAddress != null) {
             startUDPServer();
         }
     }
 
-    private void startUDPServer() {
+    private void startUDPServer() throws InterruptedException {
         this.group = new NioEventLoopGroup();
         Bootstrap b = new Bootstrap();
         b.group(group).channel(NioDatagramChannel.class)
                 .option(ChannelOption.SO_BROADCAST, true)
                 .handler((ChannelHandler) new NettyKdcUdpServerHandler(kdcContext));
-        b.bind(udpAddress.getPort());
+        b.bind(udpAddress.getPort()).sync();
     }
 
     static class KrbMessageDecoder extends LengthFieldBasedFrameDecoder {


Mime
View raw message