org.apache.directory.server.core.partition.impl.btree
Class BTreePartition

java.lang.Object
  extended by org.apache.directory.server.core.partition.impl.btree.BTreePartition
All Implemented Interfaces:
Partition
Direct Known Subclasses:
JdbmPartition

public abstract class BTreePartition
extends java.lang.Object
implements Partition

An abstract Partition that uses general BTree operations.

Version:
$Rev: 689396 $
Author:
Apache Directory Project
'XBean'

Field Summary
protected  int cacheSize
           
protected  ServerEntry contextEntry
          The rootDSE context
protected  java.lang.String id
           
protected  Optimizer optimizer
           
protected  Registries registries
           
protected  SearchEngine<ServerEntry> searchEngine
          the search engine used to search the database
protected  java.lang.String suffix
           
protected  org.apache.directory.shared.ldap.name.LdapDN suffixDn
           
protected static java.util.Set<java.lang.String> SYS_INDEX_OIDS
           
 
Fields inherited from interface org.apache.directory.server.core.partition.Partition
DEFAULT_CACHE_SIZE, DEFAULT_PARTITION_IMPLEMENTATION, SYSTEM_PARTITION_NAME
 
Constructor Summary
protected BTreePartition()
          Creates a B-tree based context partition.
 
Method Summary
abstract  void add(AddOperationContext opContext)
          Adds an entry to this ContextPartition.
abstract  void addIndexOn(Index<java.lang.Long,ServerEntry> index)
           
abstract  int count()
          Gets the count of the total number of entries in the database.
 void delete(DeleteOperationContext opContext)
          Deletes a leaf entry from this ContextPartition: non-leaf entries cannot be deleted until this operation has been applied to their children.
abstract  void delete(java.lang.Long id)
           
abstract  void destroy()
          Deinitialized this partition.
abstract  Index<java.lang.String,ServerEntry> getAliasIndex()
          Gets the system index defined on the ALIAS_ATTRIBUTE which for LDAP would be the aliasedObjectName and for X.500 would be aliasedEntryName.
 int getCacheSize()
          Gets the entry cache size for this BTreePartition.
abstract  int getChildCount(java.lang.Long id)
           
abstract  java.lang.String getEntryDn(java.lang.Long id)
           
abstract  java.lang.Long getEntryId(java.lang.String dn)
           
abstract  java.lang.String getEntryUpdn(java.lang.Long id)
          Gets the user provided distinguished name.
abstract  java.lang.String getEntryUpdn(java.lang.String dn)
          Gets the user provided distinguished name.
 java.lang.String getId()
          Gets the unique identifier for this partition.
abstract  Index<java.lang.String,ServerEntry> getNdnIndex()
          Gets the Index mapping the normalized distinguished names of entries as Strings to the BigInteger primary keys of entries.
abstract  Index<java.lang.Long,ServerEntry> getOneAliasIndex()
          Gets the alias index mapping parent entries with scope expanding aliases children one level below them; this system index is used to dereference aliases on one/single level scoped searches.
abstract  Index<java.lang.Long,ServerEntry> getOneLevelIndex()
          Gets the Index mapping the Long primary keys of parents to the Long primary keys of their children.
abstract  java.lang.Long getParentId(java.lang.Long childId)
           
abstract  java.lang.Long getParentId(java.lang.String dn)
           
abstract  Index<java.lang.String,ServerEntry> getPresenceIndex()
           
abstract  java.lang.String getProperty(java.lang.String key)
           
 SearchEngine<ServerEntry> getSearchEngine()
          Gets the DefaultSearchEngine used by this ContextPartition to search the Database.
abstract  Index<java.lang.Long,ServerEntry> getSubAliasIndex()
          Gets the alias index mapping relative entries with scope expanding alias descendents; this system index is used to dereference aliases on subtree scoped searches.
abstract  Index<java.lang.Long,ServerEntry> getSubLevelIndex()
          Gets the Index mapping the Long primary keys of ancestors to the Long primary keys of their descendants.
abstract  Index<?,ServerEntry> getSystemIndex(java.lang.String attribute)
           
abstract  java.util.Iterator<java.lang.String> getSystemIndices()
           
abstract  Index<java.lang.String,ServerEntry> getUpdnIndex()
          Gets the Index mapping user provided distinguished names of entries as Strings to the BigInteger primary keys of entries.
abstract  Index<?,ServerEntry> getUserIndex(java.lang.String attribute)
           
