@Override public boolean include(Profile profile) { assert profile instanceof CacheProfile; CacheProfile cp = (CacheProfile) profile; // if region in cache is not yet initialized, exclude if (!cp.regionInitialized) { return false; } DataPolicy dp = cp.dataPolicy; return dp.withStorage(); } });
protected static boolean isRemoteAccessor(CacheProfile profile) { if (!profile.dataPolicy.withStorage()) { return true; } if (profile.isPartitioned) { PartitionProfile prProfile = (PartitionProfile) profile; if (prProfile.localMaxMemory == 0) { return true; } } return false; }
/** * Return false if it will never store entry ekys and values locally; otherwise return true. */ protected boolean hasStorage() { return this.getDataPolicy().withStorage(); }
/** * Return true if cached or allEvents */ public boolean cachedOrAllEvents() { return this.dataPolicy.withStorage() || allEvents(); }
public boolean canStoreDataLocally() { return this.getDataPolicy().withStorage(); }
@Override public boolean include(Profile profile) { assert profile instanceof CacheProfile; CacheProfile cp = (CacheProfile) profile; DataPolicy dp = cp.dataPolicy; return dp.withReplication() || (cp.allEvents() && (dp.withStorage() || cp.hasCacheListener)); } });
@Override public Set<Region<?, ?>> rootRegions() { preOp(); Set<Region<?, ?>> rootRegions = new HashSet<>(); for (Region<?, ?> region : this.cache.rootRegions()) { if (!region.getAttributes().getDataPolicy().withStorage()) { rootRegions.add(new ProxyRegion(this, region)); } } return Collections.unmodifiableSet(rootRegions); }
preloaded.add(profile.getDistributedMember()); memberProfiles.put(profile.getDistributedMember(), profile); } else if (profile.dataPolicy.withStorage()) {
protected static boolean isLocalAccessor(CacheDistributionAdvisee region) { if (!region.getAttributes().getDataPolicy().withStorage()) { return true; } if (region.getAttributes().getPartitionAttributes() != null && region.getAttributes().getPartitionAttributes().getLocalMaxMemory() == 0) { return true; } return false; }
@Override public void postRemoveAllFireEvents(DistributedRemoveAllOperation removeAllOp, VersionedObjectList successfulOps) { if (!this.getDataPolicy().withStorage() && this.getConcurrencyChecksEnabled() && removeAllOp.getBaseEvent().isBridgeEvent()) { // if there is no local storage we need to transfer version information // to the successfulOps list for transmission back to the client successfulOps.clear(); removeAllOp.fillVersionedObjectList(successfulOps); } Set successfulKeys = new HashSet(successfulOps.size()); for (Object key : successfulOps.getKeys()) { successfulKeys.add(key); } for (Iterator it = removeAllOp.eventIterator(); it.hasNext();) { @Unretained EntryEventImpl event = (EntryEventImpl) it.next(); if (successfulKeys.contains(event.getKey())) { invokeDestroyCallbacks(EnumListenerEvent.AFTER_DESTROY, event, !event.callbacksInvoked() && !event.isPossibleDuplicate(), this.isUsedForPartitionedRegionBucket /* * If this is replicated region, use "false". We must notify gateways inside RegionEntry * lock, NOT here, to preserve the order of events sent by gateways for same key. If this is * bucket region, use "true", because the event order is guaranteed */); } } }
if (allGatewaySenderIds.contains(sender.getId())) { if (!this.getDataPolicy().withStorage() && sender.isParallel()) { return;
@Override public void postPutAllFireEvents(DistributedPutAllOperation putAllOp, VersionedObjectList successfulPuts) { if (!this.getDataPolicy().withStorage() && this.getConcurrencyChecksEnabled() && putAllOp.getBaseEvent().isBridgeEvent()) { // if there is no local storage we need to transfer version information // to the successfulPuts list for transmission back to the client successfulPuts.clear(); putAllOp.fillVersionedObjectList(successfulPuts); } Set successfulKeys = new HashSet(successfulPuts.size()); for (Object key : successfulPuts.getKeys()) { successfulKeys.add(key); } for (Iterator it = putAllOp.eventIterator(); it.hasNext();) { @Unretained EntryEventImpl event = (EntryEventImpl) it.next(); if (successfulKeys.contains(event.getKey())) { EnumListenerEvent op = event.getOperation().isCreate() ? EnumListenerEvent.AFTER_CREATE : EnumListenerEvent.AFTER_UPDATE; invokePutCallbacks(op, event, !event.callbacksInvoked() && !event.isPossibleDuplicate(), this.isUsedForPartitionedRegionBucket /* * If this is replicated region, use "false". We must notify gateways inside RegionEntry * lock, NOT here, to preserve the order of events sent by gateways for same key. If this is * bucket region, use "true", because the event order is guaranteed */); } } }
protected void enableConcurrencyChecks() { this.setConcurrencyChecksEnabled(true); if (this.getDataPolicy().withStorage()) { RegionEntryFactory versionedEntryFactory = this.entries.getEntryFactory().makeVersioned(); Assert.assertTrue(this.entries.isEmpty(), "RegionMap should be empty but was of size:" + this.entries.size()); this.entries.setEntryFactory(versionedEntryFactory); } }
@Override protected boolean operateOnRegion(CacheEvent event, ClusterDistributionManager dm) throws EntryNotFoundException { DistributedRegion region = (DistributedRegion) event.getRegion(); switch (this.clearOp) { case OP_CLEAR: region.clearRegionLocally((RegionEventImpl) event, false, this.rvv); region.notifyBridgeClients((RegionEventImpl) event); this.appliedOperation = true; break; case OP_LOCK_FOR_CLEAR: if (region.getDataPolicy().withStorage()) { DistributedClearOperation.regionLocked(this.getSender(), region.getFullPath(), region); region.lockLocallyForClear(dm, this.getSender(), event); } this.appliedOperation = true; break; } return true; }
@Override public void postPutAll(DistributedPutAllOperation putallOp, VersionedObjectList successfulPuts, InternalRegion reg) { if (!reg.getDataPolicy().withStorage() && reg.getConcurrencyChecksEnabled() && putallOp.getBaseEvent().isBridgeEvent()) { // if there is no local storage we need to transfer version information // to the successfulPuts list for transmission back to the client successfulPuts.clear(); putallOp.fillVersionedObjectList(successfulPuts); } // BR & DR's putAll long token = -1; try { token = reg.postPutAllSend(putallOp, successfulPuts); reg.postPutAllFireEvents(putallOp, successfulPuts); } finally { if (token != -1 && reg instanceof DistributedRegion) { putallOp.endOperation(token); } } }
@Override public void postRemoveAll(DistributedRemoveAllOperation op, VersionedObjectList successfulOps, InternalRegion reg) { if (!reg.getDataPolicy().withStorage() && reg.getConcurrencyChecksEnabled() && op.getBaseEvent().isBridgeEvent()) { // if there is no local storage we need to transfer version information // to the successfulOps list for transmission back to the client successfulOps.clear(); op.fillVersionedObjectList(successfulOps); } // BR, DR's removeAll long token = -1; try { token = reg.postRemoveAllSend(op, successfulOps); reg.postRemoveAllFireEvents(op, successfulOps); } finally { if (token != -1 && reg instanceof DistributedRegion) { op.endOperation(token); } } } }
/** * Used to bootstrap txState. * * @return member with primary bucket for partitionedRegions */ @Override public DistributedMember getOwnerForKey(KeyInfo key) { assert !this.isInternalRegion() || this.isMetaRegionWithTransactions(); if (!this.getAttributes().getDataPolicy().withStorage() || (this.getConcurrencyChecksEnabled() && this.getAttributes().getDataPolicy() == DataPolicy.NORMAL)) { // execute on random replicate return getRandomReplicate(); } // if we are non-persistent, forward transactions to // a persistent member if (this.getConcurrencyChecksEnabled() && !generateVersionTag) { return getRandomPersistentReplicate(); } return super.getOwnerForKey(key); }
/** initializes a new version vector for this region */ private RegionVersionVector createVersionVector() { RegionVersionVector regionVersionVector = RegionVersionVector.create(getVersionMember(), this); if (this.getDataPolicy().withPersistence()) { // copy the versions that we have recovered from disk into // the version vector. RegionVersionVector diskVector = diskRegion.getRegionVersionVector(); regionVersionVector.recordVersions(diskVector.getCloneForTransmission()); } else if (!this.getDataPolicy().withStorage()) { // version vectors are currently only necessary in empty regions for // tracking canonical member IDs regionVersionVector.turnOffRecordingForEmptyRegion(); } if (serverRegionProxy != null) { regionVersionVector.setIsClientVector(); } cache.getDistributionManager().addMembershipListener(regionVersionVector); return regionVersionVector; }
&& attrs.getDataPolicy().withStorage()) { logger.warn( "Region {} is being created with scope {} but enable-network-partition-detection is enabled in the distributed system. This can lead to cache inconsistencies if there is a network failure.",
if (!event.isBulkOpInProgress() || this.getDataPolicy().withStorage()) {