static void TestDistributedSystem(Cache cache, String hostname, int port, String poolName, String regionName) { //create pool factory to create the pool. PoolFactory fact = PoolManager.CreateFactory(); //adding host(endpoint) in pool fact.AddServer(hostname, port); //enabling subscription on pool fact.SetSubscriptionEnabled(true); //creating pool with name "examplePool" fact.Create(poolName); RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY); IRegion <string, string> region = regionFactory.SetPoolName(poolName).Create <string, string>(regionName); Console.WriteLine("Created a generic Region."); // Put an Entry (Key and Value pair) into the Region using the IDictionary interface. region["Key1"] = "Value1"; Console.WriteLine("Put the first Entry into the Region"); // Put another Entry into the Region. region["123"] = "123"; Console.WriteLine("Put the second Entry into the Region"); // Get Entries back out of the Region. string result1 = region["Key1"]; Console.WriteLine("Obtained the first Entry from the Region"); string result2 = region["123"]; Console.WriteLine("Obtained the second Entry from the Region"); // Invalidate an Entry in the Region. region.Invalidate("Key1"); Console.WriteLine("Invalidated the first Entry in the Region"); // Destroy an Entry in the Region using the IDictionary interface. region.Remove("123"); Console.WriteLine("Destroyed the second Entry in the Region"); }
public void createPoolAndTestAttrs(string poolName) { CacheHelper.Init(); PoolFactory factory = PoolManager.CreateFactory(); factory.SetFreeConnectionTimeout(10000); factory.SetLoadConditioningInterval(1); factory.SetSocketBufferSize(1024); factory.SetReadTimeout(10); factory.SetMinConnections(2); factory.SetMaxConnections(5); factory.SetIdleTimeout(5); factory.SetRetryAttempts(5); factory.SetPingInterval(1); factory.SetUpdateLocatorListInterval(122000); factory.SetStatisticInterval(1); factory.SetServerGroup("ServerGroup1"); factory.SetSubscriptionEnabled(true); factory.SetSubscriptionRedundancy(1); factory.SetSubscriptionMessageTrackingTimeout(5); factory.SetSubscriptionAckInterval(1); factory.AddLocator("localhost", CacheHelper.LOCATOR_PORT_1); factory.SetPRSingleHopEnabled(false); Pool pool = factory.Create(poolName); Assert.AreEqual(10000, pool.FreeConnectionTimeout, "FreeConnectionTimeout"); Assert.AreEqual(1, pool.LoadConditioningInterval, "LoadConditioningInterval"); Assert.AreEqual(1024, pool.SocketBufferSize, "SocketBufferSize"); Assert.AreEqual(10, pool.ReadTimeout, "ReadTimeout"); Assert.AreEqual(2, pool.MinConnections, "MinConnections"); Assert.AreEqual(5, pool.MaxConnections, "MaxConnections"); Assert.AreEqual(5, pool.IdleTimeout, "IdleTimeout"); Assert.AreEqual(5, pool.RetryAttempts, "RetryAttempts"); Assert.AreEqual(1, pool.PingInterval, "PingInterval"); Assert.AreEqual(122000, pool.UpdateLocatorListInterval, "UpdateLocatorListInterval"); Assert.AreEqual(1, pool.StatisticInterval, "StatisticInterval"); Assert.AreEqual("ServerGroup1", pool.ServerGroup, "ServerGroup"); Assert.AreEqual(true, pool.SubscriptionEnabled, "SubscriptionEnabled"); Assert.AreEqual(1, pool.SubscriptionRedundancy, "SubscriptionRedundancy"); Assert.AreEqual(5, pool.SubscriptionMessageTrackingTimeout, "SubscriptionMessageTrackingTimeout"); Assert.AreEqual(1, pool.SubscriptionAckInterval, "SubscriptionAckInterval"); Assert.AreEqual(false, pool.PRSingleHopEnabled, "PRSingleHopEnabled"); }
public void testExistingPool(string poolName) { PoolFactory factory = PoolManager.CreateFactory(); try { factory.Create(poolName); Assert.Fail("Did not get expected IllegalStateException"); } catch (IllegalStateException /*excp*/) { Util.Log("Got expected IllegalStateException"); } catch (Exception excp) { Assert.Fail("Got unexpected {0}: {1}", excp.GetType().Name, excp.Message); } }
static void Main(string[] args) { try { // Create CacheFactory using the settings from the gfcpp.properties file by default. CacheFactory cacheFactory = CacheFactory.CreateCacheFactory(); Console.WriteLine("Created CacheFactory"); // Create a Geode Cache. Cache cache = cacheFactory.SetSubscriptionEnabled(true).Create(); Console.WriteLine("Created the Geode Cache"); //Create Poolfactory with endpoint and then create pool using poolfactory. PoolFactory pfact = PoolManager.CreateFactory(); Pool pptr = pfact.AddServer("localhost", 40404).Create("examplePool"); RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY); Console.WriteLine("Created the Regionfactory"); // Create the example Region programmatically. IRegion <string, string> region = regionFactory.SetPoolName("examplePool").Create <string, string>("exampleRegion"); Console.WriteLine("Created the Region Programmatically"); // Put an Entry (Key and Value pair) into the Region using the direct/shortcut method. region["Key1"] = "Value1"; Console.WriteLine("Put the first Entry into the Region"); // Put an Entry into the Region by manually creating a Key and a Value pair. string key = "key-123"; string value = "val-123"; region[key] = value; Console.WriteLine("Put the second Entry into the Region"); // Get Entries back out of the Region. string result1 = region["Key1"]; Console.WriteLine("Obtained the first Entry from the Region"); string result2 = region[key]; Console.WriteLine("Obtained the second Entry from the Region"); // Invalidate an Entry in the Region. region.Invalidate("Key1"); Console.WriteLine("Invalidated the first Entry in the Region"); // Destroy an Entry in the Region. region.Remove(key); Console.WriteLine("Destroyed the second Entry in the Region"); // Close the Geode Cache. cache.Close(); Console.WriteLine("Closed the Geode Cache"); } // An exception should not occur catch (GeodeException gfex) { Console.WriteLine("PoolWithEndpoints Geode Exception: {0}", gfex.Message); } }