@@ -24,6 +24,8 @@ class Fluent::Kafka2Output < Output
2424 config_param :partition_key_key , :string , :default => 'partition_key' , :desc => "Field for kafka partition key"
2525 config_param :default_partition_key , :string , :default => nil
2626 config_param :partition_key , :string , :default => 'partition' , :desc => "Field for kafka partition"
27+ config_param :partitioner_hash_function , :enum , list : [ :crc32 , :murmur2 ] , :default => :crc32 ,
28+ :desc => "Specify kafka patrtitioner hash algorithm"
2729 config_param :default_partition , :integer , :default => nil
2830 config_param :use_default_for_unknown_topic , :bool , :default => false , :desc => "If true, default_topic is used when topic not found"
2931 config_param :client_id , :string , :default => 'fluentd'
@@ -99,17 +101,20 @@ def refresh_client(raise_error = true)
99101 @kafka = Kafka . new ( seed_brokers : @seed_brokers , client_id : @client_id , logger : logger , connect_timeout : @connect_timeout , socket_timeout : @socket_timeout , ssl_ca_cert_file_path : @ssl_ca_cert ,
100102 ssl_client_cert : read_ssl_file ( @ssl_client_cert ) , ssl_client_cert_key : read_ssl_file ( @ssl_client_cert_key ) , ssl_client_cert_chain : read_ssl_file ( @ssl_client_cert_chain ) ,
101103 ssl_ca_certs_from_system : @ssl_ca_certs_from_system , sasl_scram_username : @username , sasl_scram_password : @password ,
102- sasl_scram_mechanism : @scram_mechanism , sasl_over_ssl : @sasl_over_ssl , ssl_verify_hostname : @ssl_verify_hostname )
104+ sasl_scram_mechanism : @scram_mechanism , sasl_over_ssl : @sasl_over_ssl , ssl_verify_hostname : @ssl_verify_hostname ,
105+ partitioner : Kafka ::Partitioner . new ( hash_function : @partitioner_hash_function ) )
103106 elsif @username != nil && @password != nil
104107 @kafka = Kafka . new ( seed_brokers : @seed_brokers , client_id : @client_id , logger : logger , connect_timeout : @connect_timeout , socket_timeout : @socket_timeout , ssl_ca_cert_file_path : @ssl_ca_cert ,
105108 ssl_client_cert : read_ssl_file ( @ssl_client_cert ) , ssl_client_cert_key : read_ssl_file ( @ssl_client_cert_key ) , ssl_client_cert_chain : read_ssl_file ( @ssl_client_cert_chain ) ,
106109 ssl_ca_certs_from_system : @ssl_ca_certs_from_system , sasl_plain_username : @username , sasl_plain_password : @password , sasl_over_ssl : @sasl_over_ssl ,
107- ssl_verify_hostname : @ssl_verify_hostname )
110+ ssl_verify_hostname : @ssl_verify_hostname ,
111+ partitioner : Kafka ::Partitioner . new ( hash_function : @partitioner_hash_function ) )
108112 else
109113 @kafka = Kafka . new ( seed_brokers : @seed_brokers , client_id : @client_id , logger : logger , connect_timeout : @connect_timeout , socket_timeout : @socket_timeout , ssl_ca_cert_file_path : @ssl_ca_cert ,
110114 ssl_client_cert : read_ssl_file ( @ssl_client_cert ) , ssl_client_cert_key : read_ssl_file ( @ssl_client_cert_key ) , ssl_client_cert_chain : read_ssl_file ( @ssl_client_cert_chain ) ,
111115 ssl_ca_certs_from_system : @ssl_ca_certs_from_system , sasl_gssapi_principal : @principal , sasl_gssapi_keytab : @keytab , sasl_over_ssl : @sasl_over_ssl ,
112- ssl_verify_hostname : @ssl_verify_hostname )
116+ ssl_verify_hostname : @ssl_verify_hostname ,
117+ partitioner : Kafka ::Partitioner . new ( hash_function : @partitioner_hash_function ) )
113118 end
114119 log . info "initialized kafka producer: #{ @client_id } "
115120 rescue Exception => e
0 commit comments