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 2011/07/05 11:26:41 UTC
svn commit: r1142939 - in /directory/apacheds/trunk:
jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
xdbm-partition/src/ma...
Author: elecharny
Date: Tue Jul 5 09:26:41 2011
New Revision: 1142939
URL: http://svn.apache.org/viewvc?rev=1142939&view=rev
Log:
o Factorised the Store.destroy() method into a common method in the AbstractStore class
o Removed the useless rename/move methods which take no Entry parameter in Store
Modified:
directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java
directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=1142939&r1=1142938&r2=1142939&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Tue Jul 5 09:26:41 2011
@@ -180,50 +180,27 @@ public class JdbmStore<E> extends Abstra
/**
- * Close the partition : we have to close all the userIndices and the master table.
- *
- * @throws Exception lazily thrown on any closer failures to avoid leaving
- * open files
+ * {@inheritDoc}
*/
public synchronized void destroy() throws Exception
{
- LOG.debug( "destroy() called on store for {}", this.suffixDn );
+ MultiException errors = new MultiException( I18n.err( I18n.ERR_577 ) );
if ( !initialized )
{
return;
}
-
- List<Index<?, E, Long>> array = new ArrayList<Index<?, E, Long>>();
- array.addAll( userIndices.values() );
- array.addAll( systemIndices.values() );
- MultiException errors = new MultiException( I18n.err( I18n.ERR_577 ) );
-
- for ( Index<?, E, Long> index : array )
- {
- try
- {
- index.close();
- LOG.debug( "Closed {} index for {} partition.", index.getAttributeId(), suffixDn );
- }
- catch ( Throwable t )
- {
- LOG.error( I18n.err( I18n.ERR_124 ), t );
- errors.addThrowable( t );
- }
- }
-
+
try
{
- master.close();
- LOG.debug( I18n.err( I18n.ERR_125, suffixDn ) );
+ super.destroy();
}
- catch ( Throwable t )
+ catch ( Exception e )
{
- LOG.error( I18n.err( I18n.ERR_126 ), t );
- errors.addThrowable( t );
+ errors.addThrowable( e );
}
+ // This is specific to the JDBM store : close the record manager
try
{
recMan.close();
@@ -239,8 +216,6 @@ public class JdbmStore<E> extends Abstra
{
throw errors;
}
-
- initialized = false;
}
Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1142939&r1=1142938&r2=1142939&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Tue Jul 5 09:26:41 2011
@@ -713,7 +713,7 @@ public class JdbmStoreTest
Rdn rdn = new Rdn( "sn=James" );
- store.rename( dn, rdn, true );
+ store.rename( dn, rdn, true, null );
}
@@ -732,7 +732,7 @@ public class JdbmStoreTest
Rdn rdn = new Rdn( "sn=Ja\\+es" );
- store.rename( dn, rdn, true );
+ store.rename( dn, rdn, true, null );
Dn dn2 = new Dn( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." );
Long id = store.getEntryId( dn2 );
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java?rev=1142939&r1=1142938&r2=1142939&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java Tue Jul 5 09:26:41 2011
@@ -374,7 +374,7 @@ public abstract class AbstractXdbmPartit
}
else
{
- store.rename( oldDn, newRdn, deleteOldRdn );
+ store.rename( oldDn, newRdn, deleteOldRdn, null );
}
}
catch ( Exception e )
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=1142939&r1=1142938&r2=1142939&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java Tue Jul 5 09:26:41 2011
@@ -54,6 +54,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.schema.AttributeType;
import org.apache.directory.shared.ldap.model.schema.MatchingRule;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.util.exception.MultiException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -154,8 +155,8 @@ public abstract class AbstractStore<E, I
ALIASED_OBJECT_NAME_AT = schemaManager.getAttributeType( SchemaConstants.ALIASED_OBJECT_NAME_AT );
ENTRY_CSN_AT = schemaManager.getAttributeType( SchemaConstants.ENTRY_CSN_AT );
ENTRY_UUID_AT = schemaManager.getAttributeType( SchemaConstants.ENTRY_UUID_AT );
-
}
+
protected void protect( String property )
{
@@ -218,6 +219,9 @@ public abstract class AbstractStore<E, I
}
+ /**
+ * {@inheritDoc}
+ */
public String getId()
{
return id;
@@ -1292,15 +1296,6 @@ public abstract class AbstractStore<E, I
/**
* {@inheritDoc}
*/
- public synchronized void rename( Dn dn, Rdn newRdn, boolean deleteOldRdn ) throws Exception
- {
- rename( dn, newRdn, deleteOldRdn, null );
- }
-
-
- /**
- * {@inheritDoc}
- */
public synchronized void moveAndRename( Dn oldDn, Dn newSuperiorDn, Rdn newRdn, Entry modifiedEntry, boolean deleteOldRdn ) throws Exception
{
// Check that the old entry exists
@@ -1352,15 +1347,6 @@ public abstract class AbstractStore<E, I
/**
* {@inheritDoc}
*/
- public synchronized void move( Dn oldDn, Dn newSuperiorDn, Dn newDn ) throws Exception
- {
- move( oldDn, newSuperiorDn, newDn, null );
- }
-
-
- /**
- * {@inheritDoc}
- */
public synchronized void move( Dn oldDn, Dn newSuperiorDn, Dn newDn, Entry modifiedEntry ) throws Exception
{
// Check that the parent Dn exists
@@ -2170,5 +2156,67 @@ public abstract class AbstractStore<E, I
{
this.checkHasEntryDuringAdd = checkHasEntryDuringAdd;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public void destroy() throws LdapException, Exception
+ {
+ LOG.debug( "destroy() called on store for {}", this.suffixDn );
+
+ if ( !initialized )
+ {
+ return;
+ }
+
+ // don't reset initialized flag
+ initialized = false;
+
+ MultiException errors = new MultiException( I18n.err( I18n.ERR_577 ) );
+
+ for ( Index<?, E, ID> index : userIndices.values() )
+ {
+ try
+ {
+ index.close();
+ LOG.debug( "Closed {} user index for {} partition.", index.getAttributeId(), suffixDn );
+ }
+ catch ( Throwable t )
+ {
+ LOG.error( I18n.err( I18n.ERR_124 ), t );
+ errors.addThrowable( t );
+ }
+ }
+
+ for ( Index<?, E, ID> index : systemIndices.values() )
+ {
+ try
+ {
+ index.close();
+ LOG.debug( "Closed {} system index for {} partition.", index.getAttributeId(), suffixDn );
+ }
+ catch ( Throwable t )
+ {
+ LOG.error( I18n.err( I18n.ERR_124 ), t );
+ errors.addThrowable( t );
+ }
+ }
+
+ try
+ {
+ master.close();
+ LOG.debug( I18n.err( I18n.ERR_125, suffixDn ) );
+ }
+ catch ( Throwable t )
+ {
+ LOG.error( I18n.err( I18n.ERR_126 ), t );
+ errors.addThrowable( t );
+ }
+
+ if ( errors.size() > 0 )
+ {
+ throw errors;
+ }
+ }
}
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=1142939&r1=1142938&r2=1142939&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java Tue Jul 5 09:26:41 2011
@@ -33,6 +33,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.entry.Entry;
import org.apache.directory.shared.ldap.model.entry.Modification;
import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.name.Dn;
import org.apache.directory.shared.ldap.model.name.Rdn;
import org.apache.directory.shared.ldap.model.schema.AttributeType;
@@ -91,29 +92,21 @@ public interface Store<E, ID extends Com
* Partition (store with search capabilities) when it just needs a simple
* store and it's indices to conduct search operations.
*/
-
public static final String[] SYS_INDEX_OID_ARRAY =
- { ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID,
-
- ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID,
-
- ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID,
-
- ApacheSchemaConstants.APACHE_RDN_AT_OID,
-
- ApacheSchemaConstants.APACHE_N_DN_AT_OID,
-
- ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
-
- ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID,
-
- ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID,
-
- SchemaConstants.ENTRY_CSN_AT_OID,
-
- SchemaConstants.ENTRY_UUID_AT_OID,
-
- SchemaConstants.OBJECT_CLASS_AT_OID };
+ {
+ ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID,
+ ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID,
+ ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID,
+ ApacheSchemaConstants.APACHE_RDN_AT_OID,
+ ApacheSchemaConstants.APACHE_N_DN_AT_OID,
+ ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
+ ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID,
+ ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID,
+ SchemaConstants.ENTRY_CSN_AT_OID,
+ SchemaConstants.ENTRY_UUID_AT_OID,
+ SchemaConstants.OBJECT_CLASS_AT_OID
+ };
+
public static final Set<String> SYS_INDEX_OIDS = Collections.unmodifiableSet( new HashSet<String>( Arrays
.asList( SYS_INDEX_OID_ARRAY ) ) );
@@ -214,12 +207,12 @@ public interface Store<E, ID extends Com
/**
- * Close the store : we have to close all the userIndices and the master table.
+ * Close the store : we have to close all the system and user Indices, plus the master table.
*
- * @throws Exception lazily thrown on any closer failures to avoid leaving
+ * @throws LdapException lazily thrown on any closer failures to avoid leaving
* open files
*/
- void destroy() throws Exception;
+ void destroy() throws LdapException, Exception;
/**
@@ -562,25 +555,6 @@ public interface Store<E, ID extends Com
*/
void rename( Dn dn, Rdn newRdn, boolean deleteOldRdn, Entry entry ) throws Exception;
-
- /**
- * Changes the relative distinguished name of an entry specified by a
- * distinguished name with the optional removal of the old Rdn attribute
- * value from the entry. Name changes propagate down as dn changes to the
- * descendants of the entry where the Rdn changed.
- *
- * An Rdn change operation does not change parent child relationships. It
- * merely propagates a name change at a point in the DIT where the Rdn is
- * changed. The change propagates down the subtree rooted at the
- * distinguished name specified.
- *
- * @param dn the normalized distinguished name of the entry to alter
- * @param newRdn the new Rdn to set
- * @param deleteOldRdn whether or not to remove the old Rdn attr/val
- * @throws Exception if there are any errors propagating the name changes
- */
- void rename( Dn dn, Rdn newRdn, boolean deleteOldRdn ) throws Exception;
-
void moveAndRename( Dn oldChildDn, Dn newParentDn, Rdn newRdn, Entry entry, boolean deleteOldRdn ) throws Exception;
@@ -612,38 +586,6 @@ public interface Store<E, ID extends Com
* @param oldDn The previous entry Dn
* @param newSuperior The new superior Dn
* @param newDn The new Dn
- * @throws Exception If the move failed
- */
- void move( Dn oldDn, Dn newSuperior, Dn newDn ) throws Exception;
-
-
- /**
- * <p>Move an entry from one place to the other. The Rdn remains unchanged,
- * the parent Dn changes</p>
- * <p>We have to update some of the index when moving an entry. Assuming
- * that the target destination does not exist, the following index must
- * be updated :</p>
- * <ul>
- * <li><b>oneLevel</b> index</li>
- * <li><b>subLevel</b> index</li>
- * </ul>
- * <p>If the moved entry is an alias, then we also have to update the
- * following index :</p>
- * <ul>
- * <li><b>oneAlias</b> index</li>
- * <li><b>subAlias</b> index</li>
- * </ul>
- * <p>The <b>Alias</b> index is not updated, as the entry ID won't change.</p>
- * <p>We have a few check we must do before moving the entry :
- * <ul>
- * <li>The destination must not exist
- * <li>The moved entry must exist (this has already been checked)
- * <li>The moved entry must not inherit from a referral (already checked)
- * </ul>
- *
- * @param oldDn The previous entry Dn
- * @param newSuperior The new superior Dn
- * @param newDn The new Dn
* @param entry The entry to move
* @throws Exception If the move failed
*/
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java?rev=1142939&r1=1142938&r2=1142939&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java Tue Jul 5 09:26:41 2011
@@ -46,32 +46,6 @@ public class AvlStore<E> extends Abstrac
/** static logger */
private static final Logger LOG = LoggerFactory.getLogger( AvlStore.class );
-
- /**
- * {@inheritDoc}
- */
- public void destroy() throws Exception
- {
- // don't reset initialized flag
- initialized = false;
-
- if ( master != null )
- {
- master.close();
- }
-
- for ( Index idx : systemIndices.values() )
- {
- idx.close();
- }
-
- for ( Index idx : userIndices.values() )
- {
- idx.close();
- }
- }
-
-
/**
* {@inheritDoc}
* TODO why this and initRegistries on Store interface ???
@@ -173,5 +147,4 @@ public class AvlStore<E> extends Abstrac
{
return 0L;
}
-
}
Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java?rev=1142939&r1=1142938&r2=1142939&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java Tue Jul 5 09:26:41 2011
@@ -388,7 +388,7 @@ public class AbstractStoreTest
// move
Dn newSuperior = new Dn( schemaManager, "o=Good Times Co." );
Dn newDn = new Dn( schemaManager, "cn=user,o=Good Times Co." );
- store.move( dn, newSuperior, newDn );
+ store.move( dn, newSuperior, newDn, null );
entry = verifyParentId( newDn );
// move and rename
Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java?rev=1142939&r1=1142938&r2=1142939&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java Tue Jul 5 09:26:41 2011
@@ -614,7 +614,7 @@ public class AvlStoreTest
Rdn rdn = new Rdn( "sn=James" );
- store.rename( dn, rdn, true );
+ store.rename( dn, rdn, true, null );
}
@@ -633,7 +633,7 @@ public class AvlStoreTest
Rdn rdn = new Rdn( "sn=Ja\\+es" );
- store.rename( dn, rdn, true );
+ store.rename( dn, rdn, true, null );
Dn dn2 = new Dn( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." );
Long id = store.getEntryId( dn2 );