[
https://issues.apache.org/jira/browse/HBASE-14925?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15832660#comment-15832660
]
ronan stokes edited comment on HBASE-14925 at 1/21/17 12:22 AM:
----------------------------------------------------------------
Here's one mechanism to get the regions for a particular table from the shell -
it would be relatively easy to turn it into a command. It's a little hackish as
it reads an internal variable of the shell admin instance but when integrated
as a command, it could use an appropriate mechanism...
\# list_regions
\# return list of regions for a table as an array
\# results are ordered by start key
\# each element of list is hash of \{ "name","size", "requests" \}
\#
def list_regions(tgtTable)
hbadmin = @hbase.admin(@hbase)
hbjadmin = hbadmin.instance_variable_get("@admin")
cluster_status = hbjadmin.getClusterStatus()
master = cluster_status.getMaster()
results = Array.new
for server in cluster_status.getServers()
for name,region in cluster_status.getLoad(server).getRegionsLoad()
region_name = region.getNameAsString()
regionStoreFileSize = region.getStorefileSizeMB()
regionRequests = region.getRequestsCount()
if region_name.start_with? tgtTable
results << { "server" => server, "name" => region_name, "size" =>
regionStoreFileSize, "requests" => regionRequests }
end
end
end
results.sort!{ |a,b| a["name"].split(',')[1] <=> b["name"].split(',')[1] }
return results
end
was (Author: [email protected]):
Here's one mechanism to get the regions for a particular table from the shell -
it would be relatively easy to turn it into a command. It's a little hackish as
it reads an internal variable of the shell admin instance but when integrated
as a command, it could use an appropriate mechanism...
\# list_regions
\# return list of regions for a table as an array
\# results are ordered by start key
\# each element of list is hash of { "name","size", "requests" }
\#
def list_regions(tgtTable)
hbadmin = @hbase.admin(@hbase)
hbjadmin = hbadmin.instance_variable_get("@admin")
cluster_status = hbjadmin.getClusterStatus()
master = cluster_status.getMaster()
results = Array.new
for server in cluster_status.getServers()
for name,region in cluster_status.getLoad(server).getRegionsLoad()
region_name = region.getNameAsString()
regionStoreFileSize = region.getStorefileSizeMB()
regionRequests = region.getRequestsCount()
if region_name.start_with? tgtTable
results << { "server" => server, "name" => region_name, "size" =>
regionStoreFileSize, "requests" => regionRequests }
end
end
end
results.sort!{ |a,b| a["name"].split(',')[1] <=> b["name"].split(',')[1] }
return results
end
> Develop HBase shell command/tool to list table's region info through command
> line
> ---------------------------------------------------------------------------------
>
> Key: HBASE-14925
> URL: https://issues.apache.org/jira/browse/HBASE-14925
> Project: HBase
> Issue Type: Improvement
> Components: shell
> Reporter: Romil Choksi
> Assignee: huaxiang sun
>
> I am going through the hbase shell commands to see if there is anything I can
> use to get all the regions info just for a particular table. I don’t see any
> such command that provides me that information.
> It would be better to have a command that provides region info, start key,
> end key etc taking a table name as the input parameter. This is available
> through HBase UI on clicking on a particular table's link
> A tool/shell command to get a list of regions for a table or all tables in a
> tabular structured output (that is machine readable)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)