本文整理了Java中org.apache.geode.cache.RegionAttributes.getEvictionAttributes
方法的一些代码示例,展示了RegionAttributes.getEvictionAttributes
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RegionAttributes.getEvictionAttributes
方法的具体详情如下:
包路径:org.apache.geode.cache.RegionAttributes
类名称:RegionAttributes
方法名:getEvictionAttributes
[英]Attributes that control the size of the Region
using an EvictionAlgorithmand a EvictionAction.
[中]使用驱逐算法和驱逐动作控制Region
大小的属性。
代码示例来源:origin: apache/geode
@Override
public EvictionAttributes getEvictionAttributes() {
return this.ra.getEvictionAttributes();
}
代码示例来源:origin: apache/geode
protected boolean isOverflowToDisk(final Region region) {
return (region.getAttributes().getEvictionAttributes() != null
&& EvictionAction.OVERFLOW_TO_DISK
.equals(region.getAttributes().getEvictionAttributes().getAction()));
}
代码示例来源:origin: apache/geode
private boolean isOverflowEnabled() {
EvictionAttributes ea = getAttributes().getEvictionAttributes();
return ea != null && ea.getAction().isOverflowToDisk();
}
代码示例来源:origin: apache/geode
private boolean isMemoryEvictionConfigured() {
boolean result = false;
EvictionAttributes ea = region.getAttributes().getEvictionAttributes();
if (ea != null && ea.getAlgorithm().isLRUMemory()) {
result = true;
}
return result;
}
代码示例来源:origin: apache/geode
public static EvictionAttributesData getEvictionAttributesData(RegionAttributes regAttrs) {
String algorithm = "";
Integer maximum = null;
if (regAttrs.getEvictionAttributes().getAlgorithm() != null) {
algorithm = regAttrs.getEvictionAttributes().getAlgorithm().toString();
if (algorithm.equals(EvictionAlgorithm.NONE.toString())) {
EvictionAttributesData evictionAttributesData =
new EvictionAttributesData(algorithm, null, EvictionAlgorithm.NONE.toString());
return evictionAttributesData;
}
if (!regAttrs.getEvictionAttributes().getAlgorithm().isLRUHeap()) {
maximum = regAttrs.getEvictionAttributes().getMaximum();
}
}
String action = regAttrs.getEvictionAttributes().getAction().toString();
EvictionAttributesData evictionAttributesData =
new EvictionAttributesData(algorithm, maximum, action);
return evictionAttributesData;
}
代码示例来源:origin: apache/geode
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");
}
}
代码示例来源:origin: apache/geode
@Test
public void testIsRegionOverflowToDiskWhenEvictionActionIsOverflowToDisk() {
final Region mockRegion = mock(Region.class, "Region");
final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes");
final EvictionAttributes mockEvictionAttributes =
mock(EvictionAttributes.class, "EvictionAttributes");
when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes);
when(mockRegionAttributes.getEvictionAttributes()).thenReturn(mockEvictionAttributes);
when(mockEvictionAttributes.getAction()).thenReturn(EvictionAction.OVERFLOW_TO_DISK);
final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction();
assertThat(function.isOverflowToDisk(mockRegion)).isTrue();
verify(mockRegion, times(2)).getAttributes();
verify(mockRegionAttributes, times(2)).getEvictionAttributes();
}
代码示例来源:origin: apache/geode
@Test
public void testIsRegionOverflowToDiskWithNullEvictionAttributes() {
final Region mockRegion = mock(Region.class, "Region");
final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes");
when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes);
when(mockRegionAttributes.getEvictionAttributes()).thenReturn(null);
final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction();
assertThat(function.isOverflowToDisk(mockRegion)).isFalse();
}
代码示例来源:origin: apache/geode
@Test
public void testIsRegionOverflowToDiskWhenEvictionActionIsLocalDestroy() {
final Region mockRegion = mock(Region.class, "Region");
final RegionAttributes mockRegionAttributes = mock(RegionAttributes.class, "RegionAttributes");
final EvictionAttributes mockEvictionAttributes =
mock(EvictionAttributes.class, "EvictionAttributes");
when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes);
when(mockRegionAttributes.getEvictionAttributes()).thenReturn(mockEvictionAttributes);
when(mockEvictionAttributes.getAction()).thenReturn(EvictionAction.LOCAL_DESTROY);
final DescribeDiskStoreFunction function = new DescribeDiskStoreFunction();
assertThat(function.isOverflowToDisk(mockRegion)).isFalse();
verify(mockRegion, times(2)).getAttributes();
verify(mockRegionAttributes, times(2)).getEvictionAttributes();
}
代码示例来源:origin: apache/geode
/**
* Note: hydra invokes this with setRefid=false.
*/
public void setAttributes(RegionAttributes attrs, boolean setRefid) {
this.hasAttributes = true;
if (attrs instanceof RegionAttributesCreation) {
this.attrs = (RegionAttributesCreation) attrs;
} else {
this.attrs = new RegionAttributesCreation(this.cache, attrs, false);
}
if ((setRefid && (this.attrs.getRefid() == null))) {
this.attrs.setRefid(getRefid());
}
if (attrs.getPartitionAttributes() != null && attrs.getEvictionAttributes() != null
&& attrs.getEvictionAttributes().getAlgorithm().isLRUMemory()
&& attrs.getPartitionAttributes().getLocalMaxMemory() != 0 && attrs.getEvictionAttributes()
.getMaximum() != attrs.getPartitionAttributes().getLocalMaxMemory()) {
getCache().getLogger().warning(String.format(
"For region %s with data policy PARTITION, memory LRU eviction attribute maximum has been reset from %sMB to local-max-memory %sMB",
new Object[] {this.getName(), attrs.getEvictionAttributes().getMaximum(),
attrs.getPartitionAttributes().getLocalMaxMemory()}));
this.attrs.setEvictionAttributes(attrs.getEvictionAttributes().createLRUMemoryAttributes(
attrs.getPartitionAttributes().getLocalMaxMemory(),
attrs.getEvictionAttributes().getObjectSizer(),
attrs.getEvictionAttributes().getAction()));
}
}
代码示例来源:origin: apache/geode
@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();
}
代码示例来源:origin: apache/geode
@Test
public void userRegionShouldNotBeSetBeforeIndexInitialized() throws Exception {
TestLuceneServiceImpl testService = new TestLuceneServiceImpl();
Field f = LuceneServiceImpl.class.getDeclaredField("cache");
f.setAccessible(true);
f.set(testService, cache);
AsyncEventQueueFactoryImpl aeqFactory = mock(AsyncEventQueueFactoryImpl.class);
when(cache.createAsyncEventQueueFactory()).thenReturn(aeqFactory);
DistributedSystem ds = mock(DistributedSystem.class);
Statistics luceneIndexStats = mock(Statistics.class);
when(cache.getDistributedSystem()).thenReturn(ds);
when(((StatisticsFactory) ds).createAtomicStatistics(any(), anyString()))
.thenReturn(luceneIndexStats);
when(cache.getRegion(anyString())).thenReturn(region);
when(cache.getDistributionManager()).thenReturn(mock(DistributionManager.class));
when(cache.getDistributionManager().getWaitingThreadPool())
.thenReturn(Executors.newSingleThreadExecutor());
RegionAttributes ratts = mock(RegionAttributes.class);
when(region.getAttributes()).thenReturn(ratts);
when(ratts.getDataPolicy()).thenReturn(DataPolicy.PARTITION);
EvictionAttributes evictionAttrs = mock(EvictionAttributes.class);
when(ratts.getEvictionAttributes()).thenReturn(evictionAttrs);
when(evictionAttrs.getAlgorithm()).thenReturn(EvictionAlgorithm.NONE);
Map<String, Analyzer> fieldMap = new HashMap<String, Analyzer>();
fieldMap.put("field1", null);
fieldMap.put("field2", null);
testService.createIndex("index", "region", fieldMap, null, true);
}
代码示例来源:origin: apache/geode
operation = mock(Operation.class);
when(regionAttributes.getEvictionAttributes()).thenReturn(evictionAttributes);
when(regionAttributes.getRegionTimeToLive()).thenReturn(expirationAttributes);
when(regionAttributes.getRegionIdleTimeout()).thenReturn(expirationAttributes);
代码示例来源:origin: apache/geode
@Test
public void beforeDataRegionCreatedShouldHaveSerializer() {
String name = "indexName";
String regionPath = "regionName";
String[] fields = {"field1", "field2"};
String aeqId = LuceneServiceImpl.getUniqueIndexName(name, regionPath);
InternalCache cache = Fakes.cache();
final Region region = Fakes.region(regionPath, cache);
RegionAttributes attributes = region.getAttributes();
DataPolicy policy = attributes.getDataPolicy();
when(policy.withPartitioning()).thenReturn(true);
EvictionAttributes evictionAttributes = mock(EvictionAttributes.class);
when(attributes.getEvictionAttributes()).thenReturn(evictionAttributes);
CopyOnWriteArraySet set = new CopyOnWriteArraySet();
set.add(aeqId);
when(attributes.getAsyncEventQueueIds()).thenReturn(set);
when(evictionAttributes.getAlgorithm()).thenReturn(EvictionAlgorithm.NONE);
LuceneServiceImpl service = mock(LuceneServiceImpl.class);
Analyzer analyzer = mock(Analyzer.class);
LuceneSerializer serializer = mock(LuceneSerializer.class);
InternalRegionArguments internalRegionArgs = mock(InternalRegionArguments.class);
when(internalRegionArgs.addCacheServiceProfile(any())).thenReturn(internalRegionArgs);
LuceneRegionListener listener = new LuceneRegionListener(service, cache, name, "/" + regionPath,
fields, analyzer, null, serializer);
listener.beforeCreate(null, regionPath, attributes, internalRegionArgs);
verify(service).beforeDataRegionCreated(eq(name), eq("/" + regionPath), eq(attributes),
eq(analyzer), any(), eq(aeqId), eq(serializer), any());
}
}
代码示例来源:origin: apache/geode
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.getAttributes()).thenReturn(mockSessionRegionAttributes);
when(mockSessionRegionAttributes.getDataPolicy()).thenReturn(DataPolicy.REPLICATE);
when(mockSessionRegionAttributes.getDiskStoreName()).thenReturn(diskStoreName);
when(mockSessionRegionAttributes.getEvictionAttributes())
.thenReturn(mockSessionEvictionAttributes);
when(mockSessionEvictionAttributes.getAction()).thenReturn(EvictionAction.OVERFLOW_TO_DISK);
when(mockGuestRegionAttributes.getDiskStoreName())
.thenReturn(DiskStoreDetails.DEFAULT_DISK_STORE_NAME);
when(mockGuestRegionAttributes.getEvictionAttributes()).thenReturn(mockGuestEvictionAttributes);
when(mockGuestEvictionAttributes.getAction()).thenReturn(EvictionAction.OVERFLOW_TO_DISK);
代码示例来源:origin: apache/geode
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);
}
}
代码示例来源:origin: apache/geode
public int getSizeForEviction() {
EvictionAttributes ea = this.getAttributes().getEvictionAttributes();
if (ea == null)
return 0;
EvictionAlgorithm algo = ea.getAlgorithm();
if (!algo.isLRUHeap())
return 0;
EvictionAction action = ea.getAction();
int size =
action.isLocalDestroy() ? this.getRegionMap().sizeInVM() : (int) this.getNumEntriesInVM();
return size;
}
代码示例来源:origin: apache/geode
final EvictionAttributes ea = pr.getAttributes().getEvictionAttributes();
代码示例来源:origin: apache/geode
|| !pr.getAttributes().getEvictionAttributes().getAlgorithm().isNone()) {
return ClusterDistributionManager.PARTITIONED_REGION_EXECUTOR;
代码示例来源:origin: apache/geode
public IndexManager(InternalCache cache, Region region) {
this.cache = cache;
this.region = region;
// must be a SortedMap to ensure the indexes are iterated over in fixed
// order
// to avoid deadlocks when acquiring locks
// indexes = Collections.synchronizedSortedMap(new TreeMap());
indexMaintenanceSynchronous = region.getAttributes().getIndexMaintenanceSynchronous();
isOverFlowToDisk =
region.getAttributes().getEvictionAttributes().getAction().isOverflowToDisk();
this.offHeap = region.getAttributes().getOffHeap();
if (!indexMaintenanceSynchronous) {
updater = new IndexUpdaterThread(this.INDEX_MAINTENANCE_BUFFER,
"OqlIndexUpdater:" + region.getFullPath());
updater.start();
}
}
内容来源于网络,如有侵权,请联系作者删除!