protected String getDiskStoreName(final Region region) { return StringUtils.defaultIfBlank(region.getAttributes().getDiskStoreName(), DiskStoreDetails.DEFAULT_DISK_STORE_NAME); }
@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 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(); }
@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 testIsRegionUsingDiskStoreWhenUsingDefaultDiskStore() { 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_REPLICATE); when(mockRegionAttributes.getDiskStoreName()).thenReturn(null); when(mockDiskStore.getName()).thenReturn(DiskStoreDetails.DEFAULT_DISK_STORE_NAME); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.isUsingDiskStore(mockRegion, mockDiskStore)).isTrue(); verify(mockRegion, atLeastOnce()).getAttributes(); }
@Test public void testIsRegionUsingDiskStoreWhenPersistent() { 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"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_PARTITION); when(mockRegionAttributes.getDiskStoreName()).thenReturn(diskStoreName); when(mockDiskStore.getName()).thenReturn(diskStoreName); final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction(); assertThat(function.isUsingDiskStore(mockRegion, mockDiskStore)).isTrue(); verify(mockRegion, atLeastOnce()).getAttributes(); }
private void setDiskAttributes(BucketAttributesFactory factory) { factory.setDiskSynchronous(this.partitionedRegion.getAttributes().isDiskSynchronous()); factory.setDiskStoreName(this.partitionedRegion.getAttributes().getDiskStoreName()); }
@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(); }
when(mockUserRegion.subregions(false)).thenReturn(CollectionUtils.asSet(mockSessionRegion)); when(mockUserRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_PARTITION); when(mockUserRegionAttributes.getDiskStoreName()).thenReturn(diskStoreName); when(mockUserRegionAttributes.getEvictionAttributes()).thenReturn(mockUserEvictionAttributes); when(mockUserEvictionAttributes.getAction()).thenReturn(EvictionAction.LOCAL_DESTROY); when(mockSessionRegion.subregions(false)).thenReturn(Collections.emptySet()); when(mockSessionRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); when(mockSessionRegionAttributes.getDiskStoreName()).thenReturn(diskStoreName); when(mockSessionRegionAttributes.getEvictionAttributes()) .thenReturn(mockSessionEvictionAttributes); when(mockGuestRegion.subregions(false)).thenReturn(Collections.emptySet()); when(mockGuestRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); when(mockGuestRegionAttributes.getDiskStoreName()) .thenReturn(DiskStoreDetails.DEFAULT_DISK_STORE_NAME); when(mockGuestRegionAttributes.getEvictionAttributes()).thenReturn(mockGuestEvictionAttributes);
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);
concurrencyLevel = ra.getConcurrencyLevel(); dataPolicy = ra.getDataPolicy(); diskStoreName = ra.getDiskStoreName(); enableAsyncConflation = ra.getEnableAsyncConflation(); enableSubscriptionConflation = ra.getEnableSubscriptionConflation();
String poolName = regAttrs.getPoolName(); boolean isCloningEnabled = regAttrs.getCloningEnabled(); String diskStoreName = regAttrs.getDiskStoreName(); String interestPolicy = null; if (regAttrs.getSubscriptionAttributes() != null) {
diskDir = getCache().findDiskStore(attrs.getDiskStoreName()).getDiskDirs()[0];
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; }
protected <K, V> Region<K, V> createRegion(final String regionName, final RegionShortcut regionShortCut, final String colocatedWithRegionName, final PartitionAttributes partitionAttributes, final RegionAttributes regionAttributes, PartitionListener lucenePrimaryBucketListener) { PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory(); if (lucenePrimaryBucketListener != null) { partitionAttributesFactory.addPartitionListener(lucenePrimaryBucketListener); } partitionAttributesFactory.setColocatedWith(colocatedWithRegionName); configureLuceneRegionAttributesFactory(partitionAttributesFactory, partitionAttributes); // Create AttributesFactory based on input RegionShortcut RegionAttributes baseAttributes = this.cache.getRegionAttributes(regionShortCut.toString()); AttributesFactory factory = new AttributesFactory(baseAttributes); factory.setPartitionAttributes(partitionAttributesFactory.create()); if (regionAttributes.getDataPolicy().withPersistence()) { factory.setDiskStoreName(regionAttributes.getDiskStoreName()); } RegionAttributes<K, V> attributes = factory.create(); return createRegion(regionName, attributes); }
this.concurrencyChecksEnabled = attrs.getConcurrencyChecksEnabled(); this.earlyAck = attrs.getEarlyAck(); this.diskStoreName = attrs.getDiskStoreName(); if (this.diskStoreName == null) { this.diskWriteAttributes = attrs.getDiskWriteAttributes();
this.diskStoreName = attrs.getDiskStoreName(); this.isDiskSynchronous = attrs.isDiskSynchronous(); if (this.diskStoreName == null) {
this.regionAttributes.concurrencyChecksEnabled = regionAttributes.getConcurrencyChecksEnabled(); this.regionAttributes.earlyAck = regionAttributes.getEarlyAck(); this.regionAttributes.diskStoreName = regionAttributes.getDiskStoreName(); if (this.regionAttributes.diskStoreName == null) { this.regionAttributes.diskWriteAttributes = regionAttributes.getDiskWriteAttributes();
this.publisher = attr.getPublisher(); this.enableAsyncConflation = attr.getEnableAsyncConflation(); this.diskStoreName = attr.getDiskStoreName(); if (this.diskStoreName == null) { this.diskWriteAttributes = attr.getDiskWriteAttributes();
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()); assertNull(attrs.getDiskStoreName()); File[] diskDirs = attrs.getDiskDirs(); assertNotNull(diskDirs);