this.cacheListeners = new ArrayList(Arrays.asList(attrs.getCacheListeners())); this.gatewaySenderIds = new HashSet<String>(attrs.getGatewaySenderIds()); this.asyncEventQueueIds = new HashSet<String>(attrs.getAsyncEventQueueIds()); this.cacheLoader = attrs.getCacheLoader(); this.cacheWriter = attrs.getCacheWriter(); this.entryIdleTimeout = attrs.getEntryIdleTimeout(); this.customEntryIdleTimeout = attrs.getCustomEntryIdleTimeout(); this.entryTimeToLive = attrs.getEntryTimeToLive(); this.customEntryTimeToLive = attrs.getCustomEntryTimeToLive(); this.initialCapacity = attrs.getInitialCapacity(); this.keyConstraint = attrs.getKeyConstraint(); this.valueConstraint = attrs.getValueConstraint(); this.loadFactor = attrs.getLoadFactor(); this.regionIdleTimeout = attrs.getRegionIdleTimeout(); this.regionTimeToLive = attrs.getRegionTimeToLive(); this.scope = attrs.getScope(); this.statisticsEnabled = attrs.getStatisticsEnabled(); this.ignoreJTA = attrs.getIgnoreJTA(); this.concurrencyLevel = attrs.getConcurrencyLevel(); this.concurrencyChecksEnabled = attrs.getConcurrencyChecksEnabled(); this.earlyAck = attrs.getEarlyAck(); this.diskStoreName = attrs.getDiskStoreName(); if (this.diskStoreName == null) { this.diskWriteAttributes = attrs.getDiskWriteAttributes(); this.diskDirs = attrs.getDiskDirs(); this.diskSizes = attrs.getDiskDirSizes(); } else { this.diskWriteAttributes = null;
if (regAttrs.getCacheLoader() != null) { cacheLoaderClassName = regAttrs.getCacheLoader().getClass().getCanonicalName(); if (regAttrs.getCacheWriter() != null) { cacheWriteClassName = regAttrs.getCacheWriter().getClass().getCanonicalName(); if (regAttrs.getKeyConstraint() != null) { keyConstraintClassName = regAttrs.getKeyConstraint().getName(); if (regAttrs.getValueConstraint() != null) { valueContstraintClassName = regAttrs.getValueConstraint().getName(); CacheListener[] listeners = regAttrs.getCacheListeners(); int regionTimeToLive = regAttrs.getRegionTimeToLive().getTimeout(); int regionIdleTimeout = regAttrs.getRegionIdleTimeout().getTimeout(); int entryTimeToLive = regAttrs.getEntryTimeToLive().getTimeout(); int entryIdleTimeout = regAttrs.getEntryIdleTimeout().getTimeout(); Object o1 = regAttrs.getCustomEntryTimeToLive(); if (o1 != null) { customEntryTimeToLive = o1.toString(); Object o2 = regAttrs.getCustomEntryIdleTimeout(); if (o2 != null) { customEntryIdleTimeout = o2.toString(); boolean ignoreJTA = regAttrs.getIgnoreJTA(); String dataPolicy = regAttrs.getDataPolicy().toString();
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; }
AttributesFactory factory = new AttributesFactory(); RegionAttributes attrs = factory.create(); assertNull(attrs.getCacheLoader()); assertNull(attrs.getCacheWriter()); assertNull(attrs.getCacheListener()); assertEquals(Arrays.asList(new CacheListener[0]), Arrays.asList(attrs.getCacheListeners())); assertEquals(0, attrs.getRegionTimeToLive().getTimeout()); assertEquals(0, attrs.getRegionIdleTimeout().getTimeout()); assertEquals(0, attrs.getEntryTimeToLive().getTimeout()); assertEquals(null, attrs.getCustomEntryTimeToLive()); assertEquals(0, attrs.getEntryIdleTimeout().getTimeout()); assertEquals(null, attrs.getCustomEntryIdleTimeout()); assertEquals(Scope.DISTRIBUTED_NO_ACK, attrs.getScope()); assertEquals(DataPolicy.DEFAULT, attrs.getDataPolicy()); assertEquals(InterestPolicy.DEFAULT, attrs.getSubscriptionAttributes().getInterestPolicy()); assertEquals(MirrorType.NONE, attrs.getMirrorType()); assertEquals(null, attrs.getDiskStoreName()); assertEquals(AttributesFactory.DEFAULT_DISK_SYNCHRONOUS, attrs.isDiskSynchronous()); assertNull(attrs.getKeyConstraint()); assertEquals(16, attrs.getInitialCapacity()); assertEquals(0.75, attrs.getLoadFactor(), 0.0); assertFalse(attrs.getStatisticsEnabled()); assertFalse(attrs.getPersistBackup()); DiskWriteAttributes dwa = attrs.getDiskWriteAttributes(); assertNotNull(dwa); assertNull(attrs.getDiskStoreName()); File[] diskDirs = attrs.getDiskDirs(); assertNotNull(diskDirs);
CacheListener listener = ra.getCacheListener(); if (listener != null) { allListeners.add(listener.toString()); CacheWriter writer = ra.getCacheWriter(); if (writer != null) { allCacheWriters.add(writer.toString()); CacheLoader loader = ra.getCacheLoader(); if (loader != null) { allCacheLoaders.add(loader); allDataPolicies.add(ra.getDataPolicy()); allRegionTtl.add(ra.getRegionTimeToLive()); allEntryTtl.add(ra.getEntryTimeToLive()); allCustomTtl.add(ra.getCustomEntryTimeToLive().toString()); allRegionIdleTimeout.add(ra.getRegionIdleTimeout()); allEntryIdleTimeout.add(ra.getEntryIdleTimeout()); allCustomIdle.add(ra.getCustomEntryIdleTimeout().toString()); allScopes.add(ra.getScope()); allLoadFactors.add(new Float(ra.getLoadFactor())); allInitialCaps.add(Integer.valueOf(ra.getInitialCapacity())); allConcLevels.add(Integer.valueOf(ra.getConcurrencyLevel())); allStatsEnabled.add(Boolean.valueOf(ra.getStatisticsEnabled())); allUserAttributes.add(snap.getUserAttribute()); allKeyConstraints.add(ra.getKeyConstraint()); allValueConstraints.add(ra.getValueConstraint());
operation = mock(Operation.class); when(regionAttributes.getEvictionAttributes()).thenReturn(evictionAttributes); when(regionAttributes.getRegionTimeToLive()).thenReturn(expirationAttributes); when(regionAttributes.getRegionIdleTimeout()).thenReturn(expirationAttributes); when(regionAttributes.getEntryTimeToLive()).thenReturn(expirationAttributes); when(regionAttributes.getEntryIdleTimeout()).thenReturn(expirationAttributes); when(regionAttributes.getDataPolicy()).thenReturn(dataPolicy); when(regionAttributes.getDiskStoreName()).thenReturn("store"); when(regionAttributes.getConcurrencyLevel()).thenReturn(16); 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);
public DataPolicy getDataPolicy() { if (this.event != null) { return this.event.getRegion().getAttributes().getDataPolicy(); } return null; }
@Test public void testIsRegionUsingDiskStoreWhenDiskStoresMismatch() { final Region mockRegion = mock(Region.class, "Region"); final DiskStore mockDiskStore = mock(DiskStore.class, "DiskStore"); final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_PARTITION); when(mockRegionAttributes.getDiskStoreName()).thenReturn("mockDiskStore"); when(mockDiskStore.getName()).thenReturn("testDiskStore"); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.isUsingDiskStore(mockRegion, mockDiskStore)).isFalse(); }
private PartitionAttributes initializeAttributes(final Cache cache) { PartitionAttributes partitionAttributes = mock(PartitionAttributes.class); RegionAttributes attributes = mock(RegionAttributes.class); when(attributes.getCacheListeners()).thenReturn(new CacheListener[0]); when(attributes.getRegionTimeToLive()).thenReturn(ExpirationAttributes.DEFAULT); when(attributes.getRegionIdleTimeout()).thenReturn(ExpirationAttributes.DEFAULT); when(attributes.getEntryTimeToLive()).thenReturn(ExpirationAttributes.DEFAULT); when(attributes.getEntryIdleTimeout()).thenReturn(ExpirationAttributes.DEFAULT); when(attributes.getMembershipAttributes()).thenReturn(new MembershipAttributes()); when(cache.getRegionAttributes(RegionShortcut.PARTITION.toString())).thenReturn(attributes); when(partitionAttributes.getTotalNumBuckets()).thenReturn(113); return partitionAttributes; }
@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()); }
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; } }
@Test public void testIsRegionUsingDiskStoreWhenOverflowing() { final String diskStoreName = "testDiskStore"; final Region mockRegion = mock(Region.class, "Region"); final DiskStore mockDiskStore = mock(DiskStore.class, "DiskStore"); final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes"); final EvictionAttributes mockEvictionAttributes = mock(EvictionAttributes.class, "EvictionAttributes"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PARTITION); when(mockRegionAttributes.getDiskStoreName()).thenReturn(diskStoreName); when(mockRegionAttributes.getEvictionAttributes()).thenReturn(mockEvictionAttributes); when(mockEvictionAttributes.getAction()).thenReturn(EvictionAction.OVERFLOW_TO_DISK); when(mockDiskStore.getName()).thenReturn(diskStoreName); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.isUsingDiskStore(mockRegion, mockDiskStore)).isTrue(); verify(mockRegion, times(4)).getAttributes(); verify(mockRegionAttributes, times(2)).getEvictionAttributes(); }
private AsyncEventQueueFactoryImpl createAEQFactory(final RegionAttributes attributes) { AsyncEventQueueFactoryImpl factory = (AsyncEventQueueFactoryImpl) cache.createAsyncEventQueueFactory(); if (attributes.getPartitionAttributes() != null) { factory.setParallel(true); // parallel AEQ for PR } else { factory.setParallel(false); // TODO: not sure if serial AEQ working or not } factory.setMaximumQueueMemory(1000); factory.setDispatcherThreads(10); factory.setBatchSize(1000); factory.setIsMetaQueue(true); if (attributes.getDataPolicy().withPersistence()) { factory.setPersistent(true); } factory.setDiskStoreName(attributes.getDiskStoreName()); factory.setDiskSynchronous(true); factory.setForwardExpirationDestroy(true); return factory; }
static void validateRegionAttributes(RegionAttributes attrs) { if (!attrs.getDataPolicy().withPartitioning()) { // replicated region throw new UnsupportedOperationException( "Lucene indexes on replicated regions are not supported"); } // For now we cannot support eviction with local destroy. // Eviction with overflow to disk still needs to be supported EvictionAttributes evictionAttributes = attrs.getEvictionAttributes(); EvictionAlgorithm evictionAlgorithm = evictionAttributes.getAlgorithm(); if (evictionAlgorithm != EvictionAlgorithm.NONE && evictionAttributes.getAction().isLocalDestroy()) { throw new UnsupportedOperationException( "Lucene indexes on regions with eviction and action local destroy are not supported"); } }
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(); } }
if (!attr.getDataPolicy().withReplication() || attr.getConcurrencyChecksEnabled()) { events = TxEventTestUtil.getPutEvents(tl.lastEvent.getEvents()); } else {
private void validateExpirationAttributes(final RegionAttributes userRA, final PartitionRegionConfig prconf) { if (!userRA.getRegionIdleTimeout().equals(prconf.getRegionIdleTimeout())) { throw new IllegalStateException( String.format( "The %1$s set in RegionAttributes is incompatible with %1$s used by other distributed members.", new Object[] {" region idle timout "})); } if (!userRA.getRegionTimeToLive().equals(prconf.getRegionTimeToLive())) { throw new IllegalStateException( String.format( "The %1$s set in RegionAttributes is incompatible with %1$s used by other distributed members.", new Object[] {" region time to live "})); } if (!userRA.getEntryIdleTimeout().equals(prconf.getEntryIdleTimeout())) { throw new IllegalStateException( String.format( "The %1$s set in RegionAttributes is incompatible with %1$s used by other distributed members.", new Object[] {" entry idle timout "})); } if (!userRA.getEntryTimeToLive().equals(prconf.getEntryTimeToLive())) { throw new IllegalStateException( String.format( "The %1$s set in RegionAttributes is incompatible with %1$s used by other distributed members.", new Object[] {" entry time to live "})); } }
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(); }
@Override public EvictionAttributes getEvictionAttributes() { return this.ra.getEvictionAttributes(); }
@Override public PartitionAttributes getPartitionAttributes() { return this.ra.getPartitionAttributes(); }