You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by "Roger Fischer (CW)" <rf...@Brocade.com> on 2017/08/17 22:06:43 UTC

How to define the Affinity Key in XML

Hello,

how does one define the affinity key in XML?

The documentation describes only the @CacheAffinityKeyMapped annotation.

I have found a couple of examples that define the affinity key in the cacheKeyConfiguration. For example: modules/yardstick/config/ignite-bin-multicast-config.xml

    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" parent="base-ignite.cfg">
        ...
        <property name="cacheKeyConfiguration">
            <list>
                <bean class="org.apache.ignite.cache.CacheKeyConfiguration">
                    <property name="typeName" value="BinaryKeyWithLegacyIdentity"/>
                    <property name="affinityKeyFieldName" value="f3" />
                </bean>

However, when I try to add cacheKeyConfiguration to my XML config file, I get an exception:

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'cacheKeyConfiguration' of bean class [org.apache.ignite.configuration.CacheConfiguration]: Bean property 'cacheKeyConfiguration' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

Also, looking at the configuration XSD (IgniteConfigurationSection.xsd), affinityKeyFieldName seems to be allowed only in the binaryConfiguration.

I have two caches:
* Switches with a UUID as the key (representing switchId)
* PortStats with  a POJO key (dateDate and PortId), and a switchId field in the object POJO

I want to use switchId as the affinity key.
* For the Switch cache the affinity key is the same as the object's key. So, I believe, no special config is required.
* For the PortStats cache, the affinity key is not part of the object's key, but is a regular field in the object.

I don't know how to configure (in XML) the latter.

Thanks...

Roger



Re: How to define the Affinity Key in XML

Posted by vkulichenko <va...@gmail.com>.
Roger,

CacheKeyConfiguration is set on IgniteConfiguration, not CacheConfiguration.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-to-define-the-Affinity-Key-in-XML-tp16264p16266.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.