Return-Path: X-Original-To: apmail-accumulo-dev-archive@www.apache.org Delivered-To: apmail-accumulo-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 C48C6D5C3 for ; Thu, 13 Sep 2012 03:10:26 +0000 (UTC) Received: (qmail 955 invoked by uid 500); 13 Sep 2012 03:10:26 -0000 Delivered-To: apmail-accumulo-dev-archive@accumulo.apache.org Received: (qmail 696 invoked by uid 500); 13 Sep 2012 03:10:22 -0000 Mailing-List: contact dev-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list dev@accumulo.apache.org Received: (qmail 666 invoked by uid 99); 13 Sep 2012 03:10:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Sep 2012 03:10:20 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.212.41] (HELO mail-vb0-f41.google.com) (209.85.212.41) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Sep 2012 03:10:12 +0000 Received: by vbkv13 with SMTP id v13so3605657vbk.0 for ; Wed, 12 Sep 2012 20:09:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:x-gm-message-state; bh=l6iPn2ODBlq2Q3/IU3fxQNqszOqcgqVSZtvi54PJMNM=; b=O8PFh+MalbZdJCfbvHbxSkfemQyJDGA7UI7NnAowDCbfSga3lzzWTdAPV+yTICObbW kyDcRiXB6WrhWXy/TJQW4b92CfFRAnuvvpYZJGzC5p/2XMkI8NrSM/LONKrX4l1GnlHJ o8IrW0JR4RNiGKQwaMFYFVE96A0TnE3X8vl/F+gim/YYAtTa8m8bqYos17gv+sCgc06F 3zAtHN0mCrTAP94rIIhtAp63Ge8ai7u/y7qDzEjVVepumScN9kb2tTNZfAX8jUMIW5o/ k8fuITgJzGEW0PZWOAv2VQMWgFGbB2Dfrva9LtB1NcLbPTKvUSg8smmPpk0k3Rcfo1iu qUjw== MIME-Version: 1.0 Received: by 10.52.90.148 with SMTP id bw20mr323012vdb.6.1347505786007; Wed, 12 Sep 2012 20:09:46 -0700 (PDT) Received: by 10.220.215.145 with HTTP; Wed, 12 Sep 2012 20:09:45 -0700 (PDT) X-Originating-IP: [88.211.67.219] In-Reply-To: References: Date: Thu, 13 Sep 2012 04:09:45 +0100 Message-ID: Subject: Re: Double Checked Locking - broken? working? From: Mike Drob To: dev@accumulo.apache.org Content-Type: multipart/alternative; boundary=20cf307f3be0b52ece04c98ca3aa X-Gm-Message-State: ALoCoQkggn7h97vQyWQjfzszf9QqFFugGS0gi7ijg1t8MFsPFzpmhKEwe+lig4i3nFPkDYLStm4L --20cf307f3be0b52ece04c98ca3aa Content-Type: text/plain; charset=ISO-8859-1 It's a private static field that never changes once we do the initial load. The load looks idempotent, so I'm not sure it's worth the hassle of trying to synchronize on it, or even do it lazily. Maybe somebody with more history has seen that it is way more performance intensive than I give it credit for, but I think we should just throw that part in a static block and be done with it. Alternatively, in the middle of that article, he suggests that if you have a static singleton (which this appears to be) that you can throw it in another class and the memory model will work out. -Mike On Thu, Sep 13, 2012 at 12:25 AM, Eric Newton wrote: > The article is correct. Just go ahead and simplify the code. > > -Eric > > On Wed, Sep 12, 2012 at 5:47 PM, David Medinets >wrote: > > > I see the following code in the Property class: > > > > public static boolean isValidTablePropertyKey(String key) { > > if (validTableProperties == null) { > > synchronized (Property.class) { > > if (validTableProperties == null) { > > HashSet tmp = new HashSet(); > > for (Property p : Property.values()) > > if (!p.getType().equals(PropertyType.PREFIX) && > > p.getKey().startsWith(Property.TABLE_PREFIX.getKey())) > > tmp.add(p.getKey()); > > validTableProperties = tmp; > > } > > } > > } > > > > return validTableProperties.contains(key) || > > key.startsWith(Property.TABLE_CONSTRAINT_PREFIX.getKey()) > > || key.startsWith(Property.TABLE_ITERATOR_PREFIX.getKey()) || > > key.startsWith(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey()); > > } > > > > However, > > http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html > > says that Double Check Locking does not work. Is there any reason to > > believe that the article is incorrect? At the end of the article, it > > recommends using volatile in Java 1.5 and above. Is there any reason > > the code should not be changed to use the volatile technique? > > > --20cf307f3be0b52ece04c98ca3aa--