[Orca-checkins] r346 - trunk/orca/lib/Orca
Blair Zajac
blair at orcaware.com
Sun Jun 13 15:47:12 PDT 2004
Author: blair
Date: Sun Jun 13 15:45:12 2004
New Revision: 346
Modified:
trunk/orca/lib/Orca/ImageFile.pm
trunk/orca/lib/Orca/SourceFile.pm
Log:
Finally fix the long outstanding bug that generates multiple plots
(one plot for each unique combination of input data columns) for one
plot appearing in the configuration file. This most commonly appears
in the disk space used plots. Patch based off of work from John
Garner <jcgarner at douglas.co.us>.
* lib/Orca/ImageFile.pm
(add_additional_plot):
Merge in any new data sources in a plot into an existing image.
* lib/Orca/SourceFile.pm
(add_plots):
For plots that have only one data line and a regular expression
match in it, do not generate a name for it that contains a list
of all the column names that matched, as this generates a
separate image for each combination of matching column names.
Instead use a name that is generated by the data line in the
configuration file, so it catches all column names that match.
If an existing image is found for the case of a single data line
with a regular expression match and an existing image is found,
then update the original image with the new matching column.
Modified: trunk/orca/lib/Orca/ImageFile.pm
==============================================================================
--- trunk/orca/lib/Orca/ImageFile.pm (original)
+++ trunk/orca/lib/Orca/ImageFile.pm Sun Jun 13 15:45:12 2004
@@ -23,7 +23,8 @@
$INCORRECT_NUMBER_OF_ARGS);
use Orca::Config qw(%config_global
@config_groups
- @config_plots);
+ @config_plots
+ data_index_to_color);
use Orca::Utils qw(name_to_fsname recursive_mkdir);
use vars qw($VERSION);
@@ -215,6 +216,60 @@
$self;
}
+# Merge in any new data sources in a plot into an existing image.
+sub add_additional_plot {
+ unless (@_ == 2) {
+ confess "$0: Orca::ImageFile::add_additional_plot ",
+ $INCORRECT_NUMBER_OF_ARGS;
+ }
+
+ my ($self, $new_plot_ref) = @_;
+
+ my %existing_legends;
+ my $existing_plot_ref = $self->[I_PLOT_REF];
+
+ foreach my $legend (@{$existing_plot_ref->{legend}}) {
+ $existing_legends{$legend} = 1;
+ }
+
+ my $i = @{$existing_plot_ref->{legend}};
+ my $number_legends_in_new_plot = @{$new_plot_ref->{legend}};
+ my $number_plots_added = 0;
+ for (my $j=0; $j<$number_legends_in_new_plot; ++$j) {
+ next if $existing_legends{$new_plot_ref->{legend}[$j]};
+ ++$number_plots_added;
+
+ # For those attributes of the new plot that are array references
+ # and need to be indexed for the particular data being plotted,
+ # copy them over. Skip the 'creates' attribute which is not used
+ # for plotting and skip the color attribute as the color is
+ # treated
+ # specially.
+ for my $attribute (keys %$new_plot_ref) {
+ next if $attribute eq 'color';
+ next if $attribute eq 'creates';
+ next unless UNIVERSAL::isa($new_plot_ref->{$attribute}, 'ARRAY');
+ $existing_plot_ref->{$attribute}[$i] = $new_plot_ref->{$attribute}[$j];
+ }
+
+ # If the color was not already specified for this particular plot
+ # and for this particular data index, then there were no more
+ # colors in the plot definition, so get the proper color from the
+ # configuration file. Do not copy the color from the new plot,
+ # since the new plot in the merged image will have a different
+ # index into the color list.
+ unless (defined $existing_plot_ref->{color}[$i]) {
+ $existing_plot_ref->{color}[$i] = data_index_to_color($i);
+ }
+
+ ++$i;
+ }
+
+ if ($number_plots_added) {
+ $self->_update_graph_options;
+ }
+}
+
sub add_rrds {
my $self = shift;
Modified: trunk/orca/lib/Orca/SourceFile.pm
==============================================================================
--- trunk/orca/lib/Orca/SourceFile.pm (original)
+++ trunk/orca/lib/Orca/SourceFile.pm Sun Jun 13 15:45:12 2004
@@ -346,7 +346,8 @@
$i = $oldest_regexp_index;
}
- my $plot = $config_plots[$i];
+ my $original_plot = $config_plots[$i];
+ my $plot = $original_plot;
# Skip this plot if the source group indexes does not match.
# Increment the index of the next plot to handle.
@@ -383,8 +384,11 @@
}
# 1) Regular expression match in the first data with no additional datas.
+ my $plot_has_only_one_data_with_regexp = 0;
if ($number_datas == 1 and $regexp_element_index != -1) {
+ $plot_has_only_one_data_with_regexp = 1;
+
# If we've gone up to the last column to match, then go on.
if ($regexp_pos[$i] >= @column_description) {
if ($oldest_regexp_index == $i) {
@@ -743,10 +747,43 @@
}
}
- # Generate a new plot for these data.
- my $image;
- my $all_names_with_subgroup = join(',', @names_with_subgroup);
- if (defined ($image = $image_files_ref->{hash}{$all_names_with_subgroup})){
+ # Generate a name for this image that is used to look up already
+ # created Orca::Image objects. Normally, the name will contain
+ # all the column names that matched the data lines in the
+ # configuration file. However, if a plot has only one data line
+ # and that data line has a regular expression match in it, then
+ # this method will generate a different image for all input data
+ # files that contain different combinations of matching column
+ # names. For this case, do not store the column names that match,
+ # use a stringified form of the original data line with a
+ # 'volatile' tag in it to help ensure that there are no name
+ # collisions. Also, shorten the two arrays that contain the
+ # matching column names to a contain single element with the name
+ # of the data line that generated the image with no mention of the
+ # names of the matched columns.
+ my $all_names_with_subgroup;
+ if ($plot_has_only_one_data_with_regexp) {
+ $all_names_with_subgroup = join('_',
+ $group_name,
+ $subgroup_name,
+ lc($plot->{data_type}[0]),
+ 'volatile',
+ @{$original_plot->{data}[0]});
+ @my_short_rrds = ($all_names_with_subgroup);
+ @names_without_subgroup = (join('_',
+ $group_name,
+ lc($plot->{data_type}[0]),
+ 'volatile',
+ @{$original_plot->{data}[0]}));
+ } else {
+ $all_names_with_subgroup = join(',', sort @names_with_subgroup);
+ }
+
+ my $image = $image_files_ref->{hash}{$all_names_with_subgroup};
+ if (defined $image) {
+ if ($plot_has_only_one_data_with_regexp) {
+ $image->add_additional_plot($plot);
+ }
$image->add_rrds(@my_rrds);
} else {
$image = Orca::ImageFile->new($group_index,
More information about the Orca-checkins
mailing list