Return-Path: X-Original-To: apmail-jackrabbit-users-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 585E0946E for ; Sat, 24 Dec 2011 07:26:20 +0000 (UTC) Received: (qmail 46031 invoked by uid 500); 24 Dec 2011 07:26:19 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 45834 invoked by uid 500); 24 Dec 2011 07:26:16 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 45825 invoked by uid 99); 24 Dec 2011 07:26:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Dec 2011 07:26:14 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of stefan.guggisberg@gmail.com designates 209.85.210.170 as permitted sender) Received: from [209.85.210.170] (HELO mail-iy0-f170.google.com) (209.85.210.170) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Dec 2011 07:26:08 +0000 Received: by iafj26 with SMTP id j26so33162395iaf.1 for ; Fri, 23 Dec 2011 23:25:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=mve3KoG1vcnPWa9vy2reElDh2OWPkDfltPszGAEXmSQ=; b=R4kGtnw7HRpvGIOTtAPCfiRdficx8eB34fDtEsnieHzjS96RHK492StCEAdnNEbZk6 uoBGYe1/iEB9Jhgi+Ob3sJTTO7djjyWaF2cq/pVlkXE1IWApdTjNmbXh6u8R9KIEv5R9 iK9NAY6hsRB1ClnJbjYj3NyZll9OZLGSdoNso= MIME-Version: 1.0 Received: by 10.42.176.196 with SMTP id bf4mr17597238icb.27.1324711547215; Fri, 23 Dec 2011 23:25:47 -0800 (PST) Received: by 10.42.19.136 with HTTP; Fri, 23 Dec 2011 23:25:47 -0800 (PST) In-Reply-To: <4EF4F231.6090505@pentaho.com> References: <4EF38781.2080002@pentaho.com> <4EF4CA51.3020106@pentaho.com> <4EF4F231.6090505@pentaho.com> Date: Sat, 24 Dec 2011 08:25:47 +0100 Message-ID: Subject: Re: Concurrent modifications to a single node From: Stefan Guggisberg To: users@jackrabbit.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Fri, Dec 23, 2011 at 10:27 PM, Mat Lowery wrote: > Thanks for your help. =A0FYI: https://issues.apache.org/jira/browse/JCR-3= 194 excellent, thanks! cheers stefan > > > > On 12/23/2011 03:49 PM, Stefan Guggisberg wrote: >> >> package test; >> >>> >> >>> =A0import java.io.File; >> >>> =A0import java.util.concurrent.ExecutorService; >> >>> =A0import java.util.concurrent.Executors; >> >>> =A0import java.util.concurrent.TimeUnit; >> >>> =A0import java.util.concurrent.atomic.AtomicBoolean; >> >>> =A0import java.util.concurrent.atomic.AtomicInteger; >> >>> >> >>> =A0import javax.jcr.Repository; >> >>> =A0import javax.jcr.RepositoryException; >> >>> =A0import javax.jcr.Session; >> >>> =A0import javax.jcr.SimpleCredentials; >> >>> >> >>> =A0import org.apache.jackrabbit.core.TransientRepository; >> >>> >> >>> =A0public class JackrabbitTest { >> >>> >> >>> =A0 =A0public static void main(final String[] args) throws Exception= { >> >>> =A0 =A0 =A0File dir =3D File.createTempFile("jackrabbit-test", ""); >> >>> =A0 =A0 =A0dir.delete(); >> >>> =A0 =A0 =A0dir.mkdir(); >> >>> =A0 =A0 =A0System.out.println("created temporary directory: " + >> >>> =A0 =A0 =A0 =A0 =A0dir.getAbsolutePath()); >> >>> =A0 =A0 =A0dir.deleteOnExit(); >> >>> >> >>> =A0 =A0 =A0final Repository jcrRepo =3D new TransientRepository(dir)= ; >> >>> =A0 =A0 =A0final AtomicBoolean passed =3D new AtomicBoolean(true); >> >>> =A0 =A0 =A0final AtomicInteger counter =3D new AtomicInteger(0); >> >>> =A0 =A0 =A0ExecutorService executor =3D Executors.newFixedThreadPool= (50); >> >>> =A0 =A0 =A0Runnable runnable =3D new Runnable() { >> >>> >> >>> =A0 =A0 =A0 =A0@Override >> >>> =A0 =A0 =A0 =A0public void run() { >> >>> =A0 =A0 =A0 =A0 =A0try { >> >>> =A0 =A0 =A0 =A0 =A0 =A0Session session =3D jcrRepo.login( >> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0new SimpleCredentials("admin", >> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"admin".toCharArray())); >> >>> =A0 =A0 =A0 =A0 =A0 =A0session.getRootNode().addNode("n" + >> >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0counter.getAndIncrement()); /= /unique name >> >>> =A0 =A0 =A0 =A0 =A0 =A0session.save(); >> >>> =A0 =A0 =A0 =A0 =A0 =A0session.logout(); >> >>> =A0 =A0 =A0 =A0 =A0} catch (RepositoryException e) { >> >>> =A0 =A0 =A0 =A0 =A0 =A0e.printStackTrace(); >> >>> =A0 =A0 =A0 =A0 =A0 =A0passed.set(false); >> >>> =A0 =A0 =A0 =A0 =A0} >> >>> =A0 =A0 =A0 =A0} >> >>> >> >>> =A0 =A0 =A0}; >> >>> =A0 =A0 =A0System.out.println("Running threads"); >> >>> =A0 =A0 =A0for (int i =3D 0; i< =A0 500; i++) { >> >>> =A0 =A0 =A0 =A0executor.execute(runnable); >> >>> =A0 =A0 =A0} >> >>> =A0 =A0 =A0executor.shutdown(); //Disable new tasks from being submi= tted >> >>> =A0 =A0 =A0if (!executor.awaitTermination(120, TimeUnit.SECONDS)) { >> >>> =A0 =A0 =A0 =A0System.err.println("timeout"); >> >>> =A0 =A0 =A0 =A0System.exit(1); >> >>> =A0 =A0 =A0} >> >>> =A0 =A0 =A0if (!passed.get()) { >> >>> =A0 =A0 =A0 =A0System.err.println("one or more threads got an except= ion"); >> >>> =A0 =A0 =A0 =A0System.exit(1); >> >>> =A0 =A0 =A0} else { >> >>> =A0 =A0 =A0 =A0System.out.println("all threads ran with no exception= s"); >> >>> =A0 =A0 =A0 =A0System.exit(0); >> >>> =A0 =A0 =A0} >> >>> >> >>> =A0 =A0} >> >>> >> >>> =A0}