public CacheWriter setCacheWriter(CacheWriter cacheWriter) { CacheWriter old = this.cacheWriter; this.cacheWriter = cacheWriter; setHasCacheWriter(true); if (cacheWriter instanceof BridgeClient && !hasCacheLoader()) { // fix for bug 36247 setCacheLoader((BridgeClient)cacheWriter); } return old; }
attrs.setCacheLoader((CacheLoader) d); attrs.setCacheLoader((CacheLoader) d);
attrs.setCacheLoader((CacheLoader) d); attrs.setCacheLoader((CacheLoader) d);
/** * Tests a cache loader an interesting combination of declarables */ public void testCacheLoaderWithDeclarables() throws CacheException { CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); CacheLoaderWithDeclarables loader = new CacheLoaderWithDeclarables(); attrs.setCacheLoader(loader); cache.createRegion("root", attrs); testXml(cache); }
/** * Tests that a region created with a named attributes has the correct * attributes. * */ public void testPartitionedRegionInstantiation() throws CacheException { CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); Properties gp = new Properties(); gp.setProperty(PartitionAttributesFactory.GLOBAL_MAX_MEMORY_PROPERTY, "2"); gp.setProperty(PartitionAttributesFactory.GLOBAL_MAX_BUCKETS_PROPERTY, "17"); Properties lp = new Properties(); lp.setProperty(PartitionAttributesFactory.LOCAL_MAX_MEMORY_PROPERTY, "4"); PartitionAttributesFactory paf = new PartitionAttributesFactory(); // paf.setEntryTimeToLive( // new ExpirationAttributes(10, ExpirationAction.DESTROY)).setCacheLoader( paf.setLocalProperties(lp).setGlobalProperties(gp); attrs.setCacheLoader(new DBLoader()); attrs.setPartitionAttributes(paf.create()); cache.createRegion("pRoot", attrs); testXml(cache); } }
/** * Tests a bridge client and special setCacheWriter behavior on * region attributes */ public void testBridgeClientAsLoader() throws CacheException { getSystem(); CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(1); BridgeClient bc = new TestBridgeClient(); Properties props = new Properties(); props.setProperty("endpoints", "server=" + DistributedTestCase.getIPLiteral() + ":" + ports[0]); bc.init(props); attrs.setCacheLoader(bc); cache.createRegion("root", attrs); testXml(cache); final Region ro = cache.getRegion("root"); assertSame(ro.getAttributes().getCacheLoader(), ro.getAttributes().getCacheWriter()); assertTrue(ro.getAttributes().getCacheLoader() instanceof TestBridgeClient); // now that a BridgeLoader creates its own pool make sure it exists assertEquals("pools="+PoolManager.getAll(), 1, PoolManager.getAll().size()); }
/** * Tests a bridge client and special setCacheLoader over-ride behavior on * region attributes */ public void testBridgeClientLoaderOverride() throws CacheException { getSystem(); CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(1); BridgeClient bc = new TestBridgeClient(); Properties props = new Properties(); props.setProperty("endpoints", "server=" + DistributedTestCase.getIPLiteral() + ":" + ports[0]); bc.init(props); attrs.setCacheWriter(bc); attrs.setCacheLoader(new CacheLoaderWithDeclarables()); cache.createRegion("root", attrs); testXml(cache); final Region ro = cache.getRegion("root"); assertTrue(ro.getAttributes().getCacheWriter() instanceof BridgeClient); assertTrue(ro.getAttributes().getCacheLoader() instanceof CacheLoaderWithDeclarables); // now that a BridgeLoader creates its own pool make sure it exists assertEquals("pools="+PoolManager.getAll(), 1, PoolManager.getAll().size()); }
/** * Tests a bridge client and special setCacheWriter over-ride behavior on * region attributes */ public void testBridgeClientWriterOverride() throws CacheException { getSystem(); CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(1); BridgeClient bc = new TestBridgeClient(); Properties props = new Properties(); props.setProperty("endpoints", "server=" + DistributedTestCase.getIPLiteral() + ":" + ports[0]); bc.init(props); attrs.setCacheLoader(bc); attrs.setCacheWriter(new MyTestCacheWriter()); cache.createRegion("root", attrs); testXml(cache); final Region ro = cache.getRegion("root"); assertTrue(ro.getAttributes().getCacheLoader() instanceof BridgeClient); assertTrue(ro.getAttributes().getCacheWriter() instanceof MyTestCacheWriter); // now that a BridgeLoader creates its own pool make sure it exists assertEquals("pools="+PoolManager.getAll(), 1, PoolManager.getAll().size()); }
attr.setEvictionAttributes(regDef.getEvictionAttributes()); if (regDef.getCacheLoader() != null) attr.setCacheLoader((CacheLoader)(TestHelper.createInstance(regDef.getCacheLoader()))); if (regDef.getCacheWriter() != null) attr.setCacheWriter((CacheWriter)(TestHelper.createInstance(regDef.getCacheWriter())));
if (parentIsUserSpecified) { if (parentWithHas.hasCacheLoader()) { setCacheLoader(parent.getCacheLoader()); setCacheLoader(parent.getCacheLoader());
if (parentIsUserSpecified) { if (parentWithHas.hasCacheLoader()) { setCacheLoader(parent.getCacheLoader()); setCacheLoader(parent.getCacheLoader());