Skip to content

The field clientIP in ClientConfig.class maybe static? #3294

Closed
@WuShang-3306

Description

@WuShang-3306

The field clientIP in ClientConfig.class maybe static?
The problem is that how much consumer service has, it is need to register same number of times.
And I alse use windows dev environment, this make me worried。NetworkInterface.getNetworkInterfaces method cost too much time, and it need cost coumser nums multiply method cost times, this make my application start too slow.
So, I think the filed The field clientIP in ClientConfig.class maybe static?Or it has other uses?But I only konw little of it.
Can someone tell me?

ClientConfig.class 中的 clientIP 字段或许应该是static的?
目前我使用windows作为本地的开发环境,NetworkInterface.getNetworkInterfaces方法每获取一次都需要花费不少的时间,而且每有一个consumer,就会在注册的时候调用一次这方法,这将花费consumer数量X单次时间 的巨长的时间,甚至在我启用懒加载的时候超出了服务启动完成的时间。
所以我想ClientConfig.class中的字段是否可能是static的?可能这个字段还有其他的用途?我对它了解太少了。
有人能告诉我吗?

public class ClientConfig { public static final String SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY = "com.rocketmq.sendMessageWithVIPChannel"; private String namesrvAddr = NameServerAddressUtils.getNameServerAddresses(); private String clientIP = RemotingUtil.getLocalAddress(); private String instanceName = System.getProperty("rocketmq.client.name", "DEFAULT"); private int clientCallbackExecutorThreads = Runtime.getRuntime().availableProcessors(); protected String namespace; protected AccessChannel accessChannel = AccessChannel.LOCAL;

Activity

odbozhou

odbozhou commented on Aug 26, 2021

@odbozhou
Contributor

ClientIp is dynamically acquired at startup. Static variables are generally used to save constants determined during compilation. Static variables are not suitable.
Obtaining ip information locally does not go through the network, and generally does not take a long time. You can locate the specific time-consuming time.

WuShang-3306

WuShang-3306 commented on Aug 26, 2021

@WuShang-3306
Author

ClientIp is dynamically acquired at startup. Static variables are generally used to save constants determined during compilation. Static variables are not suitable.
Obtaining ip information locally does not go through the network, and generally does not take a long time. You can locate the specific time-consuming time.

Thanks for your help.
There is 100+ consumes in my one service.All register completed cost more then 40 sconds.If i disable Disable some network adapters like wlan, it will Halve the time spent,but i think it still too slow。
Also,clientIp in all consumes is same(I don't use clusters or anything like that),so I think this field meybe static, only query once when class has been loaded.
Or meybe provide one way when in this environment that can set use NetworkInterface.getNetworkInterfaces method only once?
Thank you.

Git-Yang

Git-Yang commented on Aug 28, 2021

@Git-Yang
Member

ClientIp is dynamically acquired at startup. Static variables are generally used to save constants determined during compilation. Static variables are not suitable.
Obtaining ip information locally does not go through the network, and generally does not take a long time. You can locate the specific time-consuming time.

Thanks for your help.
There is 100+ consumes in my one service.All register completed cost more then 40 sconds.If i disable Disable some network adapters like wlan, it will Halve the time spent,but i think it still too slow。
Also,clientIp in all consumes is same(I don't use clusters or anything like that),so I think this field meybe static, only query once when class has been loaded.
Or meybe provide one way when in this environment that can set use NetworkInterface.getNetworkInterfaces method only once?
Thank you.

The clientIP will be obtained only when the clientInstance is started for the first time. Do the 100+ consumptions you mentioned use the same clientInstance?

github-actions

github-actions commented on Sep 8, 2022

@github-actions

This issue is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs.

github-actions

github-actions commented on Sep 12, 2022

@github-actions

This issue was closed because it has been inactive for 3 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @odbozhou@Git-Yang@WuShang-3306

        Issue actions

          The field clientIP in ClientConfig.class maybe static? · Issue #3294 · apache/rocketmq