Search in sources :

Example 1 with Publisher

use of com.alipay.sofa.registry.client.api.Publisher in project dubbo by apache.

the class SofaRegistryServiceDiscovery method doRegister.

@Override
public void doRegister(ServiceInstance serviceInstance) {
    SofaRegistryInstance sofaRegistryInstance = new SofaRegistryInstance(serviceInstance.getId(), serviceInstance.getHost(), serviceInstance.getPort(), serviceInstance.getServiceName(), serviceInstance.getMetadata());
    Publisher publisher = publishers.get(serviceInstance.getServiceName());
    this.serviceInstance = serviceInstance;
    if (null == publisher) {
        PublisherRegistration registration = new PublisherRegistration(serviceInstance.getServiceName());
        registration.setGroup(DEFAULT_GROUP);
        publisher = registryClient.register(registration, gson.toJson(sofaRegistryInstance));
        publishers.put(serviceInstance.getServiceName(), publisher);
    } else {
        publisher.republish(gson.toJson(sofaRegistryInstance));
    }
}
Also used : PublisherRegistration(com.alipay.sofa.registry.client.api.registration.PublisherRegistration) Publisher(com.alipay.sofa.registry.client.api.Publisher)

Example 2 with Publisher

use of com.alipay.sofa.registry.client.api.Publisher in project dubbo by alibaba.

the class SofaRegistryServiceDiscovery method doRegister.

@Override
public void doRegister(ServiceInstance serviceInstance) {
    SofaRegistryInstance sofaRegistryInstance = new SofaRegistryInstance(serviceInstance.getId(), serviceInstance.getHost(), serviceInstance.getPort(), serviceInstance.getServiceName(), serviceInstance.getMetadata());
    Publisher publisher = publishers.get(serviceInstance.getServiceName());
    this.serviceInstance = serviceInstance;
    if (null == publisher) {
        PublisherRegistration registration = new PublisherRegistration(serviceInstance.getServiceName());
        registration.setGroup(DEFAULT_GROUP);
        publisher = registryClient.register(registration, gson.toJson(sofaRegistryInstance));
        publishers.put(serviceInstance.getServiceName(), publisher);
    } else {
        publisher.republish(gson.toJson(sofaRegistryInstance));
    }
}
Also used : PublisherRegistration(com.alipay.sofa.registry.client.api.registration.PublisherRegistration) Publisher(com.alipay.sofa.registry.client.api.Publisher)

Aggregations

Publisher (com.alipay.sofa.registry.client.api.Publisher)2 PublisherRegistration (com.alipay.sofa.registry.client.api.registration.PublisherRegistration)2