/** * Test hook for bug 48578. Returns true if it sees a net loader. Returns false if it does not * have one. */ public boolean hasNetLoader() { return this.hasNetLoader(getCacheDistributionAdvisor()); }
@Override public Set adviseNetWrite() { return getCacheDistributionAdvisor().adviseNetWrite(); }
@Override public void initialCriticalMembers(boolean localMemoryIsCritical, Set<InternalDistributedMember> criticalMembers) { Set<InternalDistributedMember> others = getCacheDistributionAdvisor().adviseGeneric(); for (InternalDistributedMember idm : criticalMembers) { if (others.contains(idm)) { addCriticalMember(idm); } } }
@Override protected Set getRecipients() { CacheDistributionAdvisor advisor = getRegion().getCacheDistributionAdvisor(); return advisor.adviseInvalidateRegion(); }
@Override protected Set getRecipients() { CacheDistributionAdvisor advisor = getRegion().getCacheDistributionAdvisor(); return advisor.adviseDestroyRegion(); }
@Override protected Set getRecipients() { CacheDistributionAdvisor advisor = getRegion().getCacheDistributionAdvisor(); return advisor.adviseInvalidateRegion(); }
protected Set getRecipients() { CacheDistributionAdvisor advisor = getRegion().getCacheDistributionAdvisor(); this.originalRecipients = advisor.adviseCacheOp(); return this.originalRecipients; }
/** * @return a random persistent replicate, null if there is none */ public InternalDistributedMember getRandomPersistentReplicate() { final GetRandomReplicate getPersistentReplicate = new GetRandomReplicate(true); this.getCacheDistributionAdvisor().accept(getPersistentReplicate, null); return getPersistentReplicate.member; }
@Override public void checkSameSenderIdsAvailableOnAllNodes() { List<Set<String>> senderIds = this.getCacheDistributionAdvisor().adviseSameGatewaySenderIds(getGatewaySenderIds()); if (!senderIds.isEmpty()) { throw new GatewaySenderConfigurationException( String.format( "Region %s has %s gateway sender IDs. Another cache has same region with %s gateway sender IDs. For region across all members, gateway sender ids should be same.", new Object[] {this.getName(), senderIds.get(0), senderIds.get(1)})); } List<Set<String>> asycnQueueIds = this.getCacheDistributionAdvisor() .adviseSameAsyncEventQueueIds(getVisibleAsyncEventQueueIds()); if (!asycnQueueIds.isEmpty()) { throw new GatewaySenderConfigurationException( String.format( "Region %s has %s AsyncEvent queue IDs. Another cache has same region with %s AsyncEvent queue IDs. For region across all members, AsyncEvent queue IDs should be same.", new Object[] {this.getName(), asycnQueueIds.get(0), asycnQueueIds.get(1)})); } }
/** * @return a random replicate, null if there are none */ public InternalDistributedMember getRandomReplicate() { /* * [sumedh] The old code causes creation of a unnecessary HashSet and population with all * replicates (which may be large), then copy into an array and then selection of a random one * from that. The new approach uses a much more efficient visitor instead. Set replicates = * this.getCacheDistributionAdvisor().adviseReplicates(); if (replicates.isEmpty()) { return * null; } return (InternalDistributedMember)(replicates .toArray()[new * Random().nextInt(replicates.size())]); */ final GetRandomReplicate getReplicate = new GetRandomReplicate(); this.getCacheDistributionAdvisor().accept(getReplicate, null); return getReplicate.member; }
@Override protected Set getRecipients() { CacheDistributionAdvisor advisor = getRegion().getCacheDistributionAdvisor(); return advisor.adviseUpdate(getEvent()); }
/** * If this region has concurrency controls enabled this will pull any missing changes from other * replicates using InitialImageOperation and a filtered chunking protocol. */ public void synchronizeForLostMember(InternalDistributedMember lostMember, VersionSource lostVersionID) { if (!this.getConcurrencyChecksEnabled()) { return; } CacheDistributionAdvisor advisor = getCacheDistributionAdvisor(); Set<InternalDistributedMember> targets = advisor.adviseInitializedReplicates(); for (InternalDistributedMember target : targets) { synchronizeWith(target, lostVersionID, lostMember); } }
DistributedRegion dr = (DistributedRegion) r; msg.addViewVersion(dr, dr.getDistributionAdvisor().startOperation()); newMemberSet.addAll(dr.getCacheDistributionAdvisor().adviseTX());
@Test public void testDistributeNotFailWithRegionDestroyedException() throws RemoteOperationException { EntryEventImpl event = mock(EntryEventImpl.class); EventID eventID = mock(EventID.class); DistributedRegion region = mock(DistributedRegion.class); InternalDistributedSystem ids = mock(InternalDistributedSystem.class); DistributionManager dm = mock(DistributionManager.class); CancelCriterion cc = mock(CancelCriterion.class); CacheDistributionAdvisor advisor = mock(CacheDistributionAdvisor.class); InternalDistributedMember member = mock(InternalDistributedMember.class); Set<InternalDistributedMember> replicates = new HashSet<>(Arrays.asList(member)); RemotePutMessage.RemotePutResponse response = mock(RemotePutMessage.RemotePutResponse.class); Object expectedOldValue = new Object(); when(event.getRegion()).thenReturn(region); when(event.getEventId()).thenReturn(eventID); when(region.getCacheDistributionAdvisor()).thenReturn(advisor); when(advisor.adviseInitializedReplicates()).thenReturn(replicates); when(response.waitForResult()).thenThrow(new RegionDestroyedException("", "")); when(region.getSystem()).thenReturn(ids); when(region.getDistributionManager()).thenReturn(dm); when(ids.getDistributionManager()).thenReturn(dm); when(dm.getCancelCriterion()).thenReturn(cc); when(dm.putOutgoing(any())).thenReturn(null); RemotePutMessage.distribute(event, 1, false, false, expectedOldValue, false, false); } }
msg.regionPath = this.region.getFullPath(); msg.lostVersionSources = needsSync.toArray(new VersionSource[needsSync.size()]); Set recipients = this.region.getCacheDistributionAdvisor().adviseReplicates(); for (Iterator it = recipients.iterator(); it.hasNext();) { InternalDistributedMember mbr = (InternalDistributedMember) it.next();
@Override public void run() { CacheDistributionAdvisor advisor = ((DistributedRegion) proxy.getHARegionQueue().getRegion()) .getCacheDistributionAdvisor(); Set members = advisor.adviseCacheOp(); // Send client denylist message ClientDenylistProcessor.sendDenylistedClient(proxy.getProxyID(), dm, members); // close the proxy for slow receiver. proxy.close(false, false); removeClientProxy(proxy); if (PoolImpl.AFTER_QUEUE_DESTROY_MESSAGE_FLAG) { ClientServerObserver bo = ClientServerObserverHolder.getInstance(); bo.afterQueueDestroyMessage(); } // send remove from denylist. RemoveClientFromDenylistMessage rcm = new RemoveClientFromDenylistMessage(); rcm.setProxyID(proxy.getProxyID()); dm.putOutgoing(rcm); denyListedClients.remove(proxy.getProxyID()); } });
@Override protected FilterRoutingInfo getRecipientFilterRouting(Set cacheOpRecipients) { // for removeAll, we need to determine the routing information for each event and // create a consolidated routing object representing all events that can be // used for distribution CacheDistributionAdvisor advisor; LocalRegion region = (LocalRegion) this.event.getRegion(); if (region instanceof PartitionedRegion) { advisor = ((PartitionedRegion) region).getCacheDistributionAdvisor(); } else if (region.isUsedForPartitionedRegionBucket()) { advisor = ((BucketRegion) region).getPartitionedRegion().getCacheDistributionAdvisor(); } else { advisor = ((DistributedRegion) region).getCacheDistributionAdvisor(); } FilterRoutingInfo consolidated = new FilterRoutingInfo(); for (int i = 0; i < this.removeAllData.length; i++) { @Unretained EntryEventImpl ev = getEventForPosition(i); if (ev != null) { FilterRoutingInfo eventRouting = advisor.adviseFilterRouting(ev, cacheOpRecipients); if (eventRouting != null) { consolidated.addFilterInfo(eventRouting); } removeAllData[i].filterRouting = eventRouting; } } // we need to create routing information for each PUT event return consolidated; }
@Override protected FilterRoutingInfo getRecipientFilterRouting(Set cacheOpRecipients) { // for putAll, we need to determine the routing information for each event and // create a consolidated routing object representing all events that can be // used for distribution CacheDistributionAdvisor advisor; LocalRegion region = (LocalRegion) this.event.getRegion(); if (region instanceof PartitionedRegion) { advisor = ((PartitionedRegion) region).getCacheDistributionAdvisor(); } else if (region.isUsedForPartitionedRegionBucket()) { advisor = ((BucketRegion) region).getPartitionedRegion().getCacheDistributionAdvisor(); } else { advisor = ((DistributedRegion) region).getCacheDistributionAdvisor(); } FilterRoutingInfo consolidated = new FilterRoutingInfo(); for (int i = 0; i < this.putAllData.length; i++) { @Unretained EntryEventImpl ev = getEventForPosition(i); if (ev != null) { FilterRoutingInfo eventRouting = advisor.adviseFilterRouting(ev, cacheOpRecipients); if (eventRouting != null) { consolidated.addFilterInfo(eventRouting); } putAllData[i].filterRouting = eventRouting; } } // we need to create routing information for each PUT event return consolidated; }
@Override protected void setMemoryThresholdFlag(MemoryEvent event) { Set<InternalDistributedMember> others = getCacheDistributionAdvisor().adviseGeneric(); if (event.isLocal() || others.contains(event.getMember())) { if (event.getState().isCritical() && !event.getPreviousState().isCritical() && (event.getType() == ResourceType.HEAP_MEMORY || (event.getType() == ResourceType.OFFHEAP_MEMORY && getOffHeap()))) { addCriticalMember(event.getMember()); } else if (!event.getState().isCritical() && event.getPreviousState().isCritical() && (event.getType() == ResourceType.HEAP_MEMORY || (event.getType() == ResourceType.OFFHEAP_MEMORY && getOffHeap()))) { removeCriticalMember(event.getMember()); } } }
try { Set<InternalDistributedMember> participants = getCacheDistributionAdvisor().adviseInvalidateRegion(); getCacheDistributionAdvisor().adviseInvalidateRegion(); clearRegionLocally(regionEvent, cacheWrite, null); if (!regionEvent.isOriginRemote() && regionEvent.getOperation().isDistributed()) {