You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/12/08 08:15:15 UTC

svn commit: r111233 - /incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/EveContextFactory.java /incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java /incubator/directory/eve/trunk/xdocs/partitions.xml

Author: akarasulu
Date: Tue Dec  7 23:15:14 2004
New Revision: 111233

URL: http://svn.apache.org/viewcvs?view=rev&rev=111233
Log:
Changes ...

 o added the ability to put suffix attributes into the env Hashtable as 
   javax.naming.directory.Attributes values and have it get picked up
 o added more documentation explaining these mechanisms 
 o rearranged partition doc a little bit
 o integrated the configuration builder and the use of the config bean into
   the EveContextFactory -  makes things a little bit cleaner and easier to
   comprehend


Modified:
   incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/EveContextFactory.java
   incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java
   incubator/directory/eve/trunk/xdocs/partitions.xml

Modified: incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/EveContextFactory.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/EveContextFactory.java?view=diff&rev=111233&p1=incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/EveContextFactory.java&r1=111232&p2=incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/EveContextFactory.java&r2=111233
==============================================================================
--- incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/EveContextFactory.java	(original)
+++ incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/EveContextFactory.java	Tue Dec  7 23:15:14 2004
@@ -48,8 +48,8 @@
 import org.apache.eve.RootNexus;
 import org.apache.eve.SystemPartition;
 import org.apache.eve.ApplicationPartition;
+import org.apache.eve.ContextPartitionConfig;
 import org.apache.eve.protocol.LdapProtocolProvider;
-import org.apache.eve.exception.EveNamingException;
 import org.apache.eve.exception.EveConfigurationException;
 import org.apache.eve.jndi.ibs.*;
 import org.apache.eve.db.*;
@@ -109,7 +109,6 @@
     };
 
 
-
     // ------------------------------------------------------------------------
     // Members
     // ------------------------------------------------------------------------
@@ -597,25 +596,25 @@
         MatchingRuleRegistry reg = globalRegistries.getMatchingRuleRegistry();
 
         // start getting all the parameters from the initial environment
-        String[] names = ( ( String ) initialEnv.get( EnvKeys.PARTITIONS ) ).split( " " );
+        ContextPartitionConfig[] configs = null;
+        configs = PartitionConfigBuilder.getContextPartitionConfigs( initialEnv );
 
-        for ( int ii = 0; ii < names.length; ii++ )
+        for ( int ii = 0; ii < configs.length; ii++ )
         {
             // ----------------------------------------------------------------
             // create working directory under eve directory for app partition
             // ----------------------------------------------------------------
 
-            String suffix = ( String ) initialEnv.get( EnvKeys.SUFFIX + names[ii] );
-            String wkdir = eveWkdir + File.separator + names[ii];
-            mkdirs( eveWkdir, names[ii] );
+            String wkdir = eveWkdir + File.separator + configs[ii].getId();
+            mkdirs( eveWkdir, configs[ii].getId() );
 
             // ----------------------------------------------------------------
             // create the database/store
             // ----------------------------------------------------------------
 
-            Name upSuffix = new LdapName( suffix );
+            Name upSuffix = new LdapName( configs[ii].getSuffix() );
             Normalizer dnNorm = reg.lookup( "distinguishedNameMatch" ).getNormalizer();
-            Name normSuffix = new LdapName( ( String ) dnNorm.normalize( suffix ) );
+            Name normSuffix = new LdapName( ( String ) dnNorm.normalize( configs[ii].getSuffix() ) );
             Database db = new JdbmDatabase( upSuffix, wkdir );
 
             // ----------------------------------------------------------------
@@ -645,19 +644,13 @@
             // if user indices are specified add those attribute types as well
             // ----------------------------------------------------------------
 
-            if ( initialEnv.containsKey( EnvKeys.INDICES + names[ii] ) )
+            for ( int jj = 0; jj < configs[ii].getIndices().length; jj++ )
             {
-                String[] indices = ( ( String ) initialEnv.get( EnvKeys.INDICES
-                        + names[ii] ) ).split( " " );
-
-                for ( int jj = 0; jj < indices.length; jj++ )
-                {
-                    attributeTypeList.add( attributeTypeRegistry.lookup( indices[jj] ) );
-                }
+                attributeTypeList.add( attributeTypeRegistry.lookup( configs[ii].getIndices()[jj] ) );
             }
 
             // ----------------------------------------------------------------
-            // fire up the appPartition & register it with the next
+            // fire up the appPartition & register it with the nexus
             // ----------------------------------------------------------------
 
             AttributeType[] indexTypes = ( AttributeType[] ) attributeTypeList
@@ -670,27 +663,7 @@
             // add the nexus context entry
             // ----------------------------------------------------------------
 
-            Attributes rootAttrs;
-            Object rootEntry = initialEnv.get( EnvKeys.ATTRIBUTES + names[ii] );
-
-            if ( rootEntry instanceof String )
-            {
-                rootAttrs = new LockableAttributesImpl();
-                String ldif = ( ( String ) rootEntry ).trim().replace( '*', '\n' );
-                ( new LdifParserImpl() ).parse( rootAttrs, ldif );
-            }
-            else if ( rootEntry instanceof Attributes )
-            {
-                rootAttrs = ( Attributes ) rootEntry;
-            }
-            else
-            {
-                throw new EveNamingException( "The root entry env property was"
-                        + " not of an expected type: " + rootEntry,
-                        ResultCodeEnum.OTHER );
-            }
-
-            partition.add( suffix, normSuffix, rootAttrs );
+            partition.add( configs[ii].getSuffix(), normSuffix, configs[ii].getAttributes() );
         }
     }
 

