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);
}
Aggregations