Package flumotion :: Package component :: Module component :: Class BaseComponent
[hide private]

Class BaseComponent

source code

             object --+    
                      |    
common.common.InitMixin --+
                          |
extern.log.log.Loggable --+
                          |
                         BaseComponent
Known Subclasses:

I am the base class for all Flumotion components.

Nested Classes [hide private]
child class of BaseComponentMedium componentMediumClass
the medium class to use for this component
Instance Methods [hide private]
 
__init__(self, config, haveError=None)
Subclasses should not override __init__ at all.
source code
 
init(self)
A subclass should do as little as possible in its init method.
source code
 
do_check(self)
Subclasses can implement me to run any checks before the component performs setup.
source code
 
check_properties(self, properties, addMessage)
BaseComponent convenience vmethod for running checks.
source code
 
do_setup(self)
Subclasses can implement me to set up the component before it is started.
source code
 
do_stop(self)
BaseComponent vmethod for stopping.
source code
 
setup(self)
Sets up the component.
source code
 
setup_completed(self) source code
 
setShutdownHook(self, shutdownHook)
Set the shutdown hook for this component (replacing any previous hook).
source code
 
stop(self)
Tell the component to stop.
source code
 
getName(self) source code
 
setWorkerName(self, workerName) source code
 
getWorkerName(self) source code
 
setMedium(self, medium) source code
 
setMood(self, mood)
Set the given mood on the component if it's different from the current one.
source code
int
getMood(self)
Gets the mood on the component.
source code
 
waitForHappy(self) source code
 
addMessage(self, message)
Add a message to the component.
source code
 
fixRenamedProperties(self, properties, list)
Fix properties that have been renamed from a previous version, and add a warning for them.
source code
 
adminCallRemote(self, methodName, *args, **kwargs)
Call a remote method on all admin client views on this component.
source code
 
_pollCPU(self) source code
 
_pollMemory(self) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

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

Class Variables [hide private]
  logCategory = 'basecomp'
Implementors can provide a category to log their messages under.

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

Instance Variables [hide private]
BaseComponentMedium medium
the component's medium
string name
the name of the component
componentui.WorkerComponentUIState uiState
state of the component to be shown in a UI.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, config, haveError=None)
(Constructor)

source code 

Subclasses should not override __init__ at all.

Instead, they should implement init(), which will be called by this implementation automatically.

flumotion.common.common.InitMixin for more details.

Overrides: object.__init__

init(self)

source code 

A subclass should do as little as possible in its init method. In particular, it should not try to access resources.

Failures during init are marshalled back to the manager through the worker's remote_create method, since there is no component state proxied to the manager yet at the time of init.

do_check(self)

source code 

Subclasses can implement me to run any checks before the component performs setup.

Messages can be added to the component state's 'messages' list key. Any error messages added will trigger the component going to sad, with flumotion.common.errors.ComponentSetupError being raised before getting to setup stage; do_setup() will not be called.

In the event of a fatal problem that can't be expressed through an error message, this method should raise an exception or return a failure.

It is not necessary to chain up in this function. The return value may be a deferred.

check_properties(self, properties, addMessage)

source code 

BaseComponent convenience vmethod for running checks.

A component implementation can override this method to run any checks that it needs to. Typically, a check_properties implementation will call the provided addMessage() callback to note warnings or errors. For errors, addMessage() will set component's mood to sad, which will abort the init process before getting to do_setup().

Parameters:
  • properties (dict of string => object) - The component's properties
  • addMessage (flumotion.common.messages.Message -> None) - Thunk to add a message to the component state. Will raise an exception if the message is of level ERROR.

do_setup(self)

source code 

Subclasses can implement me to set up the component before it is started. It should set up the component, possibly opening files and resources. Non-programming errors should not be raised, but returned as a failing deferred.

The return value may be a deferred.

do_stop(self)

source code 

BaseComponent vmethod for stopping. The component should do any cleanup it needs, but must not set the component's mood to sleeping.

Returns:
twisted.internet.defer.Deferred

setup(self)

source code 

Sets up the component. Called during __init__, so be sure not to raise exceptions, instead adding messages to the component state.

setShutdownHook(self, shutdownHook)

source code 

Set the shutdown hook for this component (replacing any previous hook). When a component is stopped, then this hook will be fired.

stop(self)

source code 

Tell the component to stop. The connection to the manager will be closed. The job process will also finish.

addMessage(self, message)

source code 

Add a message to the component. If any of the messages is an error, the component will turn sad.

Parameters:

fixRenamedProperties(self, properties, list)

source code 

Fix properties that have been renamed from a previous version, and add a warning for them.

Parameters:
  • properties (dict) - properties; will be modified as a result.
  • list (list of tuple of (str, str)) - list of (old, new) tuples of property names.

adminCallRemote(self, methodName, *args, **kwargs)

source code 

Call a remote method on all admin client views on this component.

This gets serialized through the manager and multiplexed to all admin clients, and from there on to all views connected to each admin client model.

Because there can be any number of admin clients that this call will go out do, it does not make sense to have one return value. This function will return None always.


Instance Variable Details [hide private]

uiState

state of the component to be shown in a UI. Contains at least the following keys.
  • cpu-percent: percentage of CPU use in last interval
  • start-time: time when component was started, in epoch seconds
  • current-time: current time in epoch seconds, as seen on component's machine, which might be out of sync
  • virtual-size: virtual memory size in bytes

Subclasses can add additional keys for their respective UI.

Type:
componentui.WorkerComponentUIState