Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C98029A91 for ; Fri, 18 Nov 2011 13:23:06 +0000 (UTC) Received: (qmail 34877 invoked by uid 500); 18 Nov 2011 13:23:06 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 34836 invoked by uid 500); 18 Nov 2011 13:23:06 -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 34829 invoked by uid 99); 18 Nov 2011 13:23:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Nov 2011 13:23:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Fri, 18 Nov 2011 13:23:01 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A044D2388993 for ; Fri, 18 Nov 2011 13:22:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1203640 [1/2] - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/api/partition/ core-api/src/main/java/org/apache/directory/server/core/api/txn/ core-api/src/main/java/org/apache/direct... Date: Fri, 18 Nov 2011 13:22:39 -0000 To: commits@directory.apache.org From: saya@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111118132241.A044D2388993@eris.apache.org> Author: saya Date: Fri Nov 18 13:22:37 2011 New Revision: 1203640 URL: http://svn.apache.org/viewvc?rev=1203640&view=rev Log: Changed DefaultSearchEngine to use transactionally wrapped indices, cursors and master tables. Also changed the search engine to use the Partition interface rather than the Store interface. Changed txn layer so that it takes into account the possibility of changes and search without txns. Changes search tests accordingly and they are still passing. Added some missing asl headers. TODO: time for putting the txn initialization code and some basic txn testing to see txns working top down. More coding after that. Added: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/OperationExecutionManagerFactory.java Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/OperationExecutionManager.java directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnManager.java directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/EntryModification.java directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/IndexModification.java directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryReplace.java directory/apacheds/branches/apacheds-txns/core-shared/src/test/java/org/apache/directory/server/core/shared/txn/DefaultTxnManagerTest.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LeafEvaluator.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java directory/apacheds/branches/apacheds-txns/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/OperationExecutionManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/OperationExecutionManager.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/OperationExecutionManager.java (original) +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/OperationExecutionManager.java Fri Nov 18 13:22:37 2011 @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ package org.apache.directory.server.core.api.partition; @@ -61,7 +80,7 @@ public interface OperationExecutionManag * @param addContext the context used to add and entry to this ContextPartition * @throws LdapException if there are any problems */ - public void add( Partition partition, AddOperationContext addContext ) throws LdapException; + void add( Partition partition, AddOperationContext addContext ) throws LdapException; /** @@ -73,7 +92,7 @@ public interface OperationExecutionManag * delete from this ContextPartition. * @throws Exception if there are any problems */ - public void delete( Partition partition, DeleteOperationContext deleteContext ) throws LdapException; + void delete( Partition partition, DeleteOperationContext deleteContext ) throws LdapException; /** @@ -83,7 +102,7 @@ public interface OperationExecutionManag * @param id The id of the entry to delete * @throws Exception If the deletion failed */ - public void delete( Partition partition, Dn entryDn, UUID id ) throws LdapException; + void delete( Partition partition, Dn entryDn, UUID id ) throws LdapException; /** @@ -97,10 +116,10 @@ public interface OperationExecutionManag * * @throws Exception if there are any problems */ - public void modify( Partition partition, ModifyOperationContext modifyContext ) throws LdapException; + void modify( Partition partition, ModifyOperationContext modifyContext ) throws LdapException; - public Entry modify( Partition partition, Dn dn, Modification... mods ) throws Exception; + Entry modify( Partition partition, Dn dn, Modification... mods ) throws Exception; /** @@ -113,7 +132,7 @@ public interface OperationExecutionManag * @param renameContext the modify Dn context * @throws Exception if there are any problems */ - public void rename( Partition partition, RenameOperationContext renameContext ) throws LdapException; + void rename( Partition partition, RenameOperationContext renameContext ) throws LdapException; /** @@ -135,7 +154,7 @@ public interface OperationExecutionManag * @param originalEntry entry to be renamed as read from the underlying partition * @throws Exception if there are any errors propagating the name changes */ - public void rename( Partition partition, Dn dn, Rdn newRdn, boolean deleteOldRdn, Entry entry, Entry originalEntry ) + void rename( Partition partition, Dn dn, Rdn newRdn, boolean deleteOldRdn, Entry entry, Entry originalEntry ) throws Exception; @@ -147,7 +166,7 @@ public interface OperationExecutionManag * @param moveContext The context containing the DNs to move * @throws Exception if there are any problems */ - public void move( Partition partition, MoveOperationContext moveContext ) throws LdapException; + void move( Partition partition, MoveOperationContext moveContext ) throws LdapException; /** @@ -182,7 +201,7 @@ public interface OperationExecutionManag * @param originalEntry entry to be moved. Version of the entry as read from the underlying partition. * @throws Exception If the move failed */ - public void move( Partition partition, Dn oldDn, Dn newSuperiorDn, Dn newDn, Entry modifiedEntry, + void move( Partition partition, Dn oldDn, Dn newSuperiorDn, Dn newDn, Entry modifiedEntry, Entry originalEntry ) throws Exception; @@ -199,11 +218,11 @@ public interface OperationExecutionManag * the modifyDN operation * @throws Exception if there are any problems */ - public void moveAndRename( Partition partition, MoveAndRenameOperationContext moveAndRenameContext ) + void moveAndRename( Partition partition, MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException; - public void moveAndRename( Partition partition, Dn oldDn, Dn newSuperiorDn, Rdn newRdn, Entry modifiedEntry, + void moveAndRename( Partition partition, Dn oldDn, Dn newSuperiorDn, Rdn newRdn, Entry modifiedEntry, Entry originalEntry, boolean deleteOldRdn ) throws Exception; @@ -220,7 +239,7 @@ public interface OperationExecutionManag * @return an Attributes object representing the entry * @throws Exception if there are any problems */ - public Entry lookup( Partition partition, LookupOperationContext lookupContext ) throws LdapException; + Entry lookup( Partition partition, LookupOperationContext lookupContext ) throws LdapException; /** @@ -231,6 +250,17 @@ public interface OperationExecutionManag * @return The found Entry, or null if not found * @throws Exception If the lookup failed for any reason (except a not found entry) */ - public Entry lookup( Partition partition, UUID id ) throws LdapException; + Entry lookup( Partition partition, UUID id ) throws LdapException; + + + /** + * Returns the entry id for the given dn + * + * @param partition partition the given dn corresponds to + * @param dn dn for which we want to get the id + * @return entry id + * @throws LdapException + */ + public UUID getEntryId( Partition partition, Dn dn ) throws LdapException; } Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java (original) +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java Fri Nov 18 13:22:37 2011 @@ -61,6 +61,9 @@ public interface Partition /** root ID common to all partitions */ UUID rootID = UUID.fromString( "00000000-0000-0000-0000-000000000000" ); + /** Default id used for context entry if context entry doesnt exists */ + UUID defaultID = UUID.fromString( "00000000-0000-0000-0000-000000000001" ); + // ----------------------------------------------------------------------- // C O N F I G U R A T I O N M E T H O D S // ----------------------------------------------------------------------- Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java (original) +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnLogManager.java Fri Nov 18 13:22:37 2011 @@ -47,7 +47,7 @@ public interface TxnLogManager * @param sync log edit will be flushed to media if set to true * @throws IOException */ - void log( LogEdit logEdit, boolean sync ) throws IOException; + void log( LogEdit logEdit, boolean sync ) throws Exception; /** @@ -55,9 +55,9 @@ public interface TxnLogManager * * @param logRecord log record to be logged * @param sync log edit will be flushed to media if set to true - * @throws IOException + * @throws Exception */ - void log( UserLogRecord logRecord, boolean sync ) throws IOException; + void log( UserLogRecord logRecord, boolean sync ) throws Exception; /** * Provide a transactionally consistent view on the entry identified Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnManager.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnManager.java (original) +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/TxnManager.java Fri Nov 18 13:22:37 2011 @@ -33,25 +33,25 @@ public interface TxnManager * Starts a new txn and associates it with the current thread. * * @param readOnly whether the txn is read only - * @throws IOException + * @throws Exception */ - void beginTransaction( boolean readOnly ) throws IOException; + void beginTransaction( boolean readOnly ) throws Exception; /** * Tries to commit the current txn associated with the current thread. ReadWrite txns have to be verified against txns * that committed after they started for any conflicting change and conflicting * exception is thrown if verificatin fails. * - * @throws IOException + * @throws Exception * @throws TxnConflictException */ - void commitTransaction() throws IOException, TxnConflictException; + void commitTransaction() throws Exception, TxnConflictException; /** * Aborts the current txn associated with the current thread. * - * @throws IOException + * @throws Exception */ - void abortTransaction() throws IOException; + void abortTransaction() throws Exception; } Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/EntryModification.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/EntryModification.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/EntryModification.java (original) +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/EntryModification.java Fri Nov 18 13:22:37 2011 @@ -1,4 +1,22 @@ - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ package org.apache.directory.server.core.api.txn.logedit; import java.util.UUID; Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/IndexModification.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/IndexModification.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/IndexModification.java (original) +++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/txn/logedit/IndexModification.java Fri Nov 18 13:22:37 2011 @@ -1,4 +1,22 @@ - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ package org.apache.directory.server.core.api.txn.logedit; import org.apache.directory.server.core.api.partition.Partition; Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultOperationExecutionManager.java Fri Nov 18 13:22:37 2011 @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ package org.apache.directory.server.core.shared.partition; @@ -15,6 +34,7 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext; import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext; import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext; +import org.apache.directory.server.core.api.partition.OperationExecutionManager; import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexCursor; @@ -22,6 +42,7 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.api.partition.index.MasterTable; import org.apache.directory.server.core.api.partition.index.ParentIdAndRdn; import org.apache.directory.server.core.api.txn.TxnLogManager; +import org.apache.directory.server.core.shared.txn.TxnManagerFactory; import org.apache.directory.server.core.shared.txn.logedit.DataChangeContainer; import org.apache.directory.server.core.shared.txn.logedit.EntryAddDelete; import org.apache.directory.server.core.shared.txn.logedit.EntryChange; @@ -55,13 +76,18 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.model.schema.UsageEnum; -public class DefaultOperationExecutionManager +public class DefaultOperationExecutionManager implements OperationExecutionManager { /** Txn log manager kept for fast access */ private TxnLogManager txnLogManager; + public DefaultOperationExecutionManager() + { + txnLogManager = TxnManagerFactory.txnLogManagerInstance(); + } + //--------------------------------------------------------------------------------------------- // The Add operation //--------------------------------------------------------------------------------------------- @@ -1719,15 +1745,10 @@ public class DefaultOperationExecutionMa // ID and DN operations //--------------------------------------------------------------------------------------------- /** - * Returns the entry id for the given dn - * - * @param partition partition the given dn corresponds to - * @param dn dn for which we want to get the id - * @return entry id - * @throws LdapException + * {@inheritDoc} */ @SuppressWarnings("unchecked") - private UUID getEntryId( Partition partition, Dn dn ) throws LdapException + public UUID getEntryId( Partition partition, Dn dn ) throws LdapException { try { Added: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/OperationExecutionManagerFactory.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/OperationExecutionManagerFactory.java?rev=1203640&view=auto ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/OperationExecutionManagerFactory.java (added) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/OperationExecutionManagerFactory.java Fri Nov 18 13:22:37 2011 @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.server.core.shared.partition; + +import org.apache.directory.server.core.api.partition.OperationExecutionManager; + +public class OperationExecutionManagerFactory +{ + /** Operation Manager instance */ + private static OperationExecutionManager executionManager; + + + public static void init() + { + executionManager = new DefaultOperationExecutionManager(); + } + + + public static OperationExecutionManager instance() + { + return executionManager; + } +} Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnLogManager.java Fri Nov 18 13:22:37 2011 @@ -38,6 +38,7 @@ import org.apache.directory.shared.ldap. import org.apache.directory.server.core.api.txn.TxnLogManager; import org.apache.directory.server.core.api.txn.logedit.LogEdit; +import org.apache.directory.server.core.shared.txn.logedit.DataChangeContainer; /** @@ -69,11 +70,21 @@ public class DefaultTxnLogManager implem /** * {@inheritDoc} */ - public void log( LogEdit logEdit, boolean sync ) throws IOException + public void log( LogEdit logEdit, boolean sync ) throws Exception { Transaction curTxn = txnManager.getCurTxn(); + + if ( curTxn == null ) + { + /* + * Txn is not initialized. This might happen if the change path does not use txn like during testing + * or bootstrap. In this case we should have some data change and we will apply them to the underyling + * partitions directly + */ + logEdit.apply( false ); + } - if ( ( curTxn == null ) || ( ! ( curTxn instanceof ReadWriteTxn ) ) ) + if ( ! ( curTxn instanceof ReadWriteTxn ) ) { throw new IllegalStateException( "Trying to log logedit without ReadWriteTxn" ); } @@ -118,7 +129,7 @@ public class DefaultTxnLogManager implem /** * {@inheritDoc} */ - public void log( UserLogRecord logRecord, boolean sync ) throws IOException + public void log( UserLogRecord logRecord, boolean sync ) throws Exception { try { @@ -152,6 +163,13 @@ public class DefaultTxnLogManager implem */ public IndexCursor wrap( Dn partitionDn, IndexCursor wrappedCursor, IndexComparator comparator, String attributeOid, boolean forwardIndex, Object onlyValueKey, UUID onlyIDKey ) throws Exception { + Transaction curTxn = txnManager.getCurTxn(); + + if ( ( curTxn == null ) ) + { + return wrappedCursor; + } + return new IndexCursorWrapper( partitionDn, wrappedCursor, comparator, attributeOid, forwardIndex, onlyValueKey, onlyIDKey ); } @@ -159,8 +177,16 @@ public class DefaultTxnLogManager implem /** * {@inheritDoc} */ + @SuppressWarnings("unchecked") public Index wrap( Dn partitionDn, Index wrappedIndex ) throws Exception { + Transaction curTxn = txnManager.getCurTxn(); + + if ( ( curTxn == null ) ) + { + return ( Index )wrappedIndex; + } + return new IndexWrapper( partitionDn, ( Index ) wrappedIndex ); } @@ -170,6 +196,13 @@ public class DefaultTxnLogManager implem */ public MasterTable wrap( Dn partitionDn, MasterTable wrappedTable ) throws Exception { + Transaction curTxn = txnManager.getCurTxn(); + + if ( ( curTxn == null ) ) + { + return wrappedTable; + } + return new MasterTableWrapper( partitionDn, wrappedTable ); } @@ -198,7 +231,8 @@ public class DefaultTxnLogManager implem if ( ( curTxn == null ) ) { - throw new IllegalStateException( "Trying to add dn set wihout txn" ); + // NO txn, return without doing anything. + return; } // No need to do anything for read only txns Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/DefaultTxnManager.java Fri Nov 18 13:22:37 2011 @@ -100,7 +100,7 @@ class DefaultTxnManager implements TxnMa /** * {@inheritDoc} */ - public void beginTransaction( boolean readOnly ) throws IOException + public void beginTransaction( boolean readOnly ) throws Exception { Transaction curTxn = getCurTxn(); @@ -124,7 +124,7 @@ class DefaultTxnManager implements TxnMa /** * {@inheritDoc} */ - public void commitTransaction() throws IOException, TxnConflictException + public void commitTransaction() throws Exception, TxnConflictException { Transaction txn = getCurTxn(); @@ -151,7 +151,7 @@ class DefaultTxnManager implements TxnMa /** * {@inheritDoc} */ - public void abortTransaction() throws IOException + public void abortTransaction() throws Exception { Transaction txn = getCurTxn(); @@ -242,7 +242,7 @@ class DefaultTxnManager implements TxnMa * into the txn log and the lsn of that log record is the * start time. */ - private void beginReadWriteTxn() throws IOException + private void beginReadWriteTxn() throws Exception { ReadWriteTxn txn = new ReadWriteTxn(); @@ -443,10 +443,10 @@ class DefaultTxnManager implements TxnMa * committed yet as its commit record might not have made it to the underlying media but this is OK as rw3 cannot commit before rw1 because of the log. * * @param txn txn to commit. - * @throws IOException + * @throws Exception * @throws TxnConflictException */ - private void commitReadWriteTxn( ReadWriteTxn txn ) throws IOException, TxnConflictException + private void commitReadWriteTxn( ReadWriteTxn txn ) throws Exception, TxnConflictException { UserLogRecord logRecord = txn.getUserLogRecord(); @@ -531,7 +531,7 @@ class DefaultTxnManager implements TxnMa * @param txn txn to abort * @throws IOException */ - private void abortReadWriteTxn( ReadWriteTxn txn ) throws IOException + private void abortReadWriteTxn( ReadWriteTxn txn ) throws Exception { UserLogRecord logRecord = txn.getUserLogRecord(); Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryReplace.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryReplace.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryReplace.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryReplace.java Fri Nov 18 13:22:37 2011 @@ -1,4 +1,22 @@ - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ package org.apache.directory.server.core.shared.txn.logedit; import java.io.IOException; Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/test/java/org/apache/directory/server/core/shared/txn/DefaultTxnManagerTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/test/java/org/apache/directory/server/core/shared/txn/DefaultTxnManagerTest.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/core-shared/src/test/java/org/apache/directory/server/core/shared/txn/DefaultTxnManagerTest.java (original) +++ directory/apacheds/branches/apacheds-txns/core-shared/src/test/java/org/apache/directory/server/core/shared/txn/DefaultTxnManagerTest.java Fri Nov 18 13:22:37 2011 @@ -89,7 +89,7 @@ public class DefaultTxnManagerTest @Test - public void testBeginCommitReadOnlyTxn() throws IOException + public void testBeginCommitReadOnlyTxn() throws Exception { try { @@ -100,12 +100,12 @@ public class DefaultTxnManagerTest txnManager.commitTransaction(); } - catch ( IOException e ) + catch ( TxnConflictException e ) { e.printStackTrace(); fail(); } - catch ( TxnConflictException e ) + catch ( IOException e ) { e.printStackTrace(); fail(); @@ -125,7 +125,7 @@ public class DefaultTxnManagerTest txnManager.abortTransaction(); } - catch ( IOException e ) + catch ( Exception e ) { e.printStackTrace(); fail(); @@ -145,12 +145,12 @@ public class DefaultTxnManagerTest txnManager.commitTransaction(); } - catch ( IOException e ) + catch ( TxnConflictException e ) { e.printStackTrace(); fail(); } - catch ( TxnConflictException e ) + catch ( Exception e ) { e.printStackTrace(); fail(); @@ -170,7 +170,7 @@ public class DefaultTxnManagerTest txnManager.abortTransaction(); } - catch ( IOException e ) + catch ( Exception e ) { e.printStackTrace(); fail(); @@ -217,12 +217,12 @@ public class DefaultTxnManagerTest txnManager.commitTransaction(); } - catch ( IOException e ) + catch ( TxnConflictException e ) { e.printStackTrace(); fail(); } - catch ( TxnConflictException e ) + catch ( Exception e ) { e.printStackTrace(); fail(); Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java Fri Nov 18 13:22:37 2011 @@ -22,12 +22,15 @@ package org.apache.directory.server.xdbm import java.util.UUID; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.AbstractIndexCursor; import org.apache.directory.server.core.api.partition.index.ForwardIndexEntry; +import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexCursor; import org.apache.directory.server.core.api.partition.index.IndexEntry; -import org.apache.directory.server.xdbm.Store; -import org.apache.directory.shared.ldap.model.entry.Entry; +import org.apache.directory.server.core.api.txn.TxnLogManager; +import org.apache.directory.server.core.shared.txn.TxnManagerFactory; +import org.apache.directory.shared.ldap.model.constants.SchemaConstants; /** @@ -58,10 +61,15 @@ public class AllEntriesCursor extends Ab * @param db * @throws Exception */ - public AllEntriesCursor( Store db ) throws Exception + @SuppressWarnings("unchecked") + public AllEntriesCursor( Partition db ) throws Exception { + TxnLogManager txnLogManager = TxnManagerFactory.txnLogManagerInstance(); + Index entryUuidIdx = db.getSystemIndex( SchemaConstants.ENTRY_UUID_AT_OID ); + entryUuidIdx = txnLogManager.wrap( db.getSuffixDn(), entryUuidIdx ); + // Get a reverse cursor because we want to sort by ID - wrapped = db.getEntryUuidIndex().reverseCursor(); + wrapped = ( ( Index )entryUuidIdx ).reverseCursor(); } Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java Fri Nov 18 13:22:37 2011 @@ -30,7 +30,6 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.api.partition.index.IndexEntry; import org.apache.directory.server.xdbm.search.Evaluator; import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException; -import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.filter.ExprNode; Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java Fri Nov 18 13:22:37 2011 @@ -23,13 +23,15 @@ package org.apache.directory.server.xdbm import java.util.UUID; import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.AbstractIndexCursor; import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexCursor; import org.apache.directory.server.core.api.partition.index.IndexEntry; -import org.apache.directory.server.xdbm.Store; +import org.apache.directory.server.core.api.txn.TxnLogManager; +import org.apache.directory.server.core.shared.txn.TxnManagerFactory; +import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException; -import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.entry.Value; import org.apache.directory.shared.ldap.model.schema.AttributeType; @@ -66,8 +68,9 @@ public class ApproximateCursor extend * @throws Exception If the creation failed */ @SuppressWarnings("unchecked") - public ApproximateCursor( Store db, ApproximateEvaluator approximateEvaluator ) throws Exception + public ApproximateCursor( Partition db, ApproximateEvaluator approximateEvaluator ) throws Exception { + TxnLogManager txnLogManager = TxnManagerFactory.txnLogManagerInstance(); this.approximateEvaluator = approximateEvaluator; AttributeType attributeType = approximateEvaluator.getExpression().getAttributeType(); @@ -75,13 +78,16 @@ public class ApproximateCursor extend if ( db.hasIndexOn( attributeType ) ) { - Index index = ( Index ) db.getIndex( attributeType ); - userIdxCursor = index.forwardCursor( value.getValue() ); + Index index = db.getIndex( attributeType ); + index = txnLogManager.wrap( db.getSuffixDn(), index ); + userIdxCursor = ( ( Index )index ).forwardCursor( value.getValue() ); uuidIdxCursor = null; } else { - uuidIdxCursor = db.getEntryUuidIndex().forwardCursor(); + Index entryUuidIdx = db.getSystemIndex( SchemaConstants.ENTRY_UUID_AT_OID ); + entryUuidIdx = txnLogManager.wrap( db.getSuffixDn(), entryUuidIdx ); + uuidIdxCursor = ( ( Index ) entryUuidIdx).forwardCursor(); userIdxCursor = null; } } Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java Fri Nov 18 13:22:37 2011 @@ -21,12 +21,11 @@ package org.apache.directory.server.xdbm import java.util.Iterator; -import java.util.UUID; import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexEntry; -import org.apache.directory.server.xdbm.Store; import org.apache.directory.shared.ldap.model.entry.Attribute; import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.entry.Value; @@ -51,7 +50,8 @@ public class ApproximateEvaluator ext * @param schemaManager The SchemaManager * @throws Exception If the creation failed */ - public ApproximateEvaluator( ApproximateNode node, Store db, SchemaManager schemaManager ) + @SuppressWarnings("unchecked") + public ApproximateEvaluator( ApproximateNode node, Partition db, SchemaManager schemaManager ) throws Exception { super( node, db, schemaManager ); @@ -59,6 +59,8 @@ public class ApproximateEvaluator ext if ( db.hasIndexOn( attributeType ) ) { idx = ( Index ) db.getIndex( attributeType ); + idx = ( Index ) txnLogManager.wrap(db.getSuffixDn(), idx ); + normalizer = null; ldapComparator = null; } @@ -145,7 +147,7 @@ public class ApproximateEvaluator ext // resuscitate the entry if it has not been and set entry in IndexEntry if ( null == entry ) { - entry = db.lookup( indexEntry.getId() ); + entry = masterTable.get( indexEntry.getId() ); indexEntry.setEntry( entry ); } Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java Fri Nov 18 13:22:37 2011 @@ -25,8 +25,8 @@ import java.util.List; import java.util.UUID; import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.IndexCursor; -import org.apache.directory.server.xdbm.Store; import org.apache.directory.server.xdbm.search.Evaluator; import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.filter.AndNode; @@ -46,7 +46,7 @@ import org.apache.directory.shared.util. public class CursorBuilder { /** The database used by this builder */ - private Store db = null; + private Partition db = null; /** Evaluator dependency on a EvaluatorBuilder */ private EvaluatorBuilder evaluatorBuilder; @@ -58,7 +58,7 @@ public class CursorBuilder * @param db database used by this enumerator * @param evaluatorBuilder the evaluator builder */ - public CursorBuilder( Store db, EvaluatorBuilder evaluatorBuilder ) + public CursorBuilder( Partition db, EvaluatorBuilder evaluatorBuilder ) { this.db = db; this.evaluatorBuilder = evaluatorBuilder; Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java Fri Nov 18 13:22:37 2011 @@ -23,9 +23,11 @@ package org.apache.directory.server.xdbm import java.util.List; import java.util.UUID; +import org.apache.directory.server.constants.ApacheSchemaConstants; import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.i18n.I18n; import org.apache.directory.server.core.api.partition.index.Index; +import org.apache.directory.server.core.shared.partition.OperationExecutionManagerFactory; import org.apache.directory.server.xdbm.Store; import org.apache.directory.server.xdbm.search.Optimizer; import org.apache.directory.shared.ldap.model.filter.AndNode; @@ -54,7 +56,7 @@ import org.apache.directory.shared.ldap. public class DefaultOptimizer implements Optimizer { /** the database this optimizer operates on */ - private final Store db; + private final Partition db; private UUID contextEntryId; @@ -63,7 +65,7 @@ public class DefaultOptimizer implements * * @param db the database this optimizer works for. */ - public DefaultOptimizer( Store db ) throws Exception + public DefaultOptimizer( Partition db ) throws Exception { this.db = db; } @@ -77,7 +79,7 @@ public class DefaultOptimizer implements { try { - this.contextEntryId = db.getEntryId( ((Partition)db).getSuffixDn() ); + this.contextEntryId = OperationExecutionManagerFactory.instance().getEntryId( db, db.getSuffixDn() ); } catch ( Exception e ) { @@ -87,7 +89,7 @@ public class DefaultOptimizer implements if ( contextEntryId == null ) { - return db.getDefaultId(); + return Partition.defaultID; } return contextEntryId; @@ -350,14 +352,15 @@ public class DefaultOptimizer implements { if ( db.hasUserIndexOn( node.getAttributeType() ) ) { - Index idx = db.getPresenceIndex(); + Index idx; + idx = ( Index )db.getSystemIndex( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ); return idx.count( node.getAttributeType().getOid() ); } else if ( db.hasSystemIndexOn( node.getAttributeType() ) ) { // the system indices (objectClass, entryUUID, entryCSN) are maintained for // each entry, so we could just return the database count - return db.count(); + return db.getMasterTable().count(); } return Long.MAX_VALUE; @@ -373,23 +376,27 @@ public class DefaultOptimizer implements */ private long getScopeScan( ScopeNode node ) throws Exception { - UUID id = db.getEntryId( node.getBaseDn() ); + Index idx; + idx = db.getSystemIndex( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ); + UUID id = OperationExecutionManagerFactory.instance().getEntryId( db, node.getBaseDn() ); switch ( node.getScope() ) { case OBJECT: return 1L; case ONELEVEL: - return db.getChildCount( id ); + idx = db.getSystemIndex( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ); + return ( ( Index )idx ).count( id ); case SUBTREE: if ( id.compareTo( getContextEntryId() ) == 0 ) { - return db.count(); + return db.getMasterTable().count(); } else { - return db.getSubLevelIndex().count( id ); + idx = db.getSystemIndex( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ); + return ( ( Index )idx ).count( id ); } default: Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java Fri Nov 18 13:22:37 2011 @@ -24,18 +24,22 @@ import java.util.UUID; import javax.naming.directory.SearchControls; +import org.apache.directory.server.constants.ApacheSchemaConstants; +import org.apache.directory.server.core.api.partition.OperationExecutionManager; import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.i18n.I18n; import org.apache.directory.server.core.api.partition.index.EmptyIndexCursor; import org.apache.directory.server.core.api.partition.index.ForwardIndexEntry; +import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexCursor; import org.apache.directory.server.core.api.partition.index.IndexEntry; import org.apache.directory.server.core.api.partition.index.SingletonIndexCursor; -import org.apache.directory.server.xdbm.Store; +import org.apache.directory.server.core.api.txn.TxnLogManager; +import org.apache.directory.server.core.shared.partition.OperationExecutionManagerFactory; +import org.apache.directory.server.core.shared.txn.TxnManagerFactory; import org.apache.directory.server.xdbm.search.Evaluator; import org.apache.directory.server.xdbm.search.Optimizer; import org.apache.directory.server.xdbm.search.SearchEngine; -import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.exception.LdapNoSuchObjectException; import org.apache.directory.shared.ldap.model.filter.AndNode; import org.apache.directory.shared.ldap.model.filter.BranchNode; @@ -56,12 +60,23 @@ public class DefaultSearchEngine impleme { /** the Optimizer used by this DefaultSearchEngine */ private final Optimizer optimizer; + /** the Database this DefaultSearchEngine operates on */ - private final Store db; + private final Partition db; + /** creates Cursors over entries satisfying filter expressions */ private final CursorBuilder cursorBuilder; + /** creates evaluators which check to see if candidates satisfy a filter expression */ private final EvaluatorBuilder evaluatorBuilder; + + /** Txn log manager */ + private final TxnLogManager txnLogManager; + + /** Operation execution manager */ + private final OperationExecutionManager executionManager; + + // ------------------------------------------------------------------------ @@ -76,13 +91,15 @@ public class DefaultSearchEngine impleme * @param evaluatorBuilder an expression evaluator builder * @param optimizer an optimizer to use during search */ - public DefaultSearchEngine( Store db, CursorBuilder cursorBuilder, + public DefaultSearchEngine( Partition db, CursorBuilder cursorBuilder, EvaluatorBuilder evaluatorBuilder, Optimizer optimizer ) { this.db = db; this.optimizer = optimizer; this.cursorBuilder = cursorBuilder; this.evaluatorBuilder = evaluatorBuilder; + txnLogManager = TxnManagerFactory.txnLogManagerInstance(); + executionManager = OperationExecutionManagerFactory.instance(); } @@ -100,16 +117,17 @@ public class DefaultSearchEngine impleme /** * @see SearchEngine#cursor(org.apache.directory.shared.ldap.model.name.Dn, org.apache.directory.shared.ldap.model.message.AliasDerefMode, ExprNode, SearchControls) */ + @SuppressWarnings("unchecked") public IndexCursor cursor( Dn base, AliasDerefMode aliasDerefMode, ExprNode filter, SearchControls searchCtls ) throws Exception { Dn effectiveBase; - UUID baseId = db.getEntryId( base ); + UUID baseId = executionManager.getEntryId( db, base ); // Check that we have an entry, otherwise we can immediately get out if ( baseId == null ) { - if ( ((Partition)db).getSuffixDn().equals( base ) ) + if ( db.getSuffixDn().equals( base ) ) { // The context entry is not created yet, return an empty cursor return new EmptyIndexCursor(); @@ -121,7 +139,10 @@ public class DefaultSearchEngine impleme } } - String aliasedBase = db.getAliasIndex().reverseLookup( baseId ); + Index aliasIdx; + aliasIdx = db.getSystemIndex( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ); + aliasIdx = txnLogManager.wrap( db.getSuffixDn(), aliasIdx ); + String aliasedBase = ( (Index) aliasIdx ).reverseLookup( baseId ); // -------------------------------------------------------------------- // Determine the effective base with aliases @@ -156,7 +177,7 @@ public class DefaultSearchEngine impleme UUID effectiveBaseId = baseId; if ( effectiveBase != base ) { - effectiveBaseId = db.getEntryId( effectiveBase ); + effectiveBaseId = executionManager.getEntryId( db, effectiveBase ); } IndexEntry indexEntry = new ForwardIndexEntry(); Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java Fri Nov 18 13:22:37 2011 @@ -23,13 +23,15 @@ package org.apache.directory.server.xdbm import java.util.UUID; import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.AbstractIndexCursor; import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexCursor; import org.apache.directory.server.core.api.partition.index.IndexEntry; -import org.apache.directory.server.xdbm.Store; +import org.apache.directory.server.core.api.txn.TxnLogManager; +import org.apache.directory.server.core.shared.txn.TxnManagerFactory; +import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException; -import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.entry.Value; import org.apache.directory.shared.ldap.model.schema.AttributeType; @@ -65,8 +67,9 @@ public class EqualityCursor extends A * @throws Exception If the creation failed */ @SuppressWarnings("unchecked") - public EqualityCursor( Store db, EqualityEvaluator equalityEvaluator ) throws Exception + public EqualityCursor( Partition db, EqualityEvaluator equalityEvaluator ) throws Exception { + TxnLogManager txnLogManager = TxnManagerFactory.txnLogManagerInstance(); this.equalityEvaluator = equalityEvaluator; AttributeType attributeType = equalityEvaluator.getExpression().getAttributeType(); @@ -74,13 +77,16 @@ public class EqualityCursor extends A if ( db.hasIndexOn( attributeType ) ) { - Index userIndex = ( Index ) db.getIndex( attributeType ); - userIdxCursor = userIndex.forwardCursor( value.getValue() ); + Index index = db.getIndex( attributeType ); + index = txnLogManager.wrap( db.getSuffixDn(), index ); + userIdxCursor = ( ( Index )index ).forwardCursor( value.getValue() ); uuidIdxCursor = null; } else { - uuidIdxCursor = db.getEntryUuidIndex().forwardCursor(); + Index entryUuidIdx = db.getSystemIndex( SchemaConstants.ENTRY_UUID_AT_OID ); + entryUuidIdx = txnLogManager.wrap( db.getSuffixDn(), entryUuidIdx ); + uuidIdxCursor = ( ( Index ) entryUuidIdx).forwardCursor(); userIdxCursor = null; } } Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java Fri Nov 18 13:22:37 2011 @@ -24,9 +24,9 @@ import java.util.Comparator; import java.util.Iterator; import java.util.UUID; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexEntry; -import org.apache.directory.server.xdbm.Store; import org.apache.directory.shared.ldap.model.entry.Attribute; import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.entry.Value; @@ -56,7 +56,7 @@ public class EqualityEvaluator extend @SuppressWarnings("unchecked") - public EqualityEvaluator( EqualityNode node, Store db, SchemaManager schemaManager ) + public EqualityEvaluator( EqualityNode node, Partition db, SchemaManager schemaManager ) throws Exception { super( node, db, schemaManager ); @@ -64,6 +64,8 @@ public class EqualityEvaluator extend if ( db.hasIndexOn( attributeType ) ) { idx = ( Index ) db.getIndex( attributeType ); + idx = ( Index ) txnLogManager.wrap(db.getSuffixDn(), idx ); + normalizer = null; ldapComparator = null; } @@ -105,7 +107,7 @@ public class EqualityEvaluator extend // resuscitate the entry if it has not been and set entry in IndexEntry if ( null == entry ) { - entry = db.lookup( indexEntry.getId() ); + entry = masterTable.get( indexEntry.getId() ); indexEntry.setEntry( entry ); } @@ -159,7 +161,7 @@ public class EqualityEvaluator extend return idx.reverse( id ); } - return evaluateEntry( db.lookup( id ) ); + return evaluateEntry( masterTable.get( id ) ); } Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java Fri Nov 18 13:22:37 2011 @@ -23,10 +23,9 @@ package org.apache.directory.server.xdbm import java.util.ArrayList; import java.util.List; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.i18n.I18n; -import org.apache.directory.server.xdbm.Store; import org.apache.directory.server.xdbm.search.Evaluator; -import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.filter.AndNode; import org.apache.directory.shared.ldap.model.filter.ApproximateNode; import org.apache.directory.shared.ldap.model.filter.EqualityNode; @@ -50,7 +49,7 @@ import org.apache.directory.shared.util. */ public class EvaluatorBuilder { - private final Store db; + private final Partition db; private final SchemaManager schemaManager; @@ -62,7 +61,7 @@ public class EvaluatorBuilder * @param schemaManager the schema manager * @throws Exception failure to access db or lookup schema in registries */ - public EvaluatorBuilder( Store db, SchemaManager schemaManager ) throws Exception + public EvaluatorBuilder( Partition db, SchemaManager schemaManager ) throws Exception { this.db = db; this.schemaManager = schemaManager; Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java Fri Nov 18 13:22:37 2011 @@ -23,14 +23,16 @@ package org.apache.directory.server.xdbm import java.util.UUID; import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.AbstractIndexCursor; import org.apache.directory.server.core.api.partition.index.ForwardIndexEntry; import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexCursor; import org.apache.directory.server.core.api.partition.index.IndexEntry; -import org.apache.directory.server.xdbm.Store; +import org.apache.directory.server.core.api.txn.TxnLogManager; +import org.apache.directory.server.core.shared.txn.TxnManagerFactory; +import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException; -import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.schema.AttributeType; @@ -71,20 +73,25 @@ public class GreaterEqCursor extends * @throws Exception If the creation failed */ @SuppressWarnings("unchecked") - public GreaterEqCursor( Store db, GreaterEqEvaluator greaterEqEvaluator ) throws Exception + public GreaterEqCursor( Partition db, GreaterEqEvaluator greaterEqEvaluator ) throws Exception { + TxnLogManager txnLogManager = TxnManagerFactory.txnLogManagerInstance(); this.greaterEqEvaluator = greaterEqEvaluator; AttributeType attributeType = greaterEqEvaluator.getExpression().getAttributeType(); if ( db.hasIndexOn( attributeType ) ) { - userIdxCursor = ( ( Index ) db.getIndex( attributeType ) ).forwardCursor(); + Index index = db.getIndex( attributeType ); + index = txnLogManager.wrap( db.getSuffixDn(), index ); + userIdxCursor = ( ( Index )index ).forwardCursor(); ndnIdxCursor = null; } else { - ndnIdxCursor = db.getEntryUuidIndex().forwardCursor(); + Index entryUuidIdx = db.getSystemIndex( SchemaConstants.ENTRY_UUID_AT_OID ); + entryUuidIdx = txnLogManager.wrap( db.getSuffixDn(), entryUuidIdx ); + ndnIdxCursor = ( ( Index ) entryUuidIdx).forwardCursor(); userIdxCursor = null; } } Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java Fri Nov 18 13:22:37 2011 @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.UUID; import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexEntry; import org.apache.directory.server.xdbm.Store; @@ -45,7 +46,7 @@ import org.apache.directory.shared.ldap. public class GreaterEqEvaluator extends LeafEvaluator { @SuppressWarnings("unchecked") - public GreaterEqEvaluator( GreaterEqNode node, Store db, SchemaManager schemaManager ) + public GreaterEqEvaluator( GreaterEqNode node, Partition db, SchemaManager schemaManager ) throws Exception { super( node, db, schemaManager ); @@ -53,6 +54,7 @@ public class GreaterEqEvaluator exten if ( db.hasIndexOn( node.getAttributeType() ) ) { idx = ( Index ) db.getIndex( attributeType ); + idx = ( Index ) txnLogManager.wrap(db.getSuffixDn(), idx ); } else { @@ -100,7 +102,7 @@ public class GreaterEqEvaluator exten // resuscitate the entry if it has not been and set entry in IndexEntry if ( null == entry ) { - entry = db.lookup( indexEntry.getId() ); + entry = masterTable.get( indexEntry.getId() ); indexEntry.setEntry( entry ); } @@ -158,7 +160,7 @@ public class GreaterEqEvaluator exten return idx.reverseGreaterOrEq( id, node.getValue().getValue() ); } - return evaluateEntry( db.lookup( id ) ); + return evaluateEntry( masterTable.get( id ) ); } Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LeafEvaluator.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LeafEvaluator.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LeafEvaluator.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LeafEvaluator.java Fri Nov 18 13:22:37 2011 @@ -19,10 +19,14 @@ */ package org.apache.directory.server.xdbm.search.impl; +import org.apache.directory.server.core.api.partition.OperationExecutionManager; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.Index; -import org.apache.directory.server.xdbm.Store; +import org.apache.directory.server.core.api.partition.index.MasterTable; +import org.apache.directory.server.core.api.txn.TxnLogManager; +import org.apache.directory.server.core.shared.partition.OperationExecutionManagerFactory; +import org.apache.directory.server.core.shared.txn.TxnManagerFactory; import org.apache.directory.server.xdbm.search.Evaluator; -import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.filter.SimpleNode; import org.apache.directory.shared.ldap.model.schema.AttributeType; import org.apache.directory.shared.ldap.model.schema.LdapComparator; @@ -42,7 +46,7 @@ public abstract class LeafEvaluator i protected final SimpleNode node; /** The backend */ - protected final Store db; + protected final Partition db; /** The SchemaManager instance */ protected final SchemaManager schemaManager; @@ -58,15 +62,23 @@ public abstract class LeafEvaluator i /** The index to use if any */ protected Index idx; + + /** Txn log manager */ + protected TxnLogManager txnLogManager; + + /** Master table */ + protected MasterTable masterTable; @SuppressWarnings("unchecked") - public LeafEvaluator( SimpleNode node, Store db, SchemaManager schemaManager ) + public LeafEvaluator( SimpleNode node, Partition db, SchemaManager schemaManager ) throws Exception { this.db = db; this.node = node; this.schemaManager = schemaManager; this.attributeType = node.getAttributeType(); + txnLogManager = TxnManagerFactory.txnLogManagerInstance(); + masterTable = txnLogManager.wrap( db.getSuffixDn(), db.getMasterTable() ); } Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java Fri Nov 18 13:22:37 2011 @@ -23,14 +23,16 @@ package org.apache.directory.server.xdbm import java.util.UUID; import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.AbstractIndexCursor; import org.apache.directory.server.core.api.partition.index.ForwardIndexEntry; import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexCursor; import org.apache.directory.server.core.api.partition.index.IndexEntry; -import org.apache.directory.server.xdbm.Store; +import org.apache.directory.server.core.api.txn.TxnLogManager; +import org.apache.directory.server.core.shared.txn.TxnManagerFactory; +import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException; -import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.schema.AttributeType; @@ -54,31 +56,36 @@ public class LessEqCursor extends Abs private final IndexCursor userIdxCursor; /** NDN Cursor on all entries in (set when no index on user attribute) */ - private final IndexCursor uuidIdxCursor; + private final IndexCursor uuidIdxCursor; /** * Used to store indexEntry from ndnCandidate so it can be saved after * call to evaluate() which changes the value so it's not referring to * the NDN but to the value of the attribute instead. */ - IndexEntry ndnCandidate; + IndexEntry ndnCandidate; @SuppressWarnings("unchecked") - public LessEqCursor( Store db, LessEqEvaluator lessEqEvaluator ) throws Exception + public LessEqCursor( Partition db, LessEqEvaluator lessEqEvaluator ) throws Exception { + TxnLogManager txnLogManager = TxnManagerFactory.txnLogManagerInstance(); this.lessEqEvaluator = lessEqEvaluator; AttributeType attributeType = lessEqEvaluator.getExpression().getAttributeType(); if ( db.hasIndexOn( attributeType ) ) { - userIdxCursor = ( ( Index ) db.getIndex( attributeType ) ).forwardCursor(); + Index index = db.getIndex( attributeType ); + index = txnLogManager.wrap( db.getSuffixDn(), index ); + userIdxCursor = ( ( Index )index ).forwardCursor(); uuidIdxCursor = null; } else { - uuidIdxCursor = ( IndexCursor ) db.getEntryUuidIndex().forwardCursor(); + Index entryUuidIdx = db.getSystemIndex( SchemaConstants.ENTRY_UUID_AT_OID ); + entryUuidIdx = txnLogManager.wrap( db.getSuffixDn(), entryUuidIdx ); + uuidIdxCursor = ( ( Index ) entryUuidIdx).forwardCursor(); userIdxCursor = null; } } @@ -401,7 +408,8 @@ public class LessEqCursor extends Abs return setAvailable( false ); } - + + @SuppressWarnings("unchecked") public IndexEntry get() throws Exception { checkNotClosed( "get()" ); @@ -418,7 +426,7 @@ public class LessEqCursor extends Abs if ( available() ) { - return ndnCandidate; + return ( IndexEntry ) ndnCandidate; } throw new InvalidCursorPositionException( I18n.err( I18n.ERR_708 ) ); Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java Fri Nov 18 13:22:37 2011 @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.UUID; import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexEntry; import org.apache.directory.server.xdbm.Store; @@ -45,7 +46,7 @@ import org.apache.directory.shared.ldap. public class LessEqEvaluator extends LeafEvaluator { @SuppressWarnings("unchecked") - public LessEqEvaluator( LessEqNode node, Store db, SchemaManager schemaManager ) + public LessEqEvaluator( LessEqNode node, Partition db, SchemaManager schemaManager ) throws Exception { super( node, db, schemaManager ); @@ -53,6 +54,7 @@ public class LessEqEvaluator extends if ( db.hasIndexOn( attributeType ) ) { idx = ( Index ) db.getIndex( attributeType ); + idx = ( Index ) txnLogManager.wrap(db.getSuffixDn(), idx ); } else { @@ -95,7 +97,7 @@ public class LessEqEvaluator extends return idx.reverseLessOrEq( id, node.getValue().getValue() ); } - return evaluateEntry( db.lookup( id ) ); + return evaluateEntry( masterTable.get( id ) ); } @@ -111,7 +113,7 @@ public class LessEqEvaluator extends // resuscitate the entry if it has not been and set entry in IndexEntry if ( null == entry ) { - entry = db.lookup( indexEntry.getId() ); + entry = masterTable.get( indexEntry.getId() ); indexEntry.setEntry( entry ); } Modified: directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java?rev=1203640&r1=1203639&r2=1203640&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java (original) +++ directory/apacheds/branches/apacheds-txns/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java Fri Nov 18 13:22:37 2011 @@ -21,11 +21,15 @@ package org.apache.directory.server.xdbm import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.api.partition.index.AbstractIndexCursor; +import org.apache.directory.server.core.api.partition.index.Index; import org.apache.directory.server.core.api.partition.index.IndexCursor; import org.apache.directory.server.core.api.partition.index.IndexEntry; -import org.apache.directory.server.xdbm.Store; +import org.apache.directory.server.core.api.txn.TxnLogManager; +import org.apache.directory.server.core.shared.txn.TxnManagerFactory; import org.apache.directory.server.xdbm.search.Evaluator; +import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException; import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.filter.ExprNode; @@ -39,16 +43,20 @@ import org.apache.directory.shared.ldap. public class NotCursor extends AbstractIndexCursor { private static final String UNSUPPORTED_MSG = I18n.err( I18n.ERR_718 ); - private final IndexCursor uuidCursor; + private final IndexCursor uuidCursor; private final Evaluator childEvaluator; @SuppressWarnings("unchecked") - public NotCursor( Store store, Evaluator childEvaluator ) + public NotCursor( Partition store, Evaluator childEvaluator ) throws Exception { this.childEvaluator = childEvaluator; - this.uuidCursor = ( IndexCursor ) store.getEntryUuidIndex().forwardCursor(); + + TxnLogManager txnLogManager = TxnManagerFactory.txnLogManagerInstance(); + Index entryUuidIdx = store.getSystemIndex( SchemaConstants.ENTRY_UUID_AT_OID ); + entryUuidIdx = txnLogManager.wrap( store.getSuffixDn(), entryUuidIdx ); + uuidCursor = ( ( Index )entryUuidIdx ).forwardCursor(); } @@ -133,7 +141,7 @@ public class NotCursor extends Abstra if ( available() ) { - return uuidCursor.get(); + return ( IndexEntry ) uuidCursor.get(); } throw new InvalidCursorPositionException( I18n.err( I18n.ERR_708 ) );