incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1102558 - in /incubator/tashi: branches/stablefix/src/tashi/nodemanager/nodemanagerservice.py trunk/src/tashi/nodemanager/nodemanagerservice.py
Date Fri, 13 May 2011 04:10:55 GMT
Author: stroucki
Date: Fri May 13 04:10:54 2011
New Revision: 1102558

URL: http://svn.apache.org/viewvc?rev=1102558&view=rev
Log:
nodemanagerservice: Age and expire the CM handle. If the CM happens to reboot, this should
get the NMs to check in again after a while.

Modified:
    incubator/tashi/branches/stablefix/src/tashi/nodemanager/nodemanagerservice.py
    incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py

Modified: incubator/tashi/branches/stablefix/src/tashi/nodemanager/nodemanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stablefix/src/tashi/nodemanager/nodemanagerservice.py?rev=1102558&r1=1102557&r2=1102558&view=diff
==============================================================================
--- incubator/tashi/branches/stablefix/src/tashi/nodemanager/nodemanagerservice.py (original)
+++ incubator/tashi/branches/stablefix/src/tashi/nodemanager/nodemanagerservice.py Fri May
13 04:10:54 2011
@@ -89,7 +89,6 @@ class NodeManagerService(object):
 			self.log.exception('Failed to save VM info to %s' % (self.infoFile))
 	
 	def vmStateChange(self, vmId, old, cur):
-		cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
 		instance = self.getInstance(vmId)
 		if (old and instance.state != old):
 			self.log.warning('VM state was %s, call indicated %s' % (vmStates[instance.state], vmStates[old]))
@@ -99,6 +98,7 @@ class NodeManagerService(object):
 		newInst = Instance(d={'state':cur})
 		success = lambda: None
 		try:
+			cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
 			cm.vmUpdate(instance.id, newInst, old)
 		except Exception, e:
 			self.log.exception('RPC failed for vmUpdate on CM')
@@ -108,8 +108,20 @@ class NodeManagerService(object):
 		return True
 	
 	def backupVmInfoAndFlushNotifyCM(self):
-		cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
+		cm = None
+		cmUseCount = 0
 		while True:
+			if cmUseCount > 10 or cm is None:
+				try:
+					# XXXstroucki hope rpyc handles destruction
+					cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
+					cmUseCount = 0
+				except Exception, e:
+					self.log.warning("Could not get a handle to the clustermanager")
+					time.sleep(60)
+					continue
+
+			cmUseCount = cmUseCount + 1
 			start = time.time()
 			try:
 				self.saveVmInfo()
@@ -140,12 +152,23 @@ class NodeManagerService(object):
 				time.sleep(toSleep)
 	
 	def registerWithClusterManager(self):
-		cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
+		cm = None
+		cmUseCount = 0
 		while True:
+			if cmUseCount > 10 or cm is None:
+				try:
+					cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
+					cmUseCount = 0
+				except Exception, e:
+					self.log.warning("Could not get a handle to the clustermanager")
+					time.sleep(60)
+					continue
+			cmUseCount = cmUseCount + 1
 			start = time.time()
 			try:
 				host = self.vmm.getHostInfo(self)
 				instances = self.instances.values()
+				cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
 				self.id = cm.registerNodeManager(host, instances)
 			except Exception, e:
 				self.log.exception('Failed to register with the CM')

Modified: incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py?rev=1102558&r1=1102557&r2=1102558&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py Fri May 13 04:10:54
2011
@@ -108,8 +108,20 @@ class NodeManagerService(object):
 		return True
 	
 	def backupVmInfoAndFlushNotifyCM(self):
-		cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
+		cm = None
+		cmUseCount = 0
 		while True:
+			if cmUseCount > 10 or cm is None:
+				try:
+					# XXXstroucki hope rpyc handles destruction
+					cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
+					cmUseCount = 0
+				except Exception, e:
+					self.log.warning("Could not get a handle to the clustermanager")
+					time.sleep(60)
+					continue
+
+			cmUseCount = cmUseCount + 1
 			start = time.time()
 			try:
 				self.saveVmInfo()
@@ -140,12 +152,23 @@ class NodeManagerService(object):
 				time.sleep(toSleep)
 	
 	def registerWithClusterManager(self):
-		cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
+		cm = None
+		cmUseCount = 0
 		while True:
+			if cmUseCount > 10 or cm is None:
+				try:
+					cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
+					cmUseCount = 0
+				except Exception, e:
+					self.log.warning("Could not get a handle to the clustermanager")
+					time.sleep(60)
+					continue
+			cmUseCount = cmUseCount + 1
 			start = time.time()
 			try:
 				host = self.vmm.getHostInfo(self)
 				instances = self.instances.values()
+				cm = ConnectionManager(self.username, self.password, self.cmPort)[self.cmHost]
 				self.id = cm.registerNodeManager(host, instances)
 			except Exception, e:
 				self.log.exception('Failed to register with the CM')



Mime
View raw message