cocluto/ClusterController/QueueMachine.py

63 lines
2.1 KiB
Python

class QueueMachineStateFlags: #
DISABLED=1 # the queue machine is disabled
ALARM=2 # the queue machine is in alarm state (see man qstat)
UNKNOWN=4 # the queue machine is in unknown state because sge_execd cannot be contected (see man qstat)
ERROR=8 # the queue is in error state
OBSOLETE=16 # the queue no longer exists but it is still visible because it still contains running jobs
SUSPENDED=32 # the queue machine is suspended
class QueueMachine:
"""
a QueueMachine instance represents a given SGE queue on a given machine (eg allintel.q@simpatix10)
"""
def __init__( self, queueName, machineName ):
self.m_queueName = queueName
self.m_machineName = machineName
self.m_numSlots = None
self.m_numUsedSlots = None
self.m_fCpuLoad = None
def getName( self ):
"""
returns the name of the machine queue (such as allintel.q@simpatix10)
"""
return self.m_queueName + '@' + self.m_machineName
def getQueueName( self ):
return self.m_queueName
def getMachineName( self ):
return self.m_machineName
def setNumSlots( self, numSlots ):
self.m_numSlots = numSlots
def setNumUsedSlots( self, numSlots ):
self.m_numUsedSlots = numSlots
def getNumSlots( self ):
assert( self.m_numSlots != None )
return self.m_numSlots
def getNumUsedSlots( self ):
assert( self.m_numUsedSlots != None )
return self.m_numUsedSlots
def setCpuLoad( self, fCpuLoad ):
self.m_fCpuLoad = fCpuLoad
def cpuLoadIsAvailable( self ):
return self.m_fCpuLoad != None
def getCpuLoad( self ):
assert( self.m_fCpuLoad != None )
return self.m_fCpuLoad
def setState( self, state ):
self.m_stateFlags = state
def isDisabled( self ):
return self.m_stateFlags & QueueMachineStateFlags.DISABLED
def isInErrorState( self ):
return self.m_stateFlags & QueueMachineStateFlags.ERROR
def isResponding( self ):
return not (self.m_stateFlags & QueueMachineStateFlags.UNKNOWN)
def isInAlarmState( self ):
return self.m_stateFlags & QueueMachineStateFlags.ALARM
def isSuspended( self ):
return self.m_stateFlags & QueueMachineStateFlags.SUSPENDED
"""
def getStateAsString( self ):
assert( self.m_strState != None )
return self.m_strState
"""