void updateNodeToBucketMap( HashMap<InternalDistributedMember, HashSet<Integer>> nodeToBuckets, Set<Integer> buckets) { for (int id : buckets) { InternalDistributedMember node = getOrCreateNodeForBucketWrite(id, null); if (nodeToBuckets.containsKey(node)) { nodeToBuckets.get(node).add(id); } else { HashSet<Integer> set = new HashSet<Integer>(); set.add(id); nodeToBuckets.put(node, set); } } }
void updateNodeToBucketMap( HashMap<InternalDistributedMember, HashMap<Integer, HashSet>> nodeToBuckets, HashMap<Integer, HashSet> bucketKeys) { for (int id : bucketKeys.keySet()) { InternalDistributedMember node = getOrCreateNodeForBucketWrite(id, null); if (nodeToBuckets.containsKey(node)) { nodeToBuckets.get(node).put(id, bucketKeys.get(id)); } else { HashMap<Integer, HashSet> map = new HashMap<Integer, HashSet>(); map.put(id, bucketKeys.get(id)); nodeToBuckets.put(node, map); } } }
public static HashMap<InternalDistributedMember, HashSet<Integer>> groupByMemberToBuckets( PartitionedRegion pr, Set<Integer> bucketSet, boolean primaryOnly) { if (primaryOnly) { HashMap<InternalDistributedMember, HashSet<Integer>> memberToBucketsMap = new HashMap(); try { for (Integer bucketId : bucketSet) { InternalDistributedMember mem = pr.getOrCreateNodeForBucketWrite(bucketId, null); HashSet buckets = memberToBucketsMap.get(mem); if (buckets == null) { buckets = new HashSet(); // faster if this was an ArrayList memberToBucketsMap.put(mem, buckets); } buckets.add(bucketId); } } catch (NoSuchElementException done) { } return memberToBucketsMap; } else { return pruneNodes(pr, bucketSet); } } }
/** * Find the bucket in region2 that matches the bucket id from region1. */ protected BucketRegion getMatchingBucket(PartitionedRegion region, Integer bucketId) { // Force the bucket to be created if it is not already region.getOrCreateNodeForBucketWrite(bucketId, null); return region.getDataStore().getLocalBucketById(bucketId); } }
mem = pr.getOrCreateNodeForBucketWrite(bucketId.intValue(), null); } else { mem = pr.getOrCreateNodeForBucketRead(bucketId.intValue());
@Test public void createMissingBucket() throws BucketNotFoundException { setUpMockBucket(0); when(fileDataStore.getLocalBucketById(eq(0))).thenReturn(null); when(fileAndChunkRegion.getOrCreateNodeForBucketWrite(eq(0), (RetryTimeKeeper) any())) .then(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { when(fileDataStore.getLocalBucketById(eq(0))).thenReturn(fileAndChunkBuckets.get(0)); return null; } }); assertNotNull(repoManager.getRepository(userRegion, 0, null)); }
final InternalDistributedMember targetNode = getOrCreateNodeForBucketWrite(bucketId, null); retryNode = getOrCreateNodeForBucketWrite(bucketId, retryTime); } catch (TimeoutException ignore) { if (getRegionAdvisor().isStorageAssignedForBucket(bucketId)) { retryNode = getOrCreateNodeForBucketWrite(bucketId, retryTime); if (lastNode.equals(retryNode)) { if (retryTime == null) { retryNode = getOrCreateNodeForBucketWrite(bucketId, retryTime);
final InternalDistributedMember targetNode = getOrCreateNodeForBucketWrite(bucketId, null); retryNode = getOrCreateNodeForBucketWrite(bucketId, retryTime); } catch (TimeoutException ignore) { if (getRegionAdvisor().isStorageAssignedForBucket(bucketId)) { retryNode = getOrCreateNodeForBucketWrite(bucketId, retryTime); if (lastNode.equals(retryNode)) { if (retryTime == null) { retryNode = getOrCreateNodeForBucketWrite(bucketId, retryTime);
private VersionedObjectList sendMsgByBucket(final Integer bucketId, RemoveAllPRMessage prMsg, PartitionedRegion pr) { // retry the put remotely until it finds the right node managing the bucket InternalDistributedMember currentTarget = pr.getOrCreateNodeForBucketWrite(bucketId.intValue(), null); if (!currentTarget.equals(this.state.getTarget())) { @Released EntryEventImpl firstEvent = prMsg.getFirstEvent(pr); try { throw new TransactionDataNotColocatedException( String.format("Key %s is not colocated with transaction", firstEvent.getKey())); } finally { firstEvent.release(); } } try { return pr.tryToSendOneRemoveAllMessage(prMsg, currentTarget); } catch (ForceReattemptException prce) { pr.checkReadiness(); throw new TransactionDataNotColocatedException(prce.getMessage()); } catch (PrimaryBucketException notPrimary) { RuntimeException re = new TransactionDataRebalancedException( "Transactional data moved, due to rebalancing."); re.initCause(notPrimary); throw re; } catch (DataLocationException dle) { throw new TransactionException(dle); } }
private VersionedObjectList sendMsgByBucket(final Integer bucketId, PutAllPRMessage prMsg, PartitionedRegion pr) { // retry the put remotely until it finds the right node managing the bucket InternalDistributedMember currentTarget = pr.getOrCreateNodeForBucketWrite(bucketId.intValue(), null); if (!currentTarget.equals(this.state.getTarget())) { @Released EntryEventImpl firstEvent = prMsg.getFirstEvent(pr); try { throw new TransactionDataNotColocatedException( String.format("Key %s is not colocated with transaction", firstEvent.getKey())); } finally { firstEvent.release(); } } try { return pr.tryToSendOnePutAllMessage(prMsg, currentTarget); } catch (ForceReattemptException prce) { pr.checkReadiness(); throw new TransactionDataNotColocatedException(prce.getMessage()); } catch (PrimaryBucketException notPrimary) { RuntimeException re = new TransactionDataRebalancedException( "Transactional data moved, due to rebalancing."); re.initCause(notPrimary); throw re; } catch (DataLocationException dle) { throw new TransactionException(dle); } }
assert bucketId != KeyInfo.UNKNOWN_BUCKET; final InternalDistributedMember targetNode = getOrCreateNodeForBucketWrite(bucketId, null); currentTarget = getOrCreateNodeForBucketWrite(bucketId, retryTime); retryTime = new RetryTimeKeeper(this.retryTimeout); currentTarget = getOrCreateNodeForBucketWrite(bucketId, retryTime); event.setPossibleDuplicate(true); if (lastNode.equals(currentTarget)) { retryTime = new RetryTimeKeeper(this.retryTimeout); currentTarget = getOrCreateNodeForBucketWrite(bucketId, retryTime);
targetNode = getOrCreateNodeForBucketWrite(bucketId, retryTime); } else { targetNode = getOrCreateNodeForBucketRead(bucketId);