@Override public Scope getScope() { return this.ra.getScope(); }
/** * validate attributes of subregion being created, sent to parent * * @throws IllegalArgumentException if attrs is null * @throws IllegalStateException if attributes are invalid */ private void validateSubregionAttributes(RegionAttributes attrs) { if (attrs == null) { throw new IllegalArgumentException( "region attributes must not be null"); } if (this.scope == Scope.LOCAL && attrs.getScope() != Scope.LOCAL) { throw new IllegalStateException( "A region with Scope.LOCAL can only have subregions with Scope.LOCAL"); } }
protected LocalMetaRegion(RegionAttributes attrs, InternalRegionArguments ira) { super(DYNAMIC_REGION_LIST_NAME, attrs, null, DynamicRegionFactory.this.cache, ira); Assert.assertTrue(attrs.getScope().isLocal()); }
/** * This implementation only checks readiness and scope */ @Override public Lock getRegionDistributedLock() throws IllegalStateException { checkReadiness(); checkForLimitedOrNoAccess(); Scope theScope = getAttributes().getScope(); Assert.assertTrue(theScope == Scope.LOCAL); throw new IllegalStateException( "Only supported for GLOBAL scope, not LOCAL"); }
/** * This implementation only checks readiness and scope */ @Override public Lock getDistributedLock(Object key) throws IllegalStateException { checkReadiness(); checkForLimitedOrNoAccess(); Scope theScope = getAttributes().getScope(); Assert.assertTrue(theScope == Scope.LOCAL); throw new IllegalStateException( "Only supported for GLOBAL scope, not LOCAL"); }
/************** Public Methods ************************/ Object doNetSearch() throws TimeoutException { resetResults(); RegionAttributes attrs = region.getAttributes(); this.requestInProgress = true; Scope scope = attrs.getScope(); Assert.assertTrue(scope != Scope.LOCAL); netSearchForBlob(); this.requestInProgress = false; return this.result; }
@Test public void testExecuteWithRegions() throws Exception { when(cache.rootRegions()).thenReturn(regions); when(region.getFullPath()).thenReturn("/MyRegion"); when(region.getParentRegion()).thenReturn(null); when(region.subregions(true)).thenReturn(subregions); when(region.subregions(false)).thenReturn(subregions); when(region.getAttributes()).thenReturn(regionAttributes); when(regionAttributes.getDataPolicy()).thenReturn(mock(DataPolicy.class)); when(regionAttributes.getScope()).thenReturn(mock(Scope.class)); regions.add(region); getRegionsFunction.execute(functionContext); }
protected void checkVersionTag(DistributedRegion rgn, VersionTag tag) { RegionAttributes attr = rgn.getAttributes(); if (attr.getConcurrencyChecksEnabled() && attr.getDataPolicy().withPersistence() && attr.getScope() != Scope.GLOBAL && (tag.getMemberID() == null || test_InvalidVersion)) { if (logger.isDebugEnabled()) { logger.debug("Version tag is missing the memberID: {}", tag); } String msg = String.format("memberID cannot be null for persistent regions: %s", tag); RuntimeException ex = (sender.getVersionObject().compareTo(Version.GFE_80) < 0) ? new InternalGemFireException(msg) : new InvalidVersionException(msg); throw ex; } }
/** * Tests that {@link Region#get} returns <code>null</code> when there is no remote loader. */ @Test public void testNoRemoteCacheLoader() { assertThat(getRegionAttributes().getScope().isDistributed()).isTrue(); final String name = this.getUniqueName(); final Object key = "KEY"; SerializableRunnable create = new CacheSerializableRunnable("Create Region") { @Override public void run2() throws CacheException { createRegion(name); } }; final VM vm0 = VM.getVM(0); final VM vm1 = VM.getVM(1); vm0.invoke(create); vm1.invoke(create); vm0.invoke(new CacheSerializableRunnable("Remote load") { @Override public void run2() throws CacheException { Region<Object, Object> region = getRootRegion().getSubregion(name); assertThat(region.get(key)).isNull(); } }); }
/** * Tests that doing a distributed get results in a <code>netSearch</code>. */ @Test public void testDistributedGet() { assertThat(getRegionAttributes().getScope().isDistributed()).isTrue(); final String name = this.getUniqueName(); final Object key = "KEY"; final Object value = "VALUE"; VM vm0 = VM.getVM(0); VM vm1 = VM.getVM(1); vm0.invoke(new CacheSerializableRunnable("Populate region") { @Override public void run2() throws CacheException { Region<Object, Object> region = createRegion(name); region.put(key, value); } }); SerializableRunnable get = new CacheSerializableRunnable("Distributed get") { @Override public void run2() throws CacheException { Region<Object, Object> region = createRegion(name); assertThat(region.get(key)).isEqualTo(value); } }; vm1.invoke(get); }
@Override public void run() { Region<String, String> rgn = getRootRegion().getSubregion(rgnName); if (!rgn.getAttributes().getScope().isAck()) { await().untilAsserted(() -> { checkCommitAndNoData(rgn); }); } else { checkCommitAndNoData(rgn); } }
public RegionInformation(Region<?, ?> region, boolean recursive) { this.name = region.getFullPath().substring(1); this.path = region.getFullPath().substring(1); this.scope = region.getAttributes().getScope(); this.dataPolicy = region.getAttributes().getDataPolicy(); if (region.getParentRegion() == null) { this.isRoot = true; if (recursive) { Set<Region<?, ?>> subRegions = region.subregions(recursive); subRegionInformationSet = getSubRegions(subRegions); } } else { this.isRoot = false; this.parentRegion = region.getParentRegion().getFullPath(); } }
@Test public void processReturnsCacheRegions() throws Exception { RegionAttributes regionAttributesStub = mock(RegionAttributes.class); when(cacheStub.getRegion(TEST_REGION1)).thenReturn(region1Stub); when(region1Stub.getName()).thenReturn(TEST_REGION1); when(region1Stub.size()).thenReturn(10); when(region1Stub.getAttributes()).thenReturn(regionAttributesStub); when(regionAttributesStub.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_REPLICATE); when(regionAttributesStub.getKeyConstraint()).thenReturn(String.class); when(regionAttributesStub.getValueConstraint()).thenReturn(Integer.class); when(regionAttributesStub.getScope()).thenReturn(Scope.DISTRIBUTED_ACK); Result result = operationHandler.process(serializationService, MessageUtil.makeGetSizeRequest(TEST_REGION1), getNoAuthCacheExecutionContext(cacheStub)); RegionAPI.GetSizeResponse response = (RegionAPI.GetSizeResponse) result.getMessage(); Assert.assertEquals(10, response.getSize()); }
assertThat(getRegionAttributes().getScope().isDistributed()).isTrue();
assertThat(getRegionAttributes().getScope().isDistributed()).isTrue();
when(regionAttributes.getLoadFactor()).thenReturn(0.75f); when(regionAttributes.getMembershipAttributes()).thenReturn(membershipAttributes); when(regionAttributes.getScope()).thenReturn(scope); when(partitionedRegion.getFullPath()).thenReturn("parent"); when(internalRegionArgs.getPartitionedRegion()).thenReturn(partitionedRegion);
void initialize(LocalRegion theRegion, Object theKey, Object theCallbackArg) { this.region = theRegion; this.regionName = theRegion.getFullPath(); this.key = theKey; this.aCallbackArgument = theCallbackArg; RegionAttributes attrs = theRegion.getAttributes(); Scope scope = attrs.getScope(); if (scope.isDistributed()) { this.advisor = ((CacheDistributionAdvisee) this.region).getCacheDistributionAdvisor(); this.distributionManager = theRegion.getDistributionManager(); this.timeout = getSearchTimeout(); this.advisor.addMembershipListener(this); } }
public BucketRegion(String regionName, RegionAttributes attrs, LocalRegion parentRegion, InternalCache cache, InternalRegionArguments internalRegionArgs) { super(regionName, attrs, parentRegion, cache, internalRegionArgs); if (PartitionedRegion.DISABLE_SECONDARY_BUCKET_ACK) { Assert.assertTrue(attrs.getScope().isDistributedNoAck()); } else { Assert.assertTrue(attrs.getScope().isDistributedAck()); } Assert.assertTrue(attrs.getDataPolicy().withReplication()); Assert.assertTrue(!attrs.getEarlyAck()); Assert.assertTrue(isUsedForPartitionedRegionBucket()); Assert.assertTrue(!isUsedForPartitionedRegionAdmin()); Assert.assertTrue(internalRegionArgs.getBucketAdvisor() != null); Assert.assertTrue(internalRegionArgs.getPartitionedRegion() != null); this.redundancy = internalRegionArgs.getPartitionedRegionBucketRedundancy(); this.partitionedRegion = internalRegionArgs.getPartitionedRegion(); setEventSeqNum(); }
/** * 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); } }
this.requestInProgress = true; RegionAttributes attrs = region.getAttributes(); Scope scope = attrs.getScope(); CacheLoader loader = ((AbstractRegion) region).basicGetLoader(); if (scope.isLocal()) {