[ https://issues.apache.org/jira/browse/HBASE-20270?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16451304#comment-16451304 ]
Sean Busbey commented on HBASE-20270: ------------------------------------- This is a great step in the right direction! {code} diff --git a/hbase-shell/src/main/ruby/shell/commands.rb b/hbase-shell/src/main/ruby/shell/commands.rb index 85a742e436c1e6234169e59d9bafd4552887f65c..5074ed170c920009c8c229ca7c892c5a0448fa32 100644 --- a/hbase-shell/src/main/ruby/shell/commands.rb +++ b/hbase-shell/src/main/ruby/shell/commands.rb @@ -26,9 +26,19 @@ module Shell @shell = shell end + # get command name + + def command_name + klass_name = self.class.name.split('::').last + command = klass_name.gsub(/([^\^])([A-Z])/, '\1_\2').downcase.gsub(/_cfs/, 'CFs') + command + end {code} A description like "gets the name that an operator would type into the shell" would be better. Drop the {{s/_cfs/CFs}} from the generic handler. Leave that kind of non-obvious mapping to the per-command over ridden method. {code} diff --git a/hbase-shell/src/main/ruby/shell/commands/append_peer_tableCFs.rb b/hbase-shell/src/main/ruby/shell/commands/append_peer_tableCFs.rb index 0dbf2d72dd0f0e98c346060eb3d9ca70e5edea29..d452151a8212ebcc4b45b47b21950b0aa315f8c7 100644 --- a/hbase-shell/src/main/ruby/shell/commands/append_peer_tableCFs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/append_peer_tableCFs.rb @@ -34,6 +34,12 @@ EOF def command(id, table_cfs) replication_admin.append_peer_tableCFs(id, table_cfs) end + + def command_name + klass_name = self.class.name.split('::').last + command = klass_name.gsub(/([^\^])([A-Z])/, '\1_\2').downcase.gsub(/_cfs/, 'CFs') + command + end end end end {code} For all of these "CFs" commands, either make a common parent class that does this command_name override or have each of them return a string literal. (I don't have a strong feeling either way, but the "return a string" sounds easier to reason about to me.) > Turn off command help that follows all errors in shell > ------------------------------------------------------ > > Key: HBASE-20270 > URL: https://issues.apache.org/jira/browse/HBASE-20270 > Project: HBase > Issue Type: Task > Components: shell > Affects Versions: 2.0.0 > Reporter: Sean Busbey > Assignee: Sakthi > Priority: Major > Fix For: 2.0.0 > > Attachments: hbase-20270.master.001.patch, > hbase-20270.master.002.patch, hbase-20270.master.003.patch, > hbase-20270.master.004.patch > > > Right now if a shell command gives an error, any error, it then echos the > command help. It makes it harder to see the actual error text and is annoying. > example: > {code} > > > > hbase(main):007:0> create 'test:a_table', 'family', { NUMREGIONS => 20, > SPLITALGO => 'HexStringSplit'} > ERROR: Unknown namespace test! > Creates a table. Pass a table name, and a set of column family > specifications (at least one), and, optionally, table configuration. > Column specification can be a simple string (name), or a dictionary > (dictionaries are described below in main help output), necessarily > including NAME attribute. > Examples: > Create a table with namespace=ns1 and table qualifier=t1 > hbase> create 'ns1:t1', {NAME => 'f1', VERSIONS => 5} > Create a table with namespace=default and table qualifier=t1 > hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'} > hbase> # The above in shorthand would be the following: > hbase> create 't1', 'f1', 'f2', 'f3' > hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, > BLOCKCACHE => true} > hbase> create 't1', {NAME => 'f1', CONFIGURATION => > {'hbase.hstore.blockingStoreFiles' => '10'}} > hbase> create 't1', {NAME => 'f1', IS_MOB => true, MOB_THRESHOLD => > 1000000, MOB_COMPACT_PARTITION_POLICY => 'weekly'} > Table configuration options can be put at the end. > Examples: > hbase> create 'ns1:t1', 'f1', SPLITS => ['10', '20', '30', '40'] > hbase> create 't1', 'f1', SPLITS => ['10', '20', '30', '40'] > hbase> create 't1', 'f1', SPLITS_FILE => 'splits.txt', OWNER => 'johndoe' > hbase> create 't1', {NAME => 'f1', VERSIONS => 5}, METADATA => { 'mykey' => > 'myvalue' } > hbase> # Optionally pre-split the table into NUMREGIONS, using > hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname) > hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'} > hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit', > REGION_REPLICATION => 2, CONFIGURATION => > {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}} > hbase> create 't1', {NAME => 'f1', DFS_REPLICATION => 1} > You can also keep around a reference to the created table: > hbase> t1 = create 't1', 'f1' > Which gives you a reference to the table named 't1', on which you can then > call methods. > Took 0.0221 seconds > > > hbase(main):008:0> create_namespace 'test' > Took 0.2554 seconds > > > hbase(main):009:0> create 'test:a_table', 'family', { NUMREGIONS => 20, > SPLITALGO => 'HexStringSplit'} > Created table test:a_table > Took 1.2264 seconds > {code} > I was trying to make a table in the test namespace before making the > namespace. Much faster to recognize and move on when the error text isn't > followed by 80x the text. -- This message was sent by Atlassian JIRA (v7.6.3#76005)