directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1128966 - in /directory/apacheds/trunk: protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ server-integ/src/test/java/org/apache/directory/server/replication/
Date Sun, 29 May 2011 21:39:11 GMT
Author: kayyagari
Date: Sun May 29 21:39:10 2011
New Revision: 1128966

URL: http://svn.apache.org/viewvc?rev=1128966&view=rev
Log:
o changed some configuration options for handling cookie storage

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaDitStoreUtil.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaDitStoreUtil.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaDitStoreUtil.java?rev=1128966&r1=1128965&r2=1128966&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaDitStoreUtil.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicaDitStoreUtil.java
Sun May 29 21:39:10 2011
@@ -117,6 +117,7 @@ public class ReplicaDitStoreUtil
         entry.add( "ads-replSearchFilter", replica.getSearchFilter() );
 
         adminSession.add( entry );
+        LOG.debug( "stored replication consumer entry {}", entry.getDn() );
     }
 
 
@@ -145,8 +146,9 @@ public class ReplicaDitStoreUtil
             lastSentCsnAt.add( replica.getLastSentCsn() );
         }
 
-        Dn dn = new Dn( schemaManager, "ads-dsReplicaId=" + replica.getId() + "," + REPL_CONSUMER_DN
);
+        Dn dn = new Dn( schemaManager, "ads-replConsumerId=" + replica.getId() + "," + REPL_CONSUMER_DN
);
         adminSession.modify( dn, mods );
+        LOG.debug( "updated last sent CSN of consumer entry {}", dn );
     }
 
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java?rev=1128966&r1=1128965&r2=1128966&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
Sun May 29 21:39:10 2011
@@ -146,8 +146,6 @@ public class SyncReplConsumer implements
 
     private List<Modification> cookieModLst;
 
-    private Dn configEntryDn;
-
     private static AttributeType COOKIE_AT_TYPE;
 
 
@@ -187,8 +185,6 @@ public class SyncReplConsumer implements
         cookieModLst = new ArrayList<Modification>( 1 );
         cookieModLst.add( cookieMod );
 
-        configEntryDn = new Dn( schemaManager, config.getConfigEntryDn() );
-
         prepareSyncSearchRequest();
     }
 
@@ -217,7 +213,7 @@ public class SyncReplConsumer implements
             // Do a bind
             try
             {
-                connection.bind( config.getReplUserDn(), config.getReplUserPassword() );
+                connection.bind( config.getReplUserDn(), Strings.utf8ToString( config.getReplUserPassword()
) );
                 return true;
             }
             catch ( LdapException le )
@@ -661,7 +657,7 @@ public class SyncReplConsumer implements
                 attr.clear();
                 attr.add( syncCookie );
 
-                session.modify( configEntryDn, cookieModLst );
+                session.modify( config.getConfigEntryDn(), cookieModLst );
             }
 
             lastSavedCookie = new byte[syncCookie.length];
@@ -702,8 +698,7 @@ public class SyncReplConsumer implements
             {
                 try
                 {
-                    Entry entry = session.lookup( configEntryDn, new String[]
-                        { COOKIE_AT_TYPE.getName() } );
+                    Entry entry = session.lookup( config.getConfigEntryDn(), COOKIE_AT_TYPE.getName()
);
                     if ( entry != null )
                     {
                         Attribute attr = entry.get( COOKIE_AT_TYPE );
@@ -752,11 +747,11 @@ public class SyncReplConsumer implements
                     cookieAttr );
                 List<Modification> deleteModLst = new ArrayList<Modification>();
                 deleteModLst.add( deleteCookieMod );
-                session.modify( configEntryDn, deleteModLst );
+                session.modify( config.getConfigEntryDn(), deleteModLst );
             }
             catch ( Exception e )
             {
-                LOG.warn( "Failed to delete the cookie from the entry with Dn {}", configEntryDn
);
+                LOG.warn( "Failed to delete the cookie from the entry with Dn {}", config.getConfigEntryDn()
);
                 LOG.warn( "{}", e );
             }
         }

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java?rev=1128966&r1=1128965&r2=1128966&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
Sun May 29 21:39:10 2011
@@ -23,14 +23,15 @@ package org.apache.directory.server.ldap
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.net.ssl.X509TrustManager;
+
 import org.apache.directory.ldap.client.api.NoVerificationTrustManager;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.model.message.SearchScope;
+import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.util.Strings;
 
-import javax.net.ssl.X509TrustManager;
-
 
 /**
  * 
@@ -87,14 +88,7 @@ public class SyncreplConfiguration imple
     /** the replica's id */
     private int replicaId;
 
-    /** a flag to indicate to store the cookie in a file, default is false
-     *  NOTE: a value of true indicates that the cookie will be stored
-     *  on file system, which is useful while testing the consumer
-     *  without loading config partition
-     */
-    private boolean storeCookieInFile = false;
-
-    private static final String REPL_CONFIG_AREA = "ou=consumers,ou=system";
+    private Dn configEntryDn = null;
 
     /** flag to indicate whether to chase referrals or not, default is false hence passes
ManageDsaITControl with syncsearch request*/
     private boolean chaseReferrals = false;
