@Override protected void removeSenderFromAdvisor(InternalDistributedMember sender, int serial, boolean regionDestroyed) { getDistributionAdvisor().removeIdWithSerial(sender, serial, regionDestroyed); }
private void waitForCurrentOperations(final DistributedRegion r, final boolean initialized) { if (initialized) { if (this.flushNewOps) { r.getDistributionAdvisor().forceNewMembershipVersion(); // force a new "view" so // we can track current // ops } try { r.getDistributionAdvisor().waitForCurrentOperations(); } catch (RegionDestroyedException e) { // continue with the next region } } }
protected void releaseViewVersions() { RuntimeException rte = null; for (Iterator it = viewVersions.entrySet().iterator(); it.hasNext();) { Map.Entry e = (Map.Entry) it.next(); DistributedRegion dr = (DistributedRegion) e.getKey(); Long viewVersion = (Long) e.getValue(); // need to continue the iteration if one of the regions is destroyed // since others may still be okay try { dr.getDistributionAdvisor().endOperation(viewVersion); } catch (RuntimeException ex) { rte = ex; } } if (rte != null) { throw rte; } }
@Override public Set<DistributedMember> getMembers(Region region) { if (region instanceof DistributedRegion) { DistributedRegion distributedRegion = (DistributedRegion) region; return (Set<DistributedMember>) distributedRegion.getDistributionAdvisor().adviseCacheOp(); } else if (region instanceof PartitionedRegion) { PartitionedRegion partitionedRegion = (PartitionedRegion) region; return (Set<DistributedMember>) partitionedRegion.getRegionAdvisor().adviseAllPRNodes(); } else { return Collections.emptySet(); } }
/** * region's distribution advisor marked that a distribution is ended. This method should pair with * startOperation in try/finally block. */ public void endOperation(long viewVersion) { DistributedRegion region = getRegion(); if (viewVersion != -1) { region.getDistributionAdvisor().endOperation(viewVersion); if (logger.isTraceEnabled()) { logger.trace(LogMarker.STATE_FLUSH_OP_VERBOSE, "done dispatching operation in view version {}", viewVersion); } } }
protected void waitForCurrentOperations() { // Fix for #48066 - make sure that region operations are completely // distributed to peers before destroying the region. boolean flushOnClose = !Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "no-flush-on-close"); // test hook if (!this.cache.forcedDisconnect() && flushOnClose && this.getDistributionManager().getMembershipManager() != null && this.getDistributionManager().getMembershipManager().isConnected()) { getDistributionAdvisor().forceNewMembershipVersion(); try { getDistributionAdvisor().waitForCurrentOperations(); } catch (Exception e) { // log this but try to close the region so that listeners are invoked logger.warn(String.format("%s: error closing region %s", new Object[] {this, getFullPath()}), e); } } }
msg.addViewVersion(dr, dr.getDistributionAdvisor().startOperation()); newMemberSet.addAll(dr.getCacheDistributionAdvisor().adviseTX());
@Test public void testProcessWithWaitForCurrentOperationsThatTimesOut() { InternalDistributedMember relayRecipient = mock(InternalDistributedMember.class); ClusterDistributionManager dm = mock(ClusterDistributionManager.class); InternalCache gfc = mock(InternalCache.class); DistributedRegion region = mock(DistributedRegion.class); CacheDistributionAdvisor distributionAdvisor = mock(CacheDistributionAdvisor.class); when(dm.getDistributionManagerId()).thenReturn(relayRecipient); when(dm.getExistingCache()).thenReturn(gfc); when(region.isInitialized()).thenReturn(true); when(region.getDistributionAdvisor()).thenReturn(distributionAdvisor); when(gfc.getRegionByPathForProcessing(any())).thenReturn(region); doThrow(new GemFireIOException("expected in fatal log message")).when(distributionAdvisor) .waitForCurrentOperations(); StateMarkerMessage message = new StateMarkerMessage(); message.relayRecipient = relayRecipient; message.process(dm); verify(dm, times(1)).putOutgoing(any()); } }
when(prRoot.getDistributionAdvisor()).thenReturn(cda); doNothing().when(cda).addMembershipListener(any()); when(cache.createVMRegion(eq(PR_ROOT_REGION_NAME), any(), any())).thenReturn(prRoot);
/** * The startOperation and endOperation methods of DistributedCacheOperation record the * beginning and end of distribution of an operation. If startOperation is invoked it * is essential that endOperation be invoked or the state-flush operation will hang.<br> * This test ensures that if distribution of the operation throws an exception then * endOperation is correctly invoked before allowing the exception to escape the startOperation * method. */ @Test public void endOperationIsInvokedOnDistributionError() { DistributedRegion region = mock(DistributedRegion.class); CacheDistributionAdvisor advisor = mock(CacheDistributionAdvisor.class); when(region.getDistributionAdvisor()).thenReturn(advisor); TestOperation operation = new TestOperation(null); operation.region = region; try { operation.startOperation(); } catch (RuntimeException e) { assertEquals("boom", e.getMessage()); } assertTrue(operation.endOperationInvoked); }
private void operateOnCache(InternalCache cache) { final boolean isDebugEnabled = logger.isDebugEnabled(); if (cache.getCacheServers().size() == 0) { for (DistributedRegion r : getDistributedRegions(cache)) { CacheDistributionAdvisor cda = (CacheDistributionAdvisor) r.getDistributionAdvisor(); CacheDistributionAdvisor.CacheProfile cp = (CacheDistributionAdvisor.CacheProfile) cda.getProfile(getSender()); if (cp != null) { if (isDebugEnabled) { logger.debug("Setting hasCacheServer flag to false on region \"{}\" for {}", r.getFullPath(), getSender()); } cp.hasCacheServer = false; } } for (PartitionedRegion r : this.getPartitionedRegions(cache)) { CacheDistributionAdvisor cda = (CacheDistributionAdvisor) r.getDistributionAdvisor(); CacheDistributionAdvisor.CacheProfile cp = (CacheDistributionAdvisor.CacheProfile) cda.getProfile(getSender()); if (cp != null) { if (isDebugEnabled) { logger.debug("Setting hasCacheServer flag to false on region \"{}\" for {}", r.getFullPath(), getSender()); } cp.hasCacheServer = false; } } } }
private void operateOnCache(InternalCache cache) { final boolean isDebugEnabled = logger.isDebugEnabled(); for (DistributedRegion r : getDistributedRegions(cache)) { CacheDistributionAdvisor cda = (CacheDistributionAdvisor) r.getDistributionAdvisor(); CacheDistributionAdvisor.CacheProfile cp = (CacheDistributionAdvisor.CacheProfile) cda.getProfile(getSender()); if (cp != null) { if (isDebugEnabled) { logger.debug("Setting hasCacheServer flag on region \"{}\" for {}", r.getFullPath(), getSender()); } cp.hasCacheServer = true; } } for (PartitionedRegion r : this.getPartitionedRegions(cache)) { CacheDistributionAdvisor cda = (CacheDistributionAdvisor) r.getDistributionAdvisor(); CacheDistributionAdvisor.CacheProfile cp = (CacheDistributionAdvisor.CacheProfile) cda.getProfile(getSender()); if (cp != null) { if (isDebugEnabled) { logger.debug("Setting hasCacheServer flag on region \"{}\" for {}", r.getFullPath(), getSender()); } cp.hasCacheServer = true; } } }
try { if (this.containsRegionContentChange()) { viewVersion = region.getDistributionAdvisor().startOperation();
if (initialized) { region.getDistributionAdvisor().forceNewMembershipVersion(); try { region.getDistributionAdvisor().waitForCurrentOperations(); } catch (RegionDestroyedException ignore) { return;
public static VersionTag findVersionTag(InternalRegion r, EventID eventId, boolean isBulkOp) { DistributionManager dm = r.getDistributionManager(); Set recipients; if (r instanceof DistributedRegion) { recipients = ((DistributedRegion) r).getDistributionAdvisor().adviseCacheOp(); } else { recipients = ((PartitionedRegion) r).getRegionAdvisor().adviseDataStore(); } ResultReplyProcessor processor = new ResultReplyProcessor(dm, recipients); FindVersionTagMessage msg = new FindVersionTagMessage(recipients, processor.getProcessorId(), r.getFullPath(), eventId, isBulkOp); dm.putOutgoing(msg); try { processor.waitForReplies(); } catch (InterruptedException e) { dm.getCancelCriterion().checkCancelInProgress(e); Thread.currentThread().interrupt(); return null; } return processor.getVersionTag(); }
Map<InternalDistributedMember, PersistentMemberID> persistentIds = null; if (region.getDataPolicy().withPersistence()) { persistentIds = region.getDistributionAdvisor().adviseInitializedPersistentMembers();
return; final Set recipients = prRoot.getDistributionAdvisor().adviseGeneric(); if (recipients.size() <= 0) { return;
new InternalRegionArguments().setIsUsedForPartitionedRegionAdmin(true) .setInternalRegion(true).setCachePerfStatsHolder(prMetaStatsHolder)); root.getDistributionAdvisor().addMembershipListener(new MemberFailureListener(cache)); } catch (RegionExistsException ignore) {
/** * pause local operations so that a clear() can be performed and flush comm channels to the given * member */ void lockLocallyForClear(DistributionManager dm, InternalDistributedMember locker, CacheEvent event) { RegionVersionVector rvv = getVersionVector(); ARMLockTestHook armLockTestHook = getRegionMap().getARMLockTestHook(); if (armLockTestHook != null) { armLockTestHook.beforeLock(this, event); } if (rvv != null) { // block new operations from being applied to the region map rvv.lockForClear(getFullPath(), dm, locker); // Check for region destroyed after we have locked, to make sure // we don't continue a clear if the region has been destroyed. checkReadiness(); // Only need to flush if NOACK at this point if (this.getAttributes().getScope().isDistributedNoAck()) { Set<InternalDistributedMember> members = getDistributionAdvisor().adviseCacheOp(); StateFlushOperation.flushTo(members, this); } } if (armLockTestHook != null) { armLockTestHook.afterLock(this, null); } }
final Set netWriteRecipients; if (cacheWriter == null && this.owner.scope.isDistributed()) { CacheDistributionAdvisor cda = ((DistributedRegion) this.owner).getDistributionAdvisor(); netWriteRecipients = cda.adviseNetWrite(); } else {