directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1005677 - in /directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config: ConfigPartitionReader.java beans/JdbmIndexBean.java
Date Fri, 08 Oct 2010 00:17:11 GMT
Author: elecharny
Date: Fri Oct  8 00:17:11 2010
New Revision: 1005677

URL: http://svn.apache.org/viewvc?rev=1005677&view=rev
Log:
Added the JdbmIndex bean

Added:
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/JdbmIndexBean.java
Modified:
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java

Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=1005677&r1=1005676&r2=1005677&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
(original)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
Fri Oct  8 00:17:11 2010
@@ -58,6 +58,7 @@ import javax.naming.directory.SearchCont
 
 import org.apache.directory.server.changepw.ChangePasswordServer;
 import org.apache.directory.server.config.beans.ChangeLogBean;
+import org.apache.directory.server.config.beans.JdbmIndexBean;
 import org.apache.directory.server.config.beans.JournalBean;
 import org.apache.directory.server.config.beans.KdcServerBean;
 import org.apache.directory.server.config.beans.NtpServerBean;
@@ -1279,9 +1280,16 @@ public class ConfigPartitionReader
     }
 
 
-    public JdbmIndex<?, Entry> createJdbmIndex( Entry indexEntry ) throws Exception
+    /**
+     * Read the JdbmIndex from the configuration in DIT
+     * 
+     * @param indexEntry The Entry containing the configuration for this index
+     * @return An bean containing the JdbmEntry configuration
+     * @throws Exception If the configuration cannot be read
+     */
+    public JdbmIndexBean<String, Entry> readJdbmIndex( Entry indexEntry ) throws Exception
     {
-        JdbmIndex<String, Entry> index = new JdbmIndex<String, Entry>();
+        JdbmIndexBean<String, Entry> index = new JdbmIndexBean<String, Entry>();
         index.setAttributeId( getString( ConfigSchemaConstants.ADS_INDEX_ATTRIBUTE_ID, indexEntry
) );
         EntryAttribute cacheAttr = indexEntry.get( ConfigSchemaConstants.ADS_INDEX_CACHESIZE
);
 
@@ -1300,6 +1308,27 @@ public class ConfigPartitionReader
         return index;
     }
 
+
+    /**
+     * Create a new instance of a JdbmIndex from the configuration read from the DIT
+     * 
+     * @param indexEntry The entry contianing the JdbmIndex configuration
+     * @return An JdbmIndex instance
+     * @throws Exception If the instance cannot be created
+     */
+    public JdbmIndex<?, Entry> createJdbmIndex( Entry indexEntry ) throws Exception
+    {
+        JdbmIndex<String, Entry> index = new JdbmIndex<String, Entry>();
+        JdbmIndexBean<String, Entry> indexBean = readJdbmIndex( indexEntry );
+        
+        index.setAttributeId( indexBean.getAttributeId() );
+        index.setCacheSize( indexBean.getCacheSize() );
+        index.setNumDupLimit( indexBean.getNumDupLimit() );
+        
+
+        return index;
+    }
+
     private TransportBean[] readTransports( DN adsServerDN ) throws Exception
     {
         AttributeType adsTransportIdAt = schemaManager.getAttributeType( ConfigSchemaConstants.ADS_TRANSPORT_ID
);

Added: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/JdbmIndexBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/JdbmIndexBean.java?rev=1005677&view=auto
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/JdbmIndexBean.java
(added)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/JdbmIndexBean.java
Fri Oct  8 00:17:11 2010
@@ -0,0 +1,125 @@
+/*
+ *   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.directory.server.config.beans;
+
+
+/**
+ * A class used to store the NtpServer configuration.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JdbmIndexBean<K, E>
+{
+    private int DEFAULT_INDEX_CACHE_SIZE = 100;
+    
+    /** default duplicate limit before duplicate keys switch to using a btree for values
*/
+    public static final int DEFAULT_DUPLICATE_LIMIT = 512;
+
+    /**
+     * the attribute identifier set at configuration time for this index which may not
+     * be the OID but an alias name for the attributeType associated with this Index
+     */
+    private String attributeId;
+
+    /** the size (number of index entries) for the cache */
+    private int cacheSize = DEFAULT_INDEX_CACHE_SIZE;
+
+    /**
+     * duplicate limit before duplicate keys switch to using a btree for values
+     */
+    protected int numDupLimit = DEFAULT_DUPLICATE_LIMIT;
+
+    /**
+     * Create a new NtpServerBean instance
+     */
+    public JdbmIndexBean()
+    {
+    }
+
+
+    /**
+     * Gets the attribute identifier set at configuration time for this index which may not
+     * be the OID but an alias name for the attributeType associated with this Index
+     *
+     * @return configured attribute oid or alias name
+     */
+    public String getAttributeId()
+    {
+        return attributeId;
+    }
+
+
+    /**
+     * Sets the attribute identifier set at configuration time for this index which may not
+     * be the OID but an alias name for the attributeType associated with this Index
+     *
+     * @param attributeId configured attribute oid or alias name
+     */
+    public void setAttributeId( String attributeId )
+    {
+        this.attributeId = attributeId;
+    }
+
+
+    /**
+     * Gets the size of the index cache in terms of the number of index entries to be cached.
+     *
+     * @return the size of the index cache
+     */
+    public int getCacheSize()
+    {
+        return cacheSize;
+    }
+
+
+    /**
+     * Sets the size of the index cache in terms of the number of index entries to be cached.
+     *
+     * @param cacheSize the size of the index cache
+     */
+    public void setCacheSize( int cacheSize )
+    {
+        this.cacheSize = cacheSize;
+    }
+
+
+    /**
+     * Gets the threshold at which point duplicate keys use btree indirection to store
+     * their values.
+     *
+     * @return the threshold for storing a keys values in another btree
+     */
+    public int getNumDupLimit()
+    {
+        return numDupLimit;
+    }
+
+
+    /**
+     * Sets the threshold at which point duplicate keys use btree indirection to store
+     * their values.
+     *
+     * @param numDupLimit the threshold for storing a keys values in another btree
+     */
+    public void setNumDupLimit( int numDupLimit )
+    {
+        this.numDupLimit = numDupLimit;
+    }
+}



Mime
View raw message