Refine search
@Override public boolean isLocal(Object key) { return this.topology.getDistribution(key).isPrimary(); } }
@Override public boolean isLocal(Object key) { return this.topology.getDistribution(key).isPrimary(); } }
@Override public boolean accept(Object key, Object value, Metadata metadata) { return clusteringDependentLogic.getCacheTopology().getDistribution(key).isPrimary(); } }
@Override public boolean accept(Object key, Object value, Metadata metadata) { return clusteringDependentLogic.getCacheTopology().getDistribution(keyDataConversion.toStorage(key)).isPrimary(); } }
@Override public boolean shouldModifyIndexes(FlagAffectedCommand command, InvocationContext ctx, DistributionManager distributionManager, RpcManager rpcManager, Object key) { if(key == null) { return ctx.isOriginLocal(); } return (command == null || !command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER)) && (distributionManager == null || distributionManager.getCacheTopology().getDistribution(key).isPrimary()); } };
@Override public boolean shouldModifyIndexes(FlagAffectedCommand command, InvocationContext ctx, DistributionManager distributionManager, RpcManager rpcManager, Object key) { if(key == null) { return ctx.isOriginLocal(); } return !(command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER) || command.hasAnyFlag(FlagBitSets.SKIP_INDEXING)) && (distributionManager == null || distributionManager.getCacheTopology().getDistribution(key).isPrimary()); } };
@Override public boolean shouldModifyIndexes(FlagAffectedCommand command, InvocationContext ctx, DistributionManager distributionManager, RpcManager rpcManager, Object key) { if (key == null || distributionManager == null) { return true; } DistributionInfo info = distributionManager.getCacheTopology().getDistribution(key); // If this is a backup node we should modify the entry in the remote context return info.isPrimary() || info.isWriteOwner() && (ctx.isInTxScope() || !ctx.isOriginLocal() || command != null && command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER)); } },
private String getStringKeyForCache(Cache cache) { LocalizedCacheTopology topology = cache.getAdvancedCache().getDistributionManager().getCacheTopology(); return IntStream.generate(ThreadLocalRandom.current()::nextInt).mapToObj(i -> "key" + i) .filter(key -> topology.getDistribution(key).isPrimary()).findAny().get(); }
private boolean isPrimaryOwner(Cache<?, ?> cache, Object key) { return TestingUtil.extractComponent(cache, ClusteringDependentLogic.class).getCacheTopology().getDistribution(key).isPrimary(); }
public void testDistributionFromPrimaryOwner() throws Exception { Object key = "testDistributionFromPrimaryOwner"; doTestDistribution(key, cacheManagers.stream() .map(cm -> cm.<Object, Integer>getCache(DIST).getAdvancedCache()) .filter(cache -> cache.getDistributionManager().getCacheTopology().getDistribution(key).isPrimary()) .findAny() .get()); }
@Override public TestCache create(String groupName, List<Cache<GroupKey, String>> cacheList) { for (Cache<GroupKey, String> cache : cacheList) { DistributionManager distributionManager = TestingUtil.extractComponent(cache, DistributionManager.class); DistributionInfo distributionInfo = distributionManager.getCacheTopology().getDistribution(groupName); if (distributionInfo.isPrimary()) { return new TestCache(cache, cache.getAdvancedCache()); } } throw new IllegalStateException("didn't find a cache... should never happen!"); } },
private boolean isPrimaryOwner(VisitableCommand cmd) { if (cmd instanceof DataCommand) { return cache.getAdvancedCache().getDistributionManager().getCacheTopology() .getDistribution(((DataCommand) cmd).getKey()).isPrimary(); } else { return true; } }
private static void assertKeyDistribution(Cache<?, ?> cache, String counterName) { WeakCounterImpl counter = getCounter(cache.getCacheManager(), counterName); DistributionManager distributionManager = cache.getAdvancedCache().getDistributionManager(); LocalizedCacheTopology topology = distributionManager.getCacheTopology(); Set<WeakCounterKey> preferredKeys = new HashSet<>(); WeakCounterKey[] keys = counter.getPreferredKeys(); if (keys != null) { for (WeakCounterKey key : keys) { AssertJUnit.assertTrue(topology.getDistribution(key).isPrimary()); AssertJUnit.assertTrue(preferredKeys.add(key)); } } for (WeakCounterKey key : counter.getKeys()) { if (!preferredKeys.remove(key)) { AssertJUnit.assertFalse(topology.getDistribution(key).isPrimary()); } } AssertJUnit.assertTrue(preferredKeys.isEmpty()); }
@Override public TestCache create(String groupName, List<Cache<GroupKey, String>> cacheList) { Cache<GroupKey, String> primaryOwner = null; AdvancedCache<GroupKey, String> backupOwner = null; for (Cache<GroupKey, String> cache : cacheList) { DistributionManager distributionManager = TestingUtil.extractComponent(cache, DistributionManager.class); DistributionInfo distributionInfo = distributionManager.getCacheTopology().getDistribution(groupName); if (primaryOwner == null && distributionInfo.isPrimary()) { primaryOwner = cache; } else if (backupOwner == null && distributionInfo.isWriteOwner()) { backupOwner = cache.getAdvancedCache(); } if (primaryOwner != null && backupOwner != null) { return new TestCache(primaryOwner, backupOwner); } } throw new IllegalStateException("didn't find a cache... should never happen!"); } },
@Override public TestCache create(String groupName, List<Cache<GroupKey, String>> cacheList) { Cache<GroupKey, String> primaryOwner = null; AdvancedCache<GroupKey, String> nonOwner = null; for (Cache<GroupKey, String> cache : cacheList) { DistributionManager distributionManager = TestingUtil.extractComponent(cache, DistributionManager.class); DistributionInfo distributionInfo = distributionManager.getCacheTopology().getDistribution(groupName); if (primaryOwner == null && distributionInfo.isPrimary()) { primaryOwner = cache; } else if (nonOwner == null && !distributionInfo.isWriteOwner()) { nonOwner = cache.getAdvancedCache(); } if (primaryOwner != null && nonOwner != null) { return new TestCache(primaryOwner, nonOwner); } } throw new IllegalStateException("didn't find a cache... should never happen!"); } };
private String findKeyBasedOnOwnership(String keyPrefix, LocalizedCacheTopology cacheTopology, boolean shouldBePrimaryOwner) { for (int i = 0; i < 1000; i++) { String key = keyPrefix + i; boolean isPrimaryOwner = cacheTopology.getDistribution(key).isPrimary(); if (isPrimaryOwner == shouldBePrimaryOwner) { if (shouldBePrimaryOwner) { log.debugf("Found key %s with primary owner %s, segment %d", key, cacheTopology.getLocalAddress(), cacheTopology.getSegment(key)); } else { log.debugf("Found key %s with primary owner != %s, segment %d", key, cacheTopology.getLocalAddress(), cacheTopology.getSegment(key)); } return key; } } throw new RuntimeException("No key could be found for owner, this may be a bug in test or really bad luck!"); }
DistributionInfo distribution = timestampsRegion.getCache().getDistributionManager().getCacheTopology().getDistribution(Person.class.getSimpleName()); SessionFactory qsf = distribution.isPrimary() ? sf2 : sf1;
CacheEntryEvent<K, V> event = (CacheEntryEvent<K, V>) eventWrapper.getEvent(); if (event.isPre() && isClustered || isPrimaryOnly && !clusteringDependentLogic.getCacheTopology().getDistribution(eventWrapper.getKey()).isPrimary()) { return;
CacheEntryEvent<K, V> event = (CacheEntryEvent<K, V>) eventWrapper.getEvent(); if (event.isPre() && isClustered || isPrimaryOnly && !clusteringDependentLogic.getCacheTopology().getDistribution(eventWrapper.getKey()).isPrimary()) { return;
LocalizedCacheTopology cacheTopology = advancedCache(2).getDistributionManager().getCacheTopology(); for (Object key : key2Tx.keySet()) { if (cacheTopology.getDistribution(key).isPrimary()) { migratedKey = key; break;