use of org.springframework.cloud.client.serviceregistry.Registration in project spring-cloud-alibaba by alibaba.
the class DubboServiceRegistrationAutoConfiguration method onServiceInstancePreRegistered.
@EventListener(ServiceInstancePreRegisteredEvent.class)
public void onServiceInstancePreRegistered(ServiceInstancePreRegisteredEvent event) {
Registration registration = event.getSource();
if (!DubboBootstrap.getInstance().isReady() || !DubboBootstrap.getInstance().isStarted()) {
ServiceRegistry<Registration> registry = event.getRegistry();
synchronized (registry) {
registrations.putIfAbsent(registry, new HashSet<>());
registrations.get(registry).add(registration);
}
} else {
attachDubboMetadataServiceMetadata(registration);
}
}
use of org.springframework.cloud.client.serviceregistry.Registration in project Sermant by huaweicloud.
the class RegistrationInterceptor method doBefore.
@Override
public ExecuteContext doBefore(ExecuteContext context) {
if (!(context.getArguments()[0] instanceof Registration)) {
return context;
}
fillClientInfo((Registration) context.getArguments()[0]);
final RegisterCenterService service = ServiceManager.getService(RegisterCenterService.class);
final FixedResult fixedResult = new FixedResult();
service.register(fixedResult);
if (fixedResult.isSkip()) {
context.skip(fixedResult.getResult());
}
return context;
}
use of org.springframework.cloud.client.serviceregistry.Registration in project spring-cloud-netflix by spring-cloud.
the class DiscoveryClientRouteLocatorTests method testIgnoredLocalServiceByDefault.
@Test
public void testIgnoredLocalServiceByDefault() {
given(this.discovery.getServices()).willReturn(Collections.singletonList(MYSERVICE));
Registration registration = new Registration() {
@Override
public String getServiceId() {
return MYSERVICE;
}
@Override
public String getHost() {
return "localhost";
}
@Override
public int getPort() {
return 80;
}
@Override
public boolean isSecure() {
return false;
}
@Override
public URI getUri() {
return null;
}
@Override
public Map<String, String> getMetadata() {
return null;
}
};
DiscoveryClientRouteLocator routeLocator = new DiscoveryClientRouteLocator("/", this.discovery, this.properties, registration);
LinkedHashMap<String, ZuulRoute> routes = routeLocator.locateRoutes();
ZuulRoute actual = routes.get("/**");
assertNull("routes didn't ignore " + MYSERVICE, actual);
List<Route> routesMap = routeLocator.getRoutes();
assertNotNull("routesMap was null", routesMap);
assertTrue("routesMap was empty", routesMap.isEmpty());
}
use of org.springframework.cloud.client.serviceregistry.Registration in project Sermant by huaweicloud.
the class RegisterServiceImpl method before.
@Override
public void before(Object obj, Method method, Object[] arguments, BeforeResult beforeResult) {
final Object argument = arguments[0];
if (argument instanceof ZookeeperRegistration) {
ZookeeperRegistration instanceInfo = (ZookeeperRegistration) argument;
// 存放当前服务实例, 仅初始化一次
CurrentInstance.newInstance(instanceInfo.getServiceId(), instanceInfo.getHost(), instanceInfo.getPort());
} else if (argument instanceof Registration) {
Registration instanceInfo = (Registration) argument;
Map<String, String> meta = instanceInfo.getMetadata();
meta.put(GrayConstant.GRAY_VERSION_KEY, PluginConfigManager.getPluginConfig(GrayConfig.class).getGrayVersion());
// 存放当前服务实例, 仅初始化一次
CurrentInstance.newInstance(instanceInfo.getServiceId(), instanceInfo.getHost(), instanceInfo.getPort());
} else if (argument instanceof InstanceInfo) {
InstanceInfo instanceInfo = (InstanceInfo) argument;
// 存放当前服务实例, 初始化标签观察者
CurrentInstance.newInstance(instanceInfo.getVIPAddress(), instanceInfo.getIPAddr(), instanceInfo.getPort());
}
}
use of org.springframework.cloud.client.serviceregistry.Registration in project Sermant by huaweicloud.
the class RegistrationInterceptor method doBefore.
@Override
public ExecuteContext doBefore(ExecuteContext context) {
if (!(context.getArguments()[0] instanceof Registration)) {
return context;
}
fillClientInfo((Registration) context.getArguments()[0]);
final RegisterCenterService service = ServiceManager.getService(RegisterCenterService.class);
final FixedResult fixedResult = new FixedResult();
service.register(fixedResult);
if (fixedResult.isSkip()) {
context.skip(fixedResult.getResult());
}
return context;
}
Aggregations