diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb index 0f1b6539ee2..776c9e3f4ee 100644 --- a/hbase-shell/src/main/ruby/hbase/admin.rb +++ b/hbase-shell/src/main/ruby/hbase/admin.rb @@ -1383,6 +1383,16 @@ module Hbase @admin.modifyNamespace(nsb.build) 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) diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb index 96b7fe22995..889c143cd2c 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 00000000000..a4991d16943 --- /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