Author: arkurth Date: Thu Jun 4 15:06:56 2009 New Revision: 781768 URL: http://svn.apache.org/viewvc?rev=781768&view=rev Log: VCL-15 Added is_blockrequest() sub to DataStructure.pm. Added check to State.pm::DESTROY() to determine if a blockrequest is being processed or not. It now attempts to delete the computerloadlog entries only if not a blockrequest.
Modified: incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm Modified: incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=781768&r1=781767&r2=781768&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm Thu Jun 4 15:06:56 2009 @@ -1755,6 +1755,36 @@ #///////////////////////////////////////////////////////////////////////////// +=head2 is_blockrequest + + Parameters : None. + Returns : If DataStructure contains blockrequest data: true + If DataStructure does not contain blockrequest data: false + Description : This subroutine determines whether or not the DataStructure + contains data for a blockrequest. + +=cut + +sub is_blockrequest { + my $self = shift; + + # Check if subroutine was called as an object method + unless (ref($self) && $self->isa('VCL::DataStructure')) { + notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called as a VCL::DataStructure module object method"); + return; + } + + # Check if reservation_id has been set, return 1 or 0 based on that + if ($self->blockrequest_id) { + return 1; + } + else { + return 0; + } +} + +#///////////////////////////////////////////////////////////////////////////// + 1; __END__ Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm?rev=781768&r1=781767&r2=781768&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm Thu Jun 4 15:06:56 2009 @@ -890,16 +890,23 @@ sub DESTROY { my $self = shift; - my $reservation_id = $self->data->get_reservation_id(); notify($ERRORS{'DEBUG'}, 0, "destructor called, ref(\$self)=" . ref($self)); - # Delete all computerloadlog rows with loadstatename = 'begin' for thie reservation - if (delete_computerloadlog_reservation($reservation_id, 'begin')) { - notify($ERRORS{'DEBUG'}, 0, "removed computerloadlog rows with loadstate=begin for reservation"); - } - else { - notify($ERRORS{'WARNING'}, 0, "failed to remove computerloadlog rows with loadstate=begin for reservation"); + # If not a blockrequest, delete computerloadlog entry + if ($self && $self->data && !$self->data->is_blockrequest()) { + my $reservation_id = $self->data->get_reservation_id(); + + # Delete all computerloadlog rows with loadstatename = 'begin' for thie reservation + if ($reservation_id && delete_computerloadlog_reservation($reservation_id, 'begin')) { + notify($ERRORS{'DEBUG'}, 0, "removed computerloadlog rows with loadstate=begin for reservation"); + } + elsif (!$reservation_id) { + notify($ERRORS{'WARNING'}, 0, "failed to retrieve the reservation id, computerloadlog rows not removed"); + } + else { + notify($ERRORS{'WARNING'}, 0, "failed to remove computerloadlog rows with loadstate=begin for reservation"); + } } # Print the number of database handles this process created for testing/development