Пример #1
0
        private void SetCacheLoader(string regionName, ICacheLoader <string, string> loader)
        {
            GIRegion region = CacheHelper.GetVerifyRegion <string, string>(regionName);
            AttributesMutator <string, string> attrMutator = region.AttributesMutator;

            attrMutator.SetCacheLoader(loader);
        }
Пример #2
0
        public void CreateRegion(string locators,
                                 bool caching, bool listener, bool writer)
        {
            if (listener)
            {
                m_listener = new TallyListener <int, object>();
            }
            else
            {
                m_listener = null;
            }
            GIRegion region = null;

            region = CacheHelper.CreateTCRegion_Pool <int, object>(RegionName, true, caching,
                                                                   m_listener, locators, "__TESTPOOL1_", true);
            if (listener)
            {
                m_listener.SetCallBackArg(key0);
            }

            if (writer)
            {
                m_writer = new TallyWriter <int, object>();
            }
            else
            {
                m_writer = null;
            }
            if (writer)
            {
                AttributesMutator <int, object> at = region.AttributesMutator;
                at.SetCacheWriter(m_writer);
                m_writer.SetCallBackArg(key0);
            }
        }
Пример #3
0
        private void RegisterKeys()
        {
            GIRegion region0 = CacheHelper.GetRegion <string, string>(m_regionNames[0]);
            GIRegion region1 = CacheHelper.GetRegion <string, string>(m_regionNames[1]);
            string   cKey1   = m_keys[1];
            string   cKey2   = m_keys[3];

            region0.GetSubscriptionService().RegisterKeys(new string[] { cKey1 });
            region1.GetSubscriptionService().RegisterKeys(new string[] { cKey2 });
        }
Пример #4
0
        // Note this just returns default(TVal) hence null or empty string, use
        // GetLoadCount() to get the load count int value.
        public override string Load(GIRegion region, string key, object callbackArg)
        {
            base.Load(region, key, callbackArg);
            int loadCount = GetLoadCount();

            if (key != null)
            {
                Util.Log(Util.LogLevel.Debug,
                         "Putting the value ({0}) for local region clients only.",
                         loadCount);
                region[key] = loadCount.ToString();
            }
            return(loadCount.ToString());
        }
Пример #5
0
        public void StepTwoCallbacks()
        {
            var regionAttributesFactory = new RegionAttributesFactory <string, string>();

            GIRegion region = CacheHelper.CreateRegion <string, string>(PeerRegionName,
                                                                        regionAttributesFactory.Create());

            CreateEntry(RegionNames[0], m_keys[1], m_vals[1]);
            CreateEntry(RegionNames[1], m_keys[3], m_vals[3]);

            SetCacheLoader(RegionNames[0], new ThinClientTallyLoader());
            SetCacheLoader(RegionNames[1], new ThinClientTallyLoader());

            Assert.IsNotNull(GetEntry(RegionNames[0], m_keys[0]),
                             "Found null value in region0.");
            Assert.IsNotNull(GetEntry(RegionNames[1], m_keys[0]),
                             "Found null value in region1.");
        }
Пример #6
0
        public void CreateRegion2(string locators,
                                  bool caching, bool listener, bool writer)
        {
            CallbackListener callbackLis = null;

            if (listener)
            {
                m_callbackListener = new CallbackListener();
                m_callbackListener.SetCallbackArg(m_callbackarg);
                callbackLis = m_callbackListener;
            }
            else
            {
                m_listener = null;
            }
            GIRegion region = null;

            region = CacheHelper.CreateTCRegion_Pool <int, object>(RegionName, true, caching,
                                                                   callbackLis, locators, "__TESTPOOL1_", true);
        }
Пример #7
0
        public void StepOneCallbacks()
        {
            m_reg1Listener1 = new TallyListener <string, string>();
            m_reg2Listener1 = new TallyListener <string, string>();
            m_reg1Loader1   = new ThinClientTallyLoader();
            m_reg2Loader1   = new ThinClientTallyLoader();
            m_reg1Writer1   = new TallyWriter <string, string>();
            m_reg2Writer1   = new TallyWriter <string, string>();

            SetCacheListener(RegionNames[0], m_reg1Listener1);
            SetCacheLoader(RegionNames[0], m_reg1Loader1);
            SetCacheWriter(RegionNames[0], m_reg1Writer1);

            SetCacheListener(RegionNames[1], m_reg2Listener1);
            SetCacheLoader(RegionNames[1], m_reg2Loader1);
            SetCacheWriter(RegionNames[1], m_reg2Writer1);

            RegisterKeys();
            m_reg3Listener1 = new TallyListener <string, string>();
            //m_reg3Loader1 = new TallyLoader<string, string>();
            m_reg3Loader1 = new ThinClientTallyLoader();
            m_reg3Writer1 = new TallyWriter <string, string>();
            var regionAttributesFactory = new RegionAttributesFactory <string, string>();

            GIRegion region = CacheHelper.CreateRegion <string, string>(PeerRegionName,
                                                                        regionAttributesFactory.Create());

            SetCacheListener(PeerRegionName, m_reg3Listener1);
            SetCacheLoader(PeerRegionName, m_reg3Loader1);
            SetCacheWriter(PeerRegionName, m_reg3Writer1);

            // Call the loader and writer
            Assert.IsNotNull(GetEntry(RegionNames[0], m_keys[0]),
                             "Found null value.");
            Assert.IsNotNull(GetEntry(RegionNames[1], m_keys[0]),
                             "Found null value.");
            Assert.IsNotNull(GetEntry(PeerRegionName, m_keys[0]),
                             "Found null value.");

            CreateEntry(PeerRegionName, m_keys[1], m_vals[1]);
        }
Пример #8
0
        public void CreateRegion2(string locators,
                                  bool caching, bool listener, bool writer)
        {
            CallbackListener callbackLis = null;

            if (listener)
            {
                m_callbackListener = new CallbackListener();
                m_callbackListener.SetCallbackArg(m_callbackarg);
                callbackLis = m_callbackListener;
            }
            else
            {
                m_listener = null;
            }
            GIRegion region = null;

            region = CacheHelper.CreateTCRegion_Pool <int, object>(RegionName, true, caching,
                                                                   callbackLis, locators, "__TESTPOOL1_", true);
            CacheHelper.DCache.TypeRegistry.RegisterTypeGeneric(Portfolio.CreateDeserializable);
            CacheHelper.DCache.TypeRegistry.RegisterTypeGeneric(Position.CreateDeserializable);
        }