29.6. Distributed Execution and Locality
In a Distributed Environment ownership, in regards to the
DistributionManager
and ConsistentHash
, is theoretical; neither of these classes have any knowledge if data is actively in the cache. Instead, these classes are used to determine which node should store the specified key.
To examine the locality of a given key use either of the following options:
- Option 1: Confirm that the key is both found in the cache and the
DistributionManager
indicates it is local, as seen in the following example:(cache.getAdvancedCache().withFlags(SKIP_REMOTE_LOOKUP).containsKey(key) && cache.getAdvancedCache().getDistributionManager().getLocality(key).isLocal())
- Option 2: Query the
DataContainer
directly:cache.getAdvancedCache().getDataContainer().containsKey(key)
Note
If the entry is passivated then theDataContainer
will returnFalse
, regardless of the key's presence.