def my_zk(): config = ApplicationConfig('test_rpclib') service_interface = 'com.yytcloud.platform.service.api.IApplicationQueryService' # 该对象较重,有zookeeper的连接,需要保存使用 registry = ZookeeperRegistry('10.188.181.146:2181', config) # registry = MulticastRegistry('224.5.6.7:1234', config) user_provider = DubboClient(service_interface, registry, version='1.0.0',group='usertest_yytcloud_default') for i in range(1000): try: pk=user_provider.call("queryAllApplication") # pk = user_provider.queryCorpList() print(pk) # print(user_provider.getUserByCode('wuzq')) # print user_provider.getUser(123) # print user_provider.queryUser( # {u'age': 18, u'time': 1428463514153, u'sex': u'MAN', u'id': u'A003', u'name': u'zhangsan'}) # datas = user_provider.queryAll() # for key, user in datas.items(): # print user['name'] # print user_provider.isLimit('MAN', 'Joe') # print user_provider('getUser', 'A005') # print user_provider.notFunc() # print user_provider.gotException() except DubboClientError as client_error: print(client_error.message) print(client_error.data) time.sleep(5)
def test_config_init(): config = ApplicationConfig('test_register_config') service_interface = 'com.ofpay.demo.api.UserProvider' registry = ZookeeperRegistry('172.19.66.49:2181', config) user_provider = DubboClient(service_interface, registry, version='1.0.0') for i in range(10000): try: print user_provider.findOne() except DubboClientError, client_error: print client_error time.sleep(1)
def test_dubbo(): service_interface = 'com.ofpay.demo.api.UserProvider' # 该对象较重,有zookeeper的连接,需要保存使用 registry = ZookeeperRegistry('172.19.65.33:2181') user_provider = DubboClient(service_interface, registry, version='2.0') for x in range(number): user_provider.getUser('A003') user_provider.queryUser( {u'age': 18, u'time': 1428463514153, u'sex': u'MAN', u'id': u'A003', u'name': u'zhangsan'}) # user_provider.queryAll() user_provider.isLimit('MAN', 'Joe') user_provider('getUser', 'A005')
""" import time from dubbo_client import ZookeeperRegistry, DubboClient, DubboClientError, ApplicationConfig __author__ = 'caozupeng' if __name__ == '__main__': #config = ApplicationConfig('provider') #service_interface = 'com.jaycekon.dubbo.service.CityDubboService' config = ApplicationConfig('clife-bigdata-business-scene') service_interface = 'com.clife.bigdata.service.ai.sleep.SleepReportService' registry = ZookeeperRegistry('200.200.200.55:2181', config) user_provider = DubboClient(service_interface, registry, version='2.5.3', group='/clife-v4') for i in range(1000): try: print user_provider.getSleepReport(139, 68265, "2019-05-13", 0) #print user_provider.findCityByName('A003') # print user_provider.getUser(123) # print user_provider.queryUser( # {u'age': 18, u'time': 1428463514153, u'sex': u'MAN', u'id': u'A003', u'name': u'zhangsan'}) # datas = user_provider.queryAll() # for key, user in datas.items(): # print user['name'] # print user_provider.isLimit('MAN', 'Joe')
The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import time from dubbo_client import ZookeeperRegistry, DubboClient, DubboClientError, ApplicationConfig __author__ = 'caozupeng' if __name__ == '__main__': service_interface = 'com.clife.bigdate.service.CityDubboService' config = ApplicationConfig('clife-bigdata-business-scene') registry = ZookeeperRegistry('200.200.200.55:2181', config, version='2.5.3', group='/clife-v4') user_provider = DubboClient(service_interface, registry, version='2.5.3', group='/clife-v4') #(user_provider.findCityByName('A003'))
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import time from dubbo_client import ZookeeperRegistry, DubboClient, DubboClientError, ApplicationConfig __author__ = 'caozupeng' if __name__ == '__main__': config = ApplicationConfig('test_rpclib') service_interface = 'com.ofpay.demo.api.UserProvider' # 该对象较重,有zookeeper的连接,需要保存使用 registry = ZookeeperRegistry('115.28.74.185:2181', config) # registry = MulticastRegistry('224.5.6.7:1234', config) user_provider = DubboClient(service_interface, registry, version='2.0') for i in range(1000): try: print user_provider.getUser('A003') # print user_provider.getUser(123) # print user_provider.queryUser( # {u'age': 18, u'time': 1428463514153, u'sex': u'MAN', u'id': u'A003', u'name': u'zhangsan'}) # datas = user_provider.queryAll() # for key, user in datas.items(): # print user['name'] # print user_provider.isLimit('MAN', 'Joe') # print user_provider('getUser', 'A005') # print user_provider.notFunc() # print user_provider.gotException()
def zookeeper(): registry = ZookeeperRegistry('172.19.65.33:2181') registry.subscribe('com.ofpay.demo.api.UserProvider') print registry.get_provides('com.ofpay.demo.api.UserProvider')
def zookeeper(): registry = ZookeeperRegistry('172.19.65.33:2181') registry.subscribe('com.ofpay.demo.api.UserProvider') print registry.get_providers('com.ofpay.demo.api.UserProvider')
# coding=utf-8 import time from dubbo_client import ZookeeperRegistry, DubboClient, DubboClientError, ApplicationConfig, MulticastRegistry __author__ = 'caozupeng' """ 通过zookeeper发现服务端,然后进行测试调用 """ if __name__ == '__main__': # 等待注册的服务上线 time.sleep(5) config = ApplicationConfig('test_rpclib') service_interface = 'com.ofpay.demo.api.UserProvider' # 该对象较重,有zookeeper的连接,需要保存使用,“zookeeper”是hostname registry = ZookeeperRegistry('127.0.0.1:2181', config) # registry = MulticastRegistry('224.5.6.7:1234', config) user_provider = DubboClient(service_interface, registry, version='2.0') # 调用一千次,打印到输出中 for i in range(1000): try: # 获取A003编号的用户信息 print user_provider.getUser('A003') # 获取用户ID为123的用户信息 print user_provider.getUser(123) # 根据给定的一系列条件,json查询字符串查询用户信息 print user_provider.queryUser({ u'age': 18, u'time': 1428463514153, u'sex': u'MAN', u'id': u'A003',
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import time from dubbo_client import ZookeeperRegistry, DubboClient, DubboClientError, ApplicationConfig if __name__ == '__main__': config = ApplicationConfig('test_rpclib') service_interface = 'com.qianmi.kstore.provider.CustomerAddressProvider' # 该对象较重,有zookeeper的连接,需要保存使用 registry = ZookeeperRegistry('zookeeper:2181', config) # registry = MulticastRegistry('224.5.6.7:1234', config) user_provider = DubboClient(service_interface, registry, version='1.0') for i in range(1000): try: print user_provider.findAddressByCustomerId(1) # print user_provider.save(1, 3) except DubboClientError, client_error: print client_error.message print client_error.data time.sleep(5)
def test_zookeeper_registry(self): address = '127.0.0.1:2181' interface = 'dubbo.DubboService' registry = ZookeeperRegistry(address, application_config) registry.subscribe(interface) print(registry.get_providers(interface))
#!usr/bin/env python # -*- coding:utf-8 -*- """ @author: jayzhen @email: [email protected] @site: https://github.com/gitjayzhen @software: PyCharm & Python 2.7 @file: DubboClientTest.py @time: 2018/09/14 12:25 """ import time from dubbo_client import ApplicationConfig, ZookeeperRegistry, DubboClient from dubbo_client import DubboClientError config = ApplicationConfig('test_rpclib') service_interface = "com.auto.Interface.*" # registry包含了和zookeeper的连接,该对象需要缓存 registry = ZookeeperRegistry('*.*.*.*:2181', config) print registry.get_provides(service_interface) user_provider = DubboClient(service_interface, registry, version='2.5.3') for i in range(100): print user_provider("getAllfunctioninfo") time.sleep(5)
# coding=utf-8 import time from dubbo_client import ZookeeperRegistry, DubboClient, DubboClientError, ApplicationConfig, MulticastRegistry __author__ = 'caozupeng' if __name__ == '__main__': config = ApplicationConfig('test_rpclib') service_interface = 'com.ofpay.demo.api.UserProvider' # 该对象较重,有zookeeper的连接,需要保存使用 registry = ZookeeperRegistry('192.168.59.103:2181', config) # registry = MulticastRegistry('224.5.6.7:1234', config) user_provider = DubboClient(service_interface, registry, version='2.0') for i in range(1000): try: print user_provider.getUser('A003') print user_provider.getUser(123) print user_provider.queryUser({ u'age': 18, u'time': 1428463514153, u'sex': u'MAN', u'id': u'A003', u'name': u'zhangsan' }) datas = user_provider.queryAll() for key, user in datas.items(): print user['name'] print user_provider.isLimit('MAN', 'Joe') print user_provider('getUser', 'A005')