Modified: incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java?view=diff&rev=111233&p1=incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java&r1=111232&p2=incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java&r2=111233
==============================================================================
--- incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java	(original)
+++ incubator/directory/eve/trunk/dib/src/java/org/apache/eve/jndi/PartitionConfigBuilder.java	Tue Dec  7 23:15:14 2004
@@ -21,6 +21,7 @@
 import java.util.Enumeration;
 
 import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
 
 import org.apache.eve.ContextPartitionConfig;
 import org.apache.ldap.common.message.LockableAttributesImpl;
@@ -98,9 +99,28 @@
         // --------------------------------------------------------------------
 
         buf.setLength( 0 );
-        buf.append( EnvKeys.ATTRIBUTES ).append( id ).append( "." );
+        buf.append( EnvKeys.ATTRIBUTES ).append( id );
 
+        /*
+         * before going on to extract attributes check to see if the
+         * attributes base plus id has an Attributes object set.  Users
+         * can programatically use Attributes objects rather than
+         * wrestle with individual key value pairs.
+         */
         String keyBase = buf.toString();
+        if ( env.containsKey( keyBase ) )
+        {
+            config.setAttributes( ( Attributes ) env.get( keyBase ) );
+            return config;
+        }
+
+        /*
+         * looks like the environment attributes were not set programatically
+         * with an Attributes object for the base.  So we now add the extra
+         * '.' and go on to try and detect all the keys and their attributes.
+         */
+        buf.append( "." );
+        keyBase = buf.toString();
         for ( Enumeration list = env.keys(); list.hasMoreElements(); )
         {
             String attrKey = ( String ) list.nextElement();

Modified: incubator/directory/eve/trunk/xdocs/partitions.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/xdocs/partitions.xml?view=diff&rev=111233&p1=incubator/directory/eve/trunk/xdocs/partitions.xml&r1=111232&p2=incubator/directory/eve/trunk/xdocs/partitions.xml&r2=111233
==============================================================================
--- incubator/directory/eve/trunk/xdocs/partitions.xml	(original)
+++ incubator/directory/eve/trunk/xdocs/partitions.xml	Tue Dec  7 23:15:14 2004
@@ -63,24 +63,39 @@
         </p>
       </subsection>
 
-      <subsection name="User/Application Partitions">
+      <subsection name="User Partitions">
         <p>
           User partitions are partitions added by users.  When you download and
           start using Eve you may want to create a separate partition to store
-          the entries of your application.  To us user and application partition
-          means the same thing: not the system partition!
+          the entries of your application.  To us user (sometimes also referred
+          to as application) partitions are those that are not the system
+          partition!  In the following section we describe how a user partition
+          can be created in Eve.
         </p>
+      </subsection>
+    </section>
 
-        <p>
-          Adding new application partitions to the server is a matter of
-          setting the right JNDI environment properties.  These properties are
-          used in both standalone and in embedded configurations.  Below is an
-          example of a properties configuration for two partitions hanging off
-          of the naming contexts <code>dc=apache,dc=org</code> and
-          <code>ou=test</code>:
+    <section name="Adding User Partitions">
+      <p>
+        Adding new application partitions to the server is a matter of
+        setting the right JNDI environment properties.  These properties are
+        used in both standalone and in embedded configurations.  We will show
+        you how to configure partitions by example using properties files and
+        programatically.
+      </p>
+
+      <subsection name="Using Properties Files">
+        <p>
+          Obviously properties files are not the best way to configure a large
+          system like an LDAP server.  However properties files are the JNDI
+          standard for pulling in configuration.  Eve as a JNDI provider tries
+          to honor this.  Hence the use of a properties file for configuration.
+          Below we have the configuration of two user defined partitions within
+          a properties file.  These partitions are for the naming contexts:
+          <code>dc=apache,dc=org</code> and <code>ou=test</code>.
         </p>
 
-        <source>
+    <source>
 # all multivalued properties are space separated like the list of partions here
 eve.db.partitions=apache test
 
@@ -95,38 +110,42 @@
 eve.db.partition.indices.test=ou objectClass
 eve.db.partition.attributes.test.ou=test
 eve.db.partition.attributes.test.objectClass=top organizationalUnit extensibleObject
-        </source>
+    </source>
 
         <p>
           Although somewhat ugly the way we use properties for settings does
-          work and hopefully we can build a tool on top of this to save the
+          work.  Hopefully we can build a tool on top of this to save the
           user some hassle.  Another approach may be to use XML or something
           easier to generate these properties from them.  For now its the best
-          non-specific means we have to inject settings through JNDI env
+          non-specific means we have to inject settings through JNDI environment
           Hashtables while still being able to load settings via properties
-          files.  Ultimately JNDI properties are the common denominator.
+          files.  Properties from proerties files are the common denominator
+          though.  Another means is however possible programatically.
         </p>
-
+        <br></br>
+        <h4>Partition Id</h4>
         <p>
-          Breifly we'll explain these properties.  All partition properties
-          are associated with one another using some partition id.  All
-          partition ids are listed as a space separated list using the <b>
-          eve.db.partitions</b> property: above it lists the ids for the too
+          Breifly we'll explain these properties and the scheme used.  A
+          partition's property set is associated as a set using the partition's
+          id.  All partition ids are listed as a space separated list using the
+          <b>eve.db.partitions</b> property: above it lists the ids for the two
           partitions, <i>apache</i> and <i>test</i>.
         </p>
-
+        <br></br>
+        <h4>Naming Context</h4>
         <p>
           Partitions need to know the naming context they will store entries
           for.  This naming context is also referred to as the suffix since all
-          entries in the partition have this common suffix.  You guessed it,
-          the suffix is a distinguished name.  The property key for the suffix
-          of a partition is composed of the following property key base
+          entries in the partition have this common suffix.  The suffix is a
+          distinguished name.  The property key for the suffix of a partition is
+          composed of the following property key base
           <b>eve.db.partition.suffix.</b> concatenated with the id of the
           partition: <b>eve.db.partition.suffix.</b><i>${id}</i>.  For example
           if the partition id is foo, then the suffix key would be,
           <b>eve.db.partition.suffix.foo</b>.
-         </p>
-
+        </p>
+        <br></br>
+        <h4>User Defined Indices</h4>
         <p>
           Partitions can have indices on attributes.  Unlike OpenLDAP where you
           can build specific types of indices, Eve indices are of a single type.
@@ -138,7 +157,8 @@
           partition has indices built on top of <b>ou</b>, <b>objectClass</b>
           and <b>uid</b>.
         </p>
-
+        <br></br>
+        <h4>Suffix Entry</h4>
         <p>
           When creating a context the root entry of the context corresponding
           to the suffix of the partition must be created.  This entry is
@@ -155,7 +175,65 @@
         </p>
       </subsection>
 
-      <subsection name="Future Progress">
+      <subsection name="Programaticly">
+        <p>
+          This is simple create a Hashtable and stuff it with those properties.
+          But that's a real pain.  The other option is to set all the properties
+          that way minus the one for the suffix entries attributes.  We have
+          a shortcut where you can set an Attributes object within the Hashtable
+          and it will get picked up instead of using the standard property
+          scheme above.
+        </p>
+
+        <p>
+          Simply put the Attributes into the Hashtable using the following
+          key <b>eve.db.partition.attributes.</b><i>${id}</i>.  Below we show
+          how this can be done for the same example above:
+        </p>
+
+<souce>
+BasicAttributes attrs = new BasicAttributes( true );
+BasicAttribute attr = new BasicAttribute( "objectClass" );
+attr.add( "top" );
+attr.add( "organizationalUnit" );
+attr.add( "extensibleObject" );
+attrs.put( attr );
+attr = new BasicAttribute( "ou" );
+attr.add( "testing" );
+attrs.put( attr );
+
+extras.put( EnvKeys.PARTITIONS, "testing example" );
+extras.put( EnvKeys.SUFFIX + "testing", "ou=testing" );
+extras.put( EnvKeys.INDICES + "testing", "ou objectClass" );
+extras.put( EnvKeys.ATTRIBUTES + "testing", attrs );
+
+attrs = new BasicAttributes( true );
+attr = new BasicAttribute( "objectClass" );
+attr.add( "top" );
+attr.add( "domain" );
+attr.add( "extensibleObject" );
+attrs.put( attr );
+attr = new BasicAttribute( "dc" );
+attr.add( "example" );
+attrs.put( attr );
+
+extras.put( EnvKeys.SUFFIX + "example", "dc=example" );
+extras.put( EnvKeys.INDICES + "example", "ou dc objectClass" );
+extras.put( EnvKeys.ATTRIBUTES + "example", attrs );
+</souce>
+
+        <p>
+          Ok that does not look any shorter.  We'll add to this in the future.
+          Perhaps we enable the use of configuration beans that can be used
+          with an SPI specific to Eve.  However this starts making your code
+          Eve specific.  You can just change properties and use the SUN provider
+          anymore to have your code be location independent.
+        </p>
+      </subsection>
+    </section>
+
+    <section name="Future Progress">
+      <subsection name="Partition Nesting">
         <p>
           Today we have some limitations to the way we can partition the DIB.
           Namely we can't have a partition within a partition and sometimes this
@@ -166,24 +244,73 @@
           "http://nagoya.apache.org/jira/browse/DIREVE-23">JIRA improvement</a>
           specifically aimed at achieving this goal.
         </p>
+      </subsection>
 
+      <subsection name="Partition Variety">
         <p>
           Obviously we want as many different kinds of partitions as possible.
-          Ones using RDBMS' and ones using LDAP servers are welcome as well
-          so we can serve their content as well in one unified view.
-        </p>
+          Some really cool ideas have floated around out there for a while.
+          Here's a list of theoretically possible partition types that might
+          be useful or just cool:
+        </p>
+
+        <ul>
+          <li>
+            Partitions that use JDBC to store entries.  These would probably
+            be way too slow.  However they might be useful if some mapping
+            were to be used to represent an existing application's database
+            schema as an LDAP DIT.  This would allow us to expose any database
+            data via LDAP.
+          </li>
+
+          <li>
+            Partitions using other LDAP servers to store their entries.  Why
+            do this when introducing latency.  Perhaps you want to proxy other
+            servers or make other servers behave like Eve.
+          </li>
+
+          <li>
+            A partition that serves out the Windows registry via LDAP.  A
+            standard mechanism to map the Windows registry to an LDAP DIT is
+            pretty simple.  This would be a neat way to expose client machine
+            registry management.
+          </li>
+
+          <li>
+            A partition based on SleepyCat's JE.  I was going to try this
+            and see how it performs against JDBM.
+          </li>
+
+          <li>
+            A partition based on an in-memory BTree implementation.  This would
+            be fast and really cool for storing things like schema info.  It
+            would also be cool for staging data between memory and disk.
+          </li>
+
+          <li>
+            A partition based on Prevalyer.  This is like an in-memory partition
+            but you can save it at the end of the day.  This might be really
+            useful especially for things the system partition which almost
+            always need to be in memory.  The system partition can do this by
+            using really large caches equal to the number of entries in the
+            system partition.
+          </li>
+        </ul>
+      </subsection>
 
+      <subsection name="Partitioning entries under a single context?">
         <p>
           Other aspirations include entry partitioning within a container
           context.  Imagine having 250 million entries under
           <code>ou=citizens,dc=census,dc=gov</code>.  You don't want all 250
           million in one partition but would like to sub partition these entries
           under the same context based on some attribute.  Basically we will be
-          using the attribute value to implement sub partitioning where within
-          a single context we are partitioning entries.
+          using the attribute's value to implement sub partitioning where within
+          a single context we are partitioning entries.  The value is used to
+          hash entries across buckets (the buckets are other partitions).  Yeah
+          this is a bit wild but it would be useful in several situations.
         </p>
       </subsection>
-
     </section>
   </body>
 </document>