protected boolean isOverflowToDisk(final Region region) { return (region.getAttributes().getEvictionAttributes() != null && EvictionAction.OVERFLOW_TO_DISK .equals(region.getAttributes().getEvictionAttributes().getAction())); }
@Override public boolean isMappingSynchronous(String regionName, Cache cache) { Region<?, ?> region = cache.getRegion(regionName); if (region == null) { throw new IllegalStateException("Region for mapping could not be found."); } // If our region has a Jdbc Writer set as the cache writer then we know it is syncronous return region.getAttributes().getCacheWriter() != null && region.getAttributes().getCacheWriter() instanceof JdbcWriter; }
private static Region createSubregion(final Region region) { Region subregion = getSubregion(); if (subregion == null) { subregion = region.createSubregion(SUBREGION_NAME, region.getAttributes()); } return subregion; }
CompactMapRangeIndex(InternalCache cache, String indexName, Region region, String fromClause, String indexedExpression, String projectionAttributes, String origFromClause, String origIndxExpr, String[] defintions, boolean isAllKeys, String[] multiIndexingKeysPattern, Object[] mapKeys, IndexStatistics stats) { super(cache, indexName, region, fromClause, indexedExpression, projectionAttributes, origFromClause, origIndxExpr, defintions, isAllKeys, multiIndexingKeysPattern, mapKeys, stats); RegionAttributes ra = region.getAttributes(); this.entryToMapKeyIndexKeyMap = new java.util.concurrent.ConcurrentHashMap( ra.getInitialCapacity(), ra.getLoadFactor(), ra.getConcurrencyLevel()); }
/** * Returns a <code>RegionAttributesResponse</code> that will be returned to the specified * recipient. The message will contains a copy of the local manager's system config. */ public static RegionAttributesResponse create(DistributionManager dm, InternalDistributedMember recipient, Region r) { RegionAttributesResponse m = new RegionAttributesResponse(); m.setRecipient(recipient); m.attributes = new RemoteRegionAttributes(r.getAttributes()); return m; }
private boolean isMemoryEvictionConfigured() { boolean result = false; EvictionAttributes ea = region.getAttributes().getEvictionAttributes(); if (ea != null && ea.getAlgorithm().isLRUMemory()) { result = true; } return result; }
public PrimaryKeyIndex(InternalCache cache, String indexName, Region region, String fromClause, String indexedExpression, String projectionAttributes, String origFromClause, String origIndxExpr, String[] defintions, IndexStatistics indexStatistics) { super(cache, indexName, region, fromClause, indexedExpression, projectionAttributes, origFromClause, origIndxExpr, defintions, indexStatistics); // TODO: Check if the below is correct Class constr = region.getAttributes().getValueConstraint(); if (constr == null) constr = Object.class; this.indexResultType = new ObjectTypeImpl(constr); markValid(true); }
MemoryIndexStore(Region region, InternalIndexStatistics internalIndexStats, InternalCache cache) { this.region = region; RegionAttributes ra = region.getAttributes(); // Initialize the reverse-map if in-place modification is set by the // application. if (IndexManager.isObjectModificationInplace()) { this.entryToValuesMap = new ConcurrentHashMap(ra.getInitialCapacity(), ra.getLoadFactor(), ra.getConcurrencyLevel()); } this.internalIndexStats = internalIndexStats; this.cache = cache; }
@Test public void testGetRegionDiskStoreName() { final String expectedDiskStoreName = "testDiskStore"; final Region mockRegion = mock(Region.class, "Region"); final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDiskStoreName()).thenReturn(expectedDiskStoreName); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.getDiskStoreName(mockRegion)).isEqualTo(expectedDiskStoreName); }
@Test public void testGetRegionDiskStoreNameWhenUnspecified() { final Region mockRegion = mock(Region.class, "Region"); final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDiskStoreName()).thenReturn(null); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.getDiskStoreName(mockRegion)) .isEqualTo(DiskStoreDetails.DEFAULT_DISK_STORE_NAME); }
@Test public void testIsRegionPersistentWhenDataPolicyIsPersistentPartition() { final Region mockRegion = mock(Region.class, "Region"); final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_PARTITION); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.isPersistent(mockRegion)).isTrue(); }
@Test public void testIsRegionPersistentWhenDataPolicyIsPersistentReplicate() { final Region mockRegion = mock(Region.class, "Region"); final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_REPLICATE); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.isPersistent(mockRegion)).isTrue(); }
@Test public void testIsRegionPersistentWhenDataPolicyIsPartition() { final Region mockRegion = mock(Region.class, "Region"); final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PARTITION); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.isPersistent(mockRegion)).isFalse(); }
@Test public void testIsRegionPersistentWhenDataPolicyIsPreloaded() { final Region mockRegion = mock(Region.class, "Region"); final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PRELOADED); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.isPersistent(mockRegion)).isFalse(); }
@Test public void testIsRegionPersistentWhenDataPolicyIsReplicate() { final Region mockRegion = mock(Region.class, "Region"); final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.isPersistent(mockRegion)).isFalse(); }
@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(); }
protected LuceneIndexForPartitionedRegion setupSpy(final Region region, final LuceneIndexForPartitionedRegion index, final String aeq) { index.setSearchableFields(new String[] {"field"}); LuceneIndexForPartitionedRegion spy = spy(index); doReturn(null).when(spy).createRegion(any(), any(), any(), any(), any(), any()); doReturn(null).when(spy).createAEQ(any(), any()); spy.setupRepositoryManager(null); spy.createAEQ(region.getAttributes(), aeq); spy.initialize(); return spy; }
@Override public void run() { Region<String, String> rgn = getRootRegion().getSubregion(rgnName); if (!rgn.getAttributes().getScope().isAck()) { await().untilAsserted(() -> { checkCommitAndNoData(rgn); }); } else { checkCommitAndNoData(rgn); } }
@Test public void initializeWithoutPersistenceShouldCreateAEQ() { boolean withPersistence = false; String name = "indexName"; String regionPath = "regionName"; InternalCache cache = Fakes.cache(); Region region = initializeScenario(withPersistence, regionPath, cache); LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache); LuceneIndexForPartitionedRegion spy = setupSpy(region, index, "aeq"); verify(spy).createAEQ(eq(region.getAttributes()), eq("aeq")); }
private void initialize(Region region) { setNumberOfEntries(region.size()); EvictionAttributes ea = region.getAttributes().getEvictionAttributes(); if (ea != null && ea.getAlgorithm().isLRUMemory()) { setHeapSize(((InternalRegion) region).getEvictionCounter()); } else { setHeapSize(-1); } }