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 C4CFD200CC5 for ; Tue, 11 Jul 2017 15:05:54 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C35B7165DEC; Tue, 11 Jul 2017 13:05:54 +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 E1CE7165DE3 for ; Tue, 11 Jul 2017 15:05:53 +0200 (CEST) Received: (qmail 54285 invoked by uid 500); 11 Jul 2017 13:05:52 -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 54232 invoked by uid 99); 11 Jul 2017 13:05:51 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2017 13:05:50 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 5C0A7196062 for ; Tue, 11 Jul 2017 13:05:50 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.379 X-Spam-Level: X-Spam-Status: No, score=0.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id yZjfhZ-tfr2c for ; Tue, 11 Jul 2017 13:05:44 +0000 (UTC) Received: from mail-yb0-f173.google.com (mail-yb0-f173.google.com [209.85.213.173]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 129426247D for ; Tue, 11 Jul 2017 13:05:42 +0000 (UTC) Received: by mail-yb0-f173.google.com with SMTP id e201so37698596ybb.1 for ; Tue, 11 Jul 2017 06:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=34TwWSdJKn0z6CF9dm/DuEvyB95juuOo089n2r7kKG4=; b=sT6BuoK6TPiA6YmBVuHlfksXb/BLoLaG6qAP6aGZfcNFW2h97+rs0IqJDdmpDwb7+J TaFmexHLRWtkZXDW/bKTlDiDkct9bcDC/rgExjStCOEVViiMm9LqxKnNmdf9jCSukN8l IWPzSZEzTRw7tuH6OZ32+Ee5u5glCLaycRA5ZcultzMsFYdTCo4BsjKS9TdYg/OgxF4v P6pQY9KpdQ5jVX+Nrj5rAZlmIrijsFBBlEH5Wq+qiW0nrz0jZo2uyJePOl/XKbrqsjlz sgAjvLMdFlPGwDWmUZDsfjQF8VLXGQq4om8d8A3sAOddIQOHlgSTdX7W9nlAoUaQLLbj 6vOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=34TwWSdJKn0z6CF9dm/DuEvyB95juuOo089n2r7kKG4=; b=JEU01GN76rkKmXr+gtgOIxnxk3uAw/zjLqobrNdAzWWNIEy+pX3/ftyXX1fwucKmsy BIRY736QLgwiFKrquYg5d/IelJrUwrJqkiOa7WJP1pYLuzGjnayZcM7uJKySjtKtqLvA /rJW7SPJxQojeICRI+c6cucgjDqIMSdQ3aw45wzLN0a5MbGVnEczTGCAShQvYGOrjJVO 9bMQnI1Xep28EHieKRQsR/LCspWLLPt/PhDx+ea9twH+4eIJHGJ5/M60n3JWmwU//BED tjZVyaOiW6KwXYlCMTWhx2VIOh++eoygUP4+tE6u1Gyv616sFF7gey4wvqxj2l6rk1/z zZfQ== X-Gm-Message-State: AIVw111BU7iHN6Htyw/48H8VnVUM3eJzTPw390AFRKuqLTWvcdjSaGwF GPwBBLpgoCkol6ikkIp2k8WkOS/G9w== X-Received: by 10.37.201.130 with SMTP id z124mr17707297ybf.216.1499778340670; Tue, 11 Jul 2017 06:05:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.13.211.199 with HTTP; Tue, 11 Jul 2017 06:05:40 -0700 (PDT) In-Reply-To: References: From: Anoop John Date: Tue, 11 Jul 2017 18:35:40 +0530 Message-ID: Subject: Re: scope of RegionCoprocessorEnvironment sharedData To: "user@hbase.apache.org" Content-Type: text/plain; charset="UTF-8" archived-at: Tue, 11 Jul 2017 13:05:55 -0000 Ya. It is the same RegionScanner impl in use only being passed. Ya the param type should have been RegionScanner I guess. We made that mistake! -Anoop- On Mon, Jul 10, 2017 at 8:37 PM, Ted Yu wrote: > The tricky part is that postScannerNext() passes InternalScanner parameter > instead of RegionScanner. > > FYI > > On Sun, Jul 9, 2017 at 10:57 PM, Anoop John wrote: > >> Ya as Ted said, u are not getting Scan object in the postScannerNext >> and so can not make use of the attribute in Scan within this hook. >> Just setting the sharedData variable will cause issue with concurrent >> scans. (As u imagine) >> >> So I can think of solving this in 2 possible ways. (May be more ways >> possible) >> >> 1. U keep a Map within ur CP impl. You implement postScannerOpen >> where u will get the ref to Scanner been created as well as the Scan. >> If the Scan is having attribute, keep that scanner within ur Map. >> During postScannerNext check if the coming in scanner is there in ur >> Map. If so that means this is the one where u can do the action. >> Also dont forget to implement postScannerClose and remove that scanner >> from the Map. Here u might have some perf penalty as u have to add >> and get from Map which has to be a concurrent map too. >> >> Another way >> >> 2. Create a custom scanner implementing RegionScanner. The new one >> has to take an original Region Scanner and just delegate the calls. On >> postScannerOpen, u will get the original scanner been created and u >> can just wrap it with ur new scanner object. ( If the Scan object is >> having required attribute).. In postScannerNext() u can check for ur >> own RegionScanner type and if so u can do action. >> >> >> -Anoop- >> >> >> On Sat, Jul 8, 2017 at 9:13 PM, Ted Yu wrote: >> > if (canUseGetOperation(e)) { >> > //logic goes here >> > >> > Does your Get target the same region being scanned ? >> > If not, issuing the Get is not advised since the other region may be >> hosted >> > on different region server. >> > >> > Cheers >> > >> > On Thu, Jul 6, 2017 at 7:14 AM, Veerraju Tadimeti >> wrote: >> > >> >> hi, >> >> >> >> I have few questions regarding scope of *RegionCoprocessorEnvironment* >> >> sharedData. >> >> >> >> >> >> >> >> - *Is sharedData map is shared accross all instances simultaneously >> ?* >> >> - I am putting a variable in sharedData in preScannerOpen() >> based on >> >> scan attribute, >> >> - check that variable exists in postScannerNext() then apply >> logic, >> >> - remove the variable postScannerClose(). >> >> - If data is in multiple regions, when one coprocessor removes >> >> variable in postScannerClose(), will the variable is NULL for >> another >> >> region coprocessor in postScannerNext() ? >> >> >> >> >> >> - * Is sharedData map is shared across all the client request >> >> operations ?* >> >> >> >> If a variable is set in sharedData for one client operation(say SCAN), >> will >> >> the variable is available for another client operation(new SCAN) ? >> >> >> >> >> >> - *Will the variables be garbage collected even if we dont implement >> >> (removed variables in sharedData) postScannerClose() method* >> >> >> >> >> >> Please find below the logic that I am using currently >> >> *CODE: * >> >> >> >> public RegionScanner >> >> *preScannerOpen*(ObserverContext >> >> e, Scan scan, RegionScanner s) throws IOException { >> >> byte[] useGetInPostScannerNext = scan.getAttribute(USE_GET_ >> >> OPERATION_IN_POST_SCANNER_NEXT); >> >> String useGetInPostScannerNextStr = Bytes.toString( >> >> useGetInPostScannerNext); >> >> if (Boolean.parseBoolean(useGetInPostScannerNextStr)) { >> >> e.getEnvironment().getSharedData().put(USE_GET_ >> >> OPERATION_IN_POST_SCANNER_NEXT, useGetInPostScannerNextStr); >> >> } >> >> return super.preScannerOpen(e, scan, s); >> >> } >> >> >> >> @Override >> >> public boolean *postScannerNext*(final >> >> ObserverContext >> >> e, >> >> final InternalScanner s, final List results, final >> int >> >> limit, >> >> final boolean hasMore) throws IOException { >> >> try { >> >> >> >> if (canUseGetOperation(e)) { >> >> >> >> //logic goes here >> >> } >> >> } catch (Exception ex) { >> >> logger.error("Exception in postScannerNext ", ex); >> >> throw new IOException(ex); >> >> } >> >> return hasMore; >> >> } >> >> >> >> @Override >> >> public void >> >> *postScannerClose*(ObserverContext >> >> e, InternalScanner s) throws IOException { >> >> if (canUseGetOperation(e)) { >> >> e.getEnvironment().getSharedData().remove(USE_ >> >> GET_OPERATION_IN_POST_SCANNER_NEXT); >> >> } >> >> super.postScannerClose(e, s); >> >> } >> >> >> >> private boolean *canUseGetOperation*(final >> >> ObserverContext >> >> e) { >> >> String useGetOperationInPostScannerNext = (String) >> >> e.getEnvironment().getSharedData().get(USE_GET_ >> OPERATION_IN_POST_SCANNER_ >> >> NEXT); >> >> return Boolean.parseBoolean(useGetOperationInPostScannerNext); >> >> } >> >> >> >> Thanks, >> >> Raju, >> >> (972)273-0155 <(972)%20273-0155>. >> >> >>