Пример #1
0
    def __init__(self, kernel):
        self.kernel = kernel
        self.logger = kernel.logger
        self.dispatcher = kernel.dispatcher
        self.spComparator = ServicePSCComparator()
        self.dispatcher.register('psc.service.loader', self, 'domain_control')

        self.callBackChannel = 'psc.service.loader.%s%s' % (kernel.guid, crypto.makeCookie(10))
        self.dispatcher.register(self.callBackChannel, self, 'domain_control')
Пример #2
0
 def test_makeCookie(self):
     # limited amount to test here, but check
     # the length is good and the characters all
     # come from the tokenspace
     # Try 100 times (a lame test really!)
     
     for i in xrange(100):
         l = random.randint(1, 2000)
         cookie = crypto.makeCookie(l)
         self.assertTrue(len(cookie), l)
         ct = [i for i in cookie if i not in crypto.tokenspace]
         self.assertEquals(ct, [])
Пример #3
0
 def __init__(self, kernel, serviceName, profile):
     self.kernel = kernel
     self.logger = kernel.logger
     self.dispatcher = kernel.dispatcher
     self.serviceName = serviceName
     self.publishedName = profile['publishedName']
     self.profile = profile
     self.callBackChannel = 'psc.service.loader.%s%s' % (kernel.guid, crypto.makeCookie(10))
     self.dispatcher.register(self.callBackChannel, self, 'domain_control')
     
     # on this channel we get notified of a PSC having launched a service.
     self.dispatcher.register('psc.service.notification', self, 'domain_control')
     
     # this counter gets decremented as services are launched. Once 
     # the counter hits zero, our job is done.
     try:
         try:
             self.pscRequired = int(self.profile['launch']['minpscs'])
         except:
             self.logger.error("'minpscs' key in configuration for service %s has an invalid value (%s): default to 2" \
                               % (self.serviceName, self.profile['launch']['minpscs']))
             self.pscRequired=2
         self.launchPending = 0
         # list of PSCs that have offered to run the service
         self.pscReadyQueue = []
     except KeyError:
         self.pscRequired = 2
         self.profile['launch']['minpscs'] = self.pscRequired
         
         
     try:
         self.workersPerPSC = self.profile['launch']['workserperpsc']
     except KeyError:
         self.workersPerPSC = 2
         self.profile['launch']['workserperpsc'] = self.workersPerPSC
         
     self.workersRequired = self.pscRequired * self.workersPerPSC