public void setPersistBackup(boolean persistBackup) { if (persistBackup) { if (!getDataPolicy().withPersistence()) { if (getDataPolicy().withPartitioning()) { setDataPolicy(DataPolicy.PERSISTENT_PARTITION); } else { setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); } } } else { // It is less clear what we should do here for backwards compat. // If the current data policy is persist then we need to change it // otherwise just leave it alone if (getDataPolicy().withReplication()) { setDataPolicy(DataPolicy.REPLICATE); } else if (getDataPolicy().withPartitioning()) { setDataPolicy(DataPolicy.PARTITION); } } }
@Override public boolean include(Profile profile) { assert profile instanceof CacheProfile; CacheProfile cp = (CacheProfile) profile; if (cp.dataPolicy.withPreloaded()) { return true; } return false; } });
@Override public MirrorType getMirrorType() { if (this.dataPolicy.isNormal() || this.dataPolicy.isPreloaded() || this.dataPolicy.isEmpty() || this.dataPolicy.withPartitioning()) { return MirrorType.NONE; } else if (this.dataPolicy.withReplication()) { return MirrorType.KEYS_VALUES; } else { throw new IllegalStateException( String.format("No mirror type corresponds to data policy %s", this.dataPolicy)); } }
@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)); } });
void checkEntryTimeoutAction(String mode, ExpirationAction ea) { if ((this.getDataPolicy().withReplication() || this.getDataPolicy().withPartitioning()) && (ea == ExpirationAction.LOCAL_DESTROY || ea == ExpirationAction.LOCAL_INVALIDATE)) { throw new IllegalArgumentException( String.format("%s action is incompatible with this region's data policy.", mode)); } }
@Override public <K, V> Set<Integer> getLocalBucketSet(Region<K, V> region) { if (!region.getAttributes().getDataPolicy().withPartitioning()) { return null; } return this.localBucketSet; } }
@Override public boolean include(Profile profile) { // probably not needed as all profiles for a partitioned region are Partition profiles if (profile instanceof PartitionProfile) { PartitionProfile p = (PartitionProfile) profile; return p.isDataStore && (!p.dataPolicy.withPersistence() || p.regionInitialized); } return false; } });
@Override public boolean include(Profile profile) { assert profile instanceof CacheProfile; CacheProfile cp = (CacheProfile) profile; if (cp.dataPolicy.withReplication() && cp.regionInitialized) { return true; } return false; } });
assumeThat(supportsTransactions()).isTrue(); assumeThat(getRegionAttributes().getScope().isGlobal()).isFalse(); assumeThat(getRegionAttributes().getDataPolicy().withPersistence()).isFalse(); if (!getRegionAttributes().getDataPolicy().withReplication() && !getRegionAttributes().getDataPolicy().withPreloaded()) { vm1.invoke(newKey1); vm1.invoke(newKey3); if (!getRegionAttributes().getDataPolicy().withReplication() && !getRegionAttributes().getDataPolicy().withPreloaded()) { vm3.invoke(newKey2); vm3.invoke(newKey3); if (!getRegionAttributes().getDataPolicy().withReplication() && !getRegionAttributes().getDataPolicy().withPreloaded()) { vm1.invoke(newKey1); vm1.invoke(newKey3); vm2.invoke(newKey2); vm2.invoke(create3); if (!getRegionAttributes().getDataPolicy().withReplication() && !getRegionAttributes().getDataPolicy().withPreloaded()) { vm2.invoke(newKey3); if (!getRegionAttributes().getDataPolicy().withReplication() && !getRegionAttributes().getDataPolicy().withPreloaded()) { vm3.invoke(newKey2); vm3.invoke(newKey3);
assumeThat(getRegionAttributes().getDataPolicy().withReplication()).isFalse(); assumeThat(getRegionAttributes().getDataPolicy().withPreloaded()).isFalse();
this.isPR = dp.withPartitioning(); if (!(this.isPR || dp.withReplication())) { String errMsg = null; if (dp.withPreloaded() && cqBaseRegion.getAttributes().getEvictionAttributes() != null && cqBaseRegion.getAttributes().getEvictionAttributes().getAction() .equals(EvictionAction.LOCAL_DESTROY)) { if ((dp.withReplication() && (!(cqBaseRegion.getAttributes().getScope().isDistributedAck() || cqBaseRegion.getAttributes().getScope().isGlobal())))) { String errMsg = "The replicated region " + this.regionName
RegionAttributesCreation rac = (RegionAttributesCreation) attrs; isPartitionedRegion = rac.getPartitionAttributes() != null || (rac.hasDataPolicy() && rac.getDataPolicy().withPartitioning()); } else { isPartitionedRegion = attrs.getPartitionAttributes() != null || attrs.getDataPolicy().withPartitioning(); String dpString; DataPolicy dp = attrs.getDataPolicy(); if (dp.isEmpty()) { dpString = EMPTY_DP; } else if (dp.isNormal()) { dpString = NORMAL_DP; } else if (dp.isPreloaded()) { dpString = PRELOADED_DP; } else if (dp.isReplicate()) { dpString = REPLICATE_DP; } else if (dp == DataPolicy.PERSISTENT_REPLICATE) { } else if (dp == DataPolicy.PERSISTENT_PARTITION) { dpString = PERSISTENT_PARTITION_DP; } else if (dp.isPartition()) { if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_1) >= 0) { dpString = PARTITION_DP;
if (profile.dataPolicy.withReplication()) { if (!persistent || profile.dataPolicy.withPersistence()) { } else if (profile.dataPolicy.isPreloaded()) { preloaded.add(profile.getDistributedMember()); memberProfiles.put(profile.getDistributedMember(), profile); } else if (profile.dataPolicy.withStorage()) {
@Override public boolean visit(DistributionAdvisor advisor, Profile profile, int profileIndex, int numProfiles, DistributedMember member) { final CacheProfile cp = (CacheProfile) profile; if (this.randIndex < 0) { this.randIndex = PartitionedRegion.RANDOM.nextInt(numProfiles); } if (cp.dataPolicy.withReplication() && cp.regionInitialized) { if (onlyPersistent && !cp.dataPolicy.withPersistence()) { return true; } // store the last replicated member in any case since in the worst case // there may be no replicated node after "randIndex" in which case the // last visited member will be used this.member = cp.getDistributedMember(); if (profileIndex >= this.randIndex) { return false; } } return true; } }
getDataPolicy().withReplication() || getDataPolicy().isPreloaded(), getAttributes().getDataPolicy().withPersistence(), this.stopper);
if (this.dataPolicy.withReplication()) { s |= REPLICATE_MASK; if (this.dataPolicy.isPersistentReplicate()) { s |= PERSISTENT_MASK; if (this.dataPolicy.isEmpty()) s |= PROXY_MASK; if (this.dataPolicy.isPreloaded()) s |= PRELOADED_MASK;
if (this.getDataPolicy().withPersistence()) { targetProvider = new CreatePersistentRegionProcessor(this, getPersistenceAdvisor(), recoverFromDisk); if (this.getDataPolicy().withPersistence()) { recovered_rvv = this.getVersionVector() == null ? null : this.getVersionVector().getCloneForTransmission(); advice = targetProvider.getInitialImageAdvice(advice); boolean attemptGetFromOne = imageSrc != null // we were given a specific member || this.getDataPolicy().withPreloaded() && !advice.preloaded.isEmpty() // this is a if (this.getDataPolicy().isPreloaded()) { GIIStatus ret_preload = iiop.getFromOne(advice.preloaded, false, advice, recoverFromDisk, recovered_rvv);
@Override public void writeToDisk() { if (this.diskRegion == null) { DataPolicy dp = getDataPolicy(); if (dp.isEmpty()) { throw new IllegalStateException( String.format("Cannot write a region with data-policy %s to disk.", dp)); } else if (!dp.withPersistence() && !isOverflowEnabled()) { throw new IllegalStateException( "Cannot write a region that is not configured to access disks."); } } else { this.diskRegion.asynchForceFlush(); } }
/** 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; }
public void remoteTestPostSnapshot(String name, boolean isController, boolean isRoot) throws CacheException { assertTrue(preSnapshotRegion.isDestroyed()); try { preSnapshotRegion.get("0"); fail("Should have thrown a RegionReinitializedException"); } catch (RegionReinitializedException e) { // pass } LogWriter log = getCache().getLogger(); // get new reference to region Region postSnapshotRegion = isRoot ? getRootRegion(name) : getRootRegion().getSubregion(name); assertNotNull("Could not get reference to reinitialized region", postSnapshotRegion); boolean expectData = isController || postSnapshotRegion.getAttributes().getMirrorType().isMirrored() || postSnapshotRegion.getAttributes().getDataPolicy().isPreloaded(); log.info("region has " + postSnapshotRegion.keySet().size() + " entries"); assertEquals(expectData ? MAX_KEYS : 0, postSnapshotRegion.keySet().size()); // gets the data either locally or by netSearch assertEquals(new Integer(3), postSnapshotRegion.get("3")); // bug 33311 coverage if (expectData) { assertFalse(postSnapshotRegion.containsValueForKey("9")); assertTrue(postSnapshotRegion.containsKey("9")); } }