You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by vj...@apache.org on 2021/01/19 09:22:44 UTC

[hbase] branch branch-2 updated: HBASE-25496 add get_namespace_rsgroup command (#2874)

This is an automated email from the ASF dual-hosted git repository.

vjasani pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new c95c090  HBASE-25496 add get_namespace_rsgroup command (#2874)
c95c090 is described below

commit c95c09064ce670bc0db75921c31d40b7f96309f7
Author: xijiawen <15...@163.com>
AuthorDate: Tue Jan 19 17:21:01 2021 +0800

    HBASE-25496 add get_namespace_rsgroup command (#2874)
    
    Signed-off-by: Viraj Jasani <vj...@apache.org>
---
 hbase-shell/src/main/ruby/hbase/admin.rb           | 10 ++++++
 hbase-shell/src/main/ruby/shell.rb                 |  1 +
 .../ruby/shell/commands/get_namespace_rsgroup.rb   | 41 ++++++++++++++++++++++
 3 files changed, 52 insertions(+)

diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb
index 0f1b653..776c9e3 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -1384,6 +1384,16 @@ module Hbase
     end
 
     #----------------------------------------------------------------------------------------------
+    # Get namespace's rsgroup
+    def get_namespace_rsgroup(namespace_name)
+      # Fail if namespace name is not a string
+      raise(ArgumentError, 'Namespace name must be of type String') unless namespace_name.is_a?(String)
+      nsd = @admin.getNamespaceDescriptor(namespace_name)
+      raise(ArgumentError, 'Namespace does not exist') unless nsd
+      nsd.getConfigurationValue("hbase.rsgroup.name")
+    end
+
+    #----------------------------------------------------------------------------------------------
     # Drops a table
     def drop_namespace(namespace_name)
       @admin.deleteNamespace(namespace_name)
diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb
index 96b7fe2..889c143 100644
--- a/hbase-shell/src/main/ruby/shell.rb
+++ b/hbase-shell/src/main/ruby/shell.rb
@@ -627,5 +627,6 @@ Shell.load_command_group(
     rename_rsgroup
     alter_rsgroup_config
     show_rsgroup_config
+    get_namespace_rsgroup
   ]
 )
diff --git a/hbase-shell/src/main/ruby/shell/commands/get_namespace_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/get_namespace_rsgroup.rb
new file mode 100644
index 0000000..a4991d1
--- /dev/null
+++ b/hbase-shell/src/main/ruby/shell/commands/get_namespace_rsgroup.rb
@@ -0,0 +1,41 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+module Shell
+  module Commands
+    class GetNamespaceRsgroup < Command
+      def help
+        <<-EOF
+Get the group name the given NameSpace is a member of.
+
+Example:
+
+  hbase> get_namespace_rsgroup 'namespace_name'
+
+EOF
+      end
+
+      def command(namespace_name)
+        group_name = admin.get_namespace_rsgroup(namespace_name)
+        unless group_name.nil?
+          formatter.row([group_name])
+        end
+        formatter.footer(1)
+      end
+    end
+  end
+end
\ No newline at end of file