@ -69,6 +69,7 @@ our @EXPORT_OK = qw(
) ;
my $ file_sequence_number : shared = 0 ;
my $ rowcount : shared = 0 ;
sub reset_export_status {
@ -152,8 +153,17 @@ sub export_cdrs {
}
}
foreach my $ record ( @$ records ) {
return 0 if ( defined $ export_cdr_limit and $ context - > { rownum } >= $ export_cdr_limit ) ;
return 0 if $ context - > { file_sequence_number } > $ NGCP:: BulkProcessor:: Projects:: Export:: Ama:: Format:: Fields:: FileSequenceNumber:: max_fsn ;
if ( defined $ export_cdr_limit ) {
lock $ rowcount ;
if ( $ rowcount >= $ export_cdr_limit ) {
_info ( $ context , "exceeding export limit $export_cdr_limit" ) ;
return 0 ;
}
}
if ( $ context - > { file_sequence_number } > $ NGCP:: BulkProcessor:: Projects:: Export:: Ama:: Format:: Fields:: FileSequenceNumber:: max_fsn ) {
_info ( $ context , "exceeding file sequence number " . $ NGCP:: BulkProcessor:: Projects:: Export:: Ama:: Format:: Fields:: FileSequenceNumber:: max_fsn ) ;
return 0 ;
}
my ( $ id , $ call_id ) = @$ record ;
next unless _export_cdrs_init_context ( $ context , $ id , $ call_id ) ;
eval {
@ -184,7 +194,7 @@ sub export_cdrs {
$ context - > { ama_files } = [] ;
$ context - > { has_next } = 1 ;
$ context - > { rownum } = 0 ;
#$context->{rownum} = 0 ;
_increment_file_sequence_number ( $ context ) ;
} ,
@ -224,7 +234,7 @@ sub export_cdrs {
joins = > $ export_cdr_joins ,
conditions = > $ export_cdr_conditions ,
#sort => [{ column => 'id', numeric => 1, dir => 1 }],
limit = > $ export_cdr_limit ,
#limit => $export_cdr_limit ,
) ;
eval {
@ -263,7 +273,8 @@ sub _export_cdrs_init_context {
if ( ( scalar @ { $ context - > { cdrs } } ) == $ cdrs_in_block ) {
foreach my $ cdr ( @ { $ context - > { cdrs } } ) {
$ context - > { file_cdr_id_map } - > { $ cdr - > { id } } = $ cdr ; #->{start_time};
$ context - > { rownum } += 1 ;
lock $ rowcount ;
$ rowcount += 1 ;
}
$ result = 1 ;
}
@ -289,7 +300,8 @@ sub _commit_export_status {
) = @ params { qw /
context
/ } ;
_info ( $ context , "file " . $ context - > { file } - > get_filename ( ) . " (" . kbytes2gigs ( int ( ( - s $ context - > { file } - > get_filename ( ) ) / 1024 ) ) . ") written (" . $ context - > { file } - > get_record_count ( ) . " records in " . $ context - > { file } - > get_block_count ( ) . " blocks)" ) ;
my $ result = 1 ;
_info ( $ context , "file " . $ context - > { file } - > get_filename ( 1 ) . " (" . kbytes2gigs ( int ( $ context - > { file } - > get_filesize ( ) / 1024 ) ) . ") - " . $ context - > { file } - > get_record_count ( ) . " records in " . $ context - > { file } - > get_block_count ( ) . " blocks" ) ;
eval {
ping_dbs ( ) ;
$ context - > { db } - > db_begin ( ) ;
@ -309,7 +321,6 @@ sub _commit_export_status {
) ; #set mark...
_info ( $ context , "file sequence number $context->{file_sequence_number} saved" ) ;
$ context - > { db } - > db_commit ( ) ;
} ;
$ context - > { file_cdr_id_map } = { } ;
my $ err = $@ ;
@ -317,14 +328,16 @@ sub _commit_export_status {
eval {
$ context - > { db } - > db_rollback ( 1 ) ;
} ;
eval {
unlink $ context - > { file } - > get_filename ( ) ;
} ;
#eval {
# unlink $context->{file}->get_filename();
#} ;
die ( $ err ) ;
$ result = 0 ;
} else {
push ( @ { $ context - > { ama_files } } , $ context - > { file } - > get_filename ( ) ) ;
_increment_file_sequence_number ( $ context ) if $ context - > { has_next } ;
}
return $ result ;
}
@ -382,6 +395,7 @@ sub _get_record {
padding = > 0 ,
recording_office_id = > '438716' , #008708
call_type = > '970' ,
#call code 970c
#timing ind 000
#seervice observed 0c