hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject svn commit: r1570328 - in /hbase/branches/0.98/hbase-shell/src/main/ruby: hbase/ shell/commands/
Date Thu, 20 Feb 2014 19:45:48 GMT
Author: mbertozzi
Date: Thu Feb 20 19:45:47 2014
New Revision: 1570328

URL: http://svn.apache.org/r1570328
Log:
HBASE-6642 enable_all,disable_all,drop_all can call 'list' command with regex directly

Modified:
    hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/admin.rb
    hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/replication_admin.rb
    hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/disable_all.rb
    hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/drop_all.rb
    hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/enable_all.rb
    hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb
    hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_replicated_tables.rb
    hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb

Modified: hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/admin.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/admin.rb?rev=1570328&r1=1570327&r2=1570328&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/admin.rb (original)
+++ hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/admin.rb Thu Feb 20 19:45:47 2014
@@ -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
 
     #----------------------------------------------------------------------------------------------

Modified: hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/replication_admin.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/replication_admin.rb?rev=1570328&r1=1570327&r2=1570328&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/replication_admin.rb (original)
+++ hbase/branches/0.98/hbase-shell/src/main/ruby/hbase/replication_admin.rb Thu Feb 20 19:45:47
2014
@@ -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
 
     #----------------------------------------------------------------------------------------------

Modified: hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/disable_all.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/disable_all.rb?rev=1570328&r1=1570327&r2=1570328&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/disable_all.rb (original)
+++ hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/disable_all.rb Thu Feb 20
19:45:47 2014
@@ -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 ])

Modified: hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/drop_all.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/drop_all.rb?rev=1570328&r1=1570327&r2=1570328&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/drop_all.rb (original)
+++ hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/drop_all.rb Thu Feb 20 19:45:47
2014
@@ -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 ])

Modified: hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/enable_all.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/enable_all.rb?rev=1570328&r1=1570327&r2=1570328&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/enable_all.rb (original)
+++ hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/enable_all.rb Thu Feb 20
19:45:47 2014
@@ -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 ])

Modified: hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb?rev=1570328&r1=1570327&r2=1570328&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb (original)
+++ hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb Thu Feb
20 19:45:47 2014
@@ -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

Modified: hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_replicated_tables.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_replicated_tables.rb?rev=1570328&r1=1570327&r2=1570328&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_replicated_tables.rb
(original)
+++ hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_replicated_tables.rb
Thu Feb 20 19:45:47 2014
@@ -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"

Modified: hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb?rev=1570328&r1=1570327&r2=1570328&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb (original)
+++ hbase/branches/0.98/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb Thu Feb
20 19:45:47 2014
@@ -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 + ")"
])



Mime
View raw message