org.apache.directory.server.core.partition.impl.btree
Class AbstractBTreePartition<ID extends Comparable<ID>>

java.lang.Object
  extended by org.apache.directory.server.core.api.partition.AbstractPartition
      extended by org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition<ID>
All Implemented Interfaces:
org.apache.directory.server.core.api.partition.Partition, Store<org.apache.directory.shared.ldap.model.entry.Entry,ID>
Direct Known Subclasses:
AvlPartition

public abstract class AbstractBTreePartition<ID extends Comparable<ID>>
extends org.apache.directory.server.core.api.partition.AbstractPartition
implements Store<org.apache.directory.shared.ldap.model.entry.Entry,ID>

An abstract Partition that uses general BTree operations.

Author:
Apache Directory Project

Field Summary
protected  org.apache.directory.shared.ldap.model.schema.AttributeType ALIASED_OBJECT_NAME_AT
           
protected  Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> aliasIdx
          a system index on aliasedObjectName attribute
protected  int cacheSize
          The Entry cache size for this partition
static int DEFAULT_CACHE_SIZE
          The default cache size is set to 10 000 objects
protected  org.apache.directory.shared.ldap.model.schema.AttributeType ENTRY_CSN_AT
           
protected  org.apache.directory.shared.ldap.model.schema.AttributeType ENTRY_UUID_AT
           
protected  Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> entryCsnIdx
          a system index on entryCSN attribute
protected  Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> entryUuidIdx
          a system index on entryUUID attribute
protected  AtomicBoolean isSyncOnWrite
          true if we sync disks on every write operation
protected  MasterTable<ID,org.apache.directory.shared.ldap.model.entry.Entry> master
          the master table storing entries by primary key
protected  org.apache.directory.shared.ldap.model.schema.AttributeType OBJECT_CLASS_AT
          Cached attributes types to avoid lookup all over the code
protected  Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> objectClassIdx
          a system index on objectClass attribute
protected  Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> oneAliasIdx
          the one level scope alias index
protected  Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> oneLevelIdx
          the parent child relationship index
protected  Optimizer optimizer
          The optimizer to use during search operation
protected  boolean optimizerEnabled
          Tells if the Optimizer is enabled
protected  URI partitionPath
          The path in which this Partition stores files
protected  Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> presenceIdx
          the attribute presence index
protected  Index<ParentIdAndRdn<ID>,org.apache.directory.shared.ldap.model.entry.Entry,ID> rdnIdx
          the relative distinguished name index
protected  SearchEngine<org.apache.directory.shared.ldap.model.entry.Entry,ID> searchEngine
          the search engine used to search the database
protected  Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> subAliasIdx
          the subtree scope alias index
protected  Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> subLevelIdx
          a system index on the entries of descendants of root Dn
protected  Map<String,Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID>> systemIndices
          a map of attributeType numeric ID to system userIndices
protected  Map<String,Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID>> userIndices
          a map of attributeType numeric ID to user userIndices
 
Fields inherited from class org.apache.directory.server.core.api.partition.AbstractPartition
id, initialized, schemaManager, suffixDn
 
Fields inherited from interface org.apache.directory.server.xdbm.Store
SYS_INDEX_OID_ARRAY, SYS_INDEX_OIDS
 
Constructor Summary
protected AbstractBTreePartition(org.apache.directory.shared.ldap.model.schema.SchemaManager schemaManager)
          Creates a B-tree based context partition.
 
Method Summary
 void add(org.apache.directory.server.core.api.interceptor.context.AddOperationContext addContext)
          
protected  void addAliasIndices(ID aliasId, org.apache.directory.shared.ldap.model.name.Dn aliasDn, String aliasTarget)
          Adds userIndices for an aliasEntry to be added to the database while checking for constrained alias constructs like alias cycles and chaining.
 void addIndex(Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> index)
          Adds a (system or user) index to the list of index for this store.
 void addIndexedAttributes(Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID>... indexes)
          Add some new indexes
