Java Code Examples for reactor.core.publisher.UnicastProcessor#sink()
The following examples show how to use
reactor.core.publisher.UnicastProcessor#sink() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InstanceEventPublisher.java From Moss with Apache License 2.0 | 4 votes |
protected InstanceEventPublisher() { UnicastProcessor<InstanceEvent> unicastProcessor = UnicastProcessor.create(); this.publishedFlux = unicastProcessor.publish().autoConnect(0); this.sink = unicastProcessor.sink(); }
Example 2
Source File: AbstractEventHandlerTest.java From Moss with Apache License 2.0 | 4 votes |
private TestEventHandler(Publisher<InstanceEvent> publisher) { super(publisher, InstanceRegisteredEvent.class); UnicastProcessor<InstanceEvent> processor = UnicastProcessor.create(); this.sink = processor.sink(); this.flux = processor; }
Example 3
Source File: GenericEvent.java From linstor-server with GNU General Public License v3.0 | 4 votes |
@Override public void triggerEvent(ObjectIdentifier objectIdentifier, T value) { Flux<T> stream = null; FluxSink<T> sink; Set<FluxSink<Tuple2<ObjectIdentifier, Flux<T>>>> waiterSet = null; lock.lock(); try { sink = sinks.get(objectIdentifier); if (sink == null) { UnicastProcessor<T> processor = UnicastProcessor.create(); ConnectableFlux<T> publisher = processor.replay(1); publisher.connect(); // Publish events signals on the main scheduler to detach the execution from this thread, // so that we don't react to events in the thread-local context where the event is triggered. stream = publisher.publishOn(scheduler); streams.put(objectIdentifier, stream); try { eventStreamStore.addEventStream(new EventIdentifier(null, objectIdentifier)); } catch (LinStorDataAlreadyExistsException exc) { throw new ImplementationError(exc); } sink = processor.sink(); sinks.put(objectIdentifier, sink); List<ObjectIdentifier> matchingWaitObjects = matchingObjects(objectIdentifier); waiterSet = new HashSet<>(); for (ObjectIdentifier waitObject : matchingWaitObjects) { Set<FluxSink<Tuple2<ObjectIdentifier, Flux<T>>>> waitersForObject = waiters.get(waitObject); if (waitersForObject != null) { waiterSet.addAll(waitersForObject); } } } } finally { lock.unlock(); } if (waiterSet != null) { for (FluxSink<Tuple2<ObjectIdentifier, Flux<T>>> waiter : waiterSet) { waiter.next(Tuples.of(objectIdentifier, stream)); } } sink.next(value); }
Example 4
Source File: TcpConnectorPeer.java From linstor-server with GNU General Public License v3.0 | 4 votes |
protected TcpConnectorPeer( ErrorReporter errorReporterRef, CommonSerializer commonSerializerRef, String peerIdRef, TcpConnector connectorRef, SelectionKey key, AccessContext accCtx, Node nodeRef ) { errorReporter = errorReporterRef; commonSerializer = commonSerializerRef; peerId = peerIdRef; connector = connectorRef; node = nodeRef; msgOutQueue = new LinkedList<>(); // Do not use createMessage() here! // The SslTcpConnectorPeer has not initialized SSLEngine instance yet, // so a NullPointerException would be thrown in createMessage(). // After initialization of the sslEngine, msgIn will be overwritten with // a reference to a valid instance. msgIn = new MessageData(false); selKey = key; peerAccCtx = accCtx; attachment = null; internalPingMsg = new TcpHeaderOnlyMessage(MessageTypes.PING); internalPongMsg = new TcpHeaderOnlyMessage(MessageTypes.PONG); serializerId = new AtomicLong(0); serializerLock = new ReentrantReadWriteLock(true); satelliteStateLock = new ReentrantReadWriteLock(true); if (node != null) { satelliteState = new SatelliteState(); } finishedMsgInQueue = new LinkedList<>(); UnicastProcessor<Tuple2<Long, Publisher<?>>> processor = UnicastProcessor.create(); incomingMessageSink = processor.sink(); processor .transform(OrderingFlux::order) .flatMap(Function.identity(), Integer.MAX_VALUE) .subscribe( ignored -> { // do nothing }, exc -> errorReporterRef.reportError( exc, null, null, "Uncaught exception in processor for peer '" + this + "'") ); }
Example 5
Source File: InstanceEventPublisher.java From spring-boot-admin with Apache License 2.0 | 4 votes |
protected InstanceEventPublisher() { UnicastProcessor<InstanceEvent> unicastProcessor = UnicastProcessor.create(); this.publishedFlux = unicastProcessor.publish().autoConnect(0); this.sink = unicastProcessor.sink(); }
Example 6
Source File: AbstractEventHandlerTest.java From spring-boot-admin with Apache License 2.0 | 4 votes |
private TestEventHandler(Publisher<InstanceEvent> publisher) { super(publisher, InstanceRegisteredEvent.class); UnicastProcessor<InstanceEvent> processor = UnicastProcessor.create(); this.sink = processor.sink(); this.flux = processor; }