Class AutoCreateTopicsInterceptor
- java.lang.Object
-
- io.streamthoughts.azkarra.api.components.BaseComponentModule
-
- io.streamthoughts.azkarra.runtime.interceptors.AutoCreateTopicsInterceptor
-
- All Implemented Interfaces:
ComponentFactoryAware
,ConfigurableComponentFactory
,Configurable
,StreamsLifecycleInterceptor
public class AutoCreateTopicsInterceptor extends BaseComponentModule implements StreamsLifecycleInterceptor, Configurable
ThisStreamsLifecycleInterceptor
create both topics source and sink before starting the streams instance. Optionally, this interceptor can also be used to automatically delete all topics used by the applications when it's closed. This interceptor is state-full and thus a new instance must be created for each topology.
-
-
Constructor Summary
Constructors Constructor Description AutoCreateTopicsInterceptor()
Creates a newAutoCreateTopicsInterceptor
instance.AutoCreateTopicsInterceptor(org.apache.kafka.clients.admin.AdminClient adminClient)
Creates a newAutoCreateTopicsInterceptor
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(Conf configuration)
Configures this instance with the specifiedConf
.void
onStart(StreamsLifecycleContext context, StreamsLifecycleChain chain)
Intercepts the streams instance before being started.void
onStop(StreamsLifecycleContext context, StreamsLifecycleChain chain)
Intercepts the streams instance before being stopped.void
setDeleteTopicsOnStreamsClosed(boolean delete)
Sets if topics should be automatically deleted once the streams is closed.void
setNumPartitions(int numPartitions)
Sets the default number of partitions uses for creating topics.void
setReplicationFactor(short replicationFactor)
Sets the default replication factor uses for creating topics.void
setTopicConfigs(Map<String,String> topicConfigs)
void
setTopics(Collection<org.apache.kafka.clients.admin.NewTopic> topics)
Sets the list of new topics to create.-
Methods inherited from class io.streamthoughts.azkarra.api.components.BaseComponentModule
getComponentFactory, getConfiguration, setComponentFactory
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.streamthoughts.azkarra.api.components.ConfigurableComponentFactory
getAllComponents, getAllComponents, getAllComponents, getAllComponents, getComponent, getComponent, getComponent, getComponent
-
-
-
-
Constructor Detail
-
AutoCreateTopicsInterceptor
public AutoCreateTopicsInterceptor()
Creates a newAutoCreateTopicsInterceptor
instance.
-
AutoCreateTopicsInterceptor
public AutoCreateTopicsInterceptor(org.apache.kafka.clients.admin.AdminClient adminClient)
Creates a newAutoCreateTopicsInterceptor
instance.- Parameters:
adminClient
- theAdminClient
to be used.
-
-
Method Detail
-
configure
public void configure(Conf configuration)
Configures this instance with the specifiedConf
.- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classBaseComponentModule
- Parameters:
configuration
- theConf
instance used to configure this instance.
-
onStart
public void onStart(StreamsLifecycleContext context, StreamsLifecycleChain chain)
Intercepts the streams instance before being started.- Specified by:
onStart
in interfaceStreamsLifecycleInterceptor
chain
- theStreamsLifecycleChain
instance.
-
onStop
public void onStop(StreamsLifecycleContext context, StreamsLifecycleChain chain)
Intercepts the streams instance before being stopped.- Specified by:
onStop
in interfaceStreamsLifecycleInterceptor
chain
- theStreamsLifecycleChain
instance.
-
setReplicationFactor
public void setReplicationFactor(short replicationFactor)
Sets the default replication factor uses for creating topics.- Parameters:
replicationFactor
- the replication factor.
-
setNumPartitions
public void setNumPartitions(int numPartitions)
Sets the default number of partitions uses for creating topics.- Parameters:
numPartitions
- the number of partitions.
-
setTopics
public void setTopics(Collection<org.apache.kafka.clients.admin.NewTopic> topics)
Sets the list of new topics to create.- Parameters:
topics
- the list ofNewTopic
instances.
-
setDeleteTopicsOnStreamsClosed
public void setDeleteTopicsOnStreamsClosed(boolean delete)
Sets if topics should be automatically deleted once the streams is closed.- Parameters:
delete
-true
to enable, otherwisefalse
.
-
-