Interface KafkaStreamsContainer
-
- All Superinterfaces:
QueryableKafkaStreams
,QueryCall.QueryCallFactory
- All Known Implementing Classes:
LocalKafkaStreamsContainer
public interface KafkaStreamsContainer extends QueryableKafkaStreams
AKafkaStreamsContainer
is used to encapsulate and to manipulate aKafkaStreams
instance that can be running either locally or remotely.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
KafkaStreamsContainer.KafkaMetricFilter
AKafkaMetricFilter
can be used to only get specific metrics.static interface
KafkaStreamsContainer.StateChangeWatcher
Watch aKafkaStreams
instance forKafkaStreams.State
change.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addStateChangeWatcher(KafkaStreamsContainer.StateChangeWatcher watcher)
Register a watcher to be notified ofKafkaStreams.State
change event.List<LocalStatePartitionsInfo>
allLocalStorePartitionInfos()
Gets the partition restoration and lag for all local state store.String
applicationId()
Gets configuredStreamsConfig.APPLICATION_ID_CONFIG
for thisKafkaStreams
instance.boolean
checkEndpoint(Endpoint endpoint)
Checks whether the givenEndpoint
is the same as this container.void
close(boolean cleanUp, Duration timeout)
Closes thisKafkaStreams
instance and wait up to the timeout for the streams to be closed.default void
close(Duration timeout)
Closes thisKafkaStreams
instance.String
containerId()
Gets the id for this container.org.apache.kafka.clients.producer.Producer<byte[],byte[]>
createNewProducer(Map<String,Object> overrides)
Creates a newProducer
instance using the same configs that the Kafka Streams instance.Optional<org.apache.kafka.common.serialization.Serde>
defaultKeySerde()
Gets the defaultSerde
configured for key.KafkaStreamsInstance
describe()
Describes the localKafkaStreams
instance.Optional<Endpoint>
endpoint()
Gets the endpoint configured for thisKafkaStreams
instance.Optional<Throwable>
exception()
Gets the last observed exception thrown theKafkaStreams
instance.org.apache.kafka.clients.admin.AdminClient
getAdminClient()
Gets a sharedAdminClient
instance for thisKafkaStreams
instance.<K,V>
EventStreamPublisher<K,V>getEventStreamPublisherForType(String eventType)
Gets a newEventStreamPublisher
for the given event-tye.default org.apache.kafka.streams.KafkaStreams
getKafkaStreams()
Returns the wrappedKafkaStreams
instance.default org.apache.kafka.streams.Topology
getTopology()
Returns the wrappedTopology
instance.boolean
isRunning()
Checks if theKafkaStreams
is either RUNNING or REBALANCING.Set<String>
listRegisteredEventStreamTypes()
Gets the set of registered event streams.default Set<MetricGroup>
metrics()
Gets allMetric
s for thisKafkaStreams
instance.Set<MetricGroup>
metrics(KafkaStreamsContainer.KafkaMetricFilter filter)
Gets allMetric
s for thisKafkaStreams
instance matching the specifiedKafkaStreamsContainer.KafkaMetricFilter
.ConsumerGroupOffsets
offsets()
Gets the offsets for the topic/partitions assigned to thisKafkaStreams
instance.<K,V>
voidregisterEventStream(EventStream<K,V> eventStream)
Registers a newEventStream
to this container.void
restart()
Restarts this container.long
startedSince()
Gets the started epoch-time in milliseconds.TimestampedValue<State>
state()
Gets the current state of the streams container.Conf
streamsConfig()
Gets the configuration for thisKafkaStreams
instance.Set<org.apache.kafka.streams.processor.ThreadMetadata>
threadMetadata()
Gets the local thread metadata.StreamsTopologyGraph
topologyGraph()
Gets theStreamsTopologyGraph
for thisKafkaStreams
instance.TopologyMetadata
topologyMetadata()
Gets theTopologyMetadata
about the topology runs by thisKafkaStreams
instance.-
Methods inherited from interface io.streamthoughts.azkarra.api.query.QueryableKafkaStreams
newQueryCall
-
-
-
-
Method Detail
-
restart
void restart()
Restarts this container.
-
close
default void close(Duration timeout)
Closes thisKafkaStreams
instance.
-
close
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.
-
state
TimestampedValue<State> state()
Gets the current state of the streams container.- Returns:
- a
TimestampedValue
instance.
-
threadMetadata
Set<org.apache.kafka.streams.processor.ThreadMetadata> threadMetadata()
Gets the local thread metadata.- Returns:
- a set of
ThreadMetadata
instance.
-
startedSince
long startedSince()
Gets the started epoch-time in milliseconds.- Returns:
- a unix epoch-time in milliseconds.
-
streamsConfig
Conf streamsConfig()
Gets the configuration for thisKafkaStreams
instance.- Returns:
- a
Conf
instance.
-
containerId
String containerId()
Gets the id for this container.- Returns:
- a string container id.
-
applicationId
String applicationId()
Gets configuredStreamsConfig.APPLICATION_ID_CONFIG
for thisKafkaStreams
instance.- Returns:
- a string
application.id
-
endpoint
Optional<Endpoint> endpoint()
Gets the endpoint configured for thisKafkaStreams
instance.- Returns:
- an optional
Endpoint
- See Also:
StreamsConfig.APPLICATION_SERVER_CONFIG
-
exception
Optional<Throwable> exception()
Gets the last observed exception thrown theKafkaStreams
instance.- Returns:
- a
Throwable
instance.
-
topologyMetadata
TopologyMetadata topologyMetadata()
Gets theTopologyMetadata
about the topology runs by thisKafkaStreams
instance.- Returns:
- a
TopologyMetadata
instance.
-
topologyGraph
StreamsTopologyGraph topologyGraph()
Gets theStreamsTopologyGraph
for thisKafkaStreams
instance.- Returns:
- a new
TopologyDescription
instance.
-
metrics
default Set<MetricGroup> metrics()
Gets allMetric
s for thisKafkaStreams
instance.- Returns:
- a
Set
ofMetric
. - See Also:
KafkaStreams.metrics()
-
metrics
Set<MetricGroup> metrics(KafkaStreamsContainer.KafkaMetricFilter filter)
Gets allMetric
s for thisKafkaStreams
instance matching the specifiedKafkaStreamsContainer.KafkaMetricFilter
.- Parameters:
filter
- theKafkaStreamsContainer.KafkaMetricFilter
to be used.- Returns:
- a
Set
ofMetric
. - See Also:
KafkaStreams.metrics()
-
offsets
ConsumerGroupOffsets offsets()
Gets the offsets for the topic/partitions assigned to thisKafkaStreams
instance. If theKafkaStreams
instance is not running then no offsets will be computed.- Returns:
- the
ConsumerGroupOffsets
.
-
defaultKeySerde
Optional<org.apache.kafka.common.serialization.Serde> defaultKeySerde()
Gets the defaultSerde
configured for key.- Returns:
- a optional
Serde
instance.
-
isRunning
boolean isRunning()
Checks if theKafkaStreams
is either RUNNING or REBALANCING.- Returns:
false
if noKafkaStreams
is initialized.
-
getKafkaStreams
default org.apache.kafka.streams.KafkaStreams getKafkaStreams()
Returns the wrappedKafkaStreams
instance. This method can throw anUnsupportedOperationException
if theKafkaStreamsContainer
implementation doesn't manage theKafkaStreams
locally.- Returns:
- the
KafkaStreams
.
-
getTopology
default org.apache.kafka.streams.Topology getTopology()
Returns the wrappedTopology
instance. This method can throw anUnsupportedOperationException
if theKafkaStreamsContainer
implementation doesn't manage theKafkaStreams
locally.- Returns:
- the
Topology
instance.
-
checkEndpoint
boolean checkEndpoint(Endpoint endpoint)
Checks whether the givenEndpoint
is the same as this container.- Parameters:
endpoint
- theEndpoint
to verify.- Returns:
true
if the given host
-
allLocalStorePartitionInfos
List<LocalStatePartitionsInfo> allLocalStorePartitionInfos()
Gets the partition restoration and lag for all local state store.- Returns:
- the list of
LocalStatePartitionsInfo
.
-
describe
KafkaStreamsInstance describe()
Describes the localKafkaStreams
instance.- Returns:
- the
KafkaStreamsInstance
instance.
-
createNewProducer
org.apache.kafka.clients.producer.Producer<byte[],byte[]> createNewProducer(Map<String,Object> overrides)
Creates a newProducer
instance using the same configs that the Kafka Streams instance.- Parameters:
overrides
- the producer configs to overrides.
-
getAdminClient
org.apache.kafka.clients.admin.AdminClient getAdminClient()
Gets a sharedAdminClient
instance for thisKafkaStreams
instance.- Returns:
- a
AdminClient
instance.
-
getEventStreamPublisherForType
<K,V> EventStreamPublisher<K,V> getEventStreamPublisherForType(String eventType)
Gets a newEventStreamPublisher
for the given event-tye.- Parameters:
eventType
- theEventStream
type.- Returns:
- a new
EventStreamPublisher
instance.
-
registerEventStream
<K,V> void registerEventStream(EventStream<K,V> eventStream)
Registers a newEventStream
to this container.- Type Parameters:
K
- the record key-type.V
- the record value-type.- Parameters:
eventStream
- theEventStream
to register.
-
listRegisteredEventStreamTypes
Set<String> listRegisteredEventStreamTypes()
Gets the set of registered event streams.- Returns:
- the
Set
of event-streams.
-
addStateChangeWatcher
void addStateChangeWatcher(KafkaStreamsContainer.StateChangeWatcher watcher)
Register a watcher to be notified ofKafkaStreams.State
change event.- Parameters:
watcher
- theKafkaStreamsContainer.StateChangeWatcher
to be registered.
-
-