Search in sources :

Example 1 with RSocketBroker

use of com.alibaba.spring.boot.rsocket.broker.cluster.RSocketBroker in project alibaba-rsocket-broker by alibaba.

the class RSocketBrokerHandlerRegistryImpl method getBrokerClustersEvent.

private CloudEventImpl<UpstreamClusterChangedEvent> getBrokerClustersEvent(Collection<RSocketBroker> rSocketBrokers, String topology) {
    List<String> uris;
    if ("internet".equals(topology)) {
        uris = rSocketBrokers.stream().filter(rsocketBroker -> rsocketBroker.isActive() && rsocketBroker.getExternalDomain() != null).map(RSocketBroker::getAliasUrl).collect(Collectors.toList());
    } else {
        uris = rSocketBrokers.stream().filter(RSocketBroker::isActive).map(RSocketBroker::getUrl).collect(Collectors.toList());
    }
    UpstreamClusterChangedEvent upstreamClusterChangedEvent = new UpstreamClusterChangedEvent();
    upstreamClusterChangedEvent.setGroup("");
    upstreamClusterChangedEvent.setInterfaceName("*");
    upstreamClusterChangedEvent.setVersion("");
    upstreamClusterChangedEvent.setUris(uris);
    // passing in the given attributes
    return RSocketCloudEventBuilder.builder(upstreamClusterChangedEvent).withDataschema(URI.create("rsocket:event:com.alibaba.rsocket.upstream.UpstreamClusterChangedEvent")).withSource(BrokerAppContext.identity()).build();
}
Also used : Sinks(reactor.core.publisher.Sinks) BearerTokenMetadata(com.alibaba.rsocket.metadata.BearerTokenMetadata) java.util(java.util) ConcurrentHashMap(org.eclipse.collections.impl.map.mutable.ConcurrentHashMap) Multimap(org.eclipse.collections.api.multimap.Multimap) LoggerFactory(org.slf4j.LoggerFactory) BrokerAppContext(com.alibaba.spring.boot.rsocket.broker.BrokerAppContext) RejectedSetupException(io.rsocket.exceptions.RejectedSetupException) RSocketAppPrincipal(com.alibaba.spring.boot.rsocket.broker.security.RSocketAppPrincipal) FastListMultimap(org.eclipse.collections.impl.multimap.list.FastListMultimap) Metrics(io.micrometer.core.instrument.Metrics) ApplicationErrorException(io.rsocket.exceptions.ApplicationErrorException) AuthenticationService(com.alibaba.spring.boot.rsocket.broker.security.AuthenticationService) RSocket(io.rsocket.RSocket) CloudEventImpl(com.alibaba.rsocket.cloudevents.CloudEventImpl) Duration(java.time.Duration) RSocketBroker(com.alibaba.spring.boot.rsocket.broker.cluster.RSocketBroker) Schedulers(reactor.core.scheduler.Schedulers) RSocketFilterChain(com.alibaba.rsocket.route.RSocketFilterChain) URI(java.net.URI) UpstreamClusterChangedEvent(com.alibaba.rsocket.upstream.UpstreamClusterChangedEvent) DoubleFunction(org.eclipse.collections.api.block.function.primitive.DoubleFunction) AppStatusEvent(com.alibaba.rsocket.events.AppStatusEvent) RSocketBrokerManager(com.alibaba.spring.boot.rsocket.broker.cluster.RSocketBrokerManager) ServiceMeshInspector(com.alibaba.spring.boot.rsocket.broker.route.ServiceMeshInspector) RSocketMimeType(com.alibaba.rsocket.metadata.RSocketMimeType) Logger(org.slf4j.Logger) RsocketErrorCode(com.alibaba.rsocket.observability.RsocketErrorCode) Mono(reactor.core.publisher.Mono) ServiceRoutingSelector(com.alibaba.spring.boot.rsocket.broker.route.ServiceRoutingSelector) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) RSocketCompositeMetadata(com.alibaba.rsocket.metadata.RSocketCompositeMetadata) ServiceInstancesChangedEvent(com.alibaba.rsocket.upstream.ServiceInstancesChangedEvent) Nullable(org.jetbrains.annotations.Nullable) Flux(reactor.core.publisher.Flux) AppMetadata(com.alibaba.rsocket.metadata.AppMetadata) MurmurHash3(com.alibaba.rsocket.utils.MurmurHash3) ConnectionSetupPayload(io.rsocket.ConnectionSetupPayload) RSocketCloudEventBuilder(com.alibaba.rsocket.cloudevents.RSocketCloudEventBuilder) LocalReactiveServiceCaller(com.alibaba.rsocket.rpc.LocalReactiveServiceCaller) NotNull(org.jetbrains.annotations.NotNull) ServiceLocator(com.alibaba.rsocket.ServiceLocator) JwtPrincipal(com.alibaba.spring.boot.rsocket.broker.security.JwtPrincipal) RSocketBroker(com.alibaba.spring.boot.rsocket.broker.cluster.RSocketBroker) UpstreamClusterChangedEvent(com.alibaba.rsocket.upstream.UpstreamClusterChangedEvent)

Aggregations

ServiceLocator (com.alibaba.rsocket.ServiceLocator)1 CloudEventImpl (com.alibaba.rsocket.cloudevents.CloudEventImpl)1 RSocketCloudEventBuilder (com.alibaba.rsocket.cloudevents.RSocketCloudEventBuilder)1 AppStatusEvent (com.alibaba.rsocket.events.AppStatusEvent)1 AppMetadata (com.alibaba.rsocket.metadata.AppMetadata)1 BearerTokenMetadata (com.alibaba.rsocket.metadata.BearerTokenMetadata)1 RSocketCompositeMetadata (com.alibaba.rsocket.metadata.RSocketCompositeMetadata)1 RSocketMimeType (com.alibaba.rsocket.metadata.RSocketMimeType)1 RsocketErrorCode (com.alibaba.rsocket.observability.RsocketErrorCode)1 RSocketFilterChain (com.alibaba.rsocket.route.RSocketFilterChain)1 LocalReactiveServiceCaller (com.alibaba.rsocket.rpc.LocalReactiveServiceCaller)1 ServiceInstancesChangedEvent (com.alibaba.rsocket.upstream.ServiceInstancesChangedEvent)1 UpstreamClusterChangedEvent (com.alibaba.rsocket.upstream.UpstreamClusterChangedEvent)1 MurmurHash3 (com.alibaba.rsocket.utils.MurmurHash3)1 BrokerAppContext (com.alibaba.spring.boot.rsocket.broker.BrokerAppContext)1 RSocketBroker (com.alibaba.spring.boot.rsocket.broker.cluster.RSocketBroker)1 RSocketBrokerManager (com.alibaba.spring.boot.rsocket.broker.cluster.RSocketBrokerManager)1 ServiceMeshInspector (com.alibaba.spring.boot.rsocket.broker.route.ServiceMeshInspector)1 ServiceRoutingSelector (com.alibaba.spring.boot.rsocket.broker.route.ServiceRoutingSelector)1 AuthenticationService (com.alibaba.spring.boot.rsocket.broker.security.AuthenticationService)1