Class KafkaHealthIndicator
java.lang.Object
io.micronaut.configuration.kafka.health.KafkaHealthIndicator
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,io.micronaut.management.health.indicator.HealthIndicator
,ClusterResourceListener
@Singleton
@Requires(bean=KafkaDefaultConfiguration.class) @Requires(property="kafka.health.enabled",value="true",defaultValue="true")
public class KafkaHealthIndicator
extends Object
implements io.micronaut.management.health.indicator.HealthIndicator, ClusterResourceListener
A
HealthIndicator
for Kafka.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionKafkaHealthIndicator
(io.micronaut.context.BeanContext beanContext, KafkaDefaultConfiguration defaultConfiguration, NetworkClientCreator networkClientCreator, KafkaHealthConfiguration kafkaHealthConfiguration) Constructs a new Kafka health indicator for the given arguments.KafkaHealthIndicator
(AdminClient adminClient, KafkaDefaultConfiguration defaultConfiguration) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
getClusterReplicationFactor
(Config config) Retrieve the cluster "offsets.topic.replication.factor" for the givenConfig
, falling back to "default.replication.factor" if required, in order to support Confluent Cloud hosted Kafka.static int
getMinNodeCount
(Config config) Retrieve the cluster "min.insync.replicas" for the givenConfig
, falling back to "offsets.topic.replication.factor" or "default.replication.factor" if required, in order to support Confluent Cloud hosted Kafka.reactor.core.publisher.Flux<io.micronaut.management.health.indicator.HealthResult>
void
onUpdate
(ClusterResource clusterResource) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Constructor Details
-
KafkaHealthIndicator
@Inject public KafkaHealthIndicator(io.micronaut.context.BeanContext beanContext, KafkaDefaultConfiguration defaultConfiguration, NetworkClientCreator networkClientCreator, KafkaHealthConfiguration kafkaHealthConfiguration) Constructs a new Kafka health indicator for the given arguments.- Parameters:
beanContext
- BeanContextdefaultConfiguration
- The default configurationnetworkClientCreator
- Functional interface to create aNetworkClient
.kafkaHealthConfiguration
- Kafka Health indicator configuration
-
KafkaHealthIndicator
@Deprecated(forRemoval=true) public KafkaHealthIndicator(AdminClient adminClient, KafkaDefaultConfiguration defaultConfiguration) Deprecated, for removal: This API element is subject to removal in a future version.Constructs a new Kafka health indicator for the given arguments.- Parameters:
adminClient
- The admin clientdefaultConfiguration
- The default configuration
-
-
Method Details
-
onUpdate
- Specified by:
onUpdate
in interfaceClusterResourceListener
-
getClusterReplicationFactor
Retrieve the cluster "offsets.topic.replication.factor" for the givenConfig
, falling back to "default.replication.factor" if required, in order to support Confluent Cloud hosted Kafka.- Parameters:
config
- the clusterConfig
- Returns:
- the cluster replication factor, or Integer.MAX_VALUE if none found
-
getMinNodeCount
Retrieve the cluster "min.insync.replicas" for the givenConfig
, falling back to "offsets.topic.replication.factor" or "default.replication.factor" if required, in order to support Confluent Cloud hosted Kafka.- Parameters:
config
- the clusterConfig
- Returns:
- the optional cluster minimum number of replicas that must acknowledge a write
-
getResult
public reactor.core.publisher.Flux<io.micronaut.management.health.indicator.HealthResult> getResult()- Specified by:
getResult
in interfaceio.micronaut.management.health.indicator.HealthIndicator
-
KafkaHealthIndicator(io.micronaut.context.BeanContext,io.micronaut.configuration.kafka.config.KafkaDefaultConfiguration,io.micronaut.configuration.kafka.health.NetworkClientCreator,io.micronaut.configuration.kafka.config.KafkaHealthConfiguration)
instead.