Search in sources :

Example 1 with ServiceLocator

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());
            }
        }
    }
}
Also used : ServiceLocator(com.alibaba.rsocket.ServiceLocator)

Example 2 with ServiceLocator

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);
    }
}
Also used : ServiceLocator(com.alibaba.rsocket.ServiceLocator)

Example 3 with ServiceLocator

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();
}
Also used : ServiceLocator(com.alibaba.rsocket.ServiceLocator)

Example 4 with ServiceLocator

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);
}
Also used : ServiceLocator(com.alibaba.rsocket.ServiceLocator)

Example 5 with ServiceLocator

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));
}
Also used : ServiceLocator(com.alibaba.rsocket.ServiceLocator) ServiceRegistryMetadata(com.alibaba.rsocket.metadata.ServiceRegistryMetadata) Test(org.junit.jupiter.api.Test)

Aggregations

ServiceLocator (com.alibaba.rsocket.ServiceLocator)13 CloudEventImpl (com.alibaba.rsocket.cloudevents.CloudEventImpl)3 ServicesExposedEvent (com.alibaba.rsocket.events.ServicesExposedEvent)3 Collectors (java.util.stream.Collectors)3 RSocketAppContext (com.alibaba.rsocket.RSocketAppContext)2 RSocketRequesterSupport (com.alibaba.rsocket.RSocketRequesterSupport)2 RSocketServiceHealth (com.alibaba.rsocket.health.RSocketServiceHealth)2 RSocketRemoteServiceBuilder (com.alibaba.rsocket.invocation.RSocketRemoteServiceBuilder)2 RsocketErrorCode (com.alibaba.rsocket.observability.RsocketErrorCode)2 UpstreamCluster (com.alibaba.rsocket.upstream.UpstreamCluster)2 UpstreamManager (com.alibaba.rsocket.upstream.UpstreamManager)2 Payload (io.rsocket.Payload)2 ByteBufPayload (io.rsocket.util.ByteBufPayload)2 NotNull (org.jetbrains.annotations.NotNull)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 RSocketService (com.alibaba.rsocket.RSocketService)1 RSocketCloudEventBuilder (com.alibaba.rsocket.cloudevents.RSocketCloudEventBuilder)1 AppStatusEvent (com.alibaba.rsocket.events.AppStatusEvent)1 CloudEventsProcessor (com.alibaba.rsocket.events.CloudEventsProcessor)1