[infinispan-dev] KeyAffinityService

Mircea Markus mmarkus at redhat.com
Thu Jun 13 18:37:02 EDT 2013



Sent from my iPhone

On 13 Jun 2013, at 17:45, cotton-ben <ben.cotton at ALUMNI.RUTGERS.EDU> wrote:

> 
> 
> We need a way for a "foreign" node to be able to come up with the same
> affinityKey produced earlier by a "local" node.
> 
> Thanks for the response, Mircea.  Let me elaborate.
> 
> E.g.  consider the infinispan quick start that is made up of
> AbstractNode.java, Node0.java, Node1.java, Node2.java
> 
> Let's say that @t=0  we execute the following code within Node0.java:
> 
> //assume keySvc reference constructed and .start()  invoked
> 
> Object pinnedDimensionKeyAffinityAtNode0 =
> keySvc.getCollocatedKey(myObjectNaturalKey);
> this.dimensionsPinnedCache.put(pinnedDimensionKeyAffinityAtNode0, myObject);
> 
> 
> Now, let's say it is @t=1 and we want to get() 'myObject' from code within
> Node2.java ... how?
> I don't think it is possible with the existing API.  However if you add the
> signature requested, I could do
> something like this:
> 
> Object pinnedKey = keySvc.getKeyForAddress(getAddress(Node0),
> myObjectNaturalKey);//need this API!
> myObject = this.dimensionsPinnedCache.get(pinnedKey);
Here's one way of doing it:  as you know that myObjectNatKey maps to node1, send an distributed executor task to be executed on Node1 only. This would iterate over all the entries in Node1 and match the object based on myObjNatKey (this should be aggregated in the object itself, or in the key). Of course this approach is costly but it can work if the vast majority of your requests go to Node1.

> 
> 
> I need some way for Node2.java to know that it can re-compute the
> affinityKey rendered by Node0.java ... that way Node2 can operate on <K,V>
> sets pinned by affinity to Node0
> 
> Maybe I am missing something, is there some with the existing 5.3 API for
> Node2 to do this?  Or do we need to add the signature suggested at
> https://issues.jboss.org/browse/ISPN-3112?
I'm thinking about it but might not be as simple as the algorithm i have in mind might break during topology changes.

> As far as I can tell, I think we need to add the requested signature. 
> Without it, I don't think Node2.java can do the operation described above.
> 
> 
> 
> 
> --
> View this message in context: http://infinispan-developer-list.980875.n3.nabble.com/KeyAffinityService-nice-2-recommendations-tp4027152p4027394.html
> Sent from the Infinispan Developer List mailing list archive at Nabble.com.
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev



More information about the infinispan-dev mailing list