/** * Sets the cache writer for the next <code>RegionAttributes</code> created. * * @param cacheWriter * the cache writer or null if no cache writer * @return a reference to this RegionFactory object * @see AttributesFactory#setCacheWriter */ public RegionFactory<K,V> setCacheWriter(CacheWriter<K,V> cacheWriter) { this.attrsFactory.setCacheWriter(cacheWriter); return this; }
/** * Sets the cache writer for the next <code>RegionAttributes</code> created. * * @param cacheWriter * the cache writer or null if no cache writer * @return a reference to this RegionFactory object * @see AttributesFactory#setCacheWriter */ public RegionFactory<K,V> setCacheWriter(CacheWriter<K,V> cacheWriter) { this.attrsFactory.setCacheWriter(cacheWriter); return this; }
public void run2() throws CacheException { Properties config = new Properties(); config.setProperty("mcast-port", "0"); system = (InternalDistributedSystem) DistributedSystem.connect(config); getCache(); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); BridgeClient writer = new BridgeClient(); Properties props = new Properties(); props.setProperty("endpoints", "server=" + host0 + ":" + port); props.setProperty("establishCallbackConnection", "true"); writer.init(props); factory.setCacheWriter(writer); createRegion(name, factory.create()); } });
public void run2() throws CacheException { Properties config = new Properties(); config.setProperty("mcast-port", "0"); system = (InternalDistributedSystem) DistributedSystem.connect(config); getCache(); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); BridgeClient writer = new BridgeClient(); Properties props = new Properties(); props.setProperty("endpoints", "server=" + host0 + ":" + port); props.setProperty("establishCallbackConnection", "true"); writer.init(props); factory.setCacheWriter(writer); createRegion(name, factory.createRegionAttributes()); } });
public void run2() throws CacheException { Properties config = new Properties(); config.setProperty("mcast-port", "0"); system = (InternalDistributedSystem) DistributedSystem.connect(config); getCache(); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); BridgeClient writer = new BridgeClient(); Properties props = new Properties(); props.setProperty("endpoints", "server=" + host0 + ":" + port); props.setProperty("establishCallbackConnection", "true"); writer.init(props); factory.setCacheWriter(writer); createRegion(name, factory.createRegionAttributes()); } });
public void run2() throws CacheException { AttributesFactory fac = new AttributesFactory(); if (index % 2 == 0) { fac.setCacheWriter(new CacheWriterAdapter()); } createRegion(rgnName, fac.create()); } });
public AttributesFactory getBridgeServerRegionAttributes(CacheLoader cl, CacheWriter cw) { AttributesFactory ret = new AttributesFactory(); if (cl != null) { ret.setCacheLoader(cl); } if (cw != null) { ret.setCacheWriter(cw); } ret.setScope(Scope.DISTRIBUTED_ACK); ret.setConcurrencyChecksEnabled(false); return ret; }
public void run2() throws CacheException{ CacheWriter cw = new CacheWriterCallBack(); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.GLOBAL); factory.setCacheWriter(cw); region = cache.createRegion("map", factory.create()); } };
public AttributesFactory getBridgeServerMirroredRegionAttributes(CacheLoader cl, CacheWriter cw) { AttributesFactory ret = new AttributesFactory(); if (cl != null) { ret.setCacheLoader(cl); } if (cw != null) { ret.setCacheWriter(cw); } ret.setScope(Scope.DISTRIBUTED_NO_ACK); ret.setDataPolicy(DataPolicy.REPLICATE); ret.setConcurrencyChecksEnabled(false); return ret; }
public AttributesFactory getBridgeServerMirroredAckRegionAttributes(CacheLoader cl, CacheWriter cw) { AttributesFactory ret = new AttributesFactory(); if (cl != null) { ret.setCacheLoader(cl); } if (cw != null) { ret.setCacheWriter(cw); } ret.setScope(Scope.DISTRIBUTED_ACK); ret.setConcurrencyChecksEnabled(false); ret.setMirrorType(MirrorType.KEYS_VALUES); return ret; }
public static void createRegionToTestRemove(){ try{ AttributesFactory factory2 = new AttributesFactory(); factory2.setScope(Scope.DISTRIBUTED_ACK); CacheWriter cacheWriter = new RemoveCacheWriter(); CacheListener cacheListener = new RemoveCacheListener(); factory2.setCacheWriter(cacheWriter); factory2.setCacheListener(cacheListener); RegionAttributes attr2 = factory2.create(); remRegion = cache.createRegion("remove", attr2); } catch (Exception ex){ ex.printStackTrace(); } }
public void run2() throws CacheException{ cache.setLockTimeout(5); CacheWriter cacheWriter = new CacheWriterCallBack(); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.GLOBAL); factory.setCacheWriter(cacheWriter); region = cache.createRegion("map", factory.create()); } };
/** * Tests that a <code>CacheWriter</code> is <I>not</I> invoked on a * {@linkplain Region#localDestroyRegion local destroy}. */ public void testCacheWriterLocalDestroy() throws CacheException { final String name = this.getUniqueName(); // If any of the writer's callback methods are invoked TestCacheWriter writer = new TestCacheWriter() { }; AttributesFactory factory = new AttributesFactory(getRegionAttributes()); factory.setCacheWriter(writer); RegionAttributes attrs = factory.create(); Region region = createRegion(name, attrs); region.localDestroyRegion(); }
public static void createCacheForVM1(){ try{ CacheWriter aWriter = new BeforeCreateCallback(); ds = (new PutAllGlobalDUnitTest("temp")).getSystem(props); cache = CacheFactory.create(ds); cache.setLockTimeout(TIMEOUT_PERIOD/1000); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.GLOBAL); factory.setCacheWriter(aWriter); RegionAttributes attr = factory.create(); region = cache.createRegion("map", attr); } catch (Exception ex){ ex.printStackTrace(); } } public static void closeCache(){
public static synchronized void createCache(){ try{ CacheListener aListener = new AfterCreateCallback(); CacheWriter aWriter = new BeforeCreateCallback(); ds = (new PutAllCallBkSingleVMDUnitTest("temp")).getSystem(props); cache = CacheFactory.create(ds); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setCacheWriter(aWriter); factory.setCacheListener(aListener); RegionAttributes attr = factory.create(); region = cache.createRegion("map", attr); } catch (Exception ex){ ex.printStackTrace(); } }
public static void createCacheForVM1() throws Exception { CacheWriter aWriter = new BeforeCreateCallback(); ds = (new PutAllDAckDUnitTest("temp")).getSystem(props); cache = CacheFactory.create(ds); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setCacheWriter(aWriter); RegionAttributes attr = factory.create(); region = cache.createRegion("map", attr); } public static void closeCache() throws Exception {
public static void createRegion(CacheLoader cacheLoader, CacheWriter cacheWriter, Integer localMaxMemory) { try { new PartitionedRegionLoaderWriterDUnitTest("DUnitTests") .createCache(new Properties()); AttributesFactory factory = new AttributesFactory(); factory.setCacheLoader(cacheLoader); factory.setCacheWriter(cacheWriter); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setLocalMaxMemory(localMaxMemory.intValue()); factory.setDataPolicy(DataPolicy.PARTITION); factory.setPartitionAttributes(paf.create()); RegionAttributes attrs = factory.create(); cache.createRegion(PartitionedRegionName, attrs); } catch (Exception e) { fail("Not Expected : " , e); } }
@SuppressWarnings({ "unchecked", "deprecation", "rawtypes" }) void createRegion(String name, boolean accessor, int redundantCopies, CacheWriter<?, ?> cw) { AttributesFactory af = new AttributesFactory(); af.setPartitionAttributes(new PartitionAttributesFactory() .setLocalMaxMemory(accessor ? 0 : 12) .setRedundantCopies(redundantCopies).create()); af.setCacheWriter(cw); getCache().createRegion(name, af.create()); }
public static final Region createRegion(String name, String rootName, RegionAttributes attrs) throws CacheException { Region root = cache.getRegion(rootName); if (root == null) { // don't put listeners on root region RegionAttributes rootAttrs = attrs; AttributesFactory fac = new AttributesFactory(attrs); ExpirationAttributes expiration = ExpirationAttributes.DEFAULT; // fac.setCacheListener(null); fac.setCacheLoader(null); fac.setCacheWriter(null); fac.setPartitionAttributes(null); fac.setRegionTimeToLive(expiration); fac.setEntryTimeToLive(expiration); fac.setRegionIdleTimeout(expiration); fac.setEntryIdleTimeout(expiration); rootAttrs = fac.create(); root = cache.createRegion(rootName, rootAttrs); } return LocalRegionHelper.createSubregion(root, name, attrs, null); }
public Object call() { Cache cache = getCache(); PoolFactory factory = PoolManager.createFactory(); factory.addServer(getServerHostName(host), serverPort); factory.create("pool1"); AttributesFactory af = new AttributesFactory(); af.setDataPolicy(DataPolicy.DEFAULT); af.setScope(Scope.LOCAL); af.setPoolName("pool1"); af.setCacheWriter(new MyCacheWriter()); RegionAttributes attrs = af.create(); cache.createRegion(regionName, attrs); return null; } });