Changeset 57

Show
Ignore:
Timestamp:
10/09/06 20:36:52 (7 years ago)
Author:
lincoln
Message:

Bugfix: don't call postprocessors that aren't ready, rework accept-data-or-not postprocessor logic

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • shepherd

    r52 r57  
    33# "Shepherd" 
    44 
    5 my $version = '0.2.9'; 
     5my $version = '0.2.10'; 
    66 
    77# A wrapper for various Aussie TV guide data grabbers 
     
    2424# 0.2.8   : Integrated reconciler 
    2525# 0.2.9   : Grabber config support 
     26# 0.2.10  : Bugfix: don't call postprocessors that aren't ready, 
     27#           rework accept-data-or-not postprocessor logic 
    2628 
    2729BEGIN { *CORE::GLOBAL::die = \&my_die; } 
     
    127129my $starttime, my $endtime; 
    128130my $input_postprocess_file = "$CWD/reconciled_output_pre_postprocessors.xml"; 
    129 my $insufficient_grabber_data = 0; 
     131my $grabber_data_percent = 0; 
    130132 
    131133# OBSOLETE: will be removed 
     
    245247{ 
    246248    my $used_grabbers = 0; 
    247     my $need_more_data = 1; 
     249    my $found_data_percent = 0; 
    248250 
    249251    print "\nGrabber stage:\n"; 
     
    289291 
    290292        # check to see if we have all the data we want 
    291         $need_more_data = &analyze_plugin_data($channel_ok_threshold_percent, "AGGREGATE GRABBER"); 
    292  
    293         last if (!$need_more_data); 
     293        $found_data_percent = &analyze_plugin_data($channel_ok_threshold_percent, "AGGREGATE GRABBER"); 
     294 
     295        last if ($found_data_percent >= $channel_ok_threshold_percent); 
    294296    } 
    295297 
     
    301303    } 
    302304 
    303     if ($need_more_data) 
     305    if ($found_data_percent < $channel_ok_threshold_percent) 
    304306    { 
    305307        print "SHEPHERD: Ran through ALL grabbers but still missing data!!! :(\n"; 
    306         $insufficient_grabber_data = 1; 
     308        $grabber_data_percent = $found_data_percent; 
    307309        return; 
    308310    } 
     
    594596 
    595597# analyze grabber data - do we have all the data we want? 
    596 # returns 1 if we need more data, 0 if we have all we want 
     598# returns percent of data found 
    597599sub analyze_plugin_data 
    598600{ 
    599601    my ($threshold,$analysistype) = @_; 
    600     my $retval = 0; # until proven otherwise 
    601602    my $total_data_percent = 0, my $total_channels = 0; 
    602603    my $statusstring = ""; 
     
    617618            } else { 
    618619                $statusstring .= sprintf "%s: %0.1f%% [hungry], ",$ch,$data_in_channel_percent; 
    619                 $retval = 1; 
    620620            } 
    621621            $total_data_percent += $data_in_channel_percent; 
    622622        } else { 
    623623            $statusstring .= sprintf "%s: 0%% [starving], ",$ch; 
    624             $retval = 1; 
    625624        } 
    626625    } 
     
    636635        uc($analysistype), $statusstring, $total_data_percent, 
    637636        ($total_data_percent >= $channel_ok_threshold_percent ? ">" : "<"), $channel_ok_threshold_percent, 
    638         ($retval ? "WANT MORE DATA" : "COMPLETE"); 
    639     return $retval; 
     637        (($total_data_percent < $channel_ok_threshold_percent) ? "WANT MORE DATA" : "COMPLETE"); 
     638    return $total_data_percent; 
    640639} 
    641640 
     
    10431042    # first time around: feed in reconciled data ($input_postprocess_file) 
    10441043 
    1045     my $need_more_data; 
    1046  
    10471044    printf "\nPostprocessing stage:\n"; 
    10481045 
    10491046    foreach my $postprocessor (sort { $components->{$a} <=> $components->{$b} } query_postprocessors()) { 
    10501047        next if ($components->{$postprocessor}->{disabled}); 
     1048        next if (!$components->{$postprocessor}->{ready}); 
    10511049 
    10521050        $components->{$postprocessor}->{lastdata} = time; 
     
    10871085        # process and analyze it! 
    10881086        &soak_up_data($postprocessor, $output, "postprocessor"); 
    1089         $need_more_data = &analyze_plugin_data($postprocessor_ok_threshold_percent, "POSTPROCESSOR"); 
     1087        my $found_data_percent = &analyze_plugin_data($postprocessor_ok_threshold_percent, "POSTPROCESSOR"); 
    10901088 
    10911089        $components->{$postprocessor}->{laststatus} = $plugin_data->{$postprocessor}->{laststatus}; 
    10921090 
    1093         if (($need_more_data) && (!$insufficient_grabber_data)) { 
    1094             # urgh.  this postprocessor did a bad bad thing ... 
    1095             printf "SHEPHERD: XML data from postprocessor %s rejected, using XML from previous stage\n",$postprocessor; 
    1096  
    1097             if (defined $components->{$postprocessor}->{conescutive_failures}) { 
    1098                 $components->{$postprocessor}->{conescutive_failures}++; 
     1091        if ($found_data_percent < $postprocessor_ok_threshold_percent) { 
     1092            # how bad is the data?  is it significantly different to that of what the grabber run finished with? 
     1093            # allow at most 5% of the data to go away 
     1094            if ($grabber_data_percent > ($found_data_percent + 5)) { 
     1095                # urgh.  this postprocessor did a bad bad thing ... 
     1096                printf "SHEPHERD: XML data from postprocessor %s rejected, using XML from previous stage\n",$postprocessor; 
     1097 
     1098                if (defined $components->{$postprocessor}->{conescutive_failures}) { 
     1099                    $components->{$postprocessor}->{conescutive_failures}++; 
     1100                } else { 
     1101                    $components->{$postprocessor}->{conescutive_failures} = 1; 
     1102                } 
     1103                printf "SHEPHERD: Postprocessor \"%s\" has now failed %d times in a row.  %d more and it will be automatically disabled.\n", 
     1104                    $postprocessor, 
     1105                    $components->{$postprocessor}->{conescutive_failures}, 
     1106                    ($postprocessor_disable_failure_threshold - $components->{$postprocessor}->{conescutive_failures}); 
     1107 
     1108                if ($components->{$postprocessor}->{conescutive_failures} >= $postprocessor_disable_failure_threshold) { 
     1109                    printf "SHEPHERD: Disabling Postprocessor \"%s\".\n",$postprocessor; 
     1110                    $components->{$postprocessor}->{disabled} = 1; 
     1111                } 
    10991112            } else { 
    1100                 $components->{$postprocessor}->{conescutive_failures} = 1; 
    1101             } 
    1102             printf "SHEPHERD: Postprocessor \"%s\" has now failed %d times in a row.  %d more and it will be automatically disabled.\n", 
    1103                 $postprocessor, 
    1104                 $components->{$postprocessor}->{conescutive_failures}, 
    1105                 ($postprocessor_disable_failure_threshold - $components->{$postprocessor}->{conescutive_failures}); 
    1106  
    1107             if ($components->{$postprocessor}->{conescutive_failures} >= $postprocessor_disable_failure_threshold) { 
    1108                 printf "SHEPHERD: Disabling Postprocessor \"%s\".\n",$postprocessor; 
    1109                 $components->{$postprocessor}->{disabled} = 1; 
     1113                # accept what this postprocessor did to our output ... 
     1114                printf "SHEPHERD: accepting output from postprocessor %s, feeding it into next stage\n",$postprocessor; 
     1115                $input_postprocess_file = $output; 
     1116                delete $components->{$postprocessor}->{conescutive_failures} if (defined $components->{$postprocessor}->{conescutive_failures}); 
    11101117            } 
    11111118        } else { 
  • status

    r55 r57  
    1 shepherd:0.2.9:shepherd 
     1shepherd:0.2.10:shepherd 
    22rex:3.2.1-r2:grabber 
    33oztivo:0.4-r2:grabber