本文整理汇总了Python中pyon.net.endpoint.RPCClient类的典型用法代码示例。如果您正苦于以下问题:Python RPCClient类的具体用法?Python RPCClient怎么用?Python RPCClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RPCClient类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
parser = argparse.ArgumentParser(description="CC Control script")
parser.add_argument("pidfile", help="pidfile to use. If not specified, uses the first one found.")
parser.add_argument("command", help="command to send to the container agent", choices=IContainerAgent.names())
parser.add_argument("commandargs", metavar="arg", nargs="*", help="arguments to the command being sent")
opts = parser.parse_args()
pidfile = opts.pidfile
if not pidfile:
raise Exception("No pidfile specified")
parms = {}
with open(pidfile, "r") as pf:
parms = msgpack.loads(pf.read())
assert parms, "No content in pidfile"
node, ioloop = make_node(parms["messaging"])
cc = RPCClient(node=node, name=(parms["container-xp"], parms["container-agent"]))
# make a manual call - this is to avoid having to have the IonObject for the call
methdefs = [x[1] for x in IContainerAgent.namesAndDescriptions() if x[0] == opts.command]
assert len(methdefs) == 1
arg_names = methdefs[0].positional # ('name', 'module', 'cls', 'config')
msg_args = msgpack.dumps(
dict(zip(arg_names, opts.commandargs))
) # ('name', <usrinp1>, 'cls', <usrinp2>) -> { 'name' : <usrinp1>, 'cls': <usrinp2> }
retval = cc.request(msg_args, op=opts.command)
print "Returned", retval
node.client.close()
开发者ID:blazetopher,项目名称:pyon,代码行数:33,代码来源:control_cc.py
示例2: register_dataset
def register_dataset(self, data_product_id=''):
procs,_ = self.clients.resource_registry.find_resources(restype=RT.Process, id_only=True)
pid = None
for p in procs:
if 'registration_worker' in p:
pid = p
if not pid:
log.warning('No registration worker found')
return
rpc_cli = RPCClient(to_name=pid)
rpc_cli.request({'data_product_id':data_product_id}, op='register_dap_dataset')
开发者ID:edwardhunter,项目名称:coi-services,代码行数:11,代码来源:dataset_management_service.py
示例3: __init__
def __init__(self, process=None, **kwargs):
self._process = process
if 'to_name' in kwargs and kwargs['to_name'] is not None and not isinstance(kwargs['to_name'], BaseTransport):
container = (hasattr(self._process, 'container') and self._process.container) or self._get_container_instance()
if container:
kwargs['to_name'] = container.create_xn_service(kwargs['to_name'])
else:
log.info('No container at ProcessRPCClient init time, will wait until message send to upgrade to Exchange Object')
RPCClient.__init__(self, **kwargs)
开发者ID:mkl-,项目名称:scioncc,代码行数:11,代码来源:endpoint.py
示例4: test_rpc_client
def test_rpc_client(self, iomock):
node = Mock(spec=NodeB)
rpcc = RPCClient(node=node, to_name="simply", iface=ISimpleInterface)
rpcc.node.channel.return_value = self._setup_mock_channel()
self.assertTrue(hasattr(rpcc, "simple"))
ret = rpcc.simple(one="zap", two="zip")
iomock.assert_called_once_with("SimpleInterface_simple_in", one="zap", two="zip")
self.assertEquals(ret, "bidirmsg")
开发者ID:ooici-dm,项目名称:pyon,代码行数:12,代码来源:test_endpoint.py
示例5: __init__
def __init__(self, process=None, **kwargs):
self._process = process
self._declare_name = kwargs.pop("declare_name", True) # MM: Prevent senders from declaring with wrong AMQP properties
if 'to_name' in kwargs and kwargs['to_name'] is not None and not isinstance(kwargs['to_name'], BaseTransport):
container = (hasattr(self._process, 'container') and self._process.container) or self._get_container_instance()
if container:
if self._declare_name:
# NOTE: What if this is a process or agent client? Cannot declare with known properties.
# Client creates the service XN
kwargs['to_name'] = container.create_service_xn(kwargs['to_name'])
else:
log.info('No container at ProcessRPCClient init time, will wait until message send to upgrade to Exchange Object')
RPCClient.__init__(self, **kwargs)
开发者ID:edwardhunter,项目名称:scioncc,代码行数:15,代码来源:endpoint.py
示例6: create_endpoint
def create_endpoint(self, to_name=None, existing_channel=None, **kwargs):
if not self._process:
raise StandardError("No Process specified")
newkwargs = kwargs.copy()
newkwargs['process'] = self._process
return RPCClient.create_endpoint(self, to_name, existing_channel, **newkwargs)
开发者ID:oldpatricka,项目名称:pyon,代码行数:7,代码来源:endpoint.py
示例7: register_dataset
def register_dataset(self, dataset_id='', external_data_product_name=''):
dataset_obj = self.read_dataset(dataset_id)
dataset_obj.registered = True
self.update_dataset(dataset=dataset_obj)
external_data_product_name = external_data_product_name or dataset_obj.name
procs,_ = self.clients.resource_registry.find_resources(restype=RT.Process, id_only=True)
pid = None
for p in procs:
if 'registration_worker' in p:
pid = p
if not pid:
log.warning('No registration worker found')
return
rpc_cli = RPCClient(to_name=pid)
rpc_cli.request({'dataset_id':dataset_id, 'data_product_name':external_data_product_name}, op='register_dap_dataset')
开发者ID:jamie-cyber1,项目名称:coi-services,代码行数:16,代码来源:dataset_management_service.py
示例8: create_endpoint
def create_endpoint(self, to_name=None, existing_channel=None, **kwargs):
if not self._process:
raise StandardError("No Process specified")
# upgrade to exchange object
if to_name is None and not isinstance(self._send_name, BaseTransport):
container = self._process.container or self._get_container_instance()
if not container:
raise StandardError("No container found, can not upgrade to ExchangeObject")
if self._declare_name:
self._send_name = container.create_service_xn(self._send_name)
# upgrade one timers too
if to_name is not None and not isinstance(to_name, BaseTransport):
container = self._process.container or self._get_container_instance()
if not container:
raise StandardError("No container found, can not upgrade to ExchangeObject")
if self._declare_name:
to_name = container.create_service_xn(to_name)
newkwargs = kwargs.copy()
newkwargs['process'] = self._process
return RPCClient.create_endpoint(self, to_name, existing_channel, **newkwargs)
开发者ID:edwardhunter,项目名称:scioncc,代码行数:25,代码来源:endpoint.py
示例9: TestProcessInt
class TestProcessInt(IonIntegrationTestCase):
def setUp(self):
self._start_container()
self.pid = self.container.spawn_process('fake', 'pyon.ion.test.test_process', 'FakeService')
self.fsclient = RPCClient(to_name='fake_service')
@unittest.skip("timeouts removed 18 oct 2012")
def test_timeout_with_messaging(self):
with self.assertRaises(IonTimeout) as cm:
self.fsclient.request({}, op='takes_too_long', timeout=5)
self.assertIn('execute in allotted time', cm.exception.message)
@unittest.skipIf(os.getenv('CEI_LAUNCH_TEST', False), "Test reaches into container, doesn't work with CEI")
@unittest.skip("heartbeat failing process is disabled")
def test_heartbeat_failure(self):
self.patch_cfg('pyon.ion.process.CFG', {'cc':{'timeout':{'heartbeat_proc_count_threshold':2, 'heartbeat':1.0}}})
svc = self.container.proc_manager.procs[self.pid]
ip = svc._process
stopar = AsyncResult()
self.container.proc_manager.add_proc_state_changed_callback(lambda *args: stopar.set(args))
noticear = AsyncResult() # notify us when the call has been made
ar = ip._routing_call(svc.takes_too_long, None, noticear=noticear)
noticear.get(timeout=10) # wait for the call to be made
# heartbeat a few times so we trigger the failure soon
for x in xrange(2):
ip.heartbeat()
# wait for ip thread to kick over
ip._ctrl_thread.join(timeout=5)
# now wait for notice proc got canned
stopargs = stopar.get(timeout=5)
self.assertEquals(stopargs, (svc, ProcessStateEnum.FAILED, self.container))
# should've shut down, no longer in container's process list
self.assertEquals(len(self.container.proc_manager.procs), 0)
开发者ID:ateranishi,项目名称:pyon,代码行数:42,代码来源:test_process.py
示例10: run_test
def run_test():
x509_cert = {
"certificate": """-----BEGIN CERTIFICATE-----
MIIEMzCCAxugAwIBAgICBQAwDQYJKoZIhvcNAQEFBQAwajETMBEGCgmSJomT8ixkARkWA29yZzEX
MBUGCgmSJomT8ixkARkWB2NpbG9nb24xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdDSUxvZ29uMRsw
GQYDVQQDExJDSUxvZ29uIEJhc2ljIENBIDEwHhcNMTAxMTE4MjIyNTA2WhcNMTAxMTE5MTAzMDA2
WjBvMRMwEQYKCZImiZPyLGQBGRMDb3JnMRcwFQYKCZImiZPyLGQBGRMHY2lsb2dvbjELMAkGA1UE
BhMCVVMxFzAVBgNVBAoTDlByb3RlY3ROZXR3b3JrMRkwFwYDVQQDExBSb2dlciBVbndpbiBBMjU0
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6QhsWxhUXbIxg+1ZyEc7d+hIGvchVmtb
g0kKLmivgoVsA4U7swNDRH6svW242THta0oTf6crkRx7kOKg6jma2lcAC1sjOSddqX7/92ChoUPq
7LWt2T6GVVA10ex5WAeB/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8mMwOFP7GWzSSfaWLILoXcci1ZbheJ9607faxKrvXCEpw
xw36FfbgPfeuqUdI5E6fswKBgFIxCu99gnSNulEWemL3LgWx3fbHYIZ9w6MZKxIheS9AdByhp6px
lt1zeKu4hRCbdtaha/TMDbeV1Hy7lA4nmU1s7dwojWU+kSZVcrxLp6zxKCy6otCpA1aOccQIlxll
Vc2vO7pUIp3kqzRd5ovijfMB5nYwygTB4FwepWY5eVfXAoGBAIqrLKhRzdpGL0Vp2jwtJJiMShKm
WJ1c7fBskgAVk8jJzbEgMxuVeurioYqj0Cn7hFQoLc+npdU5byRti+4xjZBXSmmjo4Y7ttXGvBrf
c2bPOQRAYZyD2o+/MHBDsz7RWZJoZiI+SJJuE4wphGUsEbI2Ger1QW9135jKp6BsY2qZ
-----END RSA PRIVATE KEY-----""",
}
container = cc.Container()
container.start() # :(
client = RPCClient(node=container.node, name="app_integration", iface=IAppIntegrationService)
print "Before start client"
container.start_client("app_integration", client)
print "Before register user"
res = client.register_user(x509_cert["certificate"], x509_cert["rsa_private_key"])
print "After register user: " + str(res)
container.stop()
开发者ID:newbrough,项目名称:pyon,代码行数:61,代码来源:app_integration_service.py
示例11: __init__
def __init__(self, process=None, **kwargs):
self._process = process
RPCClient.__init__(self, **kwargs)
开发者ID:oldpatricka,项目名称:pyon,代码行数:3,代码来源:endpoint.py
示例12: __init__
def __init__(self, to_name=None, node=None, **kwargs):
to_name = to_name or __name__ + "test"
RPCClient.__init__(self, to_name=to_name, node=node, **kwargs)
开发者ID:dstuebe,项目名称:coi-services,代码行数:3,代码来源:test_process_dispatcher.py
示例13: setUp
def setUp(self):
self._start_container()
self.pid = self.container.spawn_process('fake', 'pyon.ion.test.test_process', 'FakeService')
self.fsclient = RPCClient(to_name='fake_service')
开发者ID:mkl-,项目名称:scioncc,代码行数:4,代码来源:test_process.py
示例14: stats
def stats(cls,pid):
'''
RPC Method for querying a Transform's internal statistics
'''
rpc_cli = RPCClient(to_name=pid)
return rpc_cli.request({},op='_stat')
开发者ID:blazetopher,项目名称:coi-services,代码行数:6,代码来源:transform.py
注:本文中的pyon.net.endpoint.RPCClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论