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     * A facade for the Journal subsystem.
030     *
031     * @org.apache.xbean.XBean
032     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033     * @version $Rev$, $Date$
034     */
035    public interface Journal
036    {
037        /**
038         * Checks whether or not the Journal has been enabled.
039         *
040         * @return true if the Journal is logging changes, false otherwise
041         */
042        boolean isEnabled();
043    
044    
045        /**
046         * Enable or disable the Journal service
047         * @param enabled true to enable the service, false to disable it
048         */
049        void setEnabled( boolean enabled );
050        
051    
052        /**
053         * @return The underlying storage
054         */
055        JournalStore getJournalStore();
056    
057    
058        /**
059         * Set the underlying storage
060         * @param store The storage
061         */
062        void setJournalStore( JournalStore store );
063    
064    
065        /**
066         * Records a change as an LDIF entry.
067         *
068         * @param principal the authorized LDAP principal triggering the change
069         * @param revision the operation revision
070         * @param forward LDIF of the change going to the next state
071         * @throws Exception if there are problems logging the change
072         */
073        void log( LdapPrincipal principal, long revision, LdifEntry entry ) throws Exception;
074    
075        
076        /**
077         * Records a ack for a change
078         *
079         * @param revision The change revision which is acked
080         */
081        void ack( long revision );
082    
083        
084        /**
085         * Records a nack for a change
086         *
087         * @param revision The change revision which is acked
088         */
089        void nack( long revision );
090    
091        
092        /**
093         * Initialize the Journal.
094         * 
095         * @param service The associated DirectoryService
096         * @throws Exception If something went wrong 
097         */
098        void init( DirectoryService service ) throws Exception;
099    
100        
101        /**
102         * Destroy the journal service
103         * @throws Exception If something went wrong
104         */
105        void destroy() throws Exception;
106    
107    
108        /**
109         * @return the rotation
110         */
111        int getRotation();
112    
113    
114        /**
115         * @param rotation the rotation to set
116         */
117        void setRotation( int rotation );
118    }