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:28:10 UTC
[hbase] branch branch-2.3 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.3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.3 by this push:
new 013f2d5 HBASE-25496 add get_namespace_rsgroup command (#2874)
013f2d5 is described below
commit 013f2d5be93aa0df702678ec3e9c1edd9d21388a
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 1507c7a..6b9036c 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -1328,6 +1328,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 6303d6b..0b2ab9a 100644
--- a/hbase-shell/src/main/ruby/shell.rb
+++ b/hbase-shell/src/main/ruby/shell.rb
@@ -508,5 +508,6 @@ Shell.load_command_group(
get_table_rsgroup
remove_servers_rsgroup
rename_rsgroup
+ 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