You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by fa...@apache.org on 2014/12/02 19:32:30 UTC

svn commit: r1642984 - in /vcl/trunk/managementnode/lib/VCL: Module/State.pm reclaim.pm reserved.pm utils.pm

Author: fapeeler
Date: Tue Dec  2 18:32:30 2014
New Revision: 1642984

URL: http://svn.apache.org/r1642984
Log:
VCL-568



Modified:
    vcl/trunk/managementnode/lib/VCL/Module/State.pm
    vcl/trunk/managementnode/lib/VCL/reclaim.pm
    vcl/trunk/managementnode/lib/VCL/reserved.pm
    vcl/trunk/managementnode/lib/VCL/utils.pm

Modified: vcl/trunk/managementnode/lib/VCL/Module/State.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/State.pm?rev=1642984&r1=1642983&r2=1642984&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/State.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/State.pm Tue Dec  2 18:32:30 2014
@@ -703,6 +703,11 @@ sub state_exit {
 				}
 			}
 		}
+
+		if($request_state_name_new eq 'complete') {
+			
+			delete_computerloadlog_reservation(\@reservation_ids,0,1);
+		}
 		
 		# Delete all computerloadlog rows with loadstatename = 'begin' for all reservations in this request
 		delete_computerloadlog_reservation(\@reservation_ids, '!beginacknowledgetimeout');

Modified: vcl/trunk/managementnode/lib/VCL/reclaim.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reclaim.pm?rev=1642984&r1=1642983&r2=1642984&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reclaim.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reclaim.pm Tue Dec  2 18:32:30 2014
@@ -102,7 +102,7 @@ sub process {
 	my @reservation_ids							 = $self->data->get_reservation_ids();
 
 	# Delete all computerloadlog rows with loadstatename = 'beginacknowledgetimeout' for all reservations in this request
-	delete_computerloadlog_reservation(\@reservation_ids, 'beginacknowledgetimeout');
+	delete_computerloadlog_reservation(\@reservation_ids,0,1);
 
 	# Remove related fixedIPsr variable, if it exists
 	if ($server_request_id) {

Modified: vcl/trunk/managementnode/lib/VCL/reserved.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reserved.pm?rev=1642984&r1=1642983&r2=1642984&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reserved.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reserved.pm Tue Dec  2 18:32:30 2014
@@ -111,6 +111,7 @@ sub process {
 	# Update the computer state to reserved
 	# This causes pending to change to the Connect button on the Current Reservations page
 	update_computer_state($computer_id, 'reserved');
+	insertloadlog($reservation_id, $computer_id, "reserved", "$computer_short_name successfully reserved");
 	
 	# Wait for the user to acknowledge the request by clicking Connect button or from API
 	if (!$self->code_loop_timeout(sub{$self->user_acknowledged()}, [], 'waiting for user acknowledgement', $acknowledge_timeout_seconds, 1, 10)) {
@@ -142,7 +143,7 @@ sub process {
 	# Add a 'reserved' computerloadlog entry
 	# Do this last - important for cluster reservation timing
 	# Parent's reserved process will loop until this exists for all child reservations
-	insertloadlog($reservation_id, $computer_id, "reserved", "$computer_short_name successfully reserved");
+	insertloadlog($reservation_id, $computer_id, "postreserve", "$computer_short_name post reserve successfully");
 	
 	# For cluster reservations, the parent must wait until all child reserved processes have exited
 	# Otherwise, the state will change to inuse while the child processes are still finishing up the reserved state
@@ -190,7 +191,7 @@ sub wait_for_child_reservations {
 	my @failed;
 	for my $reservation_id (keys %$request_loadstate_names) {
 		my @loadstate_names = @{$request_loadstate_names->{$reservation_id}};
-		if (grep { $_ eq 'reserved' } @loadstate_names) {
+		if (grep { $_ eq 'postreserve' } @loadstate_names) {
 			push @reserved_exists, $reservation_id;
 		}
 		else {
@@ -209,14 +210,14 @@ sub wait_for_child_reservations {
 	}
 	
 	if (@reserved_does_not_exist) {
-		notify($ERRORS{'DEBUG'}, 0, "computerloadlog 'reserved' entry does NOT exist for all reservations:\n" .
+		notify($ERRORS{'DEBUG'}, 0, "computerloadlog 'postreserve' entry does NOT exist for all reservations:\n" .
 			"exists for reservation IDs: " . join(', ', @reserved_exists) . "\n" .
 			"does not exist for reservation IDs: " . join(', ', @reserved_does_not_exist)
 		);
 		return 0;
 	}
 	else {
-		notify($ERRORS{'DEBUG'}, 0, "computerloadlog 'reserved' entry exists for all reservations");
+		notify($ERRORS{'DEBUG'}, 0, "computerloadlog 'postreserve' entry exists for all reservations");
 	}
 	
 	notify($ERRORS{'DEBUG'}, 0, "all child reservation reserved processes have completed");

Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1642984&r1=1642983&r2=1642984&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Tue Dec  2 18:32:30 2014
@@ -5529,23 +5529,27 @@ EOF
 
 =head2 delete_computerloadlog_reservation
 
- Parameters  : $reservation_id, $loadstatename (optional)
+ Parameters  : $reservation_id, $loadstatename (optional), $immediate (optional)
  Returns     : boolean
  Description : Deletes rows from the computerloadlog table. A loadstatename
                argument can be specified to limit the rows removed to a
                certain loadstatename value. To delete all rows except those
                matching a certain loadstatename, begin the loadstatename
                with a !. The $reservation_id argument may either be a single
-               integer or an array reference.
+               integer or an array reference. A immediate option can be specified 
+					to clear all entries
 
 =cut
 
 sub delete_computerloadlog_reservation {
-	my ($reservation_id_argument, $loadstatename) = @_;
-	
+	my $reservation_id_argument = shift;
+	my $loadstatename = shift;
+	my $immediate = shift;
+
+
 	# Check the passed parameter
-	if (!(defined($reservation_id_argument))) {
-		notify($ERRORS{'WARNING'}, 0, "reservation ID was not specified");
+	unless (defined($reservation_id_argument) ) {
+		notify($ERRORS{'WARNING'}, 0, "reservation_id_argument argument were not specified");
 		return;
 	}
 	
@@ -5556,6 +5560,11 @@ sub delete_computerloadlog_reservation {
 	else {
 		$reservation_id_string = $reservation_id_argument;
 	}
+
+	if(!defined($immediate)){
+		$immediate =0;
+	}
+
 	
 	# Construct the SQL statement
 	my $sql_statement = <<EOF;
@@ -5585,6 +5594,11 @@ EOF
 	else {
 		notify($ERRORS{'DEBUG'}, 0, "removing all computerloadlog entries for reservation");
 	}
+
+	#Only remove entries older than 2 minutes	unless the immediate flag
+	unless ($immediate) {
+		$sql_statement .= " AND timestamp <= (NOW() - INTERVAL 2 Minute);";
+	}
 	
 	# Call the database execute subroutine
 	if (database_execute($sql_statement)) {