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 <vboylin1...@gmail.com> 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!
>

Reply via email to