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