uninitialized constantというエラーになってしまいました。
[root@312 Ruby]# ruby benchmark_controller.rb
benchmark_controller.rb:1:in `<main>': uninitialized constant Object::ApplicationController (NameError)
実行しているスクリプトは以下のURLに記載があるベンチマーク用スクリプトです。
http://gihyo.jp/dev/serial/01/various-nosql/0006
http://github.com/sasata299/gihyo_sample/blob/master/app/controllers/benchmark_controller.rb
以下の"RailsからHBaseを利用するコードの例"でも同様の結果になります。
http://gihyo.jp/dev/serial/01/various-nosql/0005
ApplicationControllerを継承していると思うのですが、
application_controller.rb は存在しており、トラブルシュート方法が
調べきれませんでした。
質問分の長さの関係でサーバーは添付できてないですが、必要な
ログがあれば添付致します。
fork して Rails 2.3.11 で動くようにしてみました。
あと、HBaseのベンチだけ実行するhbase_benchmark_controller.rbを作りました。
https://github.com/nuna/gihyo_sample
以下の手順で試せるはずです。
1. git clone https://github.com/nuna/gihyo_sample か、Downloads ボタンでダウンロードして下さい。tar.gzやzipで落とした場合は展開してください。
2. gem install rails -v 2.3.11
3. gem install hbase-stargate
4. gihyo_sample ディレクトリに移動して、./script/console
5. app.get('/hbase_benchmark/get') # get のベンチ
6. app.get('/hbase_benchmark/set') # set のベンチ
5, 6 は localhost:8080 に HBase が動いてないとエラーになります。
新たに作成までしていただいてありがとうございます。
非常にありがたいです!!
さっそく試してみたところ、以下のようにsetのベンチは
実行できましたが、getのベンチは各パラメータの値が
取得できていないように見えます。
これはHbase側の問題になるのでしょうか。
------------------------------------
[root@3-12 nuna-gihyo_sample-54e9264]# ./script/console
Loading development environment (Rails 2.3.11)
>> app.get('/hbase_benchmark/set')
user system total real
HBase
31.110000 5.450000 36.560000 ( 61.308208)
=> 200
>>
?> app.get('/hbase_benchmark/get')
user system total real
HBase=> 500
>>
>>exit
[root@sm3-12 nuna-gihyo_sample-54e9264]# ./script/console
Loading development environment (Rails 2.3.11)
>> app.get('/hbase_benchmark/get')
user system total real
HBase=> 500
>> app.get('/hbase_benchmark/set')
user system total real
HBase
30.280000 5.280000 35.560000 ( 58.213991)
=> 200
>>
------------------------------------
hbaseのshellでは問題なく動作しているように見えます。
------------------------------------
hbase(main):032:0> list
TABLE
City
articles
2 row(s) in 0.0440 seconds
hbase(main):038:0> put 'City', '2', 'ID', '2'
0 row(s) in 0.0500 seconds
hbase(main):039:0> put 'City', '2', 'Name', 'Qandahar'
0 row(s) in 0.0500 seconds
hbase(main):040:0> put 'City', '2', 'CountryCode', 'AFG'
0 row(s) in 0.0360 seconds
hbase(main):041:0> put 'City', '2', 'Population', '237500'
0 row(s) in 0.0360 seconds
hbase(main):047:0> get 'City','2'
COLUMN CELL
CountryCode: timestamp=1311921850889, value=AFG
ID: timestamp=1311921850537, value=2
Name: timestamp=1311921850715, value=Qandahar
Population: timestamp=1311921851052, value=237500
4 row(s) in 0.1220 seconds
hbase(main):048:0>
------------------------------------
hbase_benchmark_controller.rbが読めておらず
申し訳ないですが、アドバイスいただけると
ありがたいです。
以下の内容のファイルを作って(hbase_benchmark.rb とか)、
それをコマンドラインで実行する($ ruby hbase_benchmark.rb)とどうでしょう。
エラーがあってももう少し細かくエラーメッセージが出ると思います。
require 'benchmark'
require 'stargate'
Benchmark.bm do |x|
x.report('HBase set') {
client = Stargate::Client.new("http://localhost:8080")
client.create_table('articles', 'data')
1.upto(10000) do |num|
client.create_row('articles', num.to_s, Time.now.to_i, [
{:name => 'data:title', :value => "title_#{num}"},
{:name => 'data:body', :value => "body_#{num}"}
])
end
}
end
Benchmark.bm do |x|
x.report('HBase get') {
client = Stargate::Client.new("http://localhost:8080")
1.upto(10000) do |num|
row = client.show_row('articles', (1 + rand(10000)).to_s)
end
}
end
詳細なエラーが確認できました。
http.rb等に関連したエラーのように見えますが、詳細がわかりません。
すいません。
特にhttp.rbの変更等はしていないので、rubyやgemのversionの問題でしょうか?
お手数ですが使用しているrubyとgemのversionを教えていただけますでしょうか?
----------------------------
[root@sm3-12 Ruby]# ruby hbase_benchmark.rb
user system total real
HBase set 25.030000 5.980000 31.010000 ( 61.195851)
user system total real
HBase get/usr/local/lib/ruby/1.9.1/net/http.rb:894:in `read': unexpected end of file (Zlib::GzipFile::Error)
from /usr/local/lib/ruby/1.9.1/net/http.rb:894:in `block in get'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1194:in `block in transport_request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:2342:in `reading_body'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1193:in `transport_request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1177:in `request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1170:in `block in request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:627:in `start'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1168:in `request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:888:in `get'
from /usr/local/lib/ruby/gems/1.9.1/gems/hbase-stargate-1.5.5/lib/stargate/client.rb:33:in `block in get'
from /usr/local/lib/ruby/gems/1.9.1/gems/hbase-stargate-1.5.5/lib/stargate/client.rb:78:in `block in safe_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/hbase-stargate-1.5.5/lib/stargate/client.rb:68:in `safe_response'
from /usr/local/lib/ruby/gems/1.9.1/gems/hbase-stargate-1.5.5/lib/stargate/client.rb:78:in `safe_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/hbase-stargate-1.5.5/lib/stargate/client.rb:33:in `get'
from /usr/local/lib/ruby/gems/1.9.1/gems/hbase-stargate-1.5.5/lib/stargate/operation/row_operation.rb:21:in `show_row'
from hbase_benchmark.rb:23:in `block (3 levels) in <main>'
from hbase_benchmark.rb:22:in `upto'
from hbase_benchmark.rb:22:in `block (2 levels) in <main>'
from /usr/local/lib/ruby/1.9.1/benchmark.rb:294:in `measure'
from /usr/local/lib/ruby/1.9.1/benchmark.rb:381:in `item'
from hbase_benchmark.rb:19:in `block in <main>'
from /usr/local/lib/ruby/1.9.1/benchmark.rb:178:in `benchmark'
from /usr/local/lib/ruby/1.9.1/benchmark.rb:208:in `bm'
from hbase_benchmark.rb:18:in `<main>'
[root@sm3-12 Ruby]# ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
[root@sm3-12 Ruby]#
[root@sm3-12 Ruby]# gem -v
1.3.7
---------------------------
宜しくお願いします。