Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 66790 invoked from network); 10 Jun 2010 14:30:12 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Jun 2010 14:30:12 -0000 Received: (qmail 50739 invoked by uid 500); 10 Jun 2010 14:30:12 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 50692 invoked by uid 500); 10 Jun 2010 14:30:12 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 50685 invoked by uid 99); 10 Jun 2010 14:30:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jun 2010 14:30:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jun 2010 14:30:08 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 603E523889CB; Thu, 10 Jun 2010 14:29:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r953333 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/interceptor/context/ core-integ/src/test/java/org/apache/directory/server/core/operations/move/ Date: Thu, 10 Jun 2010 14:29:25 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100610142925.603E523889CB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Thu Jun 10 14:29:24 2010 New Revision: 953333 URL: http://svn.apache.org/viewvc?rev=953333&view=rev Log: o Cleaned the OperationContext hierarchy, removing some duplicated methods o Added some asserts in the Move perftest Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/BindOperationContext.java directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MovePerfIT.java Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java?rev=953333&r1=953332&r2=953333&view=diff ============================================================================== --- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java (original) +++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java Thu Jun 10 14:29:24 2010 @@ -23,6 +23,7 @@ package org.apache.directory.server.core import org.apache.directory.server.core.CoreSession; import org.apache.directory.server.core.changelog.ChangeLogEvent; import org.apache.directory.server.core.changelog.LogChange; +import org.apache.directory.shared.ldap.entry.Entry; import org.apache.directory.shared.ldap.name.DN; @@ -33,18 +34,34 @@ import org.apache.directory.shared.ldap. */ public abstract class AbstractChangeOperationContext extends AbstractOperationContext implements ChangeOperationContext { + /** The ChangeLog event */ private ChangeLogEvent changeLogEvent; - /** The flag used to tell the server to store the change sinto the changeLog */ + /** The flag used to tell the server to store the changes into the changeLog */ protected LogChange logChange; + + /** The modified Entry as it will be stored into the backend */ + protected Entry modifiedEntry; + /** + * + * Creates a new instance of AbstractChangeOperationContext. + * + * @param session + */ public AbstractChangeOperationContext( CoreSession session ) { super( session ); } + /** + * + * Creates a new instance of AbstractChangeOperationContext. + * + * @param session + */ public AbstractChangeOperationContext( CoreSession session, DN dn ) { super( session, dn ); @@ -52,6 +69,24 @@ public abstract class AbstractChangeOper /** + * @return the modifiedEntry + */ + public Entry getModifiedEntry() + { + return modifiedEntry; + } + + + /** + * @param modifiedEntry the modifiedEntry to set + */ + public void setModifiedEntry( Entry modifiedEntry ) + { + this.modifiedEntry = modifiedEntry; + } + + + /** * @see org.apache.directory.server.core.interceptor.context.ChangeOperationContext#getChangeLogEvent() */ public ChangeLogEvent getChangeLogEvent() Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java?rev=953333&r1=953332&r2=953333&view=diff ============================================================================== --- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java (original) +++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java Thu Jun 10 14:29:24 2010 @@ -106,7 +106,7 @@ public abstract class AbstractOperationC } - protected void setSession( CoreSession session ) + public void setSession( CoreSession session ) { this.session = session; } Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/BindOperationContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/BindOperationContext.java?rev=953333&r1=953332&r2=953333&view=diff ============================================================================== --- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/BindOperationContext.java (original) +++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/BindOperationContext.java Thu Jun 10 14:29:24 2010 @@ -20,26 +20,13 @@ package org.apache.directory.server.core.interceptor.context; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.apache.commons.lang.NotImplementedException; import org.apache.directory.server.core.CoreSession; -import org.apache.directory.server.core.LdapPrincipal; import org.apache.directory.server.core.ReferralHandlingMode; -import org.apache.directory.server.core.entry.ClonedServerEntry; import org.apache.directory.server.i18n.I18n; import org.apache.directory.shared.ldap.codec.MessageTypeEnum; import org.apache.directory.shared.ldap.constants.AuthenticationLevel; -import org.apache.directory.shared.ldap.entry.Entry; -import org.apache.directory.shared.ldap.entry.Modification; import org.apache.directory.shared.ldap.exception.LdapAuthenticationException; -import org.apache.directory.shared.ldap.exception.LdapException; -import org.apache.directory.shared.ldap.message.control.Control; -import org.apache.directory.shared.ldap.name.DN; import org.apache.directory.shared.ldap.util.StringTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +38,7 @@ import org.slf4j.LoggerFactory; * * @author Apache Directory Project */ -public class BindOperationContext implements OperationContext +public class BindOperationContext extends AbstractOperationContext { /** A logger for this class */ private static final Logger LOG = LoggerFactory.getLogger( BindOperationContext.class ); @@ -65,42 +52,18 @@ public class BindOperationContext implem /** The SASL identifier */ private String saslAuthId; - private static final Control[] EMPTY_CONTROLS = new Control[0]; - - /** The DN associated with the context */ - private DN dn; - - /** The associated request's controls */ - private Map requestControls = new HashMap(4); - - /** The associated response's controls */ - private Map responseControls = new HashMap(4); - /** A flag to tell that this is a collateral operation */ private boolean collateralOperation; - /** the Interceptors bypassed by this operation */ - private Collection bypassed; - - private CoreSession session; - - private LdapPrincipal authorizedPrincipal; - - private OperationContext next; - - private OperationContext previous; - private ReferralHandlingMode referralHandlingMode; - private ClonedServerEntry entry; - /** * Creates a new instance of BindOperationContext. */ public BindOperationContext( CoreSession session ) { - this.session = session; + super( session ); } @@ -221,18 +184,6 @@ public class BindOperationContext implem } - public CoreSession getSession() - { - return session; - } - - - public void setSession( CoreSession session ) - { - this.session = session; - } - - /** * Tells if the current operation is considered a side effect of the * current context @@ -249,262 +200,6 @@ public class BindOperationContext implem } - /** - * @return The associated DN - */ - public DN getDn() - { - return dn; - } - - - /** - * Set the context DN - * - * @param dn The DN to set - */ - public void setDn( DN dn ) - { - this.dn = dn; - } - - - public void addRequestControl( Control requestControl ) - { - requestControls.put( requestControl.getOid(), requestControl ); - } - - - public Control getRequestControl( String numericOid ) - { - return requestControls.get( numericOid ); - } - - - public boolean hasRequestControl( String numericOid ) - { - return requestControls.containsKey( numericOid ); - } - - - public boolean hasRequestControls() - { - return ! requestControls.isEmpty(); - } - - - public void addResponseControl( Control responseControl ) - { - responseControls.put( responseControl.getOid(), responseControl ); - } - - - public Control getResponseControl( String numericOid ) - { - return responseControls.get( numericOid ); - } - - - public boolean hasResponseControl( String numericOid ) - { - return responseControls.containsKey( numericOid ); - } - - - public Control[] getResponseControls() - { - if ( responseControls.isEmpty() ) - { - return EMPTY_CONTROLS; - } - - return responseControls.values().toArray( EMPTY_CONTROLS ); - } - - - public boolean hasResponseControls() - { - return ! responseControls.isEmpty(); - } - - - public int getResponseControlCount() - { - return responseControls.size(); - } - - - public void addRequestControls( Control[] requestControls ) - { - for ( Control c : requestControls ) - { - this.requestControls.put( c.getOid(), c ); - } - } - - - /** - * Gets the set of bypassed Interceptors. - * - * @return the set of bypassed Interceptors - */ - public Collection getByPassed() - { - if ( bypassed == null ) - { - return Collections.emptyList(); - } - - return Collections.unmodifiableCollection( bypassed ); - } - - - /** - * Sets the set of bypassed Interceptors. - * - * @param byPassed the set of bypassed Interceptors - */ - public void setByPassed( Collection byPassed ) - { - this.bypassed = byPassed; - } - - - /** - * Checks to see if an Interceptor is bypassed for this operation. - * - * @param interceptorName the interceptorName of the Interceptor to check for bypass - * @return true if the Interceptor should be bypassed, false otherwise - */ - public boolean isBypassed( String interceptorName ) - { - return bypassed != null && bypassed.contains( interceptorName ); - } - - - /** - * Checks to see if any Interceptors are bypassed by this operation. - * - * @return true if at least one bypass exists - */ - public boolean hasBypass() - { - return bypassed != null && !bypassed.isEmpty(); - } - - - public LookupOperationContext newLookupContext( DN dn ) - { - return new LookupOperationContext( session, dn ); - } - - - public Entry lookup( LookupOperationContext opContext ) throws LdapException - { - return session.getDirectoryService().getOperationManager().lookup( opContext ); - } - - - public Entry lookup( DN dn, Collection byPassed ) throws LdapException - { - LookupOperationContext opContext = newLookupContext( dn ); - opContext.setByPassed( byPassed ); - return session.getDirectoryService().getOperationManager().lookup( opContext ); - } - - - public LdapPrincipal getEffectivePrincipal() - { - if ( authorizedPrincipal != null ) - { - return authorizedPrincipal; - } - - return session.getEffectivePrincipal(); - } - - - // ----------------------------------------------------------------------- - // OperationContext Linked List Methods - // ----------------------------------------------------------------------- - - - public boolean isFirstOperation() - { - return previous == null; - } - - - public OperationContext getFirstOperation() - { - if ( previous == null ) - { - return this; - } - - return previous.getFirstOperation(); - } - - - public OperationContext getLastOperation() - { - if ( next == null ) - { - return this; - } - - return next.getLastOperation(); - } - - - public OperationContext getNextOperation() - { - return next; - } - - - public OperationContext getPreviousOperation() - { - return previous; - } - - - public void add( Entry entry, Collection bypass ) throws LdapException - { - throw new NotImplementedException(); - } - - - public void delete( DN dn, Collection bypass ) throws LdapException - { - throw new NotImplementedException(); - } - - - public void modify( DN dn, List mods, Collection bypass ) throws LdapException - { - throw new NotImplementedException(); - } - - - private void setup( AbstractOperationContext opContext ) - { - opContext.setPreviousOperation( this ); - next = opContext; - opContext.setByPassed( opContext.getByPassed() ); - opContext.setAuthorizedPrincipal( authorizedPrincipal ); - } - - - public boolean hasEntry( DN dn, Collection byPassed ) throws LdapException - { - EntryOperationContext opContext = new EntryOperationContext( session, dn ); - setup( opContext ); - opContext.setByPassed( byPassed ); - return session.getDirectoryService().getOperationManager().hasEntry( opContext ); - } - - public ReferralHandlingMode getReferralHandlingMode() { return referralHandlingMode; @@ -517,18 +212,6 @@ public class BindOperationContext implem } - public ClonedServerEntry getEntry() - { - return entry; - } - - - public void setEntry( ClonedServerEntry entry ) - { - this.entry = entry; - } - - /** * {@inheritDoc} */ Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MovePerfIT.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MovePerfIT.java?rev=953333&r1=953332&r2=953333&view=diff ============================================================================== --- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MovePerfIT.java (original) +++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MovePerfIT.java Thu Jun 10 14:29:24 2010 @@ -19,11 +19,7 @@ */ package org.apache.directory.server.core.operations.move; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - import org.apache.directory.ldap.client.api.LdapConnection; -import org.apache.directory.ldap.client.api.message.SearchResponse; import org.apache.directory.server.core.annotations.ContextEntry; import org.apache.directory.server.core.annotations.CreateDS; import org.apache.directory.server.core.annotations.CreateIndex; @@ -114,11 +110,11 @@ public class MovePerfIT extends Abstract long ttt0 = System.nanoTime(); connection.move( oldDn, newSuperior ); - SearchResponse oldEntry = connection.lookup( oldDn ); - SearchResponse newEntry = connection.lookup( newDn ); + //SearchResponse oldEntry = connection.lookup( oldDn ); + //SearchResponse newEntry = connection.lookup( newDn ); - assertNull( oldEntry ); - assertNotNull( newEntry ); + //assertNull( oldEntry ); + //assertNotNull( newEntry ); long ttt1 = System.nanoTime(); // Swap the dn