Return-Path: X-Original-To: apmail-directory-dev-archive@www.apache.org Delivered-To: apmail-directory-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2977F1041E for ; Mon, 10 Feb 2014 15:35:49 +0000 (UTC) Received: (qmail 75002 invoked by uid 500); 10 Feb 2014 15:35:48 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 74963 invoked by uid 500); 10 Feb 2014 15:35:42 -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 74956 invoked by uid 99); 10 Feb 2014 15:35:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Feb 2014 15:35:41 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of elecharny@gmail.com designates 74.125.82.179 as permitted sender) Received: from [74.125.82.179] (HELO mail-we0-f179.google.com) (74.125.82.179) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Feb 2014 15:35:36 +0000 Received: by mail-we0-f179.google.com with SMTP id q58so4411124wes.10 for ; Mon, 10 Feb 2014 07:35:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=BdcJSsNqS6oMY8rgONzDATBuIAp/8tE/TJpPwpBSkTk=; b=Cd3j4uPZCqeLk4DcuCXpYNpmrRqXz8RxCgm7LjzcNu/DJUp6Dtnkp+lsMrEf9/VeYS Pe1J407gZh2GzKE8Fg62Bk/eexuhnbp24lkBO78TSeve4Wr9DhgcCKxvOCu426xP7DQo xnvPoU+O29TQoGtoQZIaJ8hRGtnJSkHmSAr92kbGS1hjFgrNnIF0jw9KbX3Dd3pyqUVL vG7zwLm9gCV75lgvLu+PCT3AWP+dMJybQchKwxZg4gHy2B47xUCYrTQsT+/YIQJejPiS cQe6ysVSFnun8IHWdH0WvJBXhf3kVMcEjeyJtVBMlywyTdo6Es13fiSghSN7NPbL8Ymt AdwQ== X-Received: by 10.180.207.10 with SMTP id ls10mr11100995wic.4.1392046515782; Mon, 10 Feb 2014 07:35:15 -0800 (PST) Received: from Emmanuels-MacBook-Pro.local (chateau.entrouvert.org. [109.190.108.22]) by mx.google.com with ESMTPSA id dd3sm36275492wjb.9.2014.02.10.07.35.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 07:35:14 -0800 (PST) Message-ID: <52F8F1B1.1020805@gmail.com> Date: Mon, 10 Feb 2014 16:35:13 +0100 From: =?UTF-8?B?RW1tYW51ZWwgTMOpY2hhcm55?= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Apache Directory Developers List Subject: Re: [Mavibot] Transaction discussion References: <52F4B178.3080606@symas.com> <52F51F03.1070002@gmail.com> <52F5F84D.3080706@gmail.com> In-Reply-To: <52F5F84D.3080706@gmail.com> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org I think the ReadWriiteReentrantLock data structure is the right one to deal with this situation : http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html (Thanks to Cedric Champeau for the suggestion) Le 2/8/14 10:26 AM, Emmanuel Lécharny a écrit : > Le 2/8/14 8:28 AM, Kiran Ayyagari a écrit : >> On Fri, Feb 7, 2014 at 11:29 PM, Emmanuel Lécharny wrote: >> >>>>> This is not trivial, as we want to make it as easy as possible for our >>>>> users. Typically, how should an operation know which kind of transaction >>>>> it is dealing with ? Let's have a look at such an operation : >>>>> >>>>> insert : >>>>> // check if we are already into a txn >>>>> if (in transaction) (1) >>>>> then >>>>> process operation >>>>> else >>>>> start transaction (2) >>>>> process operation >>>>> commit operation >>>>> >>>>> so far, it seems ok, but what if another thread has started a >>>>> transaction *just* after the test (1) and before (2) ? This is >>> complicated. >>>>> hmmm, how about using ThreadLocal, >>>> and not sure we need to branch based on the presence of txn handle, the >>>> start transaction(2) >>>> should always give the txn handle present in ThreadLocal >>> That would work if only we were in a single thread environment... In our >>> case, we have no idea how many threads will try to write data in Mavibot. >>> >>> ThreadLocal is meant for multithreaded environments > Sure, but in this case, it won't help, as a ThreadLocal storage will be > associated with one single thread (and each thread will have a different > insance), when we are trying to avoid many threads to access one > resource concurrently. I'm failing to see how we could use TLS in this > case. Do you have something in mind ? > > -- Regards, Cordialement, Emmanuel Lécharny www.iktek.com