Package io.streamthoughts.azkarra.api
Interface StreamsExecutionEnvironment
-
public interface StreamsExecutionEnvironmentA StreamsExecutionEnvironment manages the lifecycle ofTopologyinstances.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description StreamsExecutionEnvironmentaddFallbackConfiguration(Conf settings)Adds streamsConfig that will be used in fallback if not present in defined environment streamsConfig.StreamsExecutionEnvironmentaddGlobalStateListener(org.apache.kafka.streams.processor.StateRestoreListener listener)Adds aStateRestoreListenerinstance that will set to allKafkaStreamsinstance created in thisStreamsExecutionEnvironment.StreamsExecutionEnvironmentaddStateListener(org.apache.kafka.streams.KafkaStreams.StateListener listener)Adds aKafkaStreams.StateListenerinstance that will set to allKafkaStreamsinstance created in thisStreamsExecutionEnvironment.StreamsExecutionEnvironmentaddStreamsLifecycleInterceptor(Supplier<StreamsLifecycleInterceptor> interceptor)Adds a streams interceptor hat will set to allKafkaStreamsinstance created in thisStreamsExecutionEnvironment.ApplicationIdaddTopology(Supplier<TopologyProvider> provider)Add a newTopologyProviderinstance to thisStreamsExecutionEnvironmentto be started.ApplicationIdaddTopology(Supplier<TopologyProvider> provider, Executed executed)Add a newTopologyProviderinstance to thisStreamsExecutionEnvironmentto be started.Collection<KafkaStreamsContainer>applications()Returns allKafkaStreamsstarted applications.ConfgetConfiguration()Gets this environment configuration.Supplier<StreamThreadExceptionHandler>getStreamThreadExceptionHandler()Gets theStreamThreadExceptionHandler.Stringname()Gets the name of thisStreamsExecutionEnvironment.default voidremove(ApplicationId id)Stops the streams instance for the specified application id and remove the associated topology from this environment.voidremove(ApplicationId id, Duration timeout)Stops the streams instance for the specified application id and remove the associated topology from this environment.StreamsExecutionEnvironmentsetApplicationIdBuilder(Supplier<ApplicationIdBuilder> supplier)Sets theApplicationIdBuilderthat should be used for building streamsapplication.id.StreamsExecutionEnvironmentsetConfiguration(Conf configuration)Sets this environment configuration.StreamsExecutionEnvironmentsetKafkaStreamsFactory(Supplier<KafkaStreamsFactory> kafkaStreamsFactory)Sets theKafkaStreamsFactorythat will be used to provide theKafkaStreamsto configure and start.StreamsExecutionEnvironmentsetRocksDBConfig(RocksDBConfig settings)Sets theRocksDBConfigstreamsConfig used by topology persistent stores.StreamsExecutionEnvironmentsetStreamThreadExceptionHandler(Supplier<StreamThreadExceptionHandler> handler)Sets theStreamThreadExceptionHandlerinvoked when a StreamThread abruptly terminates due to an uncaught exception.StreamsExecutionEnvironmentsetWaitForTopicsToBeCreated(boolean waitForTopicToBeCreated)Sets if the streams instances should wait for topics source to be created before starting.voidstart()Starts thisStreamsExecutionEnvironmentinstance.Statestate()Gets the state f thisStreamsExecutionEnvironment.default voidstop()Stops thisStreamsExecutionEnvironmentinstance and all runningKafkaStreamsinstance.voidstop(boolean cleanUp)Stops thisStreamsExecutionEnvironmentinstance and all runningKafkaStreamsinstance.default voidstop(ApplicationId id, boolean cleanUp)Stops the streams instance for the specified application id.voidstop(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.StateListenerinstance that will set to allKafkaStreamsinstance created in thisStreamsExecutionEnvironment.- Parameters:
listener- theKafkaStreams.StateListenerinstance.- Returns:
- this
StreamsExecutionEnvironmentinstance. - Throws:
IllegalStateException- if thisStreamsExecutionEnvironmentinstance is started.
-
addGlobalStateListener
StreamsExecutionEnvironment addGlobalStateListener(org.apache.kafka.streams.processor.StateRestoreListener listener)
Adds aStateRestoreListenerinstance that will set to allKafkaStreamsinstance created in thisStreamsExecutionEnvironment.- Parameters:
listener- theStateRestoreListenerinstance.- Returns:
- this
StreamsExecutionEnvironmentinstance. - Throws:
IllegalStateException- if thisStreamsExecutionEnvironmentinstance is started.- See Also:
.
-
addStreamsLifecycleInterceptor
StreamsExecutionEnvironment addStreamsLifecycleInterceptor(Supplier<StreamsLifecycleInterceptor> interceptor)
Adds a streams interceptor hat will set to allKafkaStreamsinstance created in thisStreamsExecutionEnvironment.- Parameters:
interceptor- the {@link {@link StreamsLifecycleInterceptor}}.- Returns:
- this
StreamsExecutionEnvironmentinstance.
-
setStreamThreadExceptionHandler
StreamsExecutionEnvironment setStreamThreadExceptionHandler(Supplier<StreamThreadExceptionHandler> handler)
Sets theStreamThreadExceptionHandlerinvoked when a StreamThread abruptly terminates due to an uncaught exception.- Parameters:
handler- theStreamThreadExceptionHandler.- Returns:
- this
StreamsExecutionEnvironmentinstance. - See Also:
KafkaStreams.setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler)
-
getStreamThreadExceptionHandler
Supplier<StreamThreadExceptionHandler> getStreamThreadExceptionHandler()
Gets theStreamThreadExceptionHandler.- Returns:
- the
Supplier, otherwisenullif no handler is set.
-
applications
Collection<KafkaStreamsContainer> applications()
Returns allKafkaStreamsstarted applications.- Returns:
- a collection of
KafkaStreamsContainerapplications.
-
setConfiguration
StreamsExecutionEnvironment setConfiguration(Conf configuration)
Sets this environment configuration.- Returns:
- this
StreamsExecutionEnvironmentinstance.
-
getConfiguration
Conf getConfiguration()
Gets this environment configuration.- Returns:
- the
Confinstance.
-
setRocksDBConfig
StreamsExecutionEnvironment setRocksDBConfig(RocksDBConfig settings)
Sets theRocksDBConfigstreamsConfig used by topology persistent stores.- Parameters:
settings- theRocksDBConfiginstance.- Returns:
- this
StreamsExecutionEnvironmentinstance.
-
setApplicationIdBuilder
StreamsExecutionEnvironment setApplicationIdBuilder(Supplier<ApplicationIdBuilder> supplier)
Sets theApplicationIdBuilderthat should be used for building streamsapplication.id.- Parameters:
supplier- theApplicationIdBuilderinstance supplier.- Returns:
- this
StreamsExecutionEnvironmentinstance.
-
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
StreamsExecutionEnvironmentinstance.
-
addFallbackConfiguration
StreamsExecutionEnvironment addFallbackConfiguration(Conf settings)
Adds streamsConfig that will be used in fallback if not present in defined environment streamsConfig.- Parameters:
settings- theConfinstance.- Returns:
- this
StreamsExecutionEnvironmentinstance.
-
setKafkaStreamsFactory
StreamsExecutionEnvironment setKafkaStreamsFactory(Supplier<KafkaStreamsFactory> kafkaStreamsFactory)
Sets theKafkaStreamsFactorythat will be used to provide theKafkaStreamsto configure and start.- Parameters:
kafkaStreamsFactory- theKafkaStreamsFactoryinstance.- Returns:
- this
StreamsExecutionEnvironmentinstance.
-
addTopology
ApplicationId addTopology(Supplier<TopologyProvider> provider)
Add a newTopologyProviderinstance to thisStreamsExecutionEnvironmentto be started.- Parameters:
provider- theTopologyProvidersupplier.- Returns:
- this
ApplicationIdinstance if the environment is already started, otherwisenull.
-
addTopology
ApplicationId addTopology(Supplier<TopologyProvider> provider, Executed executed)
Add a newTopologyProviderinstance to thisStreamsExecutionEnvironmentto be started.- Parameters:
provider- theTopologyProvidersupplier.executed- theExecutedinstance.- Returns:
- this
ApplicationIdinstance if the environment is already started, otherwisenull.
-
start
void start()
Starts thisStreamsExecutionEnvironmentinstance.
-
stop
default void stop()
Stops thisStreamsExecutionEnvironmentinstance and all runningKafkaStreamsinstance.
-
stop
void stop(boolean cleanUp)
Stops thisStreamsExecutionEnvironmentinstance and all runningKafkaStreamsinstance.- Parameters:
cleanUp- if local states of eachKafkaStreamsinstance 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- theApplicationIdof the streams instance.cleanUp- if local states of eachKafkaStreamsinstance 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- theApplicationIdof the streams instance.cleanUp- if local states of eachKafkaStreamsinstance 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- theApplicationIdof 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- theApplicationIdof 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:
.
-
-