Beispiel #1
0
 def start(self, stack_id, func, *args, **kwargs):
     """
     Run the given method in a sub-thread.
     """
     if stack_id not in self.groups:
         self.groups[stack_id] = threadgroup.ThreadGroup()
     return self.groups[stack_id].add_thread(func, *args, **kwargs)
Beispiel #2
0
    def test_stack_create(self):
        stack_name = 'service_create_test_stack'
        params = {'foo': 'bar'}
        template = '{ "Template": "data" }'

        stack = get_wordpress_stack(stack_name, self.ctx)

        self.m.StubOutWithMock(parser, 'Template')
        self.m.StubOutWithMock(parser, 'Parameters')
        self.m.StubOutWithMock(parser, 'Stack')

        parser.Template(template).AndReturn(stack.t)
        parser.Parameters(stack_name, stack.t,
                          params).AndReturn(stack.parameters)
        parser.Stack(self.ctx, stack.name, stack.t,
                     stack.parameters).AndReturn(stack)

        self.m.StubOutWithMock(stack, 'validate')
        stack.validate().AndReturn(None)

        self.m.StubOutWithMock(threadgroup, 'ThreadGroup')
        threadgroup.ThreadGroup().AndReturn(DummyThreadGroup())

        self.m.ReplayAll()

        result = self.man.create_stack(self.ctx, stack_name, template, params,
                                       {})
        self.assertEqual(result, stack.identifier())
        self.assertTrue(isinstance(result, dict))
        self.assertTrue(result['stack_id'])
        self.m.VerifyAll()
Beispiel #3
0
    def __init__(self):
        """Initialize the service launcher.

        :returns: None

        """
        self._services = threadgroup.ThreadGroup()
        self.backdoor_port = eventlet_backdoor.initialize_if_enabled()
Beispiel #4
0
 def _timer_in_thread(self, stack_id, func, *args, **kwargs):
     """
     Define a periodic task, to be run in a separate thread, in the stack
     threadgroups.  Periodicity is cfg.CONF.periodic_interval
     """
     if stack_id not in self.stg:
         self.stg[stack_id] = threadgroup.ThreadGroup()
     self.stg[stack_id].add_timer(cfg.CONF.periodic_interval, func, *args,
                                  **kwargs)
Beispiel #5
0
 def _start_in_thread(self, stack_id, func, *args, **kwargs):
     if stack_id not in self.stg:
         self.stg[stack_id] = threadgroup.ThreadGroup()
     self.stg[stack_id].add_thread(func, *args, **kwargs)
Beispiel #6
0
 def __init__(self, threads=1000):
     self.tg = threadgroup.ThreadGroup(threads)
Beispiel #7
0
 def __init__(self):
     self.services = []
     self.tg = threadgroup.ThreadGroup()
     self.done = event.Event()
Beispiel #8
0
    def __init__(self, threads=1000):
        self.tg = threadgroup.ThreadGroup(threads)

        # signal that the service is done shutting itself down:
        self._done = event.Event()
Beispiel #9
0
 def _start_in_thread(self, stack_id, stack_name, func, *args, **kwargs):
     if stack_id not in self.stg:
         thr_name = '%s-%s' % (stack_name, stack_id)
         self.stg[stack_id] = threadgroup.ThreadGroup(thr_name)
     self.stg[stack_id].add_thread(func, *args, **kwargs)