Class ApacheKafkaUtils

java.lang.Object
com.linkedin.venice.pubsub.adapter.kafka.ApacheKafkaUtils

public class ApacheKafkaUtils extends Object
  • Field Details

    • EMPTY_RECORD_HEADERS

      public static final org.apache.kafka.common.header.internals.RecordHeaders EMPTY_RECORD_HEADERS
  • Constructor Details

    • ApacheKafkaUtils

      public ApacheKafkaUtils()
  • Method Details

    • convertToKafkaSpecificHeaders

      public static org.apache.kafka.common.header.internals.RecordHeaders convertToKafkaSpecificHeaders(PubSubMessageHeaders headers)
    • validateAndCopyKafkaSSLConfig

      public static boolean validateAndCopyKafkaSSLConfig(VeniceProperties veniceProperties, Properties properties)
      This function will extract SSL related config if Kafka SSL is enabled.
      Parameters:
      veniceProperties -
      properties -
      Returns:
      whether Kafka SSL is enabled or not0
    • isKafkaSSLProtocol

      public static boolean isKafkaSSLProtocol(PubSubSecurityProtocol kafkaProtocol)
    • isKafkaProtocolValid

      public static boolean isKafkaProtocolValid(String kafkaProtocol)
    • isKafkaSSLProtocol

      public static boolean isKafkaSSLProtocol(String kafkaProtocol)
    • generateClientId

      public static String generateClientId(String clientName, String brokerAddress)
      Generates a standardized and unique client ID for Kafka clients.

      This ensures uniqueness in client IDs, preventing naming collisions that could cause `InstanceAlreadyExistsException` during JMX metric registration. If multiple Kafka clients share the same client ID, Kafka's internal JMX registration can fail, leading to errors. By appending a timestamp, this method guarantees that each generated ID is unique.

      If the provided client name is null, it defaults to "kc". If the broker address is null, it defaults to an empty string. The generated client ID follows the format:

      clientName-brokerAddress-timestamp

      Parameters:
      clientName - The name of the client (can be null, defaults to "kc").
      brokerAddress - The broker address (can be null, defaults to an empty string).
      Returns:
      A unique client ID in the format: clientName-brokerAddress-timestamp.