Search in sources :

Example 21 with Registry

use of org.apache.dubbo.registry.Registry in project dubbo by alibaba.

the class Offline method offline.

public static boolean offline(String servicePattern) {
    boolean hasService = false;
    Collection<ProviderModel> providerModelList = serviceRepository.getExportedServices();
    for (ProviderModel providerModel : providerModelList) {
        if (providerModel.getServiceMetadata().getDisplayServiceKey().matches(servicePattern)) {
            hasService = true;
            List<ProviderModel.RegisterStatedURL> statedUrls = providerModel.getStatedUrl();
            for (ProviderModel.RegisterStatedURL statedURL : statedUrls) {
                if (statedURL.isRegistered()) {
                    Registry registry = registryFactory.getRegistry(statedURL.getRegistryUrl());
                    registry.unregister(statedURL.getProviderUrl());
                    statedURL.setRegistered(false);
                }
            }
        }
    }
    return hasService;
}
Also used : Registry(org.apache.dubbo.registry.Registry) ProviderModel(org.apache.dubbo.rpc.model.ProviderModel)

Example 22 with Registry

use of org.apache.dubbo.registry.Registry in project dubbo by alibaba.

the class RedisRegistryTest method testAvailableWithBackup.

@Test
public void testAvailableWithBackup() {
    URL url = URL.valueOf("redis://redisOne:8880").addParameter(BACKUP_KEY, "redisTwo:8881");
    Registry registry = new RedisRegistryFactory().createRegistry(url);
    Registry finalRegistry = registry;
    assertThrows(JedisConnectionException.class, () -> finalRegistry.isAvailable());
    url = URL.valueOf(this.registryUrl.toFullString()).addParameter(BACKUP_KEY, "redisTwo:8881");
    registry = new RedisRegistryFactory().createRegistry(url);
    assertThat(registry.isAvailable(), is(true));
}
Also used : AbstractRegistry(org.apache.dubbo.registry.support.AbstractRegistry) Registry(org.apache.dubbo.registry.Registry) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Example 23 with Registry

use of org.apache.dubbo.registry.Registry in project dubbo by alibaba.

the class MultipleRegistry method subscribe.

@Override
public void subscribe(URL url, NotifyListener listener) {
    MultipleNotifyListenerWrapper multipleNotifyListenerWrapper = new MultipleNotifyListenerWrapper(listener);
    multipleNotifyListenerMap.put(listener, multipleNotifyListenerWrapper);
    for (Registry registry : referenceRegistries.values()) {
        SingleNotifyListener singleNotifyListener = new SingleNotifyListener(multipleNotifyListenerWrapper, registry);
        multipleNotifyListenerWrapper.putRegistryMap(registry.getUrl(), singleNotifyListener);
        registry.subscribe(url, singleNotifyListener);
    }
    super.subscribe(url, multipleNotifyListenerWrapper);
}
Also used : AbstractRegistry(org.apache.dubbo.registry.support.AbstractRegistry) Registry(org.apache.dubbo.registry.Registry)

Example 24 with Registry

use of org.apache.dubbo.registry.Registry in project dubbo by alibaba.

the class MultipleRegistry method initReferenceRegistry.

protected void initReferenceRegistry(URL url, Map<String, Registry> registryMap) {
    origReferenceRegistryURLs = url.getParameter(REGISTRY_FOR_REFERENCE, new ArrayList<String>());
    effectReferenceRegistryURLs = this.filterReferenceRegistry(origReferenceRegistryURLs);
    for (String tmpUrl : effectReferenceRegistryURLs) {
        if (registryMap.get(tmpUrl) != null) {
            referenceRegistries.put(tmpUrl, registryMap.get(tmpUrl));
            continue;
        }
        Registry registry = getRegistry(URL.valueOf(tmpUrl));
        registryMap.put(tmpUrl, registry);
        referenceRegistries.put(tmpUrl, registry);
    }
}
Also used : ArrayList(java.util.ArrayList) AbstractRegistry(org.apache.dubbo.registry.support.AbstractRegistry) Registry(org.apache.dubbo.registry.Registry)

Example 25 with Registry

use of org.apache.dubbo.registry.Registry in project dubbo by alibaba.

the class MultipleRegistry method destroy.

@Override
public void destroy() {
    Set<Registry> registries = new HashSet<Registry>(serviceRegistries.values());
    registries.addAll(referenceRegistries.values());
    for (Registry registry : registries) {
        registry.destroy();
    }
}
Also used : AbstractRegistry(org.apache.dubbo.registry.support.AbstractRegistry) Registry(org.apache.dubbo.registry.Registry) HashSet(java.util.HashSet)

Aggregations

Registry (org.apache.dubbo.registry.Registry)26 Test (org.junit.jupiter.api.Test)9 AbstractRegistry (org.apache.dubbo.registry.support.AbstractRegistry)8 URL (org.apache.dubbo.common.URL)7 ArrayList (java.util.ArrayList)3 Status (org.apache.dubbo.common.status.Status)3 ProviderModel (org.apache.dubbo.rpc.model.ProviderModel)3 RegistryStatusChecker (org.apache.dubbo.registry.status.RegistryStatusChecker)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ConfigurationException (org.apache.dubbo.admin.common.exception.ConfigurationException)1 QOS_HOST (org.apache.dubbo.common.constants.QosConstants.QOS_HOST)1 QOS_PORT (org.apache.dubbo.common.constants.QosConstants.QOS_PORT)1 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)1 RegistryConfig (org.apache.dubbo.config.RegistryConfig)1 ServiceConfig (org.apache.dubbo.config.ServiceConfig)1 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)1 DemoService (org.apache.dubbo.config.spring.api.DemoService)1 MockRegistry (org.apache.dubbo.config.spring.registry.MockRegistry)1 NotifyListener (org.apache.dubbo.registry.NotifyListener)1