Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> Strange Problem on using HRegion's getScanner Method in RegionServer


Copy link to this message
-
Re: Strange Problem on using HRegion's getScanner Method in RegionServer
bq.  make an RPC call of my custom RPC server to scan the HRegion

How many regions do you have ?
How do you direct the RPC call to the region where the data was inserted ?

What version of HBase are you using ?

Cheers
On Tue, Dec 3, 2013 at 8:22 AM, Wukang Lin <[EMAIL PROTECTED]> wrote:

> Hi all,
>     I got a trouble in using HRegion's RegionScanner in RegionServer.
>     In my project, a custom RPC server was started in RegionServer using
> coprocessor mechanism, and it work well. In this RPC server, it receive a
> call from client, and scan the HRegion specialised by the params setted by
> the client like this:
>
> ---------------------------------------------------------------------------------------------------------------------
> HRegion region = this.getHRegionByEncodeName(encodeName);
>
> Scan scan = new Scan();
> RegionScanner scanner = null;
> try {
>       scanner = region.getScanner(scan);
>       long total = 0;
>       boolean hasNext = true;
>       List<KeyValue> kvs = new ArrayList<KeyValue>();
>       while (hasNext) {
>           kvs.clear();
>           hasNext = scanner.next(kvs);
>           if (kvs.size() > 0) {
>               total++;
>            }
>       } catch (IOException e) {
>            LOG.warn("Exception thrown when scanning region '" + regionName
> + "', SKIP IT!", e);
>       } finally {
>
>               if (scanner != null) {
>                    try {
>                         scanner.close();
>                    } catch (IOException e) {
>                          e.printStackTrace();
>                    }
>              }
>        }
>        LOG.info("Total " + total + " rows scanned.");
>
> ---------------------------------------------------------------------------------------------------------------------
> Then, I put a row to a HRegion by HTable interface, and make an RPC call of
> my custom RPC server to scan the HRegion(the code lines above is executed
> in a HRegionServer, a HRegion is scanned), and got nothing, total = 0. But
> if I use client side scan like HTable's scan interface or HBase shell, I
> can get the row I insert just now. I tried to flush the region and do a
> major compaction on the HRegion using hbase shell, Nothing changed.
> So, what's wrong with the code above? how to scan a HRegion in
> HRegionServer instance?
> Any responses is Appreciated!
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB