directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1448166 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/api/ core-api/src/test/java/org/apache/directory/server/core/api/ core/src/main/java/org/apache/directory/server/core/ jdbm-partition/src/main/...
Date Wed, 20 Feb 2013 13:45:17 GMT
Author: elecharny
Date: Wed Feb 20 13:45:17 2013
New Revision: 1448166

URL: http://svn.apache.org/r1448166
Log:
o Exposed the lockWrite() and unlockWrite() methods in OperationManager
o Protected the backend in the syncWorker thred, by using the OperationManager lock, otherwise
we may have some concurrent modification in JDBM
o Flushed the JDBM journal in the sync() method, otherwise the *.db file remain empty.

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/OperationManager.java
    directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/api/MockOperationManager.java
    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/DefaultOperationManager.java
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/OperationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/OperationManager.java?rev=1448166&r1=1448165&r2=1448166&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/OperationManager.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/OperationManager.java
Wed Feb 20 13:45:17 2013
@@ -27,8 +27,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.interceptor.context.BindOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.CompareOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
-import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.GetRootDseOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext;
@@ -129,4 +129,16 @@ public interface OperationManager
      * TODO document after determining if this method should be here.
      */
     void unbind( UnbindOperationContext unbindContext ) throws LdapException;
+
+
+    /**
+     * Acquires a WriteLock
+     */
+    public void lockWrite();
+
+
+    /**
+     * Releases a WriteLock
+     */
+    public void unlockWrite();
 }

Modified: directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/api/MockOperationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/api/MockOperationManager.java?rev=1448166&r1=1448165&r2=1448166&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/api/MockOperationManager.java
(original)
+++ directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/api/MockOperationManager.java
Wed Feb 20 13:45:17 2013
@@ -22,15 +22,14 @@ package org.apache.directory.server.core
 
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.exception.LdapException;
-import org.apache.directory.server.core.api.OperationManager;
 import org.apache.directory.server.core.api.filtering.BaseEntryFilteringCursor;
 import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.BindOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.CompareOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
-import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.GetRootDseOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext;
@@ -121,4 +120,14 @@ public class MockOperationManager implem
     public void unbind( UnbindOperationContext unbindContext ) throws LdapException
     {
     }
