Return-Path: X-Original-To: apmail-hbase-user-archive@www.apache.org Delivered-To: apmail-hbase-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7D13218EE0 for ; Wed, 10 Feb 2016 08:34:25 +0000 (UTC) Received: (qmail 52253 invoked by uid 500); 10 Feb 2016 08:34:24 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 52187 invoked by uid 500); 10 Feb 2016 08:34:23 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 52173 invoked by uid 99); 10 Feb 2016 08:34:23 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Feb 2016 08:34:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 3A446C0DF7 for ; Wed, 10 Feb 2016 08:34:23 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id UtHxRRu0Abz0 for ; Wed, 10 Feb 2016 08:34:21 +0000 (UTC) Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 8E4DF20507 for ; Wed, 10 Feb 2016 08:34:20 +0000 (UTC) Received: by mail-wm0-f50.google.com with SMTP id p63so17074305wmp.1 for ; Wed, 10 Feb 2016 00:34:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=HHyE9qA1zPaDk4OUzvlaOz6e+FsxrOu2U+zRxQjQ1ak=; b=QbfCcIBAHDsFo0oR0iJaKOIRAf6mab4Uq4PP2CMy9+OjAeRyJGaAJKgwNCfTgyhxhD wuLWXQj/SS6qwlHHMT7WmGa0w2jL3NWXFJErLutXC4va7F3ppqh7ueqBC0/Yk5Y1yP50 aUGSulJw7lTx/Oq/s8sz1fjVw8lFxzwtGGU7nGKEjHmjH1CSuygGxleM515cJV/eSboa NaCWmveojmbJvm8QHwCWoPwxKGHRRsTNP42Vajrj1k58TsAcI6AyTQwaYQFuGtzzfyb9 lfVz+jJYc3eH9JoHQhbfSlOtQWXHsHMXcfxAhxzuMVHndWCmkOgcd/AG5qev3T+11t9t EcIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=HHyE9qA1zPaDk4OUzvlaOz6e+FsxrOu2U+zRxQjQ1ak=; b=IBSGE297Sj7b6WkgqR5HVXVp/AS1w8yaUm3YscWH4RABbIACOt87AKqs9Yv8sOzpFA V/hHmsvrqEI242KhLslDBAQQ51Qt2W2K5+toq03zT1FL0nR0wauik85tML7lBTpTOgeG y8jH7kPbYyHLkfLyKViVz+H0IvOlKTk4jmJUumg60dak5397J8qmBsKfC3ce1KNczb7m U6xCoPudrrEh5CAAV9tbuxvOL/NbNx7MaOtUOK9nZaTPcUlzlH0TgpiS1uUV9AXMIUNT u0aXUpFWVwVS4E8hFyD9PVBQ2KTILrxpEMB0GmsAAaPC8bmX4vTGuBS8bq+yFV3TzJjl foJg== X-Gm-Message-State: AG10YOS5RfPP5j3WV6OuhFGnQFx6/btxuO57fdSaKlVlvp58TpioboTQRQYuLGwu/mY7A5yA17iCsmeU9oXm8Q== X-Received: by 10.194.103.234 with SMTP id fz10mr38718175wjb.31.1455093259199; Wed, 10 Feb 2016 00:34:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.180.68 with HTTP; Wed, 10 Feb 2016 00:33:59 -0800 (PST) In-Reply-To: References: From: Serega Sheypak Date: Wed, 10 Feb 2016 09:33:59 +0100 Message-ID: Subject: Re: Confusion with new 1.0 clint API To: user Content-Type: multipart/alternative; boundary=047d7bf109e6d47675052b664c6e --047d7bf109e6d47675052b664c6e Content-Type: text/plain; charset=UTF-8 It helped, thanks. Now I have single reusable BufferedMutator instance and I don't call .close() after mutations, I call .flush() Is it ok? 2016-02-09 23:09 GMT+01:00 Stack : > On Tue, Feb 9, 2016 at 9:46 AM, Serega Sheypak > wrote: > > > I've modified my code: > > > > void saveUsers(Collection users){ > > if(users && !users.isEmpty()){ > > > > // Get Connection instance, instance created once. , BM is > new > > for each request.' > > > > > If new for each request, don't bother using BM. Otherwise, put the BM in > same place you keep your Connection and just be sure to call close on BM > when your app goes down. > St.Ack > > > > > > > > def mutator = > > getConnection().getBufferedMutator(getBufferedMutatorParams()) > > > > List putList = users.collect{toPut(it)} > > mutator.mutate(putList) > > *mutator.close() // exception here* > > } > > } > > > > Exception is still thrown > > > > 2016-02-09 15:43 GMT+01:00 Stack : > > > > > On Tue, Feb 9, 2016 at 6:37 AM, Serega Sheypak < > serega.sheypak@gmail.com > > > > > > wrote: > > > > > > > Hi, thanks for reply! > > > > > > > > > > > > > What should we add here to make the doc more clear on > > BufferedMutator? > > > > > > > > > > > > > > > > > > > http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/BufferedMutator.html > > > > It's pretty clear. > > > > > > > > > And in the example? > > > > Example shows that both connection and buffered mutator are thread > safe > > > and > > > > they are closed at once. > > > > - Should keep single instance of connection and bufferedmutator per > > > thread? > > > > > > > > > > No. Connection says you should generally share the Connection instance. > > > Ditto for BufferedMutator. It is backed by a buffer so you are batching > > > your writes when you use it. If you share the BM, your batching will > more > > > 'regular'. > > > > > > > > > > - Should I keep connection per thread and instantiate mutator for > each > > > > request? > > > > > > > > > > See above. > > > > > > > > > > - what happens if autoflush enabled? > > > > > > > > > > When the backing buffer is full, it gets flushed to the cluster. > > > > > > > > > > - is it possible to turn on sync mode for saving data? > > > > > > > > > > Yes. Don't use a BufferedMutator. Your throughput will go down as you > do > > an > > > RPC per write. > > > > > > > > > > - Connection could get into failed/invalid state for some reason (RS > > > down, > > > > RS up, some networking partitioned happend). Is it possible? > > > > > > > > > > > > It could happen but I think by now we've seen nearly all of the ways in > > > which a Connection can fail and internally, it compensates. > > > > > > > > > > > > > If it's > > > > possible, then what is the right way to handle it: "close" failed > > > > connection and ask for new one? > > > > > > > > > > > Good question. Connection internally will retry and 'ride over' near > all > > > cluster issues but the catastrophic. > > > > > > St.Ack > > > > > > > > > > > > > > I assume users is collection of User's. > > > > > Have you tried obtaining / closing mutator for each User instead of > > > > sharing > > > > > the mutator ? > > > > > > > > > If another flush, say because there were lots of puts, then when > > close > > > > > comes in, we are out of threads and you'd get below. > > > > Looks like it's the root cause, let me try! > > > > > > > > Thank you for detailed explanation! > > > > > > > > > > > > > > > > 2016-02-09 7:10 GMT+01:00 Stack : > > > > > > > > > On Mon, Feb 8, 2016 at 3:01 PM, Serega Sheypak < > > > serega.sheypak@gmail.com > > > > > > > > > > wrote: > > > > > > > > > > > Hi, I'm confused with new HBase 1.0 API. API says that > application > > > > should > > > > > > manage connections (Previously HConnections) on their own. > Nothing > > is > > > > > > managed itnernally now. > > > > > > > > > > > > > > > > > That is right. > > > > > > > > > > > > > > > > > > > > > > > > > > Here is an example: > > > > > > > > > > > > > > > > > > > > > > > > > > > https://hbase.apache.org/xref/org/apache/hadoop/hbase/client/example/BufferedMutatorExample.html > > > > > > > > > > > > It gives no clue about lifecycle :( > > > > > > > > > > > > > > > > > > > > > Connection is fairly explicit: > > > > > > > > > > > > > > > > > > > > http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Connection.html > > > > > > > > > > What should we add here to make the doc more clear on > > BufferedMutator? > > > > > > > > > > > > > > > > > > > > http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/BufferedMutator.html > > > > > > > > > > And in the example? > > > > > > > > > > > > > > > > > > > > > Right now I create single connection instance for servlet and > > > > > > BufferedMutator per request. > > > > > > > > > > > > > > > > > > > > > > > The recommendation is a singled BufferedMutator shared across > > requests. > > > > > > > > > > > > > > > > > > > > > > > > > > //getConnection returns single instance, it doesn't return new > > > > connection > > > > > > each time > > > > > > def mutator = > > > > > > getConnection().getBufferedMutator(getBufferedMutatorParams()) > > > > > > > > > > > > > > > > > > > > > getConnection is your method? > > > > > > > > > > > > > > > getBufferedMutator creates a new one? > > > > > > > > > > > > > > > > > > > > > users.each{ mutator.mutate(toPut(it))} > > > > > > mutator.close() //exception is thrown here > > > > > > > > > > > > > > > > > The close is flushing out all the writes. > > > > > > > > > > If a BufferedMutator per servlet instance, there are probably many > > when > > > > > many requests coming in. > > > > > > > > > > See what happens when you create one: > > > > > > > > > > > > > > > > > > > > > > > > > http://hbase.apache.org/xref/org/apache/hadoop/hbase/client/ConnectionImplementation.html#313 > > > > > > > > > > which calls through to here.... > > > > > > > > > > > > > > > > > > > > http://hbase.apache.org/xref/org/apache/hadoop/hbase/client/HTable.html#126 > > > > > > > > > > ... which creates an executor of max 1 task only. > > > > > > > > > > If another flush, say because there were lots of puts, then when > > close > > > > > comes in, we are out of threads and you'd get below. > > > > > > > > > > St.Ack > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > And I get tons of exceptions thrown on "mutator.close()", what > do I > > > do > > > > > > wrong? > > > > > > > > > > > > WARNING: #905, the task was rejected by the pool. This is > > unexpected. > > > > > > Server is node04.server.com, 60020,1447338864601 > > > > > > java.util.concurrent.RejectedExecutionException: Task > > > > > > java.util.concurrent.FutureTask@5cff3b40 rejected from > > > > > > java.util.concurrent.ThreadPoolExecutor@686c2853[Terminated, > pool > > > > size = > > > > > > 0, > > > > > > active threads = 0, queued tasks = 0, completed tasks = 1] > > > > > > at > > > > > > > > > > > > > > > > > > > > > > > > > > > java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047) > > > > > > at > > > > > > > > > > > > > > > > > > > > > java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823) > > > > > > at > > > > > > > > > > > > > > > > > > > > > > > > > > > java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369) > > > > > > at > > > > > > > > > > > > > > > > > > > > > > > > > > > java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112) > > > > > > at > > > > > > > > > > > > > > > > > > > > > > > > > > > org.apache.hadoop.hbase.client.AsyncProcess$AsyncRequestFutureImpl.sendMultiAction(AsyncProcess.java:956) > > > > > > at > > > > > > > > > > > > > > > > > > > > > > > > > > > org.apache.hadoop.hbase.client.AsyncProcess$AsyncRequestFutureImpl.access$000(AsyncProcess.java:574) > > > > > > at > > > > > > > > > > > > > > > > > > > > > > > > > > > org.apache.hadoop.hbase.client.AsyncProcess.submitMultiActions(AsyncProcess.java:423) > > > > > > at > > > > > > > > > > > > org.apache.hadoop.hbase.client.AsyncProcess.submit(AsyncProcess.java:403) > > > > > > at > > > > > > > > > > > > org.apache.hadoop.hbase.client.AsyncProcess.submit(AsyncProcess.java:320) > > > > > > at > > > > > > > > > > > > > > > > > > > > > > > > > > > org.apache.hadoop.hbase.client.BufferedMutatorImpl.backgroundFlushCommits(BufferedMutatorImpl.java:206) > > > > > > at > > > > > > > > > > > > > > > > > > > > > > > > > > > org.apache.hadoop.hbase.client.BufferedMutatorImpl.close(BufferedMutatorImpl.java:158) > > > > > > at > > > org.apache.hadoop.hbase.client.BufferedMutator$close$0.call(Unknown > > > > > > Source) > > > > > > > > > > > > > > > > > > > > > --047d7bf109e6d47675052b664c6e--