incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1229807 - in /incubator/tashi/branches/stroucki-accounting: etc/ src/tashi/accounting/ src/tashi/clustermanager/ src/tashi/nodemanager/
Date Tue, 10 Jan 2012 23:40:06 GMT
Author: stroucki
Date: Tue Jan 10 23:40:06 2012
New Revision: 1229807

URL: http://svn.apache.org/viewvc?rev=1229807&view=rev
Log:
configs: add new parameters
clustermanagerservce: handle configurable accounting
nodemanagerservice: handle configurable accounting
accounting: remove debug
accountingservice: remove debug, handle configurable sleep time for polling for active VMs

Modified:
    incubator/tashi/branches/stroucki-accounting/etc/Accounting.cfg
    incubator/tashi/branches/stroucki-accounting/etc/NodeManager.cfg
    incubator/tashi/branches/stroucki-accounting/etc/TashiDefaults.cfg
    incubator/tashi/branches/stroucki-accounting/src/tashi/accounting/accounting.py
    incubator/tashi/branches/stroucki-accounting/src/tashi/accounting/accountingservice.py
    incubator/tashi/branches/stroucki-accounting/src/tashi/clustermanager/clustermanagerservice.py
    incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/nodemanagerservice.py

Modified: incubator/tashi/branches/stroucki-accounting/etc/Accounting.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/etc/Accounting.cfg?rev=1229807&r1=1229806&r2=1229807&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/etc/Accounting.cfg (original)
+++ incubator/tashi/branches/stroucki-accounting/etc/Accounting.cfg Tue Jan 10 23:40:06 2012
@@ -1,3 +1,10 @@
+[Accounting]
+service = tashi.accounting.AccountingService
+
+[AccountingService]
+port = 2228
+pollSleep = 600
+
 [handler_fileHandler]
 class = FileHandler
 level = NOTSET

Modified: incubator/tashi/branches/stroucki-accounting/etc/NodeManager.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/etc/NodeManager.cfg?rev=1229807&r1=1229806&r2=1229807&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/etc/NodeManager.cfg (original)
+++ incubator/tashi/branches/stroucki-accounting/etc/NodeManager.cfg Tue Jan 10 23:40:06 2012
@@ -79,6 +79,8 @@ infoFile = /var/tmp/nm.dat
 clusterManagerHost = localhost ; Clustermanager hostname
 clusterManagerPort = 9882
 statsInterval = 0.0
+accountingHost = clustermanager
+accountingPort = 2228
 ;bind = 0.0.0.0 ; not supported (Thrift is missing support to specify what to bind to!)
 
 [Security]

Modified: incubator/tashi/branches/stroucki-accounting/etc/TashiDefaults.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/etc/TashiDefaults.cfg?rev=1229807&r1=1229806&r2=1229807&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/etc/TashiDefaults.cfg (original)
+++ incubator/tashi/branches/stroucki-accounting/etc/TashiDefaults.cfg Tue Jan 10 23:40:06
2012
@@ -55,6 +55,8 @@ allowMismatchedVersions = False
 maxMemory = 8192
 maxCores = 8
 allowDuplicateNames = False
+accountingHost = clustermanager
+accountingPort = 2228
 ;bind = 0.0.0.0 ; not supported (Thrift is missing support to specify what to bind to!)
 
 [GetentOverride]

Modified: incubator/tashi/branches/stroucki-accounting/src/tashi/accounting/accounting.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/src/tashi/accounting/accounting.py?rev=1229807&r1=1229806&r2=1229807&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/src/tashi/accounting/accounting.py (original)
+++ incubator/tashi/branches/stroucki-accounting/src/tashi/accounting/accounting.py Tue Jan
10 23:40:06 2012
@@ -69,7 +69,6 @@ class Accounting(object):
 			t = ThreadedServer(service=rpycservices.ManagerService, hostname='0.0.0.0', port=int(self.config.get('AccountingService',
'port')), auto_register=False, authenticator=authenticator)
 		else:
 			t = ThreadedServer(service=rpycservices.ManagerService, hostname='0.0.0.0', port=int(self.config.get('AccountingService',
'port')), auto_register=False)
-			print "ah"
 
 		t.logger.setLevel(logging.ERROR)
 		t.service.service = service

Modified: incubator/tashi/branches/stroucki-accounting/src/tashi/accounting/accountingservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/src/tashi/accounting/accountingservice.py?rev=1229807&r1=1229806&r2=1229807&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/src/tashi/accounting/accountingservice.py
(original)
+++ incubator/tashi/branches/stroucki-accounting/src/tashi/accounting/accountingservice.py
Tue Jan 10 23:40:06 2012
@@ -32,11 +32,17 @@ class AccountingService(object):
             self.log = logging.getLogger(__name__)
             self.log.setLevel(logging.INFO)
 
+	    self.config = config
+
+	    self.pollsleep = self.config.get("AccountingService", "pollSleep")
+	    if self.pollsleep is None:
+		    self.pollsleep = 600
+
             self.cm = createClient(config)
             threading.Thread(target=self.__start).start()
 
+	# remote
         def record(self, strings):
-            print "here"
             for string in strings:
                 self.log.info("Remote: %s" % (string))
 
@@ -46,12 +52,10 @@ class AccountingService(object):
                     instances = self.cm.getInstances()
                     for instance in instances:
                         # XXXstroucki this currently duplicates what the CM was doing.
