Return-Path: Delivered-To: apmail-hadoop-zookeeper-user-archive@minotaur.apache.org Received: (qmail 97213 invoked from network); 18 Jul 2010 00:03:18 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 18 Jul 2010 00:03:18 -0000 Received: (qmail 77610 invoked by uid 500); 18 Jul 2010 00:03:16 -0000 Delivered-To: apmail-hadoop-zookeeper-user-archive@hadoop.apache.org Received: (qmail 77036 invoked by uid 500); 18 Jul 2010 00:03:15 -0000 Mailing-List: contact zookeeper-user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: zookeeper-user@hadoop.apache.org Delivered-To: mailing list zookeeper-user@hadoop.apache.org Received: (qmail 76857 invoked by uid 99); 18 Jul 2010 00:03:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jul 2010 00:03:15 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of aoriani@gmail.com designates 209.85.216.169 as permitted sender) Received: from [209.85.216.169] (HELO mail-qy0-f169.google.com) (209.85.216.169) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jul 2010 00:03:06 +0000 Received: by qyk32 with SMTP id 32so1311354qyk.14 for ; Sat, 17 Jul 2010 17:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:sender:received:from:date :x-google-sender-auth:message-id:subject:to:content-type; bh=RdqiwYABqB57Ev9uofMHuaax7eQ9+j5uloVPvDIcuL0=; b=LqJ8JQI2eC8gD4SD2cz76O4iMBkd4BqpOfcFAeFFodpi3YQgsWDCYE+Rr6pFGITw3m LLc2Djdsrg2lzBlMe8BjwX1bQ8k59izkbBY+sZneshk8UGY3HlHHFc8+12fjf3PSvN4x thw+ktKRaHdRtHgaOjFt2ECpba8mPWQelloso= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type; b=w5cUsHyDr3rvX6QnPhKQ/ZY+ndlU4DKWL2pbY7pVEJZpqMmeVJkur4wKFqy6rIgdiy v6xkBJLTEHaxXGAZXiRH3car/DqYT8sN0v5h9yMPsn8kPZDSH/zj1XccXFGZfG3exPxk /vHQYip+RPgsyKbACEFp9GmTRzYRXpUQMq7fw= Received: by 10.224.59.195 with SMTP id m3mr2651424qah.34.1279411364528; Sat, 17 Jul 2010 17:02:44 -0700 (PDT) MIME-Version: 1.0 Sender: aoriani@gmail.com Received: by 10.229.233.80 with HTTP; Sat, 17 Jul 2010 17:02:24 -0700 (PDT) From: =?ISO-8859-1?Q?Andr=E9_Oriani?= Date: Sat, 17 Jul 2010 21:02:24 -0300 X-Google-Sender-Auth: qBVb4GkQd6_aS3uvNaOXG5rma3g Message-ID: Subject: BookKeeper Doubts To: zookeeper-user@hadoop.apache.org Content-Type: multipart/alternative; boundary=00c09fa21ac3e78508048b9e2b08 X-Virus-Checked: Checked by ClamAV on apache.org --00c09fa21ac3e78508048b9e2b08 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, I was not sure if I had understood the behavior of BookKeeper from documentation. So I made a little program, reproduced below, to see what BookKeeper looks like in action. Assuming my code is correct ( you never know when your code has some nasty obvious bugs that only other person tha= n you can see ) , I could draw the follow conclusions: 1) Only the creator can add entries to a ledger, even though you can open the ledger, get a handle and call addEntry on it. No exception is thrown i= . In other words, you cannot open a ledger for append. 2) Readers are able to see only the entries that were added to a ledger until someone had opened it for reading. If you want to ensure readers wil= l see all the entries, you must add all entries before any reader attempts to read from the ledger. Could someone please tell me if those conclusions are correct or if I am mistaken? In the later case, could that person also tell me what is wrong ? Thanks a lot for the attention and the patience with this BookKeeper newbie= , Andr=E9 package br.unicamp.zooexp.booexp; import java.io.IOException; import java.util.Enumeration; import org.apache.bookkeeper.client.BKException; import org.apache.bookkeeper.client.BookKeeper; import org.apache.bookkeeper.client.LedgerEntry; import org.apache.bookkeeper.client.LedgerHandle; import org.apache.bookkeeper.client.BookKeeper.DigestType; import org.apache.zookeeper.KeeperException; public class BookTest { public static void main (String ... args) throws IOException, InterruptedException, KeeperException, BKException{ BookKeeper bk =3D new BookKeeper("127.0.0.1"); LedgerHandle lh =3D bk.createLedger(DigestType.CRC32, "123" .getBytes()); long lh_id =3D lh.getId(); lh.addEntry("Teste".getBytes()); lh.addEntry("Test2".getBytes()); System.out.printf("Got %d entries for lh\n" ,lh.getLastAddConfirmed()+1); lh.addEntry("Test3".getBytes()); LedgerHandle lh1 =3D bk.openLedger(lh_id, DigestType.CRC32, "123" .getBytes()); System.out.printf("Got %d entries for lh1\n" ,lh1.getLastAddConfirmed()+1); lh.addEntry("Test4".getBytes()); lh.addEntry("Test5".getBytes()); lh.addEntry("Test6".getBytes()); System.out.printf("Got %d entries for lh\n" ,lh.getLastAddConfirmed()+1); Enumeration seq =3D lh.readEntries(0, lh.getLastAddConfirmed()); while (seq.hasMoreElements()){ System.out.println(new String(seq.nextElement().getEntry())); } lh.close(); lh1.addEntry("Test7".getBytes()); lh1.addEntry("Test8".getBytes()); System.out.printf("Got %d entries for lh1\n" ,lh1.getLastAddConfirmed()+1); seq =3D lh1.readEntries(0, lh1.getLastAddConfirmed()); while (seq.hasMoreElements()){ System.out.println(new String(seq.nextElement().getEntry())); } lh1.close(); LedgerHandle lh2 =3D bk.openLedger(lh_id, DigestType.CRC32, "123" .getBytes()); lh2.addEntry("Test9".getBytes()); System.out.printf("Got %d entries for lh2 \n" ,lh2.getLastAddConfirmed()+1); seq =3D lh2.readEntries(0, lh2.getLastAddConfirmed()); while (seq.hasMoreElements()){ System.out.println(new String(seq.nextElement().getEntry())); } bk.halt(); } } Output: Got 2 entries for lh Got 3 entries for lh1 Got 6 entries for lh Teste Test2 Test3 Test4 Test5 Test6 Got 3 entries for lh1 Teste Test2 Test3 Got 3 entries for lh2 Teste Test2 Test3 --00c09fa21ac3e78508048b9e2b08--