By sin on Jul 02, 2007
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_dn2iddc=example,dc=com
bash-2.03$ java com.sleepycat.je.util.DbDump -h ../db -p -s dc_example_dc_com_id2entry
Opends Uses a 8-byte AtomicLong to create
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
You can find more information onSleepycat andOpends integration in this presentation