Monday Jul 02, 2007

Implementing Opends Back-end using Sleepycat

Like Previous versions of directory servers, opends backend is built upon sleepycat database. However, unlike previous versions, the sleepycat database is purely Java-based. Sleepycat db provides the Database class which appears like a HashMap where both the keys and the values are represented using the DatabaseEntry objects. An Environment encompasses the databases and it's the unit for cache and transactions among the databases.

Fig. A Database has keys and values. A DatabaseEntry object represents both key and value. You may want to note that a DatbaseEntry object takes only the byte array.

 

 

 

 

 

 

 

  The three main classes of the Opends backend are:

  RootContainer - Represents a backend id. It encapsulates the JE Environment class.

  EntryContainer - Represents a base DN for the RootContainer.

  DatabaseContainer - Represents a particular database.

 As evident from the description, RootContainer contains 1..n EntryContainer objects.

  

  Opends creates a number of databases related to the actual data and the necessary indexes. DBDump utility from Sleepycat can be used to dump the content of a database. For ex,

  bash-2.03$ java com.sleepycat.je.util.DbDump -h ../db -p -s dc_example_dc_com_dn2id

 dc=example,dc=com
 \\00\\00\\00\\00\\00\\00\\00\\01
 cn=user#0,dc=example,dc=com
 \\00\\00\\00\\00\\00\\00\\00\\02
 cn=user#10,dc=example,dc=com

 

 bash-2.03$ java com.sleepycat.je.util.DbDump -h ../db -p -s dc_example_dc_com_id2entry

 \\00\\00\\00\\00\\00\\00\\00\\01
 \\01`h\\02\\01\\00\\04c\\01\\11dc=example,dc=com\\12organizationalUnit\\01ou\\00\\01\\06people\\01entryUUID\\00\\01$54c89c45-327b-3d38-8a2e-b7814de651a4
 \\00\\00\\00\\00\\00\\00\\00\\02
 \\01`x\\02\\01\\00\\04s\\01\\1bcn=user#0,dc=example,dc=com\\0dinetorgperson\\02sn\\00\\01\\06commoncn\\00\\01\\06user#0\\01entryUUID\\00\\01$f1ae0607-4fcf-3878-813b-fff5cc871b37

 Opends Uses a 8-byte AtomicLong to create the entryId.

 An algorithm for the LDAP ADD operation ( Small details ignored)

 Connection Handler and then LDAPRequest Handler thread receives the request from the Client.
 The Add request is passed on to the pool of worker threads
 A worker thread performs the following operations in sequence ( some operations are omitted):
 Grab a READ Lock on the parent entry to ensure that the parent entry doesn't undergo any changes which this operation is in progress.
 Grab a WRITE Lock on the entry to be created.
 Search for the entry in the backend to make sure that it doesn't exist.
 Get the Backend instance for that entry dn. It is found by searching into the TreeMap maintained by the DirectoryServer class.
 Find the EntryContainer associated with the entry DN.
 Create a new Java DB Transaction Object
 Open dn2id database and verify that the key with the dn doesn't exist already.
 Read the EntryID of the parent from dn2id database.
 Get a new EntryID from the RootContainer for the new Entry.
 Insert the new Entry into dn2id database.
 Insert into Id2Entry database.
 Insert into Indexes
 Insert into id2children and id2subtree databases
 Commit/Rollback the transacation
 Return

 

You can find more information onSleepycat andOpends integration in this presentation
About

This is the blog of a software engineer, specialized in identity management. Kunal Sinha works in Directory Services Engineering (OpenDS) team from Austin,Texas.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks