示例#1
0
 public PileCacheUserStore(IPileImplementation pile)
 {
     m_Pile  = pile;
     m_Cache = new LocalCache(m_Pile, null, null);
     m_Cache.Configure(null);
     m_Cache.Start();
 }
示例#2
0
 public Cache()
 {
     cache.Pile = new DefaultPile(cache);
     ConfigAttribute.Apply(this, App.ConfigRoot);
     cache.Configure(App.ConfigRoot);
     cache.Start();
 }
示例#3
0
        private static LocalCache makeCache()
        {
            var cache = new LocalCache();

            cache.Pile = new DefaultPile(cache);
            cache.Configure(null);
            cache.Start();
            return(cache);
        }
示例#4
0
文件: CacheTest.cs 项目: mjaric/nfx
        private LocalCache makeCache(IConfigSectionNode conf = null)
        {
            var cache = new LocalCache();

            cache.Pile = new DefaultPile(cache);
            cache.Configure(conf);
            cache.Start();
            return(cache);
        }
示例#5
0
        public static LocalCache MakeCache(IConfigSectionNode conf = null)
        {
            var cache = new LocalCache(NOPApplication.Instance);

            cache.Pile = new DefaultPile(cache);
            cache.Configure(conf);
            cache.Start();
            return(cache);
        }
示例#6
0
        protected override void DoStart()
        {
            if (m_TargetName.IsNullOrWhiteSpace())
            {
                throw new MDBException(StringConsts.MDB_STORE_CONFIG_NO_TARGET_NAME_ERROR);
            }

            if (m_Areas.Count == 0)
            {
                throw new MDBException(StringConsts.MDB_STORE_CONFIG_NO_AREAS_ERROR);
            }


            try
            {
                GDIDAuthorityService.CheckNameValidity(m_SchemaName);
                GDIDAuthorityService.CheckNameValidity(m_BankName);

                var gdidScope = GetGDIDScopePrefix(m_SchemaName, m_BankName);
                m_GDIDGenerator = new GDIDGenerator("GDIDGen({0})".Args(gdidScope), this, gdidScope, null);
                if (AgniSystem.IsMetabase)
                {
                    foreach (var ah in AgniSystem.Metabase.GDIDAuthorities)
                    {
                        m_GDIDGenerator.AuthorityHosts.Register(ah);
                        App.Log.Write(new NFX.Log.Message
                        {
                            Type  = NFX.Log.MessageType.InfoD,
                            Topic = SysConsts.LOG_TOPIC_MDB,
                            From  = GetType().FullName + ".makeGDIDGen()",
                            Text  = "Registered GDID authority host: " + ah.ToString()
                        });
                    }
                }
            }
            catch (Exception error)
            {
                throw new MDBException(StringConsts.MDB_STORE_CONFIG_GDID_ERROR + error.ToMessageWithType());
            }

            try
            {
                m_Cache      = new LocalCache("MDBDataStore::" + Name, this);
                m_Cache.Pile = new DefaultPile(m_Cache, "MDBDataStore::Pile::" + Name);
                m_Cache.Configure(null);
                m_Cache.Start();
            }
            catch
            {
                try { DisposableObject.DisposeAndNull(ref m_GDIDGenerator); } catch {}
                try { DisposableObject.DisposeAndNull(ref m_Cache); } catch {}
                throw;
            }
        }
示例#7
0
文件: CacheTest.cs 项目: mjaric/nfx
        public void T050_PileNonOwnershipErrorStart()
        {
            var pile = new DefaultPile();

            try
            {
                var cache = new LocalCache();
                cache.Pile = pile;
                cache.Configure(null);
                cache.Start(); //can not start cache that uses inactive pile which is not managed by this cache
            }
            finally
            {
                pile.Dispose();
            }
        }
示例#8
0
        public void T040_PileOwnership()
        {
            var cache = new LocalCache(NOPApplication.Instance);

            cache.Pile = new DefaultPile(cache);
            cache.Configure(null);
            cache.Start();


            var tA = cache.GetOrCreateTable <string>("A");

            tA.Put("aaa", "avalue");
            Aver.AreObjectsEqual("avalue", tA.Get("aaa"));

            cache.WaitForCompleteStop();
            Aver.IsTrue(DaemonStatus.Inactive == cache.Status);
            Aver.IsTrue(DaemonStatus.Inactive == cache.Pile.Status);
        }
示例#9
0
文件: CacheTest.cs 项目: mjaric/nfx
        public void T040_PileOwnership()
        {
            var cache = new LocalCache();

            cache.Pile = new DefaultPile(cache);
            cache.Configure(null);
            cache.Start();


            var tA = cache.GetOrCreateTable <string>("A");

            tA.Put("aaa", "avalue");
            Assert.AreEqual("avalue", tA.Get("aaa"));

            cache.WaitForCompleteStop();
            Assert.AreEqual(NFX.ServiceModel.ControlStatus.Inactive, cache.Status);
            Assert.AreEqual(NFX.ServiceModel.ControlStatus.Inactive, cache.Pile.Status);
        }
