hbase의 cmd 는 shell script과 ruby를 기반으로 되어 있다.


bin/hbase는 shell script이고, hirb.rb라는 ruby 파일을 호출하도록 되어 있다.


if [ "$COMMAND" = "shell" ] ; then

  # eg export JRUBY_HOME=/usr/local/share/jruby

  if [ "$JRUBY_HOME" != "" ] ; then

    CLASSPATH="$JRUBY_HOME/lib/jruby.jar:$CLASSPATH"

    HBASE_OPTS="$HBASE_OPTS -Djruby.home=$JRUBY_HOME -Djruby.lib=$JRUBY_HOME/lib"

  fi

  CLASS="org.jruby.Main -X+O ${JRUBY_OPTS} ${HBASE_HOME}/bin/hirb.rb"





1. prompt


hirb.rb는 내부적으로 ruby의 irb (Interactive Ruby Shell) 을 이용하도록 되어 있다. 


hbase(main):001:0>


3개의 word가 colon separator(:) 으로 나누어진 상태로 스크립트를 사용할 수 있다. 

첫번째 word는 main object이름를 출력하고, 두번째 word는 line number를 의미하고, 마지막 word는 semantic indentation이다. 


hbase(main):002:0> list 'test'

TABLE                                                                                                                                          

test                                                                                                                                           

1 row(s) in 0.9690 seconds




irb 정보(http://ruby-doc.org/docs/ProgrammingRuby/html/irb.htmlhttp://linux.die.net/man/1/irb)를 통해 확인해보니. 다음과 같다. 


FlagDescription
%NCurrent command.
%mto_s of the main object (self).
%Minspect of the main object (self).
%lDelimiter type. In strings that are continued across a line break, %l will display the type of delimiter used to begin the string, so you'll know how to end it. The delimiter will be one of "'/], or `.
%niIndent level. The optional number n is used as a width specification to printf, as printf("%nd").
%nnCurrent line number (n used as with the indent level).
%%A literal percent sign.


For instance, the default prompt mode is defined as follows:

IRB.conf[:PROMPT_MODE][:DEFAULT] = {
      :PROMPT_I => "%N(%m):%03n:%i> ",
      :PROMPT_S => "%N(%m):%03n:%i%l ",
      :PROMPT_C => "%N(%m):%03n:%i* ",
      :RETURN => "%s\n"
}


%i 는 설명이 없지만.. identation이다.

예제)
hbase(main):012:0> def bar
hbase(main):013:1>   def aa
hbase(main):014:2>   print bb
hbase(main):015:2>   end
hbase(main):016:1> end


2. debug

hbase> debug <RETURN>

또는 
$ ./bin/hbase shell -d


3. customized

.irbrc 파일을 생성해서 customized hbase irb shell을 구성할 수 있다. 
                        $ more .irbrc
                        require 'irb/ext/save-history'
                        IRB.conf[:SAVE_HISTORY] = 100
                        IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"


출처: http://hbase.apache.org/shell.html



'nosql' 카테고리의 다른 글

[hbase] hbase 2013 발표 자료 공개  (0) 2013.07.11
[hbase] regsion서버에 G1 gc 적용으로 좋아진 예  (0) 2013.07.09
[hbase] Phoenix 성능  (0) 2013.06.24
[hbase] ROOT catalog table 삭제  (0) 2013.06.20
[hbase] 제한적인 트랙잭션  (0) 2013.06.20
Posted by '김용환'
,