Created
March 8, 2013 21:25
-
-
Save robdaemon/5120004 to your computer and use it in GitHub Desktop.
Get region counts for an HBase service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.hadoop.hbase.HBaseConfiguration | |
import org.apache.hadoop.hbase.client.HBaseAdmin | |
import org.apache.hadoop.hbase.client.HTable | |
import org.apache.hadoop.hbase.util.Bytes | |
conf = HBaseConfiguration.create() | |
admin = HBaseAdmin.new(conf) | |
tables = admin.listTables() | |
table_regioncounts = {} | |
tables.each do |t| | |
table_name = Bytes.toString(t.getName()) | |
table_handle = HTable.new(conf, table_name) | |
regions = table_handle.getRegionsInfo() | |
table_regioncounts[table_name] = regions.size | |
table_handle.close | |
end | |
puts table_regioncounts.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment