Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 32781 invoked from network); 19 Apr 2007 08:07:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Apr 2007 08:07:48 -0000 Received: (qmail 25955 invoked by uid 500); 19 Apr 2007 08:07:54 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 25926 invoked by uid 500); 19 Apr 2007 08:07:54 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Delivered-To: moderator for dev@directory.apache.org Received: (qmail 21424 invoked by uid 99); 19 Apr 2007 08:02:30 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of SRS0=Q6iK=JW=apache.org=seelmann@srs.kundenserver.de designates 212.227.126.186 as permitted sender) Message-ID: <462721F2.6000007@apache.org> Date: Thu, 19 Apr 2007 10:01:54 +0200 From: Stefan Seelmann User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Apache Directory Developers List Subject: Re: [DAS] Unique IDs for Model Instances (Was Initial Context?) References: <4626FBB7.7000405@gmail.com> In-Reply-To: <4626FBB7.7000405@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX1+c5zgiUvI/zB+CGDN8/mRBlsTZ/Zwc+1dImvU xZZXJ4JMRjbZ0ShgizZsIb0AWE3WvuMqIsiiO/KiTwlA49Mbx9 B/DaJxPXZWBjXcSLRNWSkhJohwvmfnX4fwK5SdHg0o= X-Virus-Checked: Checked by ClamAV on apache.org Hi Ole, Ole Ersoy wrote: > Here's what I'm thinking the process is: > > For each model instance we generate a surrogate key. > > We do that by getting the total number of children that > the context cn=accounts, cn=users, cn=example, ou=com > has, and then add 1. So if there are 14 children, the > new child gets a surrogate key assigned to it which is > 15. > > Then we write the surrogate key, along with a descriptive human > readable/identifiable string (Like "Alex Karasulu") taken from one of > the root object's attributes a file designated > by the DAS's configuration. This is so that if the server > crashes (Hardware - never ADS), we'll know because we did > not write a completion flag into the file, and next time we run > the DAS it can recover. > > Then we create the subcontext like this (dirContext is > cn=accounts, cn=users, cn=example, ou=com): > > dirContext.createSubcontext("cn=15", attributes); > The are some (LDAP-related) problems with this approach: - This operation isn't atomic. There is some time between you calculate the key and the real write operation. If there are many concurrent threads writing model instances you will get an NameAlreadyBoundException. Then you have to try again. I think with random keys there are less collisions. - There is no count(*) in LDAP. So to determine the number of children you have to retrieve all children and count them within the DAS. Imagine you have thousands or millions of children all of the DNs must be transfered over the wire. This can take some time and will slow down the system and doesn't scale well. Regards, Stefan