private IRegion <object, object> CreateOverflowRegion(string regionName, string libraryName, string factoryFunctionName) { RegionFactory rf = CacheHelper.DCache.CreateRegionFactory(RegionShortcut.LOCAL); rf.SetCachingEnabled(true); rf.SetLruEntriesLimit(20); rf.SetInitialCapacity(1000); rf.SetDiskPolicy(DiskPolicyType.Overflows); Properties <string, string> sqliteProperties = new Properties <string, string>(); sqliteProperties.Insert("PageSize", "65536"); sqliteProperties.Insert("MaxFileSize", "512000000"); String sqlite_dir = "SqLiteDir" + Process.GetCurrentProcess().Id.ToString(); sqliteProperties.Insert("PersistenceDirectory", sqlite_dir); rf.SetPersistenceManager(libraryName, factoryFunctionName, sqliteProperties); CacheHelper.Init(); IRegion <object, object> region = CacheHelper.GetRegion <object, object>(regionName); if ((region != null) && !region.IsDestroyed) { region.GetLocalView().DestroyRegion(); Assert.IsTrue(region.IsDestroyed, "IRegion<object, object> {0} was not destroyed.", regionName); } region = rf.Create <object, object>(regionName); Assert.IsNotNull(region, "IRegion<object, object> was not created."); return(region); }
public ProductBrowser() { InitializeComponent(); Serializable.RegisterType(Product.CreateInstance); /* * Initialize Cache system properties */ Apache.Geode.Client.Properties prop = Apache.Geode.Client.Properties.Create(); prop.Insert("log-file", logFile); prop.Insert("log-level", logLevel); prop.Insert("name", "ProductCache"); CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(prop); try { /* * Create the GemFire Client cache */ Cache cache = cacheFactory.SetSubscriptionEnabled(true).Create(); /* * Specify required region attributes */ RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY); /* * Create the region and register interest in all keys */ prodRegion = regionFactory .SetCachingEnabled(true) .SetCacheListener(this) .Create("product"); prodRegion.RegisterAllKeys(); } catch (Exception e) { MessageBox.Show("Error during client initialization. " + e.Message); } }
public void OverflowPutGetManagedSetInstance() { RegionFactory rf = CacheHelper.DCache.CreateRegionFactory(RegionShortcut.LOCAL); rf.SetCachingEnabled(true); rf.SetLruEntriesLimit(20); rf.SetInitialCapacity(1000); rf.SetDiskPolicy(DiskPolicyType.Overflows); Properties <string, string> sqliteProperties = new Properties <string, string>(); sqliteProperties.Insert("PageSize", "65536"); sqliteProperties.Insert("MaxFileSize", "512000000"); String sqlite_dir = "SqLiteDir" + Process.GetCurrentProcess().Id.ToString(); sqliteProperties.Insert("PersistenceDirectory", sqlite_dir); //rf.SetPersistenceManager(new Apache.Geode.Plugins.SQLite.SqLiteImpl<object, object>(), sqliteProperties); rf.SetPersistenceManager("SqLiteImpl", "createSqLiteInstance", sqliteProperties); CacheHelper.Init(); IRegion <object, object> region = CacheHelper.GetRegion <object, object>("OverFlowRegion"); if ((region != null) && !region.IsDestroyed) { region.GetLocalView().DestroyRegion(); Assert.IsTrue(region.IsDestroyed, "IRegion<object, object> OverFlowRegion was not destroyed."); } region = rf.Create <object, object>("OverFlowRegion"); Assert.IsNotNull(region, "IRegion<object, object> was not created."); ValidateAttributes(region); //Console.WriteLine("TEST-2"); // put some values into the cache. DoNput(region, 100); //Console.WriteLine("TEST-2.1 All PUts Donee"); CheckNumOfEntries(region, 100); //Console.WriteLine("TEST-3"); // check whether value get evicted and token gets set as overflow CheckOverflowToken(region, 100, 20); // do some gets... printing what we find in the cache. DoNget(region, 100); TestEntryDestroy(region); TestGetOp(region, 100); //Console.WriteLine("TEST-4"); // test to verify same region repeatedly to ensure that the persistece // files are created and destroyed correctly IRegion <object, object> subRegion; for (int i = 0; i < 1; i++) { subRegion = CreateSubRegion(region, "SubRegion", "Apache.Geode.Plugins.SqLite", "SqLiteImpl<object,object>.Create()"); subRegion.DestroyRegion(); Assert.IsTrue(subRegion.IsDestroyed, "Expected region to be destroyed"); Assert.IsFalse(File.Exists(GetSqLiteFileName(sqlite_dir, "SubRegion")), "Persistence file present after region destroy"); } //Console.WriteLine("TEST-5"); }