/** * When a <code>client-cache</code> element is first encountered, we create a * {@link ClientCacheCreation}and fill it in appropriately */ private void startClientCache(Attributes atts) { if (this.cache != null) { throw new CacheXmlException("Only a single cache or client-cache element is allowed"); } this.cache = new ClientCacheCreation(true); String copyOnRead = atts.getValue(COPY_ON_READ); if (copyOnRead != null) { this.cache.setCopyOnRead(Boolean.valueOf(copyOnRead).booleanValue()); } stack.push(this.cache); } /**
/** * When a <code>client-cache</code> element is first encountered, we create a * {@link ClientCacheCreation}and fill it in appropriately */ private void startClientCache(Attributes atts) { if (this.cache != null) { throw new CacheXmlException("Only a single cache or client-cache element is allowed"); } this.cache = new ClientCacheCreation(true); String copyOnRead = atts.getValue(COPY_ON_READ); if (copyOnRead != null) { this.cache.setCopyOnRead(Boolean.valueOf(copyOnRead).booleanValue()); } stack.push(this.cache); } /**
public void testNoTXWriterOnClient() { //test writer is not created ClientCacheCreation cc = new ClientCacheCreation(); CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation(); txMgrCreation.setWriter(new TestTransactionWriter()); cc.addCacheTransactionManagerCreation(txMgrCreation); try { testXml(cc); fail("expected exception not thrown"); } catch (IllegalStateException e) { } }
/** * Creates a new <code>CacheXmlGenerator</code> that generates XML * for a given <code>ClientCache</code>. */ private CacheXmlGenerator(ClientCache cache, boolean useSchema, String version, boolean includeKeysValues) { this.cache = (Cache)cache; this.useSchema = useSchema; this.version = version; this.includeKeysValues = includeKeysValues; this.generateDefaults = true; if (cache instanceof ClientCacheCreation) { this.creation = (ClientCacheCreation) cache; this.creation.startingGenerate(); } else { this.creation = new ClientCacheCreation(); if (generateDefaults() || cache.getCopyOnRead()) { this.creation.setCopyOnRead(cache.getCopyOnRead()); } } } /**
/** * Creates a new <code>CacheXmlGenerator</code> that generates XML * for a given <code>ClientCache</code>. */ private CacheXmlGenerator(ClientCache cache, boolean useSchema, String version, boolean includeKeysValues) { this.cache = (Cache)cache; this.useSchema = useSchema; this.version = CacheXmlVersion.valueForVersion(version); this.includeKeysValues = includeKeysValues; this.generateDefaults = true; if (cache instanceof ClientCacheCreation) { this.creation = (ClientCacheCreation) cache; this.creation.startingGenerate(); } else { this.creation = new ClientCacheCreation(); if (generateDefaults() || cache.getCopyOnRead()) { this.creation.setCopyOnRead(cache.getCopyOnRead()); } } } /**
/** * Generates a dummy cache from the given client cache description. */ private static ClientCacheCreation generateDummyCache( String cacheConfig, ClientCacheDescription ccd, DynamicRegionFactory.Config dynamicRegionConfig, String fn) { if (dynamicRegionConfig != null) { // must open the DynamicRegionFactory before creating the cache log("Opening the configured DynamicRegionFactory"); DynamicRegionFactory.get().open(dynamicRegionConfig); } // create and configure the dummy cache log("Adding dummy cache from: " + ccd); ClientCacheCreation dummyCache = new ClientCacheCreation(); ResourceManagerCreation dummyResourceManager = new ResourceManagerCreation(); dummyCache.setResourceManagerCreation(dummyResourceManager); ccd.configureDummy(dummyCache); // add the dynamic region factory configuration, if any if (dynamicRegionConfig != null) { dummyCache.setDynamicRegionFactoryConfig(dynamicRegionConfig); } log("Added dummy cache: " + ccd.cacheToString(dummyCache)); // save the cache config for future reference XmlCacheConfigs.put(fn, cacheConfig); return dummyCache; }
public void testClientCache() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); cache.setCopyOnRead(true); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.getCopyOnRead()); assertEquals(true, c.isClient()); for (ClientRegionShortcut pra: ClientRegionShortcut.values()) { assertNotNull(c.getRegionAttributes(pra.name())); } assertEquals(ClientRegionShortcut.values().length, c.listRegionAttributes().size()); } public void testNormalCache() throws CacheException {
public void testTXManagerOnClientCache() { ClientCacheCreation cc = new ClientCacheCreation(); //CacheCreation cc = new CacheCreation(); CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation(); txMgrCreation.addListener(new TestTXListener()); cc.addCacheTransactionManagerCreation(txMgrCreation); testXml(cc); Cache c = getCache(); assertTrue(c instanceof ClientCache); c.loadCacheXml(generate(cc)); ClientCache clientC = (ClientCache) c; CacheTransactionManager mgr = clientC.getCacheTransactionManager(); assertNotNull(mgr); assertTrue(mgr.getListeners()[0] instanceof TestTXListener); }
public void testCACHING_PROXY() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("cproxy", "CACHING_PROXY"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("cproxy"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals("DEFAULT", ra.getPoolName()); } public void testCACHING_PROXY_HEAP_LRU() throws CacheException {
public void testPROXY() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("proxy", "PROXY"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("proxy"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.EMPTY, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals("DEFAULT", ra.getPoolName()); } public void testCACHING_PROXY() throws CacheException {
public void testClientLOCAL_PERSISTENT() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("cplocal", "LOCAL_PERSISTENT"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("cplocal"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(null, ra.getPoolName()); } public void testClientLOCAL_PERSISTENT_OVERFLOW() throws CacheException {
public void testClientLOCAL() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("local", "LOCAL"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("local"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(null, ra.getPoolName()); } public void testClientLOCAL_HEAP_LRU() throws CacheException {
public void testClientLOCAL_PERSISTENT_OVERFLOW() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("cpolocal", "LOCAL_PERSISTENT_OVERFLOW"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("cpolocal"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(null, ra.getPoolName()); assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); }
public void testCACHING_PROXY_HEAP_LRU() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("cproxylru", "CACHING_PROXY_HEAP_LRU"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("cproxylru"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals("DEFAULT", ra.getPoolName()); assertEquals(EvictionAttributes.createLRUHeapAttributes(), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testCACHING_PROXY_OVERFLOW() throws CacheException {
public void testClientLOCAL_HEAP_LRU() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("locallru", "LOCAL_HEAP_LRU"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("locallru"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(null, ra.getPoolName()); assertEquals(EvictionAttributes.createLRUHeapAttributes(), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testClientLOCAL_OVERFLOW() throws CacheException {
public void testCACHING_PROXY_OVERFLOW() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("cproxyoverflow", "CACHING_PROXY_OVERFLOW"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("cproxyoverflow"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals("DEFAULT", ra.getPoolName()); assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testClientLOCAL() throws CacheException {
public void testClientLOCAL_OVERFLOW() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("localoverflow", "LOCAL_OVERFLOW"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("localoverflow"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(null, ra.getPoolName()); assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testClientLOCAL_PERSISTENT() throws CacheException {
this.creation = new ClientCacheCreation(); if (generateDefaults() || cache.getCopyOnRead()) { this.creation.setCopyOnRead(cache.getCopyOnRead());
this.creation = new ClientCacheCreation(); if (generateDefaults() || cache.getCopyOnRead()) { this.creation.setCopyOnRead(cache.getCopyOnRead());