@@ -176,18 +170,9 @@ public class SyncreplConfiguration imple
     /**
      * @return the replication user's password
      */
-    public String getReplUserPassword()
-    {
-        return Strings.utf8ToString(replUserPassword);
-    }
-
-
-    /**
-     * @param replUserPassword the replication user's password
-     */
-    public void setReplUserPassword( String replUserPassword )
+    public byte[] getReplUserPassword()
     {
-        setReplUserPassword( replUserPassword.getBytes() );
+        return replUserPassword;
     }
 
 
@@ -428,15 +413,14 @@ public class SyncreplConfiguration imple
     }
 
 
+    /** a flag to indicate to store the cookie in a file, default is false
+     *  NOTE: a value of true indicates that the cookie will be stored
+     *  on file system, which is useful while testing the consumer
+     *  without loading config partition
+     */
     public boolean isStoreCookieInFile()
     {
-        return storeCookieInFile;
-    }
-
-
-    public void setStoreCookieInFile( boolean storeCookieInFile )
-    {
-        this.storeCookieInFile = storeCookieInFile;
+        return ( configEntryDn == null );
     }
 
 
@@ -457,9 +441,9 @@ public class SyncreplConfiguration imple
     }
 
 
-    public String getConfigEntryDn()
+    public Dn getConfigEntryDn()
     {
-        return "ads-replConsumerId=" + replicaId + "," + REPL_CONFIG_AREA;
+        return configEntryDn;
     }
 
 
@@ -510,4 +494,13 @@ public class SyncreplConfiguration imple
     {
         return trustManager;
     }
+
+
+    /**
+     * @param configEntryDn the configEntryDn to set
+     */
+    public void setConfigEntryDn( Dn configEntryDn )
+    {
+        this.configEntryDn = configEntryDn;
+    }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java?rev=1128966&r1=1128965&r2=1128966&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
Sun May 29 21:39:10 2011
@@ -302,7 +302,7 @@ public class ClientServerReplicationIT
         consumerServer = ServerAnnotationProcessor.instantiateLdapServer( serverAnnotation,
provDirService, 0 );
         
         SyncReplConsumer syncreplClient = new SyncReplConsumer();
-        SyncreplConfiguration config = new SyncreplConfiguration();
+        final SyncreplConfiguration config = new SyncreplConfiguration();
         config.setProviderHost( "localhost" );
         config.setPort( 16000 );
         config.setReplUserDn( "uid=admin,ou=system" );
@@ -320,12 +320,34 @@ public class ClientServerReplicationIT
         
         Runnable r = new Runnable()
         {
-            
             public void run()
             {
                 try
                 {
                     consumerServer.start();
+                    DirectoryService ds = consumerServer.getDirectoryService();
+                    
+                    Dn configDn = new Dn( ds.getSchemaManager(), "ads-replProviderId=localhost,ou=system"
);
+                    config.setConfigEntryDn( configDn );
+                    
+                    Entry provConfigEntry = new DefaultEntry( ds.getSchemaManager(), configDn
);
+                    provConfigEntry.add( "objectClass", "ads-replProvider" );
+                    provConfigEntry.add( "ads-replProviderId", "localhost" );
+                    provConfigEntry.add( "ads-searchBaseDN", config.getBaseDn() );
+                    provConfigEntry.add( "ads-replProvHostName", config.getProviderHost()
);
+                    provConfigEntry.add( "ads-replProvPort", String.valueOf( config.getPort()
) );
+                    provConfigEntry.add( "ads-replAliasDerefMode", config.getAliasDerefMode().getJndiValue()
);
+                    provConfigEntry.add( "ads-replAttribute", config.getAttributes() );
+                    provConfigEntry.add( "ads-replRefreshInterval", String.valueOf( config.getRefreshInterval()
) );
+                    provConfigEntry.add( "ads-replRefreshNPersist", String.valueOf( config.isRefreshNPersist()
) );
+                    provConfigEntry.add( "ads-replSearchScope", config.getSearchScope().getLdapUrlValue()
);
+                    provConfigEntry.add( "ads-replSearchFilter", config.getFilter() );
+                    provConfigEntry.add( "ads-replSearchSizeLimit", String.valueOf( config.getSearchSizeLimit()
) );
+                    provConfigEntry.add( "ads-replSearchTimeOut", String.valueOf( config.getSearchTimeout()
) );
+                    provConfigEntry.add( "ads-replUserDn", config.getReplUserDn() );
+                    provConfigEntry.add( "ads-replUserPassword", config.getReplUserPassword()
);
+                    
+                    ds.getAdminSession().add( provConfigEntry );
                 }
                 catch( Exception e )
                 {



Mime
View raw message