abstract  java.util.Iterator<java.lang.String> getUserIndices()
           
 boolean hasEntry(EntryOperationContext opContext)
          Fast operation to check and see if a particular entry exists.
abstract  boolean hasSystemIndexOn(java.lang.String attribute)
           
abstract  boolean hasUserIndexOn(java.lang.String attribute)
           
 void inspect()
           
abstract  boolean isInitialized()
          Checks to see if this partition is initialized or not.
 EntryFilteringCursor list(ListOperationContext opContext)
          A specialized form of one level search used to return a minimal set of information regarding child entries under a base.
abstract  IndexCursor<java.lang.Long,ServerEntry> list(java.lang.Long id)
           
abstract  ClonedServerEntry lookup(java.lang.Long id)
           
 ClonedServerEntry lookup(LookupOperationContext opContext)
          Looks up an entry by distinguished/absolute name.
abstract  void modify(ModifyOperationContext opContext)
          Modifies an entry by adding, removing or replacing a set of attributes.
abstract  void move(MoveOperationContext opContext)
          Transplants a child entry, to a position in the namespace under a new parent entry.
abstract  void moveAndRename(MoveAndRenameOperationContext opContext)
          Transplants a child entry, to a position in the namespace under a new parent entry and changes the RN of the child entry which can optionally have its old RN attributes removed.
abstract  void rename(RenameOperationContext opContext)
          Modifies an entry by changing its relative name.
 EntryFilteringCursor search(SearchOperationContext opContext)
          Conducts a search against this ContextPartition.
abstract  void setAliasIndexOn(Index<java.lang.String,ServerEntry> index)
          Sets the system index defined on the ALIAS_ATTRIBUTE which for LDAP would be the aliasedObjectName and for X.500 would be aliasedEntryName.
 void setCacheSize(int cacheSize)
          Used to specify the entry cache size for a Partition.
 void setId(java.lang.String id)
          Sets the unique identifier for this partition.
abstract  void setNdnIndexOn(Index<java.lang.String,ServerEntry> index)
          Sets the normalized distinguished name Index.
abstract  void setOneAliasIndexOn(Index<java.lang.Long,ServerEntry> index)
          Sets the alias index mapping parent entries with scope expanding aliases children one level below them; this system index is used to dereference aliases on one/single level scoped searches.
abstract  void setOneLevelIndexOn(Index<java.lang.Long,ServerEntry> index)
          Sets the one level Index.
abstract  void setPresenceIndexOn(Index<java.lang.String,ServerEntry> index)
          Sets the attribute existance Index.
abstract  void setProperty(java.lang.String key, java.lang.String value)
           
abstract  void setRegistries(Registries registries)
          Allows for schema entity registries to be swapped out during runtime.
abstract  void setSubAliasIndexOn(Index<java.lang.Long,ServerEntry> index)
          Sets the alias index mapping relative entries with scope expanding alias descendents; this system index is used to dereference aliases on subtree scoped searches.
abstract  void setUpdnIndexOn(Index<java.lang.String,ServerEntry> index)
          Sets the user provided distinguished name Index.
abstract  void sync()
          Flushes any changes made to this partition now.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.directory.server.core.partition.Partition
bind, getSuffix, getSuffixDn, getUpSuffixDn, init, setSuffix, unbind
 

Field Detail

SYS_INDEX_OIDS

protected static final java.util.Set<java.lang.String> SYS_INDEX_OIDS

searchEngine

protected SearchEngine<ServerEntry> searchEngine
the search engine used to search the database


optimizer

protected Optimizer optimizer

registries

protected Registries registries

id

protected java.lang.String id

cacheSize

protected int cacheSize

suffixDn

protected org.apache.directory.shared.ldap.name.LdapDN suffixDn

suffix

protected java.lang.String suffix

contextEntry

protected ServerEntry contextEntry
The rootDSE context

Constructor Detail

BTreePartition

protected BTreePartition()
Creates a B-tree based context partition.

Method Detail

setCacheSize

public void setCacheSize(int cacheSize)
Used to specify the entry cache size for a Partition. Various Partition implementations may interpret this value in different ways: i.e. total cache size limit verses the number of entries to cache.

Specified by:
setCacheSize in interface Partition
Parameters:
cacheSize - the maximum size of the cache in the number of entries

getCacheSize

public int getCacheSize()
Gets the entry cache size for this BTreePartition.

Specified by:
getCacheSize in interface Partition
Returns:
the maximum size of the cache as the number of entries maximum before paging out

getId

public java.lang.String getId()
Gets the unique identifier for this partition.

