public void testSetCacheLoader() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(REPLICATE_PROXY); CacheLoader cl = new MyCacheLoader(); r1 = factory.setCacheLoader(cl).create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(cl, ra.getCacheLoader()); } finally { cleanUpRegion(r1); } }
.setCacheLoader(new TestCacheLoader()) .create("replicate"); cache.createRegionFactory(RegionShortcut.PARTITION) .setCacheLoader(new TestCacheLoader()) .create("pr"); .setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)) .setDiskStoreName("store") .setCacheLoader(new TestCacheLoader()) .create("overflow_replicate"); cache.createRegionFactory(RegionShortcut.PARTITION_OVERFLOW) .setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)) .setDiskStoreName("store") .setCacheLoader(new TestCacheLoader()) .create("overflow_pr");
public void run2() throws CacheException { getCache(); CacheLoader cl = new TestCacheLoader() { public Object load2(LoaderHelper helper) throws CacheLoaderException { assertNotNull(helper); assertEquals(key1, helper.getKey()); assertEquals(rName, helper.getRegion().getName()); assertEquals(arg, helper.getArgument()); return helper.getArgument(); } }; PartitionedRegion pr = (PartitionedRegion) new RegionFactory() .setCacheLoader(cl) .setPartitionAttributes( new PartitionAttributesFactory() .setRedundantCopies(1) .setLocalMaxMemory(localMaxMemory) .create()) .create(rName); assertSame(cl, pr.getDataStore().getCacheLoader()); } };
if (cacheLoader != null) { Class<CacheLoader<K, V>> cacheLoaderKlass = forName(cacheLoader, CliStrings.CREATE_REGION__CACHELOADER); factory.setCacheLoader(newInstance(cacheLoaderKlass, CliStrings.CREATE_REGION__CACHELOADER));
if (cacheLoader != null) { Class<CacheLoader<K, V>> cacheLoaderKlass = forName(cacheLoader, CliStrings.CREATE_REGION__CACHELOADER); factory.setCacheLoader(newInstance(cacheLoaderKlass, CliStrings.CREATE_REGION__CACHELOADER));