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

@Singleton @Requires(beans=org.apache.kafka.clients.admin.AdminClient.class) @Requires(property="kafka.health.enabled",value="true",defaultValue="true") public class KafkaHealthIndicator extends Object implements io.micronaut.management.health.indicator.HealthIndicator
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

    Constructors
    Constructor
    Description
    KafkaHealthIndicator(AdminClient adminClient, KafkaDefaultConfiguration defaultConfiguration)
    Constructs a new Kafka health indicator for the given arguments.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Retrieve the cluster "offsets.topic.replication.factor" for the given Config, falling back to "default.replication.factor" if required, in order to support Confluent Cloud hosted Kafka.
    static int
    Retrieve the cluster "min.insync.replicas" for the given Config, 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>
     

    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

      public KafkaHealthIndicator(AdminClient adminClient, KafkaDefaultConfiguration defaultConfiguration)
      Constructs a new Kafka health indicator for the given arguments.
      Parameters:
      adminClient - The admin client
      defaultConfiguration - The default configuration
  • Method Details

    • getClusterReplicationFactor

      public static int getClusterReplicationFactor(Config config)
      Retrieve the cluster "offsets.topic.replication.factor" for the given Config, falling back to "default.replication.factor" if required, in order to support Confluent Cloud hosted Kafka.
      Parameters:
      config - the cluster Config
      Returns:
      the cluster replication factor, or Integer.MAX_VALUE if none found
    • getMinNodeCount

      public static int getMinNodeCount(Config config)
      Retrieve the cluster "min.insync.replicas" for the given Config, falling back to "offsets.topic.replication.factor" or "default.replication.factor" if required, in order to support Confluent Cloud hosted Kafka.
      Parameters:
      config - the cluster Config
      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 interface io.micronaut.management.health.indicator.HealthIndicator