コード例 #1
0
ファイル: ConcurrentRepackTest.cs プロジェクト: shoff/ngit
        private static void WhackCache()
        {
            WindowCacheConfig config = new WindowCacheConfig();

            config.SetPackedGitOpenFiles(1);
            WindowCache.Reconfigure(config);
        }
コード例 #2
0
ファイル: ConcurrentRepackTest.cs プロジェクト: shoff/ngit
        public override void TearDown()
        {
            base.TearDown();
            WindowCacheConfig windowCacheConfig = new WindowCacheConfig();

            WindowCache.Reconfigure(windowCacheConfig);
        }
コード例 #3
0
ファイル: ConcurrentRepackTest.cs プロジェクト: shoff/ngit
        public override void SetUp()
        {
            WindowCacheConfig windowCacheConfig = new WindowCacheConfig();

            windowCacheConfig.SetPackedGitOpenFiles(1);
            WindowCache.Reconfigure(windowCacheConfig);
            base.SetUp();
        }
コード例 #4
0
 /// <summary>Close the resources utilized by this repository</summary>
 public virtual void Close()
 {
     WindowCache.Purge(this);
     lock (this)
     {
         loadedIdx  = null;
         reverseIdx = null;
     }
 }
コード例 #5
0
        public virtual void TestCache_TooFewFiles()
        {
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetPackedGitOpenFiles(2);
            WindowCache.Reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);
        }
コード例 #6
0
 public override void TearDown()
 {
     if (wc != null)
     {
         wc.Release();
     }
     WindowCache.Reconfigure(new WindowCacheConfig());
     base.TearDown();
 }
コード例 #7
0
        public virtual void TestCache_TooSmallLimit()
        {
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetPackedGitWindowSize(4096);
            cfg.SetPackedGitLimit(4096);
            WindowCache.Reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);
        }
コード例 #8
0
        private void CheckLimits(WindowCacheConfig cfg)
        {
            WindowCache cache = WindowCache.GetInstance();

            NUnit.Framework.Assert.IsTrue(cache.GetOpenFiles() <= cfg.GetPackedGitOpenFiles()
                                          );
            NUnit.Framework.Assert.IsTrue(cache.GetOpenBytes() <= cfg.GetPackedGitLimit());
            NUnit.Framework.Assert.IsTrue(0 < cache.GetOpenFiles());
            NUnit.Framework.Assert.IsTrue(0 < cache.GetOpenBytes());
        }
コード例 #9
0
        public override void SetUp()
        {
            base.SetUp();
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetStreamFileThreshold(streamThreshold);
            WindowCache.Reconfigure(cfg);
            repo = CreateBareRepository();
            wc   = (WindowCursor)repo.NewObjectReader();
        }
コード例 #10
0
ファイル: WindowCache.cs プロジェクト: TetradogOther/NGit
 /// <summary>Modify the configuration of the window cache.</summary>
 /// <remarks>
 /// Modify the configuration of the window cache.
 /// <p>
 /// The new configuration is applied immediately. If the new limits are
 /// smaller than what what is currently cached, older entries will be purged
 /// as soon as possible to allow the cache to meet the new limit.
 /// </remarks>
 /// <param name="cfg">the new window cache configuration.</param>
 /// <exception cref="System.ArgumentException">
 /// the cache configuration contains one or more invalid
 /// settings, usually too low of a limit.
 /// </exception>
 public static void Reconfigure(WindowCacheConfig cfg)
 {
     NGit.Storage.File.WindowCache nc = new NGit.Storage.File.WindowCache(cfg);
     NGit.Storage.File.WindowCache oc = cache;
     if (oc != null)
     {
         oc.RemoveAll();
     }
     cache = nc;
     streamFileThreshold = cfg.GetStreamFileThreshold();
     DeltaBaseCache.Reconfigure(cfg);
 }
コード例 #11
0
        public virtual void TestCache_Defaults()
        {
            WindowCacheConfig cfg = new WindowCacheConfig();

            WindowCache.Reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);
            WindowCache cache = WindowCache.GetInstance();

            NUnit.Framework.Assert.AreEqual(6, cache.GetOpenFiles());
            NUnit.Framework.Assert.AreEqual(17346, cache.GetOpenBytes());
        }
