Beispiel #1
0
    def on_init(self):
        if not EEAgentCore:
            msg = "EEAgentCore isn't available. Use autolaunch.cfg buildout"
            log.error(msg)
            self.heartbeat_thread = None
            return
        log.debug("ExecutionEngineAgent Pyon on_init")
        launch_type_name = self.CFG.eeagent.launch_type.name

        if not launch_type_name:
            # TODO: Fail fast here?
            log.error("No launch_type.name specified")

        self._factory = get_exe_factory(launch_type_name,
                                        self.CFG,
                                        pyon_container=self.container,
                                        log=log)

        # TODO: Allow other core class?
        self.core = EEAgentCore(self.CFG, self._factory, log)

        interval = self.CFG.eeagent.get('heartbeat', DEFAULT_HEARTBEAT)
        if interval > 0:
            self.heartbeater = HeartBeater(self.CFG, self._factory, log=log)
            self.heartbeater.poll()
            self.heartbeat_thread = looping_call(0.1, self.heartbeater.poll)
        else:
            self.heartbeat_thread = None
    def on_init(self):
        if not EEAgentCore:
            msg = "EEAgentCore isn't available. Use autolaunch.cfg buildout"
            log.error(msg)
            self.heartbeat_thread = None
            return
        log.debug("ExecutionEngineAgent Pyon on_init")
        launch_type_name = self.CFG.eeagent.launch_type.name

        if not launch_type_name:
            # TODO: Fail fast here?
            log.error("No launch_type.name specified")

        self._factory = get_exe_factory(
            launch_type_name, self.CFG, pyon_container=self.container, log=log)

        # TODO: Allow other core class?
        self.core = EEAgentCore(self.CFG, self._factory, log)

        interval = float(self.CFG.eeagent.get('heartbeat', DEFAULT_HEARTBEAT))
        if interval > 0:
            self.heartbeater = HeartBeater(
                self.CFG, self._factory, self.resource_id, self, log=log)
            self.heartbeater.poll()
            self.heartbeat_thread, self._heartbeat_thread_event = looping_call(0.1, self.heartbeater.poll)
        else:
            self.heartbeat_thread = None
            self._heartbeat_thread_event = None
    def on_init(self):
        if not HighAvailabilityCore:
            msg = "HighAvailabilityCore isn't available. Use production.cfg buildout"
            log.error(msg)
            return
        log.debug("HighAvailabilityCore Pyon on_init")

        policy_name = self.CFG.get_safe("highavailability.policy.name")
        if policy_name is None:
            msg = "HA service requires a policy name at CFG.highavailability.policy.name"
            raise Exception(msg)
        try:
            self.policy = policy.policy_map[policy_name.lower()]
        except KeyError:
            raise Exception("HA Service doesn't support '%s' policy" % policy_name)

        policy_parameters = self.CFG.get_safe("highavailability.policy.parameters")

        self.policy_interval = self.CFG.get_safe("highavailability.policy.interval",
                DEFAULT_INTERVAL)

        cfg = self.CFG.get_safe("highavailability")
        pds = self.CFG.get_safe("highavailability.process_dispatchers", [])
        process_spec = self.CFG.get_safe("highavailability.process_spec")
        # TODO: Allow other core class?
        self.core = HighAvailabilityCore(cfg, ProcessDispatcherSimpleAPIClient,
                pds, process_spec, self.policy)

        self.policy_thread = looping_call(self.policy_interval, self.core.apply_policy)
    def on_init(self):
        if not EEAgentCore:
            msg = "EEAgentCore isn't available. Use production.cfg buildout"
            log.error(msg)
            return
        log.debug("ExecutionEngineAgent Pyon on_init")
        launch_type_name = self.CFG.eeagent.launch_type.name

        if not launch_type_name:
            # TODO: Fail fast here?
            log.error("No launch_type.name specified")

        self._factory = get_exe_factory(launch_type_name, self.CFG,
            pyon_container=self.container, log=log)

        # TODO: Allow other core class?
        self.core = EEAgentCore(self.CFG, self._factory, log)

        interval = self.CFG.eeagent.get('heartbeat', DEFAULT_HEARTBEAT)
        if interval > 0:
            self.heartbeater = HeartBeater(self.CFG, self._factory, log=log)
            looping_call(interval, self.heartbeater.poll)
    def on_init(self):
        if not HighAvailabilityCore:
            msg = "HighAvailabilityCore isn't available. Use autolaunch.cfg buildout"
            log.error(msg)
            return
        log.debug("HighAvailabilityCore Pyon on_init")

        policy_name = self.CFG.get_safe("highavailability.policy.name")
        if policy_name is None:
            msg = "HA service requires a policy name at CFG.highavailability.policy.name"
            raise Exception(msg)
        try:
            self.policy = policy.policy_map[policy_name.lower()]
        except KeyError:
            raise Exception("HA Service doesn't support '%s' policy" % policy_name)

        policy_parameters = self.CFG.get_safe("highavailability.policy.parameters")

        self.policy_interval = self.CFG.get_safe("highavailability.policy.interval",
                DEFAULT_INTERVAL)

        cfg = self.CFG.get_safe("highavailability")

        # use default PD name as the sole PD if none are provided in config
        self.pds = self.CFG.get_safe("highavailability.process_dispatchers",
            [ProcessDispatcherService.name])

        self.process_definition_id = self.CFG.get_safe("highavailability.process_definition_id")
        self.process_configuration = self.CFG.get_safe("highavailability.process_configuration")
        aggregator_config = self.CFG.get_safe("highavailability.aggregator")

        self.service_id = self._register_service()

        # TODO: Allow other core class?
        self.core = HighAvailabilityCore(cfg, ProcessDispatcherSimpleAPIClient,
                self.pds, self.policy, process_definition_id=self.process_definition_id,
                parameters=policy_parameters,
                process_configuration=self.process_configuration,
                aggregator_config=aggregator_config,
                pd_client_kwargs={'container': self.container,
                    'service_id': self.service_id})

        self.policy_thread = looping_call(self.policy_interval, self.core.apply_policy)

        dashi_messaging = self.CFG.get_safe("highavailability.dashi_messaging", False)
        if dashi_messaging:

            dashi_name = self.CFG.get_safe("highavailability.dashi_name")
            if not dashi_name:
                raise Exception("dashi_name unknown")
            dashi_uri = self.CFG.get_safe("highavailability.dashi_uri")
            if not dashi_uri:
                rabbit_host = self.CFG.get_safe("server.amqp.host")
                rabbit_user = self.CFG.get_safe("server.amqp.username")
                rabbit_pass = self.CFG.get_safe("server.amqp.password")

                if not (rabbit_host and rabbit_user and rabbit_pass):
                    raise Exception("cannot form dashi URI")

                dashi_uri = "amqp://%s:%s@%s/" % (rabbit_user, rabbit_pass,
                                                  rabbit_host)
            dashi_exchange = self.CFG.get_safe("highavailability.dashi_exchange")
            if not dashi_exchange:
                dashi_exchange = get_sys_name()

            self.dashi_handler = HADashiHandler(self, dashi_name, dashi_uri, dashi_exchange)

        else:
            self.dashi_handler = None