directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Directory Server v1.5 > 1.4.3 Adding your own partition resp. suffix
Date Wed, 28 Oct 2009 20:43:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=DIRxSRVx11&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/DIRxSRVx11/1.4.3+Adding+your+own+partition+resp.+suffix">1.4.3
Adding your own partition resp. suffix</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~seelmann">Stefan
Seelmann</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <style type='text/css'>/*<![CDATA[*/
table.ScrollbarTable  {border: none;padding: 3px;width: 100%;padding: 3px;margin: 0px;background-color:
#f0f0f0}
table.ScrollbarTable td.ScrollbarPrevIcon {text-align: center;width: 16px;border: none;}
table.ScrollbarTable td.ScrollbarPrevName {text-align: left;border: none;}
table.ScrollbarTable td.ScrollbarParent {text-align: center;border: none;}
table.ScrollbarTable td.ScrollbarNextName {text-align: right;border: none;}
table.ScrollbarTable td.ScrollbarNextIcon {text-align: center;width: 16px;border: none;}

/*]]>*/</style><div class="Scrollbar"><table class='ScrollbarTable'><tr><td
class='ScrollbarPrevIcon'><a href="/confluence/display/DIRxSRVx11/1.4.2+Changing+the+admin+password"><img
border='0' align='middle' src='/confluence/images/icons/back_16.gif' width='16' height='16'></a></td><td
width='33%' class='ScrollbarPrevName'><a href="/confluence/display/DIRxSRVx11/1.4.2+Changing+the+admin+password">1.4.2
Changing the admin password</a>&nbsp;</td><td width='33%' class='ScrollbarParent'><sup><a
href="/confluence/display/DIRxSRVx11/1.4.+Basic+configuration+tasks"><img border='0'
align='middle' src='/confluence/images/icons/up_16.gif' width='8' height='8'></a></sup><a
href="/confluence/display/DIRxSRVx11/1.4.+Basic+configuration+tasks">1.4. Basic configuration
tasks</a></td><td width='33%' class='ScrollbarNextName'>&nbsp;<a
href="/confluence/display/DIRxSRVx11/1.4.5+Configure+logging">1.4.5 Configure logging</a></td><td
class='ScrollbarNextIcon'><a href="/confluence/display/DIRxSRVx11/1.4.5+Configure+logging"><img
border='0' align='middle' src='/confluence/images/icons/forwd_16.gif' width='16' height='16'></a></td></tr></table></div>

<h1><a name="1.4.3Addingyourownpartitionresp.suffix-Addingyourownpartitionresp.suffix"></a>Adding
your own partition resp. suffix</h1>

<p>This section describes how to add your own data partition.</p>
<div>
<ul>
    <li><a href='#1.4.3Addingyourownpartitionresp.suffix-Whatarepartitions%3F'>What
are partitions?</a></li>
    <li><a href='#1.4.3Addingyourownpartitionresp.suffix-Minimalpartitiondefinition'>Minimal
partition definition</a></li>
    <li><a href='#1.4.3Addingyourownpartitionresp.suffix-Addingapartitionprogrammatically'>Adding
a partition programmatically</a></li>
    <li><a href='#1.4.3Addingyourownpartitionresp.suffix-MoreconfigurationoptionsforaJDBMpartition'>More
configuration options for a JDBM partition</a></li>
</ul></div>

<h2><a name="1.4.3Addingyourownpartitionresp.suffix-Whatarepartitions%3F"></a>What
are partitions?</h2>

<p>In ApacheDS entries are stored in partitions.  Each partition contains a complete
entry tree, also referred to as a DIT. Multiple partitions may exist and the entry trees they
contain are disconnected from each other, meaning that changes to entries in partition <em>A</em>
would never affect entries in partition <em>B</em>. The entries in a particular
partition are stored below some naming context called the partition suffix.</p>

<p>The default implementation of partitions is based on <a href="http://jdbm.sourceforge.net/"
title="jdbm.sourceforge.net" rel="nofollow">JDBM</a> B+Trees (but it's possible to
add custom partition implementations). The ApacheDS default configuration contains a a data
partition with the suffix "dc=example,dc=com". The image below shows the suffixes of a freshly
installed ApacheDS within Apache Directory Studio.</p>

<p><img src="/confluence/download/attachments/55548/partitions_in_studio_after_install.png"
align="absmiddle" border="0" /></p>

<p>The schema subsystem and ApacheDS itself store their information in special partitions,
"ou=schema" and "ou=system" respectively.</p>

<h2><a name="1.4.3Addingyourownpartitionresp.suffix-Minimalpartitiondefinition"></a>Minimal
partition definition</h2>

<p>For the examples in the following sections, we want to add a partition with the suffix
"o=sevenSeas". This requires editing of the <em>server.xml</em> file, and injecting
a first entry, associated with the root of this partition (here, "o=sevenseas") .</p>

<p>Open the <em>server.xml</em> file for your directory instance in your
favorite editor and look for the following element with name partitions.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
...
 <span class="code-tag">&lt;partitions&gt;</span>
  ...
  &lt;jdbmPartition id=<span class="code-quote">"example"</span> cacheSize=<span
class="code-quote">"100"</span> suffix=<span class="code-quote">"dc=example,dc=com"</span>
optimizerEnabled=<span class="code-quote">"true"</span>
                 syncOnWrite=<span class="code-quote">"true"</span>&gt;
    <span class="code-tag">&lt;indexedAttributes&gt;</span>
    ...
    <span class="code-tag">&lt;/indexedAttributes&gt;</span>
  <span class="code-tag">&lt;/jdbmPartition&gt;</span>
 <span class="code-tag">&lt;/partitions&gt;</span>
...
</pre>
</div></div>
<p>Add another jdbmPartition element for the sevenSeas partition, just below the example
partition:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
...
<span class="code-tag">&lt;partitions&gt;</span>

 <span class="code-tag">&lt;jdbmPartition ...&gt;</span>
   ...
 <span class="code-tag">&lt;/jdbmPartition&gt;</span>

 <span class="code-tag">&lt;jdbmPartition id=<span class="code-quote">"sevenSeas"</span>
suffix=<span class="code-quote">"o=sevenSeas"</span> /&gt;</span>

<span class="code-tag">&lt;/partitions&gt;</span>
...
</pre>
</div></div>
<p>Save the <em>server.xml</em> file and restart the server. The server
has a new suffix now, but no context entry has been created for it. If you connect with an
LDAP Browser (Apache Directory Studio for instance), the partition is only visible in the
Root DSE. Below the Entry Editor of Directory Studio for the Root DSE after connecting to
an ApacheDS instance configured like above.</p>

<p><img src="/confluence/download/attachments/55548/root_dse.png" align="absmiddle"
border="0" /></p>

<p>Before using the partition (e.g. adding entries), you have to add a context entry.
If you plan to load LDIF data to your partition anyway, simply provide the context entry (the
"root" of your partition) as a first data set. In our example it might look like this:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
dn: o=sevenSeas
o: sevenSeas
objectClass: top
objectClass: organization
description: The context entry <span class="code-keyword">for</span> suffix o=sevenSeas
</pre>
</div></div>
<p>It is also possible to import a file to ApacheDS which only contains such an entry,
of cause. Here is an example on how to procede for the seven seas :</p>

<p>In the LDAP Browser of Directory Studio, right click on the DIT entry and select
"Import &#45;&gt; LDIF Import...". A file selections dialog appears. Browse to the
LDIF file and click Finish. The entry (or entries, if you provide more of them) will be added
to to partition.</p>

<p>The following image depicts the partitions after reconnecting with Apache Directory
Studio (<em>LDAP Browser</em> view).</p>

<p><img src="/confluence/download/attachments/55548/partitions_in_studio_after_adding.png"
align="absmiddle" border="0" /></p>

<h3><a name="1.4.3Addingyourownpartitionresp.suffix-Laodingthecontextentryautomaticallyonstartup"></a>Laoding
the context entry automatically on startup</h3>

<p>If you don't want to launch Apache Studio, or to inject the LDIF file using a command
line tool, you can also tells the server to load the file when it will be laucnhed the first
time. Just create a ldif file containing the context entry, and add some tag into the <em>server.xml</em>
file. For instance, you have created the <b>sevenSeasRoot.ldif</b> file containing</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
# SevenSeas root context entry
dn: o=sevenSeas
o: sevenSeas
objectClass: top
objectClass: organization
description: The context entry <span class="code-keyword">for</span> suffix o=sevenSeas
</pre>
</div></div>
<p>Now just modify the <em>server.xml</em> file to add this line :</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
...
  &lt;apacheDS id=<span class="code-quote">"apacheDS"</span>
            synchPeriodMillis=<span class="code-quote">"15000"</span>
            allowAnonymousAccess=<span class="code-quote">"<span class="code-keyword">false</span>"</span>&gt;

    &lt;directoryService&gt;#directoryService&lt;/directoryService&gt;

    &lt;!-- We load the SevenSeas root context entry here --&gt;
    &lt;ldifDirectory&gt;sevenSeasRoot.ldif&lt;/ldifDirectory&gt;
    ...
</pre>
</div></div>
<p>The contextEntry will be loaded when the server will be started the first time.</p>

<h2><a name="1.4.3Addingyourownpartitionresp.suffix-Addingapartitionprogrammatically"></a>Adding
a partition programmatically</h2>

<p> The same o=sevenseas partition can be created through the application code using
the Partition and DirectoryService API</p>

<p> Here is the sample code to create a new partition o=sevenseas and its context entry
programmatically</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
JdbmPartition sevenseasPartition = <span class="code-keyword">new</span> JdbmPartition();
sevenseasPartition.setId(<span class="code-quote">"sevenseas"</span>);
sevenseasPartition.setSuffix(<span class="code-quote">"o=sevenseas"</span>);
sevenseasPartition.setCacheSize(1000);
sevenseasPartition.init(directoryService);

<span class="code-comment">// Create some indices (optional)
</span>Set&lt;Index&lt;?,ServerEntry&gt;&gt; indexedAttrs = <span
class="code-keyword">new</span> HashSet&lt;Index&lt;?, ServerEntry&gt;&gt;();
indexedAttrs.add( <span class="code-keyword">new</span> JdbmIndex&lt;<span
class="code-object">Object</span>, ServerEntry&gt;(<span class="code-quote">"objectClass"</span>));
indexedAttrs.add( <span class="code-keyword">new</span> JdbmIndex&lt;<span
class="code-object">Object</span>, ServerEntry&gt;(<span class="code-quote">"o"</span>));
sevenseasPartition.setIndexedAttributes( indexedAttrs );

<span class="code-comment">//Add partition to the directory service
</span>directoryService.addPartition(sevenseasPartition);

<span class="code-comment">// start the directory service
</span>directoryService.startup();

<span class="code-comment">// create the context entry
</span>ServerEntry entry = <span class="code-keyword">new</span> DefaultServerEntry(
directoryService.getRegistries(), <span class="code-keyword">new</span> LdapDN(
<span class="code-quote">"o=sevenseas"</span>) );
entry.put( <span class="code-quote">"objectClass"</span>,  <span class="code-quote">"top"</span>,
<span class="code-quote">"organization"</span> );
entry.put(<span class="code-quote">"o"</span>,<span class="code-quote">"sevenseas"</span>);

<span class="code-comment">// add the context entry
</span>AddContextPartitionOperationContext adOpContext = <span class="code-keyword">new</span>
AddContextPartitionOperationContext( directoryService.getAdminSession(), sevenseasPartition
);
adOpContext.add( entry, <span class="code-keyword">null</span> );
directoryService.getPartitionNexus().addContextPartition( adOpContext );
</pre>
</div></div>

<h2><a name="1.4.3Addingyourownpartitionresp.suffix-MoreconfigurationoptionsforaJDBMpartition"></a>More
configuration options for a JDBM partition</h2>

<p>Here is a list of the used attributes, their default values and meaning</p>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> id </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> (required) uniquely identifies the partition </td>
</tr>
<tr>
<td class='confluenceTd'> suffix </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> (required) an LDAP DN ("dc=example, dc=com", for instance)
</td>
</tr>
<tr>
<td class='confluenceTd'> cacheSize </td>
<td class='confluenceTd'> &#45;1 </td>
<td class='confluenceTd'> cache size expressed as a number of entries </td>
</tr>
<tr>
<td class='confluenceTd'> optimizerEnabled </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> syncOnWrite </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> sync disks on every write operation </td>
</tr>
</tbody></table>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/DIRxSRVx11/1.4.3+Adding+your+own+partition+resp.+suffix">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=55548&revisedVersion=10&originalVersion=9">View
Change</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message