Created
September 10, 2010 22:00
-
-
Save tinomen/574449 to your computer and use it in GitHub Desktop.
riak-sinatra-test-session.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -X PUT -v -F value=@bauhaus.jpg http://localhost:9292/test/bauhaus.jpg | |
* About to connect() to localhost port 9292 (#0) | |
* Trying ::1... Connection refused | |
* Trying fe80::1... Connection refused | |
* Trying 127.0.0.1... connected | |
* Connected to localhost (127.0.0.1) port 9292 (#0) | |
> PUT /test/bauhaus.jpg HTTP/1.1 | |
> User-Agent: curl/7.21.0 (x86_64-apple-darwin10.4.0) libcurl/7.21.0 OpenSSL/1.0.0a zlib/1.2.5 libidn/1.19 | |
> Host: localhost:9292 | |
> Accept: */* | |
> Content-Length: 4307 | |
> Expect: 100-continue | |
> Content-Type: multipart/form-data; boundary=----------------------------19fa2cae36ac | |
> | |
* Done waiting for 100-continue | |
* Empty reply from server | |
* Connection #0 to host localhost left intact | |
curl: (52) Empty reply from server | |
* Closing connection #0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './coffer' | |
use Rack::Reloader | |
run Sinatra::Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is working in irb | |
ruby-1.8.7-p249 > client = Riak::Client.new :host => 'localhost', :port => 8091, :prefix => 'riak' | |
=> #<Riak::Client http://localhost:8091> | |
ruby-1.8.7-p249 > bucket = client.bucket("test") | |
=> #<Riak::Bucket http://localhost:8091/riak/test> | |
ruby-1.8.7-p249 > exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rackup | |
[2010-09-10 15:50:44] INFO WEBrick 1.3.1 | |
[2010-09-10 15:50:44] INFO ruby 1.9.2 (2010-04-28) [x86_64-darwin10.3.0] | |
[2010-09-10 15:50:44] INFO WEBrick::HTTPServer#start: pid=55718 port=9292 | |
{"value"=>{:filename=>"bauhaus.jpg", :type=>"image/jpeg", :name=>"value", :tempfile=>#<File:/var/folders/g6/g6uYCmNuEPKqdW9G2OvA1U+++TM/-Tmp-/RackMultipart20100910-55718-1acs5up>, :head=>"Content-Disposition: form-data; name=\"value\"; filename=\"bauhaus.jpg\"\r\nContent-Type: image/jpeg\r\n"}, "bucket"=>"test", "key"=>"bauhaus.jpg"} | |
Trace/BPT trap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'riak' | |
# $riak_client = Riak::Client.new :host => '127.0.0.1', :port => 8091, :prefix => 'riak' | |
put '/:bucket/:key' do | |
riak_client = Riak::Client.new :host => '127.0.0.1', :port => 8091, :prefix => 'riak' | |
puts params.inspect | |
tmpfile = params[:value][:tempfile] | |
unless (params[:value] && tmpfile) | |
halt 500, 'missing value' | |
end | |
mime_type = params[:value][:type] | |
begin | |
bucket = riak_client.bucket("test") | |
rescue Exception => e | |
puts e.inspect #nothing is caught | |
end | |
puts "mime_type: #{mime_type}" | |
new_item = Riak::RObject.new(bucket, params[:key]) | |
new_item.content_type = mime_type if mime_type | |
new_item.data = tmpfile | |
new_item.store | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -H "Accept: text/plain" http://127.0.0.1:8091/stats | |
{ | |
"vnode_gets": 0, | |
"vnode_puts": 0, | |
"read_repairs": 0, | |
"vnode_gets_total": 4, | |
"vnode_puts_total": 1, | |
"node_gets": 0, | |
"node_gets_total": 4, | |
"node_get_fsm_time_mean": "undefined", | |
"node_get_fsm_time_median": "undefined", | |
"node_get_fsm_time_95": "undefined", | |
"node_get_fsm_time_99": "undefined", | |
"node_get_fsm_time_100": "undefined", | |
"node_puts": 0, | |
"node_puts_total": 1, | |
"node_put_fsm_time_mean": "undefined", | |
"node_put_fsm_time_median": "undefined", | |
"node_put_fsm_time_95": "undefined", | |
"node_put_fsm_time_99": "undefined", | |
"node_put_fsm_time_100": "undefined", | |
"read_repairs_total": 0, | |
"cpu_nprocs": 124, | |
"cpu_avg1": 133, | |
"cpu_avg5": 141, | |
"cpu_avg15": 156, | |
"mem_total": 3931420000.0, | |
"mem_allocated": 3903148000.0, | |
"nodename": "dev1@127.0.0.1", | |
"connected_nodes": [ | |
"dev2@127.0.0.1", | |
"dev3@127.0.0.1" | |
], | |
"sys_driver_version": "1.5", | |
"sys_global_heaps_size": 0, | |
"sys_heap_type": "private", | |
"sys_logical_processors": 2, | |
"sys_otp_release": "R14A", | |
"sys_process_count": 150, | |
"sys_smp_support": true, | |
"sys_system_version": "Erlang R14A (erts-5.8) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:64] [hipe] [kernel-poll:true]", | |
"sys_system_architecture": "i386-apple-darwin10.4.0", | |
"sys_threads_enabled": true, | |
"sys_thread_pool_size": 64, | |
"sys_wordsize": 8, | |
"ring_members": [ | |
"dev1@127.0.0.1", | |
"dev2@127.0.0.1", | |
"dev3@127.0.0.1" | |
], | |
"ring_num_partitions": 64, | |
"ring_ownership": "[{'dev3@127.0.0.1',21},{'dev2@127.0.0.1',21},{'dev1@127.0.0.1',22}]", | |
"ring_creation_size": 64, | |
"storage_backend": "riak_kv_bitcask_backend", | |
"pbc_connects_total": 0, | |
"pbc_connects": 0, | |
"pbc_active": 0, | |
"runtime_tools_version": "1.8.4", | |
"riak_kv_version": "0.12.0", | |
"riak_core_version": "0.12.0", | |
"luke_version": "0.2.1", | |
"erlang_js_version": "0.4", | |
"bitcask_version": "1.0.3", | |
"mochiweb_version": "1.7.1", | |
"webmachine_version": "1.7.1", | |
"crypto_version": "2.0", | |
"os_mon_version": "2.2.5", | |
"sasl_version": "2.1.9.2", | |
"stdlib_version": "1.17", | |
"kernel_version": "2.14" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.9.2-head@coffer: | |
system: | |
uname: "Darwin telegramsam.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386" | |
shell: "bash" | |
version: "3.2.48(1)-release" | |
rvm: | |
version: "rvm 0.1.44 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]" | |
ruby: | |
interpreter: "ruby" | |
version: "1.9.2dev" | |
date: "2010-04-28" | |
platform: "x86_64-darwin10.3.0" | |
patchlevel: "2010-04-28 trunk 27536" | |
full_version: "ruby 1.9.2dev (2010-04-28 trunk 27536) [x86_64-darwin10.3.0]" | |
homes: | |
gem: "/Users/jmallory/.rvm/gems/ruby-1.9.2-head@coffer" | |
ruby: "/Users/jmallory/.rvm/rubies/ruby-1.9.2-head" | |
binaries: | |
ruby: "/Users/jmallory/.rvm/rubies/ruby-1.9.2-head/bin/ruby" | |
irb: "/Users/jmallory/.rvm/rubies/ruby-1.9.2-head/bin/irb" | |
gem: "/Users/jmallory/.rvm/rubies/ruby-1.9.2-head/bin/gem" | |
rake: "/Users/jmallory/.rvm/gems/ruby-1.9.2-head@global/bin/rake" | |
environment: | |
PATH: "/Users/jmallory/.rvm/bin:/Users/jmallory/.rvm/gems/ruby-1.9.2-head@coffer/bin:/Users/jmallory/.rvm/gems/ruby-1.9.2-head@global/bin:/Users/jmallory/.rvm/rubies/ruby-1.9.2-head/bin:/Users/jmallory/.rvm/bin:/opt/local/bin:/opt/local/sbin:/Users/jmallory/bin:/usr/local/mysql/bin:/usr/local/git/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/share/narwhal/bin" | |
GEM_HOME: "/Users/jmallory/.rvm/gems/ruby-1.9.2-head@coffer" | |
GEM_PATH: "/Users/jmallory/.rvm/gems/ruby-1.9.2-head@coffer:/Users/jmallory/.rvm/gems/ruby-1.9.2-head@global" | |
BUNDLE_PATH: "/Users/jmallory/.rvm/gems/ruby-1.9.2-head@coffer" | |
MY_RUBY_HOME: "/Users/jmallory/.rvm/rubies/ruby-1.9.2-head" | |
IRBRC: "/Users/jmallory/.rvm/rubies/ruby-1.9.2-head/.irbrc" | |
RUBYOPT: "" | |
gemset: "coffer" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment