It is not exactly what I want. Lets imagine for a while I have kind of router before my jboss eap farm. I know that one of the server have particular entity in its cache, becouse it previulsy handle similar request.
So if I could only trough the key of the entity determinate on which of jboss node it was processed... i could route the next request there.
Your answer is about sending a task to that node in limited to emebeded case. And even if I implement this DistributedCallable the response of it would be serialized which I want to avoid.
I need to know the algorithm responsible for choosing infinispan node (jboss eap node) against cache key.
Infinispan does it just when puting a value, geting value or invoking this callable stuf.
The real question how can I get IP:PORT of the node?
- Unless you're using the same interface, the clustering and web subsystems might be using different addresses. Assuming you're using a servlet, you can retrieve the "web" address using the servlet request port. You could then match that with the address returned by the CacheManager.
- The fact that one node has created an entry in a distributed cache does not mean it will be the owner of that key. You need to use the KeyAffinityService for this.
Maybe I don't uderstand something.
- Tanks to CacheManager I can match server address against embeded infinispan node address. That is something but I still don't know on which node become an owner of particular key.
- KeyAffinityService doesn't help me either, yes, of course thanks to that I can point on which node i.e. local I want to put my values but... stils I cannot determinate where the key was previously put.
The best thnig I can think of is binding all these stuff together with some database support which keeps mapping key --> node_address....
But each function of infinispan API have to use some alorithm to define list owners for a key, so this mapping is already there I think.
My dream is method like: List<Address> CacheContainer.getOwnersForKey(key) or Address CacheContainer.getRandomlySelectedOwnerForKey(key).
Maybe I'm not pricise. Let take a look at some use case:
REQUEST_1 (KEY) --> ROUTER? --> WEB_SERVER_X --> SOME_OBJECT --> INFINISPAN_NODE_Z
REQUEST_2 (KEY) --> ROUTER? --> ??? how can I discover addres of INFINISPAN_NODE_Z the owner of <KEY,SOME_OBJECT> entry?
Can I achieve this using inifinispan API?
DistributionManager distributionManager = cache.getAdvancedCache().getDistributionManager();
Address address = distributionManager.getPrimaryLocation(key);