You are viewing a plain text version of this content. The canonical link for it is here.
Posted to tashi-commits@incubator.apache.org by mr...@apache.org on 2009/06/04 18:33:13 UTC

svn commit: r781825 - /incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py

Author: mryan3
Date: Thu Jun  4 18:33:12 2009
New Revision: 781825

URL: http://svn.apache.org/viewvc?rev=781825&view=rev
Log:
Code to publish stats from the nodemanager


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

Modified: incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py?rev=781825&r1=781824&r2=781825&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py Thu Jun  4 18:33:12 2009
@@ -30,6 +30,7 @@
 from tashi.services import clustermanagerservice
 from tashi.nodemanager import RPC
 from tashi import boolean, vmStates, logged, ConnectionManager, timed
+import tashi
 
 class NodeManagerService(object):
 	"""RPC handler for the NodeManager
@@ -46,6 +47,7 @@
 		self.convertExceptions = boolean(config.get('NodeManagerService', 'convertExceptions'))
 		self.registerFrequency = float(config.get('NodeManagerService', 'registerFrequency'))
 		self.infoFile = self.config.get('NodeManagerService', 'infoFile')
+		self.statsInterval = float(self.config.get('NodeManagerService', 'statsInterval'))
 		self.id = None
 		self.notifyCM = []
 		self.loadVmInfo()
@@ -60,6 +62,7 @@
 				self.vmStateChange(vmId, None, InstanceState.Exited)
 		threading.Thread(target=self.backupVmInfoAndFlushNotifyCM).start()
 		threading.Thread(target=self.registerWithClusterManager).start()
+		threading.Thread(target=self.statsThread).start()
 	
 	def loadVmInfo(self):
 		try:
@@ -272,4 +275,20 @@
 	def listVms(self):
 		return self.instances.keys()
 	
-
+	def statsThread(self):
+		while True:
+			try:
+				publishList = []
+				for vmId in self.instances:
+					try:
+						id = self.instances[vmId].id
+						stats = self.vmm.getStats(vmId)
+						for stat in stats:
+							publishList.append({"vm_%d_%s" % (id, stat):stats[stat]})
+					except:
+						self.log.exception('statsThread threw an exception')
+				if (len(publishList) > 0):
+					tashi.publisher.publishList(publishList)
+			except:
+				self.log.exception('statsThread threw an exception')
+			time.sleep(self.statsInterval)