[ 
https://issues.apache.org/jira/browse/HBASE-3577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12999850#comment-12999850
 ] 

Kazuki Ohta commented on HBASE-3577:
------------------------------------

The attached patch added two interfaces to Thrift api.

{code}

  /**
   * Get all the regions and their address for a specified table.
   *
   * @return A map of TRegionInfo with its server address
   */
  map<TRegionInfo, TServerAddress> getRegionsInfo(
    /** table name */
    1:Text tableName)
    throws (1:IOError io)

  /**
   * Find the region on which given row is being served.
   *
   * @return Location of the row.
   */
  TRegionLocation getRegionLocation(
    /** table name */
    1:Text tableName,
    /** row key */
    2:Text row)
    throws (1:IOError io)
{code}

I confirmed the behavior via Ruby program below.

{code}
require 'rubygems'
require 'thrift'
require 'thrift/transport/socket'
require 'thrift/transport/buffered_transport'
require 'thrift/protocol/binary_protocol'
require 'hbase'
require 'hbase_types'

socket = Thrift::Socket.new('localhost', 8181)
transport = Thrift::BufferedTransport.new(socket)
protocol = Thrift::BinaryProtocol.new(transport)
client = Apache::Hadoop::Hbase::Thrift::Hbase::Client.new(protocol)
transport.open();
begin
  p client.getTableNames()
  p client.compact("sample")
  p client.getTableRegions("sample")
  p client.getRegionsInfo("sample")
  location = client.getRegionLocation("sample", "row0")
  p location.serverAddress.host
  p location.serverAddress.port  
ensure
  transport.close()
end
{code}

{code}
$ ruby client.rb
["sample"]
nil
[<Apache::Hadoop::Hbase::Thrift::TRegionInfo startKey:, endKey:, 
id:1294007944410, 
name:73616d706c652c2c313239343030373934343431302e35313633306364343333666431626532646339663831373537613332303234342e,
 version:0>]
{<Apache::Hadoop::Hbase::Thrift::TRegionInfo startKey:, endKey:, 
id:1294007944410, 
name:73616d706c652c2c313239343030373934343431302e35313633306364343333666431626532646339663831373537613332303234342e,
 version:0>=><Apache::Hadoop::Hbase::Thrift::TServerAddress 
host:3139322e3136382e312e313030, port:53679>}
"192.168.1.100"
53679
{code}

One question here. The patch must include the files which are auto-generated by 
thrift. Currently, thrift uses version 0.2.0? Get the thrift below, and then 
generating the java-files are just fine?

* http://www.apache.org/dist/incubator/thrift/0.2.0-incubating/

Thanks Kazuki

> enables Thrift client to get the Region location
> ------------------------------------------------
>
>                 Key: HBASE-3577
>                 URL: https://issues.apache.org/jira/browse/HBASE-3577
>             Project: HBase
>          Issue Type: Improvement
>          Components: thrift
>            Reporter: Kazuki Ohta
>         Attachments: HBASE3577-1.patch
>
>
> The current thrift interface has the getTableRegions() interface like below.
> {code}
>   list<TRegionInfo> getTableRegions(
>     /** table name */
>     1:Text tableName)
>     throws (1:IOError io)
> {code}
> {code}
> struct TRegionInfo {
>   1:Text startKey,
>   2:Text endKey,
>   3:i64 id,
>   4:Text name,
>   5:byte version
> }
> {code}
> But the method don't have the region location information (where the region 
> is located).
> I want to add the Thrift interfaces like below in HTable.java.
> {code}
> public Map<HRegionInfo, HServerAddress> getRegionsInfo() throws IOException
> {code}
> {code}
> public HRegionLocation getRegionLocation(final String row)
> {code}

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to