Search in sources :

Example 6 with SubscriberRegistration

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

the class SofaRegistryServiceDiscovery method registerServiceWatcher.

protected void registerServiceWatcher(String serviceName, ServiceInstancesChangedListener listener) {
    Subscriber subscriber = subscribers.get(serviceName);
    if (null == subscriber) {
        final CountDownLatch latch = new CountDownLatch(1);
        SubscriberRegistration subscriberRegistration = new SubscriberRegistration(serviceName, (dataId, data) -> {
            handleRegistryData(dataId, data, listener, latch);
        });
        subscriberRegistration.setGroup(DEFAULT_GROUP);
        subscriberRegistration.setScopeEnum(ScopeEnum.global);
        subscriber = registryClient.register(subscriberRegistration);
        subscribers.put(serviceName, subscriber);
        waitAddress(serviceName, latch);
    }
}
Also used : Subscriber(com.alipay.sofa.registry.client.api.Subscriber) CountDownLatch(java.util.concurrent.CountDownLatch) SubscriberRegistration(com.alipay.sofa.registry.client.api.registration.SubscriberRegistration)

Aggregations

SubscriberRegistration (com.alipay.sofa.registry.client.api.registration.SubscriberRegistration)6 Subscriber (com.alipay.sofa.registry.client.api.Subscriber)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Configurator (com.alipay.sofa.registry.client.api.Configurator)1 RegistryClient (com.alipay.sofa.registry.client.api.RegistryClient)1 RegistryClientConfig (com.alipay.sofa.registry.client.api.RegistryClientConfig)1 SubscriberDataObserver (com.alipay.sofa.registry.client.api.SubscriberDataObserver)1 RegistryType (com.alipay.sofa.registry.client.api.model.RegistryType)1 ConfiguratorRegistration (com.alipay.sofa.registry.client.api.registration.ConfiguratorRegistration)1 PublisherRegistration (com.alipay.sofa.registry.client.api.registration.PublisherRegistration)1 DefaultRegistryClient (com.alipay.sofa.registry.client.provider.DefaultRegistryClient)1 DefaultRegistryClientConfigBuilder (com.alipay.sofa.registry.client.provider.DefaultRegistryClientConfigBuilder)1 ScopeEnum (com.alipay.sofa.registry.core.model.ScopeEnum)1 ProviderInfoListener (com.alipay.sofa.rpc.listener.ProviderInfoListener)1 NetUtil (io.seata.common.util.NetUtil)1 Configuration (io.seata.config.Configuration)1 ConfigurationFactory (io.seata.config.ConfigurationFactory)1 FILE_CONFIG_SPLIT_CHAR (io.seata.config.ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR)1 FILE_ROOT_REGISTRY (io.seata.config.ConfigurationKeys.FILE_ROOT_REGISTRY)1 RegistryService (io.seata.discovery.registry.RegistryService)1