public class MemoryChangeLogStore extends java.lang.Object implements TaggableChangeLogStore
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
CHANGELOG_FILE |
private long |
currentRevision
An incremental number giving the current revision
|
private DirectoryService |
directoryService
The DirectoryService
|
private java.util.List<ChangeLogEvent> |
events |
private Tag |
latest
The latest tag
|
private static java.lang.String |
REV_FILE |
private static java.lang.String |
TAG_FILE |
private java.util.Map<java.lang.Long,Tag> |
tags
A Map of tags and revisions
|
private java.io.File |
workingDirectory |
| Constructor and Description |
|---|
MemoryChangeLogStore() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Save logs, tags and revision on disk, and clean everything in memory
|
org.apache.directory.api.ldap.model.cursor.Cursor<ChangeLogEvent> |
find()
Gets a Cursor over all the ChangeLogEvents within the system since
revision 0.
|
org.apache.directory.api.ldap.model.cursor.Cursor<ChangeLogEvent> |
find(long startRevision,
long endRevision)
Finds the ChangeLogEvents that occurred between a revision range inclusive.
|
org.apache.directory.api.ldap.model.cursor.Cursor<ChangeLogEvent> |
findAfter(long revision)
Finds the ChangeLogEvents that occurred after a revision exclusive.
|
org.apache.directory.api.ldap.model.cursor.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)
Initialize the store.
|
private void |
loadChangeLog() |
private void |
loadRevision() |
private void |
loadTags() |
ChangeLogEvent |
log(LdapPrincipal principal,
org.apache.directory.api.ldap.model.ldif.LdifEntry forward,
org.apache.directory.api.ldap.model.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.api.ldap.model.ldif.LdifEntry forward,
java.util.List<org.apache.directory.api.ldap.model.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.
|
private void |
saveChangeLog() |
private void |
saveRevision() |
private void |
saveTags() |
void |
sync()
Write the changes on disk
|
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() |
private static final java.lang.String REV_FILE
private static final java.lang.String TAG_FILE
private static final java.lang.String CHANGELOG_FILE
private long currentRevision
private Tag latest
private final java.util.Map<java.lang.Long,Tag> tags
private final java.util.List<ChangeLogEvent> events
private java.io.File workingDirectory
private DirectoryService directoryService
public Tag tag(long revision) throws java.lang.Exception
tag in interface TaggableChangeLogStorerevision - the revision to tag the snapshotjava.lang.Exception - if there is a problem taking a tag, or if
the revision does not existpublic Tag tag() throws java.lang.Exception
tag in interface TaggableChangeLogStorejava.lang.Exception - if there is a problem taking a tagpublic Tag tag(java.lang.String description) throws java.lang.Exception
TaggableChangeLogStoretag in interface TaggableChangeLogStoredescription - a description of the state associate with the tagjava.lang.Exception - if there is a problem taking a tagpublic void init(DirectoryService service) throws java.lang.Exception
ChangeLogStoreinit in interface ChangeLogStoreservice - The associated DirectoryServicejava.lang.Exception - If the initialization failedprivate void loadRevision()
throws java.lang.Exception
java.lang.Exceptionprivate void saveRevision()
throws java.lang.Exception
java.lang.Exceptionprivate void saveTags()
throws java.lang.Exception
java.lang.Exceptionprivate void loadTags()
throws java.lang.Exception
java.lang.Exceptionprivate void loadChangeLog()
throws java.lang.Exception
java.lang.Exceptionprivate void saveChangeLog()
throws java.lang.Exception
java.lang.Exceptionpublic void sync()
throws java.lang.Exception
ChangeLogStoresync in interface ChangeLogStorejava.lang.Exception - If the write failedpublic void destroy()
throws java.lang.Exception
destroy in interface ChangeLogStorejava.lang.Exception - If we can't destroy the logspublic long getCurrentRevision()
ChangeLogStoregetCurrentRevision in interface ChangeLogStorepublic ChangeLogEvent log(LdapPrincipal principal, org.apache.directory.api.ldap.model.ldif.LdifEntry forward, org.apache.directory.api.ldap.model.ldif.LdifEntry reverse) throws java.lang.Exception
log in interface ChangeLogStoreprincipal - the authorized LDAP principal triggering the changeforward - LDIF of the change going to the next statereverse - LDIF (anti-operation): the change required to revert this changejava.lang.Exception - if there are problems logging the changepublic ChangeLogEvent log(LdapPrincipal principal, org.apache.directory.api.ldap.model.ldif.LdifEntry forward, java.util.List<org.apache.directory.api.ldap.model.ldif.LdifEntry> reverses) throws java.lang.Exception
log in interface ChangeLogStoreprincipal - the authorized LDAP principal triggering the changeforward - LDIF of the change going to the next statereverses - LDIF (anti-operation): the changes required to revert this changejava.lang.Exception - if there are problems logging the changepublic ChangeLogEvent lookup(long revision) throws java.lang.Exception
ChangeLogStorelookup in interface ChangeLogStorerevision - to get a ChangeLogEvent forjava.lang.Exception - if there are failures accessing the storejava.lang.IllegalArgumentException - if the revision is out of range (less than 0
and greater than the current revision)public org.apache.directory.api.ldap.model.cursor.Cursor<ChangeLogEvent> find() throws java.lang.Exception
ChangeLogStorefind in interface ChangeLogStorejava.lang.Exception - if there are failures accessing the storepublic org.apache.directory.api.ldap.model.cursor.Cursor<ChangeLogEvent> findBefore(long revision) throws java.lang.Exception
ChangeLogStorefindBefore in interface ChangeLogStorerevision - the revision number to get the ChangeLogEvents beforejava.lang.Exception - if there are failures accessing the storejava.lang.IllegalArgumentException - if the revision is out of range (less than 0
and greater than the current revision)public org.apache.directory.api.ldap.model.cursor.Cursor<ChangeLogEvent> findAfter(long revision) throws org.apache.directory.api.ldap.model.exception.LdapException
ChangeLogStorefindAfter in interface ChangeLogStorerevision - the revision number to get the ChangeLogEvents afterorg.apache.directory.api.ldap.model.exception.LdapExceptionpublic org.apache.directory.api.ldap.model.cursor.Cursor<ChangeLogEvent> find(long startRevision, long endRevision) throws java.lang.Exception
ChangeLogStorefind in interface ChangeLogStorestartRevision - the revision number to start getting the ChangeLogEvents aboveendRevision - the revision number to start getting the ChangeLogEvents belowjava.lang.Exception - if there are failures accessing the storejava.lang.IllegalArgumentException - if the start and end revisions are out of range
(less than 0 and greater than the current revision), or if startRevision > endRevisionpublic Tag getLatest() throws org.apache.directory.api.ldap.model.exception.LdapException
TaggableChangeLogStoregetLatest in interface TaggableChangeLogStoreorg.apache.directory.api.ldap.model.exception.LdapExceptionpublic Tag removeTag(long revision) throws java.lang.Exception
TaggableChangeLogStoreremoveTag in interface TaggableChangeLogStorerevision - the revision number that was taggedjava.lang.Exception - on failures to access the tag storeTaggableChangeLogStore.removeTag(long)public Tag tag(long revision, java.lang.String descrition) throws java.lang.Exception
TaggableChangeLogStoretag in interface TaggableChangeLogStorerevision - the revision number that was taggeddescrition - a description of the state associate with the tagjava.lang.Exception - on failures to access the tag storeTaggableChangeLogStore.tag(long, String)public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()