From: Chris W. <la...@us...> - 2004-10-05 03:08:41
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20853 Modified Files: ResultsIterator.pm ResultsManage.pm Log Message: OIN-63: ensure that CommonSearch, RsultsManage, ResultsIterator all play nice together (passing the right parameters, etc.); update logging Index: ResultsIterator.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/ResultsIterator.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ResultsIterator.pm 5 Jul 2004 12:59:37 -0000 1.5 --- ResultsIterator.pm 5 Oct 2004 03:08:24 -0000 1.6 *************** *** 41,45 **** "[$object_class: $object_id]" ); ! return ITER_IS_DONE unless ( $object_class and $object_id ); my $object = eval { --- 41,49 ---- "[$object_class: $object_id]" ); ! unless ( $object_class and $object_id ) { ! $log->is_info && ! $log->info( "No class or ID found in iterator, all done." ); ! return ITER_IS_DONE; ! } my $object = eval { *************** *** 55,60 **** return $self->fetch_object; } ! $log->is_debug && ! $log->debug( "Caught non-security exception: $@" ); die $@; } --- 59,63 ---- return $self->fetch_object; } ! $log->is_debug && $log->debug( "Caught non-security exception: $@" ); die $@; } *************** *** 67,70 **** --- 70,75 ---- } + $log->is_debug && $log->debug( "Fetched object ok, checking min/max" ); + # Using min/max and haven't reached it yet *************** *** 73,76 **** --- 78,83 ---- $self->{_SEARCH_COUNT}++; $self->{_SEARCH_RAW_COUNT}++; + $log->is_debug && + $log->debug( "Haven't reached min threshold" ); return $self->fetch_object; } *************** *** 78,81 **** --- 85,89 ---- if ( $self->{_SEARCH_MAX} and ( $self->{_SEARCH_COUNT} > $self->{_SEARCH_MAX} ) ) { + $log->is_debug && $log->debug( "Over max threshold, we're all done" ); return ITER_IS_DONE; } *************** *** 84,87 **** --- 92,98 ---- # actually return the object. Finish up. + $log->is_debug && + $log->debug( "Min/max passed ok; assign extra data then finish" ); + my %extra_data = (); if ( $self->{_SEARCH_EXTRA_NAME} ) { *************** *** 90,93 **** --- 101,106 ---- foreach my $name ( @{ $self->{_SEARCH_EXTRA_NAME} } ) { my $extra_value = shift @extra_data; + $log->is_debug && $log->debug( "Adding extra data '$name' => ", + "'$extra_value'" ); $object->{ "tmp_$name" } = $extra_value; $extra_data{ $name } = $extra_value; Index: ResultsManage.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/ResultsManage.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ResultsManage.pm 5 Jul 2004 13:00:22 -0000 1.11 --- ResultsManage.pm 5 Oct 2004 03:08:25 -0000 1.12 *************** *** 322,332 **** "ID '", $self->search_id, "'" ); ! my $results = $self->_retrieve_raw_results; $log->is_info && ! $log->info( "Found: ", scalar @{ $results }, " results" ); return ( $return_type eq 'iterator' ) ! ? $self->_retrieve_iterator( $results, $p ) ! : $results; } --- 322,333 ---- "ID '", $self->search_id, "'" ); ! my $raw_results = $self->_retrieve_raw_results; $log->is_info && ! $log->info( "Found: ", scalar @{ $raw_results }, " results; asked ", ! "to return '$return_type'" ); return ( $return_type eq 'iterator' ) ! ? $self->_retrieve_iterator( $raw_results, $p ) ! : $raw_results; } *************** *** 391,403 **** sub _retrieve_iterator { ! my ( $self, $results, $p ) = @_; ! $log ||= get_logger( LOG_APP ); ! ! my $iterator = OpenInteract2::ResultsIterator->new({ ! results => $results, extra_name => $self->extra_name, skip_security => $p->{skip_security} }); - return $iterator; } --- 392,401 ---- sub _retrieve_iterator { ! my ( $self, $raw_results, $p ) = @_; ! return OpenInteract2::ResultsIterator->new({ ! results => $raw_results, extra_name => $self->extra_name, skip_security => $p->{skip_security} }); } *************** *** 489,499 **** } unless ( -w $results_dir ) { ! $log->error( "Search results dir '", $results_dir, "' is not writeable" ); oi_error "Configuration option for writing search results ", "'$results_dir' exists but is not writeable"; } my $iterations = 0; while ( 1 ) { ! my $search_id = SPOPS::Utility->generate_random_code( FILENAME_WIDTH ); my $filename = $self->_build_results_filename( $search_id ); my $lockfile = $self->_build_lock_filename( $search_id ); --- 487,500 ---- } unless ( -w $results_dir ) { ! $log->error( "Search results directory '$results_dir' ", ! "is not writeable" ); oi_error "Configuration option for writing search results ", "'$results_dir' exists but is not writeable"; } my $iterations = 0; + my ( $search_id ); + FIND_ID: while ( 1 ) { ! $search_id = SPOPS::Utility->generate_random_code( FILENAME_WIDTH ); my $filename = $self->_build_results_filename( $search_id ); my $lockfile = $self->_build_lock_filename( $search_id ); *************** *** 506,514 **** $iterations++; next if ( -f $filename || -f $lockfile ); ! $log->is_debug && ! $log->debug( "Found non-existent search info for ", ! "'$search_id' in '$results_dir'" ); ! return $search_id; } } --- 507,515 ---- $iterations++; next if ( -f $filename || -f $lockfile ); ! $log->is_debug && $log->debug( "Found unused search filename ", ! "in '$results_dir': '$search_id'" ); ! last FIND_ID; } + return $search_id; } |