directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject directory-kerby git commit: WIP: Working on ZK based backend
Date Mon, 16 Mar 2015 22:55:28 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master e98333ad7 -> 58866a42b


WIP: Working on ZK based backend


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

Branch: refs/heads/master
Commit: 58866a42b48c5a451950c6e6b0d00cfa59ad951f
Parents: e98333a
Author: Drankye <drankye@gmail.com>
Authored: Tue Mar 17 06:52:57 2015 +0800
Committer: Drankye <drankye@gmail.com>
Committed: Tue Mar 17 06:52:57 2015 +0800

----------------------------------------------------------------------
 kdc-backend/ldap-backend/pom.xml                | 12 ++++
 .../kerb/identity/backend/LdapBackendTest.java  | 41 ++++++++++++
 kdc-backend/zookeeper-backend/pom.xml           |  6 ++
 .../kerberos/kdc/identitybackend/ZKConfKey.java |  5 +-
 .../ZookeeperIdentityBackend.java               | 11 +++
 .../identity/backend/ZookeeperBackendTest.java  | 70 ++++++++++++++++++++
 6 files changed, 144 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/58866a42/kdc-backend/ldap-backend/pom.xml
----------------------------------------------------------------------
diff --git a/kdc-backend/ldap-backend/pom.xml b/kdc-backend/ldap-backend/pom.xml
index 45d1bdf..545c5a9 100644
--- a/kdc-backend/ldap-backend/pom.xml
+++ b/kdc-backend/ldap-backend/pom.xml
@@ -46,5 +46,17 @@
       <artifactId>api-ldap-client-api</artifactId>
       <version>${ldap.api.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.kerby</groupId>
+      <artifactId>kerb-identity-test</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/58866a42/kdc-backend/ldap-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/LdapBackendTest.java
----------------------------------------------------------------------
diff --git a/kdc-backend/ldap-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/LdapBackendTest.java
b/kdc-backend/ldap-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/LdapBackendTest.java
new file mode 100644
index 0000000..8361136
--- /dev/null
+++ b/kdc-backend/ldap-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/LdapBackendTest.java
@@ -0,0 +1,41 @@
+/**
+ *  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.identity.backend;
+
+import org.apache.kerby.config.Conf;
+import org.apache.kerby.kerberos.kdc.identitybackend.LdapIdentityBackend;
+import org.junit.Test;
+
+/**
+ * Ldap backend test
+ */
+public class LdapBackendTest extends BackendTest {
+    private IdentityBackend backend;
+
+    public void setup() {
+        Conf config = new Conf();
+        backend = new LdapIdentityBackend(config);
+    }
+
+    @Test
+    public void testGet() {
+        super.testGet(backend);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/58866a42/kdc-backend/zookeeper-backend/pom.xml
----------------------------------------------------------------------
diff --git a/kdc-backend/zookeeper-backend/pom.xml b/kdc-backend/zookeeper-backend/pom.xml
index 3e5373d..aed9fa1 100644
--- a/kdc-backend/zookeeper-backend/pom.xml
+++ b/kdc-backend/zookeeper-backend/pom.xml
@@ -46,5 +46,11 @@
       <artifactId>zookeeper</artifactId>
       <version>${zookeeper.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.kerby</groupId>
+      <artifactId>kerb-identity-test</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/58866a42/kdc-backend/zookeeper-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/ZKConfKey.java
----------------------------------------------------------------------
diff --git a/kdc-backend/zookeeper-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/ZKConfKey.java
b/kdc-backend/zookeeper-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/ZKConfKey.java
index 33e0a2a..a9d798d 100644
--- a/kdc-backend/zookeeper-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/ZKConfKey.java
+++ b/kdc-backend/zookeeper-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/ZKConfKey.java
@@ -26,7 +26,10 @@ import org.apache.kerby.config.ConfigKey;
  */
 public enum ZKConfKey implements ConfigKey {
     ZK_HOST("127.0.0.1"),
-    ZK_PORT(9015);
+    ZK_PORT(9015),
+    DATA_DIR,
+    DATA_LOG_DIR
+    ;
 
     private Object defaultValue;
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/58866a42/kdc-backend/zookeeper-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/ZookeeperIdentityBackend.java
----------------------------------------------------------------------
diff --git a/kdc-backend/zookeeper-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/ZookeeperIdentityBackend.java
b/kdc-backend/zookeeper-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/ZookeeperIdentityBackend.java
index 505f360..a1c795b 100644
--- a/kdc-backend/zookeeper-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/ZookeeperIdentityBackend.java
+++ b/kdc-backend/zookeeper-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/ZookeeperIdentityBackend.java
@@ -29,6 +29,7 @@ import org.apache.zookeeper.server.ServerConfig;
 import org.apache.zookeeper.server.ZooKeeperServerMain;
 import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.List;
 import java.util.Properties;
@@ -44,6 +45,8 @@ public class ZookeeperIdentityBackend extends AbstractIdentityBackend
     private Config config;
     private String zkHost;
     private int zkPort;
+    private File dataDir;
+    private File dataLogDir;
 
     /**
      * Constructing an instance using specified config that contains anything
@@ -58,6 +61,9 @@ public class ZookeeperIdentityBackend extends AbstractIdentityBackend
     private void init() {
         zkHost = config.getString(ZKConfKey.ZK_HOST);
         zkPort = config.getInt(ZKConfKey.ZK_PORT);
+        dataDir = new File(config.getString(ZKConfKey.DATA_DIR));
+        dataLogDir = new File(config.getString(ZKConfKey.DATA_LOG_DIR));
+
         startEmbeddedZookeeper();
         connectZK();
     }
@@ -84,7 +90,11 @@ public class ZookeeperIdentityBackend extends AbstractIdentityBackend
     }
 
     private void startEmbeddedZookeeper() {
+
         Properties startupProperties = new Properties();
+        startupProperties.put("dataDir", dataDir.getAbsolutePath());
+        startupProperties.put("dataLogDir", dataLogDir.getAbsolutePath());
+        startupProperties.put("clientPort", zkPort);
 
         QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
         try {
@@ -102,6 +112,7 @@ public class ZookeeperIdentityBackend extends AbstractIdentityBackend
                 try {
                     zooKeeperServer.runFromConfig(configuration);
                 } catch (IOException e) {
+                    e.printStackTrace();
                     //log.error("ZooKeeper Failed", e);
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/58866a42/kdc-backend/zookeeper-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/ZookeeperBackendTest.java
----------------------------------------------------------------------
diff --git a/kdc-backend/zookeeper-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/ZookeeperBackendTest.java
b/kdc-backend/zookeeper-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/ZookeeperBackendTest.java
new file mode 100644
index 0000000..0c7f231
--- /dev/null
+++ b/kdc-backend/zookeeper-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/ZookeeperBackendTest.java
@@ -0,0 +1,70 @@
+/**
+ *  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.identity.backend;
+
+import org.apache.kerby.config.Conf;
+import org.apache.kerby.kerberos.kdc.identitybackend.ZKConfKey;
+import org.apache.kerby.kerberos.kdc.identitybackend.ZookeeperIdentityBackend;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * Ldap backend test
+ */
+public class ZookeeperBackendTest extends BackendTest {
+    private static IdentityBackend backend;
+
+    @BeforeClass
+    public static void setup() {
+        Conf config = new Conf();
+
+        Properties prop = new Properties();
+        File testdir = new File(System.getProperty("test.dir", "target"));
+        File instanceDir = new File(testdir, "zookeeper");
+        instanceDir.mkdirs();
+        File dataDir = new File(instanceDir, "data");
+        dataDir.mkdirs();
+        prop.put(ZKConfKey.DATA_DIR.getPropertyKey(), dataDir.getAbsolutePath());
+        File dataLogDir = new File(instanceDir, "log");
+        dataLogDir.mkdirs();
+        prop.put(ZKConfKey.DATA_LOG_DIR.getPropertyKey(), dataLogDir.getAbsolutePath());
+
+        config.addPropertiesConfig(prop);
+
+        backend = new ZookeeperIdentityBackend(config);
+        backend.initialize();
+        backend.start();
+    }
+
+    @Test
+    public void testGet() {
+        super.testGet(backend);
+    }
+
+    @AfterClass
+    public static void tearDown() {
+        backend.stop();
+        backend.release();
+    }
+}


Mime
View raw message