public void RedisTest() { RedisScheduler redisScheduler = new RedisScheduler("localhost", ""); ISpider spider = new DefaultSpider(); redisScheduler.Clear(); Request request = new Request("http://www.ibm.com/developerworks/cn/java/j-javadev2-22/", 1, null); request.PutExtra("1", "2"); redisScheduler.Push(request); Request result = redisScheduler.Poll(); Assert.AreEqual("http://www.ibm.com/developerworks/cn/java/j-javadev2-22/", result.Url.ToString()); Request result1 = redisScheduler.Poll(); Assert.IsNull(result1); redisScheduler.Dispose(); redisScheduler.Clear(); }
public void Redis_QueueTest() { RedisScheduler redisScheduler = new RedisScheduler("localhost", ""); ISpider spider = new DefaultSpider(); Request request1 = new Request("http://www.ibm.com/1", 1, null); Request request2 = new Request("http://www.ibm.com/2", 1, null); Request request3 = new Request("http://www.ibm.com/3", 1, null); Request request4 = new Request("http://www.ibm.com/4", 1, null); redisScheduler.Push(request1); redisScheduler.Push(request2); redisScheduler.Push(request3); redisScheduler.Push(request4); Request result = redisScheduler.Poll(); Assert.AreEqual("http://www.ibm.com/4", result.Url.ToString()); Request result1 = redisScheduler.Poll(); Assert.AreEqual("http://www.ibm.com/3", result1.Url.ToString()); redisScheduler.Dispose(); }
public void RedisTest() { RedisScheduler redisScheduler = new RedisScheduler("localhost", ""); ITask task = new TestTask(); Request request = new Request("http://www.ibm.com/developerworks/cn/java/j-javadev2-22/", null); request.PutExtra("1", "2"); redisScheduler.Push(request, task); redisScheduler.Poll(task); //System.out.println(poll); }
public void SchedulerLoadTest() { QueueDuplicateRemovedScheduler scheduler = new QueueDuplicateRemovedScheduler(); ISpider spider = new DefaultSpider("test", new Site()); scheduler.Push(new Request("http://www.a.com/", 1, null)); scheduler.Push(new Request("http://www.b.com/", 1, null)); scheduler.Push(new Request("http://www.c.com/", 1, null)); scheduler.Push(new Request("http://www.d.com/", 1, null)); RedisScheduler redisScheduler = new RedisScheduler("localhost", ""); redisScheduler.Load(scheduler.ToList()); Assert.AreEqual("http://www.d.com/", redisScheduler.Poll().Url.ToString()); Assert.AreEqual("http://www.c.com/", redisScheduler.Poll().Url.ToString()); Assert.AreEqual("http://www.b.com/", redisScheduler.Poll().Url.ToString()); Assert.AreEqual("http://www.a.com/", redisScheduler.Poll().Url.ToString()); }