コード例 #12
0
 public virtual void TestConfigureCache_PackedGitLimit_0()
 {
     try
     {
         WindowCacheConfig cfg = new WindowCacheConfig();
         cfg.SetPackedGitLimit(0);
         WindowCache.Reconfigure(cfg);
         NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitLimit = 0");
     }
     catch (ArgumentException)
     {
     }
 }
コード例 #13
0
        public virtual void TestConfigureCache_Limits1()
        {
            // This test is just to force coverage over some lower bounds for
            // the table. We don't want the table to wind up with too small
            // of a size. This is highly dependent upon the table allocation
            // algorithm actually implemented in WindowCache.
            //
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetPackedGitLimit(6 * 4096 / 5);
            cfg.SetPackedGitWindowSize(4096);
            WindowCache.Reconfigure(cfg);
        }
コード例 #14
0
 public virtual void TestConfigureCache_PackedGitWindowSize_512()
 {
     try
     {
         WindowCacheConfig cfg = new WindowCacheConfig();
         cfg.SetPackedGitWindowSize(512);
         WindowCache.Reconfigure(cfg);
         NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitWindowSize = 512");
     }
     catch (ArgumentException e)
     {
         NUnit.Framework.Assert.AreEqual("Invalid window size", e.Message);
     }
 }
コード例 #15
0
 public virtual void TestConfigureCache_PackedGitOpenFiles_0()
 {
     try
     {
         WindowCacheConfig cfg = new WindowCacheConfig();
         cfg.SetPackedGitOpenFiles(0);
         WindowCache.Reconfigure(cfg);
         NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitOpenFiles = 0");
     }
     catch (ArgumentException e)
     {
         NUnit.Framework.Assert.AreEqual("Open files must be >= 1", e.Message);
     }
 }
コード例 #16
0
 public virtual void TestConfigureCache_PackedGitWindowSize_4097()
 {
     try
     {
         WindowCacheConfig cfg = new WindowCacheConfig();
         cfg.SetPackedGitWindowSize(4097);
         WindowCache.Reconfigure(cfg);
         NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitWindowSize = 4097");
     }
     catch (ArgumentException e)
     {
         NUnit.Framework.Assert.AreEqual("Window size must be power of 2", e.Message);
     }
 }
コード例 #17
0
        /// <exception cref="System.IO.IOException"></exception>
        internal void Pin(PackFile pack, long position)
        {
            ByteWindow w = window;

            if (w == null || !w.Contains(pack, position))
            {
                // If memory is low, we may need what is in our window field to
                // be cleaned up by the GC during the get for the next window.
                // So we always clear it, even though we are just going to set
                // it again.
                //
                window = null;
                window = WindowCache.Get(pack, position);
            }
        }
コード例 #18
0
ファイル: WindowCache.cs プロジェクト: TetradogOther/NGit
        /// <exception cref="System.IO.IOException"></exception>
        internal static ByteWindow Get(PackFile pack, long offset)
        {
            NGit.Storage.File.WindowCache c = cache;
            ByteWindow r = c.GetOrLoad(pack, c.ToStart(offset));

            if (c != cache)
            {
                // The cache was reconfigured while we were using the old one
                // to load this window. The window is still valid, but our
                // cache may think its still live. Ensure the window is removed
                // from the old cache so resources can be released.
                //
                c.RemoveAll();
            }
            return(r);
        }
コード例 #19
0
 public virtual void TestConfigureCache_PackedGitWindowSizeAbovePackedGitLimit()
 {
     try
     {
         WindowCacheConfig cfg = new WindowCacheConfig();
         cfg.SetPackedGitLimit(1024);
         cfg.SetPackedGitWindowSize(8192);
         WindowCache.Reconfigure(cfg);
         NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitWindowSize > PackedGitLimit"
                                     );
     }
     catch (ArgumentException e)
     {
         NUnit.Framework.Assert.AreEqual("Window size must be < limit", e.Message);
     }
 }
コード例 #20
0
 internal int GetStreamFileThreshold()
 {
     return(WindowCache.GetStreamFileThreshold());
 }