protected  org.apache.directory.shared.ldap.model.name.Dn buildEntryDn(ID id)
          builds the Dn of the entry identified by the given id
protected abstract  Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> convertAndInit(Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> index)
          Convert and initialize an index for a specific store implementation.
 int count()
          Gets the total count of entries within this store.
 void delete(org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext deleteContext)
          
 void delete(ID id)
          Delete the entry associated with a given Id
protected  void doDestroy()
          
protected  void doInit()
          
protected  void dropAliasIndices(ID aliasId)
          Removes the index entries for an alias before the entry is deleted from the master table.
protected  void dropAliasIndices(ID aliasId, org.apache.directory.shared.ldap.model.name.Dn movedBase)
          For the alias id all ancestor one and subtree alias tuples are moved above the moved base.
protected  void dropMovedAliasIndices(org.apache.directory.shared.ldap.model.name.Dn movedBase)
          For all aliases including and under the moved base, this method removes one and subtree alias index tuples for old ancestors above the moved base that will no longer be ancestors after the move.
 void dumpIndex(OutputStream stream, String name)
          
 Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> getAliasIndex()
          
 int getCacheSize()
          Gets the entry cache size for this BTreePartition.
 int getChildCount(ID id)
          Gets the count of immediate children of the given entry ID.
abstract  ID getDefaultId()
          Gets the default ID.
 Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> getEntryCsnIndex()
          
 org.apache.directory.shared.ldap.model.name.Dn getEntryDn(ID id)
          Gets the Entry's Dn identified by the given id.
 ID getEntryId(org.apache.directory.shared.ldap.model.name.Dn dn)
          Gets the entry's id.
 Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> getEntryUuidIndex()
          
 Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> getIndex(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
          Get the user or system index associated with the given attributeType
 Set<Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID>> getIndexedAttributes()
           
 Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> getObjectClassIndex()
          
 Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> getOneAliasIndex()
          
 Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> getOneLevelIndex()
          
 ID getParentId(ID childId)
          Gets the ID of an entry's parent using the child entry's ID.
 URI getPartitionPath()
          Gets the path in which this Partition stores data.
 Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> getPresenceIndex()
          
 Index<ParentIdAndRdn<ID>,org.apache.directory.shared.ldap.model.entry.Entry,ID> getRdnIndex()
          
abstract  ID getRootId()
          Gets the root ID of this store implementation.
 SearchEngine<org.apache.directory.shared.ldap.model.entry.Entry,ID> getSearchEngine()
          Gets the DefaultSearchEngine used by this ContextPartition to search the Database.
 Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> getSubAliasIndex()
          
 Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> getSubLevelIndex()
          
protected  ID getSuffixId()
          Retrieve the SuffixID
 Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> getSystemIndex(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
          Get the system index associated with the given name
 Iterator<String> getSystemIndices()
          An iterator build on top of the System's index
 Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> getUserIndex(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
          Get the user index associated with the given name
 Iterator<String> getUserIndices()
          An iterator build on top of the User's index
 boolean hasEntry(org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext entryContext)
          This method calls Partition.lookup(LookupOperationContext) and return true if it returns an entry by default.
 boolean hasIndexOn(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
          Tells if an index is already present in the User's or System's index list
 boolean hasSystemIndexOn(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
          Tells if an index is already present in the System's index list
 boolean hasUserIndexOn(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
          Tells if an index is already present in the User's index list
 boolean isOptimizerEnabled()
          Tells if the Optimizer is enabled or not
 boolean isSyncOnWrite()
          
 IndexCursor<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> list(ID id)
          Gets an IndexEntry Cursor over the child nodes of an entry.
 org.apache.directory.server.core.api.filtering.EntryFilteringCursor list(org.apache.directory.server.core.api.interceptor.context.ListOperationContext listContext)
          
 org.apache.directory.shared.ldap.model.entry.Entry lookup(ID id)
          Get back an entry knowing its ID
 org.apache.directory.shared.ldap.model.entry.Entry lookup(org.apache.directory.server.core.api.interceptor.context.LookupOperationContext lookupContext)
          
 org.apache.directory.shared.ldap.model.entry.Entry modify(org.apache.directory.shared.ldap.model.name.Dn dn, org.apache.directory.shared.ldap.model.entry.Modification... mods)
          Modify an entry applying the given list of modifications.
 void modify(org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext modifyContext)
          
 void move(org.apache.directory.shared.ldap.model.name.Dn oldDn, org.apache.directory.shared.ldap.model.name.Dn newSuperiorDn, org.apache.directory.shared.ldap.model.name.Dn newDn, org.apache.directory.shared.ldap.model.entry.Entry modifiedEntry)
          Move an entry from one place to the other.
 void move(org.apache.directory.server.core.api.interceptor.context.MoveOperationContext moveContext)
          
 void moveAndRename(org.apache.directory.shared.ldap.model.name.Dn oldDn, org.apache.directory.shared.ldap.model.name.Dn newSuperiorDn, org.apache.directory.shared.ldap.model.name.Rdn newRdn, org.apache.directory.shared.ldap.model.entry.Entry modifiedEntry, boolean deleteOldRdn)
          
 void moveAndRename(org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext moveAndRenameContext)
          
 void rename(org.apache.directory.shared.ldap.model.name.Dn dn, org.apache.directory.shared.ldap.model.name.Rdn newRdn, boolean deleteOldRdn, org.apache.directory.shared.ldap.model.entry.Entry entry)
          Changes the relative distinguished name of an entry specified by a distinguished name with the optional removal of the old Rdn attribute value from the entry.
 void rename(org.apache.directory.server.core.api.interceptor.context.RenameOperationContext renameContext)
          
 org.apache.directory.server.core.api.filtering.EntryFilteringCursor search(org.apache.directory.server.core.api.interceptor.context.SearchOperationContext searchContext)
          
 void setCacheSize(int cacheSize)
          Used to specify the entry cache size for a Partition.
 void setIndexedAttributes(Set<Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID>> indexedAttributes)
          Set the list of indexes for this partition
 void setOptimizerEnabled(boolean optimizerEnabled)
          Set the optimizer flag
 void setPartitionPath(URI partitionPath)
          Sets the path in which this Partition stores data.
 void setSyncOnWrite(boolean isSyncOnWrite)
          Sets the flag telling the server to flush on disk when some modification has been done.
protected  void setupSystemIndices()
          Sets up the system indices.
protected  void setupUserIndices()
          Sets up the user indices.
 String toString()
          
 void unbind(org.apache.directory.server.core.api.interceptor.context.UnbindOperationContext unbindContext)
          
 
Methods inherited from class org.apache.directory.server.core.api.partition.AbstractPartition
checkInitialized, destroy, getId, getSchemaManager, getSuffixDn, initialize, isInitialized, setId, setSchemaManager, setSuffixDn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.directory.server.core.api.partition.Partition
sync
 

Field Detail

searchEngine

protected SearchEngine<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> searchEngine
the search engine used to search the database


optimizer

protected Optimizer optimizer
The optimizer to use during search operation


optimizerEnabled

protected boolean optimizerEnabled
Tells if the Optimizer is enabled


DEFAULT_CACHE_SIZE

public static final int DEFAULT_CACHE_SIZE
The default cache size is set to 10 000 objects

See Also:
Constant Field Values

cacheSize

protected int cacheSize
The Entry cache size for this partition


isSyncOnWrite

protected AtomicBoolean isSyncOnWrite
true if we sync disks on every write operation


partitionPath

protected URI partitionPath
The path in which this Partition stores files


master

protected MasterTable<ID extends Comparable<ID>,org.apache.directory.shared.ldap.model.entry.Entry> master
the master table storing entries by primary key


userIndices

protected Map<String,Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>> userIndices
a map of attributeType numeric ID to user userIndices


systemIndices

protected Map<String,Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>> systemIndices
a map of attributeType numeric ID to system userIndices


rdnIdx

protected Index<ParentIdAndRdn<ID extends Comparable<ID>>,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> rdnIdx
the relative distinguished name index


objectClassIdx

protected Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> objectClassIdx
a system index on objectClass attribute


oneLevelIdx

protected Index<ID extends Comparable<ID>,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> oneLevelIdx
the parent child relationship index


subLevelIdx

protected Index<ID extends Comparable<ID>,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> subLevelIdx
a system index on the entries of descendants of root Dn


presenceIdx

protected Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> presenceIdx
the attribute presence index


entryUuidIdx

protected Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> entryUuidIdx
a system index on entryUUID attribute


entryCsnIdx

protected Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> entryCsnIdx
a system index on entryCSN attribute


aliasIdx

protected Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> aliasIdx
a system index on aliasedObjectName attribute


subAliasIdx

protected Index<ID extends Comparable<ID>,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> subAliasIdx
the subtree scope alias index


oneAliasIdx

protected Index<ID extends Comparable<ID>,org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>> oneAliasIdx
the one level scope alias index


OBJECT_CLASS_AT

protected org.apache.directory.shared.ldap.model.schema.AttributeType OBJECT_CLASS_AT
Cached attributes types to avoid lookup all over the code


ENTRY_CSN_AT

protected org.apache.directory.shared.ldap.model.schema.AttributeType ENTRY_CSN_AT

ENTRY_UUID_AT

protected org.apache.directory.shared.ldap.model.schema.AttributeType ENTRY_UUID_AT

ALIASED_OBJECT_NAME_AT

protected org.apache.directory.shared.ldap.model.schema.AttributeType ALIASED_OBJECT_NAME_AT
Constructor Detail

AbstractBTreePartition

protected AbstractBTreePartition(org.apache.directory.shared.ldap.model.schema.SchemaManager schemaManager)
Creates a B-tree based context partition.

Method Detail

getCacheSize

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

Specified by:
getCacheSize in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
the maximum size of the cache as the number of entries maximum before paging out

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 Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
cacheSize - the maximum size of the cache in the number of entries

isOptimizerEnabled

public boolean isOptimizerEnabled()
Tells if the Optimizer is enabled or not

Returns:
true if the optimizer is enabled

setOptimizerEnabled

public void setOptimizerEnabled(boolean optimizerEnabled)
Set the optimizer flag

Parameters:
optimizerEnabled - The flag

setPartitionPath

public void setPartitionPath(URI partitionPath)
Sets the path in which this Partition stores data. This may be an URL to a file or directory, or an JDBC URL.

Specified by:
setPartitionPath in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
partitionDir - the path in which this Partition stores data.

isSyncOnWrite

public boolean isSyncOnWrite()

Specified by:
isSyncOnWrite in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
true if we write to disk for every modification

setSyncOnWrite

public void setSyncOnWrite(boolean isSyncOnWrite)
Sets the flag telling the server to flush on disk when some modification has been done.

Specified by:
setSyncOnWrite in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
isSyncOnWrite - A boolean set to true if we have to flush on disk when a modification occurs

setupSystemIndices

protected void setupSystemIndices()
                           throws Exception
Sets up the system indices.

Throws:
Exception

setupUserIndices

protected void setupUserIndices()
                         throws Exception
Sets up the user indices.

Throws:
Exception

getSearchEngine

public SearchEngine<org.apache.directory.shared.ldap.model.entry.Entry,ID> getSearchEngine()
Gets the DefaultSearchEngine used by this ContextPartition to search the Database.

Returns:
the search engine

getDefaultId

public abstract ID getDefaultId()
Gets the default ID.}

Specified by:
getDefaultId in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
the default ID.

getRootId

public abstract ID getRootId()
Gets the root ID of this store implementation.

Specified by:
getRootId in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
the root ID

convertAndInit

protected abstract Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> convertAndInit(Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> index)
                                                                                                                 throws Exception
Convert and initialize an index for a specific store implementation.

Parameters:
index - the index
Returns:
the converted and initialized index
Throws:
Exception

getPartitionPath

public URI getPartitionPath()
Gets the path in which this Partition stores data.

Specified by:
getPartitionPath in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
the path in which this Partition stores data.

doDestroy

protected void doDestroy()
                  throws org.apache.directory.shared.ldap.model.exception.LdapException,
                         Exception

Specified by:
doDestroy in class org.apache.directory.server.core.api.partition.AbstractPartition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException
Exception

doInit

protected void doInit()
               throws Exception

Specified by:
doInit in class org.apache.directory.server.core.api.partition.AbstractPartition
Throws:
Exception

add

public void add(org.apache.directory.server.core.api.interceptor.context.AddOperationContext addContext)
         throws org.apache.directory.shared.ldap.model.exception.LdapException

Specified by:
add in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

delete

public void delete(org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext deleteContext)
            throws org.apache.directory.shared.ldap.model.exception.LdapException

Specified by:
delete in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

delete

public void delete(ID id)
            throws org.apache.directory.shared.ldap.model.exception.LdapException
Delete the entry associated with a given Id

Specified by:
delete in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
id - The id of the entry to delete
Throws:
Exception - If the deletion failed
org.apache.directory.shared.ldap.model.exception.LdapException

list

public org.apache.directory.server.core.api.filtering.EntryFilteringCursor list(org.apache.directory.server.core.api.interceptor.context.ListOperationContext listContext)
                                                                         throws org.apache.directory.shared.ldap.model.exception.LdapException

Specified by:
list in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

list

public final IndexCursor<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> list(ID id)
                                                                                                                               throws org.apache.directory.shared.ldap.model.exception.LdapException
Gets an IndexEntry Cursor over the child nodes of an entry.

Specified by:
list in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
id - the id of the parent entry
Returns:
an IndexEntry Cursor over the child entries
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

search

public org.apache.directory.server.core.api.filtering.EntryFilteringCursor search(org.apache.directory.server.core.api.interceptor.context.SearchOperationContext searchContext)
                                                                           throws org.apache.directory.shared.ldap.model.exception.LdapException

Specified by:
search in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

lookup

public org.apache.directory.shared.ldap.model.entry.Entry lookup(org.apache.directory.server.core.api.interceptor.context.LookupOperationContext lookupContext)
                                                          throws org.apache.directory.shared.ldap.model.exception.LdapException

Specified by:
lookup in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

lookup

public org.apache.directory.shared.ldap.model.entry.Entry lookup(ID id)
                                                          throws org.apache.directory.shared.ldap.model.exception.LdapException
Get back an entry knowing its ID

Specified by:
lookup in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
id - The Entry ID we want to get back
Returns:
The found Entry, or null if not found
Throws:
Exception - If the lookup failed for any reason (except a not found entry)
org.apache.directory.shared.ldap.model.exception.LdapException

modify

public void modify(org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext modifyContext)
            throws org.apache.directory.shared.ldap.model.exception.LdapException

Specified by:
modify in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

modify

public final org.apache.directory.shared.ldap.model.entry.Entry modify(org.apache.directory.shared.ldap.model.name.Dn dn,
                                                                       org.apache.directory.shared.ldap.model.entry.Modification... mods)
                                                                throws Exception
Modify an entry applying the given list of modifications.

Specified by:
modify in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
dn - The Entry's Dn
mods - The list of modifications
Returns:
The modified entry
Throws:
Exception - If the modification failed

move

public void move(org.apache.directory.server.core.api.interceptor.context.MoveOperationContext moveContext)
          throws org.apache.directory.shared.ldap.model.exception.LdapException

Specified by:
move in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

move

public final void move(org.apache.directory.shared.ldap.model.name.Dn oldDn,
                       org.apache.directory.shared.ldap.model.name.Dn newSuperiorDn,
                       org.apache.directory.shared.ldap.model.name.Dn newDn,
                       org.apache.directory.shared.ldap.model.entry.Entry modifiedEntry)
                throws Exception

Move an entry from one place to the other. The Rdn remains unchanged, the parent Dn changes

We have to update some of the index when moving an entry. Assuming that the target destination does not exist, the following index must be updated :

If the moved entry is an alias, then we also have to update the following index :

The Alias index is not updated, as the entry ID won't change.

We have a few check we must do before moving the entry :

Specified by:
move in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
oldDn - The previous entry Dn
newSuperiorDn - The new superior Dn
newDn - The new Dn
modifiedEntry - The entry to move
Throws:
Exception - If the move failed

moveAndRename

public void moveAndRename(org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext moveAndRenameContext)
                   throws org.apache.directory.shared.ldap.model.exception.LdapException

Specified by:
moveAndRename in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

moveAndRename

public final void moveAndRename(org.apache.directory.shared.ldap.model.name.Dn oldDn,
                                org.apache.directory.shared.ldap.model.name.Dn newSuperiorDn,
                                org.apache.directory.shared.ldap.model.name.Rdn newRdn,
                                org.apache.directory.shared.ldap.model.entry.Entry modifiedEntry,
                                boolean deleteOldRdn)
                         throws Exception

Specified by:
moveAndRename in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Throws:
Exception

rename

public void rename(org.apache.directory.server.core.api.interceptor.context.RenameOperationContext renameContext)
            throws org.apache.directory.shared.ldap.model.exception.LdapException

Specified by:
rename in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

rename

public final void rename(org.apache.directory.shared.ldap.model.name.Dn dn,
                         org.apache.directory.shared.ldap.model.name.Rdn newRdn,
                         boolean deleteOldRdn,
                         org.apache.directory.shared.ldap.model.entry.Entry entry)
                  throws Exception
Changes the relative distinguished name of an entry specified by a distinguished name with the optional removal of the old Rdn attribute value from the entry. Name changes propagate down as dn changes to the descendants of the entry where the Rdn changed. An Rdn change operation does not change parent child relationships. It merely propagates a name change at a point in the DIT where the Rdn is changed. The change propagates down the subtree rooted at the distinguished name specified.

Specified by:
rename in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
dn - the normalized distinguished name of the entry to alter
newRdn - the new Rdn to set
deleteOldRdn - whether or not to remove the old Rdn attr/val
entry - the modified entry
Throws:
Exception - if there are any errors propagating the name changes

unbind

public final void unbind(org.apache.directory.server.core.api.interceptor.context.UnbindOperationContext unbindContext)
                  throws org.apache.directory.shared.ldap.model.exception.LdapException

Specified by:
unbind in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

hasEntry

public boolean hasEntry(org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext entryContext)
                 throws org.apache.directory.shared.ldap.model.exception.LdapException
This method calls Partition.lookup(LookupOperationContext) and return true if it returns an entry by default. Please override this method if there is more effective way for your implementation.

Specified by:
hasEntry in interface org.apache.directory.server.core.api.partition.Partition
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

buildEntryDn

protected org.apache.directory.shared.ldap.model.name.Dn buildEntryDn(ID id)
                                                               throws Exception
builds the Dn of the entry identified by the given id

Parameters:
id - the entry's id
Returns:
the normalized Dn of the entry
Throws:
Exception

count

public int count()
          throws Exception
Gets the total count of entries within this store.

Specified by:
count in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
the total count of entries within this store
Throws:
Exception - on failures to access the underlying store

getChildCount

public final int getChildCount(ID id)
                        throws org.apache.directory.shared.ldap.model.exception.LdapException
Gets the count of immediate children of the given entry ID.

Specified by:
getChildCount in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
id - the entry ID
Returns:
the child count
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

getEntryDn

public final org.apache.directory.shared.ldap.model.name.Dn getEntryDn(ID id)
                                                                throws Exception
Gets the Entry's Dn identified by the given id.

Specified by:
getEntryDn in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
id - the entry's id
Returns:
the entry's Dn
Throws:
Exception

getEntryId

public final ID getEntryId(org.apache.directory.shared.ldap.model.name.Dn dn)
                                           throws org.apache.directory.shared.ldap.model.exception.LdapException
Gets the entry's id. Returns null if the Dn doesn't exist in this store. Note that the Dn must be normalized!

Specified by:
getEntryId in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
dn - the normalized entry Dn
Returns:
the entry's id, or null if the Dn doesn't exists
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

getParentId

public ID getParentId(ID childId)
                                      throws Exception
Gets the ID of an entry's parent using the child entry's ID. Note that the suffix entry returns 0, which does not map to any entry.

Specified by:
getParentId in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
childId - the ID of the entry
Returns:
the id of the parent entry or zero if the suffix entry ID is used
Throws:
Exception - on failures to access the underlying store

getSuffixId

protected ID getSuffixId()
                                         throws Exception
Retrieve the SuffixID

Throws:
Exception

addIndex

public void addIndex(Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> index)
              throws Exception
Adds a (system or user) index to the list of index for this store. Note that the attribute id returned by Index.getAttributeId() must be the numeric OID.

Specified by:
addIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
index - The index to add
Throws:
Exception - If the addition failed

addIndexedAttributes

public void addIndexedAttributes(Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID>... indexes)
Add some new indexes

Parameters:
indexes - The added indexes

setIndexedAttributes

public void setIndexedAttributes(Set<Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID>> indexedAttributes)
Set the list of indexes for this partition

Parameters:
indexedAttributes - The list of indexes

getIndexedAttributes

public Set<Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID>> getIndexedAttributes()
Returns:
The list of indexed attributes

getUserIndices

public Iterator<String> getUserIndices()
An iterator build on top of the User's index

Specified by:
getUserIndices in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>

getSystemIndices

public Iterator<String> getSystemIndices()
An iterator build on top of the System's index

Specified by:
getSystemIndices in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>

getIndex

public Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> getIndex(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
                                                                                               throws IndexNotFoundException
Get the user or system index associated with the given attributeType

Specified by:
getIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
attributeType - The index attributeType we are looking for
Returns:
The associated user or system index
Throws:
IndexNotFoundException - If the index does not exist

getUserIndex

public Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> getUserIndex(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
                                                                                                   throws IndexNotFoundException
Get the user index associated with the given name

Specified by:
getUserIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
attributeType - The index name we are looking for
Returns:
The associated user index
Throws:
IndexNotFoundException - If the index does not exist

getSystemIndex

public Index<?,org.apache.directory.shared.ldap.model.entry.Entry,ID> getSystemIndex(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
                                                                                                     throws IndexNotFoundException
Get the system index associated with the given name

Specified by:
getSystemIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
attributeType - The index name we are looking for
Returns:
The associated system index
Throws:
IndexNotFoundException - If the index does not exist

getOneLevelIndex

public Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> getOneLevelIndex()

Specified by:
getOneLevelIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
The OneLevel system index

getSubLevelIndex

public Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> getSubLevelIndex()

Specified by:
getSubLevelIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
The SubLevel system index

getAliasIndex

public Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> getAliasIndex()

Specified by:
getAliasIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
The Alias system index

getOneAliasIndex

public Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> getOneAliasIndex()

Specified by:
getOneAliasIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
The OneAlias system index

getSubAliasIndex

public Index<ID,org.apache.directory.shared.ldap.model.entry.Entry,ID> getSubAliasIndex()

Specified by:
getSubAliasIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
The SubAlias system index

getObjectClassIndex

public Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> getObjectClassIndex()

Specified by:
getObjectClassIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
The ObjectClass system index

getEntryUuidIndex

public Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> getEntryUuidIndex()

Specified by:
getEntryUuidIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
The EntryUUID system index

getEntryCsnIndex

public Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> getEntryCsnIndex()

Specified by:
getEntryCsnIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
The EntryCSN system index

getPresenceIndex

public Index<String,org.apache.directory.shared.ldap.model.entry.Entry,ID> getPresenceIndex()

Specified by:
getPresenceIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
The Presence system index

getRdnIndex

public Index<ParentIdAndRdn<ID>,org.apache.directory.shared.ldap.model.entry.Entry,ID> getRdnIndex()

Specified by:
getRdnIndex in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
The Rdn system index

hasUserIndexOn

public boolean hasUserIndexOn(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
                       throws org.apache.directory.shared.ldap.model.exception.LdapException
Tells if an index is already present in the User's index list

Specified by:
hasUserIndexOn in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
attributeType - The attributeType index we are looking for
Returns:
true if the index is already present in the User's index list
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

hasSystemIndexOn

public boolean hasSystemIndexOn(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
                         throws org.apache.directory.shared.ldap.model.exception.LdapException
Tells if an index is already present in the System's index list

Specified by:
hasSystemIndexOn in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Parameters:
attributeType - The index we are looking for
Returns:
true if the index is already present in the System's index list
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

hasIndexOn

public boolean hasIndexOn(org.apache.directory.shared.ldap.model.schema.AttributeType attributeType)
                   throws org.apache.directory.shared.ldap.model.exception.LdapException
Tells if an index is already present in the User's or System's index list

Specified by:
hasIndexOn in interface Store<org.apache.directory.shared.ldap.model.entry.Entry,ID extends Comparable<ID>>
Returns:
true if the index is already present in the User's or System's index list
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException

addAliasIndices

protected void addAliasIndices(ID aliasId,
                               org.apache.directory.shared.ldap.model.name.Dn aliasDn,
                               String aliasTarget)
                        throws Exception
Adds userIndices for an aliasEntry to be added to the database while checking for constrained alias constructs like alias cycles and chaining.

Parameters:
aliasDn - normalized distinguished name for the alias entry
aliasTarget - the user provided aliased entry dn as a string
aliasId - the id of alias entry to add
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException - if index addition fails, and if the alias is not allowed due to chaining or cycle formation.
Exception - if the wrappedCursor btrees cannot be altered

dropAliasIndices

protected void dropAliasIndices(ID aliasId)
                         throws Exception
Removes the index entries for an alias before the entry is deleted from the master table.

Parameters:
aliasId - the id of the alias entry in the master table
Throws:
org.apache.directory.shared.ldap.model.exception.LdapException - if we cannot parse ldap names
Exception - if we cannot delete index values in the database

dropMovedAliasIndices

protected void dropMovedAliasIndices(org.apache.directory.shared.ldap.model.name.Dn movedBase)
                              throws Exception
For all aliases including and under the moved base, this method removes one and subtree alias index tuples for old ancestors above the moved base that will no longer be ancestors after the move.

Parameters:
movedBase - the base at which the move occurred - the moved node
Throws:
Exception - if system userIndices fail

dropAliasIndices

protected void dropAliasIndices(ID aliasId,
                                org.apache.directory.shared.ldap.model.name.Dn movedBase)
                         throws Exception
For the alias id all ancestor one and subtree alias tuples are moved above the moved base.

Parameters:
aliasId - the id of the alias
movedBase - the base where the move occurred
Throws:
Exception - if userIndices fail

dumpIndex

public void dumpIndex(OutputStream stream,
                      String name)
               throws IOException

Specified by:
dumpIndex in interface org.apache.directory.server.core.api.partition.Partition
Overrides:
dumpIndex in class org.apache.directory.server.core.api.partition.AbstractPartition
Throws:
IOException

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.