Specified by:
getId in interface Partition
Returns:
the unique identifier for this partition

setId

public void setId(java.lang.String id)
Sets the unique identifier for this partition.

Specified by:
setId in interface Partition
Parameters:
id - the unique identifier for this partition

setRegistries

public abstract void setRegistries(Registries registries)
                            throws java.lang.Exception
Allows for schema entity registries to be swapped out during runtime. This is primarily here to facilitate the swap out of a temporary bootstrap registry. Registry changes require swapping out the search engine used by a partition since the registries are used by elements in the search engine.

Parameters:
registries - the schema entity registries
Throws:
java.lang.Exception

getSearchEngine

public SearchEngine<ServerEntry> getSearchEngine()
Gets the DefaultSearchEngine used by this ContextPartition to search the Database.

Returns:
the search engine

delete

public void delete(DeleteOperationContext opContext)
            throws java.lang.Exception
Description copied from interface: Partition
Deletes a leaf entry from this ContextPartition: non-leaf entries cannot be deleted until this operation has been applied to their children.

Specified by:
delete in interface Partition
Parameters:
opContext - the context of the entry to delete from this ContextPartition.
Throws:
java.lang.Exception - if there are any problems

add

public abstract void add(AddOperationContext opContext)
                  throws java.lang.Exception
Description copied from interface: Partition
Adds an entry to this ContextPartition.

Specified by:
add in interface Partition
Parameters:
opContext - the context used to add and entry to this ContextPartition
Throws:
java.lang.Exception - if there are any problems

modify

public abstract void modify(ModifyOperationContext opContext)
                     throws java.lang.Exception
Description copied from interface: Partition
Modifies an entry by adding, removing or replacing a set of attributes.

Specified by:
modify in interface Partition
Parameters:
opContext - The contetx containin the modification operation to perform on the entry which is one of constants specified by the DirContext interface: ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE.
Throws:
java.lang.Exception - if there are any problems
See Also:
DirContext, DirContext.ADD_ATTRIBUTE, DirContext.REMOVE_ATTRIBUTE, DirContext.REPLACE_ATTRIBUTE

list

public EntryFilteringCursor list(ListOperationContext opContext)
                          throws java.lang.Exception
Description copied from interface: Partition
A specialized form of one level search used to return a minimal set of information regarding child entries under a base. Convenience method used to optimize operations rather than conducting a full search with retrieval.

Specified by:
list in interface Partition
Parameters:
opContext - the context containing the distinguished/absolute name for the search/listing
Returns:
a NamingEnumeration containing objects of type ServerSearchResult
Throws:
java.lang.Exception - if there are any problems

search

public EntryFilteringCursor search(SearchOperationContext opContext)
                            throws java.lang.Exception
Description copied from interface: Partition
Conducts a search against this ContextPartition. Namespace specific parameters for search are contained within the environment using namespace specific keys into the hash. For example in the LDAP namespace a ContextPartition implementation may look for search Controls using a namespace specific or implementation specific key for the set of LDAP Controls.

Specified by:
search in interface Partition
Parameters:
opContext - The context containing the information used by the operation
Returns:
a NamingEnumeration containing objects of type
Throws:
java.lang.Exception - if there are any problems

lookup

public ClonedServerEntry lookup(LookupOperationContext opContext)
                         throws java.lang.Exception
Description copied from interface: Partition
Looks up an entry by distinguished/absolute name. This is a simplified version of the search operation used to point read an entry used for convenience. Depending on the context parameters, we my look for a simple entry, or for a restricted set of attributes for this entry

Specified by:
lookup in interface Partition
Parameters:
opContext - The context containing the parameters
Returns:
an Attributes object representing the entry
Throws:
java.lang.Exception - if there are any problems

hasEntry

public boolean hasEntry(EntryOperationContext opContext)
                 throws java.lang.Exception
Description copied from interface: Partition
Fast operation to check and see if a particular entry exists.

Specified by:
hasEntry in interface Partition
Parameters:
opContext - The context used to pass informations
Returns:
true if the entry exists, false if it does not
Throws:
java.lang.Exception - if there are any problems

rename

public abstract void rename(RenameOperationContext opContext)
                     throws java.lang.Exception
Description copied from interface: Partition
Modifies an entry by changing its relative name. Optionally attributes associated with the old relative name can be removed from the entry. This makes sense only in certain namespaces like LDAP and will be ignored if it is irrelavent.

Specified by:
rename in interface Partition
Parameters:
opContext - the modify DN context
Throws:
java.lang.Exception - if there are any problems

