0

我正在使用 hazelcast v3.6(客户端-服务器模式)。客户端和服务器配置的相关部分复制如下。当我调用 IMap.size() 时,我得到了插入测试集群(2 个节点)的完整数据集的计数。但是,当我得到 keySet 或 entrySet 时,我只得到了一半的键/对象的集合。我尝试从客户端运行 localKeySet ,但这会引发以下异常:

Exception in thread "main" java.lang.UnsupportedOperationException: Locality is ambiguous for client!!!
    at com.hazelcast.client.proxy.ClientMapProxy.localKeySet(ClientMapProxy.java:1172)

我认为 localKeySet 在客户端上不可用,但也需要重新确认。

客户端配置- 相关部分,而不是完整配置:

    <hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-3.6.xsd"
                      xmlns="http://www.hazelcast.com/schema/client-config"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

        <properties>
            <property name="hazelcast.client.shuffle.member.list">true</property>
            <property name="hazelcast.client.heartbeat.timeout">60000</property>
            <property name="hazelcast.client.heartbeat.interval">5000</property>
            <property name="hazelcast.client.event.thread.count">5</property>
            <property name="hazelcast.client.event.queue.capacity">1000000</property>
            <property name="hazelcast.client.invocation.timeout.seconds">120</property>
        </properties>


        <network>
            <cluster-members>
<!-- ip addresses replaced -->
                <address>101.102.103.104</address>
                <address>101.102.103.105</address>
            </cluster-members>
            <smart-routing>true</smart-routing>
            <redo-operation>true</redo-operation>
            <connection-timeout>60000</connection-timeout>
            <connection-attempt-period>3000</connection-attempt-period>
            <connection-attempt-limit>2</connection-attempt-limit>
            <socket-options>
                <tcp-no-delay>false</tcp-no-delay>
                <keep-alive>true</keep-alive>
                <reuse-address>true</reuse-address>
                <linger-seconds>3</linger-seconds>
                <timeout>-1</timeout>
                <buffer-size>32</buffer-size>
            </socket-options>
        </network>

服务器配置-相关部分

   <network>
        <port auto-increment="true" port-count="100">5701</port>
        <outbound-ports>
            <ports>0-5900</ports>
        </outbound-ports>
        <join>
            <multicast enabled="false">
            </multicast>
            <tcp-ip enabled="true">
                <member>101.102.103.104</member>
                <member>101.102.103.105</member>
             </tcp-ip>
        </join>
        <interfaces enabled="true">
            <interface>101.102.103.104</interface> <!-- this is modified for the second server node -->
        </interfaces>
        <ssl enabled="false" />
        <socket-interceptor enabled="false" />
        <symmetric-encryption enabled="false">
            <algorithm>PBEWithMD5AndDES</algorithm>
            <!-- salt value to use when generating the secret key -->
            <salt>test</salt>
            <!-- pass phrase to use when generating the secret key -->
            <password>testpass</password>
            <!-- iteration count to use when generating the secret key -->
            <iteration-count>19</iteration-count>
        </symmetric-encryption>
    </network>

关于可能导致问题的原因以及解决方法的任何想法?

更新:我尝试在另一个两个节点集群上复制设置,但无法重现相同的问题。当我在新集群上调用 keySet 时,我得到了完整的密钥集,而不是一半(与原始集群不同)。我知道我可以使用谓词而不是获取整个 keySet。

更新 我将在不久的将来尝试这样做 - 我必须挖掘日志。当我关闭一个节点并且第二个节点成为所有数据的主节点时,问题得到了解决(它是一个异步复制因子为 1 的双节点测试集群)。之后,当我再次启动第二个节点时,数据再次分发,我没有看到双节点集群有任何问题。因此,集群启动后似乎发生了一些事情,导致 hazelcast 客户端从两个节点获取映射值,但对键集/条目集的任何调用都只是从一个节点获取键/值。我尝试在 hazelcast 客户端(xml 文件)中切换顺序,以查看这是否会更改客户端正在接收的键集/条目,但这并没有解决问题。

4

0 回答 0