Package io.streamthoughts.azkarra.api
Interface StreamsExecutionEnvironment
-
- All Known Implementing Classes:
DefaultStreamsExecutionEnvironment
public interface StreamsExecutionEnvironment
A StreamsExecutionEnvironment manages the lifecycle ofTopology
instances.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description StreamsExecutionEnvironment
addFallbackConfiguration(Conf settings)
Adds streamsConfig that will be used in fallback if not present in defined environment streamsConfig.StreamsExecutionEnvironment
addGlobalStateListener(org.apache.kafka.streams.processor.StateRestoreListener listener)
Adds aStateRestoreListener
instance that will set to allKafkaStreams
instance created in thisStreamsExecutionEnvironment
.StreamsExecutionEnvironment
addStateListener(org.apache.kafka.streams.KafkaStreams.StateListener listener)
Adds aKafkaStreams.StateListener
instance that will set to allKafkaStreams
instance created in thisStreamsExecutionEnvironment
.StreamsExecutionEnvironment
addStreamsLifecycleInterceptor(Supplier<StreamsLifecycleInterceptor> interceptor)
Adds a streams interceptor hat will set to allKafkaStreams
instance created in thisStreamsExecutionEnvironment
.ApplicationId
addTopology(Supplier<TopologyProvider> provider)
Add a newTopologyProvider
instance to thisStreamsExecutionEnvironment
to be started.ApplicationId
addTopology(Supplier<TopologyProvider> provider, Executed executed)
Add a newTopologyProvider
instance to thisStreamsExecutionEnvironment
to be started.Collection<KafkaStreamsContainer>
applications()
Returns allKafkaStreams
started applications.Conf
getConfiguration()
Gets this environment configuration.Supplier<StreamThreadExceptionHandler>
getStreamThreadExceptionHandler()
Gets theStreamThreadExceptionHandler
.String
name()
Gets the name of thisStreamsExecutionEnvironment
.default void
remove(ApplicationId id)
Stops the streams instance for the specified application id and remove the associated topology from this environment.void
remove(ApplicationId id, Duration timeout)
Stops the streams instance for the specified application id and remove the associated topology from this environment.StreamsExecutionEnvironment
setApplicationIdBuilder(Supplier<ApplicationIdBuilder> supplier)
Sets theApplicationIdBuilder
that should be used for building streamsapplication.id
.StreamsExecutionEnvironment
setConfiguration(Conf configuration)
Sets this environment configuration.StreamsExecutionEnvironment
setKafkaStreamsFactory(Supplier<KafkaStreamsFactory> kafkaStreamsFactory)
Sets theKafkaStreamsFactory
that will be used to provide theKafkaStreams
to configure and start.StreamsExecutionEnvironment
setRocksDBConfig(RocksDBConfig settings)
Sets theRocksDBConfig
streamsConfig used by topology persistent stores.StreamsExecutionEnvironment
setStreamThreadExceptionHandler(Supplier<StreamThreadExceptionHandler> handler)
Sets theStreamThreadExceptionHandler
invoked when a StreamThread abruptly terminates due to an uncaught exception.StreamsExecutionEnvironment
setWaitForTopicsToBeCreated(boolean waitForTopicToBeCreated)
Sets if the streams instances should wait for topics source to be created before starting.void
start()
Starts thisStreamsExecutionEnvironment
instance.State
state()
Gets the state f thisStreamsExecutionEnvironment
.default void
stop()
Stops thisStreamsExecutionEnvironment
instance and all runningKafkaStreams
instance.void
stop(boolean cleanUp)
Stops thisStreamsExecutionEnvironment
instance and all runningKafkaStreams
instance.default void
stop(ApplicationId id, boolean cleanUp)
Stops the streams instance for the specified application id.void
stop(ApplicationId id, boolean cleanUp, Duration timeout)
Stops the streams instance for the specified application id.
-
-
-
Method Detail
-
name
String name()
Gets the name of thisStreamsExecutionEnvironment
.- Returns:
- the string name.
-
state
State state()
Gets the state f thisStreamsExecutionEnvironment
.- Returns:
- the
State
.
-
addStateListener
StreamsExecutionEnvironment addStateListener(org.apache.kafka.streams.KafkaStreams.StateListener listener)
Adds aKafkaStreams.StateListener
instance that will set to allKafkaStreams
instance created in thisStreamsExecutionEnvironment
.- Parameters:
listener
- theKafkaStreams.StateListener
instance.- Returns:
- this
StreamsExecutionEnvironment
instance. - Throws:
IllegalStateException
- if thisStreamsExecutionEnvironment
instance is started.
-
addGlobalStateListener
StreamsExecutionEnvironment addGlobalStateListener(org.apache.kafka.streams.processor.StateRestoreListener listener)
Adds aStateRestoreListener
instance that will set to allKafkaStreams
instance created in thisStreamsExecutionEnvironment
.- Parameters:
listener
- theStateRestoreListener
instance.- Returns:
- this
StreamsExecutionEnvironment
instance. - Throws:
IllegalStateException
- if thisStreamsExecutionEnvironment
instance is started.- See Also:
.
-
addStreamsLifecycleInterceptor
StreamsExecutionEnvironment addStreamsLifecycleInterceptor(Supplier<StreamsLifecycleInterceptor> interceptor)
Adds a streams interceptor hat will set to allKafkaStreams
instance created in thisStreamsExecutionEnvironment
.- Parameters:
interceptor
- the {@link {@link StreamsLifecycleInterceptor}}.- Returns:
- this
StreamsExecutionEnvironment
instance.
-
setStreamThreadExceptionHandler
StreamsExecutionEnvironment setStreamThreadExceptionHandler(Supplier<StreamThreadExceptionHandler> handler)
Sets theStreamThreadExceptionHandler
invoked when a StreamThread abruptly terminates due to an uncaught exception.- Parameters:
handler
- theStreamThreadExceptionHandler
.- Returns:
- this
StreamsExecutionEnvironment
instance. - See Also:
KafkaStreams.setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler)
-
getStreamThreadExceptionHandler
Supplier<StreamThreadExceptionHandler> getStreamThreadExceptionHandler()
Gets theStreamThreadExceptionHandler
.- Returns:
- the
Supplier
, otherwisenull
if no handler is set.
-
applications
Collection<KafkaStreamsContainer> applications()
Returns allKafkaStreams
started applications.- Returns:
- a collection of
KafkaStreamsContainer
applications.
-
setConfiguration
StreamsExecutionEnvironment setConfiguration(Conf configuration)
Sets this environment configuration.- Returns:
- this
StreamsExecutionEnvironment
instance.
-
getConfiguration
Conf getConfiguration()
Gets this environment configuration.- Returns:
- the
Conf
instance.
-
setRocksDBConfig
StreamsExecutionEnvironment setRocksDBConfig(RocksDBConfig settings)
Sets theRocksDBConfig
streamsConfig used by topology persistent stores.- Parameters:
settings
- theRocksDBConfig
instance.- Returns:
- this
StreamsExecutionEnvironment
instance.
-
setApplicationIdBuilder
StreamsExecutionEnvironment setApplicationIdBuilder(Supplier<ApplicationIdBuilder> supplier)
Sets theApplicationIdBuilder
that should be used for building streamsapplication.id
.- Parameters:
supplier
- theApplicationIdBuilder
instance supplier.- Returns:
- this
StreamsExecutionEnvironment
instance.
-
setWaitForTopicsToBeCreated
StreamsExecutionEnvironment setWaitForTopicsToBeCreated(boolean waitForTopicToBeCreated)
Sets if the streams instances should wait for topics source to be created before starting. If some source topics are missing at startup, a streams instance fails.- Parameters:
waitForTopicToBeCreated
- should wait for topics to be created.- Returns:
- this
StreamsExecutionEnvironment
instance.
-
addFallbackConfiguration
StreamsExecutionEnvironment addFallbackConfiguration(Conf settings)
Adds streamsConfig that will be used in fallback if not present in defined environment streamsConfig.- Parameters:
settings
- theConf
instance.- Returns:
- this
StreamsExecutionEnvironment
instance.
-
setKafkaStreamsFactory
StreamsExecutionEnvironment setKafkaStreamsFactory(Supplier<KafkaStreamsFactory> kafkaStreamsFactory)
Sets theKafkaStreamsFactory
that will be used to provide theKafkaStreams
to configure and start.- Parameters:
kafkaStreamsFactory
- theKafkaStreamsFactory
instance.- Returns:
- this
StreamsExecutionEnvironment
instance.
-
addTopology
ApplicationId addTopology(Supplier<TopologyProvider> provider)
Add a newTopologyProvider
instance to thisStreamsExecutionEnvironment
to be started.- Parameters:
provider
- theTopologyProvider
supplier.- Returns:
- this
ApplicationId
instance if the environment is already started, otherwisenull
.
-
addTopology
ApplicationId addTopology(Supplier<TopologyProvider> provider, Executed executed)
Add a newTopologyProvider
instance to thisStreamsExecutionEnvironment
to be started.- Parameters:
provider
- theTopologyProvider
supplier.executed
- theExecuted
instance.- Returns:
- this
ApplicationId
instance if the environment is already started, otherwisenull
.
-
start
void start()
Starts thisStreamsExecutionEnvironment
instance.
-
stop
default void stop()
Stops thisStreamsExecutionEnvironment
instance and all runningKafkaStreams
instance.
-
stop
void stop(boolean cleanUp)
Stops thisStreamsExecutionEnvironment
instance and all runningKafkaStreams
instance.- Parameters:
cleanUp
- if local states of eachKafkaStreams
instance must be cleanup.- Throws:
IllegalStateException
- if the environment is not started.- See Also:
.
-
stop
default void stop(ApplicationId id, boolean cleanUp)
Stops the streams instance for the specified application id.- Parameters:
id
- theApplicationId
of the streams instance.cleanUp
- if local states of eachKafkaStreams
instance must be cleanup.- Throws:
IllegalStateException
- if the environment is not started.IllegalArgumentException
- if no streams instance exist for the givenid
.- See Also:
.
-
stop
void stop(ApplicationId id, boolean cleanUp, Duration timeout)
Stops the streams instance for the specified application id.- Parameters:
id
- theApplicationId
of the streams instance.cleanUp
- if local states of eachKafkaStreams
instance must be cleanup.timeout
- the duration to wait for the streams to shutdown.- Throws:
IllegalStateException
- if the environment is not started.IllegalArgumentException
- if no streams instance exist for the givenid
.- See Also:
.
-
remove
default void remove(ApplicationId id)
Stops the streams instance for the specified application id and remove the associated topology from this environment.- Parameters:
id
- theApplicationId
of the streams instance.- Throws:
IllegalStateException
- if the environment is not started.IllegalArgumentException
- if no streams instance exist for the givenid
.- See Also:
.
-
remove
void remove(ApplicationId id, Duration timeout)
Stops the streams instance for the specified application id and remove the associated topology from this environment.- Parameters:
id
- theApplicationId
of the streams instance.timeout
- the duration to wait for the streams to shutdown.- Throws:
IllegalStateException
- if the environment is not started.IllegalArgumentException
- if no streams instance exist for the givenid
.- See Also:
.
-
-