move

public abstract void move(MoveOperationContext opContext)
                   throws java.lang.Exception
Description copied from interface: Partition
Transplants a child entry, to a position in the namespace under a new parent entry.

Specified by:
move in interface Partition
Parameters:
opContext - The context containing the DNs to move
Throws:
java.lang.Exception - if there are any problems

moveAndRename

public abstract void moveAndRename(MoveAndRenameOperationContext opContext)
                            throws java.lang.Exception
Description copied from interface: Partition
Transplants a child entry, to a position in the namespace under a new parent entry and changes the RN of the child entry which can optionally have its old RN attributes removed. The removal of old RN attributes may not make sense in all namespaces. If the concept is undefined in a namespace this parameters is ignored. An example of a namespace where this parameter is significant is the LDAP namespace.

Specified by:
moveAndRename in interface Partition
Parameters:
opContext - The context contain all the information about the modifyDN operation
Throws:
java.lang.Exception - if there are any problems

sync

public abstract void sync()
                   throws java.lang.Exception
Description copied from interface: Partition
Flushes any changes made to this partition now.

Specified by:
sync in interface Partition
Throws:
java.lang.Exception - if buffers cannot be flushed to disk

destroy

public abstract void destroy()
                      throws java.lang.Exception
Description copied from interface: Partition
Deinitialized this partition.

Specified by:
destroy in interface Partition
Throws:
java.lang.Exception

isInitialized

public abstract boolean isInitialized()
Description copied from interface: Partition
Checks to see if this partition is initialized or not.

Specified by:
isInitialized in interface Partition
Returns:
true if the partition is initialized, false otherwise

inspect

public void inspect()
             throws java.lang.Exception
Throws:
java.lang.Exception

addIndexOn

public abstract void addIndexOn(Index<java.lang.Long,ServerEntry> index)
                         throws java.lang.Exception
Throws:
java.lang.Exception

hasUserIndexOn

public abstract boolean hasUserIndexOn(java.lang.String attribute)
                                throws java.lang.Exception
Throws:
java.lang.Exception

hasSystemIndexOn

public abstract boolean hasSystemIndexOn(java.lang.String attribute)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

getPresenceIndex

public abstract Index<java.lang.String,ServerEntry> getPresenceIndex()

getOneLevelIndex

public abstract Index<java.lang.Long,ServerEntry> getOneLevelIndex()
Gets the Index mapping the Long primary keys of parents to the Long primary keys of their children.

Returns:
the one level Index

getSubLevelIndex

public abstract Index<java.lang.Long,ServerEntry> getSubLevelIndex()
Gets the Index mapping the Long primary keys of ancestors to the Long primary keys of their descendants.

Returns:
the sub tree level Index

getUpdnIndex

public abstract Index<java.lang.String,ServerEntry> getUpdnIndex()
Gets the Index mapping user provided distinguished names of entries as Strings to the BigInteger primary keys of entries.

Returns:
the user provided distinguished name Index

getNdnIndex

public abstract Index<java.lang.String,ServerEntry> getNdnIndex()
Gets the Index mapping the normalized distinguished names of entries as Strings to the BigInteger primary keys of entries.

Returns:
the normalized distinguished name Index

getOneAliasIndex

public abstract Index<java.lang.Long,ServerEntry> getOneAliasIndex()
Gets the alias index mapping parent entries with scope expanding aliases children one level below them; this system index is used to dereference aliases on one/single level scoped searches.

Returns:
the one alias index

getSubAliasIndex

public abstract Index<java.lang.Long,ServerEntry> getSubAliasIndex()
Gets the alias index mapping relative entries with scope expanding alias descendents; this system index is used to dereference aliases on subtree scoped searches.

Returns:
the sub alias index

getAliasIndex

public abstract Index<java.lang.String,ServerEntry> getAliasIndex()
Gets the system index defined on the ALIAS_ATTRIBUTE which for LDAP would be the aliasedObjectName and for X.500 would be aliasedEntryName.

Returns:
the index on the ALIAS_ATTRIBUTE

setAliasIndexOn

public abstract void setAliasIndexOn(Index<java.lang.String,ServerEntry> index)
                              throws java.lang.Exception
Sets the system index defined on the ALIAS_ATTRIBUTE which for LDAP would be the aliasedObjectName and for X.500 would be aliasedEntryName.

Parameters:
index - the index on the ALIAS_ATTRIBUTE
Throws:
java.lang.Exception - if there is a problem setting up the index

