use of org.apache.geode.cache.EvictionAttributes in project geode by apache.
the class CqQueryUsingPoolDUnitTest method createServer.
public void createServer(VM server, final int thePort, final boolean eviction, final MirrorType mirrorType) {
SerializableRunnable createServer = new CacheSerializableRunnable("Create Cache Server") {
@Override
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Create Cache Server. ###");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setMirrorType(mirrorType);
// setting the eviction attributes.
if (eviction) {
EvictionAttributes evictAttrs = EvictionAttributes.createLRUEntryAttributes(100000, EvictionAction.OVERFLOW_TO_DISK);
factory.setEvictionAttributes(evictAttrs);
}
for (int i = 0; i < regions.length; i++) {
createRegion(regions[i], factory.createRegionAttributes());
}
try {
startBridgeServer(thePort, true);
} catch (Exception ex) {
Assert.fail("While starting CacheServer", ex);
}
}
};
server.invoke(createServer);
}
use of org.apache.geode.cache.EvictionAttributes in project geode by apache.
the class CqQueryDUnitTest method createServer.
public void createServer(VM server, final int thePort, final boolean eviction, final MirrorType mirrorType) {
SerializableRunnable createServer = new CacheSerializableRunnable("Create Cache Server") {
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Create Cache Server. ###");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setMirrorType(mirrorType);
// setting the eviction attributes.
if (eviction) {
EvictionAttributes evictAttrs = EvictionAttributes.createLRUEntryAttributes(100000, EvictionAction.OVERFLOW_TO_DISK);
factory.setEvictionAttributes(evictAttrs);
}
for (int i = 0; i < regions.length; i++) {
createRegion(regions[i], factory.createRegionAttributes());
}
Wait.pause(2000);
try {
startBridgeServer(thePort, true);
} catch (Exception ex) {
Assert.fail("While starting CacheServer", ex);
}
Wait.pause(2000);
}
};
server.invoke(createServer);
}
use of org.apache.geode.cache.EvictionAttributes in project geode by apache.
the class LuceneRegionListener method beforeCreate.
@Override
public RegionAttributes beforeCreate(Region parent, String regionName, RegionAttributes attrs, InternalRegionArguments internalRegionArgs) {
RegionAttributes updatedRA = attrs;
String path = parent == null ? "/" + regionName : parent.getFullPath() + "/" + regionName;
if (path.equals(this.regionPath)) {
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");
}
String aeqId = LuceneServiceImpl.getUniqueIndexName(this.indexName, this.regionPath);
if (!attrs.getAsyncEventQueueIds().contains(aeqId)) {
AttributesFactory af = new AttributesFactory(attrs);
af.addAsyncEventQueueId(aeqId);
updatedRA = af.create();
}
// Add index creation profile
internalRegionArgs.addCacheServiceProfile(new LuceneIndexCreationProfile(this.indexName, this.regionPath, this.fields, this.analyzer, this.fieldAnalyzers));
luceneIndex = this.service.beforeDataRegionCreated(this.indexName, this.regionPath, attrs, this.analyzer, this.fieldAnalyzers, aeqId, this.fields);
// Add internal async event id
internalRegionArgs.addInternalAsyncEventQueueId(aeqId);
}
return updatedRA;
}
use of org.apache.geode.cache.EvictionAttributes in project geode by apache.
the class CacheClientNotifierDUnitTest method checkCacheServer.
private void checkCacheServer(VM vm, final int serverPort, final boolean withCSC, final int capacity) {
SerializableRunnable checkCacheServer = new SerializableRunnable() {
@Override
public void run() throws Exception {
List<CacheServer> cacheServers = ((GemFireCacheImpl) cache).getCacheServersAndGatewayReceiver();
CacheServerImpl server = null;
for (CacheServer cs : cacheServers) {
if (cs.getPort() == serverPort) {
server = (CacheServerImpl) cs;
break;
}
}
assertNotNull(server);
CacheClientNotifier ccn = server.getAcceptor().getCacheClientNotifier();
HAContainerRegion haContainer = (HAContainerRegion) ccn.getHaContainer();
if (server.getAcceptor().isGatewayReceiver()) {
assertNull(haContainer);
return;
}
Region internalRegion = haContainer.getMapForTest();
RegionAttributes ra = internalRegion.getAttributes();
EvictionAttributes ea = ra.getEvictionAttributes();
if (withCSC) {
assertNotNull(ea);
assertEquals(capacity, ea.getMaximum());
assertEquals(EvictionAction.OVERFLOW_TO_DISK, ea.getAction());
} else {
assertNull(ea);
}
}
};
vm.invoke(checkCacheServer);
}
use of org.apache.geode.cache.EvictionAttributes in project geode by apache.
the class CqDataDUnitTest method testCQWithEviction.
/**
* Test for CQ when entries are evicted from region.
*
* @throws Exception
*/
@Test
public void testCQWithEviction() throws Exception {
final Host host = Host.getHost(0);
VM server1 = host.getVM(0);
VM client = host.getVM(2);
final int evictionThreshold = 1;
server1.invoke(new CacheSerializableRunnable("Create Cache Server") {
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Create Cache Server. ###");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
// factory.setMirrorType(MirrorType.NONE);
// setting the eviction attributes.
EvictionAttributes evictAttrs = EvictionAttributes.createLRUEntryAttributes(evictionThreshold, EvictionAction.OVERFLOW_TO_DISK);
factory.setEvictionAttributes(evictAttrs);
for (int i = 0; i < cqDUnitTest.regions.length; i++) {
Region region = createRegion(cqDUnitTest.regions[i], factory.createRegionAttributes());
// Set CacheListener.
region.getAttributesMutator().setCacheListener(new CertifiableTestCacheListener(LogWriterUtils.getLogWriter()));
}
Wait.pause(2000);
try {
cqDUnitTest.startBridgeServer(0, true);
} catch (Exception ex) {
Assert.fail("While starting CacheServer", ex);
}
Wait.pause(2000);
}
});
final int port1 = server1.invoke(() -> CqQueryDUnitTest.getCacheServerPort());
final String host0 = NetworkUtils.getServerHostName(server1.getHost());
cqDUnitTest.createClient(client, port1, host0);
// Create CQs.
cqDUnitTest.createCQ(client, "testCQWithEviction_0", cqDUnitTest.cqs[0]);
final int size = 10;
// CREATE VALUES.
cqDUnitTest.createValues(server1, cqDUnitTest.regions[0], size);
cqDUnitTest.executeCQ(client, "testCQWithEviction_0", false, "CqException");
Wait.pause(1 * 1000);
// Update VALUES.
cqDUnitTest.createValues(server1, cqDUnitTest.regions[0], size);
for (int i = 1; i <= size; i++) {
cqDUnitTest.waitForUpdated(client, "testCQWithEviction_0", cqDUnitTest.KEY + i);
}
cqDUnitTest.validateCQ(client, "testCQWithEviction_0", cqDUnitTest.noTest, 0, 10, 0);
// Close.
cqDUnitTest.closeClient(client);
cqDUnitTest.closeServer(server1);
}
Aggregations