wingo - in flumotion/trunk: . flumotion/common flumotion/component
flumotion/manager
flumotion-commit at lists.fluendo.com
flumotion-commit at lists.fluendo.com
Mon Jan 8 13:37:11 CET 2007
Author: wingo
Date: Mon Jan 8 13:37:08 2007
New Revision: 4376
Modified:
flumotion/trunk/ChangeLog
flumotion/trunk/flumotion/common/planet.py
flumotion/trunk/flumotion/component/component.py
flumotion/trunk/flumotion/manager/component.py
flumotion/trunk/flumotion/manager/manager.py
Log:
2007-01-08 Andy Wingo <wingo at pobox.com>
* flumotion/manager/component.py (ComponentAvatar._setMood): use
setMood.
(ComponentAvatar.detached): Actually unlink the jobstate and
componentstate when the job logs out; was not being done before.
* flumotion/manager/manager.py (Vishnu._getComponentState):
Because of the change in BaseComponentMedium.remote_getState, we
know we will have a non-sleeping component mood, so we can remove
this manual mood munge.
(Vishnu.componentAddMessage)
(Vishnu.workerAttached.workerAvatarComponentListReceived)
(Vishnu._addComponent, Vishnu._updateStateFromConf): Use setMood.
(Vishnu.componentStop.setSleeping): Set the component's mood to
sleeping after the disconnect deferred fires, should be enough
time for the component state to unlink from the job state.
(Vishnu._createErrback): A failed component start because a job is
already running only marks a component as lost if it did not log
in in the meantime. Fixes #551. Also use setMood.
* flumotion/component/component.py
(BaseComponentMedium.remote_getState): Make sure that the mood
that we return is not sleeping. If it is sleeping, warn real loud
and set the mood to waking.
* flumotion/common/planet.py (ManagerComponentState.setMood): New
method, sets the mood only if we are not listening to a jobState.
The intention is that all sets of mood go through this function so
as to prevent bad mood-proxy bugs like #551. The exception is that
the manager is allowed to mark the mood as sad.
Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog (original)
+++ flumotion/trunk/ChangeLog Mon Jan 8 13:37:08 2007
@@ -1,3 +1,35 @@
+2007-01-08 Andy Wingo <wingo at pobox.com>
+
+ * flumotion/manager/component.py (ComponentAvatar._setMood): use
+ setMood.
+ (ComponentAvatar.detached): Actually unlink the jobstate and
+ componentstate when the job logs out; was not being done before.
+
+ * flumotion/manager/manager.py (Vishnu._getComponentState):
+ Because of the change in BaseComponentMedium.remote_getState, we
+ know we will have a non-sleeping component mood, so we can remove
+ this manual mood munge.
+ (Vishnu.componentAddMessage)
+ (Vishnu.workerAttached.workerAvatarComponentListReceived)
+ (Vishnu._addComponent, Vishnu._updateStateFromConf): Use setMood.
+ (Vishnu.componentStop.setSleeping): Set the component's mood to
+ sleeping after the disconnect deferred fires, should be enough
+ time for the component state to unlink from the job state.
+ (Vishnu._createErrback): A failed component start because a job is
+ already running only marks a component as lost if it did not log
+ in in the meantime. Fixes #551. Also use setMood.
+
+ * flumotion/component/component.py
+ (BaseComponentMedium.remote_getState): Make sure that the mood
+ that we return is not sleeping. If it is sleeping, warn real loud
+ and set the mood to waking.
+
+ * flumotion/common/planet.py (ManagerComponentState.setMood): New
+ method, sets the mood only if we are not listening to a jobState.
+ The intention is that all sets of mood go through this function so
+ as to prevent bad mood-proxy bugs like #551. The exception is that
+ the manager is allowed to mark the mood as sad.
+
2007-01-03 Andy Wingo <wingo at pobox.com>
* flumotion/twisted/pb.py: Import errors, thanks distributed
Modified: flumotion/trunk/flumotion/common/planet.py
==============================================================================
--- flumotion/trunk/flumotion/common/planet.py (original)
+++ flumotion/trunk/flumotion/common/planet.py Mon Jan 8 13:37:08 2007
@@ -29,7 +29,7 @@
from flumotion.twisted import flavors
from flumotion.twisted.compat import implements
-from flumotion.common import enum
+from flumotion.common import enum, log
class ManagerPlanetState(flavors.StateCacheable):
"""
@@ -256,6 +256,16 @@
jobState.addListener(self, proxy('set'), proxy('append'),
proxy('remove'))
+ def setMood(self, moodValue):
+ log.debug('componentstate', 'told to change mood from %s to %d',
+ self.get('mood'), moodValue)
+ if self._jobState and moodValue != moods.sad.value:
+ log.warning('componentstate', 'cannot set component mood to '
+ 'something other than sad when we have a '
+ 'jobState -- fix your code!')
+ else:
+ self.set('mood', moodValue)
+
def clearJobState(self):
"""
Remove the job state.
Modified: flumotion/trunk/flumotion/component/component.py
==============================================================================
--- flumotion/trunk/flumotion/component/component.py (original)
+++ flumotion/trunk/flumotion/component/component.py Mon Jan 8 13:37:08 2007
@@ -206,6 +206,11 @@
# we can only get the IP after we have a remote reference, so add it
# here
self.comp.state.set('manager-ip', self.getManagerIP())
+ if self.comp.state.get('mood') == moods.sleeping.value:
+ self.warning('Badness, it should not be possible for a '
+ 'running component to have sleeping mood!')
+ self.warning('Setting mood to waking')
+ self.comp.state.set('mood', moods.waking.value)
return self.comp.state
def remote_getConfig(self):
Modified: flumotion/trunk/flumotion/manager/component.py
==============================================================================
--- flumotion/trunk/flumotion/manager/component.py (original)
+++ flumotion/trunk/flumotion/manager/component.py Mon Jan 8 13:37:08 2007
@@ -112,7 +112,7 @@
if not self.componentState.get('mood') == mood.value:
self.debug('Setting mood to %r' % mood)
- self.componentState.set('mood', mood.value)
+ self.componentState.setMood(mood.value)
def _setMoodValue(self, moodValue):
mood = moods.get(moodValue)
@@ -171,6 +171,8 @@
self.info('component "%s" logged out' % self.avatarId)
+ self.componentState.clearJobState()
+
# Now, we're detached: set our state to sleeping (or lost).
# Do this before vishnu.componentDetached() severs our association
# with our componentState. Also, don't ever remove 'sad' here.
Modified: flumotion/trunk/flumotion/manager/manager.py
==============================================================================
--- flumotion/trunk/flumotion/manager/manager.py (original)
+++ flumotion/trunk/flumotion/manager/manager.py Mon Jan 8 13:37:08 2007
@@ -404,7 +404,7 @@
state.set('name', conf.name)
state.set('type', conf.getType())
state.set('workerRequested', conf.worker)
- state.set('mood', moods.sleeping.value)
+ state.setMood(moods.sleeping.value)
state.set('config', conf.getConfigDict())
state.set('parent', parent)
@@ -491,7 +491,7 @@
N_("The component is misconfigured.")),
debug=debug)
state.append('messages', message)
- state.set('mood', moods.sad.value)
+ state.setMood(moods.sad.value)
raise e
return added
@@ -623,12 +623,12 @@
# moodPending is happy
if componentState.get('mood') == moods.sad.value:
self.debug('asked to stop a sad component without avatar')
- componentState.set('mood', moods.sleeping.value)
+ componentState.setMood(moods.sleeping.value)
componentState.set('moodPending', None)
return defer.succeed(None)
if componentState.get('mood') == moods.lost.value:
self.debug('asked to stop a lost component without avatar')
- componentState.set('mood', moods.sleeping.value)
+ componentState.setMood(moods.sleeping.value)
componentState.set('moodPending', None)
return defer.succeed(None)
@@ -639,15 +639,19 @@
d = avatar.mindCallRemote('stop')
def cleanupAndDisconnectComponent(result):
- if componentState.get('mood') == moods.sad.value:
- self.debug('clearing sad mood after stopping component')
- componentState.set('mood', moods.sleeping.value)
avatar._starting = False
avatar._beingSetup = False
-
return avatar.disconnect()
+ def setSleeping(result):
+ if componentState.get('mood') == moods.sad.value:
+ self.debug('clearing sad mood after having stopped component')
+ componentState.setMood(moods.sleeping.value)
+
+ return result
+
d.addCallback(cleanupAndDisconnectComponent)
+ d.addCallback(setSleeping)
return d
@@ -666,7 +670,7 @@
m.state.append('messages', message)
if message.level == messages.ERROR:
self.debug('Error message makes component sad')
- m.state.set('mood', moods.sad.value)
+ m.state.setMood(moods.sad.value)
# FIXME: unify naming of stuff like this
def workerAttached(self, workerAvatar):
@@ -709,7 +713,7 @@
# distinguish between a newly-started component and a lost
# component logging back in.
compState.set('moodPending', None)
- compState.set('mood', moods.sleeping.value)
+ compState.setMood(moods.sleeping.value)
allComponents = components + lostComponents
@@ -793,15 +797,19 @@
% (state.get('name'), log.getFailureMessage(failure)))
if failure.check(errors.ComponentAlreadyRunningError):
- self.info('component eappears to be running already; '
- 'treating it as lost')
- state.set('mood', moods.lost.value)
+ if self._componentMappers[state].jobState:
+ self.info('component appears to have logged in in the '
+ 'meantime')
+ else:
+ self.info('component appears to be running already; '
+ 'treating it as lost until it logs in')
+ state.setMood(moods.lost.value)
else:
message = messages.Error(T_(
N_("The component could not be started.")),
debug=log.getFailureMessage(failure))
- state.set('mood', moods.sad.value)
+ state.setMood(moods.sad.value)
state.append('messages', message)
return None
@@ -895,11 +903,6 @@
# make sure the component is in the depgraph
self._depgraph.addComponent(m.state)
- # Now that the JobState is attached, it might have overridden our
- # mood to sleeping; we MUST be waking; so we reset it here if required.
- if m.state.get('mood') == moods.sleeping.value:
- m.state.set('mood', moods.waking.value)
-
m.avatar = avatar
self._componentMappers[m.avatar] = m
avatar.componentState = m.state
More information about the flumotion-commit
mailing list