HBASE-24196 [Shell] Add rename rsgroup command in hbase shell (#1551)

Signed-off-by: Viraj Jasani <vjasani@apache.org>
Signed-off-by: Jan Hentschel <jan.hentschel@ultratendency.com>
This commit is contained in:
Reid Chan 2020-04-21 10:22:33 +08:00 committed by GitHub
parent 2d2e1d965d
commit 9cddac01ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 0 deletions

View File

@ -185,5 +185,11 @@ module Hbase
def list_tables_in_rs_group(group_name)
@admin.listTablesInRSGroup(group_name)
end
#--------------------------------------------------------------------------
# rename rsgroup
def rename_rsgroup(oldname, newname)
@admin.renameRSGroup(oldname, newname)
end
end
end

View File

@ -508,5 +508,6 @@ Shell.load_command_group(
get_server_rsgroup
get_table_rsgroup
remove_servers_rsgroup
rename_rsgroup
]
)

View File

@ -0,0 +1,35 @@
# 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 RenameRsgroup < Command
def help
<<-EOF
Rename a RegionServer group.
hbase> rename_rsgroup 'old_rsgroup_name', 'new_rsgroup_name'
EOF
end
def command(oldname, newname)
rsgroup_admin.rename_rsgroup(oldname, newname)
end
end
end
end

View File

@ -127,5 +127,18 @@ module Hbase
@hbase.rsgroup_admin().get_rsgroup_of_table('foobar')
end
end
define_test 'Test rsgroup rename' do
old_rs_group_name = 'test_group'
new_rs_group_name = 'renamed_test_group'
table_name = 'test_table'
@hbase.rsgroup_admin.rename_rsgroup(old_rs_group_name, new_rs_group_name)
assert_not_nil(@admin.getRSGroup(new_rs_group_name))
assert_nil(@admin.getRSGroup(old_rs_group_name))
assert_equal(1, @admin.getRSGroup(new_rs_group_name).getServers.count)
assert_equal(1, @admin.listTablesInRSGroup(new_rs_group_name).count)
assert_true(@admin.listTablesInRSGroup(new_rs_group_name).contains(org.apache.hadoop.hbase.TableName.valueOf(table_name)))
end
end
end