directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1005873 - in /directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config: ConfigPartitionReader.java beans/BTreePartitionBean.java beans/JdbmPartitionBean.java
Date Fri, 08 Oct 2010 15:57:42 GMT
Author: elecharny
Date: Fri Oct  8 15:57:41 2010
New Revision: 1005873

URL: http://svn.apache.org/viewvc?rev=1005873&view=rev
Log:
Added the JdbmPartition Bean

Added:
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/BTreePartitionBean.java
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/JdbmPartitionBean.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=1005873&r1=1005872&r2=1005873&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 15:57:41 2010
@@ -60,6 +60,7 @@ import org.apache.directory.server.chang
 import org.apache.directory.server.config.beans.ChangeLogBean;
 import org.apache.directory.server.config.beans.DnsServerBean;
 import org.apache.directory.server.config.beans.JdbmIndexBean;
+import org.apache.directory.server.config.beans.JdbmPartitionBean;
 import org.apache.directory.server.config.beans.JournalBean;
 import org.apache.directory.server.config.beans.KdcServerBean;
 import org.apache.directory.server.config.beans.NtpServerBean;
@@ -1239,41 +1240,71 @@ public class ConfigPartitionReader
         return partitions;
     }
 
-
-    public JdbmPartition createJdbmPartition( Entry partitionEntry ) throws Exception
+    
+    /**
+     * Read the JdbmPartitionBean from the configuration in DIT
+     * 
+     * @param partitionEntry The Entry containing the configuration for this partition
+     * @return An bean containing the JdbmPartition configuration
+     * @throws Exception If the configuration cannot be read
+     */
+    public JdbmPartitionBean readJdbmPartition( Entry partitionEntry ) throws Exception
     {
-        JdbmPartition partition = new JdbmPartition();
-        partition.setSchemaManager( schemaManager );
-
-        partition.setId( getString( ConfigSchemaConstants.ADS_PARTITION_ID, partitionEntry
) );
-        partition.setPartitionDir( new File( workDir, partition.getId() ) );
+        JdbmPartitionBean jdbmPartitionBean = new JdbmPartitionBean();
+        
+        jdbmPartitionBean.setId( getString( ConfigSchemaConstants.ADS_PARTITION_ID, partitionEntry
) );
+        jdbmPartitionBean.setPartitionDir( workDir + File.separator + jdbmPartitionBean.getId()
);
 
         DN systemDn = new DN( getString( ConfigSchemaConstants.ADS_PARTITION_SUFFIX, partitionEntry
), schemaManager );
-        partition.setSuffix( systemDn );
+        jdbmPartitionBean.setSuffix( systemDn );
 
         EntryAttribute cacheAttr = partitionEntry.get( ConfigSchemaConstants.ADS_PARTITION_CACHE_SIZE
);
 
         if ( cacheAttr != null )
         {
-            partition.setCacheSize( Integer.parseInt( cacheAttr.getString() ) );
+            jdbmPartitionBean.setCacheSize( Integer.parseInt( cacheAttr.getString() ) );
         }
 
         EntryAttribute optimizerAttr = partitionEntry.get( ConfigSchemaConstants.ADS_JDBM_PARTITION_OPTIMIZER_ENABLED
);
 
         if ( optimizerAttr != null )
         {
-            partition.setOptimizerEnabled( Boolean.parseBoolean( optimizerAttr.getString()
) );
+            jdbmPartitionBean.setOptimizerEnabled( Boolean.parseBoolean( optimizerAttr.getString()
) );
         }
 
         EntryAttribute syncAttr = partitionEntry.get( ConfigSchemaConstants.ADS_PARTITION_SYNCONWRITE
);
 
         if ( syncAttr != null )
         {
-            partition.setSyncOnWrite( Boolean.parseBoolean( syncAttr.getString() ) );
+            jdbmPartitionBean.setSyncOnWrite( Boolean.parseBoolean( syncAttr.getString()
) );
         }
 
-        Set<Index<?, Entry, Long>> indexedAttributes = createIndexes( partitionEntry.getDn()
);
-        partition.setIndexedAttributes( indexedAttributes );
+        Set<JdbmIndexBean<String, Entry>> indexedAttributes = readIndexes( partitionEntry.getDn()
);
+        jdbmPartitionBean.setIndexedAttributes( indexedAttributes );
+
+        return jdbmPartitionBean;
+    }
+
+    /**
+     * Create a new instance of a JdbmPartition from an instance of JdbmIndexBean
+     * 
+     * @param partitionEntry The entry containing the JdbmPartition configuration
+     * @return An JdbmPartition instance
+     * @throws Exception If the instance cannot be created
+     */
+    public JdbmPartition createJdbmPartition( Entry partitionEntry ) throws Exception
+    {
+        JdbmPartition partition = new JdbmPartition();
+        JdbmPartitionBean jdbmPartitionBean = readJdbmPartition( partitionEntry );
+        
+        partition.setSchemaManager( schemaManager );
+        partition.setCacheSize( jdbmPartitionBean.getCacheSize() );
+        partition.setId( jdbmPartitionBean.getId() );
+        partition.setOptimizerEnabled( jdbmPartitionBean.isOptimizerEnabled() );
+        partition.setPartitionDir( new File( jdbmPartitionBean.getPartitionDir() ) );
+        partition.setSuffix( jdbmPartitionBean.getSuffix() );
+        partition.setSyncOnWrite( jdbmPartitionBean.isSyncOnWrite() );
+        partition.setIndexedAttributes( createIndexes( jdbmPartitionBean.getIndexedAttributes()
) );
 
         return partition;
     }
