View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  package org.apache.directory.server.core.api.journal;
21  
22  
23  import org.apache.directory.api.ldap.model.exception.LdapException;
24  import org.apache.directory.api.ldap.model.ldif.LdifEntry;
25  import org.apache.directory.server.core.api.DirectoryService;
26  import org.apache.directory.server.core.api.LdapPrincipal;
27  
28  
29  /**
30   * A facade for the Journal subsystem.
31   *
32   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33   */
34  public interface Journal
35  {
36      /**
37       * Checks whether or not the Journal has been enabled.
38       *
39       * @return true if the Journal is logging changes, false otherwise
40       */
41      boolean isEnabled();
42  
43  
44      /**
45       * Enable or disable the Journal service
46       * @param enabled true to enable the service, false to disable it
47       */
48      void setEnabled( boolean enabled );
49  
50  
51      /**
52       * @return The underlying storage
53       */
54      JournalStore getJournalStore();
55  
56  
57      /**
58       * Set the underlying storage
59       * @param store The storage
60       */
61      void setJournalStore( JournalStore store );
62  
63  
64      /**
65       * Records a change as an LDIF entry.
66       *
67       * @param principal the authorized LDAP principal triggering the change
68       * @param revision the operation revision
69       * @param entry LDIF of the change going to the next state
70       * @throws LdapException if there are problems logging the change
71       */
72      void log( LdapPrincipal principal, long revision, LdifEntry entry ) throws LdapException;
73  
74  
75      /**
76       * Records a ack for a change
77       *
78       * @param revision The change revision which is acked
79       */
80      void ack( long revision );
81  
82  
83      /**
84       * Records a nack for a change
85       *
86       * @param revision The change revision which is acked
87       */
88      void nack( long revision );
89  
90  
91      /**
92       * Initialize the Journal.
93       * 
94       * @param service The associated DirectoryService
95       * @throws LdapException If something went wrong 
96       */
97      void init( DirectoryService service ) throws LdapException;
98  
99  
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 }