当前位置: 首页>>代码示例>>Python>>正文


Python ResourceAgentClient._get_agent_process_id方法代码示例

本文整理汇总了Python中pyon.agent.agent.ResourceAgentClient._get_agent_process_id方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceAgentClient._get_agent_process_id方法的具体用法?Python ResourceAgentClient._get_agent_process_id怎么用?Python ResourceAgentClient._get_agent_process_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyon.agent.agent.ResourceAgentClient的用法示例。


在下文中一共展示了ResourceAgentClient._get_agent_process_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: prepare

# 需要导入模块: from pyon.agent.agent import ResourceAgentClient [as 别名]
# 或者: from pyon.agent.agent.ResourceAgentClient import _get_agent_process_id [as 别名]
    def prepare(self, will_launch=True):
        """
        Prepare (validate) an agent for launch, fetching all associated resources

        @param will_launch - whether the running status should be checked -- set false if just generating config
        """
        assert self.agent_instance_obj

        # fetch caches just in time
        if any([not self.RR2.has_cached_predicate(x) for x in self._predicates_to_cache()]):
            self._update_cached_predicates()

        if any([not self.RR2.has_cached_resource(x) for x in self._resources_to_cache()]):
            self._update_cached_resources()

        # validate the associations, then pick things up
        self._collect_agent_instance_associations()

        if will_launch:
            # if there is an agent pid then assume that a drive is already started
            agent_process_id = ResourceAgentClient._get_agent_process_id(self._get_device()._id)
            if agent_process_id:
                raise BadRequest("Agent Instance already running for this device pid: %s" %
                                 str(agent_process_id))

        self.will_launch = will_launch
        config = self.generate_config()
        return config
开发者ID:Bobfrat,项目名称:coi-services,代码行数:30,代码来源:agent_configuration_builder.py

示例2: __init__

# 需要导入模块: from pyon.agent.agent import ResourceAgentClient [as 别名]
# 或者: from pyon.agent.agent.ResourceAgentClient import _get_agent_process_id [as 别名]
    def __init__(self, read_process_fn=None, resource_id='', desired_state=None, *args, **kwargs):

        agent_process_id = ResourceAgentClient._get_agent_process_id(resource_id)

        super(AgentProcessStateGate, self).__init__(read_process_fn,
                                                    agent_process_id,
                                                    desired_state,
                                                    *args, **kwargs)
开发者ID:MatthewArrott,项目名称:coi-services,代码行数:10,代码来源:helpers.py

示例3: test_get_agent_client_noprocess

# 需要导入模块: from pyon.agent.agent import ResourceAgentClient [as 别名]
# 或者: from pyon.agent.agent.ResourceAgentClient import _get_agent_process_id [as 别名]
    def test_get_agent_client_noprocess(self):
        inst_device_id = self.RR2.create(any_old(RT.InstrumentDevice))

        iap = ResourceAgentClient._get_agent_process_id(inst_device_id)

        # should be no running agent
        self.assertIsNone(iap)

        # should raise NotFound
        self.assertRaises(NotFound, ResourceAgentClient, inst_device_id)
开发者ID:edwardhunter,项目名称:coi-services,代码行数:12,代码来源:test_agent_launch_ops.py

示例4: base_activateInstrumentSample

# 需要导入模块: from pyon.agent.agent import ResourceAgentClient [as 别名]
# 或者: from pyon.agent.agent.ResourceAgentClient import _get_agent_process_id [as 别名]

