예제 #1
0
파일: manager.py 프로젝트: flyapen/UgFlu
    def _loadManagerBouncer(self, conf):
        if not (conf.bouncer):
            self.warning('no bouncer defined, nothing can access the '
                         'manager')
            return defer.succeed(None)

        self.debug('going to start manager bouncer %s of type %s',
                   conf.bouncer.name, conf.bouncer.type)

        defs = registry.getRegistry().getComponent(conf.bouncer.type)
        entry = defs.getEntryByType('component')
        # FIXME: use entry.getModuleName() (doesn't work atm?)
        moduleName = defs.getSource()
        methodName = entry.getFunction()
        bouncer = reflectcall.createComponent(moduleName, methodName,
                                              conf.bouncer.getConfigDict())
        d = bouncer.waitForHappy()

        def setupCallback(result):
            bouncer.debug('started')
            self.setBouncer(bouncer)

        def setupErrback(failure):
            self.warning('Error starting manager bouncer')
        d.addCallbacks(setupCallback, setupErrback)
        return d
예제 #2
0
파일: job.py 프로젝트: flyapen/UgFlu
    def _createComponent(self, avatarId, type, moduleName, methodName,
                         nice, conf):
        """
        Create a component of the given type.
        Log in to the manager with the given avatarId.

        @param avatarId:   avatarId component will use to log in to manager
        @type  avatarId:   str
        @param type:       type of component to start
        @type  type:       str
        @param moduleName: name of the module that contains the entry point
        @type  moduleName: str
        @param methodName: name of the factory method to create the component
        @type  methodName: str
        @param nice:       the nice level to run with
        @type  nice:       int
        @param conf:       the component configuration
        @type  conf:       dict
        """
        self.info('Creating component "%s" of type "%s"', avatarId, type)

        self._setNice(nice)
        self._enableCoreDumps()

        try:
            comp = createComponent(moduleName, methodName, conf)
        except Exception, e:
            msg = "Exception %s during createComponent: %s" % (
                e.__class__.__name__, " ".join(e.args))
            # traceback.print_exc()
            # a ComponentCreateError is already formatted
            if isinstance(e, errors.ComponentCreateError):
                msg = e.args[0]
            self.warning(
                "raising ComponentCreateError(%s) and stopping job" % msg)
            # This is a Nasty Hack. We raise ComponentCreateError, which can be
            # caught on the other side and marshalled as a reasonably
            # comprehensible error message. However, if we shutdown
            # immediately, the PB connection won't be available, so
            # the worker will just get an error about that! So, instead,
            # we shut down in a tenth of a second, usually allowing
            # the worker to get scheduled and read the exception over PB.
            # Ick!
            reactor.callLater(0.1, self.shutdown)
            raise errors.ComponentCreateError(msg)
예제 #3
0
파일: job.py 프로젝트: faroncoder/flumotion
    def _createComponent(self, avatarId, type, moduleName, methodName, nice,
                         conf):
        """
        Create a component of the given type.
        Log in to the manager with the given avatarId.

        @param avatarId:   avatarId component will use to log in to manager
        @type  avatarId:   str
        @param type:       type of component to start
        @type  type:       str
        @param moduleName: name of the module that contains the entry point
        @type  moduleName: str
        @param methodName: name of the factory method to create the component
        @type  methodName: str
        @param nice:       the nice level to run with
        @type  nice:       int
        @param conf:       the component configuration
        @type  conf:       dict
        """
        self.info('Creating component "%s" of type "%s"', avatarId, type)

        self._setNice(nice)
        self._enableCoreDumps()

        try:
            comp = createComponent(moduleName, methodName, conf)
        except Exception, e:
            msg = "Exception %s during createComponent: %s" % (
                e.__class__.__name__, " ".join(e.args))
            # traceback.print_exc()
            # a ComponentCreateError is already formatted
            if isinstance(e, errors.ComponentCreateError):
                msg = e.args[0]
            self.warning("raising ComponentCreateError(%s) and stopping job" %
                         msg)
            # This is a Nasty Hack. We raise ComponentCreateError, which can be
            # caught on the other side and marshalled as a reasonably
            # comprehensible error message. However, if we shutdown
            # immediately, the PB connection won't be available, so
            # the worker will just get an error about that! So, instead,
            # we shut down in a tenth of a second, usually allowing
            # the worker to get scheduled and read the exception over PB.
            # Ick!
            reactor.callLater(0.1, self.shutdown)
            raise errors.ComponentCreateError(msg)