use of org.apache.dubbo.registry.client.ServiceDiscovery in project dubbo by alibaba.
the class ZookeeperServiceDiscoveryFactoryTest method testCreateZookeeperServiceDiscovery.
@Test
public void testCreateZookeeperServiceDiscovery() {
final URL url = URL.valueOf("test://test:80");
final ZookeeperServiceDiscoveryFactory factory = new ZookeeperServiceDiscoveryFactory();
ServiceDiscovery discovery = factory.createDiscovery(url);
Assertions.assertTrue(discovery instanceof ZookeeperServiceDiscovery);
}
use of org.apache.dubbo.registry.client.ServiceDiscovery in project dubbo by alibaba.
the class LoggingEventListenerTest method testOnEvent.
@Test
public void testOnEvent() throws Exception {
URL connectionURL = URL.valueOf("file:///Users/Home");
ServiceDiscovery serviceDiscovery = new FileSystemServiceDiscovery();
serviceDiscovery.initialize(connectionURL);
// ServiceDiscoveryStartingEvent
listener.onEvent(new ServiceDiscoveryInitializingEvent(serviceDiscovery, serviceDiscovery));
// ServiceDiscoveryStartedEvent
listener.onEvent(new ServiceDiscoveryInitializedEvent(serviceDiscovery, serviceDiscovery));
// ServiceInstancePreRegisteredEvent
listener.onEvent(new ServiceInstancePreRegisteredEvent(serviceDiscovery, createInstance()));
// ServiceInstanceRegisteredEvent
listener.onEvent(new ServiceInstanceRegisteredEvent(serviceDiscovery, createInstance()));
// ServiceInstancesChangedEvent
listener.onEvent(new ServiceInstancesChangedEvent("test", Arrays.asList(createInstance())));
// ServiceInstancePreUnregisteredEvent
listener.onEvent(new ServiceInstancePreUnregisteredEvent(serviceDiscovery, createInstance()));
// ServiceInstanceUnregisteredEvent
listener.onEvent(new ServiceInstanceUnregisteredEvent(serviceDiscovery, createInstance()));
// ServiceDiscoveryStoppingEvent
listener.onEvent(new ServiceDiscoveryDestroyingEvent(serviceDiscovery, serviceDiscovery));
// ServiceDiscoveryStoppedEvent
listener.onEvent(new ServiceDiscoveryDestroyedEvent(serviceDiscovery, serviceDiscovery));
}
use of org.apache.dubbo.registry.client.ServiceDiscovery in project dubbo by alibaba.
the class MultipleRegistryServiceDiscovery method initialize.
@Override
public void initialize(URL registryURL) throws Exception {
this.registryURL = registryURL;
this.applicationName = registryURL.getParameter(CommonConstants.APPLICATION_KEY);
Map<String, String> parameters = registryURL.getParameters();
for (String key : parameters.keySet()) {
if (key.startsWith(REGISTRY_PREFIX_KEY)) {
URL url = URL.valueOf(registryURL.getParameter(key)).addParameter(CommonConstants.APPLICATION_KEY, applicationName).addParameter("registry-type", "service");
ServiceDiscovery serviceDiscovery = ServiceDiscoveryFactory.getExtension(url).getServiceDiscovery(url);
serviceDiscovery.initialize(url);
serviceDiscoveries.put(key, serviceDiscovery);
}
}
}
use of org.apache.dubbo.registry.client.ServiceDiscovery in project incubator-dubbo-ops by apache.
the class ConfigCenter method getServiceDiscoveryRegistry.
@Bean(destroyMethod = "destroy")
@DependsOn("dubboRegistry")
ServiceDiscovery getServiceDiscoveryRegistry() throws Exception {
URL registryURL = registryUrl.setPath(RegistryService.class.getName());
ServiceDiscoveryFactory factory = getExtension(registryURL);
ServiceDiscovery serviceDiscovery = factory.getServiceDiscovery(registryURL);
serviceDiscovery.initialize(registryURL);
return serviceDiscovery;
}
Aggregations