Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5F643200CEE for ; Mon, 7 Aug 2017 20:32:34 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5DF9A165D32; Mon, 7 Aug 2017 18:32:34 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8429D165D2E for ; Mon, 7 Aug 2017 20:32:33 +0200 (CEST) Received: (qmail 71702 invoked by uid 500); 7 Aug 2017 18:32:32 -0000 Mailing-List: contact commits-help@bookkeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bookkeeper-dev@bookkeeper.apache.org Delivered-To: mailing list commits@bookkeeper.apache.org Received: (qmail 71613 invoked by uid 99); 7 Aug 2017 18:32:32 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Aug 2017 18:32:32 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 4849C811AF; Mon, 7 Aug 2017 18:32:30 +0000 (UTC) Date: Mon, 07 Aug 2017 18:32:30 +0000 To: "commits@bookkeeper.apache.org" Subject: [bookkeeper] branch master updated: ISSUE #366: [DOCUMENTATION] LedgerHandleAdv MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <150213075079.22769.17606482006182986075@gitbox.apache.org> From: sijie@apache.org Reply-To: "commits@bookkeeper.apache.org" X-Git-Host: gitbox.apache.org X-Git-Repo: bookkeeper X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: ae1ba84f0935fdac43e7dd500647a70b2c4ca7f3 X-Git-Newrev: 188d7e5fb8d8beb137f13a49b7df8a9cd861cefc X-Git-Rev: 188d7e5fb8d8beb137f13a49b7df8a9cd861cefc X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated archived-at: Mon, 07 Aug 2017 18:32:34 -0000 This is an automated email from the ASF dual-hosted git repository. sijie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/bookkeeper.git The following commit(s) were added to refs/heads/master by this push: new 188d7e5 ISSUE #366: [DOCUMENTATION] LedgerHandleAdv 188d7e5 is described below commit 188d7e5fb8d8beb137f13a49b7df8a9cd861cefc Author: Sijie Guo AuthorDate: Mon Aug 7 11:32:22 2017 -0700 ISSUE #366: [DOCUMENTATION] LedgerHandleAdv Descriptions of the changes in this PR: - add documentation about LedgerHandleAdv - update overview Author: Sijie Guo Reviewers: Jia Zhai , Matteo Merli This closes #401 from sijie/issue_366, closes #366 --- site/_data/sidebar.yaml | 2 + site/docs/latest/api/ledger-adv-api.md | 82 ++++++++++++++++++++++++++++++++++ site/docs/latest/api/overview.md | 11 +++-- 3 files changed, 91 insertions(+), 4 deletions(-) diff --git a/site/_data/sidebar.yaml b/site/_data/sidebar.yaml index ec7bf17..0138070 100644 --- a/site/_data/sidebar.yaml +++ b/site/_data/sidebar.yaml @@ -39,6 +39,8 @@ groups: endpoint: overview - name: Ledger API endpoint: ledger-api + - name: Advanced Ledger API + endpoint: ledger-adv-api - name: DistributedLog endpoint: distributedlog-api - name: Development diff --git a/site/docs/latest/api/ledger-adv-api.md b/site/docs/latest/api/ledger-adv-api.md new file mode 100644 index 0000000..f46950d --- /dev/null +++ b/site/docs/latest/api/ledger-adv-api.md @@ -0,0 +1,82 @@ +--- +title: The Advanced Ledger API +--- + +In release `4.5.0`, Apache BookKeeper introduces a few advanced API for advanced usage. +This sections covers these advanced APIs. + +> Before learn the advanced API, please read [Ledger API](../ledger-api) first. + +## LedgerHandleAdv + +[`LedgerHandleAdv`](../javadoc/org/apache/bookkeeper/client/LedgerHandleAdv) is an advanced extension of [`LedgerHandle`](../javadoc/org/apache/bookkeeper/client/LedgerHandle). +It allows user passing in an `entryId` when adding an entry. + +### Creating advanced ledgers + +Here's an exmaple: + +```java +byte[] passwd = "some-passwd".getBytes(); +LedgerHandleAdv handle = bkClient.createLedgerAdv( + 3, 3, 2, // replica settings + DigestType.CRC32, + passwd); +``` + +You can also create advanced ledgers asynchronously. + +```java +class LedgerCreationCallback implements AsyncCallback.CreateCallback { + public void createComplete(int returnCode, LedgerHandle handle, Object ctx) { + System.out.println("Ledger successfully created"); + } +} +client.asyncCreateLedgerAdv( + 3, // ensemble size + 3, // write quorum size + 2, // ack quorum size + BookKeeper.DigestType.CRC32, + password, + new LedgerCreationCallback(), + "some context" +); +``` + +Besides the APIs above, BookKeeper allows users providing `ledger-id` when creating advanced ledgers. + +```java +long ledgerId = ...; // the ledger id is generated externally. + +byte[] passwd = "some-passwd".getBytes(); +LedgerHandleAdv handle = bkClient.createLedgerAdv( + ledgerId, // ledger id generated externally + 3, 3, 2, // replica settings + DigestType.CRC32, + passwd); +``` + +> Please note, it is users' responsibility to provide a unique ledger id when using the API above. +> If a ledger already exists when users try to create an advanced ledger with same ledger id, +> a [LedgerExistsException](../javadoc/org/apache/bookkeeper/client/BKException.BKLedgerExistException.html) is thrown by the bookkeeper client. + +### Add Entries + +The normal [add entries api](ledger-api/#adding-entries-to-ledgers) in advanced ledgers are disabled. Instead, when users want to add entries +to advanced ledgers, an entry id is required to pass in along with the entry data when adding an entry. + +```java +long entryId = ...; // entry id generated externally + +ledger.addEntry(entryId, "Some entry data".getBytes()); +``` + +A few notes when using this API: + +- The entry id has to be non-negative. +- Clients are okay to add entries out of order. +- However, the entries are only acknowledged in a monotonic order starting from 0. + +### Read Entries + +The read entries api in advanced ledgers remain same as [normal ledgers](../ledger-api/#reading-entries-from-ledgers). diff --git a/site/docs/latest/api/overview.md b/site/docs/latest/api/overview.md index 2940750..3eb6492 100644 --- a/site/docs/latest/api/overview.md +++ b/site/docs/latest/api/overview.md @@ -1,14 +1,17 @@ --- -title: The ledger API vs. the DistributedLog API +title: BookKeeper API --- -BookKeeper offers two APIs that applications can use to interact with it: +BookKeeper offers a few APIs that applications can use to interact with it: * The [ledger API](../ledger-api) is a lower-level API that enables you to interact with {% pop ledgers %} directly +* The [Ledger Advanced API)(../ledger-adv-api) is an advanced extension to [Ledger API](../ledger-api) to provide more flexibilities to applications. * The [DistributedLog API](../distributedlog-api) is a higher-level API that provides convenient abstractions. ## Trade-offs -The advantage of the ledger API is that it provides direct access to ledgers and thus enables you to use BookKeeper however you'd like. The disadvantage is that it requires you to manage things like leader election on your own. +The `Ledger API` provides direct access to ledgers and thus enables you to use BookKeeper however you'd like. -The advantage of the DistributedLog API is that it's easier to use, with semantics resembling a simple key/value store from the standpoint of applications. The disadvantage is that \ No newline at end of file +However, in most of use cases, if you want a `log stream`-like abstraction, it requires you to manage things like tracking list of ledgers, +managing rolling ledgers and data retention on your own. In such cases, you are recommended to use [DistributedLog API](../distributedlog-api), +with semantics resembling continous log streams from the standpoint of applications. -- To stop receiving notification emails like this one, please contact ['"commits@bookkeeper.apache.org" '].