protected DistributedMetaRegion(RegionAttributes attrs) { super(DYNAMIC_REGION_LIST_NAME, attrs, null, DynamicRegionFactory.this.cache, new InternalRegionArguments()); }
static void validate(String name) { validate(name, new InternalRegionArguments()); }
@Override public Region createSubregion(String subregionName, RegionAttributes aRegionAttributes) throws RegionExistsException, TimeoutException { try { return createSubregion(subregionName, aRegionAttributes, new InternalRegionArguments().setDestroyLockFlag(true).setRecreateFlag(false)); } catch (IOException | ClassNotFoundException e) { // only happens when loading a snapshot, not here throw new InternalGemFireError( "unexpected exception", e); } }
@Test public void createVMRegionWithDefaultArgsApplicationWorks() throws Exception { when(delegate.createVMRegion(any(), any(), any())).thenReturn(applicationRegion); Region result = cache.createVMRegion(null, null, new InternalRegionArguments()); assertThat(result).isSameAs(applicationRegion); }
@Test public void createVMRegionWithUsedForSerialGatewaySenderQueueThrows() throws Exception { assertThatThrownBy(() -> { cache.createVMRegion(null, null, new InternalRegionArguments().setIsUsedForSerialGatewaySenderQueue(true)); }).isInstanceOf(NotAuthorizedException.class); }
@Test public void createVMRegionWithUsedForMetaRegionThrows() throws Exception { assertThatThrownBy(() -> { cache.createVMRegion(null, null, new InternalRegionArguments().setIsUsedForMetaRegion(true)); }).isInstanceOf(NotAuthorizedException.class); }
@Test public void createVMRegionWithUsedForParallelGatewaySenderQueueThrows() throws Exception { assertThatThrownBy(() -> { cache.createVMRegion(null, null, new InternalRegionArguments().setIsUsedForParallelGatewaySenderQueue(true)); }).isInstanceOf(NotAuthorizedException.class); }
private HARegion(String regionName, RegionAttributes attrs, LocalRegion parentRegion, InternalCache cache) { super(regionName, attrs, parentRegion, cache, new InternalRegionArguments().setDestroyLockFlag(true).setRecreateFlag(false) .setSnapshotInputStream(null).setImageTarget(null)); this.haRegionStats = new DummyCachePerfStats(); }
@Test public void createVMRegionWithInternalRegionThrows() throws Exception { assertThatThrownBy(() -> { cache.createVMRegion(null, null, new InternalRegionArguments().setInternalRegion(true)); }).isInstanceOf(NotAuthorizedException.class); }
@Test public void createVMRegionWithUsedForPartitionedRegionBucketThrows() throws Exception { assertThatThrownBy(() -> { cache.createVMRegion(null, null, new InternalRegionArguments().setPartitionedRegionBucketRedundancy(0)); }).isInstanceOf(NotAuthorizedException.class); }
@Test public void invokeClientOperationsOnInternalRegion() { serverVM.invoke(() -> { // we need to use internal APIs to create an "internal" region GemFireCacheImpl serverCache = (GemFireCacheImpl) cache; InternalRegionArguments internalRegionArguments = new InternalRegionArguments(); internalRegionArguments.setIsUsedForPartitionedRegionAdmin(true); RegionAttributes<String, String> attributes = serverCache.getRegionAttributes(RegionShortcut.REPLICATE.toString()); LocalRegion region = (LocalRegion) serverCache.createVMRegion("internalRegion", attributes, internalRegionArguments); assertThat(region.isInternalRegion()).isTrue(); }); clientVM.invoke(this::testAllOperations); }
protected DistributedRegion prepare(boolean isConcurrencyChecksEnabled) { GemFireCacheImpl cache = Fakes.cache(); // create region attributes and internal region arguments RegionAttributes ra = createRegionAttributes(isConcurrencyChecksEnabled); InternalRegionArguments ira = new InternalRegionArguments(); // create a region object DistributedRegion region = createAndDefineRegion(isConcurrencyChecksEnabled, ra, ira, cache); if (isConcurrencyChecksEnabled) { region.enableConcurrencyChecks(); } doNothing().when(region).notifyGatewaySender(any(), any()); doReturn(true).when(region).hasSeenEvent(any(EntryEventImpl.class)); return region; }
protected SerialGatewaySenderQueueMetaRegion(String regionName, RegionAttributes attrs, LocalRegion parentRegion, InternalCache cache, AbstractGatewaySender sender) { super(regionName, attrs, parentRegion, cache, new InternalRegionArguments().setDestroyLockFlag(true).setRecreateFlag(false) .setSnapshotInputStream(null).setImageTarget(null) .setIsUsedForSerialGatewaySenderQueue(true).setSerialGatewaySender(sender)); this.sender = sender; }
public ParallelGatewaySenderQueueMetaRegion(String regionName, RegionAttributes attrs, LocalRegion parentRegion, InternalCache cache, AbstractGatewaySender pgSender) { super(regionName, attrs, parentRegion, cache, new InternalRegionArguments().setDestroyLockFlag(true).setRecreateFlag(false) .setSnapshotInputStream(null).setImageTarget(null) .setIsUsedForParallelGatewaySenderQueue(true) .setParallelGatewaySender((AbstractGatewaySender) pgSender)); this.sender = (AbstractGatewaySender) pgSender; }
protected DistributedRegion prepare(boolean isConcurrencyChecksEnabled, boolean testHasSeenEvent) { GemFireCacheImpl cache = Fakes.cache(); // create region attributes and internal region arguments RegionAttributes ra = createRegionAttributes(isConcurrencyChecksEnabled); InternalRegionArguments ira = new InternalRegionArguments(); setInternalRegionArguments(ira); // create a region object DistributedRegion region = createAndDefineRegion(isConcurrencyChecksEnabled, ra, ira, cache); if (isConcurrencyChecksEnabled) { region.enableConcurrencyChecks(); } doNothing().when(region).notifyGatewaySender(any(), any()); if (!testHasSeenEvent) { doReturn(true).when(region).hasSeenEvent(any(EntryEventImpl.class)); } return region; }
public synchronized void initializeRegionAdvisor() { if (this.buckets != null) { return; } PartitionedRegion p = getPartitionedRegion(); int numBuckets = p.getAttributes().getPartitionAttributes().getTotalNumBuckets(); ProxyBucketRegion[] bucs = new ProxyBucketRegion[numBuckets]; InternalRegionArguments args = new InternalRegionArguments(); args.setPartitionedRegionAdvisor(this); for (int i = 0; i < bucs.length; i++) { bucs[i] = new ProxyBucketRegion(i, p, args); bucs[i].initialize(); } this.buckets = bucs; }
@Override public <K, V> Region<K, V> basicCreateRegion(String name, RegionAttributes<K, V> attrs) throws RegionExistsException, TimeoutException { try { InternalRegionArguments ira = new InternalRegionArguments().setDestroyLockFlag(true) .setRecreateFlag(false).setSnapshotInputStream(null).setImageTarget(null); if (attrs instanceof UserSpecifiedRegionAttributes) { ira.setIndexes(((UserSpecifiedRegionAttributes) attrs).getIndexes()); } return createVMRegion(name, attrs, ira); } catch (IOException | ClassNotFoundException e) { // only if loading snapshot, not here throw new InternalGemFireError( "unexpected exception", e); } }
protected <K, V> Region<K, V> createRegion(final String regionName, final RegionAttributes<K, V> attributes) { // Create InternalRegionArguments to set isUsedForMetaRegion true to suppress xml generation // (among other things) InternalRegionArguments ira = new InternalRegionArguments().setDestroyLockFlag(true).setRecreateFlag(false) .setSnapshotInputStream(null).setImageTarget(null).setIsUsedForMetaRegion(true); // Create the region try { return this.cache.createVMRegion(regionName, attributes, ira); } catch (Exception e) { InternalGemFireError ige = new InternalGemFireError( "unexpected exception"); ige.initCause(e); throw ige; } }
@Test public void startingWithDoubleUnderscoreIsOkForInternalRegion() { InternalRegionArguments internalRegionArguments = new InternalRegionArguments(); internalRegionArguments.setInternalRegion(true); assertThatCode(() -> validate("__ValidInternalRegionName", internalRegionArguments)) .doesNotThrowAnyException(); }
public static Region createOrGetExistingExportLogsRegion(boolean isInitiatingMember, InternalCache cache) throws IOException, ClassNotFoundException { InternalCacheForClientAccess cacheForClientAccess = cache.getCacheForProcessingClientRequests(); Region exportLogsRegion = cacheForClientAccess.getInternalRegion(EXPORT_LOGS_REGION); if (exportLogsRegion == null) { AttributesFactory<String, Configuration> regionAttrsFactory = new AttributesFactory<>(); regionAttrsFactory.setDataPolicy(DataPolicy.EMPTY); regionAttrsFactory.setScope(Scope.DISTRIBUTED_ACK); if (isInitiatingMember) { regionAttrsFactory.setCacheWriter(new ExportLogsCacheWriter()); } InternalRegionArguments internalArgs = new InternalRegionArguments(); internalArgs.setIsUsedForMetaRegion(true); exportLogsRegion = cacheForClientAccess.createInternalRegion(EXPORT_LOGS_REGION, regionAttrsFactory.create(), internalArgs); } return exportLogsRegion; }