001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.core.journal;
021
022
023 import org.apache.directory.server.core.DirectoryService;
024 import org.apache.directory.server.core.LdapPrincipal;
025 import org.apache.directory.shared.ldap.ldif.LdifEntry;
026
027
028
029 /**
030 * A store for change events on the directory which exposes methods for
031 * managing, querying and in general performing legal operations on the log.
032 *
033 * @org.apache.xbean.XBean
034 *
035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036 * @version $Rev$, $Date$
037 */
038 public interface JournalStore
039 {
040 /**
041 * Initialize the store.
042 *
043 * @param service The associated DirectoryService
044 * @throws Exception If the initialization failed
045 */
046 void init( DirectoryService service ) throws Exception;
047
048
049 /**
050 * Write the changes on disk
051 *
052 * @throws Exception If the write failed
053 */
054 void sync() throws Exception;
055
056
057 /**
058 * Destroy the logs.
059 *
060 * @throws Exception If we can't destroy the logs
061 */
062 void destroy() throws Exception;
063
064
065 /**
066 * Gets the current revision of the server (a.k.a. the HEAD revision).
067 *
068 * @return the current revision of the server
069 */
070 long getCurrentRevision();
071
072
073 /**
074 * Records a change as a forward LDIF and the authorized principal
075 *
076 * @param principal The principal who is logging the change
077 * @param revision The operation revision
078 * @param forward The change to log
079 * @return <code>true</code> if the entry has been written
080 */
081 boolean log( LdapPrincipal principal, long revision, LdifEntry forward );
082
083
084 /**
085 * Records a ack for a change
086 *
087 * @param revision The change revision which is acked
088 * @return <code>true</code> if the ack has been written
089 */
090 boolean ack( long revision );
091
092
093 /**
094 * Records a nack for a change
095 *
096 * @param revision The change revision which is nacked
097 * @return <code>true</code> if the nack has been written
098 * @throws Exception if there are problems logging the nack
099 */
100 boolean nack( long revision );
101
102
103 /**
104 * The file name to use as the journal file. Default to
105 * 'journal.ldif'
106 * @param fileName the fileName to set
107 */
108 void setFileName( String fileName );
109
110
111 /**
112 * The working directory on which the journal file will be stored. Default
113 * to 'server-work'
114 * @param workingDirectory The working directory in which the journal file
115 * will be stored
116 */
117 void setWorkingDirectory( String workingDirectory );
118 }