protected Cache<K, V>[] getNonOwnersExcludingSelf(Object key, Address self) { Cache<K, V>[] nonOwners = getNonOwners(key); boolean selfInArray = false; for (Cache<?, ?> c : nonOwners) { if (addressOf(c).equals(self)) { selfInArray = true; break; } } if (selfInArray) { Cache<K, V>[] nonOwnersExclSelf = new Cache[nonOwners.length - 1]; int i = 0; for (Cache<K, V> c : nonOwners) { if (!addressOf(c).equals(self)) nonOwnersExclSelf[i++] = c; } return nonOwnersExclSelf; } else { return nonOwners; } }
protected void assertOnAllCaches(Object key, String value) { for (Cache<K, V> c : caches) { Object realVal = c.get(key); if (value == null) { assert realVal == null : "Expecting [" + key + "] to equal [" + value + "] on cache [" + addressOf(c) + "] but was [" + realVal + "]. Owners are " + Arrays.toString(getOwners(key)); } else { assert value.equals(realVal) : "Expecting [" + key + "] to equal [" + value + "] on cache [" + addressOf(c) + "] but was [" + realVal + "]"; } } // Allow some time for all ClusteredGetCommands to finish executing TestingUtil.sleepThread(100); }
protected void assertOwnershipAndNonOwnership(Object key, boolean allowL1) { for (Cache<K, V> c : caches) { DataContainer dc = c.getAdvancedCache().getDataContainer(); InternalCacheEntry ice = dc.get(key); if (isOwner(c, key)) { assert ice != null && ice.getValue() != null : "Fail on owner cache " + addressOf(c) + ": dc.get(" + key + ") returned " + ice; assert ice instanceof ImmortalCacheEntry : "Fail on owner cache " + addressOf(c) + ": dc.get(" + key + ") returned " + safeType(ice); } else { if (allowL1) { assert ice == null || ice.getValue() == null || ice.isL1Entry() : "Fail on non-owner cache " + addressOf(c) + ": dc.get(" + key + ") returned " + safeType(ice); } else { // Segments no longer owned are invalidated asynchronously eventually("Fail on non-owner cache " + addressOf(c) + ": dc.get(" + key + ")", () -> { InternalCacheEntry ice2 = dc.get(key); return ice2 == null || ice2.getValue() == null; }); } } } }