diff --git a/sipXcdr/lib/call_resolver.rb b/sipXcdr/lib/call_resolver.rb index d982c8c0e4..2e1bf24b21 100644 --- a/sipXcdr/lib/call_resolver.rb +++ b/sipXcdr/lib/call_resolver.rb @@ -35,9 +35,6 @@ def initialize(config) end install_signal_handler(@readers) @writer = CdrWriter.new(@config.cdr_database_url, @config.purge_age_cdr, log) - @long_calls_cleaner = Cleaner.new(@config.min_cleanup_interval, [:retire_long_calls, @config.max_call_len]) - @long_ringing_calls_cleaner = Cleaner.new(@config.min_cleanup_interval, [:retire_long_ringing_calls, @config.max_ringing_call_len]) - @failed_calls_cleaner = Cleaner.new(@config.min_cleanup_interval, [:flush_failed_calls, @config.max_failed_wait]) @state = nil end @@ -71,20 +68,14 @@ def resolve(start_time, end_time) end end - long_calls_cleaner_thread = Thread.new(@long_calls_cleaner, cse_queue) do |cleaner, queue| - cleaner.run(queue) - end - failed_calls_cleaner_thread = Thread.new(@failed_calls_cleaner, cse_queue) do |cleaner, queue| - cleaner.run(queue) - end - long_ringing_calls_cleaner_thread = Thread.new(@long_ringing_calls_cleaner, cse_queue) do |cleaner, queue| - cleaner.run(queue) - end - # state copies from CSE queue to CDR queue @state = State.new(cse_queue, cdr_queue) @state.log = @log + @state.max_call_len = @config.max_call_len + @state.max_ringing_call_len = @config.max_ringing_call_len + @state.max_failed_wait = @config.max_failed_wait + Thread.new( @state ) do | state | state.run end @@ -112,11 +103,6 @@ def resolve(start_time, end_time) log.debug("call_resolver.rb:: CSE Readers threads stopped.") log.debug("call_resolver.rb:: CSEs in Queue = #{cse_queue.size()}") - # stop running housekeeping jobs - @long_calls_cleaner.stop - @failed_calls_cleaner.stop - @long_ringing_calls_cleaner.stop - ThreadsWait.all_waits(long_calls_cleaner_thread, failed_calls_cleaner_thread, long_ringing_calls_cleaner_thread) log.debug("call_resolver.rb:: Clean-up threads stopped.") diff --git a/sipXcdr/lib/cdr.rb b/sipXcdr/lib/cdr.rb index f123ced2eb..cd2e527ca6 100644 --- a/sipXcdr/lib/cdr.rb +++ b/sipXcdr/lib/cdr.rb @@ -360,19 +360,6 @@ def accept_call_transfer(cse) end def accept_call_end(cse) - # set fields unless previous events were caught and fields already set - @from_tag = cse.from_tag if !@from_tag - @caller_aor = cse.caller_aor if !@caller_aor - @callee_aor = cse.callee_aor if !@callee_aor - @start_time = cse.event_time if !@start_time - @reference = cse.reference if !@reference - @caller_internal = cse.caller_internal if !@caller_internal - @caller_contact = Utils.contact_without_params(cse.contact) if !@caller_contact - @via_count = cse.via_count if !@via_count - @branch_id = cse.branch_id if !@branch_id - @callee_route = cse.callee_route if !@callee_route - @callee_contact = cse.contact if !@callee_contact - @legs.accept_end(cse) finish end diff --git a/sipXcdr/lib/state.rb b/sipXcdr/lib/state.rb index 6906f67453..738e3c8561 100644 --- a/sipXcdr/lib/state.rb +++ b/sipXcdr/lib/state.rb @@ -27,7 +27,7 @@ def initialize(cdr, generation) end end - attr_writer :log + attr_writer :log, :max_call_len, :max_ringing_call_len, :max_failed_wait def initialize(cse_queue, cdr_queue, cdr_class = Cdr) @cse_queue = cse_queue @@ -58,7 +58,19 @@ def run else accept(item) #@log.debug("state.rb:: Accepted #{item}") if @log - end + end + + # TODO: we should check for the min distance between runs... + # so that we reduce runtime + + # run background tasks (this should run in own tasks but currently this does not work + # with the old code (maybe the dependencies have changed because of the update to ruby-2.0.0 ? + # this is meant as an workaround but I was not able to solve it differently + # and this works + # and as ruby is one threaded in base this should not change anything regards runtime... + retire_long_calls(@max_call_len) + retire_long_ringing_calls(@max_ringing_call_len) + flush_failed_calls(@max_failed_wait) end flush_failed() @cdr_queue << nil