@Override public DataPolicy getDataPolicy() { return this.ra.getDataPolicy(); }
public DataPolicy getDataPolicy() { if (this.event != null) { return this.event.getRegion().getAttributes().getDataPolicy(); } return null; }
protected boolean withPersistence() { RegionAttributes ra = dataRegion.getAttributes(); DataPolicy dp = ra.getDataPolicy(); final boolean withPersistence = dp.withPersistence(); return withPersistence; }
@Override public <K, V> Set<Integer> getLocalBucketSet(Region<K, V> region) { if (!region.getAttributes().getDataPolicy().withPartitioning()) { return null; } return this.localBucketSet; } }
@Override public Set<Region<?, ?>> rootRegions() { preOp(); Set<Region<?, ?>> rootRegions = new HashSet<>(); for (Region<?, ?> region : this.cache.rootRegions()) { if (!region.getAttributes().getDataPolicy().withStorage()) { rootRegions.add(new ProxyRegion(this, region)); } } return Collections.unmodifiableSet(rootRegions); }
/** * Returns true if this region's config indicates that it will use a disk store. Added for bug * 42055. */ protected boolean usesDiskStore(RegionAttributes regionAttributes) { return !isProxy() && (getAttributes().getDataPolicy().withPersistence() || isOverflowEnabled()); }
@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 executeCreatesSerialAsyncQueueForNonPartitionedRegion() throws Exception { when(attributes.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); function.executeFunction(context); verify(asyncEventQueueFactory, times(1)).create(any(), any()); verify(asyncEventQueueFactory, times(1)).setParallel(false); }
@Test public void executeCreatesParallelAsyncQueueForPartitionedRegion() throws Exception { when(attributes.getDataPolicy()).thenReturn(DataPolicy.PARTITION); function.executeFunction(context); verify(asyncEventQueueFactory, times(1)).create(any(), any()); verify(asyncEventQueueFactory, times(1)).setParallel(true); }
@Test public void testIsRegionPersistentWhenDataPolicyIsNormal() { final Region mockRegion = mock(Region.class, "Region"); final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes"); when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes); when(mockRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.NORMAL); 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(); }
@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); }
@Override public void createOn(Connection conn, boolean isDurable) { byte regionDataPolicyOrdinal = getCqBaseRegion() == null ? (byte) 0 : getCqBaseRegion().getAttributes().getDataPolicy().ordinal; int state = this.cqState.getState(); this.cqProxy.createOn(getName(), conn, getQueryString(), state, isDurable, regionDataPolicyOrdinal); } }
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; }
/** * Create a continuous query on the given server and return the initial query results. * * @param cq the CQ to create on the server */ public SelectResults createWithIR(ClientCQ cq) { pool.getRITracker().addCq(cq, cq.isDurable()); byte regionDataPolicyOrdinal = cq.getCqBaseRegion() == null ? (byte) 0 : cq.getCqBaseRegion().getAttributes().getDataPolicy().ordinal; return CreateCQWithIROp.execute(this.pool, cq.getName(), cq.getQueryString(), CqStateImpl.RUNNING, cq.isDurable(), regionDataPolicyOrdinal); }
/** * Create a continuous query on the given pool * * @param cq the CQ to create on the server */ public Object create(ClientCQ cq) { pool.getRITracker().addCq(cq, cq.isDurable()); byte regionDataPolicyOrdinal = cq.getCqBaseRegion() == null ? (byte) 0 : cq.getCqBaseRegion().getAttributes().getDataPolicy().ordinal; return CreateCQOp.execute(this.pool, cq.getName(), cq.getQueryString(), CqStateImpl.RUNNING, cq.isDurable(), regionDataPolicyOrdinal); }