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