@@ -1332,6 +1363,19 @@ public class ConfigPartitionReader
     }
 
 
+    private Set<Index<?, Entry, Long>> createIndexes( Set<JdbmIndexBean<String,
Entry>> indexesBean ) throws Exception
+    {
+        Set<Index<?, Entry, Long>> indexes = new HashSet<Index<?, Entry,
Long>>();
+
+        for ( JdbmIndexBean<String, Entry> indexBean : indexesBean )
+        {
+            indexes.add( createJdbmIndex( indexBean ) );
+        }
+
+        return indexes;
+    }
+
+
     /**
      * Read the JdbmIndex from the configuration in DIT
      * 

Added: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/BTreePartitionBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/BTreePartitionBean.java?rev=1005873&view=auto
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/BTreePartitionBean.java
(added)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/BTreePartitionBean.java
Fri Oct  8 15:57:41 2010
@@ -0,0 +1,218 @@
+/*
+ *   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;
+
+import java.util.Set;
+
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.name.DN;
+
+
+/**
+ * A class used to store the BTreePartitooBean configuration.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class BTreePartitionBean
+{
+    /** The partition ID */
+    protected String id;
+    
+    /** The place this partition is stored on disk */
+    protected String PartitionDir;
+
+    /** The root DN for this partition */
+    protected DN suffix;
+    
+    /** The Entry cache size for this partition */
+    protected int cacheSize = -1;
+
+    /** Tells if the optimizer is enabled or not */
+    private boolean optimizerEnabled = true;
+    
+    /** Tells if we should flush data to disk as soon as they are written */
+    private boolean syncOnWrite = true;
+    
+    /** The set of indexed attributes */
+    private Set<JdbmIndexBean<String, Entry>> indexedAttributes;
+
+
+    /**
+     * Create a new BTreePartitionBean instance
+     */
+    public BTreePartitionBean()
+    {
+    }
+
+
+    /**
+     * Gets the unique identifier for this partition.
+     *
+     * @return the unique identifier for this partition
+     */
+    public String getId()
+    {
+        return id;
+    }
+
+
+    /**
+     * Sets the unique identifier for this partition.
+     *
+     * @param id the unique identifier for this partition
+     */
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+    
+    /**
+     * @return the partitionDir
+     */
+    public String getPartitionDir() {
+        return PartitionDir;
+    }
+
+
+    /**
+     * @param partitionDir the partitionDir to set
+     */
+    public void setPartitionDir( String partitionDir ) {
+        PartitionDir = partitionDir;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSuffix( DN suffix ) throws LdapInvalidDnException
+    {
+        this.suffix = suffix;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public DN getSuffix()
+    {
+        return suffix;
+    }
+
+
+    /**
+     * Used to specify the entry cache size for a Partition.  Various Partition
+     * implementations may interpret this value in different ways: i.e. total cache
+     * size limit verses the number of entries to cache.
+     *
+     * @param cacheSize the maximum size of the cache in the number of entries
+     */
+    public void setCacheSize( int cacheSize )
+    {
+        this.cacheSize = cacheSize;
+    }
+
+
+    /**
+     * Gets the entry cache size for this BTreePartition.
+     *
+     * @return the maximum size of the cache as the number of entries maximum before paging
out
+     */
+    public int getCacheSize()
+    {
+        return cacheSize;
+    }
+
+    
+    /**
+     * @return <code>true</code> if the optimizer is enabled
+     */
+    public boolean isOptimizerEnabled()
+    {
+        return optimizerEnabled;
+    }
+
+
+    /**
+     * Enable or disable the optimizer
+     * 
+     * @param optimizerEnabled True or false
+     */
+    public void setOptimizerEnabled( boolean optimizerEnabled )
+    {
+        this.optimizerEnabled = optimizerEnabled;
+    }
+
+
+    /**
+     * @return the syncOnWrite
+     */
+    public boolean isSyncOnWrite() 
+    {
+        return syncOnWrite;
+    }
+
+
+    /**
+     * @param syncOnWrite the syncOnWrite to set
+     */
+    public void setSyncOnWrite( boolean syncOnWrite ) 
+    {
+        this.syncOnWrite = syncOnWrite;
+    }
+    
+    
+    /**
+     * Stores the list of index defined for this partition
+     * 
+     * @param indexedAttributes The list of indexes to store
+     */
+    public void setIndexedAttributes( Set<JdbmIndexBean<String, Entry>> indexedAttributes
)
+    {
+        this.indexedAttributes = indexedAttributes;
+    }
+
+
+    /**
+     * Add some indexes to this partition
+     * 
+     * @param indexes The added indexes
+     */
+    public void addIndexedAttributes( JdbmIndexBean<String, Entry>... indexes )
+    {
+        for ( JdbmIndexBean<String, Entry> index : indexes )
+        {
+            indexedAttributes.add( index );
+        }
+    }
+
+
+    /**
+     * Get the list of index defind for this partition
+     * 
+     * @return The list of defined indexes
+     */
+    public Set<JdbmIndexBean<String, Entry>> getIndexedAttributes()
+    {
+        return indexedAttributes;
+    }
+}

Added: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/JdbmPartitionBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/JdbmPartitionBean.java?rev=1005873&view=auto
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/JdbmPartitionBean.java
(added)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/JdbmPartitionBean.java
Fri Oct  8 15:57:41 2010
@@ -0,0 +1,36 @@
+/*
+ *   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 JdbmIndex configuration.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JdbmPartitionBean extends BTreePartitionBean
+{
+    /**
+     * Create a new JdbmPartitionBean instance
+     */
+    public JdbmPartitionBean()
+    {
+    }
+}



Mime
View raw message