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