Exemplo n.º 1
0
        public virtual void TestInitFill()
        {
            TestValueQueue.MockFiller filler = new TestValueQueue.MockFiller();
            ValueQueue <string>       vq     = new ValueQueue <string>(10, 0.1f, 300, 1, ValueQueue.SyncGenerationPolicy
                                                                       .All, filler);

            Assert.Equal("test", vq.GetNext("k1"));
            Assert.Equal(1, filler.GetTop().num);
            vq.Shutdown();
        }
Exemplo n.º 2
0
        public virtual void TestgetAtMostPolicyATLEAST_ONE()
        {
            TestValueQueue.MockFiller filler = new TestValueQueue.MockFiller();
            ValueQueue <string>       vq     = new ValueQueue <string>(10, 0.3f, 300, 1, ValueQueue.SyncGenerationPolicy
                                                                       .AtleastOne, filler);

            Assert.Equal("test", vq.GetNext("k1"));
            Assert.Equal(3, filler.GetTop().num);
            // Drain completely
            Assert.Equal(2, vq.GetAtMost("k1", 10).Count);
            // Asynch Refill call
            Assert.Equal(10, filler.GetTop().num);
            vq.Shutdown();
        }
Exemplo n.º 3
0
        public virtual void TestWarmUp()
        {
            TestValueQueue.MockFiller filler = new TestValueQueue.MockFiller();
            ValueQueue <string>       vq     = new ValueQueue <string>(10, 0.5f, 300, 1, ValueQueue.SyncGenerationPolicy
                                                                       .All, filler);

            vq.InitializeQueuesForKeys("k1", "k2", "k3");
            TestValueQueue.FillInfo[] fillInfos = new TestValueQueue.FillInfo[] { filler.GetTop
                                                                                      (), filler.GetTop(), filler.GetTop() };
            Assert.Equal(5, fillInfos[0].num);
            Assert.Equal(5, fillInfos[1].num);
            Assert.Equal(5, fillInfos[2].num);
            Assert.Equal(Sets.NewHashSet("k1", "k2", "k3"), Sets.NewHashSet
                             (fillInfos[0].key, fillInfos[1].key, fillInfos[2].key));
            vq.Shutdown();
        }
Exemplo n.º 4
0
        public virtual void TestgetAtMostPolicyLOW_WATERMARK()
        {
            TestValueQueue.MockFiller filler = new TestValueQueue.MockFiller();
            ValueQueue <string>       vq     = new ValueQueue <string>(10, 0.3f, 300, 1, ValueQueue.SyncGenerationPolicy
                                                                       .LowWatermark, filler);

            Assert.Equal("test", vq.GetNext("k1"));
            Assert.Equal(3, filler.GetTop().num);
            // Drain completely
            Assert.Equal(3, vq.GetAtMost("k1", 10).Count);
            // Synchronous call
            Assert.Equal(1, filler.GetTop().num);
            // Asynch Refill call
            Assert.Equal(10, filler.GetTop().num);
            vq.Shutdown();
        }
Exemplo n.º 5
0
        public virtual void TestgetAtMostPolicyALL()
        {
            TestValueQueue.MockFiller filler = new TestValueQueue.MockFiller();
            ValueQueue <string>       vq     = new ValueQueue <string>(10, 0.1f, 300, 1, ValueQueue.SyncGenerationPolicy
                                                                       .All, filler);

            Assert.Equal("test", vq.GetNext("k1"));
            Assert.Equal(1, filler.GetTop().num);
            // Drain completely
            Assert.Equal(10, vq.GetAtMost("k1", 10).Count);
            // Synchronous call
            Assert.Equal(10, filler.GetTop().num);
            // Ask for more... return all
            Assert.Equal(19, vq.GetAtMost("k1", 19).Count);
            // Synchronous call (No Async call since num > lowWatermark)
            Assert.Equal(19, filler.GetTop().num);
            vq.Shutdown();
        }