From kato-k at rubyforge.org Fri Feb 1 00:36:46 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Fri, 1 Feb 2008 00:36:46 -0500 (EST) Subject: [ap4r-devel] [380] trunk/samples/HelloWorld/spec/load_ap4r_without_gem.rb: Modified how to set load path for spec. Message-ID: <20080201053646.B8D9918586E1@rubyforge.org> Revision: 380 Author: kato-k Date: 2008-02-01 00:36:46 -0500 (Fri, 01 Feb 2008) Log Message: ----------- Modified how to set load path for spec. Modified Paths: -------------- trunk/samples/HelloWorld/spec/load_ap4r_without_gem.rb Modified: trunk/samples/HelloWorld/spec/load_ap4r_without_gem.rb =================================================================== --- trunk/samples/HelloWorld/spec/load_ap4r_without_gem.rb 2008-02-01 02:34:43 UTC (rev 379) +++ trunk/samples/HelloWorld/spec/load_ap4r_without_gem.rb 2008-02-01 05:36:46 UTC (rev 380) @@ -1,5 +1,27 @@ -# load non-gem ap4r. -# In the case of using gem ap4r, remove a require option from spec.opts. +# In the case of laoding non-gem ap4r, make config/ap4r_spec.yml and write ap4r root dir. +# Otherwise, load gem ap4r. +# +# ap4r_spec.yml sample is following. +# +# --- +# ap4r: +# root_dir: ~/work/svn/ap4r/trunk/ap4r +# +# TODO: integrate ap4r's root setting among several config files. 2008/02/01 by kiwamu -ap4r_path = File.expand_path(File.dirname(__FILE__)) + "/../../../ap4r/lib" -$LOAD_PATH << ap4r_path +config_file = "./config/ap4r_spec.yml" +if File.exist?(config_file) + require 'yaml' + + config = {} + File.open(config_file, "r") do |input| + YAML.load_documents(ERB.new(input.read).result) do |doc| + config.merge! doc + end + end + @test_config = config["ap4r"] + @root_dir = @test_config["root_dir"] + + ap4r_lib_path = @root_dir + "/lib/" + $LOAD_PATH << ap4r_lib_path +end From kato-k at rubyforge.org Mon Feb 4 04:42:16 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Mon, 4 Feb 2008 04:42:16 -0500 (EST) Subject: [ap4r-devel] [381] trunk/ap4r/Rakefile: Added Rcov's excudes file. Message-ID: <20080204094216.B7C6518585DA@rubyforge.org> Revision: 381 Author: kato-k Date: 2008-02-04 04:42:15 -0500 (Mon, 04 Feb 2008) Log Message: ----------- Added Rcov's excudes file. Modified Paths: -------------- trunk/ap4r/Rakefile Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2008-02-01 05:36:46 UTC (rev 380) +++ trunk/ap4r/Rakefile 2008-02-04 09:42:15 UTC (rev 381) @@ -122,6 +122,9 @@ if ENV['GEM_HOME'] excludes << Regexp.escape(ENV['GEM_HOME']) end + if ENV['RUBY_HOME'] + excludes << Regexp.escape(ENV['RUBY_HOME']) + end t.rcov_opts = ["--exclude" , excludes.join(","), "--text-summary"] end From kato-k at rubyforge.org Mon Feb 4 05:41:53 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Mon, 4 Feb 2008 05:41:53 -0500 (EST) Subject: [ap4r-devel] [382] trunk/samples/HelloWorld/Rakefile: Added task for spec coverage. Message-ID: <20080204104153.777D8185861F@rubyforge.org> Revision: 382 Author: kato-k Date: 2008-02-04 05:41:51 -0500 (Mon, 04 Feb 2008) Log Message: ----------- Added task for spec coverage. Modified Paths: -------------- trunk/samples/HelloWorld/Rakefile Modified: trunk/samples/HelloWorld/Rakefile =================================================================== --- trunk/samples/HelloWorld/Rakefile 2008-02-04 09:42:15 UTC (rev 381) +++ trunk/samples/HelloWorld/Rakefile 2008-02-04 10:41:51 UTC (rev 382) @@ -73,6 +73,21 @@ CodeStatistics::TEST_TYPES << name } end + + desc "Run with rcov" + Spec::Rake::SpecTask.new("coverage") do |t| + t.spec_files = FileList["spec/**/*.rb"] + t.rcov = true + excludes = %w(^spec\/) + if ENV['GEM_HOME'] + excludes << Regexp.escape(ENV['GEM_HOME']) + end + if ENV['RUBY_HOME'] + excludes << Regexp.escape(ENV['RUBY_HOME']) + end + t.rcov_opts = ["--exclude" , excludes.join(","), + "--text-summary"] + end end task :stats => "spec:stats_setup" From noreply at rubyforge.org Mon Feb 4 17:12:23 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 4 Feb 2008 17:12:23 -0500 (EST) Subject: [ap4r-devel] [ ap4r-Patches-17780 ] allow to set HTTP timeout configuration option Message-ID: <20080204221224.248CC1858693@rubyforge.org> Patches item #17780, was opened at 2008-02-04 22:12 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=6912&aid=17780&group_id=1765 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Artem Vasiliev (artemv) Assigned to: Nobody (None) Summary: allow to set HTTP timeout configuration option Initial Comment: With this patch you can set HTTP timeout configuration parameter like this: {{{ dispatchers: - targets: queue.* threads: 1 http: timeout: 600 }}} The timeout value is in seconds. Without it I have Timeout::Error for long-running tasks - which is critical to me as I use Ap4r as tasks load balancer: with config above I want no more than one worker active all the time. Timeout errors break it. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=6912&aid=17780&group_id=1765 From kato-k at rubyforge.org Wed Feb 6 00:04:07 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Feb 2008 00:04:07 -0500 (EST) Subject: [ap4r-devel] [383] trunk: Modified rcov output path in CI environment. Message-ID: <20080206050410.39F3018585C7@rubyforge.org> Revision: 383 Author: kato-k Date: 2008-02-06 00:04:03 -0500 (Wed, 06 Feb 2008) Log Message: ----------- Modified rcov output path in CI environment. Modified Paths: -------------- trunk/ap4r/Rakefile trunk/samples/HelloWorld/Rakefile Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2008-02-04 10:41:51 UTC (rev 382) +++ trunk/ap4r/Rakefile 2008-02-06 05:04:03 UTC (rev 383) @@ -118,6 +118,8 @@ Spec::Rake::SpecTask.new(flavor) do |t| t.spec_files = FileList["spec/#{flavor}/**/*.rb"] t.rcov = true + build_artifacts = ENV['CC_BUILD_ARTIFACTS'] + t.rcov_dir = build_artifacts.nil? ? "coverage" : "#{build_artifacts}" excludes = %w(^spec\/) if ENV['GEM_HOME'] excludes << Regexp.escape(ENV['GEM_HOME']) Modified: trunk/samples/HelloWorld/Rakefile =================================================================== --- trunk/samples/HelloWorld/Rakefile 2008-02-04 10:41:51 UTC (rev 382) +++ trunk/samples/HelloWorld/Rakefile 2008-02-06 05:04:03 UTC (rev 383) @@ -78,6 +78,8 @@ Spec::Rake::SpecTask.new("coverage") do |t| t.spec_files = FileList["spec/**/*.rb"] t.rcov = true + build_artifacts = ENV['CC_BUILD_ARTIFACTS'] + t.rcov_dir = build_artifacts.nil? ? "coverage" : "#{build_artifacts}" excludes = %w(^spec\/) if ENV['GEM_HOME'] excludes << Regexp.escape(ENV['GEM_HOME']) From kato-k at rubyforge.org Wed Feb 6 03:12:53 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Feb 2008 03:12:53 -0500 (EST) Subject: [ap4r-devel] [384] trunk/ap4r: Added: configuration to set HTTP timeout. Message-ID: <20080206081253.457E418585C3@rubyforge.org> Revision: 384 Author: kato-k Date: 2008-02-06 03:12:52 -0500 (Wed, 06 Feb 2008) Log Message: ----------- Added: configuration to set HTTP timeout. Modified Paths: -------------- trunk/ap4r/History.txt trunk/ap4r/lib/ap4r/dispatcher.rb Modified: trunk/ap4r/History.txt =================================================================== --- trunk/ap4r/History.txt 2008-02-06 05:04:03 UTC (rev 383) +++ trunk/ap4r/History.txt 2008-02-06 08:12:52 UTC (rev 384) @@ -1,6 +1,8 @@ == 0.3.x -=== 0.3.6 (January ?, 2008) +=== 0.3.6 (February 6, 2008) +* Added: configuration to set HTTP timeout. + Based on a patch from Artem Vasiliev * Added: provisional support Rails2.0. * Changed: the location of message_builder.rb from rails plugin to ap4r core (ap4r/lib directory). * Fixed: bug (tracker #17206) that uninitialized constant error occurs when :active_record_store is used as session store. Modified: trunk/ap4r/lib/ap4r/dispatcher.rb =================================================================== --- trunk/ap4r/lib/ap4r/dispatcher.rb 2008-02-06 05:04:03 UTC (rev 383) +++ trunk/ap4r/lib/ap4r/dispatcher.rb 2008-02-06 08:12:52 UTC (rev 384) @@ -233,6 +233,12 @@ headers = make_header Net::HTTP.start(uri.host, uri.port) do |http| + # TODO: global configuration over dispatchers for each protocol should be considered, 2008/02/06 by kiwamu + # TODO: http open timeout should be considered, 2008/02/06 by kiwamu + if @conf['http'] && @conf['http']['timeout'] + http.read_timeout = @conf['http']['timeout'] + logger.info "set HTTP read timeout to #{http.read_timeout}s" + end @response, = http.post(uri.path, @message.object, headers) end end @@ -330,7 +336,7 @@ # class Druby < Base dispatch_mode :druby - + def invoke object = DRbObject.new_with_uri(@message[:target_url]) object.method_missing(@message[:target_method].to_sym, @message.object) From kato-k at rubyforge.org Wed Feb 6 04:20:01 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Feb 2008 04:20:01 -0500 (EST) Subject: [ap4r-devel] [385] trunk/ap4r/lib/ap4r/message_store_ext.rb: Fixed: uninitialized constant error if MySQL bridge is not installed. Message-ID: <20080206092001.6B4AB18585E5@rubyforge.org> Revision: 385 Author: kato-k Date: 2008-02-06 04:20:00 -0500 (Wed, 06 Feb 2008) Log Message: ----------- Fixed: uninitialized constant error if MySQL bridge is not installed. Modified Paths: -------------- trunk/ap4r/lib/ap4r/message_store_ext.rb Modified: trunk/ap4r/lib/ap4r/message_store_ext.rb =================================================================== --- trunk/ap4r/lib/ap4r/message_store_ext.rb 2008-02-06 08:12:52 UTC (rev 384) +++ trunk/ap4r/lib/ap4r/message_store_ext.rb 2008-02-06 09:20:00 UTC (rev 385) @@ -23,14 +23,14 @@ queue == mq end } - }.map{|queue, messages| + }.map{|queue, messages| [queue, messages[0][:created]] }.min {|q1, q2| q1[1] <=> q2[1] } queue_and_created ? queue_and_created[0] : nil end - + # Returns a message store from the specified configuration (previously # created with configure). # @@ -60,7 +60,7 @@ rescue LoadError require 'postgres-pr/connection' end - + require 'base64' class PostgreSQL < Base #:nodoc: @@ -206,10 +206,10 @@ end def connection - Thread.current[THREAD_CURRENT_PGSQL] ||= + Thread.current[THREAD_CURRENT_PGSQL] ||= # PGconn is overriding in this file, so is defined regardless of 'postgres' LoadError. if Object.const_defined? :PGError - ::PGconn.connect @config[:host], @config[:port], @config[:options], @config[:tty], @config[:database], @config[:username], @config[:password] + ::PGconn.connect @config[:host], @config[:port], @config[:options], @config[:tty], @config[:database], @config[:username], @config[:password] elsif Object.const_defined? :PostgresPR ::PostgresPR::Connection.new @config[:database], @config[:username], @config[:password], @config[:uri] end @@ -217,16 +217,16 @@ end end - + rescue LoadError # do nothing end - + begin # ActiveRecord # Make sure we have a ActiveRecord library before creating this class, - # worst case we end up with a disk-based message store. + # worst case we end up with a disk-based message store. begin require 'active_record' require 'ap4r/reliable_msg_queue' @@ -274,7 +274,7 @@ def configuration - config = { "type"=>TYPE, "adapter"=>@config[:adapter], "host"=>@config[:host], + config = { "type"=>TYPE, "adapter"=>@config[:adapter], "host"=>@config[:host], "username"=>@config[:username], "password"=>@config[:password], "database"=>@config[:database] } config["port"] = @config[:port] if @config[:port] config["socket"] = @config[:socket] if @config[:socket] @@ -335,7 +335,7 @@ rescue Exception=>error raise error end - super + super end @@ -356,7 +356,7 @@ end queue << headers unless added end - + ::Ap4r::ReliableMsgTopic.find(:all).each do |message| @topocs[message[:topic]] = Marshal::load(message[:headers]) end @@ -391,8 +391,8 @@ rescue LoadError # do nothing end - - + + class Memory < Base #:nodoc: TYPE = self.name.split('::').last.downcase @@ -443,7 +443,7 @@ @mutex.synchronize do @memory_map[insert[:id]] = insert[:message] end - end + end super @mutex.synchronize do deletes.each do |delete| @@ -476,7 +476,7 @@ maybe_result.clear end end - + def quote str # do nothing str @@ -510,15 +510,15 @@ # do nothing str end - - end + + end end end -if ReliableMsg::MessageStore::Base.use_mysql_extention +if Object.const_defined?(:Mysql) && ReliableMsg::MessageStore::Base.use_mysql_extention class Mysql #:nodoc: alias original_query query - + # In Ruby/MySQL, +query+ method does NOT care about a given block. # To make it behave the same as MySQL/Ruby, this method adds iteration # over query results. From kato-k at rubyforge.org Wed Feb 6 04:22:48 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 6 Feb 2008 04:22:48 -0500 (EST) Subject: [ap4r-devel] [386] trunk/ap4r/lib/ap4r/queue_manager_ext.rb: Fixed: const_missing error for ERB. Message-ID: <20080206092248.5DB4218585EE@rubyforge.org> Revision: 386 Author: kato-k Date: 2008-02-06 04:22:47 -0500 (Wed, 06 Feb 2008) Log Message: ----------- Fixed: const_missing error for ERB. Modified Paths: -------------- trunk/ap4r/lib/ap4r/queue_manager_ext.rb Modified: trunk/ap4r/lib/ap4r/queue_manager_ext.rb =================================================================== --- trunk/ap4r/lib/ap4r/queue_manager_ext.rb 2008-02-06 09:20:00 UTC (rev 385) +++ trunk/ap4r/lib/ap4r/queue_manager_ext.rb 2008-02-06 09:22:47 UTC (rev 386) @@ -6,7 +6,7 @@ require 'yaml' require 'thread' require 'pp' - +require 'erb' require 'uuid' require 'reliable-msg' @@ -19,21 +19,21 @@ module ReliableMsg #:nodoc: # = Dynamic configuration with ERb - # - # Some times you would like to inject dynamic values into your configuration file. + # + # Some times you would like to inject dynamic values into your configuration file. # In these cases, you can mix ERb in with your YAML to code some logic, like: - # + # # <% acl = [] %> # <% for i in 1..100 %> # <% acl << "192.168.0.#{i}" %> - # <% end %> + # <% end %> # acl: <%= acl.map{|ip| "allow #{ip}"}.join(' ') # class Config - + alias :load_no_create_original :load_no_create alias :load_or_create_original :load_or_create - + #-- # TODO: should enhance YAML.load_documents instead of this method?, 2007/5/7 kato-k def load_no_create @@ -47,7 +47,7 @@ true end end - + #-- # TODO: should enhance YAML.load_documents instead of this method?, 2007/5/7 kato-k def load_or_create @@ -68,13 +68,13 @@ @logger.info format(INFO_CREATED_CONFIG, @file) end end - + private def erb_render(configuration_content) - ERB.new(configuration_content).result + ::ERB.new(configuration_content).result end end - + class QueueManager # Gets a queue name which has the most stale message. From noreply at rubyforge.org Wed Feb 6 19:55:56 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Wed, 6 Feb 2008 19:55:56 -0500 (EST) Subject: [ap4r-devel] [ ap4r-Patches-17780 ] allow to set HTTP timeout configuration option Message-ID: <20080207005556.C9BD018585B7@rubyforge.org> Patches item #17780, was opened at 2008-02-05 07:12 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=6912&aid=17780&group_id=1765 Category: None Group: None >Status: Closed >Resolution: Accepted Priority: 3 Submitted By: Artem Vasiliev (artemv) >Assigned to: kiwamu kato (kato-k) Summary: allow to set HTTP timeout configuration option Initial Comment: With this patch you can set HTTP timeout configuration parameter like this: {{{ dispatchers: - targets: queue.* threads: 1 http: timeout: 600 }}} The timeout value is in seconds. Without it I have Timeout::Error for long-running tasks - which is critical to me as I use Ap4r as tasks load balancer: with config above I want no more than one worker active all the time. Timeout errors break it. ---------------------------------------------------------------------- >Comment By: kiwamu kato (kato-k) Date: 2008-02-07 09:55 Message: This patch is taken in into ap4r-0.3.6 which was released last night. RubyForge: -ann--ap4r-0.3.6-released http://rubyforge.org/forum/forum.php?forum_id=21467 Global configuration over dispatchers and other protocol's configuration are in my TODO list. Thanks, kiwamu ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=6912&aid=17780&group_id=1765 From noreply at rubyforge.org Thu Feb 7 03:41:30 2008 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Thu, 7 Feb 2008 03:41:30 -0500 (EST) Subject: [ap4r-devel] [ ap4r-Patches-17780 ] allow to set HTTP timeout configuration option Message-ID: <20080207084131.19A9F18585F6@rubyforge.org> Patches item #17780, was opened at 2008-02-04 22:12 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=6912&aid=17780&group_id=1765 Category: None Group: None Status: Closed Resolution: Accepted Priority: 3 Submitted By: Artem Vasiliev (artemv) Assigned to: kiwamu kato (kato-k) Summary: allow to set HTTP timeout configuration option Initial Comment: With this patch you can set HTTP timeout configuration parameter like this: {{{ dispatchers: - targets: queue.* threads: 1 http: timeout: 600 }}} The timeout value is in seconds. Without it I have Timeout::Error for long-running tasks - which is critical to me as I use Ap4r as tasks load balancer: with config above I want no more than one worker active all the time. Timeout errors break it. ---------------------------------------------------------------------- >Comment By: Artem Vasiliev (artemv) Date: 2008-02-07 08:41 Message: cool! ---------------------------------------------------------------------- Comment By: kiwamu kato (kato-k) Date: 2008-02-07 00:55 Message: This patch is taken in into ap4r-0.3.6 which was released last night. RubyForge: -ann--ap4r-0.3.6-released http://rubyforge.org/forum/forum.php?forum_id=21467 Global configuration over dispatchers and other protocol's configuration are in my TODO list. Thanks, kiwamu ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=6912&aid=17780&group_id=1765 From kato-k at rubyforge.org Thu Feb 7 06:15:26 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Thu, 7 Feb 2008 06:15:26 -0500 (EST) Subject: [ap4r-devel] [388] tags/ap4r-0.3.6/: tag 0.3.6 Message-ID: <20080207111526.D211418585F6@rubyforge.org> Revision: 388 Author: kato-k Date: 2008-02-07 06:15:26 -0500 (Thu, 07 Feb 2008) Log Message: ----------- tag 0.3.6 Added Paths: ----------- tags/ap4r-0.3.6/ Copied: tags/ap4r-0.3.6 (from rev 387, trunk) From shinohara.shunichi at future.co.jp Mon Feb 11 20:36:35 2008 From: shinohara.shunichi at future.co.jp (shinohara.shunichi at future.co.jp) Date: Tue, 12 Feb 2008 10:36:35 +0900 Subject: [ap4r-devel] Archive Test Message-ID: <14CE73B79D552644B7CBEF0428763DF60427311B@045MAIL.future.co.jp> This is a test mail. shino From shinohara.shunichi at future.co.jp Thu Feb 14 00:32:14 2008 From: shinohara.shunichi at future.co.jp (shinohara.shunichi at future.co.jp) Date: Thu, 14 Feb 2008 14:32:14 +0900 Subject: [ap4r-devel] Archive Test In-Reply-To: <14CE73B79D552644B7CBEF0428763DF60427311B@045MAIL.future.co.jp> References: <14CE73B79D552644B7CBEF0428763DF60427311B@045MAIL.future.co.jp> Message-ID: <14CE73B79D552644B7CBEF0428763DF604273409@045MAIL.future.co.jp> One more test mail. > -----Original Message----- > > This is a test mail. > > shino From kato-k at rubyforge.org Thu Feb 14 05:07:50 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Thu, 14 Feb 2008 05:07:50 -0500 (EST) Subject: [ap4r-devel] [389] trunk/samples/HelloWorld/test: Modified sample's functional test. Message-ID: <20080214100750.625DF1858663@rubyforge.org> Revision: 389 Author: kato-k Date: 2008-02-14 05:07:49 -0500 (Thu, 14 Feb 2008) Log Message: ----------- Modified sample's functional test. Added Paths: ----------- trunk/samples/HelloWorld/test/functional/sync_hello_controller_test.rb Removed Paths: ------------- trunk/samples/HelloWorld/test/integration/ap4r_queue_stub.rb trunk/samples/HelloWorld/test/integration/hello_rails_integration_with_ap4r_test.rb Added: trunk/samples/HelloWorld/test/functional/sync_hello_controller_test.rb =================================================================== --- trunk/samples/HelloWorld/test/functional/sync_hello_controller_test.rb (rev 0) +++ trunk/samples/HelloWorld/test/functional/sync_hello_controller_test.rb 2008-02-14 10:07:49 UTC (rev 389) @@ -0,0 +1,30 @@ +# Author:: Shunichi Shinohara +# Copyright:: Copyright (c) 2007 Future Architect Inc. +# Licence:: MIT Licence + +require File.dirname(__FILE__) + '/../test_helper' +require 'ap4r/queue_put_stub' +require 'sync_hello_controller' + +# Re-raise errors caught by the controller. +class SyncHelloController; def rescue_action(e) raise e end; end + +class SyncHelloControllerTest < Test::Unit::TestCase + def setup + @controller = SyncHelloController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end + + def test_hello_via_http_and_async + post :execute_via_http, {} + assert_response 200 + assert_equal 1, @controller.ap4r.queued_messages.size + end + +end Deleted: trunk/samples/HelloWorld/test/integration/ap4r_queue_stub.rb =================================================================== --- trunk/samples/HelloWorld/test/integration/ap4r_queue_stub.rb 2008-02-07 11:15:26 UTC (rev 388) +++ trunk/samples/HelloWorld/test/integration/ap4r_queue_stub.rb 2008-02-14 10:07:49 UTC (rev 389) @@ -1,42 +0,0 @@ -# Author:: Shunichi Shinohara -# Copyright:: Copyright (c) 2007 Future Architect Inc. -# Licence:: MIT Licence - -require 'reliable-msg' -require 'ap4r' - -class Ap4rTestHelper - - def clear(*queues) - end -end - -ap4r_test_helper = Ap4rTestHelper.new - -class ActionController::IntegrationTest - cattr_accessor :ap4r_helper - - def ap4r_helper - @@ap4r_helper - end -end - -ActionController::IntegrationTest.ap4r_helper = ap4r_test_helper - -module Ap4r - module AsyncHelper - module Base - def async_messages - @messages ||= [] - end - - private - def __queue_put(queue_name, queue_message, queue_headers) - async_messages << - {:queue_name => queue_name, - :message => queue_message, - :queue_headers => queue_headers} - end - end - end -end Deleted: trunk/samples/HelloWorld/test/integration/hello_rails_integration_with_ap4r_test.rb =================================================================== --- trunk/samples/HelloWorld/test/integration/hello_rails_integration_with_ap4r_test.rb 2008-02-07 11:15:26 UTC (rev 388) +++ trunk/samples/HelloWorld/test/integration/hello_rails_integration_with_ap4r_test.rb 2008-02-14 10:07:49 UTC (rev 389) @@ -1,23 +0,0 @@ -# Author:: Shunichi Shinohara -# Copyright:: Copyright (c) 2007 Future Architect Inc. -# Licence:: MIT Licence - -require "#{File.dirname(__FILE__)}/../test_helper" -require "#{File.dirname(__FILE__)}/ap4r_queue_stub" - -# TODO: not yet implemented async call invocations 2007/05/29 by shino -class HelloRailsIntegrationWithAp4rTest < ActionController::IntegrationTest - - # Trivial test case to test the ap4r test helper. - def test_truth - assert true - assert_not_nil ap4r_helper - end - - def test_hello_via_http_and_async - get "/sync_hello/execute_via_http" - assert_equal 200, status - assert_equal 1, @controller.ap4r.async_messages.size - end - -end From shinohara.shunichi at future.co.jp Thu Feb 14 19:42:10 2008 From: shinohara.shunichi at future.co.jp (shinohara.shunichi at future.co.jp) Date: Fri, 15 Feb 2008 09:42:10 +0900 Subject: [ap4r-devel] Archive Test In-Reply-To: <14CE73B79D552644B7CBEF0428763DF604273409@045MAIL.future.co.jp> References: <14CE73B79D552644B7CBEF0428763DF60427311B@045MAIL.future.co.jp> <14CE73B79D552644B7CBEF0428763DF604273409@045MAIL.future.co.jp> Message-ID: <14CE73B79D552644B7CBEF0428763DF6042734F3@045MAIL.future.co.jp> test mail. sorry for again and again. # gmane.org seems not working well for this list :-< shino > > > -----Original Message----- > > > > This is a test mail. > > > > shino From shino.shun at gmail.com Fri Feb 15 08:23:55 2008 From: shino.shun at gmail.com (shun shino) Date: Fri, 15 Feb 2008 22:23:55 +0900 Subject: [ap4r-devel] Archive Test In-Reply-To: <14CE73B79D552644B7CBEF0428763DF6042734F3@045MAIL.future.co.jp> References: <14CE73B79D552644B7CBEF0428763DF60427311B@045MAIL.future.co.jp> <14CE73B79D552644B7CBEF0428763DF604273409@045MAIL.future.co.jp> <14CE73B79D552644B7CBEF0428763DF6042734F3@045MAIL.future.co.jp> Message-ID: <6af2b9b80802150523h359cd2e2o44d819eb48d9e97e@mail.gmail.com> one more time 2008/2/15, shinohara.shunichi at future.co.jp : > test mail. sorry for again and again. > # gmane.org seems not working well for this list :-< > > shino > > > > > > > -----Original Message----- > > > > > > This is a test mail. > > > > > > shino > > > _______________________________________________ > ap4r-devel mailing list > ap4r-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/ap4r-devel > > From shinohara.shunichi at future.co.jp Wed Feb 20 03:02:44 2008 From: shinohara.shunichi at future.co.jp (shinohara.shunichi at future.co.jp) Date: Wed, 20 Feb 2008 17:02:44 +0900 Subject: [ap4r-devel] Archive Test In-Reply-To: <6af2b9b80802150523h359cd2e2o44d819eb48d9e97e@mail.gmail.com> References: <14CE73B79D552644B7CBEF0428763DF60427311B@045MAIL.future.co.jp><14CE73B79D552644B7CBEF0428763DF604273409@045MAIL.future.co.jp><14CE73B79D552644B7CBEF0428763DF6042734F3@045MAIL.future.co.jp> <6af2b9b80802150523h359cd2e2o44d819eb48d9e97e@mail.gmail.com> Message-ID: <14CE73B79D552644B7CBEF0428763DF6042739DF@045MAIL.future.co.jp> one more, I hope this will be the last one! > -----Original Message----- > > > > -----Original Message----- > > > > > > > > This is a test mail. > > > > > > > > shino > > From shinohara.shunichi at future.co.jp Sat Feb 23 10:37:15 2008 From: shinohara.shunichi at future.co.jp (shinohara.shunichi at future.co.jp) Date: Sun, 24 Feb 2008 00:37:15 +0900 Subject: [ap4r-devel] Archive Test References: <14CE73B79D552644B7CBEF0428763DF60427311B@045MAIL.future.co.jp><14CE73B79D552644B7CBEF0428763DF604273409@045MAIL.future.co.jp><14CE73B79D552644B7CBEF0428763DF6042734F3@045MAIL.future.co.jp><6af2b9b80802150523h359cd2e2o44d819eb48d9e97e@mail.gmail.com> <14CE73B79D552644B7CBEF0428763DF6042739DF@045MAIL.future.co.jp> Message-ID: <14CE73B79D552644B7CBEF0428763DF625A858@045MAIL.future.co.jp> i need one more :-< > > > > -----Original Message----- > > > > > > > > This is a test mail. > > > > > > > > shino > > From shinohara.shunichi at future.co.jp Sun Feb 24 20:47:25 2008 From: shinohara.shunichi at future.co.jp (shinohara.shunichi at future.co.jp) Date: Mon, 25 Feb 2008 10:47:25 +0900 Subject: [ap4r-devel] Archive Test In-Reply-To: <14CE73B79D552644B7CBEF0428763DF625A858@045MAIL.future.co.jp> References: <14CE73B79D552644B7CBEF0428763DF60427311B@045MAIL.future.co.jp><14CE73B79D552644B7CBEF0428763DF604273409@045MAIL.future.co.jp><14CE73B79D552644B7CBEF0428763DF6042734F3@045MAIL.future.co.jp><6af2b9b80802150523h359cd2e2o44d819eb48d9e97e@mail.gmail.com><14CE73B79D552644B7CBEF0428763DF6042739DF@045MAIL.future.co.jp> <14CE73B79D552644B7CBEF0428763DF625A858@045MAIL.future.co.jp> Message-ID: <14CE73B79D552644B7CBEF0428763DF6044BA3EF@045MAIL.future.co.jp> this should be the last one. > -----Original Message----- > > > > > -----Original Message----- > > > > > > > > > > This is a test mail. > > > > > > > > > > shino > > > > From shinohara.shunichi at future.co.jp Sun Feb 24 21:03:02 2008 From: shinohara.shunichi at future.co.jp (shinohara.shunichi at future.co.jp) Date: Mon, 25 Feb 2008 11:03:02 +0900 Subject: [ap4r-devel] FW: ap4r-devel added to Gmane In-Reply-To: <14CE73B79D552644B7CBEF0428763DF60403753A@045MAIL.future.co.jp> References: <14CE73B79D552644B7CBEF0428763DF60403753A@045MAIL.future.co.jp> Message-ID: <14CE73B79D552644B7CBEF0428763DF6044BA3F8@045MAIL.future.co.jp> Hi All I sent bellow mail about a month ago, but Gmane's archive had been not working well. Under the favor of Gmane's admin help, it goes available now. Once again, I paste up the links: * Newsgroup name: gmane.comp.lang.ruby.ap4r.devel * News URL: news://news.gmane.org/gmane.comp.lang.ruby.ap4r.devel * Web URL: http://dir.gmane.org/gmane.comp.lang.ruby.ap4r.devel Regards, shino > -----Original Message----- > Hi All, > > The archive of this list is on Gmane from now on (as well as The Mail Archive). > > Regards, > shino > > -----Original Message----- > > Gmane is a mail-to-news portal that never expires its messages. It > therefore also functions as a mailing list archive. It's a [snip] > The following parameters are set for this mailing list: > > * Newsgroup name: gmane.comp.lang.ruby.ap4r.devel > * Mailing list address: ap4r-devel at rubyforge.org > * The gateway is bi-directional > * Address encryption is on > * Spam detection is on > * The list is described as: > "Discussions for AP4R developers, Commit Logs, etc." > * News URL: news://news.gmane.org/gmane.comp.lang.ruby.ap4r.devel > * Web URL: http://dir.gmane.org/gmane.comp.lang.ruby.ap4r.devel > From kato-k at rubyforge.org Thu Feb 28 05:16:25 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Thu, 28 Feb 2008 05:16:25 -0500 (EST) Subject: [ap4r-devel] [391] trunk/ap4r/lib/ap4r: Added experimental monitoring interface by HTTP. Message-ID: <20080228101625.7B7F018585FA@rubyforge.org> Revision: 391 Author: kato-k Date: 2008-02-28 05:16:21 -0500 (Thu, 28 Feb 2008) Log Message: ----------- Added experimental monitoring interface by HTTP. Modified Paths: -------------- trunk/ap4r/lib/ap4r/mongrel.rb trunk/ap4r/lib/ap4r/mongrel_ap4r.rb Modified: trunk/ap4r/lib/ap4r/mongrel.rb =================================================================== --- trunk/ap4r/lib/ap4r/mongrel.rb 2008-02-25 05:47:55 UTC (rev 390) +++ trunk/ap4r/lib/ap4r/mongrel.rb 2008-02-28 10:16:21 UTC (rev 391) @@ -291,5 +291,61 @@ end + # TODO: comment + # + class Ap4rMonitoringHandler < ::Mongrel::HttpHandler + + def initialize(options) + @tick = Time.now + + dlq = ReliableMsg::Queue.new "$dlq" + @qm = dlq.send :qm + end + + def process(request, response) + if response.socket.closed? + return + end + + target = request.params[::Mongrel::Const::PATH_INFO][1..-1] + + if "GET".include? request.params[::Mongrel::Const::REQUEST_METHOD] + begin + # TODO: consider URL for each target, 2008/02/28 by kiwamu + result = case target + when /dlq_messages/ + @qm.store.queues["$dlq"].size + when /all_messages/ + @qm.store.queues.map{|k,v| v.size}.sum + else + raise + end + + response.start(200) do |head, out| + head['Content-Type'] = 'text/plain' + out.write result + end + rescue + response.start(500) do |head, out| + head['Content-Type'] = 'text/plain' + out.write "Failed to monitor #{target}" + end + end + else + raise "HTTP method is not GET..." + end + end + + # Does the internal reload for Rails. It might work for most cases, but + # sometimes you get exceptions. In that case just do a real restart. + def reload! + begin + #TODO not implemented 2007/04/09 by shino + raise "not yet implemented!" + end + end + + end + end end Modified: trunk/ap4r/lib/ap4r/mongrel_ap4r.rb =================================================================== --- trunk/ap4r/lib/ap4r/mongrel_ap4r.rb 2008-02-25 05:47:55 UTC (rev 390) +++ trunk/ap4r/lib/ap4r/mongrel_ap4r.rb 2008-02-28 10:16:21 UTC (rev 391) @@ -118,6 +118,7 @@ uri "/", :handler => ::Ap4r::Mongrel::Ap4rHandler.new(defaults) uri "/queues", :handler => ::Ap4r::Mongrel::Ap4rSendMessageHandler.new(defaults) uri "/subscribes", :handler => ::Ap4r::Mongrel::Ap4rSubscribeMessageHandler.new(defaults) + uri "/monitoring", :handler => ::Ap4r::Mongrel::Ap4rMonitoringHandler.new(defaults) end setup_signals(settings) end From kato-k at rubyforge.org Thu Feb 28 22:43:28 2008 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Thu, 28 Feb 2008 22:43:28 -0500 (EST) Subject: [ap4r-devel] [392] trunk/ap4r/lib/ap4r: Added mointoring API for dispatchers and modified URL. Message-ID: <20080229034328.7F6D0185869C@rubyforge.org> Revision: 392 Author: kato-k Date: 2008-02-28 22:43:27 -0500 (Thu, 28 Feb 2008) Log Message: ----------- Added mointoring API for dispatchers and modified URL. Modified Paths: -------------- trunk/ap4r/lib/ap4r/dispatcher.rb trunk/ap4r/lib/ap4r/mongrel.rb Modified: trunk/ap4r/lib/ap4r/dispatcher.rb =================================================================== --- trunk/ap4r/lib/ap4r/dispatcher.rb 2008-02-28 10:16:21 UTC (rev 391) +++ trunk/ap4r/lib/ap4r/dispatcher.rb 2008-02-29 03:43:27 UTC (rev 392) @@ -21,9 +21,10 @@ # - calls a Dispatchers::Base's instance. class Dispatchers + attr_reader :config, :group @@sleep_inverval = 0.1 + @@logger = nil - @@logger = nil def self.logger @@logger end Modified: trunk/ap4r/lib/ap4r/mongrel.rb =================================================================== --- trunk/ap4r/lib/ap4r/mongrel.rb 2008-02-28 10:16:21 UTC (rev 391) +++ trunk/ap4r/lib/ap4r/mongrel.rb 2008-02-29 03:43:27 UTC (rev 392) @@ -291,8 +291,18 @@ end - # TODO: comment + # This class is an experimental implementation of monitoring API by HTTP. + # It's possible to get the number of message in an arbitrary queue and + # the number of (alive/dead) thread of dispatchers. # + # === Rrequest example === + # GET /mointoring/queues/queue.test HTTP/1.1 + # GET /mointoring/queues/all HTTP/1.1 + # GET /mointoring/queues/dlq HTTP/1.1 + # + # GET /mointoring/dispatchers/alive_threads HTTP/1.1 + # GET /mointoring/dispatchers/dead_threads HTTP/1.1 + # class Ap4rMonitoringHandler < ::Mongrel::HttpHandler def initialize(options) @@ -313,10 +323,27 @@ begin # TODO: consider URL for each target, 2008/02/28 by kiwamu result = case target - when /dlq_messages/ - @qm.store.queues["$dlq"].size - when /all_messages/ - @qm.store.queues.map{|k,v| v.size}.sum + when /^queues\/*(\S*)/ + case queue_name = $1 + when "" + @qm.store.queues.keys.join(" ") + when "dlq" + @qm.store.queues["$dlq"].size + when "all" + @qm.store.queues.map{|k,v| v.size}.sum + else + @qm.store.queues[queue_name].size + end + when /^dispatchers\/*(\S*)/ + case $1 + when "alive_threads" + @qm.dispatchers.group.list.size + when "dead_threads" + diff = @qm.dispatchers.config.map{|d| d["threads"]}.sum - @qm.dispatchers.group.list.size + diff > 0 ? diff : 0 + else + raise + end else raise end