Skip to content

Instantly share code, notes, and snippets.

@robdaemon
Created March 8, 2013 21:25
Show Gist options
  • Save robdaemon/5120004 to your computer and use it in GitHub Desktop.
Save robdaemon/5120004 to your computer and use it in GitHub Desktop.
Get region counts for an HBase service
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