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 interface
KafkaStreamsContainer.StateChangeWatcher
Watch aKafkaStreams
instance forKafkaStreams.State
change.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStateChangeWatcher(KafkaStreamsContainer.StateChangeWatcher watcher)
Register a watcher to be notified ofKafkaStreams.State
change event.String
applicationId()
Gets configuredStreamsConfig.APPLICATION_ID_CONFIG
for thisKafkaStreams
instance.String
applicationServer()
Gets configuredStreamsConfig.APPLICATION_SERVER_CONFIG
for thisKafkaStreams
instance.void
close(boolean cleanUp, Duration timeout)
Closes thisKafkaStreams
instance and wait up to the timeout for the streams to be closed.void
close(Duration timeout)
Closes thisKafkaStreams
instance.Optional<Throwable>
exception()
Gets the last observed exception thrown theKafkaStreams
instance.Set<StreamsServerInfo>
getAllMetadata()
Collection<StreamsServerInfo>
getAllMetadataForStore(String storeName)
Optional<org.apache.kafka.common.serialization.Serde>
getDefaultKeySerde()
Gets the defaultSerde
configured for key.org.apache.kafka.streams.KafkaStreams
getKafkaStreams()
Returns the wrapperKafkaStreams
instance.<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 newProducer
instance using the same configs that the Kafka Streams instance.boolean
isNotRunning()
Checks if theKafkaStreams
is neither RUNNING nor REBALANCING.Map<org.apache.kafka.common.MetricName,? extends org.apache.kafka.common.Metric>
metrics()
Gets all the currentMetric
s for thisKafkaStreams
instance.ConsumerGroupOffsets
offsets()
void
restart()
void
setState(State state)
Future<org.apache.kafka.streams.KafkaStreams.State>
start(Executor executor)
Asynchronously start the underlyingKafkaStreams
instance.long
startedSince()
Gets the started epoch-time in milliseconds.TimestampedValue<State>
state()
Gets the current state of the streams.Conf
streamsConfig()
Gets the configuration for thisKafkaStreams
instance.Set<org.apache.kafka.streams.processor.ThreadMetadata>
threadMetadata()
Gets the local thread metadata.org.apache.kafka.streams.TopologyDescription
topologyDescription()
Gets theTopologyDescription
for thisKafkaStreams
instance.TopologyMetadata
topologyMetadata()
Gets theTopologyMetadata
about the topology runs by thisKafkaStreams
instance.
-
-
-
Method Detail
-
start
public Future<org.apache.kafka.streams.KafkaStreams.State> start(Executor executor)
Asynchronously start the underlyingKafkaStreams
instance.- Parameters:
executor
- theExecutor
instance to be used for starting the streams.- Returns:
- the future
KafkaStreams.State
of the streams.
-
setState
public void setState(State state)
-
state
public TimestampedValue<State> state()
Gets the current state of the streams.- Returns:
- a
TimestampedValue
instance;
-
getDefaultKeySerde
public Optional<org.apache.kafka.common.serialization.Serde> getDefaultKeySerde()
Gets the defaultSerde
configured for key.- Returns:
- a optional
Serde
instance.
-
threadMetadata
public Set<org.apache.kafka.streams.processor.ThreadMetadata> threadMetadata()
Gets the local thread metadata.- Returns:
- a set of
ThreadMetadata
instance.
-
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 thisKafkaStreams
instance.- Returns:
- a
Conf
instance.
-
applicationId
public String applicationId()
Gets configuredStreamsConfig.APPLICATION_ID_CONFIG
for thisKafkaStreams
instance.- Returns:
- a string application.id.
-
applicationServer
public String applicationServer()
Gets configuredStreamsConfig.APPLICATION_SERVER_CONFIG
for thisKafkaStreams
instance.- Returns:
- a string application.server.
-
exception
public Optional<Throwable> exception()
Gets the last observed exception thrown theKafkaStreams
instance.- Returns:
- a
Throwable
instance.
-
topologyMetadata
public TopologyMetadata topologyMetadata()
Gets theTopologyMetadata
about the topology runs by thisKafkaStreams
instance.- Returns:
- a
TopologyMetadata
instance.
-
topologyDescription
public org.apache.kafka.streams.TopologyDescription topologyDescription()
Gets theTopologyDescription
for thisKafkaStreams
instance.- Returns:
- a new
TopologyDescription
instance.
-
metrics
public Map<org.apache.kafka.common.MetricName,? extends org.apache.kafka.common.Metric> metrics()
Gets all the currentMetric
s for thisKafkaStreams
instance.- Returns:
- a map of
Metric
.
-
offsets
public ConsumerGroupOffsets offsets()
-
getProducer
public org.apache.kafka.clients.producer.Producer<byte[],byte[]> getProducer(Map<String,Object> overrides)
Creates a newProducer
instance using the same configs that the Kafka Streams instance.- Parameters:
overrides
- the producer configs to overrides.
-
close
public void close(Duration timeout)
Closes thisKafkaStreams
instance.
-
close
public void close(boolean cleanUp, Duration timeout)
Closes thisKafkaStreams
instance and wait up to the timeout for the streams to be closed. Atimeout
of 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 theKafkaStreams
is neither RUNNING nor REBALANCING.
-
addStateChangeWatcher
public void addStateChangeWatcher(KafkaStreamsContainer.StateChangeWatcher watcher)
Register a watcher to be notified ofKafkaStreams.State
change event.- Parameters:
watcher
- theKafkaStreamsContainer.StateChangeWatcher
to be registered.
-
getKafkaStreams
public org.apache.kafka.streams.KafkaStreams getKafkaStreams()
Returns the wrapperKafkaStreams
instance.- Returns:
- the
KafkaStreams
.
-
-