Changeset 57
- Timestamp:
- 10/09/06 20:36:52 (7 years ago)
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
shepherd
r52 r57 3 3 # "Shepherd" 4 4 5 my $version = '0.2. 9';5 my $version = '0.2.10'; 6 6 7 7 # A wrapper for various Aussie TV guide data grabbers … … 24 24 # 0.2.8 : Integrated reconciler 25 25 # 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 26 28 27 29 BEGIN { *CORE::GLOBAL::die = \&my_die; } … … 127 129 my $starttime, my $endtime; 128 130 my $input_postprocess_file = "$CWD/reconciled_output_pre_postprocessors.xml"; 129 my $ insufficient_grabber_data= 0;131 my $grabber_data_percent = 0; 130 132 131 133 # OBSOLETE: will be removed … … 245 247 { 246 248 my $used_grabbers = 0; 247 my $ need_more_data = 1;249 my $found_data_percent = 0; 248 250 249 251 print "\nGrabber stage:\n"; … … 289 291 290 292 # 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); 294 296 } 295 297 … … 301 303 } 302 304 303 if ($ need_more_data)305 if ($found_data_percent < $channel_ok_threshold_percent) 304 306 { 305 307 print "SHEPHERD: Ran through ALL grabbers but still missing data!!! :(\n"; 306 $ insufficient_grabber_data = 1;308 $grabber_data_percent = $found_data_percent; 307 309 return; 308 310 } … … 594 596 595 597 # 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 want598 # returns percent of data found 597 599 sub analyze_plugin_data 598 600 { 599 601 my ($threshold,$analysistype) = @_; 600 my $retval = 0; # until proven otherwise601 602 my $total_data_percent = 0, my $total_channels = 0; 602 603 my $statusstring = ""; … … 617 618 } else { 618 619 $statusstring .= sprintf "%s: %0.1f%% [hungry], ",$ch,$data_in_channel_percent; 619 $retval = 1;620 620 } 621 621 $total_data_percent += $data_in_channel_percent; 622 622 } else { 623 623 $statusstring .= sprintf "%s: 0%% [starving], ",$ch; 624 $retval = 1;625 624 } 626 625 } … … 636 635 uc($analysistype), $statusstring, $total_data_percent, 637 636 ($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; 640 639 } 641 640 … … 1043 1042 # first time around: feed in reconciled data ($input_postprocess_file) 1044 1043 1045 my $need_more_data;1046 1047 1044 printf "\nPostprocessing stage:\n"; 1048 1045 1049 1046 foreach my $postprocessor (sort { $components->{$a} <=> $components->{$b} } query_postprocessors()) { 1050 1047 next if ($components->{$postprocessor}->{disabled}); 1048 next if (!$components->{$postprocessor}->{ready}); 1051 1049 1052 1050 $components->{$postprocessor}->{lastdata} = time; … … 1087 1085 # process and analyze it! 1088 1086 &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"); 1090 1088 1091 1089 $components->{$postprocessor}->{laststatus} = $plugin_data->{$postprocessor}->{laststatus}; 1092 1090 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 } 1099 1112 } 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}); 1110 1117 } 1111 1118 } else { -
status
r55 r57 1 shepherd:0.2. 9:shepherd1 shepherd:0.2.10:shepherd 2 2 rex:3.2.1-r2:grabber 3 3 oztivo:0.4-r2:grabber