#.........这里部分代码省略.........
        print  'Data set for data_product_id1 = %s' % dataset_ids[0]
        self.parsed_dataset = dataset_ids[0]


        dp_obj = IonObject(RT.DataProduct,
                           name='the raw data',
                           description='raw stream test')

        data_product_id2 = self.dpclient.create_data_product(data_product=dp_obj,
                                                             stream_definition_id=raw_stream_def_id)
        print  'new dp_id = %s' % str(data_product_id2)

        self.damsclient.assign_data_product(input_resource_id=instDevice_id, data_product_id=data_product_id2)

        self.dpclient.activate_data_product_persistence(data_product_id=data_product_id2)

        # Retrieve the id of the OUTPUT stream from the out Data Product
        stream_ids, _ = self.rrclient.find_objects(data_product_id2, PRED.hasStream, None, True)
        print  'Data product streams2 = %s' % str(stream_ids)

        # Retrieve the id of the OUTPUT stream from the out Data Product
        dataset_ids, _ = self.rrclient.find_objects(data_product_id2, PRED.hasDataset, RT.Dataset, True)
        print  'Data set for data_product_id2 = %s' % dataset_ids[0]
        self.raw_dataset = dataset_ids[0]

        # add start/stop for instrument agent
        gevent.joinall([gevent.spawn(lambda:
            self.imsclient.start_instrument_agent_instance(instrument_agent_instance_id=instAgentInstance_id))])
        self.addCleanup(self.imsclient.stop_instrument_agent_instance,
                        instrument_agent_instance_id=instAgentInstance_id)

        #wait for start
        inst_agent_instance_obj = self.imsclient.read_instrument_agent_instance(instAgentInstance_id)
        agent_process_id = ResourceAgentClient._get_agent_process_id(instDevice_id)

        print "Agent process id is '%s'" % str(agent_process_id)
        self.assertTrue(agent_process_id)
        gate = ProcessStateGate(self.processdispatchclient.read_process,
                                agent_process_id,
                                ProcessStateEnum.RUNNING)

        if not expect_launch:
            self.assertFalse(gate.await(30), "The instance (%s) of bogus instrument agent spawned in 30 seconds ?!?" %
                                             agent_process_id)
            return

        self.assertTrue(gate.await(30), "The instrument agent instance (%s) did not spawn in 30 seconds" %
                                        agent_process_id)


        print "Instrument Agent Instance successfully triggered ProcessStateGate as RUNNING"

        #print  'Instrument agent instance obj: = %s' % str(inst_agent_instance_obj)

        # Start a resource agent client to talk with the instrument agent.
        self._ia_client = ResourceAgentClient(instDevice_id,
                                              to_name=agent_process_id,
                                              process=FakeProcess())

        print "ResourceAgentClient created: %s" % str(self._ia_client)

        print "Sending command=ResourceAgentEvent.INITIALIZE"
        cmd = AgentCommand(command=ResourceAgentEvent.INITIALIZE)

        if not expect_command:
            self.assertRaises(ServerError, self._ia_client.execute_agent, cmd)
开发者ID:ednad,项目名称:coi-services,代码行数:70,代码来源:test_driver_egg.py

示例5: _start_subscriber_process_lifecycle_event

# 需要导入模块: from pyon.agent.agent import ResourceAgentClient [as 别名]
# 或者: from pyon.agent.agent.ResourceAgentClient import _get_agent_process_id [as 别名]
    def _start_subscriber_process_lifecycle_event(self, origin):
        """
        @param origin    Child's resource_id. The associated PID retrieved via
                         ResourceAgentClient._get_agent_process_id is used for
                         the event subscriber itself, but we still index
                         _event_subscribers with the given origin.
        """
        def _got_process_lifecycle_event(evt, *args, **kwargs):
            with self._lock:
                if not self._active:
                    log.warn("%r: _got_process_lifecycle_event called but "
                             "manager has been destroyed",
                             self._platform_id)
                    return

                if evt.type_ != "ProcessLifecycleEvent":
                    log.trace("%r: ignoring event type %r. Only handle "
                              "ProcessLifecycleEvent directly.",
                              self._platform_id, evt.type_)
                    return

                # evt.origin is a PID
                pid = evt.origin

                if not pid in self._rids:
                    log.warn("%r: OOIION-1077 ignoring event from pid=%r. "
                             "Expecting one of %s",
                             self._platform_id, pid, self._rids.keys())
                    return

                origin = self._rids[pid]

                # # Before the _rids mapping, a preliminary mechanism to check
                # # whether the event came from the expected origin relied on
                # # the process ID having origin as a substring:
                #
                # if not origin in pid:
                #     log.warn("%r: OOIION-1077 ignoring event from origin %r. "
                #              "Expecting an origin containing %r",
                #              self._platform_id, pid, origin)
                #     return
                # # BUT this was definitely weak. Although the PID for an
                # # initial agent process seems to satisfy this assumption,
                # # this is not anymore the case upon a re-start of that agent.

                log.debug("%r: OOIION-1077  _got_process_lifecycle_event: "
                          "pid=%r origin=%r state=%r(%s)",
                          self._platform_id, pid, origin,
                          ProcessStateEnum._str_map[evt.state], evt.state)

                if evt.state is ProcessStateEnum.TERMINATED:
                    self._device_terminated_event(origin, pid)

        # use associated process ID for the subscription:
        pid = ResourceAgentClient._get_agent_process_id(origin)

        if pid is None:
            log.warn("%r: OOIION-1077 ResourceAgentClient._get_agent_process_id"
                     " returned None for origin=%r. Subscriber not created.",
                     self._platform_id, origin)
            return

        sub = self._agent._create_event_subscriber(event_type="ProcessLifecycleEvent",
                                                   origin_type='DispatchedProcess',
                                                   origin=pid,
                                                   callback=_got_process_lifecycle_event)

        with self._lock:
            # but note that we use the given origin as index in _event_subscribers:
            self._event_subscribers[origin] = sub

            # and capture the pid -> origin mapping:
            self._rids[pid] = origin

        log.debug("%r: OOIION-1077 registered ProcessLifecycleEvent subscriber "
                  "with pid=%r (origin=%r)",
                  self._platform_id, pid, origin)
开发者ID:Bobfrat,项目名称:coi-services,代码行数:79,代码来源:status_manager.py


注:本文中的pyon.agent.agent.ResourceAgentClient._get_agent_process_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。