Class KafkaStreamsContainer
- java.lang.Object
-
- io.streamthoughts.azkarra.api.streams.KafkaStreamsContainer
-
public class KafkaStreamsContainer extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceKafkaStreamsContainer.StateChangeWatcherWatch aKafkaStreamsinstance forKafkaStreams.Statechange.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddStateChangeWatcher(KafkaStreamsContainer.StateChangeWatcher watcher)Register a watcher to be notified ofKafkaStreams.Statechange event.StringapplicationId()Gets configuredStreamsConfig.APPLICATION_ID_CONFIGfor thisKafkaStreamsinstance.StringapplicationServer()Gets configuredStreamsConfig.APPLICATION_SERVER_CONFIGfor thisKafkaStreamsinstance.voidclose(boolean cleanUp, Duration timeout)Closes thisKafkaStreamsinstance and wait up to the timeout for the streams to be closed.voidclose(Duration timeout)Closes thisKafkaStreamsinstance.Optional<Throwable>exception()Gets the last observed exception thrown theKafkaStreamsinstance.Set<StreamsServerInfo>getAllMetadata()Collection<StreamsServerInfo>getAllMetadataForStore(String storeName)Optional<org.apache.kafka.common.serialization.Serde>getDefaultKeySerde()Gets the defaultSerdeconfigured for key.org.apache.kafka.streams.KafkaStreamsgetKafkaStreams()Returns the wrapperKafkaStreamsinstance.<K,V>
LocalStoreAccessor<org.apache.kafka.streams.state.ReadOnlyKeyValueStore<K,V>>getLocalKeyValueStore(String storeName)Optional<StreamsServerInfo>getLocalServerInfo()<K,V>
LocalStoreAccessor<org.apache.kafka.streams.state.ReadOnlySessionStore<K,V>>getLocalSessionStore(String storeName)<K,V>
LocalStoreAccessor<org.apache.kafka.streams.state.ReadOnlyKeyValueStore<K,org.apache.kafka.streams.state.ValueAndTimestamp<V>>>getLocalTimestampedKeyValueStore(String storeName)<K,V>
LocalStoreAccessor<org.apache.kafka.streams.state.ReadOnlyWindowStore<K,org.apache.kafka.streams.state.ValueAndTimestamp<V>>>getLocalTimestampedWindowStore(String storeName)<K,V>
LocalStoreAccessor<org.apache.kafka.streams.state.ReadOnlyWindowStore<K,V>>getLocalWindowStore(String storeName)<K> Optional<StreamsServerInfo>getMetadataForStoreAndKey(String storeName, K key, org.apache.kafka.common.serialization.Serializer<K> keySerializer)org.apache.kafka.clients.producer.Producer<byte[],byte[]>getProducer(Map<String,Object> overrides)Creates a newProducerinstance using the same configs that the Kafka Streams instance.booleanisNotRunning()Checks if theKafkaStreamsis neither RUNNING nor REBALANCING.Map<org.apache.kafka.common.MetricName,? extends org.apache.kafka.common.Metric>metrics()Gets all the currentMetrics for thisKafkaStreamsinstance.ConsumerGroupOffsetsoffsets()Gets the offsets for the topic/partitions assigned to thisKafkaStreamsinstance.voidrestart()voidsetState(State state)Sets the current state of the streams.Future<org.apache.kafka.streams.KafkaStreams.State>start(Executor executor)Asynchronously start the underlyingKafkaStreamsinstance.longstartedSince()Gets the started epoch-time in milliseconds.TimestampedValue<State>state()Gets the current state of the streams.ConfstreamsConfig()Gets the configuration for thisKafkaStreamsinstance.Set<org.apache.kafka.streams.processor.ThreadMetadata>threadMetadata()Gets the local thread metadata.org.apache.kafka.streams.TopologyDescriptiontopologyDescription()Gets theTopologyDescriptionfor thisKafkaStreamsinstance.TopologyMetadatatopologyMetadata()Gets theTopologyMetadataabout the topology runs by thisKafkaStreamsinstance.
-
-
-
Method Detail
-
start
public Future<org.apache.kafka.streams.KafkaStreams.State> start(Executor executor)
Asynchronously start the underlyingKafkaStreamsinstance.- Parameters:
executor- theExecutorinstance to be used for starting the streams.- Returns:
- the future
KafkaStreams.Stateof the streams.
-
setState
public void setState(State state)
Sets the current state of the streams.- Parameters:
state- the KafkaStreams state.
-
state
public TimestampedValue<State> state()
Gets the current state of the streams.- Returns:
- a
TimestampedValueinstance;
-
getDefaultKeySerde
public Optional<org.apache.kafka.common.serialization.Serde> getDefaultKeySerde()
Gets the defaultSerdeconfigured for key.- Returns:
- a optional
Serdeinstance.
-
threadMetadata
public Set<org.apache.kafka.streams.processor.ThreadMetadata> threadMetadata()
Gets the local thread metadata.- Returns:
- a set of
ThreadMetadatainstance.
-
startedSince
public long startedSince()
Gets the started epoch-time in milliseconds.- Returns:
- a unix epoch-time in milliseconds.
-
streamsConfig
public Conf streamsConfig()
Gets the configuration for thisKafkaStreamsinstance.- Returns:
- a
Confinstance.
-
applicationId
public String applicationId()
Gets configuredStreamsConfig.APPLICATION_ID_CONFIGfor thisKafkaStreamsinstance.- Returns:
- a string application.id.
-
applicationServer
public String applicationServer()
Gets configuredStreamsConfig.APPLICATION_SERVER_CONFIGfor thisKafkaStreamsinstance.- Returns:
- a string application.server.
-
exception
public Optional<Throwable> exception()
Gets the last observed exception thrown theKafkaStreamsinstance.- Returns:
- a
Throwableinstance.
-
topologyMetadata
public TopologyMetadata topologyMetadata()
Gets theTopologyMetadataabout the topology runs by thisKafkaStreamsinstance.- Returns:
- a
TopologyMetadatainstance.
-
topologyDescription
public org.apache.kafka.streams.TopologyDescription topologyDescription()
Gets theTopologyDescriptionfor thisKafkaStreamsinstance.- Returns:
- a new
TopologyDescriptioninstance.
-
metrics
public Map<org.apache.kafka.common.MetricName,? extends org.apache.kafka.common.Metric> metrics()
Gets all the currentMetrics for thisKafkaStreamsinstance.- Returns:
- a map of
Metric.
-
offsets
public ConsumerGroupOffsets offsets()
Gets the offsets for the topic/partitions assigned to thisKafkaStreamsinstance. If theKafkaStreamsinstance is not running then no offsets will be computed.- Returns:
- the
ConsumerGroupOffsets.
-
getProducer
public org.apache.kafka.clients.producer.Producer<byte[],byte[]> getProducer(Map<String,Object> overrides)
Creates a newProducerinstance using the same configs that the Kafka Streams instance.- Parameters:
overrides- the producer configs to overrides.
-
close
public void close(Duration timeout)
Closes thisKafkaStreamsinstance.
-
close
public void close(boolean cleanUp, Duration timeout)Closes thisKafkaStreamsinstance and wait up to the timeout for the streams to be closed. Atimeoutof 0 means to return immediately (i.eDuration.ZERO- Parameters:
cleanUp- flag to clean up the local streams states.timeout- the duration to wait for the streams to shutdown.
-
restart
public void restart()
-
getLocalServerInfo
public Optional<StreamsServerInfo> getLocalServerInfo()
-
getAllMetadata
public Set<StreamsServerInfo> getAllMetadata()
-
getAllMetadataForStore
public Collection<StreamsServerInfo> getAllMetadataForStore(String storeName)
-
getMetadataForStoreAndKey
public <K> Optional<StreamsServerInfo> getMetadataForStoreAndKey(String storeName, K key, org.apache.kafka.common.serialization.Serializer<K> keySerializer)
-
getLocalKeyValueStore
public <K,V> LocalStoreAccessor<org.apache.kafka.streams.state.ReadOnlyKeyValueStore<K,V>> getLocalKeyValueStore(String storeName)
-
getLocalTimestampedKeyValueStore
public <K,V> LocalStoreAccessor<org.apache.kafka.streams.state.ReadOnlyKeyValueStore<K,org.apache.kafka.streams.state.ValueAndTimestamp<V>>> getLocalTimestampedKeyValueStore(String storeName)
-
getLocalWindowStore
public <K,V> LocalStoreAccessor<org.apache.kafka.streams.state.ReadOnlyWindowStore<K,V>> getLocalWindowStore(String storeName)
-
getLocalTimestampedWindowStore
public <K,V> LocalStoreAccessor<org.apache.kafka.streams.state.ReadOnlyWindowStore<K,org.apache.kafka.streams.state.ValueAndTimestamp<V>>> getLocalTimestampedWindowStore(String storeName)
-
getLocalSessionStore
public <K,V> LocalStoreAccessor<org.apache.kafka.streams.state.ReadOnlySessionStore<K,V>> getLocalSessionStore(String storeName)
-
isNotRunning
public boolean isNotRunning()
Checks if theKafkaStreamsis neither RUNNING nor REBALANCING.- Returns:
trueif noKafkaStreamsis initialized.
-
addStateChangeWatcher
public void addStateChangeWatcher(KafkaStreamsContainer.StateChangeWatcher watcher)
Register a watcher to be notified ofKafkaStreams.Statechange event.- Parameters:
watcher- theKafkaStreamsContainer.StateChangeWatcherto be registered.
-
getKafkaStreams
public org.apache.kafka.streams.KafkaStreams getKafkaStreams()
Returns the wrapperKafkaStreamsinstance.- Returns:
- the
KafkaStreams.
-
-