示例#10
0
        private void CacheForm_Load(object sender, EventArgs e)
        {
            try
            {
                m_Cache      = new LocalCache(Azos.Apps.NOPApplication.Instance);
                m_Cache.Pile = new DefaultPile(m_Cache);
                m_Cache.Configure(null);
                //DURABLE
                m_Cache.TableOptions.Register(new TableOptions("table1")
                {
                    CollisionMode = CollisionMode.Durable
                });
                // m_Cache.DefaultTableOptions = new TableOptions("*") { CollisionMode = CollisionMode.Durable };
                m_Cache.Start();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToMessageWithType());
            }

            tbAbsoluteExpiration.Text = DateTime.Now.AddMinutes(120).ToString();
        }
示例#11
0
 private LocalCache makeCache(IConfigSectionNode conf = null)
 {
    var cache = new LocalCache();
    cache.Pile = new DefaultPile(cache);
    cache.Configure( conf );
    cache.Start();
    return cache;
 }
示例#12
0
      public void T060_PileNonOwnership()
      {
        var pile = new DefaultPile();
        pile.Start();
        try
        {
              var cache = new LocalCache();
              cache.Pile = pile;
              cache.Configure(null);
              cache.Start();
                
        
              var tA = cache.GetOrCreateTable<string>("A");
              tA.Put("aaa", "avalue");
              tA.Put("bbb", "bvalue");
              Assert.AreEqual("avalue", tA.Get("aaa"));

              Assert.AreEqual(2, cache.Count);
              Assert.AreEqual(2, pile.ObjectCount);

              cache.WaitForCompleteStop();
              Assert.AreEqual(NFX.ServiceModel.ControlStatus.Inactive, cache.Status);
        
              Assert.AreEqual(NFX.ServiceModel.ControlStatus.Active, pile.Status);
              Assert.AreEqual(0, pile.ObjectCount);
       
              cache = new LocalCache();
              cache.Pile = pile;
              cache.Configure(null);
              cache.Start();

              var tAbc = cache.GetOrCreateTable<string>("Abc");
              tAbc.Put("aaa", "avalue");
              tAbc.Put("bbb", "bvalue");
              tAbc.Put("ccc", "cvalue");
              tAbc.Put("ddd", "cvalue");

              Assert.AreEqual(4, pile.ObjectCount);

              var cache2 = new LocalCache();
              cache2.Pile = pile;
              cache2.Configure(null);
              cache2.Start();
                
        
              var t2 = cache2.GetOrCreateTable<string>("A");
              t2.Put("aaa", "avalue");
              t2.Put("bbb", "bvalue");
        
              Assert.AreEqual(2, cache2.Count);
              Assert.AreEqual(6, pile.ObjectCount);

              cache.WaitForCompleteStop();
              Assert.AreEqual(NFX.ServiceModel.ControlStatus.Active, pile.Status);
              Assert.AreEqual(2, pile.ObjectCount);

              cache2.WaitForCompleteStop();
              Assert.AreEqual(NFX.ServiceModel.ControlStatus.Active, pile.Status);
              Assert.AreEqual(0, pile.ObjectCount);

              pile.WaitForCompleteStop();
              Assert.AreEqual(NFX.ServiceModel.ControlStatus.Inactive, pile.Status);
        }
        finally
        {
          pile.Dispose();
        }
      }
示例#13
0
      public void T050_PileNonOwnershipErrorStart()
      {
        var pile = new DefaultPile();

        try
        {
          var cache = new LocalCache();
          cache.Pile = pile;
          cache.Configure(null);
          cache.Start();  //can not start cache that uses inactive pile which is not managed by this cache
        }
        finally
        {
          pile.Dispose();
        }
                
      }
示例#14
0
      public void T040_PileOwnership()
      {
        var cache = new LocalCache();
        cache.Pile = new DefaultPile(cache);
        cache.Configure(null);
        cache.Start();
                
        
        var tA = cache.GetOrCreateTable<string>("A");
        tA.Put("aaa", "avalue");
        Assert.AreEqual("avalue", tA.Get("aaa"));

        cache.WaitForCompleteStop();
        Assert.AreEqual(NFX.ServiceModel.ControlStatus.Inactive, cache.Status);
        Assert.AreEqual(NFX.ServiceModel.ControlStatus.Inactive, cache.Pile.Status);
      }
示例#15
0
 private static LocalCache makeCache()
 {
     var cache = new LocalCache();
        cache.Pile = new DefaultPile(cache);
        cache.Configure(null);
        cache.Start();
        return cache;
 }
