AWS 上的 Hazelcast 客户端配置

Hazelcast-client configuration on AWS

我的问题是关于 hazelcast-client 配置的。 据我了解,如果配置正确,客户端应该从 AWS api 自动获取 hazelcast 服务器节点 IP,问题是甚至不尝试连接。

这是我找到的一些日志。

Caused by: java.lang.IllegalStateException: Unable to connect to any address in the config! The following addresses were tried: []
    at com.hazelcast.client.spi.impl.ClusterListenerSupport.connectToCluster(ClusterListenerSupport.java:178)
    at com.hazelcast.client.spi.impl.ClientClusterServiceImpl.start(ClientClusterServiceImpl.java:189)

这里还有客户端配置

<bean id="hazelcastInstance" class="com.hazelcast.client.HazelcastClient"  factory-method="newHazelcastClient">
        <constructor-arg>
            <bean class="com.hazelcast.client.config.ClientConfig">
                <property name="groupConfig">
                    <bean class="com.hazelcast.config.GroupConfig">
                        <property name="name" value="dev"/>
                    </bean>
                    </property>

                     <property name="properties">
                       <props>
                       <prop key="hazelcast.icmp.enabled">true</prop>
                       </props>
                     </property>
                <property name="networkConfig">
                    <bean class="com.hazelcast.client.config.ClientNetworkConfig">

                    <property name="awsConfig">
                            <bean class="com.hazelcast.client.config.ClientAwsConfig">
                                <property name="insideAws" value="true" />
                                <property name="enabled" value="${hazelcast.aws.enabled:false}" />
                                <property name="region" value="${hazelcast.aws.region:set-me}" />
                                <property name="accessKey"value="key" />

                                <property name="secretKey" value="secret"/>


                                <property name="hostHeader" value="ec2.amazonaws.com"/>
                                <property name="iamRole" value="${hazelcast.aws.iam.role:#{null}}"/>
                                <!-- <property name="securityGroupName" value="${hazelcast.aws.securityGroupName:#{null}}" /> -->
                                <property name="tagKey" value="${hazelcast.aws.tagKey:hazelcast-cluster}" />
                                <property name="tagValue" value="${hazelcast.aws.tagValue:#{null}}" />
                                <property name="connectionTimeoutSeconds" value="${hazelcast.aws.connectionTimeout:15}" />

                            </bean>
                        </property> 
                    </bean>
                </property>
            </bean>

        </constructor-arg>
    </bean>

还尝试强制服务器 ip,行得通。我需要客户端自动发现服务器 ips。有什么线索吗?

如果您希望客户端发现AWS(或任何其他云)上的集群,则需要使用发现插件机制。旧的 AWS 发现仅供会员使用。

请参阅https://github.com/hazelcast/hazelcast-aws