You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2009/06/10 23:49:48 UTC

svn commit: r783531 - in /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core: ./ replication/

Author: elecharny
Date: Wed Jun 10 21:49:48 2009
New Revision: 783531

URL: http://svn.apache.org/viewvc?rev=783531&view=rev
Log:
Injected a first set of data structure to manage the replication configuration

Added:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/BindMethod.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicaConnection.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationConfiguration.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationProvider.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationType.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/SimpleReplicaConnection.java
Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=783531&r1=783530&r2=783531&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Wed Jun 10 21:49:48 2009
@@ -59,6 +59,7 @@
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.server.core.referral.ReferralInterceptor;
+import org.apache.directory.server.core.replication.ReplicationConfiguration;
 import org.apache.directory.server.core.schema.PartitionSchemaLoader;
 import org.apache.directory.server.core.schema.SchemaInterceptor;
 import org.apache.directory.server.core.schema.SchemaOperationControl;
@@ -183,6 +184,9 @@
     
     /** The directory instance replication ID */
     private int replicaId;
+    
+    /** The replication configuration structure */
+    private ReplicationConfiguration replicationConfig;
 
     /** remove me after implementation is completed */
     private static final String PARTIAL_IMPL_WARNING =
@@ -425,9 +429,11 @@
     public void setInterceptors( List<Interceptor> interceptors ) 
     {
         Set<String> names = new HashSet<String>();
+        
         for ( Interceptor interceptor : interceptors )
         {
             String name = interceptor.getName();
+            
             if ( names.contains( name ) )
             {
                 LOG.warn( "Encountered duplicate definitions for {} interceptor", interceptor.getName() );
@@ -1756,4 +1762,20 @@
             this.replicaId = replicaId;
         }
     }
+
+
+    public void setReplicationConfiguration( ReplicationConfiguration replicationConfig )
+    {
+        this.replicationConfig = replicationConfig;
+        
+    }
+    
+    
+    /**
+     * @return the replication configuration for this DirectoryService
+     */
+    public ReplicationConfiguration getReplicationConfiguration()
+    {
+        return replicationConfig;
+    }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=783531&r1=783530&r2=783531&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java Wed Jun 10 21:49:48 2009
@@ -30,6 +30,7 @@
 import org.apache.directory.server.core.journal.Journal;
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.replication.ReplicationConfiguration;
 import org.apache.directory.server.core.schema.SchemaService;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.csn.Csn;
@@ -481,4 +482,18 @@
      * @param replicaId the replicaId to set
      */
     void setReplicaId( int replicaId );
+
+
+    /**
+     * Sets the replication configuration in the server.
+     *
+     * @param replicationConfiguration the replication configuration to be used in the server.
+     */
+    void setReplicationConfiguration( ReplicationConfiguration replicationConfig );
+    
+    
+    /**
+     * @return the replication configuration for this DirectoryService
+     */
+    ReplicationConfiguration getReplicationConfiguration();
 }

Added: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/BindMethod.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/BindMethod.java?rev=783531&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/BindMethod.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/BindMethod.java Wed Jun 10 21:49:48 2009
@@ -0,0 +1,66 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.server.core.replication;
+
+/**
+ * An enum used to store the Bind Methods : SIMPLE or SASL 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ *
+ */
+public enum BindMethod
+{
+    /** SIMPLE bind */
+    SIMPLE( "simple" ),
+    
+    /** SASL bind */
+    SASL( "sasl" ),
+    
+    /** Unkwnon bind method */ 
+    UNKWNOWN( "" );
+    
+    /** A storage for the String representation of the BindMethod */
+    private String bindMethod;
+    
+    
+    /**
+     * Build the Enum's instances.
+     */
+    private BindMethod( String bindMethod )
+    {
+        this.bindMethod = bindMethod;
+    }
+    
+    
+    public static BindMethod getInstance( String bindMethod )
+    {
+        if ( SIMPLE.bindMethod.equalsIgnoreCase( bindMethod ) )
+        {
+            return SIMPLE;
+        }
+        
+        if ( SASL.bindMethod.equalsIgnoreCase( bindMethod ) )
+        {
+            return SASL;
+        }
+        
+        return UNKWNOWN;
+    }
+}

Added: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicaConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicaConnection.java?rev=783531&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicaConnection.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicaConnection.java Wed Jun 10 21:49:48 2009
@@ -0,0 +1,55 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.replication;
+
+
+/**
+ * A connection to a replica. This is an abstract class, extended by the 
+ * SimpleReplicaConnection or the SaslReplicaConnection.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: $, $Date: $
+ *
+ */
+public abstract class ReplicaConnection
+{
+    /** The bind method to use */
+    private BindMethod bindMethod;
+    
+    /**
+     * @return the bindMethod
+     */
+    public BindMethod getBindMethod()
+    {
+        return bindMethod;
+    }
+
+    
+    /**
+     * @param bindMethod the bindMethod to set
+     */
+    public void setBindMethod( String bindMethod )
+    {
+        this.bindMethod = BindMethod.getInstance( bindMethod );
+    }
+
+
+
+}

Added: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationConfiguration.java?rev=783531&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationConfiguration.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationConfiguration.java Wed Jun 10 21:49:48 2009
@@ -0,0 +1,65 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.replication;
+
+import java.util.List;
+
+/**
+ * The replication configuration.
+ * 
+ * @org.apache.xbean.XBean
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: $, $Date: $
+ *
+ */
+public class ReplicationConfiguration
+{
+    /** The list of replication providers */
+    private List<ReplicationProvider> providers;
+    
+    /**
+     * Default constructor
+     */
+    public ReplicationConfiguration()
+    {
+        // Nothing
+    }
+
+
+    /**
+     * Sets the providers in the server.
+     *
+     * @param providers the providers to be used in the server.
+     */
+    public void setProviders( List<ReplicationProvider> providers )
+    {
+        this.providers = providers;
+    }
+    
+    
+    /**
+     * @return The list of replication providers
+     */
+    public List<ReplicationProvider> getproviders()
+    {
+        return providers;
+    }
+}

Added: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationProvider.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationProvider.java?rev=783531&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationProvider.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationProvider.java Wed Jun 10 21:49:48 2009
@@ -0,0 +1,172 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.replication;
+
+import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+import org.apache.directory.shared.ldap.util.LdapURL;
+
+/**
+ * The replication provider data structure.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: $, $Date: $
+ */
+public class ReplicationProvider
+{
+    /** The provider unique identifier */
+    private int id;
+    
+    /** The type of replication (refreshOnly or refreshAndPersist */
+    private ReplicationType type = ReplicationType.REFRESH_AND_PERSIST;
+    
+    /** The sizeLimit for the searchRequest. Default to unlimited. */
+    private int sizeLimit = 0;
+    
+    /** The timeLimit for the search request. Default to unlimited. */
+    private int timeLimit = 0;
+    
+    /** The search operation to conduct */
+    private LdapURL url;
+    
+    /** The connection to the replica */
+    private ReplicaConnection connection;
+    
+    
+    /**
+     * @return the connection
+     */
+    public ReplicaConnection getConnection()
+    {
+        return connection;
+    }
+
+
+    /**
+     * @param connection the connection to set
+     */
+    public void setConnection( ReplicaConnection connection )
+    {
+        this.connection = connection;
+    }
+
+
+    public ReplicationProvider()
+    {
+        type = ReplicationType.REFRESH_AND_PERSIST;
+    }
+    
+    
+    /**
+     * @return the providerId
+     */
+    public int getId()
+    {
+        return id;
+    }
+
+
+    /**
+     * @param id the provider Id to set
+     */
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    
+    /**
+     * @return the type
+     */
+    public ReplicationType getReplicationType()
+    {
+        return type;
+    }
+
+
+    /**
+     * @param type the replication type to set
+     */
+    public void setType( String type )
+    {
+        this.type = ReplicationType.getInstance( type );
+    }
+
+
+    /**
+     * @return the sizeLimit
+     */
+    public int getSizeLimit()
+    {
+        return sizeLimit;
+    }
+
+
+    /**
+     * @param sizeLimit the sizeLimit to set
+     */
+    public void setSizeLimit( int sizeLimit )
+    {
+        this.sizeLimit = sizeLimit;
+    }
+
+
+    /**
+     * @return the timeLimit
+     */
+    public int getTimeLimit()
+    {
+        return timeLimit;
+    }
+
+
+    /**
+     * @param timeLimit the timeLimit to set
+     */
+    public void setTimeLimit( int timeLimit )
+    {
+        this.timeLimit = timeLimit;
+    }
+    
+    
+    /**
+     * @return the url
+     */
+    public LdapURL getUrl()
+    {
+        return url;
+    }
+    
+    
+    /**
+     * 
+     * @param url The URL to use for the replication search request
+     */
+    public void setUrl( String url )
+    {
+        try
+        {
+            this.url = new LdapURL( url );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            this.url = null;
+        }
+    }
+}

