Commit b51d5512 authored by Geoff Simmons's avatar Geoff Simmons

libtrackrdr-kafka: include the host name in client IDs

parent 452933a3
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h>
#include <limits.h>
#include "mq_kafka.h" #include "mq_kafka.h"
#include "miniobj.h" #include "miniobj.h"
...@@ -51,7 +53,8 @@ get_clock_ms(void) ...@@ -51,7 +53,8 @@ get_clock_ms(void)
const char const char
*WRK_Init(int wrk_num) *WRK_Init(int wrk_num)
{ {
char clientid[sizeof("libtrackrdr-kafka-worker-2147483648")]; char clientid[HOST_NAME_MAX + 1 + sizeof("-kafka-worker-2147483648")];
char host[HOST_NAME_MAX + 1];
rd_kafka_conf_t *wrk_conf; rd_kafka_conf_t *wrk_conf;
rd_kafka_topic_conf_t *wrk_topic_conf; rd_kafka_topic_conf_t *wrk_topic_conf;
rd_kafka_t *rk; rd_kafka_t *rk;
...@@ -62,7 +65,8 @@ const char ...@@ -62,7 +65,8 @@ const char
wrk_conf = rd_kafka_conf_dup(conf); wrk_conf = rd_kafka_conf_dup(conf);
wrk_topic_conf = rd_kafka_topic_conf_dup(topic_conf); wrk_topic_conf = rd_kafka_topic_conf_dup(topic_conf);
sprintf(clientid, "libtrackrdr-kafka-worker-%d", wrk_num); AZ(gethostname(host, HOST_NAME_MAX + 1));
sprintf(clientid, "%s-kafka-worker-%d", host, wrk_num);
if (rd_kafka_conf_set(wrk_conf, "client.id", clientid, errmsg, if (rd_kafka_conf_set(wrk_conf, "client.id", clientid, errmsg,
LINE_MAX) != RD_KAFKA_CONF_OK) { LINE_MAX) != RD_KAFKA_CONF_OK) {
MQ_LOG_Log(LOG_ERR, "rdkafka config error [client.id = %s]: %s", MQ_LOG_Log(LOG_ERR, "rdkafka config error [client.id = %s]: %s",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment