Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 29883 invoked from network); 4 Nov 2010 13:44:58 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 4 Nov 2010 13:44:58 -0000 Received: (qmail 87600 invoked by uid 500); 4 Nov 2010 13:45:29 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 87488 invoked by uid 500); 4 Nov 2010 13:45:27 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 87481 invoked by uid 99); 4 Nov 2010 13:45:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Nov 2010 13:45:26 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.214.178] (HELO mail-iw0-f178.google.com) (209.85.214.178) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Nov 2010 13:45:18 +0000 Received: by iwn1 with SMTP id 1so1613016iwn.37 for ; Thu, 04 Nov 2010 06:44:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.35.138 with SMTP id p10mr502818ibd.33.1288878295756; Thu, 04 Nov 2010 06:44:55 -0700 (PDT) Sender: mail@stefan-seelmann.de Received: by 10.231.39.198 with HTTP; Thu, 4 Nov 2010 06:44:55 -0700 (PDT) In-Reply-To: <4CD2B379.7030401@gmail.com> References: <4CD2B379.7030401@gmail.com> Date: Thu, 4 Nov 2010 14:44:55 +0100 X-Google-Sender-Auth: o9exrrLmm81d3GYdBXK6SaY9jOU Message-ID: Subject: Re: Entries in write operation contexts From: Stefan Seelmann To: Apache Directory Developers List Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Nov 4, 2010 at 2:22 PM, Emmanuel Lecharny wrote: > On 11/4/10 2:02 PM, Stefan Seelmann wrote: >> >> Hi devs, > > Hi Stefan, >> >> I'm trying to solve DIRSERVER-1579 and stumble across the various >> entries that exist in the operation contexts: >> >> 1) AbstractOperationContext.getOriginalEntry() >> That's the original entry as stored in the backend, must not be modified >> >> 2) AbstractOperationContext.getEntry() >> That's a clone of the original entry, or the entry of the add >> operation, should be used >> >> 3) AbstractChangeOperationContext.getModifiedEntry() >> This is used by move, moveAndRename and rename operations, but not >> consistently, see below. I'd suggest to get rid of that entry and use >> the cloned entry instead. >> >> 4) ModifyContext.getAlteredEntry() >> The altered entry is set by the backend and is used by interceptors >> *after* the modification was applied. > > So far, so good. The getModifiedEntry is important, as it's the one that > contains the operational attributes we want to inject into the backend when > doing a add, modify, rename or move operation. The getModifedEntry() is only used by rename and move operations. The add and modify operations use getEntry() > The AlteredEntry is used in some cases, when there are some action done > after the injection of the entry in the backend. Not sure it's really > usefull, we could be able to use the modified entry at this point. To be > checked. Right, and that's ok. >> The interceptors that modify an incoming write operation use different >> entries, lets take the OperationalAttributeInterceptor for example: >> - add: puts operational attributes to the *cloned* entry >> - modify: puts operational attributes to the *list of modifications* >> - rename: puts operational attributes to the *cloned* entry >> - move: puts operational attributes to the *modified* entry >> - moveAndRename: puts operational attributes to the *modified* entry >> >> As said above, I'd suggest to get rid of the modifiedEntry and use the >> clonedEntry for move and moveAndRename operations. > > I think that cloned and modified entry are the same, or should be the same. > I remember when I reviewed the operations 6 months ago, and improved there > performance, I faced such an issue, but wasn't able to fix it. May be it's > time for a better solution now. Yes, but in the OperationContext classes there are two fields. >> A further idea, to make the code more consistent is to change the way >> how the modify operation works: Instead of adding additional modify >> operations to the list we can also use the cloned entry and maintain >> additional attributes there (operational attributes, derived keys). >> That's the way how rename/move/moveAndRename operations handle the >> change of operational attributes, why not use the same approach for >> the modify operation? > > Not sure I completely get what you are suggesting. Can you provide a simple > example on a very basic entry ? For a modify request the modifed operational attributes are added to the modification items. For example such a modify request dn: cn=someentry changetype: modify add: description description: blah blub - is extended by the OperationalAttributeInterceptor dn: cn=someentry changetype: modify add: description description: blah blub - replace: modifyTimestamp modifyTimestams: 19700101000000Z - replace: modifiersName modifiersName: uid=admin,ou=system - and in the backend the operational attributes are set to the enty (which is loaded from the backend) and stored to the backend. So in the backend we - load entry from disk - apply modifications (including operational attributes added by interceptors) - save entry to disk In contrast, for the rename and move operations there are no modification items that can be used to set operational attributes in the interceptor chain. Instead the clonedEntry / modifiedEntry is used to set the operational attributes. In the backend this cloned entry is used to apply the rename/move operation. So in the backend we - use the entry from operation context (which includes updated operational attributes) - apply modifications - save entry to disk So my idea here is to also use the 2nd approach for the modify operation. Kind Regards, Stefan