Added: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationType.java?rev=783531&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationType.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/ReplicationType.java Wed Jun 10 21:49:48 2009
@@ -0,0 +1,72 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.replication;
+
+/**
+ * Describe the type of replication :
+ * <li>refreshOnly : replication is done only when requested. This is a 
+ * <b>Pull</b> mode</li>
+ * <li>refreshAndPersist: replication is done and a listener is created to be 
+ * informed whenever some modification occurs on the provider. This is a 
+ * <b>Push</b> mode</li>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: $, $Date: $
+ */
+public enum ReplicationType
+{
+    REFRESH_ONLY( "refreshOnly" ),
+    REFRESH_AND_PERSIST( "refreshAndPersist" ),
+    UNKNOWN( "" );
+
+    /** The inner String associated with the types */
+    private String type;
+    
+    
+    /**
+     * private constructor to create the instances.
+     */
+    private ReplicationType( String type )
+    {
+        this.type = type;
+    }
+    
+    
+    /**
+     * Get the ReplicationType associated with the given String.
+     * @param type The ReplicationType as a String 
+     * @return The associated enum instance
+     */
+    public static ReplicationType getInstance( String type )
+    {
+        if ( REFRESH_ONLY.type.equalsIgnoreCase( type ) )
+        {
+            return REFRESH_ONLY;
+        }
+        else if ( REFRESH_AND_PERSIST.type.equalsIgnoreCase( type ) )
+        {
+            return REFRESH_AND_PERSIST;
+        }
+        else
+        {
+            return UNKNOWN;
+        }
+    }
+}

Added: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/SimpleReplicaConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/SimpleReplicaConnection.java?rev=783531&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/SimpleReplicaConnection.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/replication/SimpleReplicaConnection.java Wed Jun 10 21:49:48 2009
@@ -0,0 +1,72 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.replication;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A connection to a replica. This is an abstract class, extended by the 
+ * SimpleReplicaConnection or the SaslReplicaConnection.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: $, $Date: $
+ *
+ */
+public abstract class SimpleReplicaConnection extends ReplicaConnection
+{
+    /** The DN to use to bind to the remote server */
+    private LdapDN principal;
+
+    /** The password */
+    private String credentials;
+
+    /**
+     * @return the principal
+     */
+    public LdapDN getPrincipal()
+    {
+        return principal;
+    }
+
+    /**
+     * @param principal the principal to set
+     */
+    public void setPrincipal( LdapDN principal )
+    {
+        this.principal = principal;
+    }
+
+    /**
+     * @return the credentials
+     */
+    public String getCredentials()
+    {
+        return credentials;
+    }
+
+    /**
+     * @param credentials the credentials to set
+     */
+    public void setCredentials( String credentials )
+    {
+        this.credentials = credentials;
+    }
+}