简体   繁体   English

Hazelcast客户端:如何设置端口

[英]Hazelcast client: how to set the port

I have a hazelcast cluster running and want to connect a client to it. 我有一个运行的hazelcast集群,并希望将客户端连接到它。

The hazelcast cluster is running on the default port 5701. I know this and can even mandate it in the server configuration. hazelcast集群正在默认端口5701上运行。我知道这一点,甚至可以在服务器配置中强制执行它。

The client however starts scanning a random set of ports sometimes trying more than 10 ports before finally attempting 5701 at which point it succeeds. 然而,客户端开始扫描一组随机端口,有时尝试超过10个端口,最后尝试5701,此时它成功。

This is however an excruciatingly slow process. 然而,这是一个极其缓慢的过程。

Is there a way to tell the client that it should first try port 5701? 有没有办法告诉客户端应该首先尝试端口5701?

Note that I am configuring the client programmatically. 请注意,我正在以编程方式配置客户端。 Does anyone have any pointers? 有没有人有任何指针?

UPDATE : note that I'm using the aws cluster detection meaning I can't simply hardcode the addresses with the ports included. 更新 :请注意,我正在使用aws群集检测,这意味着我不能简单地使用包含的端口对地址进行硬编码。

ClientConfig config = new ClientConfig();
ClientAwsConfig awsConfig = new ClientAwsConfig();
awsConfig.setEnabled(true);
awsConfig.setTagKey(getConfig().getAmazonTagKey());
awsConfig.setTagValue(getConfig().getAmazonTagValue());
awsConfig.setRegion(getConfig().getAmazonRegion());
config.getNetworkConfig().setAwsConfig(awsConfig);
client = HazelcastClient.newHazelcastClient(config);

添加以下工作:

awsConfig.setProperty("hz-port", "5701");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM