use of com.alibaba.rsocket.ServiceLocator in project alibaba-rsocket-broker by alibaba.
the class ServiceRoutingSelectorImpl method register.
@Override
public void register(Integer instanceId, int powerUnit, Set<ServiceLocator> services) {
// todo notification for global service
for (ServiceLocator serviceLocator : services) {
int serviceId = serviceLocator.getId();
if (!instanceServices.get(instanceId).contains(serviceId)) {
instanceServices.put(instanceId, serviceId);
serviceHandlers.putMultiCopies(serviceId, instanceId, powerUnit);
distinctServices.put(serviceId, serviceLocator);
// p2p service notification
if (p2pServiceConsumers.containsKey(serviceLocator.getGsv())) {
p2pServiceNotificationProcessor.tryEmitNext(serviceLocator.getGsv());
}
}
}
}
use of com.alibaba.rsocket.ServiceLocator in project alibaba-rsocket-broker by alibaba.
the class ServiceRoutingSelectorImpl method deregister.
@Override
public void deregister(Integer instanceId) {
if (instanceServices.containsKey(instanceId)) {
for (Integer serviceId : instanceServices.get(instanceId)) {
ServiceLocator serviceLocator = distinctServices.get(serviceId);
serviceHandlers.removeAllSameValue(serviceId, instanceId);
if (!serviceHandlers.containsKey(serviceId)) {
distinctServices.remove(serviceId);
}
if (serviceLocator != null && p2pServiceConsumers.containsKey(serviceLocator.getGsv())) {
p2pServiceNotificationProcessor.tryEmitNext(serviceLocator.getGsv());
}
}
instanceServices.removeAll(instanceId);
}
}
use of com.alibaba.rsocket.ServiceLocator in project alibaba-rsocket-broker by alibaba.
the class ServicesExposedEvent method convertServicesToCloudEvent.
public static CloudEventImpl<ServicesExposedEvent> convertServicesToCloudEvent(Collection<ServiceLocator> serviceLocators) {
ServicesExposedEvent servicesExposedEvent = new ServicesExposedEvent();
for (ServiceLocator serviceLocator : serviceLocators) {
servicesExposedEvent.addService(serviceLocator);
}
servicesExposedEvent.setAppId(RSocketAppContext.ID);
return RSocketCloudEventBuilder.builder(servicesExposedEvent).build();
}
use of com.alibaba.rsocket.ServiceLocator in project alibaba-rsocket-broker by alibaba.
the class RSocketRemoteServiceBuilder method buildJdkProxy.
@SuppressWarnings("unchecked")
public T buildJdkProxy() {
CONSUMED_SERVICES.add(new ServiceLocator(group, service, version));
RSocketRequesterRpcProxy proxy = getRequesterProxy();
return (T) Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class[] { serviceInterface }, proxy);
}
use of com.alibaba.rsocket.ServiceLocator in project alibaba-rsocket-broker by alibaba.
the class RawRSocketTest method testService.
@Test
public void testService() throws Exception {
ServiceRegistryMetadata serviceRegistryMetadata = new ServiceRegistryMetadata();
serviceRegistryMetadata.addPublishedService(new ServiceLocator(null, "com.alibaba.user.UserService", null));
System.out.println(JsonUtils.toJsonText(serviceRegistryMetadata));
}
Aggregations