@Override protected final boolean isOwner(Cache cache, Object key) { return DistributionTestHelper.isOwner(cache, key); } }
@Override protected final boolean isOwner(Cache cache, Object key) { return DistributionTestHelper.isOwner(cache, key); } }
@Override protected final boolean isOwner(Cache cache, Object key) { return DistributionTestHelper.isOwner(cache, key); } }
@Override protected final boolean isOwner(Cache cache, Object key) { return DistributionTestHelper.isOwner(cache, key); } }
@Override protected final boolean isOwner(Cache cache, Object key) { return DistributionTestHelper.isOwner(cache, key); } }
@Override protected final boolean isOwner(Cache cache, Object key) { return DistributionTestHelper.isOwner(cache, key); } }
protected boolean isOwner(Cache<?, ?> c, Object key) { return DistributionTestHelper.isOwner(c, key); }
public static <K, V> Collection<Cache<K, V>> getNonOwners(Object key, List<Cache<K, V>> caches) { List<Cache<K, V>> nonOwners = new ArrayList<Cache<K, V>>(); for (Cache<K, V> c : caches) if (!isOwner(c, key)) nonOwners.add(c); return nonOwners; }
public static <K, V> Collection<Cache<K, V>> getOwners(Object key, List<Cache<K, V>> caches) { List<Cache<K, V>> owners = new ArrayList<Cache<K, V>>(); for (Cache<K, V> c : caches) { if (isFirstOwner(c, key)) { owners.add(c); break; } } for (Cache<K, V> c : caches) if (isOwner(c, key) && !isFirstOwner(c, key)) owners.add(c); return owners; }
public void testDisjointSetTransaction() throws Exception { MagicKey k1 = new MagicKey(cache(0), cache(1)); MagicKey k2 = new MagicKey(cache(1), cache(2)); // make sure the owners of k1 and k2 are NOT the same! Set<Address> k1Owners = new HashSet<Address>(); Set<Address> k2Owners = new HashSet<Address>(); for (Cache<?, ?> cache: caches()) { if (isOwner(cache, k1)) k1Owners.add(addressOf(cache)); if (isOwner(cache, k2)) k2Owners.add(addressOf(cache)); } assert k1Owners.size() == 2: "Expected 2 owners for k1; was " + k1Owners; assert k2Owners.size() == 2: "Expected 2 owners for k1; was " + k2Owners; assert !k1Owners.equals(k2Owners) : format("k1 and k2 should have different ownership set. Was %s and %s", k1Owners, k2Owners); tm(0).begin(); cache(0).put(k1, "v1"); cache(0).put(k2, "v2"); tm(0).commit(); } }
public static void assertInStores(List<? extends Cache> caches, String key, String value) { EntryVersion ownerVersion = null; for (Cache c: caches) { CacheLoader store = TestingUtil.getFirstLoader(c); if (isOwner(c, key)) { assertIsInContainerImmortal(c, key); MarshalledEntry me = store.load(key); assertEquals(me.getValue(), value); ownerVersion = me.getMetadata().version(); } } assertNotNull(ownerVersion); if (caches.size() == 1) { return; } int equalVersions = 0; for (Cache c: caches) { CacheLoader store = TestingUtil.getFirstLoader(c); if (!isOwner(c, key)) { MarshalledEntry me = store.load(key); if (me != null && me.getMetadata() != null && ownerVersion.equals(me.getMetadata().version())) { assertEquals(me.getValue(), value); ++equalVersions; } } } assertEquals(equalVersions, 1); } }
public static void assertOwnershipAndNonOwnership(List<? extends Cache> caches, Object key) { EntryVersion ownerVersion = null; for (Cache c: caches) { DataContainer dc = c.getAdvancedCache().getDataContainer(); InternalCacheEntry ice = dc.peek(key); if (isOwner(c, key)) { assert ice != null : "Fail on owner cache " + addressOf(c) + ": dc.get(" + key + ") returned null!"; assert ice instanceof ImmortalCacheEntry : "Fail on owner cache " + addressOf(c) + ": dc.get(" + key + ") returned " + safeType(ice); ownerVersion = ice.getMetadata().version(); } } assertNotNull(ownerVersion); if (caches.size() == 1) { return; } int equalVersions = 0; for (Cache c: caches) { DataContainer dc = c.getAdvancedCache().getDataContainer(); InternalCacheEntry ice = dc.peek(key); if (!isOwner(c, key)) { if (ice == null) continue; if (ice != null && ice.getMetadata() != null && ownerVersion.equals(ice.getMetadata().version())) ++equalVersions; } } assertEquals(equalVersions, 1); }
int j=0, k = 0; for (int i=0; i<4; i++) { if (DistributionTestHelper.isOwner(cache(i), hello)) owners[j++] = i; else