HBASE-24803 Unify hbase-shell ::Shell::Commands::Command#help behavior (#2178)
- Update all hbase-shell commands to return help text implicitly - Add hbase-shell test to ensure all help methods return unindented text - Set the outermost indentation to zero for the help text of all hbase-shell commands by using the squiggly heredoc added in Ruby 2.3.0. - Document return value of hbck_chore_run and add usage examples to truncate commands - Update docs to reflect current return value of list command Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
1c45c8c7db
commit
271a3cbf13
@ -22,7 +22,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class AppendPeerNamespaces < Command
|
class AppendPeerNamespaces < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Append some namespaces to be replicable for the specified peer.
|
Append some namespaces to be replicable for the specified peer.
|
||||||
|
|
||||||
Set a namespace in the peer config means that all tables in this
|
Set a namespace in the peer config means that all tables in this
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class ClearCompactionQueues < Command
|
class ClearCompactionQueues < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Clear compacting queues on a regionserver.
|
Clear compacting queues on a regionserver.
|
||||||
The queue_name contains short and long.
|
The queue_name contains short and long.
|
||||||
short is shortCompactions's queue,long is longCompactions's queue.
|
short is shortCompactions's queue,long is longCompactions's queue.
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class ClearDeadservers < Command
|
class ClearDeadservers < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Clear the dead region servers that are never used. Returns an array containing any
|
Clear the dead region servers that are never used. Returns an array containing any
|
||||||
deadservers that could not be cleared.
|
deadservers that could not be cleared.
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
# create a new table by cloning the existent table schema.
|
# create a new table by cloning the existent table schema.
|
||||||
class CloneTableSchema < Command
|
class CloneTableSchema < Command
|
||||||
def help
|
def help
|
||||||
<<-HELP
|
<<~HELP
|
||||||
Create a new table by cloning the existent table schema.
|
Create a new table by cloning the existent table schema.
|
||||||
There're no copies of data involved.
|
There're no copies of data involved.
|
||||||
Just copy the table descriptor and split keys.
|
Just copy the table descriptor and split keys.
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class Compact < Command
|
class Compact < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Compact all regions in passed table or pass a region row
|
Compact all regions in passed table or pass a region row
|
||||||
to compact an individual region. You can also compact a single column
|
to compact an individual region. You can also compact a single column
|
||||||
family within a region.
|
family within a region.
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class CompactRs < Command
|
class CompactRs < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Compact all regions on passed regionserver.
|
Compact all regions on passed regionserver.
|
||||||
Examples:
|
Examples:
|
||||||
Compact all regions on a regionserver:
|
Compact all regions on a regionserver:
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class CompactionState < Command
|
class CompactionState < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Gets compaction status (MAJOR, MAJOR_AND_MINOR, MINOR, NONE) for a table:
|
Gets compaction status (MAJOR, MAJOR_AND_MINOR, MINOR, NONE) for a table:
|
||||||
hbase> compaction_state 'ns1:t1'
|
hbase> compaction_state 'ns1:t1'
|
||||||
hbase> compaction_state 't1'
|
hbase> compaction_state 't1'
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
# Switch compaction for a region server
|
# Switch compaction for a region server
|
||||||
class CompactionSwitch < Command
|
class CompactionSwitch < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Turn the compaction on or off on regionservers. Disabling compactions will also interrupt
|
Turn the compaction on or off on regionservers. Disabling compactions will also interrupt
|
||||||
any currently ongoing compactions. This state is ephemeral. The setting will be lost on
|
any currently ongoing compactions. This state is ephemeral. The setting will be lost on
|
||||||
restart of the server. Compaction can also be enabled/disabled by modifying configuration
|
restart of the server. Compaction can also be enabled/disabled by modifying configuration
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
# Decommission a list of region servers, optionally offload corresponding regions
|
# Decommission a list of region servers, optionally offload corresponding regions
|
||||||
class DecommissionRegionservers < Command
|
class DecommissionRegionservers < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Mark region server(s) as decommissioned to prevent additional regions from
|
Mark region server(s) as decommissioned to prevent additional regions from
|
||||||
getting assigned to them.
|
getting assigned to them.
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class DisableRpcThrottle < Command
|
class DisableRpcThrottle < Command
|
||||||
def help
|
def help
|
||||||
return <<-EOF
|
<<-EOF
|
||||||
Disable quota rpc throttle. Returns previous rpc throttle enabled value.
|
Disable quota rpc throttle. Returns previous rpc throttle enabled value.
|
||||||
NOTE: if quota is not enabled, this will not work and always return false.
|
NOTE: if quota is not enabled, this will not work and always return false.
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class EnableRpcThrottle < Command
|
class EnableRpcThrottle < Command
|
||||||
def help
|
def help
|
||||||
return <<-EOF
|
<<-EOF
|
||||||
Enable quota rpc throttle. Returns previous rpc throttle enabled value.
|
Enable quota rpc throttle. Returns previous rpc throttle enabled value.
|
||||||
NOTE: if quota is not enabled, this will not work and always return false.
|
NOTE: if quota is not enabled, this will not work and always return false.
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class GetPeerConfig < Command
|
class GetPeerConfig < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Outputs the cluster key, replication endpoint class (if present), and any replication configuration parameters
|
Outputs the cluster key, replication endpoint class (if present), and any replication configuration parameters
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,8 @@ module Shell
|
|||||||
<<-EOF
|
<<-EOF
|
||||||
Request HBCK chore to run at master side. It will try to find the orphan
|
Request HBCK chore to run at master side. It will try to find the orphan
|
||||||
regions on RegionServer or FileSystem and find the inconsistent regions.
|
regions on RegionServer or FileSystem and find the inconsistent regions.
|
||||||
You can check the HBCK report at Master web UI.
|
You can check the HBCK report at Master web UI. Returns true if HBCK chore
|
||||||
|
ran, or false if HBCK chore is already running.
|
||||||
|
|
||||||
hbase> hbck_chore_run
|
hbase> hbck_chore_run
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class ListDeadservers < Command
|
class ListDeadservers < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
List all dead region servers in hbase
|
List all dead region servers in hbase
|
||||||
Examples:
|
Examples:
|
||||||
hbase> list_deadservers
|
hbase> list_deadservers
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
# List decommissioned region servers
|
# List decommissioned region servers
|
||||||
class ListDecommissionedRegionservers < Command
|
class ListDecommissionedRegionservers < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
List region servers marked as decommissioned, which can not be assigned regions.
|
List region servers marked as decommissioned, which can not be assigned regions.
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
@ -19,7 +19,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class ListPeerConfigs < Command
|
class ListPeerConfigs < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
No-argument method that outputs the replication peer configuration for each peer defined on this cluster.
|
No-argument method that outputs the replication peer configuration for each peer defined on this cluster.
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class ListPeers < Command
|
class ListPeers < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
List all replication peer clusters.
|
List all replication peer clusters.
|
||||||
|
|
||||||
If replicate_all flag is false, the namespaces and table-cfs in peer config
|
If replicate_all flag is false, the namespaces and table-cfs in peer config
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class ListRegions < Command
|
class ListRegions < Command
|
||||||
def help
|
def help
|
||||||
return <<EOF
|
<<~EOF
|
||||||
List all regions for a particular table as an array and also filter them by server name (optional) as prefix
|
List all regions for a particular table as an array and also filter them by server name (optional) as prefix
|
||||||
and maximum locality (optional). By default, it will return all the regions for the table with any locality.
|
and maximum locality (optional). By default, it will return all the regions for the table with any locality.
|
||||||
The command displays server name, region name, start key, end key, size of the region in MB, number of requests
|
The command displays server name, region name, start key, end key, size of the region in MB, number of requests
|
||||||
@ -37,8 +37,7 @@ module Shell
|
|||||||
hbase> list_regions 'table_name', {}, ['SERVER_NAME', 'start_key']
|
hbase> list_regions 'table_name', {}, ['SERVER_NAME', 'start_key']
|
||||||
hbase> list_regions 'table_name', '', ['SERVER_NAME', 'start_key']
|
hbase> list_regions 'table_name', '', ['SERVER_NAME', 'start_key']
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def command(table_name, options = nil, cols = nil)
|
def command(table_name, options = nil, cols = nil)
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class MajorCompact < Command
|
class MajorCompact < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Run major compaction on passed table or pass a region row
|
Run major compaction on passed table or pass a region row
|
||||||
to major compact an individual region. To compact a single
|
to major compact an individual region. To compact a single
|
||||||
column family within a region specify the region name
|
column family within a region specify the region name
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
# from one RegionServer group to another.
|
# from one RegionServer group to another.
|
||||||
class MoveNamespacesRsgroup < Command
|
class MoveNamespacesRsgroup < Command
|
||||||
def help
|
def help
|
||||||
<<-CMD
|
<<~CMD
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
hbase> move_namespaces_rsgroup 'dest',['ns1','ns2']
|
hbase> move_namespaces_rsgroup 'dest',['ns1','ns2']
|
||||||
|
@ -21,7 +21,7 @@ module Shell
|
|||||||
# specified namespaces from one group to another.
|
# specified namespaces from one group to another.
|
||||||
class MoveServersNamespacesRsgroup < Command
|
class MoveServersNamespacesRsgroup < Command
|
||||||
def help
|
def help
|
||||||
<<-CMD
|
<<~CMD
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
hbase> move_servers_namespaces_rsgroup 'dest',['server1:port','server2:port'],['ns1','ns2']
|
hbase> move_servers_namespaces_rsgroup 'dest',['server1:port','server2:port'],['ns1','ns2']
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
# Recommission a region server, optionally load a list of passed regions
|
# Recommission a region server, optionally load a list of passed regions
|
||||||
class RecommissionRegionserver < Command
|
class RecommissionRegionserver < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Remove decommission marker from a region server to allow regions assignments.
|
Remove decommission marker from a region server to allow regions assignments.
|
||||||
|
|
||||||
Optionally, load regions onto the server by passing a list of encoded region names.
|
Optionally, load regions onto the server by passing a list of encoded region names.
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class RemovePeerNamespaces < Command
|
class RemovePeerNamespaces < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Remove some namespaces from the namespaces config for the specified peer.
|
Remove some namespaces from the namespaces config for the specified peer.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class SetPeerExcludeNamespaces < Command
|
class SetPeerExcludeNamespaces < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Set the namespaces which not replicated for the specified peer.
|
Set the namespaces which not replicated for the specified peer.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class SetPeerExcludeTableCFs < Command
|
class SetPeerExcludeTableCFs < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Set the table-cfs which not replicated for the specified peer.
|
Set the table-cfs which not replicated for the specified peer.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class SetPeerNamespaces < Command
|
class SetPeerNamespaces < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Set the replicable namespaces config for the specified peer.
|
Set the replicable namespaces config for the specified peer.
|
||||||
|
|
||||||
1. The replicate_all flag need to be false when set the replicable namespaces.
|
1. The replicate_all flag need to be false when set the replicable namespaces.
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class SetPeerReplicateAll < Command
|
class SetPeerReplicateAll < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Set the replicate_all flag to true or false for the specified peer.
|
Set the replicate_all flag to true or false for the specified peer.
|
||||||
|
|
||||||
If replicate_all flag is true, then all user tables (REPLICATION_SCOPE != 0)
|
If replicate_all flag is true, then all user tables (REPLICATION_SCOPE != 0)
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class SetPeerSerial < Command
|
class SetPeerSerial < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Set the serial flag to true or false for the specified peer.
|
Set the serial flag to true or false for the specified peer.
|
||||||
|
|
||||||
If serial flag is true, then all logs of user tables (REPLICATION_SCOPE != 0) will be
|
If serial flag is true, then all logs of user tables (REPLICATION_SCOPE != 0) will be
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class SetPeerTableCFs < Command
|
class SetPeerTableCFs < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Set the replicable table-cf config for the specified peer.
|
Set the replicable table-cf config for the specified peer.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
|
@ -22,7 +22,7 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class ShowPeerTableCFs < Command
|
class ShowPeerTableCFs < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Show replicable table-cf config for the specified peer.
|
Show replicable table-cf config for the specified peer.
|
||||||
|
|
||||||
hbase> show_peer_tableCFs '2'
|
hbase> show_peer_tableCFs '2'
|
||||||
|
@ -21,12 +21,12 @@ module Shell
|
|||||||
# Command for check split or merge switch status
|
# Command for check split or merge switch status
|
||||||
class SplitormergeEnabled < Command
|
class SplitormergeEnabled < Command
|
||||||
def help
|
def help
|
||||||
print <<-EOF
|
<<-EOF
|
||||||
Query the switch's state. You can set switch type, 'SPLIT' or 'MERGE'
|
Query the switch's state. You can set switch type, 'SPLIT' or 'MERGE'
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
hbase> splitormerge_enabled 'SPLIT'
|
hbase> splitormerge_enabled 'SPLIT'
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
def command(switch_type)
|
def command(switch_type)
|
||||||
|
@ -22,13 +22,13 @@ module Shell
|
|||||||
# Command for set switch for split and merge
|
# Command for set switch for split and merge
|
||||||
class SplitormergeSwitch < Command
|
class SplitormergeSwitch < Command
|
||||||
def help
|
def help
|
||||||
print <<-EOF
|
<<-EOF
|
||||||
Enable/Disable one switch. You can set switch type 'SPLIT' or 'MERGE'. Returns previous split state.
|
Enable/Disable one switch. You can set switch type 'SPLIT' or 'MERGE'. Returns previous split state.
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
hbase> splitormerge_switch 'SPLIT', true
|
hbase> splitormerge_switch 'SPLIT', true
|
||||||
hbase> splitormerge_switch 'SPLIT', false
|
hbase> splitormerge_switch 'SPLIT', false
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
def command(switch_type, enabled)
|
def command(switch_type, enabled)
|
||||||
|
@ -21,8 +21,11 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class Truncate < Command
|
class Truncate < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Disables, drops and recreates the specified table.
|
Disables, drops and recreates the specified table.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
hbase> truncate 'my_table'
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,8 +21,11 @@ module Shell
|
|||||||
module Commands
|
module Commands
|
||||||
class TruncatePreserve < Command
|
class TruncatePreserve < Command
|
||||||
def help
|
def help
|
||||||
<<-EOF
|
<<~EOF
|
||||||
Disables, drops and recreates the specified table while still maintaing the previous region boundaries.
|
Disables, drops and recreates the specified table while still maintaining the previous region boundaries.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
hbase> truncate_preserve 'my_table'
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,9 +25,26 @@ require 'shell'
|
|||||||
# Tests whether all registered commands have a help and command method
|
# Tests whether all registered commands have a help and command method
|
||||||
|
|
||||||
class ShellCommandsTest < Test::Unit::TestCase
|
class ShellCommandsTest < Test::Unit::TestCase
|
||||||
|
|
||||||
|
##
|
||||||
|
# Determine the indentation of the given text
|
||||||
|
#
|
||||||
|
# @param [String] text
|
||||||
|
# @return [Integer] number of whitespace characters used for indentation
|
||||||
|
def determine_indentation(text)
|
||||||
|
# Ignore lines only containing whitespace. For all other lines, capture
|
||||||
|
# the number of whitespace characters preceding the first non-whitespace
|
||||||
|
# character. Return the minimum number found.
|
||||||
|
text.scan(/^([ \t]*)[^\s].*$/).flatten.map { |space| space.length }.min
|
||||||
|
end
|
||||||
|
|
||||||
Shell.commands.each do |name, klass|
|
Shell.commands.each do |name, klass|
|
||||||
define_test "#{name} command class #{klass} should respond to help" do
|
define_test "#{name} command class #{klass} should return help" do
|
||||||
assert_respond_to(klass.new(nil), :help)
|
result = klass.new(nil).help
|
||||||
|
# check that help text exists and is non-empty
|
||||||
|
assert(result.is_a?(String) && result.length > 0)
|
||||||
|
# check that the help text is not indented
|
||||||
|
assert(determine_indentation(result) == 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
define_test "#{name} command class #{klass} should respond to :command" do
|
define_test "#{name} command class #{klass} should respond to :command" do
|
||||||
|
@ -324,7 +324,7 @@ TABLE
|
|||||||
t
|
t
|
||||||
1 row(s) in 0.1040 seconds
|
1 row(s) in 0.1040 seconds
|
||||||
|
|
||||||
=> #<#<Class:0x7677ce29>:0x21d377a4>
|
=> ["t"]
|
||||||
hbase(main):017:0> tables.map { |t| disable t ; drop t}
|
hbase(main):017:0> tables.map { |t| disable t ; drop t}
|
||||||
0 row(s) in 2.2510 seconds
|
0 row(s) in 2.2510 seconds
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user