Skip to content
Browse files

fix fix

  • Loading branch information...
1 parent c029a6e commit 183615075ae5b7d37df1fe6c08ebad72c0fad139 @avsej avsej committed Mar 22, 2012
Showing with 27 additions and 12 deletions.
  1. +1 −0 .gitignore
  2. +26 −12 run.rb
View
1 .gitignore
@@ -0,0 +1 @@
+Gemfile.lock
View
38 run.rb
@@ -28,7 +28,8 @@
require 'logger'
options = {
- :host => "127.0.0.1:8091",
+ :hostname => "127.0.0.1",
+ :port => 8091,
:bucket => "default",
:concurrency => 1,
:ratio => 0.5,
@@ -108,39 +109,52 @@
# select
end
+IGNORED_ERRORS = [
+ EM::Protocols::Couchbase::Error::NotFound
+]
+
options[:concurrency].times do |n|
forks << fork do
$0 = "#{__FILE__}: fork ##{n}"
value = $0.dup
value << ('.' * (options[:size] - value.size))
EM.run do
- cc = EM::Protocols::Couchbase.connect
+ cc = EM::Protocols::Couchbase.connect(:hostname => options[:hostname],
+ :port => options[:port],
+ :bucket => options[:bucket])
+ cc.on_error do |_, error|
+ warn "Failed to connect to #{options[:hostname]}:#{options[:port]}: #{error}"
+ EM.stop
+ end
on_complete = lambda do |ret|
ops_per_fork -= 1
if options[:verbose]
- case ret.operation
- when :set
- STDERR.print("s")
- when :get
- STDERR.print("g")
+ if ret.success? || IGNORED_ERRORS.include?(ret.error.class)
+ case ret.operation
+ when :set
+ STDERR.print("s")
+ when :get
+ STDERR.print("g")
+ end
+ else
+ STDERR.print("E")
end
end
EM.stop if ops_per_fork < 0
end
- on_tick = lambda do
+ EM.add_periodic_timer(options[:tick]) do
if options[:verbose]
STDERR.print(".")
end
- options[:slice].times do
+ options[:slice].times do |t|
if rand > options[:ratio]
- cc.set("#{options[:prefix]}fork-#{n}:#{n % 10}", value, &on_complete)
+ cc.set("#{options[:prefix]}fork-#{n}:#{t}", value, &on_complete)
else
- cc.get("#{options[:prefix]}fork-#{n}:#{n % 10}", &on_complete)
+ cc.get("#{options[:prefix]}fork-#{n}:#{t}", &on_complete)
end
end
end
- EM.add_periodic_timer(options[:tick], &on_tick)
end
end
end

0 comments on commit 1836150

Please sign in to comment.
Something went wrong with that request. Please try again.