Package flumotion :: Package common :: Module startset :: Class StartSet
[hide private]

Class StartSet

source code

extern.log.log.Loggable --+
                          |
                         StartSet

Instance Methods [hide private]
 
__init__(self, avatarLoggedIn, alreadyStartingError, alreadyRunningError)
Create a StartSet, a data structure for managing starts and stops of remote processes, for example jobs in a jobheaven.
source code
twisted.internet.defer.Deferred
createStart(self, avatarId)
Create and register a deferred for starting a given process.
source code
 
createSuccess(self, avatarId)
Trigger a deferred start previously registerd via createStart().
source code
 
createFailed(self, avatarId, exception)
Notify the caller that a create has failed, and remove the create from the list of pending creates.
source code
 
createRegistered(self, avatarId)
Check if a deferred create has been registered for the given avatarId.
source code
twisted.internet.defer.Deferred
shutdownStart(self, avatarId)
Create and register a deferred that will be fired when a process has shut down cleanly.
source code
 
shutdownSuccess(self, avatarId)
Trigger a callback on a deferred previously registered via shutdownStart().
source code
 
shutdownRegistered(self, avatarId)
Check if a deferred shutdown has been registered for the given avatarId.
source code
 
avatarStarted(self, avatarId)
Notify the startset that an avatar has started.
source code
 
avatarStopped(self, avatarId, getFailure)
Notify the startset that an avatar has stopped.
source code

Inherited from extern.log.log.Loggable: __providedBy__, debug, doLog, error, info, log, logFunction, logObjectName, warning, warningFailure, writeMarker

Class Variables [hide private]

Inherited from extern.log.log.Loggable: __implemented__, __provides__, logCategory

Method Details [hide private]

__init__(self, avatarLoggedIn, alreadyStartingError, alreadyRunningError)
(Constructor)

source code 

Create a StartSet, a data structure for managing starts and stops of remote processes, for example jobs in a jobheaven.

Parameters:
  • avatarLoggedIn - a procedure of type avatarId->boolean; should return True if the avatarId is logged in and "ready", and False otherwise. An avatarId is ready if avatarStarted() could have been called on it. This interface is made this way because it is assumed that whatever code instantiates a StartSet keeps track of "ready" remote processes, and this way we prevent data duplication.
  • alreadyStartingError - An exception class to raise if createStart() is called, but there is already a create deferred registered for that avatarId.
  • alreadyRunningError - An exception class to raise if createStart() is called, but there is already a "ready" process with that avatarId.

createStart(self, avatarId)

source code 

Create and register a deferred for starting a given process. The deferred will be fired when the process is ready, as triggered by a call to createSuccess().

Parameters:
  • avatarId - the id of the remote process, for example the avatarId of the job
Returns: twisted.internet.defer.Deferred

createSuccess(self, avatarId)

source code 

Trigger a deferred start previously registerd via createStart(). For example, a JobHeaven might call this method when a job has logged in and been told to start a component.

Parameters:
  • avatarId - the id of the remote process, for example the avatarId of the job

createFailed(self, avatarId, exception)

source code 

Notify the caller that a create has failed, and remove the create from the list of pending creates.

Parameters:
  • avatarId - the id of the remote process, for example the avatarId of the job
  • exception - either an exception or a failure describing why the create failed.

createRegistered(self, avatarId)

source code 

Check if a deferred create has been registered for the given avatarId.

Parameters:
  • avatarId - the id of the remote process, for example the avatarId of the job
Returns:
The deferred create, if one has been registered. Otherwise None.

shutdownStart(self, avatarId)

source code 

Create and register a deferred that will be fired when a process has shut down cleanly.

Parameters:
  • avatarId - the id of the remote process, for example the avatarId of the job
Returns: twisted.internet.defer.Deferred

shutdownSuccess(self, avatarId)

source code 

Trigger a callback on a deferred previously registered via shutdownStart(). For example, a JobHeaven would call this when a job for which shutdownStart() was called is reaped.

Parameters:
  • avatarId - the id of the remote process, for example the avatarId of the job

shutdownRegistered(self, avatarId)

source code 

Check if a deferred shutdown has been registered for the given avatarId.

Parameters:
  • avatarId - the id of the remote process, for example the avatarId of the job
Returns:
True if a deferred shutdown has been registered for this object, False otherwise

avatarStarted(self, avatarId)

source code 

Notify the startset that an avatar has started. If there was a create deferred registered for this avatar, this will cause createSuccess() to be called.

Parameters:
  • avatarId - the id of the remote process, for example the avatarId of the job

avatarStopped(self, avatarId, getFailure)

source code 

Notify the startset that an avatar has stopped. If there was a shutdown deferred registered for this avatar, this will cause shutdownSuccess() to be called.

On the other hand, if there was a create deferred still pending, we will call createFailed with the result of calling getFailure.

If no start or create was registered, we do nothing.

Parameters:
  • avatarId - the id of the remote process, for example the avatarId of the job
  • getFailure - procedure of type avatarId -> Failure. The returned failure should describe the reason that the job failed.