You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by SJTU胡昊坤 <ge...@gmail.com> on 2018/10/11 15:49:29 UTC

How to manage Kafka quota configuration with java code?

Hi community,
I'm trying to implement quota configuration function in my own kafka portal
program written in Spring Boot. I found out that there is no API for me to
do that. So I read the source code and here is my way:

write {"version":1,"config":{"producer_byte_rate":"1000"}} with path
"/config/clients/${clientId}" to zookeeper.
and write config change
like {"entity_path":"clients/${clientId}","version":2} with path
"/config/changes/config_change_0000000001" to zookeeper.
But the quota configuration function didn't work.
Then I use kafka-configs.sh to get the same result in zookeeper, but the
script work!
And I'm totally lost...
Is there anyone can help me please?
-- 

Haokun Hu



E-mail: geekun94@gmail.com or 18817874087@163.com

Re: How to manage Kafka quota configuration with java code?

Posted by SJTU胡昊坤 <ge...@gmail.com>.
My kafka version is 1.1.0, so it has two versions of notification format.
Anyway, the problem is solved by restarting the broker. I guess the
listening thread of broker might be shutdown during my debugging. Anyway,
Thanks!

赖剑清 <la...@tp-link.com.cn> 于2018年10月12日周五 下午5:32写道:

> Hi,
>
> I use kafka 0.10.0.0, the entity type enum may be different with yours.
> However, in the DynamicConfigManager.ConfigChangedNotificationHandler I
> found that the right format of a config change notification should be as:
> {"version": 1, "entity_type": "topic/client", "entity_name":
> "topic_name/client_id"}
>
> What's more, it do match at the entrance like this:
> case Some(mapAnon: Map[_, _]) =>
>           val map = mapAnon collect
>             { case (k: String, v: Any) => k -> v }
>           require(map("version") == 1)
>
> >-----Original Message-----
> >From: SJTU胡昊坤 [mailto:geekun94@gmail.com]
> >Sent: Thursday, October 11, 2018 11:49 PM
> >To: users@kafka.apache.org
> >Subject: How to manage Kafka quota configuration with java code?
> >
> >Hi community,
> >I'm trying to implement quota configuration function in my own kafka
> portal
> >program written in Spring Boot. I found out that there is no API for me
> to do
> >that. So I read the source code and here is my way:
> >
> >write {"version":1,"config":{"producer_byte_rate":"1000"}} with path
> >"/config/clients/${clientId}" to zookeeper.
> >and write config change
> >like {"entity_path":"clients/${clientId}","version":2} with path
> >"/config/changes/config_change_0000000001" to zookeeper.
> >But the quota configuration function didn't work.
> >Then I use kafka-configs.sh to get the same result in zookeeper, but the
> script
> >work!
> >And I'm totally lost...
> >Is there anyone can help me please?
> >--
> >
> >Haokun Hu
> >
> >
> >
> >E-mail: geekun94@gmail.com or 18817874087@163.com
>


-- 

Haokun Hu



E-mail: geekun94@gmail.com or 18817874087@163.com

RE: How to manage Kafka quota configuration with java code?

Posted by 赖剑清 <la...@tp-link.com.cn>.
Hi,

I use kafka 0.10.0.0, the entity type enum may be different with yours. However, in the DynamicConfigManager.ConfigChangedNotificationHandler I found that the right format of a config change notification should be as:
{"version": 1, "entity_type": "topic/client", "entity_name": "topic_name/client_id"}

What's more, it do match at the entrance like this:
case Some(mapAnon: Map[_, _]) =>
          val map = mapAnon collect
            { case (k: String, v: Any) => k -> v }
          require(map("version") == 1)

>-----Original Message-----
>From: SJTU胡昊坤 [mailto:geekun94@gmail.com]
>Sent: Thursday, October 11, 2018 11:49 PM
>To: users@kafka.apache.org
>Subject: How to manage Kafka quota configuration with java code?
>
>Hi community,
>I'm trying to implement quota configuration function in my own kafka portal
>program written in Spring Boot. I found out that there is no API for me to do
>that. So I read the source code and here is my way:
>
>write {"version":1,"config":{"producer_byte_rate":"1000"}} with path
>"/config/clients/${clientId}" to zookeeper.
>and write config change
>like {"entity_path":"clients/${clientId}","version":2} with path
>"/config/changes/config_change_0000000001" to zookeeper.
>But the quota configuration function didn't work.
>Then I use kafka-configs.sh to get the same result in zookeeper, but the script
>work!
>And I'm totally lost...
>Is there anyone can help me please?
>--
>
>Haokun Hu
>
>
>
>E-mail: geekun94@gmail.com or 18817874087@163.com