TT#50606 ama: option for automatic fsn rollover

(cherry picked from commit 6646011ffc)

Change-Id: Iab6f0ca13da3a00b780f8c88ffd4914fe0a3d7ea
changes/09/26809/1
Rene Krenn 7 years ago
parent af2ac4bdc3
commit 932bb76b2e

@ -16,6 +16,7 @@ use NGCP::BulkProcessor::Projects::Export::Ama::Settings qw(
$export_cdr_conditions
$export_cdr_limit
$export_cdr_stream
$export_cdr_rollover_fsn
);
use NGCP::BulkProcessor::Logging qw (
@ -491,13 +492,45 @@ sub _export_cdrs_create_context {
_error($context,"cannot get last file sequence number");
$result = 0;
} else {
my $reset = 0;
if ($fsn < 0) {
$fsn = 0;
$reset = 1;
} elsif ($fsn >= $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::max_fsn) {
_warn($context,"file sequence number $fsn exceeding limit (" . $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::max_fsn . ")");
$result = 0;
if ($export_cdr_rollover_fsn) {
$fsn = 0;
$reset = 1;
} else {
_warn($context,"file sequence number $fsn exceeding limit (" . $NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::max_fsn . ")");
$result = 0;
}
} else {
_info($context,"last file sequence number is $fsn");
}
if ($reset) {
eval {
NGCP::BulkProcessor::Dao::Trunk::accounting::mark::cleanup_system_marks(undef,
$export_cdr_stream,
);
NGCP::BulkProcessor::Dao::Trunk::accounting::mark::set_system_mark(undef,
$export_cdr_stream,
'0' #$NGCP::BulkProcessor::Projects::Export::Ama::Format::Fields::FileSequenceNumber::min_fsn
);
$fsn = NGCP::BulkProcessor::Dao::Trunk::accounting::mark::get_system_mark(undef,
$export_cdr_stream
); #load mark...
};
if ($@) {
if ($skip_errors) {
_warn($context,"problem with file sequence number reset: " . $@);
} else {
_error($context,"problem with file sequence number reset: " . $@);
}
$result = 0;
} else {
_info($context,"file sequence number reset to $fsn")
}
}
_info($context,"last file sequence number is $fsn");
lock $file_sequence_number;
$file_sequence_number = $fsn;
}

@ -27,7 +27,7 @@ use NGCP::BulkProcessor::LoadConfig qw(
split_tuple
parse_regexp
);
use NGCP::BulkProcessor::Utils qw(prompt timestampdigits);
use NGCP::BulkProcessor::Utils qw(prompt timestampdigits stringtobool);
#format_number check_ipnet
require Exporter;
@ -52,6 +52,7 @@ our @EXPORT_OK = qw(
$export_cdr_conditions
$export_cdr_limit
$export_cdr_stream
$export_cdr_rollover_fsn
$domestic_destination_pattern
$international_destination_pattern
@ -81,6 +82,7 @@ our $export_cdr_joins = [];
our $export_cdr_conditions = [];
our $export_cdr_limit = undef;
our $export_cdr_stream = undef;
our $export_cdr_rollover_fsn = 0;
our $domestic_destination_pattern = undef;
our $international_destination_pattern = undef;
@ -123,6 +125,7 @@ sub update_settings {
$export_cdr_limit = $data->{export_cdr_limit} if exists $data->{export_cdr_limit};
$export_cdr_stream = $data->{export_cdr_stream} if exists $data->{export_cdr_stream};
$export_cdr_rollover_fsn = stringtobool($data->{export_cdr_rollover_fsn}) if exists $data->{export_cdr_rollover_fsn};
#if ((confval("MAINTENANCE") // 'no') eq 'yes') {
# exit(0);

@ -7,5 +7,6 @@ export_cdr_joins = { 'billing.voip_subscribers source_voip_subscribers' => { 'so
export_cdr_conditions = { 'accounting.cdr.export_status' => { '=' => '"unexported"' } }, { 'accounting.cdr.call_status' => { '=' => '"ok"' } }, { 'accounting.cdr.rating_status' => { '=' => '"ok"' } }
export_cdr_limit = 300000
export_cdr_stream = ama_simple
export_cdr_rollover_fsn = 1
ama_filename_format = %1$s%2$03d.debug.ama

@ -11,5 +11,6 @@ export_cdr_stream = ama_simple
#default
#export_cdr_limit = 3500
#300000
export_cdr_rollover_fsn = 1
ama_filename_format = %1$s%2$03d.debug.ama

Loading…
Cancel
Save