Permalink
Browse files

Switched from backgroundrb to workling/starling.

  • Loading branch information...
bamnet committed Jul 23, 2009
1 parent 0b8af4e commit d33890a4be38869d0c7f851ac085cfcfc53a72ab
Showing with 2,377 additions and 5,883 deletions.
  1. +1 −1 app/controllers/conversions_controller.rb
  2. +2 −2 app/controllers/thumbnails_controller.rb
  3. +1 −13 {lib → app}/workers/thumbnail_worker.rb
  4. +1 −18 {lib → app}/workers/video_worker.rb
  5. +3 −1 config/environment.rb
  6. +16 −0 config/workling.yml
  7. +0 −47 script/backgroundrb
  8. +11 −0 script/bj_invoker.rb
  9. +37 −0 script/starling_status.rb
  10. +17 −0 script/workling_client
  11. +7 −0 script/workling_starling_client
  12. +0 −99 test/bdrb_test_helper.rb
  13. +0 −17 vendor/plugins/backgroundrb/.autotest
  14. +0 −50 vendor/plugins/backgroundrb/ChangeLog
  15. +0 −4 vendor/plugins/backgroundrb/LICENSE
  16. +0 −20 vendor/plugins/backgroundrb/README
  17. +0 −103 vendor/plugins/backgroundrb/Rakefile
  18. +0 −5 vendor/plugins/backgroundrb/TODO.org
  19. +0 −6 vendor/plugins/backgroundrb/app/controller/backgroundrb_status_controller.rb
  20. +0 −11 vendor/plugins/backgroundrb/config/backgroundrb.yml
  21. +0 −5 vendor/plugins/backgroundrb/doc/Rakefile
  22. +0 −2 vendor/plugins/backgroundrb/doc/config.yaml
  23. +0 −76 vendor/plugins/backgroundrb/doc/content/advanced/advanced.txt
  24. +0 −4 vendor/plugins/backgroundrb/doc/content/advanced/advanced.yaml
  25. +0 −20 vendor/plugins/backgroundrb/doc/content/bugs/bugs.txt
  26. +0 −5 vendor/plugins/backgroundrb/doc/content/bugs/bugs.yaml
  27. +0 −36 vendor/plugins/backgroundrb/doc/content/community/community.txt
  28. +0 −5 vendor/plugins/backgroundrb/doc/content/community/community.yaml
  29. +0 −168 vendor/plugins/backgroundrb/doc/content/content.txt
  30. +0 −5 vendor/plugins/backgroundrb/doc/content/content.yaml
  31. +0 −41 vendor/plugins/backgroundrb/doc/content/faq/faq.txt
  32. +0 −5 vendor/plugins/backgroundrb/doc/content/faq/faq.yaml
  33. +0 −182 vendor/plugins/backgroundrb/doc/content/rails/rails.txt
  34. +0 −5 vendor/plugins/backgroundrb/doc/content/rails/rails.yaml
  35. +0 −166 vendor/plugins/backgroundrb/doc/content/scheduling/scheduling.txt
  36. +0 −5 vendor/plugins/backgroundrb/doc/content/scheduling/scheduling.yaml
  37. +0 −178 vendor/plugins/backgroundrb/doc/content/workers/workers.txt
  38. +0 −5 vendor/plugins/backgroundrb/doc/content/workers/workers.yaml
  39. +0 −56 vendor/plugins/backgroundrb/doc/layouts/default/default.erb
  40. +0 −4 vendor/plugins/backgroundrb/doc/layouts/default/default.yaml
  41. +0 −7 vendor/plugins/backgroundrb/doc/lib/default.rb
  42. BIN vendor/plugins/backgroundrb/doc/output/Assets/BG-Ad-Top.png
  43. BIN vendor/plugins/backgroundrb/doc/output/Assets/BG-Body.png
  44. BIN vendor/plugins/backgroundrb/doc/output/Assets/BG-Feed.png
  45. BIN vendor/plugins/backgroundrb/doc/output/Assets/BG-Menu-Hover.png
  46. BIN vendor/plugins/backgroundrb/doc/output/Assets/BG-Menu.png
  47. BIN vendor/plugins/backgroundrb/doc/output/Assets/BG-Sidebar-Bottom.png
  48. BIN vendor/plugins/backgroundrb/doc/output/Assets/Button-Feed.png
  49. BIN vendor/plugins/backgroundrb/doc/output/images/bg-ad-top.png
  50. BIN vendor/plugins/backgroundrb/doc/output/images/bg-body.png
  51. BIN vendor/plugins/backgroundrb/doc/output/images/bg-feed.gif
  52. BIN vendor/plugins/backgroundrb/doc/output/images/bg-footer.jpg
  53. BIN vendor/plugins/backgroundrb/doc/output/images/bg-header.jpg
  54. BIN vendor/plugins/backgroundrb/doc/output/images/bg-menu-hover.png
  55. BIN vendor/plugins/backgroundrb/doc/output/images/bg-menu.png
  56. BIN vendor/plugins/backgroundrb/doc/output/images/bg-sidebar-bottom.gif
  57. BIN vendor/plugins/backgroundrb/doc/output/images/button-feed.png
  58. BIN vendor/plugins/backgroundrb/doc/output/images/icon-comment.png
  59. BIN vendor/plugins/backgroundrb/doc/output/images/more_icon.gif
  60. +0 −299 vendor/plugins/backgroundrb/doc/output/style.css
  61. +0 −13 vendor/plugins/backgroundrb/doc/page_defaults.yaml
  62. +0 −3 vendor/plugins/backgroundrb/doc/tasks/default.rake
  63. +0 −1 vendor/plugins/backgroundrb/doc/templates/default/default.txt
  64. +0 −4 vendor/plugins/backgroundrb/doc/templates/default/default.yaml
  65. +0 −25 vendor/plugins/backgroundrb/examples/backgroundrb.yml
  66. +0 −48 vendor/plugins/backgroundrb/examples/foo_controller.rb
  67. +0 −7 vendor/plugins/backgroundrb/examples/god_worker.rb
  68. +0 −8 vendor/plugins/backgroundrb/examples/worker_tests/god_worker_test.rb
  69. +0 −17 vendor/plugins/backgroundrb/examples/workers/error_worker.rb
  70. +0 −38 vendor/plugins/backgroundrb/examples/workers/foo_worker.rb
  71. +0 −7 vendor/plugins/backgroundrb/examples/workers/god_worker.rb
  72. +0 −13 vendor/plugins/backgroundrb/examples/workers/model_worker.rb
  73. +0 −11 vendor/plugins/backgroundrb/examples/workers/renewal_worker.rb
  74. +0 −26 vendor/plugins/backgroundrb/examples/workers/rss_worker.rb
  75. +0 −31 vendor/plugins/backgroundrb/examples/workers/server_worker.rb
  76. +0 −12 vendor/plugins/backgroundrb/examples/workers/world_worker.rb
  77. +0 −7 vendor/plugins/backgroundrb/examples/workers/xmpp_worker.rb
  78. +0 −12 vendor/plugins/backgroundrb/generators/bdrb_migration/USAGE
  79. +0 −19 vendor/plugins/backgroundrb/generators/bdrb_migration/bdrb_migration_generator.rb
  80. +0 −27 vendor/plugins/backgroundrb/generators/bdrb_migration/templates/migration.rb
  81. +0 −16 vendor/plugins/backgroundrb/generators/worker/USAGE
  82. +0 −12 vendor/plugins/backgroundrb/generators/worker/templates/unit_test.rb
  83. +0 −7 vendor/plugins/backgroundrb/generators/worker/templates/worker.rb
  84. +0 −16 vendor/plugins/backgroundrb/generators/worker/worker_generator.rb
  85. +0 −7 vendor/plugins/backgroundrb/init.rb
  86. +0 −1 vendor/plugins/backgroundrb/install.rb
  87. +0 −5 vendor/plugins/backgroundrb/know_issues.org
  88. +0 −23 vendor/plugins/backgroundrb/lib/backgroundrb.rb
  89. +0 −8 vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_client_helper.rb
  90. +0 −156 vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_cluster_connection.rb
  91. +0 −43 vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_config.rb
  92. +0 −29 vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_conn_error.rb
  93. +0 −179 vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_connection.rb
  94. +0 −79 vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_job_queue.rb
  95. +0 −19 vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_result.rb
  96. +0 −146 vendor/plugins/backgroundrb/lib/backgroundrb/bdrb_start_stop.rb
  97. +0 −181 vendor/plugins/backgroundrb/lib/backgroundrb/rails_worker_proxy.rb
  98. +0 −48 vendor/plugins/backgroundrb/release_notes.org
  99. +0 −46 vendor/plugins/backgroundrb/release_points.org
  100. +0 −47 vendor/plugins/backgroundrb/script/backgroundrb
  101. +0 −99 vendor/plugins/backgroundrb/script/bdrb_test_helper.rb
  102. +0 −25 vendor/plugins/backgroundrb/script/load_worker_env.rb
  103. +0 −25 vendor/plugins/backgroundrb/script/monitrc
  104. +0 −12 vendor/plugins/backgroundrb/server/backgroundrb_server.rb
  105. +0 −62 vendor/plugins/backgroundrb/server/lib/bdrb_result_storage.rb
  106. +0 −24 vendor/plugins/backgroundrb/server/lib/bdrb_server_helper.rb
  107. +0 −127 vendor/plugins/backgroundrb/server/lib/bdrb_thread_pool.rb
  108. +0 −197 vendor/plugins/backgroundrb/server/lib/cron_trigger.rb
  109. +0 −4 vendor/plugins/backgroundrb/server/lib/invalid_dump_error.rb
  110. +0 −25 vendor/plugins/backgroundrb/server/lib/log_worker.rb
  111. +0 −140 vendor/plugins/backgroundrb/server/lib/master_proxy.rb
  112. +0 −187 vendor/plugins/backgroundrb/server/lib/master_worker.rb
  113. +0 −432 vendor/plugins/backgroundrb/server/lib/meta_worker.rb
  114. +0 −34 vendor/plugins/backgroundrb/server/lib/trigger.rb
  115. +0 −99 vendor/plugins/backgroundrb/tasks/backgroundrb_tasks.rake
  116. +0 −5 vendor/plugins/backgroundrb/test/bdrb_client_test_helper.rb
  117. +0 −35 vendor/plugins/backgroundrb/test/bdrb_test_helper.rb
  118. +0 −17 vendor/plugins/backgroundrb/test/client/backgroundrb.yml
  119. +0 −13 vendor/plugins/backgroundrb/test/client/test_bdrb_client_helper.rb
  120. +0 −162 vendor/plugins/backgroundrb/test/client/test_bdrb_cluster_connection.rb
  121. +0 −20 vendor/plugins/backgroundrb/test/client/test_bdrb_config.rb
  122. +0 −29 vendor/plugins/backgroundrb/test/client/test_bdrb_connection.rb
  123. +0 −63 vendor/plugins/backgroundrb/test/client/test_bdrb_job_queue.rb
  124. +0 −130 vendor/plugins/backgroundrb/test/client/test_worker_proxy.rb
  125. +0 −281 vendor/plugins/backgroundrb/test/server/test_cron_trigger.rb
  126. +0 −54 vendor/plugins/backgroundrb/test/server/test_master_proxy.rb
  127. +0 −157 vendor/plugins/backgroundrb/test/server/test_master_worker.rb
  128. +0 −281 vendor/plugins/backgroundrb/test/server/test_meta_worker.rb
  129. +0 −14 vendor/plugins/backgroundrb/test/server/test_result_storage.rb
  130. +0 −34 vendor/plugins/backgroundrb/test/socket_mocker.rb
  131. +0 −10 vendor/plugins/backgroundrb/test/workers/bar_worker.rb
  132. +0 −10 vendor/plugins/backgroundrb/test/workers/foo_worker.rb
  133. +0 −1 vendor/plugins/backgroundrb/uninstall.rb
  134. +76 −0 vendor/plugins/workling/CHANGES.markdown
  135. +2 −2 vendor/plugins/{backgroundrb → workling}/MIT-LICENSE
  136. +382 −0 vendor/plugins/workling/README.markdown
  137. +22 −0 vendor/plugins/workling/Rakefile
  138. +26 −0 vendor/plugins/workling/TODO.markdown
  139. +16 −0 vendor/plugins/workling/config/workling.yml
  140. +3 −0 vendor/plugins/workling/init.rb
  141. +17 −0 vendor/plugins/workling/install.rb
  142. +11 −0 vendor/plugins/workling/lib/rude_q/client.rb
  143. +150 −0 vendor/plugins/workling/lib/workling.rb
  144. +59 −0 vendor/plugins/workling/lib/workling/base.rb
  145. +40 −0 vendor/plugins/workling/lib/workling/clients/amqp_client.rb
  146. +54 −0 vendor/plugins/workling/lib/workling/clients/base.rb
  147. +82 −0 vendor/plugins/workling/lib/workling/clients/memcache_queue_client.rb
  148. +14 −0 vendor/plugins/workling/lib/workling/discovery.rb
  149. +42 −0 vendor/plugins/workling/lib/workling/remote.rb
  150. +124 −0 vendor/plugins/workling/lib/workling/remote/invokers/base.rb
  151. +41 −0 vendor/plugins/workling/lib/workling/remote/invokers/basic_poller.rb
  152. +37 −0 vendor/plugins/workling/lib/workling/remote/invokers/eventmachine_subscriber.rb
  153. +150 −0 vendor/plugins/workling/lib/workling/remote/invokers/threaded_poller.rb
  154. +35 −0 vendor/plugins/workling/lib/workling/remote/runners/backgroundjob_runner.rb
  155. +42 −0 vendor/plugins/workling/lib/workling/remote/runners/base.rb
  156. +45 −0 vendor/plugins/workling/lib/workling/remote/runners/client_runner.rb
  157. +23 −0 vendor/plugins/workling/lib/workling/remote/runners/not_remote_runner.rb
  158. +38 −0 vendor/plugins/workling/lib/workling/remote/runners/spawn_runner.rb
  159. +13 −0 vendor/plugins/workling/lib/workling/remote/runners/starling_runner.rb
  160. +37 −0 vendor/plugins/workling/lib/workling/return/store/base.rb
  161. +26 −0 vendor/plugins/workling/lib/workling/return/store/memory_return_store.rb
  162. +31 −0 vendor/plugins/workling/lib/workling/return/store/starling_return_store.rb
  163. +13 −0 vendor/plugins/workling/lib/workling/routing/base.rb
  164. +55 −0 vendor/plugins/workling/lib/workling/routing/class_and_method_routing.rb
  165. +11 −0 vendor/plugins/workling/script/bj_invoker.rb
  166. +48 −0 vendor/plugins/workling/script/listen.rb
  167. +37 −0 vendor/plugins/workling/script/starling_status.rb
  168. +17 −0 vendor/plugins/workling/script/workling_client
  169. +7 −0 vendor/plugins/workling/script/workling_starling_client
  170. +18 −0 vendor/plugins/workling/test/class_and_method_routing_test.rb
  171. +36 −0 vendor/plugins/workling/test/clients/memory_queue_client.rb
  172. +13 −0 vendor/plugins/workling/test/discovery_test.rb
  173. +29 −0 vendor/plugins/workling/test/invoker_basic_poller_test.rb
  174. +26 −0 vendor/plugins/workling/test/invoker_eventmachine_subscription_test.rb
  175. +34 −0 vendor/plugins/workling/test/invoker_threaded_poller_test.rb
  176. +36 −0 vendor/plugins/workling/test/memcachequeue_client_test.rb
  177. +23 −0 vendor/plugins/workling/test/memory_return_store_test.rb
  178. +9 −0 vendor/plugins/workling/test/mocks/client.rb
  179. +5 −0 vendor/plugins/workling/test/mocks/logger.rb
  180. +5 −0 vendor/plugins/workling/test/mocks/spawn.rb
  181. +11 −0 vendor/plugins/workling/test/not_remote_runner_test.rb
  182. +50 −0 vendor/plugins/workling/test/remote_runner_test.rb
  183. +18 −0 vendor/plugins/workling/test/return_store_test.rb
  184. +22 −0 vendor/plugins/workling/test/runners/thread_runner.rb
  185. +10 −0 vendor/plugins/workling/test/spawn_runner_test.rb
  186. +29 −0 vendor/plugins/workling/test/starling_return_store_test.rb
  187. +8 −0 vendor/plugins/workling/test/starling_runner_test.rb
  188. +48 −0 vendor/plugins/workling/test/test_helper.rb
  189. +10 −0 vendor/plugins/workling/test/workers/analytics/invites.rb
  190. +15 −0 vendor/plugins/workling/test/workers/util.rb
