Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIPX-883: Fix/Workaround for Missing CDRs for failed calls (4xx responses) #152

Open
wants to merge 5 commits into
base: release-21.04-centos7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions sipXcdr/lib/call_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.")

Expand Down
13 changes: 0 additions & 13 deletions sipXcdr/lib/cdr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions sipXcdr/lib/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down