HBASE-6642 enable_all,disable_all,drop_all can call 'list' command with regex directly
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1570128 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ec0ec19d7d
commit
57671618b5
|
@ -721,8 +721,8 @@ module Hbase
|
|||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
# Returns a list of snapshots
|
||||
def list_snapshot
|
||||
@admin.listSnapshots
|
||||
def list_snapshot(regex = ".*")
|
||||
@admin.listSnapshots(regex).to_a
|
||||
end
|
||||
|
||||
# Apply config specific to a table/column to its descriptor
|
||||
|
@ -748,8 +748,10 @@ module Hbase
|
|||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
# Returns a list of namespaces in hbase
|
||||
def list_namespace
|
||||
@admin.listNamespaceDescriptors.map { |ns| ns.getName }
|
||||
def list_namespace(regex = ".*")
|
||||
pattern = java.util.regex.Pattern.compile(regex)
|
||||
list = @admin.listNamespaceDescriptors.map { |ns| ns.getName }
|
||||
list.select {|s| pattern.match(s) }
|
||||
end
|
||||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -45,8 +45,10 @@ module Hbase
|
|||
|
||||
#---------------------------------------------------------------------------------------------
|
||||
# Show replcated tables/column families, and their ReplicationType
|
||||
def list_replicated_tables
|
||||
@replication_admin.listReplicated()
|
||||
def list_replicated_tables(regex = ".*")
|
||||
pattern = java.util.regex.Pattern.compile(regex)
|
||||
list = @replication_admin.listReplicated()
|
||||
list.select {|s| pattern.match(s.get(org.apache.hadoop.hbase.client.replication.ReplicationAdmin::TNAME))}
|
||||
end
|
||||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -31,8 +31,7 @@ EOF
|
|||
end
|
||||
|
||||
def command(regex)
|
||||
regex = /^#{regex}$/ unless regex.is_a?(Regexp)
|
||||
list = admin.list.grep(regex)
|
||||
list = admin.list(regex)
|
||||
count = list.size
|
||||
list.each do |table|
|
||||
formatter.row([ table ])
|
||||
|
|
|
@ -31,8 +31,7 @@ EOF
|
|||
end
|
||||
|
||||
def command(regex)
|
||||
regex = /^#{regex}$/ unless regex.is_a?(Regexp)
|
||||
list = admin.list.grep(regex)
|
||||
list = admin.list(regex)
|
||||
count = list.size
|
||||
list.each do |table|
|
||||
formatter.row([ table ])
|
||||
|
|
|
@ -31,8 +31,7 @@ EOF
|
|||
end
|
||||
|
||||
def command(regex)
|
||||
regex = /^#{regex}$/ unless regex.is_a?(Regexp)
|
||||
list = admin.list.grep(regex)
|
||||
list = admin.list(regex)
|
||||
count = list.size
|
||||
list.each do |table|
|
||||
formatter.row([ table ])
|
||||
|
|
|
@ -34,8 +34,7 @@ EOF
|
|||
now = Time.now
|
||||
formatter.header([ "NAMESPACE" ])
|
||||
|
||||
regex = /#{regex}/ unless regex.is_a?(Regexp)
|
||||
list = admin.list_namespace.grep(regex)
|
||||
list = admin.list_namespace(regex)
|
||||
list.each do |table|
|
||||
formatter.row([ table ])
|
||||
end
|
||||
|
|
|
@ -34,9 +34,7 @@ EOF
|
|||
now = Time.now
|
||||
|
||||
formatter.header([ "TABLE:COLUMNFAMILY", "ReplicationType" ], [ 32 ])
|
||||
list = replication_admin.list_replicated_tables
|
||||
regex = /#{regex}/ unless regex.is_a?(Regexp)
|
||||
list = list.select {|s| regex.match(s.get(org.apache.hadoop.hbase.client.replication.ReplicationAdmin::TNAME))}
|
||||
list = replication_admin.list_replicated_tables(regex)
|
||||
list.each do |e|
|
||||
if e.get(org.apache.hadoop.hbase.client.replication.ReplicationAdmin::REPLICATIONTYPE) == org.apache.hadoop.hbase.client.replication.ReplicationAdmin::REPLICATIONGLOBAL
|
||||
replicateType = "GLOBAL"
|
||||
|
|
|
@ -37,8 +37,7 @@ EOF
|
|||
now = Time.now
|
||||
formatter.header([ "SNAPSHOT", "TABLE + CREATION TIME"])
|
||||
|
||||
regex = /#{regex}/ unless regex.is_a?(Regexp)
|
||||
list = admin.list_snapshot.select {|s| regex.match(s.getName)}
|
||||
list = admin.list_snapshot(regex)
|
||||
list.each do |snapshot|
|
||||
creation_time = Time.at(snapshot.getCreationTime() / 1000).to_s
|
||||
formatter.row([ snapshot.getName, snapshot.getTable + " (" + creation_time + ")" ])
|
||||
|
|
Loading…
Reference in New Issue