+
+
+    public void lockWrite()
+    {
+    }
+
+
+    public void unlockWrite()
+    {
+    }
 }

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=1448166&r1=1448165&r2=1448166&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 Feb 20 13:45:17 2013
@@ -330,7 +330,10 @@ public class DefaultDirectoryService imp
 
                 try
                 {
+                    // Protect this section against concurrent access
+                    getOperationManager().lockWrite();
                     partitionNexus.sync();
+                    getOperationManager().unlockWrite();
                 }
                 catch ( Exception e )
                 {
@@ -1282,7 +1285,7 @@ public class DefaultDirectoryService imp
         // load the last stored valid CSN value
         LookupOperationContext loc = new LookupOperationContext( getAdminSession(), systemPartition.getSuffixDn(),
             SchemaConstants.ALL_ATTRIBUTES_ARRAY );
-        
+
         Entry entry = systemPartition.lookup( loc );
 
         Attribute cntextCsnAt = entry.get( SchemaConstants.CONTEXT_CSN_AT );
@@ -1813,9 +1816,9 @@ public class DefaultDirectoryService imp
         {
             LOG.debug( "---> Initializing the DefaultDirectoryService " );
         }
-        
+
         csnFactory.setReplicaId( replicaId );
-        
+
         // If no interceptor list is defined, setup a default list
         if ( interceptors == null )
         {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java?rev=1448166&r1=1448165&r2=1448166&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
Wed Feb 20 13:45:17 2013
@@ -107,27 +107,27 @@ public class DefaultOperationManager imp
     /**
      * Acquires a WriteLock
      */
-    private void lockWrite()
+    public void lockWrite()
     {
         rwLock.writeLock().lock();
     }
 
 
     /**
-     * Releases a ReadLock
+     * Releases a WriteLock
      */
-    private void unlockRead()
+    public void unlockWrite()
     {
-        rwLock.readLock().unlock();
+        rwLock.writeLock().unlock();
     }
 
 
     /**
-     * Releases a WriteLock
+     * Releases a ReadLock
      */
-    private void unlockWrite()
+    private void unlockRead()
     {
-        rwLock.writeLock().unlock();
+        rwLock.readLock().unlock();
     }
 
 
@@ -342,7 +342,7 @@ public class DefaultOperationManager imp
             {
                 Entry parentEntry = directoryService.getReferralManager().getParentReferral(
dn );
                 Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-    
+
                 // Depending on the Context.REFERRAL property value, we will throw
                 // a different exception.
                 if ( addContext.isReferralIgnored() )
@@ -362,7 +362,7 @@ public class DefaultOperationManager imp
             // Unlock the referral manager
             directoryService.getReferralManager().unlock();
         }
-            
+
         // Call the Add method
         Interceptor head = directoryService.getInterceptor( addContext.getNextInterceptor()
);
 
@@ -440,12 +440,12 @@ public class DefaultOperationManager imp
         {
             // Check if we have an ancestor for this Dn
             Entry parentEntry = directoryService.getReferralManager().getParentReferral(
dn );
-    
+
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
                 Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-    
+
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
                     // This is a referral. We can delete it if the ManageDsaIt flag is true
@@ -531,12 +531,12 @@ public class DefaultOperationManager imp
         try
         {
             Entry parentEntry = directoryService.getReferralManager().getParentReferral(
dn );
-    
+
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
                 Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-    
+
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
                     // This is a referral. We can delete it if the ManageDsaIt flag is true
@@ -551,7 +551,7 @@ public class DefaultOperationManager imp
                 else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
                 {
                     // We can't delete an entry which has an ancestor referral
-    
+
                     // Depending on the Context.REFERRAL property value, we will throw
                     // a different exception.
                     if ( deleteContext.isReferralIgnored() )
@@ -721,7 +721,7 @@ public class DefaultOperationManager imp
         {
             // Check if we have an ancestor for this Dn
             Entry parentEntry = referralManager.getParentReferral( dn );
-    
+
             if ( parentEntry != null )
             {
                 if ( referralManager.isReferral( dn ) )
@@ -733,7 +733,7 @@ public class DefaultOperationManager imp
                         // Throw a Referral Exception
                         // We have found a parent referral for the current Dn
                         Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-    
+
                         LdapReferralException exception = buildReferralException( parentEntry,
childDn );
                         throw exception;
                     }
@@ -741,14 +741,14 @@ public class DefaultOperationManager imp
                 else if ( referralManager.hasParentReferral( dn ) )
                 {
                     // We can't delete an entry which has an ancestor referral
-    
+
                     // Depending on the Context.REFERRAL property value, we will throw
                     // a different exception.
                     if ( modifyContext.isReferralIgnored() )
                     {
                         // We have found a parent referral for the current Dn
                         Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-    
+
                         LdapPartialResultException exception = buildLdapPartialResultException(
childDn );
                         throw exception;
                     }
@@ -756,7 +756,7 @@ public class DefaultOperationManager imp
                     {
                         // We have found a parent referral for the current Dn
                         Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-    
+
                         LdapReferralException exception = buildReferralException( parentEntry,
childDn );
                         throw exception;
                     }
@@ -822,12 +822,12 @@ public class DefaultOperationManager imp
         {
             // Check if we have an ancestor for this Dn
             Entry parentEntry = directoryService.getReferralManager().getParentReferral(
dn );
-    
+
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
                 Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-    
+
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
                     // This is a referral. We can delete it if the ManageDsaIt flag is true
@@ -842,7 +842,7 @@ public class DefaultOperationManager imp
                 else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
                 {
                     // We can't delete an entry which has an ancestor referral
-    
+
                     // Depending on the Context.REFERRAL property value, we will throw
                     // a different exception.
                     if ( moveContext.isReferralIgnored() )
@@ -857,7 +857,7 @@ public class DefaultOperationManager imp
                     }
                 }
             }
-            
+
             // Now, check the destination
             // If he parent Dn is a referral, or has a referral ancestor, we have to issue
a AffectMultipleDsas result
             // as stated by RFC 3296 Section 5.6.2
@@ -927,12 +927,12 @@ public class DefaultOperationManager imp
         {
             // Check if we have an ancestor for this Dn
             Entry parentEntry = directoryService.getReferralManager().getParentReferral(
dn );
-    
+
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
                 Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-    
+
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
                     // This is a referral. We can delete it if the ManageDsaIt flag is true
@@ -947,7 +947,7 @@ public class DefaultOperationManager imp
                 else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
                 {
                     // We can't delete an entry which has an ancestor referral
-    
+
                     // Depending on the Context.REFERRAL property value, we will throw
                     // a different exception.
                     if ( moveAndRenameContext.isReferralIgnored() )
@@ -967,7 +967,7 @@ public class DefaultOperationManager imp
             // Normalize the moveAndRenameContext Dn
             Dn newSuperiorDn = moveAndRenameContext.getNewSuperiorDn();
             newSuperiorDn.apply( directoryService.getSchemaManager() );
-    
+
             // If he parent Dn is a referral, or has a referral ancestor, we have to issue
a AffectMultipleDsas result
             // as stated by RFC 3296 Section 5.6.2
             if ( directoryService.getReferralManager().isReferral( newSuperiorDn )
@@ -977,7 +977,7 @@ public class DefaultOperationManager imp
                 // as stated by RFC 3296 Section 5.6.2
                 LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
                 //exception.setRemainingName( dn );
-    
+
                 throw exception;
             }
         }
@@ -1045,12 +1045,12 @@ public class DefaultOperationManager imp
         {
             // Check if we have an ancestor for this Dn
             Entry parentEntry = directoryService.getReferralManager().getParentReferral(
dn );
-    
+
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
                 Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-    
+
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
                     // This is a referral. We can delete it if the ManageDsaIt flag is true
@@ -1065,7 +1065,7 @@ public class DefaultOperationManager imp
                 else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
                 {
                     // We can't delete an entry which has an ancestor referral
-    
+
                     // Depending on the Context.REFERRAL property value, we will throw
                     // a different exception.
                     if ( renameContext.isReferralIgnored() )
@@ -1141,12 +1141,12 @@ public class DefaultOperationManager imp
         {
             // Check if we have an ancestor for this Dn
             Entry parentEntry = directoryService.getReferralManager().getParentReferral(
dn );
-    
+
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
                 Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-    
+
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
                     // This is a referral. We can return it if the ManageDsaIt flag is true
@@ -1162,7 +1162,7 @@ public class DefaultOperationManager imp
                 else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
                 {
                     // We can't search an entry which has an ancestor referral
-    
+
                     // Depending on the Context.REFERRAL property value, we will throw
                     // a different exception.
                     if ( searchContext.isReferralIgnored() )

Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=1448166&r1=1448165&r2=1448166&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
(original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
Wed Feb 20 13:45:17 2013
@@ -680,6 +680,19 @@ public class JdbmIndex<K, V> extends Abs
     public synchronized void sync() throws IOException
     {
         commit( recMan );
+
+        BaseRecordManager baseRecordManager = null;
+
+        if ( recMan instanceof CacheRecordManager )
+        {
+            baseRecordManager = ( ( BaseRecordManager ) ( ( CacheRecordManager ) recMan ).getRecordManager()
);
+        }
+        else
+        {
+            baseRecordManager = ( ( BaseRecordManager ) recMan );
+        }
+
+        baseRecordManager.getTransactionManager().synchronizeLog();
     }
 
 

Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=1448166&r1=1448165&r2=1448166&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
(original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
Wed Feb 20 13:45:17 2013
@@ -320,6 +320,12 @@ public class JdbmPartition extends Abstr
 
         ( ( JdbmMasterTable ) master ).sync();
         recMan.commit();
+
+        if ( recMan instanceof CacheRecordManager )
+        {
+            ( ( BaseRecordManager ) ( ( CacheRecordManager ) recMan ).getRecordManager()
).getTransactionManager()
+                .synchronizeLog();
+        }
     }
 
 



Mime
View raw message