Created
February 16, 2012 12:28
Revisions
-
jtoy created this gist
Feb 16, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ require 'rsolr' require 'thread' require "optparse" $opts = {} Thread.abort_on_exception = true threads = [] $q = Queue.new OptionParser.new do |o| o.on("-u","--url URL","url") do |u| $opts[:url] = u end o.parse! end (25).times do |t| threads << Thread.new do puts s = RSolr.connect(:url => $opts[:url]) while true a = $q.pop retry_count = 0 if a begin s.add a rescue Exception => e puts e end end end end end s = "this is a long string " * 10000 a = [] 1_000_000_000.times do |i| while $q.size > 100 puts "sleeping, q size: #{$q.size} i:#{i}" sleep 1 end doc = {} doc["id"] = i doc["false_b"] = false doc["true_b"] = true doc["description_text"] = s doc["indexed_at_dt"] = Time.now.strftime("%Y-%m-%dT%H:%M:%SZ") a << doc if i % 25 == 0 && i != 0 puts i $q << a a = [] end end while $q.length > 0 do sleep 1 puts "#{$q.length}" end