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:
mbertozzi 2014-02-20 10:08:54 +00:00
parent ec0ec19d7d
commit 57671618b5
8 changed files with 16 additions and 19 deletions

View File

@ -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
#----------------------------------------------------------------------------------------------

View File

@ -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
#----------------------------------------------------------------------------------------------

View File

@ -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 ])

View File

@ -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 ])

View File

@ -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 ])

View File

@ -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

View File

@ -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"

View File

@ -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 + ")" ])