Map.AddIndex()在Hazelcast .Net客户端中抛出Hazelcast Unhandled Exception

时间:2016-09-28 13:09:52

标签: hazelcast hazelcast-imap

我需要在IMap中动态添加string,date,int类型的某些可移植字段的索引。

  1. 首先,在向Map中添加包含某些条目的索引时,会抛出Hazelcast Unhandled Exception,指出无法找到factory-id:XXX的PortableFactory。
  2. 其次,我尝试了另一种在将条目加载到地图之前添加索引的方法,并且在添加索引时没有发现任何问题,但在再次设置条目时,我得到了与上述相同的异常。但令人惊讶的是,我在地图中找到了一个带有该异常情况的记录。
  3. 为便携式对象添加索引是否需要服务器端的类定义?但是对于可移植序列化,根据文档,不需要在服务器端具有类定义。

    会员配置:

    <?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);
    }

0 个答案:

没有答案