use of org.apache.dubbo.registry.Registry in project dubbo by alibaba.
the class ZookeeperRegistryTest method testStatusChecker.
@Disabled
@Test
public /*
This UT is unstable, consider remove it later.
@see https://github.com/apache/dubbo/issues/1787
*/
void testStatusChecker() {
RegistryStatusChecker registryStatusChecker = new RegistryStatusChecker();
Status status = registryStatusChecker.check();
assertThat(status.getLevel(), is(Status.Level.UNKNOWN));
Registry registry = zookeeperRegistryFactory.getRegistry(registryUrl);
assertThat(registry, not(nullValue()));
status = registryStatusChecker.check();
assertThat(status.getLevel(), is(Status.Level.ERROR));
registry.register(serviceUrl);
status = registryStatusChecker.check();
assertThat(status.getLevel(), is(Status.Level.OK));
}
use of org.apache.dubbo.registry.Registry in project dubbo by alibaba.
the class RegistryProtocol method export.
@Override
public <T> Exporter<T> export(final Invoker<T> originInvoker) throws RpcException {
URL registryUrl = getRegistryUrl(originInvoker);
// url to export locally
URL providerUrl = getProviderUrl(originInvoker);
// Subscribe the override data
// FIXME When the provider subscribes, it will affect the scene : a certain JVM exposes the service and call
// the same service. Because the subscribed is cached key with the name of the service, it causes the
// subscription information to cover.
final URL overrideSubscribeUrl = getSubscribedOverrideUrl(providerUrl);
final OverrideListener overrideSubscribeListener = new OverrideListener(overrideSubscribeUrl, originInvoker);
overrideListeners.put(overrideSubscribeUrl, overrideSubscribeListener);
providerUrl = overrideUrlWithConfig(providerUrl, overrideSubscribeListener);
// export invoker
final ExporterChangeableWrapper<T> exporter = doLocalExport(originInvoker, providerUrl);
// url to registry
final Registry registry = getRegistry(originInvoker);
final URL registeredProviderUrl = getUrlToRegistry(providerUrl, registryUrl);
// decide if we need to delay publish
boolean register = providerUrl.getParameter(REGISTER_KEY, true);
if (register) {
registry.register(registeredProviderUrl);
}
// register stated url on provider model
registerStatedUrl(registryUrl, registeredProviderUrl, register);
exporter.setRegisterUrl(registeredProviderUrl);
exporter.setSubscribeUrl(overrideSubscribeUrl);
// Deprecated! Subscribe to override rules in 2.6.x or before.
registry.subscribe(overrideSubscribeUrl, overrideSubscribeListener);
notifyExport(exporter);
// Ensure that a new exporter instance is returned every time export
return new DestroyableExporter<>(exporter);
}
use of org.apache.dubbo.registry.Registry in project dubbo by alibaba.
the class MigrationInvoker method doReSubscribe.
private void doReSubscribe(ClusterInvoker<T> invoker, URL newSubscribeUrl) {
DynamicDirectory<T> directory = (DynamicDirectory<T>) invoker.getDirectory();
URL oldSubscribeUrl = directory.getRegisteredConsumerUrl();
Registry registry = directory.getRegistry();
registry.unregister(directory.getRegisteredConsumerUrl());
directory.unSubscribe(RegistryProtocol.toSubscribeUrl(oldSubscribeUrl));
if (directory.isShouldRegister()) {
registry.register(directory.getRegisteredConsumerUrl());
directory.setRegisteredConsumerUrl(newSubscribeUrl);
}
directory.buildRouterChain(newSubscribeUrl);
directory.subscribe(RegistryProtocol.toSubscribeUrl(newSubscribeUrl));
}
use of org.apache.dubbo.registry.Registry in project dubbo by alibaba.
the class ConsulRegistryTest method testStatusChecker.
@Test
public void testStatusChecker() {
RegistryStatusChecker registryStatusChecker = new RegistryStatusChecker();
Status status = registryStatusChecker.check();
assertThat(status.getLevel(), is(Status.Level.UNKNOWN));
Registry registry = consulRegistryFactory.getRegistry(registryUrl);
assertThat(registry, not(nullValue()));
status = registryStatusChecker.check();
assertThat(status.getLevel(), is(Status.Level.OK));
registry.register(serviceUrl);
status = registryStatusChecker.check();
assertThat(status.getLevel(), is(Status.Level.OK));
}
use of org.apache.dubbo.registry.Registry in project dubbo by alibaba.
the class AbstractRegistryFactoryTest method testRegistryFactoryGroupCache.
@Test
public void testRegistryFactoryGroupCache() throws Exception {
Registry registry1 = registryFactory.getRegistry(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=aaa"));
Registry registry2 = registryFactory.getRegistry(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=bbb"));
Assertions.assertNotSame(registry1, registry2);
}
Aggregations