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 21 package org.apache.directory.server.ldap.replication.consumer; 22 23 24 import org.apache.directory.server.core.api.DirectoryService; 25 import org.apache.directory.server.ldap.replication.ReplicationConsumerConfig; 26 27 28 /** 29 * An interface for consumers of a service which receives the ldap entries as and when a 30 * event happens in the server. The data received might vary based on the internal configuration 31 * used by implementation. 32 * 33 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 34 */ 35 public interface ReplicationConsumer 36 { 37 /** A flag we used when we want to connect without waiting */ 38 boolean NOW = true; 39 40 /** A flag we used when we want to connect after a waiting delay */ 41 boolean DIFFERED = false; 42 43 /** 44 * Sets the configuration of the consumer 45 * 46 * @param config the configuration of the consumer 47 */ 48 void setConfig( ReplicationConsumerConfig config ); 49 50 51 /** 52 * @return get the configuration of the consumer 53 */ 54 ReplicationConsumerConfig getConfig(); 55 56 57 /** 58 * Initializes the consumer 59 * 60 * @param dirService the DirectoryService 61 * @throws Exception If the initialization failed 62 */ 63 void init( DirectoryService dirService ) throws Exception; 64 65 66 /** 67 * Connect the consumer, connection immediately or wait before reconnection 68 * 69 * @param now A param that tells the consumer to connect immediately or not 70 * @return true if the consumer is connected, false otherwise 71 */ 72 boolean connect( boolean now ); 73 74 75 /** 76 * Test the connection with the provider. It does connect to the provider, and 77 * tries to bind on it using the consumer credentials. 78 */ 79 void ping(); 80 81 82 /** 83 * Stops the consumer 84 */ 85 void stop(); 86 87 88 /** 89 * @return the identifier of the consumer instance 90 */ 91 String getId(); 92 93 94 /** 95 * Starts the synchronization operation 96 * 97 * @return The replication status 98 */ 99 ReplicationStatusEnum startSync(); 100 }