Skip to content

Instantly share code, notes, and snippets.

@sankars
Forked from robdaemon/region_counts.rb
Last active April 29, 2017 18:21
Show Gist options
  • Save sankars/07d209879f4c6c154740c8eb41a7f801 to your computer and use it in GitHub Desktop.
Save sankars/07d209879f4c6c154740c8eb41a7f801 to your computer and use it in GitHub Desktop.
Print tables having more than one region
include Java
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()
if regions.size > 1
table_regioncounts[table_name] = regions.size
end
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