0

IMap でその場で string、date、int 型の特定のポータブル フィールドにインデックスを追加する必要があります。

  1. まず、特定のエントリを保持するマップにインデックスを追加すると、factory-id: XXX の PortableFactory が見つからないことを示す Hazelcast Unhandled Exception がスローされます。
  2. 次に、エントリをマップにロードする前にインデックスを追加する別の方法を試しましたが、インデックスの追加時に問題は見つかりませんでしたが、エントリを再度設定しているときに、上記と同じ例外が発生しました。しかし、驚くべきことに、その例外シナリオのレコードをマップ内に見つけました。

サーバー側でクラス定義を期待するポータブル オブジェクトのインデックスを追加しましたか? ただし、Portable Serialization の場合、ドキュメントに従ってサーバー側でクラス定義を行う必要はありません。

メンバー構成:

<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.6.xsd"
           xmlns="http://www.hazelcast.com/schema/config"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <group>
        <name>dev</name>
        <password>dev-pass</password>
    </group>
    <management-center enabled="true">http://localhost:8085/mancenter</management-center>
    <network>
        <port auto-increment="true" port-count="100">5701</port>
        <outbound-ports>           
            <ports>0</ports>
        </outbound-ports>
        <join>
            <multicast enabled="true">
                <multicast-group>224.2.2.3</multicast-group>
                <multicast-port>54327</multicast-port>
            </multicast>           
            <discovery-strategies>
            </discovery-strategies>
        </join>
        <interfaces enabled="false">
            <interface>10.10.1.*</interface>
        </interfaces>       
    </network>   
    <map name="default">       
        <in-memory-format>BINARY</in-memory-format>
        <backup-count>1</backup-count>                       
        <cache-deserialized-values>INDEX-ONLY</cache-deserialized-values>
    </map>     
    <serialization>
        <portable-version>0</portable-version>
    </serialization>
    <services enable-defaults="true"/>
    <lite-member enabled="false"/>
</hazelcast>

以下のクライアントコードを見つけてください。

private static void DoMapIndexing()
{
IMap<TKey, TValue> map = GetMap<TKey, TValue>("testMap"); 
map.AddIndex("name", false);
map.AddIndex("DOB", true);
}

private static IMap<TKey, TValue> GetMap<TKey, TValue>(string mapName)
{
IHazelcastInstance client = getHazelcastClientConnection();
return client.GetMap<TKey, TValue>(mapName);
}

private static IHazelcastInstance getHazelcastClientConnection()
{
ClientConfig config = new ClientConfig();
config.GetNetworkConfig().AddAddress("x.x.x.x");
IDictionary<int, IPortableFactory> factoryClasses = new Dictionary<int, IPortableFactory>();
factoryClasses.Add(2000, new BusinessObjectPortableFactory());
config.GetSerializationConfig().SetPortableFactories(factoryClasses);
return HazelcastClient.NewHazelcastClient(config);
}

4

0 に答える 0