@@ -34,7 +34,7 @@ def create
respond_to do |format|
if @conversion.save
MiddleMan.worker(:video_worker).enq_queue_convert(:args => {:conversion_id => @conversion.id}, :job_key => @conversion.id)
VideoWorker.asynch_convert(:conversion_id => @conversion.id)
flash[:notice] = 'Conversion was successfully created.'
format.html { redirect_to(@conversion) }
format.xml { render :xml => @conversion, :status => :created, :location => @conversion }
@@ -44,14 +44,14 @@ def create
respond_to do |format|
if @thumbnail.save
MiddleMan.worker(:thumbnail_worker).enq_queue_thumbnail(:args => {:thumbnail_id => @thumbnail.id}, :job_key => @thumbnail.id)
ThumbnailWorker.asynch_generate(:thumbnail_id => @thumbnail.id)
if request.xhr?
@thumbnails = Thumbnail.find(:all, :conditions=>{:video_id => params[:video_id]})
@video = Video.find(:first, :conditions=>{:id => params[:video_id]})
render :layout => false, :partial => 'grid', :locals => {:thumbnails => @thumbnails, :video => @video, :controls=> true} and return
end
flash[:notice] = 'Thumbnail was successfully created.'
format.html { redirect_to(video_thumbnail_path(@thumbnail.video, @thumbnail)) }
format.html { redirect_to(video_thumbnails_path(@thumbnail.video)) }
format.xml { render :xml => @thumbnail, :status => :created, :location => @thumbnail }
else
format.html { render :action => "new" }
@@ -1,15 +1,4 @@
class ThumbnailWorker < BackgrounDRb::MetaWorker
set_worker_name :thumbnail_worker
pool_size 2
def create(args = nil)
logger.info("Creating thumbnail worker")
end
#Queue the request for a thumbnail
def queue_thumbnail(args)
thumbnail = Thumbnail.find(args[:thumbnail_id])
thumbnail.update_attributes({:status => "queued"})
thread_pool.defer(:generate,args)
end
class ThumbnailWorker < Workling::Base
#Generate a thumbnail
def generate(args = nil)
logger.info("Calling generate method for thumbnail #{args[:thumbnail_id]}.")
@@ -31,7 +20,6 @@ def generate(args = nil)
thumbnail.update_attributes({:status => "failed"})
return false
end
persistent_job.finish!
end
end
@@ -1,17 +1,4 @@
class VideoWorker < BackgrounDRb::MetaWorker
set_worker_name :video_worker
pool_size 5
def create(args = nil)
logger.info("Creating converter worker.")
end
#Queue up the video for conversion
def queue_convert(args)
conversion = Conversion.find(args[:conversion_id])
conversion.update_attributes({:status => "queued"})
thread_pool.defer(:convert,args)
end
class VideoWorker < Workling::Base
#Run the conversion of the video
def convert(args = nil)
#Open all the objects we'll need
@@ -77,10 +64,6 @@ def convert(args = nil)
conversion.update_attributes({:status => "failed", :end_time => Time.now})
end
end
#Mark this job as complete in the job queue
conversion.append_to_log "Marking job as complete."
persistent_job.finish!
end
View
@@ -44,4 +44,6 @@
# config.i18n.default_locale = :de
config.action_controller.relative_url_root = "/bonsai"
end
end
Workling::Remote.dispatcher = Workling::Remote::Runners::StarlingRunner.new
View
@@ -0,0 +1,16 @@
# By default, NotRemoteRunner is used when RAILS_ENV == 'test'.
#
# You can pass options to memcached client by nesting the key value pairs
# under 'memcache_options'.
#
# You can also use a cluster of Starlings. Simply give a comma separated
# list of server:port, server:port, server:port values to listens_on.
#
production:
listens_on: localhost:15151
development:
listens_on: localhost:22122
test:
listens_on: localhost:12345
View
@@ -1,47 +0,0 @@
#!/usr/bin/env ruby
RAILS_HOME = File.expand_path(File.join(File.dirname(__FILE__),".."))
BDRB_HOME = File.join(RAILS_HOME,"vendor","plugins","backgroundrb")
WORKER_ROOT = File.join(RAILS_HOME,"lib","workers")
WORKER_LOAD_ENV = File.join(RAILS_HOME,"script","load_worker_env")
["server","server/lib","lib","lib/backgroundrb"].each { |x| $LOAD_PATH.unshift(BDRB_HOME + "/#{x}")}
$LOAD_PATH.unshift(WORKER_ROOT)
require 'rubygems'
require RAILS_HOME + "/config/boot"
require "active_support"
require 'bdrb_config'
BDRB_CONFIG = BackgrounDRb::Config.read_config("#{RAILS_HOME}/config/backgroundrb.yml")
PID_FILE = "#{RAILS_HOME}/tmp/pids/backgroundrb_#{BDRB_CONFIG[:backgroundrb][:port]}.pid"
SERVER_LOGGER = "#{RAILS_HOME}/log/backgroundrb_debug_#{BDRB_CONFIG[:backgroundrb][:port]}.log"
require 'bdrb_start_stop'
daemon = BackgrounDRb::StartStop.new
case ARGV[0]
when 'start'; daemon.start
when 'stop'; daemon.stop
when 'restart'; daemon.stop;daemon.start
when 'status'
if daemon.running?
puts "BackgrounDRb Running"
exit
else
puts "BackgrounDRb Not Running"
exit!(daemon.status)
end
else
require "logger"
require "packet"
require "optparse"
BackgrounDRb::Config.parse_cmd_options ARGV
require RAILS_HOME + "/config/environment"
require "bdrb_job_queue"
require "backgroundrb_server"
BackgrounDRb::MasterProxy.new()
end
View
@@ -0,0 +1,11 @@
@routing = Workling::Routing::ClassAndMethodRouting.new
unnormalized = REXML::Text::unnormalize(STDIN.read)
message, command, args = *unnormalized.match(/(^[^ ]*) (.*)/)
options = Hash.from_xml(args)["hash"]
if workling = @routing[command]
options = options.symbolize_keys
method_name = @routing.method_name(command)
workling.dispatch_to_worker_method(method_name, options)
end
View
@@ -0,0 +1,37 @@
require 'pp'
puts '=> Loading Rails...'
require File.dirname(__FILE__) + '/../config/environment'
require File.dirname(__FILE__) + '/../vendor/plugins/workling/lib/workling/remote/invokers/basic_poller'
require File.dirname(__FILE__) + '/../vendor/plugins/workling/lib/workling/routing/class_and_method_routing'
puts '** Rails loaded.'
trap(:INT) { exit }
client = Workling::Clients::MemcacheQueueClient.new
begin
client.connect
client.reset
client.stats # do this so that connection is shown as established below.
puts "Queue state:"
pp client.inspect
pp "Active?: #{client.active?}"
pp "Read Only?: #{client.readonly?}"
puts ""
puts "Servers:"
pp client.servers
puts ""
puts "Queue stats:"
pp client.stats
puts "\nThread Stats:"
pp Thread.list
ensure
puts '** Exiting'
client.close
end
View
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
workling = File.join(File.dirname(__FILE__), '..', 'vendor', 'plugins', 'workling', 'script', 'listen.rb')
options = {
:app_name => "workling",
:ARGV => ARGV,
:dir_mode => :normal,
:dir => File.join(File.dirname(__FILE__), '..', 'log'),
:log_output => true,
:multiple => false,
:backtrace => true,
:monitor => true
}
Daemons.run(workling, options)
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
puts "\n>>>>>"
puts ">>>>> This script has been DEPRACATED. Please use script/workling_client instead!"
puts ">>>>>\n\n"
load File.dirname(__FILE__) + '/workling_client'
View
@@ -1,99 +0,0 @@
require File.join(File.dirname(__FILE__) + "/../config/environment")
WORKER_ROOT = RAILS_ROOT + "/lib/workers"
$LOAD_PATH.unshift(WORKER_ROOT)
class Object
def self.metaclass; class << self; self; end; end
def self.iattr_accessor *args
metaclass.instance_eval do
attr_accessor *args
args.each do |attr|
define_method("set_#{attr}") do |b_value|
self.send("#{attr}=",b_value)
end
end
end
args.each do |attr|
class_eval do
define_method(attr) do
self.class.send(attr)
end
define_method("#{attr}=") do |b_value|
self.class.send("#{attr}=",b_value)
end
end
end
end
end
module BackgrounDRb
class WorkerDummyLogger
%w(info debug fatal error warn).each do |x|
define_method(x) do |log_data|
end
end
end
class WorkData
attr_accessor :args,:block,:job_method,:persistent_job_id,:job_key
def initialize(args,job_key,job_method,persistent_job_id)
@args = args
@job_key = job_key
@job_method = job_method
@persistent_job_id = persistent_job_id
end
end
class ThreadPool
attr_accessor :size,:threads,:work_queue,:logger
attr_accessor :result_queue,:master
def initialize(master,size)
@master = master
@logger = logger
@size = size
@threads = []
end
def defer(method_name,args = nil)
job_key = Thread.current[:job_key]
persistent_job_id = Thread.current[:persistent_job_id]
t = WorkData.new(args,job_key,method_name,persistent_job_id)
result = run_task(t)
result
end
# run tasks popped out of queue
def run_task task
block_arity = master.method(task.job_method).arity
begin
t_data = task.args
result = nil
if block_arity != 0
result = master.send(task.job_method,task.args)
else
result = master.send(task.job_method)
end
return result
rescue
puts($!.to_s)
puts($!.backtrace.join("\n"))
return nil
end
end
end #end of class ThreadPool
class MetaWorker
attr_accessor :logger,:thread_pool
iattr_accessor :worker_name
iattr_accessor :no_auto_load
def initialize
@logger = WorkerDummyLogger.new
@thread_pool = ThreadPool.new(self,10)
end
end
end
@@ -1,17 +0,0 @@
class Autotest
def find_files
result = {}
Find.find '.' do |f|
Find.prune if @exceptions and f =~ @exceptions and test ?d, f
next if test ?d, f
next if f =~ /(swp|~|rej|orig|flymake)$/ # temporary/patch files
next if f =~ /\/\.?#/ # Emacs autosave/cvs merge files
filename = f.sub(/^\.\//, '')
result[filename] = File.stat(filename).mtime rescue next
end
return result
end
end
Oops, something went wrong.

0 comments on commit d33890a

Please sign in to comment.