Reputation: 1
Using Ignite 2.6.0
What I would like to do: Use a class method to compute affinity key value for a cache. In other words for IgniteCache<Key, Value>
I want to use Key::someMethod
to compute the affinity key.
The default GridCacheDefaultAffinityKeyMapper
class does not seem to support using class methods.
So I thought of using CacheConfiguration::setAffinityMapper(AffinityKeyMapper)
with a custom class implementing AffinityKeyMapper
. But AffinityKeyMapper
is marked as deprecated.
If I am understanding things correctly, my two choices are
1. Compute the required affinity at object construction time and use AffinityKeyMapped
2. Ignore the deprecation warning and use CacheConfiguration::setAffinityMapper(AffinityKeyMapper)
Which of these is the right way, or is there a third way?
Upvotes: 0
Views: 121
Reputation: 8390
Ignite stores data in binary format and do not deserialize objects on server side unless you ask explicitly about this in the code (for example, if you run a compute job and get something from a cache). As a matter of fact, in general case there are no key/value classes at all on server nodes, therefore there is no way to invoke a method or use AffinityKeyMapper
. That's why it's deprecated.
I would recommend to predefine the affinity key value when you create the key object (i.e. go with option #1).
Upvotes: 1