Search code examples
ignite

How does Ingite affinity-collocation work?


I am reading through the https://apacheignite.readme.io/docs/affinity-collocation, but I didn't get a good unserstanding how the affinity-collocation works or its behavior.

Presume I have an Employee object(its id is 1000) whose companyId is 1, then this Employee object will be collocated with the Company object whose id is 1. That is, they will reside in the same node but in different cache:

Employee Cache: <1000, EmployeeObjWhoseCompanyIdIs1>
Company Cache: <1, CompanyObj>

But What if there is a third cache, say Country Cache, and it also has a key that is 1, that is:

Country Cache: <1, CountryObj>

Then, will the Employee object and the Country object will also reside in the same node?

From the Affinity class definition,it only defines the affKey to which to collocate with, but it doesn't specify the cache that owns this affKey


Solution

  • Yes, they will be stored on one node. However, I would treat this as a coincidence because it happens only because you used same types and values for keys in this particular case. Logically company ID and country ID are not related to each other, so it's not correct to say that they are collocated.