org.apache.directory.server.core.changelog
Class MemoryChangeLogStore

java.lang.Object
  extended by org.apache.directory.server.core.changelog.MemoryChangeLogStore
All Implemented Interfaces:
ChangeLogStore, TaggableChangeLogStore

public class MemoryChangeLogStore
extends java.lang.Object
implements TaggableChangeLogStore

A change log store that keeps it's information in memory.

Version:
$Rev$, $Date$ TODO remove the NamingException
Author:
Apache Directory Project
'XBean'

Constructor Summary
MemoryChangeLogStore()
           
 
Method Summary
 void destroy()
           
 Cursor<ChangeLogEvent> find()
          Gets a Cursor over all the ChangeLogEvents within the system since revision 0.
 Cursor<ChangeLogEvent> find(long startRevision, long endRevision)
          Finds the ChangeLogEvents that occurred between a revision range inclusive.
 Cursor<ChangeLogEvent> findAfter(long revision)
          Finds the ChangeLogEvents that occurred after a revision exclusive.
 Cursor<ChangeLogEvent> findBefore(long revision)
          Gets a Cursor over the ChangeLogEvents that occurred before a revision exclusive.
 long getCurrentRevision()
          Gets the current revision of the server (a.k.a.
 Tag getLatest()
          Gets the latest tag if one was at all taken.
 void init(DirectoryService service)
           
 ChangeLogEvent log(LdapPrincipal principal, org.apache.directory.shared.ldap.ldif.LdifEntry forward, org.apache.directory.shared.ldap.ldif.LdifEntry reverse)
          Records a change as a forward LDIF, a reverse change to revert the change and the authorized principal triggering the revertable change event.
 ChangeLogEvent log(LdapPrincipal principal, org.apache.directory.shared.ldap.ldif.LdifEntry forward, java.util.List<org.apache.directory.shared.ldap.ldif.LdifEntry> reverses)
          Records a change as a forward LDIF, some reverse changes to revert the change and the authorized principal triggering the revertable change event.
 ChangeLogEvent lookup(long revision)
          Looks up the ChangeLogEvent for a revision.
 Tag removeTag(long revision)
          Removes a Tag created for a given revision.
 void sync()
           
 Tag tag()
          Creates a snapshot of the server at the current revision.
 Tag tag(long revision)
          Creates a tag for a snapshot of the server in a specific state at a revision.
 Tag tag(long revision, java.lang.String descrition)
          Creates a tag with the given description for a snapshot of the server in a specific state at a revision.
 Tag tag(java.lang.String description)
          Creates a snapshot of the server at the current revision with a description of the snapshot tag.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemoryChangeLogStore

public MemoryChangeLogStore()
Method Detail

tag

public Tag tag(long revision)
        throws java.lang.Exception
Description copied from interface: TaggableChangeLogStore
Creates a tag for a snapshot of the server in a specific state at a revision.

Specified by:
tag in interface TaggableChangeLogStore
Parameters:
revision - the revision to tag the snapshot
Returns:
the Tag associated with the revision
Throws:
java.lang.Exception - if there is a problem taking a tag, or if the revision does not exist

tag

public Tag tag()
        throws java.lang.Exception
Description copied from interface: TaggableChangeLogStore
Creates a snapshot of the server at the current revision.

Specified by:
tag in interface TaggableChangeLogStore
Returns:
the revision at which the tag is created
Throws:
java.lang.Exception - if there is a problem taking a tag

tag

public Tag tag(java.lang.String description)
        throws java.lang.Exception
Description copied from interface: TaggableChangeLogStore
Creates a snapshot of the server at the current revision with a description of the snapshot tag.

Specified by:
tag in interface TaggableChangeLogStore
Parameters:
description - a description of the state associate with the tag
Returns:
the revision at which the tag is created
Throws:
java.lang.Exception - if there is a problem taking a tag

init

public void init(DirectoryService service)
          throws java.lang.Exception
Specified by:
init in interface ChangeLogStore
Throws:
java.lang.Exception

sync

public void sync()
          throws java.lang.Exception
Specified by:
sync in interface ChangeLogStore
Throws:
java.lang.Exception

destroy

public void destroy()
             throws java.lang.Exception
Specified by:
destroy in interface ChangeLogStore
Throws:
java.lang.Exception

getCurrentRevision

public long getCurrentRevision()
Description copied from interface: ChangeLogStore
Gets the current revision of the server (a.k.a. the HEAD revision).

Specified by:
getCurrentRevision in interface ChangeLogStore
Returns:
the current revision of the server

log

public ChangeLogEvent log(LdapPrincipal principal,
                          org.apache.directory.shared.ldap.ldif.LdifEntry forward,
                          org.apache.directory.shared.ldap.ldif.LdifEntry reverse)
                   throws java.lang.Exception
Records a change as a forward LDIF, a reverse change to revert the change and the authorized principal triggering the revertable change event.

Specified by:
log in interface ChangeLogStore
Parameters:
principal - the authorized LDAP principal triggering the change
forward - LDIF of the change going to the next state
reverse - LDIF (anti-operation): the change required to revert this change
Returns:
the new revision reached after having applied the forward LDIF
Throws:
java.lang.Exception - if there are problems logging the change

log

public ChangeLogEvent log(LdapPrincipal principal,
                          org.apache.directory.shared.ldap.ldif.LdifEntry forward,
                          java.util.List<org.apache.directory.shared.ldap.ldif.LdifEntry> reverses)
                   throws java.lang.Exception
Records a change as a forward LDIF, some reverse changes to revert the change and the authorized principal triggering the revertable change event.

Specified by:
log in interface ChangeLogStore
Parameters:
principal - the authorized LDAP principal triggering the change
forward - LDIF of the change going to the next state
reverses - LDIF (anti-operation): the changes required to revert this change
Returns:
the new revision reached after having applied the forward LDIF
Throws:
java.lang.Exception - if there are problems logging the change

lookup

public ChangeLogEvent lookup(long revision)
                      throws java.lang.Exception
Description copied from interface: ChangeLogStore
Looks up the ChangeLogEvent for a revision.

Specified by:
lookup in interface ChangeLogStore
Parameters:
revision - to get a ChangeLogEvent for
Returns:
the ChangeLogEvent associated with the revision
Throws:
java.lang.Exception - if there are failures accessing the store
java.lang.IllegalArgumentException - if the revision is out of range (less than 0 and greater than the current revision)

find

public Cursor<ChangeLogEvent> find()
                            throws java.lang.Exception
Description copied from interface: ChangeLogStore
Gets a Cursor over all the ChangeLogEvents within the system since revision 0. This method should exhibit isolation characteristics: meaning if the request is initiated at revision 100, then any subsequent log entries increasing the revision should not be seen.

Specified by:
find in interface ChangeLogStore
Returns:
a Cursor over all the ChangeLogEvents
Throws:
java.lang.Exception - if there are failures accessing the store

findBefore

public Cursor<ChangeLogEvent> findBefore(long revision)
                                  throws java.lang.Exception
Description copied from interface: ChangeLogStore
Gets a Cursor over the ChangeLogEvents that occurred before a revision exclusive.

Specified by:
findBefore in interface ChangeLogStore
Parameters:
revision - the revision number to get the ChangeLogEvents before
Returns:
a Cursor over the ChangeLogEvents before a revision
Throws:
java.lang.Exception - if there are failures accessing the store
java.lang.IllegalArgumentException - if the revision is out of range (less than 0 and greater than the current revision)

findAfter

public Cursor<ChangeLogEvent> findAfter(long revision)
                                 throws java.lang.Exception
Description copied from interface: ChangeLogStore
Finds the ChangeLogEvents that occurred after a revision exclusive. This method should exhibit isolation characteristics: meaning if the request is initiated at revision 100 then any subsequent log entries increasing the revision should not be seen.

Specified by:
findAfter in interface ChangeLogStore
Parameters:
revision - the revision number to get the ChangeLogEvents after
Returns:
a Cursor of all the ChangeLogEvents after and including the revision
Throws:
java.lang.Exception - if there are failures accessing the store
java.lang.IllegalArgumentException - if the revision is out of range (less than 0 and greater than the current revision)

find

public Cursor<ChangeLogEvent> find(long startRevision,
                                   long endRevision)
                            throws java.lang.Exception
Description copied from interface: ChangeLogStore
Finds the ChangeLogEvents that occurred between a revision range inclusive.

Specified by:
find in interface ChangeLogStore
Parameters:
startRevision - the revision number to start getting the ChangeLogEvents above
endRevision - the revision number to start getting the ChangeLogEvents below
Returns:
an enumeration of all the ChangeLogEvents within some revision range inclusive
Throws:
java.lang.Exception - if there are failures accessing the store
java.lang.IllegalArgumentException - if the start and end revisions are out of range (less than 0 and greater than the current revision), or if startRevision > endRevision

getLatest

public Tag getLatest()
              throws java.lang.Exception
Description copied from interface: TaggableChangeLogStore
Gets the latest tag if one was at all taken.

Specified by:
getLatest in interface TaggableChangeLogStore
Returns:
the last tag to have been created (youngest), or null if no tags have been created
Throws:
java.lang.Exception - on failures to access the tag store

removeTag

public Tag removeTag(long revision)
              throws java.lang.Exception
Description copied from interface: TaggableChangeLogStore
Removes a Tag created for a given revision.

Specified by:
removeTag in interface TaggableChangeLogStore
Parameters:
revision - the revision number that was tagged
Returns:
the removed tag, null if there is no Tag present with the given revision
Throws:
java.lang.Exception - on failures to access the tag store
See Also:
TaggableChangeLogStore.removeTag(long)

tag

public Tag tag(long revision,
               java.lang.String descrition)
        throws java.lang.Exception
Description copied from interface: TaggableChangeLogStore
Creates a tag with the given description for a snapshot of the server in a specific state at a revision.

Specified by:
tag in interface TaggableChangeLogStore
Parameters:
revision - the revision number that was tagged
descrition - a description of the state associate with the tag
Returns:
the Tag associated with the revision
Throws:
java.lang.Exception - on failures to access the tag store
See Also:
TaggableChangeLogStore.tag(long, String)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


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