/** * Checks for concurrency checks enabled on Region and that callbackEvent is not null. */ private boolean shouldPerformConcurrencyChecks(LocalRegion owner, EntryEventImpl callbackEvent) { return owner.getConcurrencyChecksEnabled() && callbackEvent != null; }
/** * issue a config message if the server and client have different concurrency checking * expectations */ private void concurrencyConfigurationCheck(VersionTag tag) { if (!this.concurrencyMessageIssued && tag == null && this.getConcurrencyChecksEnabled()) { this.concurrencyMessageIssued = true; logger.info("Server has concurrencyChecksEnabled {} but client has {} for region {}", new Object[] {!this.getConcurrencyChecksEnabled(), this.getConcurrencyChecksEnabled(), this}); } }
/** returns object used to guard the size() operation during tombstone removal */ Object getSizeGuard() { if (!this.getConcurrencyChecksEnabled()) { return new Object(); } else { return this.fullPath; // avoids creating another sync object - could be anything unique to // this region } }
/** * Return true if invalidation occurred; false if it did not, for example if it was already * invalidated */ private void basicInvalidate(final EntryEventImpl event, boolean invokeCallbacks) throws EntryNotFoundException { final boolean forceNewEntryInClientCache = this.serverRegionProxy != null && getConcurrencyChecksEnabled(); basicInvalidate(event, invokeCallbacks, forceNewEntryInClientCache); }
protected RegionVersionVector createRegionVersionVector() { if (getConcurrencyChecksEnabled()) { return createVersionVector(); } return null; }
public void expireTombstoneKeys(Set<Object> tombstoneKeys) { if (this.getConcurrencyChecksEnabled()) { this.cache.getTombstoneService().gcTombstoneKeys(this, tombstoneKeys); } }
@Override public void setRVVTrusted(boolean rvvTrusted) { if (this.getConcurrencyChecksEnabled()) { DiskRegion region = this.getDiskRegion(); // Update whether or not the RVV we have recovered is trusted (accurately represents what we // have on disk). if (region != null) { region.setRVVTrusted(rvvTrusted); } } }
/** * This method determines whether this region should synchronize with peer replicated regions when * the given member has crashed. * * @param id the crashed member * @return true if synchronization should be attempted */ public boolean shouldSyncForCrashedMember(InternalDistributedMember id) { return this.getConcurrencyChecksEnabled() && this.getDataPolicy().withReplication() && !this.isUsedForPartitionedRegionAdmin && !this.isUsedForMetaRegion && !this.isUsedForSerialGatewaySenderQueue; }
@Override public void recordRecoveredVersonHolder(VersionSource member, RegionVersionHolder versionHolder, boolean latestOplog) { if (this.getConcurrencyChecksEnabled()) { // We need to update the RVV in memory this.versionVector.initRecoveredVersion(member, versionHolder, latestOplog); DiskRegion region = this.getDiskRegion(); // We also need to update the RVV that represents what we have persisted on disk if (region != null) { region.recordRecoveredVersonHolder(member, versionHolder, latestOplog); } } }
private void givenConcurrencyChecks() { when(owner.getConcurrencyChecksEnabled()).thenReturn(true); when(partitionedRegion.getConcurrencyChecksEnabled()).thenReturn(true); }
private static LocalRegion createOwner(boolean withConcurrencyChecks) { LocalRegion owner = mock(LocalRegion.class); CachePerfStats cachePerfStats = mock(CachePerfStats.class); when(owner.getCachePerfStats()).thenReturn(cachePerfStats); when(owner.getEvictionAttributes()).thenReturn(evictionAttributes); when(owner.getConcurrencyChecksEnabled()).thenReturn(withConcurrencyChecks); when(owner.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); doThrow(EntryNotFoundException.class).when(owner).checkEntryNotFound(any()); return owner; }
void cmnClearRegion(RegionEventImpl regionEvent, boolean cacheWrite, boolean useRVV) { RegionVersionVector rvv = null; if (useRVV && this.getDataPolicy().withReplication() && this.getConcurrencyChecksEnabled()) { rvv = this.versionVector.getCloneForTransmission(); } clearRegionLocally(regionEvent, cacheWrite, rvv); }
static boolean shouldInvokeCallbacks(final LocalRegion owner, final boolean isInitialized) { LocalRegion lr = owner; boolean isPartitioned = lr.isUsedForPartitionedRegionBucket(); if (isPartitioned) { /* * if(!((BucketRegion)lr).getBucketAdvisor().isPrimary()) { * if(!BucketRegion.FORCE_LOCAL_LISTENERS_INVOCATION) { return false; } } */ lr = owner.getPartitionedRegion(); } return (isPartitioned || isInitialized) && (lr.shouldDispatchListenerEvent() || lr.shouldNotifyBridgeClients() || lr.getConcurrencyChecksEnabled()); }
@Test public void uninitializedPartitionedRegionWithConcurrencyChecksEnabledDoesInvokeCallbacks() { when(internalRegion.isUsedForPartitionedRegionBucket()).thenReturn(true); LocalRegion partitionedRegion = mock(LocalRegion.class); when(internalRegion.getPartitionedRegion()).thenReturn(partitionedRegion); when(partitionedRegion.getConcurrencyChecksEnabled()).thenReturn(true); createInstance(Operation.CREATE, false, null, localTxEntryState); assertThat(instance.isInvokeCallbacks()).isTrue(); }
@Override public void recordRecoveredVersionTag(VersionTag tag) { if (this.getConcurrencyChecksEnabled()) { this.versionVector.recordVersion(tag.getMemberID(), tag.getRegionVersion()); DiskRegion region = this.getDiskRegion(); // We also need to update the RVV that represents what we have persisted on disk if (region != null) { region.recordRecoveredVersionTag(tag); } } }
@Before public void setup() { region = mock(LocalRegion.class); regionAttributes = mock(RegionAttributes.class); when(region.createStopper()).thenCallRealMethod(); memberId = mock(ClientProxyMembershipID.class); when(region.getAttributes()).thenReturn(regionAttributes); when(regionAttributes.getDataPolicy()).thenReturn(mock(DataPolicy.class)); when(region.getConcurrencyChecksEnabled()).thenReturn(true); member = mock(DistributedMember.class); eventTracker = new DistributedEventTracker(region.getCache(), mock(CancelCriterion.class), region.getName()); }
@Test public void testGetEventTimeWithVersionTagConcurrencyChecksDisabledNoSuggestedTime() { long timestamp = System.currentTimeMillis(); LocalRegion region = mock(LocalRegion.class); when(region.getConcurrencyChecksEnabled()).thenReturn(false); when(region.cacheTimeMillis()).thenReturn(timestamp); EntryEventImpl e = createEntryEvent(region, null); VersionTag tag = VersionTag.create(mock(InternalDistributedMember.class)); tag.setVersionTimeStamp(timestamp + 1000l); e.setVersionTag(tag); assertThat(e.getEventTime(0l)).isEqualTo(timestamp); }
@Test public void testGetEventTimeWithVersionTagConcurrencyChecksDisabledWithSuggestedTime() { long timestamp = System.currentTimeMillis(); LocalRegion region = mock(LocalRegion.class); when(region.getConcurrencyChecksEnabled()).thenReturn(false); EntryEventImpl e = createEntryEvent(region, null); VersionTag tag = VersionTag.create(mock(InternalDistributedMember.class)); tag.setVersionTimeStamp(timestamp + 1000l); e.setVersionTag(tag); assertThat(e.getEventTime(timestamp)).isEqualTo(timestamp); }
@Test public void testGetEventTimeWithVersionTagConcurrencyChecksEnabled() { long timestamp = System.currentTimeMillis(); LocalRegion region = mock(LocalRegion.class); when(region.getConcurrencyChecksEnabled()).thenReturn(true); EntryEventImpl e = createEntryEvent(region, null); VersionTag tag = VersionTag.create(mock(InternalDistributedMember.class)); tag.setVersionTimeStamp(timestamp); e.setVersionTag(tag); assertThat(e.getEventTime(0l)).isEqualTo(timestamp); }
/** local regions do not perform versioning */ protected boolean shouldGenerateVersionTag(RegionEntry entry, EntryEventImpl event) { if (this.getDataPolicy().withPersistence()) { return true; } else { return this.getConcurrencyChecksEnabled() && (entry.getVersionStamp().hasValidVersion() || this.getDataPolicy().withReplication()); } }