-                        # perhaps implement a diff-like log?    
                         self.log.info('Accounting: id %d host %d vmId %d user %d cores %d
memory %d' % (instance.id, instance.hostId, instance.vmId, instance.userId, instance.cores,
instance.memory))
                 except:
                     self.log.warning("Accounting iteration failed")
 
                         
                 # wait to do the next iteration
-                # XXXstroucki make this configurable?                   
-                time.sleep(60)
+                time.sleep(self.pollsleep)

Modified: incubator/tashi/branches/stroucki-accounting/src/tashi/clustermanager/clustermanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/src/tashi/clustermanager/clustermanagerservice.py?rev=1229807&r1=1229806&r2=1229807&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/src/tashi/clustermanager/clustermanagerservice.py
(original)
+++ incubator/tashi/branches/stroucki-accounting/src/tashi/clustermanager/clustermanagerservice.py
Tue Jan 10 23:40:06 2012
@@ -22,6 +22,7 @@ import logging
 import threading
 import time
 
+from tashi.rpycservices import rpycservices             
 from tashi.rpycservices.rpyctypes import Errors, InstanceState, HostState, TashiException
 from tashi import boolean, convertExceptions, ConnectionManager, vmStates, timed, version,
scrubString
 
@@ -52,7 +53,10 @@ class ClusterManagerService(object):
 		self.maxMemory = int(self.config.get('ClusterManagerService', 'maxMemory'))
 		self.maxCores = int(self.config.get('ClusterManagerService', 'maxCores'))
 		self.allowDuplicateNames = boolean(self.config.get('ClusterManagerService', 'allowDuplicateNames'))
-		
+
+		self.accountingHost = self.config.get('ClusterManagerService', 'accountingHost')
+		self.accountingPort = self.config.get('ClusterManagerService', 'accountingPort')
+
 		self.__initAccounting()
 		self.__initCluster()
 
@@ -61,7 +65,14 @@ class ClusterManagerService(object):
 	def __initAccounting(self):
 		self.accountBuffer = []
 		self.accountLines = 0
+		self.accountingClient = None
+		try:
+			if (self.accountingHost is not None) and \
+				    (self.accountingPort is not None):
 
+				self.accountingClient=rpycservices.client(self.accountingHost, self.accountingPort)
+		except:
+			self.log.exception("Could not init accounting")
 
 	def __initCluster(self):
 		# initialize state of VMs if restarting
@@ -89,9 +100,8 @@ class ClusterManagerService(object):
 
 	def __ACCOUNTFLUSH(self):
 		try:
-			from tashi.rpycservices import rpycservices
-			client=rpycservices.client("clustermanager", 31337)
-			client.record(self.accountBuffer)
+			if (self.accountingClient is not None):
+				self.accountingClient.record(self.accountBuffer)
 			self.accountLines = 0
 			self.accountBuffer = []
 		except:

Modified: incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/nodemanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/nodemanagerservice.py?rev=1229807&r1=1229806&r2=1229807&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/nodemanagerservice.py
(original)
+++ incubator/tashi/branches/stroucki-accounting/src/tashi/nodemanager/nodemanagerservice.py
Tue Jan 10 23:40:06 2012
@@ -23,6 +23,7 @@ import sys
 import threading
 import time
 
+from tashi.rpycservices import rpycservices
 from tashi.rpycservices.rpyctypes import Host, HostState, InstanceState, TashiException,
Errors, Instance
 from tashi.nodemanager import RPC
 from tashi import boolean, vmStates, logged, ConnectionManager, timed
@@ -59,11 +60,12 @@ class NodeManagerService(object):
 			self.log.exception("Could not connect to CM")
 			return
 
+		self.accountingHost = self.config.get('NodeManagerService', 'accountingHost')
+		self.accountingPort = self.config.get('NodeManagerService', 'accountingPort')
 		self.notifyCM = []
 
-		self.accountLines = 0
-		self.accountBuffer = []
-		
+		self.__initAccounting()
+
 		self.id = None
 		# XXXstroucki this fn could be in this level maybe?
 		self.host = self.vmm.getHostInfo(self)
@@ -81,6 +83,17 @@ class NodeManagerService(object):
 		threading.Thread(target=self.__registerWithClusterManager).start()
 		threading.Thread(target=self.__statsThread).start()
 	
+	def __initAccounting(self):
+                self.accountBuffer = []
+                self.accountLines = 0
+                self.accountingClient = None
+                try:
+                        if (self.accountingHost is not None) and \
+                                    (self.accountingPort is not None):
+                                self.accountingClient=rpycservices.client(self.accountingHost,
self.accountingPort)
+                except:
+                        self.log.exception("Could not init accounting")
+			
 	def __loadVmInfo(self):
 		try:
 			self.instances = self.vmm.getInstances()
@@ -123,9 +136,8 @@ class NodeManagerService(object):
 
         def __ACCOUNTFLUSH(self):
 		try:
-			from tashi.rpycservices import rpycservices
-			client=rpycservices.client("clustermanager", 31337)
-			client.record(self.accountBuffer)
+			if (self.accountingClient is not None):
+				self.accountingClient.record(self.accountBuffer)
 			self.accountLines = 0
 			self.accountBuffer = []
 		except:



Mime
View raw message