setPresenceIndexOn

public abstract void setPresenceIndexOn(Index<java.lang.String,ServerEntry> index)
                                 throws java.lang.Exception
Sets the attribute existance Index.

Parameters:
index - the attribute existance Index
Throws:
java.lang.Exception - if there is a problem setting up the index

setOneLevelIndexOn

public abstract void setOneLevelIndexOn(Index<java.lang.Long,ServerEntry> index)
                                 throws java.lang.Exception
Sets the one level Index.

Parameters:
index - the one level Index
Throws:
java.lang.Exception - if there is a problem setting up the index

setUpdnIndexOn

public abstract void setUpdnIndexOn(Index<java.lang.String,ServerEntry> index)
                             throws java.lang.Exception
Sets the user provided distinguished name Index.

Parameters:
index - the updn Index
Throws:
java.lang.Exception - if there is a problem setting up the index

setNdnIndexOn

public abstract void setNdnIndexOn(Index<java.lang.String,ServerEntry> index)
                            throws java.lang.Exception
Sets the normalized distinguished name Index.

Parameters:
index - the ndn Index
Throws:
java.lang.Exception - if there is a problem setting up the index

setOneAliasIndexOn

public abstract void setOneAliasIndexOn(Index<java.lang.Long,ServerEntry> index)
                                 throws java.lang.Exception
Sets the alias index mapping parent entries with scope expanding aliases children one level below them; this system index is used to dereference aliases on one/single level scoped searches.

Parameters:
index - a one level alias index
Throws:
java.lang.Exception - if there is a problem setting up the index

setSubAliasIndexOn

public abstract void setSubAliasIndexOn(Index<java.lang.Long,ServerEntry> index)
                                 throws java.lang.Exception
Sets the alias index mapping relative entries with scope expanding alias descendents; this system index is used to dereference aliases on subtree scoped searches.

Parameters:
index - a subtree alias index
Throws:
java.lang.Exception - if there is a problem setting up the index

getUserIndex

public abstract Index<?,ServerEntry> getUserIndex(java.lang.String attribute)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

getSystemIndex

public abstract Index<?,ServerEntry> getSystemIndex(java.lang.String attribute)
                                             throws java.lang.Exception
Throws:
java.lang.Exception

getEntryId

public abstract java.lang.Long getEntryId(java.lang.String dn)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

getEntryDn

public abstract java.lang.String getEntryDn(java.lang.Long id)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

getParentId

public abstract java.lang.Long getParentId(java.lang.String dn)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

getParentId

public abstract java.lang.Long getParentId(java.lang.Long childId)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

getEntryUpdn

public abstract java.lang.String getEntryUpdn(java.lang.Long id)
                                       throws java.lang.Exception
Gets the user provided distinguished name.

Parameters:
id - the entry id
Returns:
the user provided distinguished name
Throws:
java.lang.Exception - if the updn index cannot be accessed

getEntryUpdn

public abstract java.lang.String getEntryUpdn(java.lang.String dn)
                                       throws java.lang.Exception
Gets the user provided distinguished name.

Parameters:
dn - the normalized distinguished name
Returns:
the user provided distinguished name
Throws:
java.lang.Exception - if the updn and ndn indices cannot be accessed

lookup

public abstract ClonedServerEntry lookup(java.lang.Long id)
                                  throws java.lang.Exception
Specified by:
lookup in interface Partition
Throws:
java.lang.Exception

delete

public abstract void delete(java.lang.Long id)
                     throws java.lang.Exception
Throws:
java.lang.Exception

list

public abstract IndexCursor<java.lang.Long,ServerEntry> list(java.lang.Long id)
                                                      throws java.lang.Exception
Throws:
java.lang.Exception

getChildCount

public abstract int getChildCount(java.lang.Long id)
                           throws java.lang.Exception
Throws:
java.lang.Exception

setProperty

public abstract void setProperty(java.lang.String key,
                                 java.lang.String value)
                          throws java.lang.Exception
Throws:
java.lang.Exception

getProperty

public abstract java.lang.String getProperty(java.lang.String key)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

getUserIndices

public abstract java.util.Iterator<java.lang.String> getUserIndices()

getSystemIndices

public abstract java.util.Iterator<java.lang.String> getSystemIndices()

count

public abstract int count()
                   throws java.lang.Exception
Gets the count of the total number of entries in the database. TODO shouldn't this be a BigInteger instead of an int?

Returns:
the number of entries in the database
Throws:
java.lang.Exception - if there is a failure to read the count


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.