Class ClientStreamServiceImpl<M extends BufferWriter>
java.lang.Object
io.camunda.zeebe.scheduler.Actor
io.camunda.zeebe.transport.stream.impl.ClientStreamServiceImpl<M>
- All Implemented Interfaces:
AsyncClosable,ConcurrencyControl,ClientStreamer<M>,ClientStreamService<M>,CloseableSilently,AutoCloseable,Executor
public final class ClientStreamServiceImpl<M extends BufferWriter>
extends Actor
implements ClientStreamer<M>, ClientStreamService<M>
Implementation for both
ClientStreamer and ClientStreamService.
TODO: In the future we may want to split this into more than implementation, where the streamer receives an execution context, and the service manages it.
-
Nested Class Summary
Nested classes/interfaces inherited from class io.camunda.zeebe.scheduler.Actor
Actor.ActorBuilder -
Field Summary
Fields inherited from class io.camunda.zeebe.scheduler.Actor
actor, ACTOR_PROP_NAME, ACTOR_PROP_PARTITION_ID -
Constructor Summary
ConstructorsConstructorDescriptionClientStreamServiceImpl(ClusterCommunicationService communicationService, ClientStreamMetrics metrics) -
Method Summary
Modifier and TypeMethodDescriptionadd(org.agrona.DirectBuffer streamType, M metadata, ClientStreamConsumer clientStreamConsumer) Registers a client and opens a stream for the given streamType and associated Metadata with all available servers.protected voidprotected voidvoidonServerJoined(MemberId memberId) A callback to be invoked when a new streaming server is added.voidonServerRemoved(MemberId memberId) A callback to be invoked when a new streaming server is removed.remove(ClientStreamId streamId) Removes a stream that is added viaClientStreamer.add(DirectBuffer, BufferWriter, ClientStreamConsumer).start(ActorSchedulingService schedulingService) Starts the service, optionally with the given actor scheduling service.streamer()Returns the managedClientStreamerassociated with this service.Returns theClientStreamassociated with this IDstreams()Returns all registered client streams.Methods inherited from class io.camunda.zeebe.scheduler.Actor
buildActorName, call, close, closeAsync, createContext, getContext, getName, handleFailure, isActorClosed, newActor, onActorClosed, onActorClosing, onActorFailed, onActorStarting, run, runOnCompletion, runOnCompletion, schedule, wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.camunda.zeebe.scheduler.AsyncClosable
closeAsyncMethods inherited from interface io.camunda.zeebe.util.CloseableSilently
closeMethods inherited from interface io.camunda.zeebe.scheduler.ConcurrencyControl
createCompletedFuture, createFuture, execute
-
Constructor Details
-
ClientStreamServiceImpl
public ClientStreamServiceImpl(ClusterCommunicationService communicationService, ClientStreamMetrics metrics)
-
-
Method Details
-
onActorStarted
protected void onActorStarted()- Overrides:
onActorStartedin classActor
-
onActorCloseRequested
protected void onActorCloseRequested()- Overrides:
onActorCloseRequestedin classActor
-
add
public ActorFuture<ClientStreamId> add(org.agrona.DirectBuffer streamType, M metadata, ClientStreamConsumer clientStreamConsumer) Description copied from interface:ClientStreamerRegisters a client and opens a stream for the given streamType and associated Metadata with all available servers. The stream is also opened for servers that are not currently reachable, but available later.NOTE: The stream to a server can be added asynchronously. So there might be a delay until the consumer receives the first data.
- Specified by:
addin interfaceClientStreamer<M extends BufferWriter>- Parameters:
streamType- type of the streammetadata- metadata associated with the streamclientStreamConsumer- consumer which process data received from the server- Returns:
- a unique id of the stream
-
remove
Description copied from interface:ClientStreamerRemoves a stream that is added viaClientStreamer.add(DirectBuffer, BufferWriter, ClientStreamConsumer). After the returned future is completed, theClientStreamConsumerwill not receive any more data.- Specified by:
removein interfaceClientStreamer<M extends BufferWriter>- Parameters:
streamId- unique id of the stream- Returns:
- a future which will be completed after the stream is removed
-
start
Description copied from interface:ClientStreamServiceStarts the service, optionally with the given actor scheduling service. Assumes the scheduling service is already running.- Specified by:
startin interfaceClientStreamService<M extends BufferWriter>
-
onServerJoined
Description copied from interface:ClientStreamServiceA callback to be invoked when a new streaming server is added. Implementations should be idempotent.- Specified by:
onServerJoinedin interfaceClientStreamService<M extends BufferWriter>
-
onServerRemoved
Description copied from interface:ClientStreamServiceA callback to be invoked when a new streaming server is removed. Implementations should be idempotent.- Specified by:
onServerRemovedin interfaceClientStreamService<M extends BufferWriter>
-
streamer
Description copied from interface:ClientStreamServiceReturns the managedClientStreamerassociated with this service.- Specified by:
streamerin interfaceClientStreamService<M extends BufferWriter>
-
streamFor
Description copied from interface:ClientStreamServiceReturns theClientStreamassociated with this ID- Specified by:
streamForin interfaceClientStreamService<M extends BufferWriter>
-
streams
Description copied from interface:ClientStreamServiceReturns all registered client streams.- Specified by:
streamsin interfaceClientStreamService<M extends BufferWriter>
-