use of org.apache.geode.internal.cache.GemFireCacheImpl in project geode by apache.
the class ClientCacheFactoryJUnitTest method test000Defaults.
@Test
public void test000Defaults() throws Exception {
this.cc = new ClientCacheFactory().create();
GemFireCacheImpl gfc = (GemFireCacheImpl) this.cc;
assertEquals(true, gfc.isClient());
Properties dsProps = this.cc.getDistributedSystem().getProperties();
assertEquals("0", dsProps.getProperty(MCAST_PORT));
assertEquals("", dsProps.getProperty(LOCATORS));
Pool defPool = gfc.getDefaultPool();
assertEquals("DEFAULT", defPool.getName());
assertEquals(new ArrayList(), defPool.getLocators());
assertEquals(Collections.singletonList(new InetSocketAddress(InetAddress.getLocalHost(), CacheServer.DEFAULT_PORT)), defPool.getServers());
ClientCache cc2 = new ClientCacheFactory().create();
if (cc2 != this.cc) {
fail("expected cc2 and cc to be == " + cc2 + this.cc);
}
try {
new ClientCacheFactory().set(LOG_LEVEL, "severe").create();
fail("expected create to fail");
} catch (IllegalStateException expected) {
}
try {
new ClientCacheFactory().addPoolLocator("127.0.0.1", 36666).create();
fail("expected create to fail");
} catch (IllegalStateException expected) {
}
}
use of org.apache.geode.internal.cache.GemFireCacheImpl in project geode by apache.
the class DeltaSessionManager method initializeSessionCache.
protected void initializeSessionCache() {
// Retrieve the cache
GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance();
if (cache == null) {
throw new IllegalStateException("No cache exists. Please configure either a PeerToPeerCacheLifecycleListener or ClientServerCacheLifecycleListener in the server.xml file.");
}
// Create the appropriate session cache
this.sessionCache = cache.isClient() ? new ClientServerSessionCache(this, cache) : new PeerToPeerSessionCache(this, cache);
// Initialize the session cache
this.sessionCache.initialize();
}
use of org.apache.geode.internal.cache.GemFireCacheImpl in project geode by apache.
the class CreateRegionFunction method createRegionConfigurationMetadataRegion.
private Region<String, RegionConfiguration> createRegionConfigurationMetadataRegion() {
// a sessionFactory in hibernate could have been re-started
// so, it is possible that this region exists already
Region<String, RegionConfiguration> r = this.cache.getRegion(REGION_CONFIGURATION_METADATA_REGION);
if (r != null) {
return r;
}
GemFireCacheImpl gemFireCache = (GemFireCacheImpl) cache;
InternalRegionArguments ira = new InternalRegionArguments().setInternalRegion(true);
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.LOCAL);
af.addCacheListener(new RegionConfigurationCacheListener());
RegionAttributes ra = af.create();
try {
return gemFireCache.createVMRegion(REGION_CONFIGURATION_METADATA_REGION, ra, ira);
} catch (IOException | ClassNotFoundException e) {
InternalGemFireError assErr = new InternalGemFireError(LocalizedStrings.GemFireCache_UNEXPECTED_EXCEPTION.toLocalizedString());
assErr.initCause(e);
throw assErr;
}
}
use of org.apache.geode.internal.cache.GemFireCacheImpl in project geode by apache.
the class AsyncEventQueueFactoryImpl method create.
public AsyncEventQueue create(String asyncQueueId, AsyncEventListener listener) {
if (listener == null) {
throw new IllegalArgumentException(LocalizedStrings.AsyncEventQueue_ASYNC_EVENT_LISTENER_CANNOT_BE_NULL.toLocalizedString());
}
AsyncEventQueue asyncEventQueue = null;
if (this.cache instanceof GemFireCacheImpl) {
if (logger.isDebugEnabled()) {
logger.debug("Creating GatewaySender that underlies the AsyncEventQueue");
}
addAsyncEventListener(listener);
GatewaySender sender = create(AsyncEventQueueImpl.getSenderIdFromAsyncEventQueueId(asyncQueueId));
AsyncEventQueueImpl queue = new AsyncEventQueueImpl(sender, listener);
asyncEventQueue = queue;
this.cache.addAsyncEventQueue(queue);
} else if (this.cache instanceof CacheCreation) {
asyncEventQueue = new AsyncEventQueueCreation(asyncQueueId, attrs, listener);
((CacheCreation) cache).addAsyncEventQueue(asyncEventQueue);
}
if (logger.isDebugEnabled()) {
logger.debug("Returning AsyncEventQueue" + asyncEventQueue);
}
return asyncEventQueue;
}
use of org.apache.geode.internal.cache.GemFireCacheImpl in project geode by apache.
the class CacheXml66DUnitTest method testLOCAL_PERSISTENT_OVERFLOW.
@Test
public void testLOCAL_PERSISTENT_OVERFLOW() throws Exception {
CacheCreation cache = new CacheCreation();
RegionCreation root = (RegionCreation) cache.createRegion("cpolocal", "LOCAL_PERSISTENT_OVERFLOW");
testXml(cache);
GemFireCacheImpl c = (GemFireCacheImpl) getCache();
Region r = c.getRegion("cpolocal");
assertNotNull(r);
RegionAttributes ra = r.getAttributes();
assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy());
assertEquals(Scope.LOCAL, ra.getScope());
assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes());
assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage(), 0);
}
Aggregations