You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by Shaun Elliott <ja...@gmail.com> on 2014/09/26 00:49:44 UTC
custom hbase commands
This is a potential answer to my question here
<http://apache-hbase.679495.n3.nabble.com/view-decoded-thrift-in-hbase-shell-td4064130.html>
that I never got a response to. I assume it is the only way...
Anyways... I would like to build my own hbase shell command. I have not
found relevant documentation explaining this. (perhaps I've missed it). To
do this, I have copied
$HBASE_HOME/libexec/lib/ruby/shell/commands/get.rb
To
$HBASE_HOME/libexec/lib/ruby/shell/commands/foo.rb
Additionally, I changed the class to: class Foo < Command as well as the
methods:
def command(table, row, *args)
foo(table(table), row, *args)
end
def foo(table, row, *args)
and the addition to the shell:
#add get command to table
::Hbase::Table.add_shell_command('foo')
>From the getting started samples, I run this:
1.8.7-p357 :003 > get 'test','row1'
COLUMN CELL
cf:a timestamp=1411441874803, value=value1
1 row(s) in 0.0210 seconds
1.8.7-p357 :004 > foo 'test','row1'
NoMethodError: undefined method `foo' for #<Object:0x205eb650>
What else do I need to do?
--
View this message in context: http://apache-hbase.679495.n3.nabble.com/custom-hbase-commands-tp4064391.html
Sent from the HBase Developer mailing list archive at Nabble.com.
Re: custom hbase commands
Posted by Ted Yu <yu...@gmail.com>.
Here is a recent thread on HBase shell:
http://search-hadoop.com/m/DHED4A0E6K/hbase+shell+sean&subj=Re+HBase+shell+compatibility+needs
FYI
On Thu, Sep 25, 2014 at 5:07 PM, Shaun Elliott <ja...@gmail.com>
wrote:
> Yup, that was the missing link. Thank you!
>
> Does anyone here know if there is there any plan for the near future to be
> able to add extended shell commands without having to modify the shell.rb
> file? Perhaps having an extensions directory of sorts?
>
>
>
> --
> View this message in context:
> http://apache-hbase.679495.n3.nabble.com/custom-hbase-commands-tp4064391p4064394.html
> Sent from the HBase Developer mailing list archive at Nabble.com.
>
Re: custom hbase commands
Posted by Shaun Elliott <ja...@gmail.com>.
Yup, that was the missing link. Thank you!
Does anyone here know if there is there any plan for the near future to be
able to add extended shell commands without having to modify the shell.rb
file? Perhaps having an extensions directory of sorts?
--
View this message in context: http://apache-hbase.679495.n3.nabble.com/custom-hbase-commands-tp4064391p4064394.html
Sent from the HBase Developer mailing list archive at Nabble.com.
Re: custom hbase commands
Posted by Ted Yu <yu...@gmail.com>.
Take a look at hbase-shell/src/main/ruby/shell.rb, starting line 273
(master branch):
Shell.load_command_group(
'dml',
:full_name => 'DATA MANIPULATION COMMANDS',
:commands => %w[
count
delete
deleteall
get
You can add your command following 'get'
Cheers
On Thu, Sep 25, 2014 at 3:49 PM, Shaun Elliott <ja...@gmail.com>
wrote:
> This is a potential answer to my question here
> <
> http://apache-hbase.679495.n3.nabble.com/view-decoded-thrift-in-hbase-shell-td4064130.html
> >
> that I never got a response to. I assume it is the only way...
>
> Anyways... I would like to build my own hbase shell command. I have not
> found relevant documentation explaining this. (perhaps I've missed it). To
> do this, I have copied
>
> $HBASE_HOME/libexec/lib/ruby/shell/commands/get.rb
>
> To
>
> $HBASE_HOME/libexec/lib/ruby/shell/commands/foo.rb
>
> Additionally, I changed the class to: class Foo < Command as well as the
> methods:
> def command(table, row, *args)
> foo(table(table), row, *args)
> end
>
> def foo(table, row, *args)
>
> and the addition to the shell:
> #add get command to table
> ::Hbase::Table.add_shell_command('foo')
>
> From the getting started samples, I run this:
> 1.8.7-p357 :003 > get 'test','row1'
> COLUMN CELL
> cf:a timestamp=1411441874803, value=value1
> 1 row(s) in 0.0210 seconds
>
> 1.8.7-p357 :004 > foo 'test','row1'
> NoMethodError: undefined method `foo' for #<Object:0x205eb650>
>
> What else do I need to do?
>
>
>
> --
> View this message in context:
> http://apache-hbase.679495.n3.nabble.com/custom-hbase-commands-tp4064391.html
> Sent from the HBase Developer mailing list archive at Nabble.com.
>