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 java.io.IOException;
24  
25  import org.apache.directory.api.ldap.model.ldif.LdifEntry;
26  import org.apache.directory.server.core.api.DirectoryService;
27  import org.apache.directory.server.core.api.LdapPrincipal;
28  
29  
30  /**
31   * A store for change events on the directory which exposes methods for 
32   * managing, querying and in general performing legal operations on the log.
33   *
34   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
35   */
36  public interface JournalStore
37  {
38      /**
39       * Initialize the store.
40       * 
41       * @param service The associated DirectoryService
42       * @throws IOException If the initialization failed
43       */
44      void init( DirectoryService service ) throws IOException;
45  
46  
47      /**
48       * Write the changes on disk
49       * 
50       * @throws IOException If the write failed
51       */
52      void sync() throws IOException;
53  
54  
55      /**
56       * Destroy the logs. 
57       * 
58       * @throws IOException If we can't destroy the logs
59       */
60      void destroy() throws IOException;
61  
62  
63      /**
64       * Gets the current revision of the server (a.k.a. the HEAD revision).
65       *
66       * @return the current revision of the server
67       */
68      long getCurrentRevision();
69  
70  
71      /**
72       * Records a change as a forward LDIF and the authorized principal
73       *
74       * @param principal The principal who is logging the change
75       * @param revision The operation revision
76       * @param forward The change to log
77       * @return <code>true</code> if the entry has been written
78       */
79      boolean log( LdapPrincipal principal, long revision, LdifEntry forward );
80  
81  
82      /**
83       * Records a ack for a change
84       *
85       * @param revision The change revision which is acked
86       * @return <code>true</code> if the ack has been written
87       */
88      boolean ack( long revision );
89  
90  
91      /**
92       * Records a nack for a change
93       *
94       * @param revision The change revision which is nacked
95       * @return <code>true</code> if the nack has been written
96       */
97      boolean nack( long revision );
98  
99  
100     /**
101      * The file name to use as the journal file. Default to 
102      * 'journal.ldif'
103      * @param fileName the fileName to set
104      */
105     void setFileName( String fileName );
106 
107 
108     /**
109      * The working directory on which the journal file will be stored. Default
110      * to 'server-work'
111      * @param workingDirectory The working directory in which the journal file
112      * will be stored
113      */
114     void setWorkingDirectory( String workingDirectory );
115 }