private void ConnectToCloudCache()
        {
            JObject vcapJson = JObject.Parse(Environment.GetEnvironmentVariable("VCAP_SERVICES"));

            Cache cache = new CacheFactory()
                          .SetAuthInitialize(
                new UsernamePassword(
                    (string)vcapJson.SelectToken(Constants.jsonPathUsername),
                    (string)vcapJson.SelectToken(Constants.jsonPathPassword)))
                          .Create();

            cache.TypeRegistry.PdxSerializer = new ReflectionBasedAutoSerializer();

            PoolFactory pool = cache.GetPoolFactory();

            foreach (string locator in vcapJson.SelectToken(Constants.jsonPathLocators).Select(s => (string)s).ToArray())
            {
                string[] hostPort = locator.Split('[', ']');
                pool.AddLocator(hostPort[0], Int32.Parse(hostPort[1]));
            }
            pool.Create("pool");

            region = cache.CreateRegionFactory(RegionShortcut.PROXY)
                     .SetPoolName("pool")
                     .Create <string, Book>("owinexample");
        }
Ejemplo n.º 2
0
        internal PoolFactory ApplyLocators(PoolFactory poolFactory)
        {
            foreach (var locator in locators_)
            {
                poolFactory.AddLocator(locator.Address.address, locator.Address.port);
            }

            return(poolFactory);
        }
Ejemplo n.º 3
0
        public void createPoolAndTestAttrs(string poolName)
        {
            CacheHelper.Init();

            PoolFactory factory = CacheHelper.DCache.GetPoolManager().CreateFactory();

            factory.SetFreeConnectionTimeout(TimeSpan.FromSeconds(10000));
            factory.SetLoadConditioningInterval(TimeSpan.FromSeconds(1));
            factory.SetSocketBufferSize(1024);
            factory.SetReadTimeout(TimeSpan.FromSeconds(10));
            factory.SetMinConnections(2);
            factory.SetMaxConnections(5);
            factory.SetIdleTimeout(TimeSpan.FromSeconds(5));
            factory.SetRetryAttempts(5);
            factory.SetPingInterval(TimeSpan.FromSeconds(1));
            factory.SetUpdateLocatorListInterval(TimeSpan.FromMilliseconds(122000));
            factory.SetStatisticInterval(TimeSpan.FromSeconds(1));
            factory.SetServerGroup("ServerGroup1");
            factory.SetSubscriptionEnabled(true);
            factory.SetSubscriptionRedundancy(1);
            factory.SetSubscriptionMessageTrackingTimeout(TimeSpan.FromSeconds(5));
            factory.SetSubscriptionAckInterval(TimeSpan.FromSeconds(1));
            factory.AddLocator("localhost", CacheHelper.LOCATOR_PORT_1);
            factory.SetPRSingleHopEnabled(false);

            Pool pool = factory.Create(poolName, CacheHelper.DCache);

            Assert.AreEqual(TimeSpan.FromSeconds(10000), pool.FreeConnectionTimeout, "FreeConnectionTimeout");
            Assert.AreEqual(TimeSpan.FromSeconds(1), pool.LoadConditioningInterval, "LoadConditioningInterval");
            Assert.AreEqual(1024, pool.SocketBufferSize, "SocketBufferSize");
            Assert.AreEqual(TimeSpan.FromSeconds(10), pool.ReadTimeout, "ReadTimeout");
            Assert.AreEqual(2, pool.MinConnections, "MinConnections");
            Assert.AreEqual(5, pool.MaxConnections, "MaxConnections");
            Assert.AreEqual(TimeSpan.FromSeconds(5), pool.IdleTimeout, "IdleTimeout");
            Assert.AreEqual(5, pool.RetryAttempts, "RetryAttempts");
            Assert.AreEqual(TimeSpan.FromSeconds(1), pool.PingInterval, "PingInterval");
            Assert.AreEqual(TimeSpan.FromMilliseconds(122000), pool.UpdateLocatorListInterval, "UpdateLocatorListInterval");
            Assert.AreEqual(TimeSpan.FromSeconds(1), pool.StatisticInterval, "StatisticInterval");
            Assert.AreEqual("ServerGroup1", pool.ServerGroup, "ServerGroup");
            Assert.AreEqual(true, pool.SubscriptionEnabled, "SubscriptionEnabled");
            Assert.AreEqual(1, pool.SubscriptionRedundancy, "SubscriptionRedundancy");
            Assert.AreEqual(TimeSpan.FromSeconds(5), pool.SubscriptionMessageTrackingTimeout, "SubscriptionMessageTrackingTimeout");
            Assert.AreEqual(TimeSpan.FromSeconds(1), pool.SubscriptionAckInterval, "SubscriptionAckInterval");
            Assert.AreEqual(false, pool.PRSingleHopEnabled, "PRSingleHopEnabled");
        }
        private void ConnectToCloudCache()
        {
            JObject vcapJson = JObject.Parse(Environment.GetEnvironmentVariable("VCAP_SERVICES"));

            /**
             * JObject vcapJson = new JObject
             * {
             *  { "locators", "192.168.12.52[55221]" },
             *  { "username", "cluster_operator_57Z2ueingjHQrgwIAB389w" },
             *  { "password", "CTl9gZJlIoS0m2BUdWpQ" }
             * };
             **/

            Cache cache = new CacheFactory()
                          .Set("log-level", "debug")
                          .Set("log-file", "pccpad.log")
                          .SetAuthInitialize(
                new UsernamePassword(
                    (string)vcapJson.SelectToken(Constants.jsonPathUsername),
                    (string)vcapJson.SelectToken(Constants.jsonPathPassword)))
                          .Create();

            cache.TypeRegistry.PdxSerializer = new ReflectionBasedAutoSerializer();

            PoolFactory pool = cache.GetPoolFactory();

            foreach (string locator in vcapJson.SelectToken(Constants.jsonPathLocators).Select(s => (string)s).ToArray())
            {
                string[] hostPort = locator.Split('[', ']');
                pool.AddLocator(hostPort[0], Int32.Parse(hostPort[1]));
            }
            globalpool = pool.Create("pool");

            region = cache.CreateRegionFactory(RegionShortcut.PROXY)
                     .SetPoolName("pool")
                     .Create <int, Customer>("customer");
        }