Search in sources :

Example 1 with ZookeeperRegistry

use of com.weibo.api.motan.registry.zookeeper.ZookeeperRegistry in project motan by weibocom.

the class ZkRegistryServiceTest method setUp.

@Before
public void setUp() throws Exception {
    Properties properties = new Properties();
    InputStream in = EmbeddedZookeeper.class.getResourceAsStream("/zoo.cfg");
    properties.load(in);
    int port = Integer.parseInt(properties.getProperty("clientPort"));
    in.close();
    URL zkUrl = new URL("zookeeper", "127.0.0.1", port, "com.weibo.api.motan.registry.RegistryService");
    URL clientUrl = new URL(MotanConstants.PROTOCOL_MOTAN, "127.0.0.1", 0, "com.weibo.motan.demoService");
    URL url1 = new URL(MotanConstants.PROTOCOL_MOTAN, "127.0.0.1", 8001, service1);
    URL url2 = new URL(MotanConstants.PROTOCOL_MOTAN, "127.0.0.1", 8002, service1);
    URL url3 = new URL(MotanConstants.PROTOCOL_MOTAN, "127.0.0.1", 8003, service2);
    embeddedZookeeper = new EmbeddedZookeeper();
    embeddedZookeeper.start();
    Thread.sleep(1000);
    zkClient = new ZkClient("127.0.0.1:" + port, 5000);
    ZookeeperRegistry registry = new ZookeeperRegistry(zkUrl, zkClient);
    registry.register(url1);
    registry.register(url2);
    registry.register(url3);
    registry.subscribe(clientUrl, null);
    registryService = new ZookeeperRegistryService(zkClient);
}
Also used : ZkClient(org.I0Itec.zkclient.ZkClient) ZookeeperRegistry(com.weibo.api.motan.registry.zookeeper.ZookeeperRegistry) InputStream(java.io.InputStream) Properties(java.util.Properties) URL(com.weibo.api.motan.rpc.URL) Before(org.junit.Before)

Aggregations

ZookeeperRegistry (com.weibo.api.motan.registry.zookeeper.ZookeeperRegistry)1 URL (com.weibo.api.motan.rpc.URL)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 ZkClient (org.I0Itec.zkclient.ZkClient)1 Before (org.junit.Before)1