Class SystemEnvPropertyOverrides

  • All Implemented Interfaces:
    KafkaPropertyOverrides

    public final class SystemEnvPropertyOverrides
    extends java.lang.Object
    implements KafkaPropertyOverrides
    Loads Kafka client property overrides from environment variables.

    Variables can either target a specific cluster name or be common across all clusters.

    Common variables, not targeted at a specific cluster, or where the service only accesses a single cluster (which is the most common pattern), should have variable names in the format: KAFKA_<PROPERTY_NAME> where:

    • PROPERTY_NAME is Kafka client property name, in uppercase, with periods . replaced with underscores _

    For example, config boostrap.servers can be set with a variable name of KAFKA_BOOTSTRAP_SERVERS.

    In the unusual situation that a service access multiple Kafka clusters, a variable can target at a specific Kafka cluster. Such variables should have a name in the format: KAFKA_<CLUSTER_NAME>_<PROPERTY_NAME> where:

    • CLUSTER_NAME is the specific name of the Kafka cluster, as returned by KafkaTopicDescriptor.cluster()), in uppercase and any dashes - replaced with underscores _.
    • PROPERTY_NAME is Kafka client property name, in uppercase, with periods . replaced with underscores _

    For example, config boostrap.servers for the main-cluster cluster can be set with a variable name of KAFKA_MAIN_CLUSTER_BOOTSTRAP_SERVERS.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.util.Map<java.lang.String,​?> get​(java.lang.String clusterName)
      Get Kafka client property overrides for a cluster.
      int hashCode()  
      void init​(java.util.Set<java.lang.String> clusterNames)
      Initialize the overrides provider
      static KafkaPropertyOverrides systemEnvPropertyOverrides()
      Factory method
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • systemEnvPropertyOverrides

        public static KafkaPropertyOverrides systemEnvPropertyOverrides()
        Factory method
        Returns:
        kafka overrides.
      • init

        public void init​(java.util.Set<java.lang.String> clusterNames)
        Description copied from interface: KafkaPropertyOverrides
        Initialize the overrides provider
        Specified by:
        init in interface KafkaPropertyOverrides
        Parameters:
        clusterNames - the set of known Kafka cluster names.
      • get

        public java.util.Map<java.lang.String,​?> get​(java.lang.String clusterName)
        Description copied from interface: KafkaPropertyOverrides
        Get Kafka client property overrides for a cluster.
        Specified by:
        get in interface KafkaPropertyOverrides
        Parameters:
        clusterName - the name of the cluster to get the overrides for.
        Returns:
        property overrides.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object