Search in sources :

Example 1 with ZookeeperInstance

use of org.apache.dubbo.registry.zookeeper.ZookeeperInstance in project dubbo by alibaba.

the class CuratorFrameworkUtils method build.

public static ServiceInstance build(org.apache.curator.x.discovery.ServiceInstance<ZookeeperInstance> instance) {
    String name = instance.getName();
    String host = instance.getAddress();
    int port = instance.getPort();
    ZookeeperInstance zookeeperInstance = instance.getPayload();
    DefaultServiceInstance serviceInstance = new DefaultServiceInstance(instance.getId(), name, host, port);
    serviceInstance.setMetadata(zookeeperInstance.getMetadata());
    return serviceInstance;
}
Also used : DefaultServiceInstance(org.apache.dubbo.registry.client.DefaultServiceInstance) ZookeeperInstance(org.apache.dubbo.registry.zookeeper.ZookeeperInstance)

Example 2 with ZookeeperInstance

use of org.apache.dubbo.registry.zookeeper.ZookeeperInstance in project dubbo by alibaba.

the class CuratorFrameworkUtils method build.

public static org.apache.curator.x.discovery.ServiceInstance<ZookeeperInstance> build(ServiceInstance serviceInstance) {
    ServiceInstanceBuilder builder = null;
    String serviceName = serviceInstance.getServiceName();
    String host = serviceInstance.getHost();
    int port = serviceInstance.getPort();
    Map<String, String> metadata = serviceInstance.getMetadata();
    String id = generateId(host, port);
    ZookeeperInstance zookeeperInstance = new ZookeeperInstance(null, serviceName, metadata);
    try {
        builder = builder().id(id).name(serviceName).address(host).port(port).payload(zookeeperInstance);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return builder.build();
}
Also used : ZookeeperInstance(org.apache.dubbo.registry.zookeeper.ZookeeperInstance) ServiceInstanceBuilder(org.apache.curator.x.discovery.ServiceInstanceBuilder)

Aggregations

ZookeeperInstance (org.apache.dubbo.registry.zookeeper.ZookeeperInstance)2 ServiceInstanceBuilder (org.apache.curator.x.discovery.ServiceInstanceBuilder)1 DefaultServiceInstance (org.apache.dubbo.registry.client.DefaultServiceInstance)1