org.paulneve.wlab.utilities
Class VmSuspender

java.lang.Object
  extended by org.paulneve.wlab.utilities.VmSuspender

public class VmSuspender
extends java.lang.Object

The VmSuspender. This class serves as the "watchdog" for overrunning students, suspends their VMs, and blocks access for the interregnum period.

Author:
Paul Neve

Constructor Summary
VmSuspender(int pollingInterval)
          Constructor.
 
Method Summary
 int getPollingInterval()
          Gets the polling interval of the VmSuspender.
 void removeStudent(Student student)
          Removes a student's suspenders Removes a student from the watchful eye of the suspender.
 void setDataAccess(DataAccess da)
          Sets the DataAccess object.
 void setGeneralUtils(GeneralUtils gu)
          Sets the GeneralUtils object.
 void setParameters(Parameters prefs)
          Sets the Parameters object.
 void setStrings(Strings s)
          Sets the Strings object.
 void setVirtualisationAccess(VirtualisationAccess va)
          Sets the VirtualisationAccess object.
 java.util.Date studentBlockTime(Student student)
          Returns the time that a given student is blocked until (i.e.
 void studentStartedVM(Student student)
          Called when a student starts a VM, and adds them to the watchful eye of the VmSuspender!
 java.util.Date studentWillBeShutdown(Student student)
          Returns the time that a given student will have their VMs shut down.
 void updateStudentSuspended(Student student, boolean changingStateIsOn)
          Checks to see if student's VMs are shut down.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VmSuspender

public VmSuspender(int pollingInterval)
Constructor. Creates a monitoring thread.

Parameters:
pollingInterval - integer, how often the suspender polls in seconds
Method Detail

studentStartedVM

public void studentStartedVM(Student student)
Called when a student starts a VM, and adds them to the watchful eye of the VmSuspender!

Parameters:
student - student to monitor

updateStudentSuspended

public void updateStudentSuspended(Student student,
                                   boolean changingStateIsOn)
Checks to see if student's VMs are shut down. The status "changing state" is a special case. Set changingStateIsOn to treat it as a running VM. Set to false to treat is as equivalent to shut down. The right behaviour will depend if we're being called from the startup or suspend functions.

Parameters:
student - student whose VMs should be checked
changingStateIsOn - as described

studentBlockTime

public java.util.Date studentBlockTime(Student student)
Returns the time that a given student is blocked until (i.e. when their interregnum period will elapse)

Parameters:
student - student to check
Returns:
either a date object representing the blocked until time, or null if they're not blocked.

studentWillBeShutdown

public java.util.Date studentWillBeShutdown(Student student)
Returns the time that a given student will have their VMs shut down.

Parameters:
student - student to check
Returns:
a date object representing the time they'll be shut down, or null if they won't be or if they have nothing running.

removeStudent

public void removeStudent(Student student)
Removes a student's suspenders Removes a student from the watchful eye of the suspender.

Parameters:
student - to liberate

getPollingInterval

public int getPollingInterval()
Gets the polling interval of the VmSuspender. This is used in a couple of places to add a bit of elasticity to certain time values.

Returns:
the poling interval, in seconds

setVirtualisationAccess

public void setVirtualisationAccess(VirtualisationAccess va)
Sets the VirtualisationAccess object. Injected via Spring so should never be used in code as such.


setDataAccess

public void setDataAccess(DataAccess da)
Sets the DataAccess object. Injected via Spring so should never be used in code as such.


setParameters

public void setParameters(Parameters prefs)
Sets the Parameters object. Injected via Spring so should never be used in code as such.


setGeneralUtils

public void setGeneralUtils(GeneralUtils gu)
Sets the GeneralUtils object. Injected via Spring so should never be used in code as such.


setStrings

public void setStrings(Strings s)
Sets the Strings object. Injected via Spring so should never be used in code as such.