示例#16
0
        public void T060_PileNonOwnership()
        {
            var pile = new DefaultPile(NOPApplication.Instance);

            pile.Start();
            try
            {
                var cache = new LocalCache(NOPApplication.Instance);
                cache.Pile = pile;
                cache.Configure(null);
                cache.Start();


                var tA = cache.GetOrCreateTable <string>("A");
                tA.Put("aaa", "avalue");
                tA.Put("bbb", "bvalue");
                Aver.AreObjectsEqual("avalue", tA.Get("aaa"));

                Aver.AreEqual(2, cache.Count);
                Aver.AreEqual(2, pile.ObjectCount);

                cache.WaitForCompleteStop();
                Aver.IsTrue(DaemonStatus.Inactive == cache.Status);

                Aver.IsTrue(DaemonStatus.Active == pile.Status);
                Aver.AreEqual(0, pile.ObjectCount);

                cache      = new LocalCache(NOPApplication.Instance);
                cache.Pile = pile;
                cache.Configure(null);
                cache.Start();

                var tAbc = cache.GetOrCreateTable <string>("Abc");
                tAbc.Put("aaa", "avalue");
                tAbc.Put("bbb", "bvalue");
                tAbc.Put("ccc", "cvalue");
                tAbc.Put("ddd", "cvalue");

                Aver.AreEqual(4, pile.ObjectCount);

                var cache2 = new LocalCache(NOPApplication.Instance);
                cache2.Pile = pile;
                cache2.Configure(null);
                cache2.Start();


                var t2 = cache2.GetOrCreateTable <string>("A");
                t2.Put("aaa", "avalue");
                t2.Put("bbb", "bvalue");

                Aver.AreEqual(2, cache2.Count);
                Aver.AreEqual(6, pile.ObjectCount);

                cache.WaitForCompleteStop();
                Aver.IsTrue(DaemonStatus.Active == pile.Status);
                Aver.AreEqual(2, pile.ObjectCount);

                cache2.WaitForCompleteStop();
                Aver.IsTrue(DaemonStatus.Active == pile.Status);
                Aver.AreEqual(0, pile.ObjectCount);

                pile.WaitForCompleteStop();
                Aver.IsTrue(DaemonStatus.Inactive == pile.Status);
            }
            finally
            {
                pile.Dispose();
            }
        }
示例#17
0
文件: CacheTest.cs 项目: mjaric/nfx
        public void T060_PileNonOwnership()
        {
            var pile = new DefaultPile();

            pile.Start();
            try
            {
                var cache = new LocalCache();
                cache.Pile = pile;
                cache.Configure(null);
                cache.Start();


                var tA = cache.GetOrCreateTable <string>("A");
                tA.Put("aaa", "avalue");
                tA.Put("bbb", "bvalue");
                Assert.AreEqual("avalue", tA.Get("aaa"));

                Assert.AreEqual(2, cache.Count);
                Assert.AreEqual(2, pile.ObjectCount);

                cache.WaitForCompleteStop();
                Assert.AreEqual(NFX.ServiceModel.ControlStatus.Inactive, cache.Status);

                Assert.AreEqual(NFX.ServiceModel.ControlStatus.Active, pile.Status);
                Assert.AreEqual(0, pile.ObjectCount);

                cache      = new LocalCache();
                cache.Pile = pile;
                cache.Configure(null);
                cache.Start();

                var tAbc = cache.GetOrCreateTable <string>("Abc");
                tAbc.Put("aaa", "avalue");
                tAbc.Put("bbb", "bvalue");
                tAbc.Put("ccc", "cvalue");
                tAbc.Put("ddd", "cvalue");

                Assert.AreEqual(4, pile.ObjectCount);

                var cache2 = new LocalCache();
                cache2.Pile = pile;
                cache2.Configure(null);
                cache2.Start();


                var t2 = cache2.GetOrCreateTable <string>("A");
                t2.Put("aaa", "avalue");
                t2.Put("bbb", "bvalue");

                Assert.AreEqual(2, cache2.Count);
                Assert.AreEqual(6, pile.ObjectCount);

                cache.WaitForCompleteStop();
                Assert.AreEqual(NFX.ServiceModel.ControlStatus.Active, pile.Status);
                Assert.AreEqual(2, pile.ObjectCount);

                cache2.WaitForCompleteStop();
                Assert.AreEqual(NFX.ServiceModel.ControlStatus.Active, pile.Status);
                Assert.AreEqual(0, pile.ObjectCount);

                pile.WaitForCompleteStop();
                Assert.AreEqual(NFX.ServiceModel.ControlStatus.Inactive, pile.Status);
            }
            finally
            {
                pile.Dispose();
            }
        }