public void TestAccumulatorByNodeByTopicByPartition(int batchSize, int time) { INode n1 = new NodeMock("n1"); INode n2 = new NodeMock("n2"); var accumulator = new AccumulatorByNodeByTopicByPartition <Tuple <string, int, int> >(t => t.Item1, t => t.Item2, batchSize, TimeSpan.FromMilliseconds(time)); var count = new CountdownEvent(2); var d = new Dictionary <INode, IBatchByTopicByPartition <Tuple <string, int, int> > >(); accumulator.NewBatch += (n, b) => { d[n] = b; count.Signal(); }; accumulator.Add(Tuple.Create(n1, Tuple.Create("1", 1, 1))); accumulator.Add(Tuple.Create(n1, Tuple.Create("1", 1, 2))); accumulator.Add(Tuple.Create(n2, Tuple.Create("2", 1, 1))); accumulator.Add(Tuple.Create(n2, Tuple.Create("2", 2, 2))); accumulator.Add(Tuple.Create(n2, Tuple.Create("2", 2, 3))); count.Wait(); Assert.AreEqual(2, d[n1].Count); Assert.AreEqual(3, d[n2].Count); d[n1].Dispose(); d[n2].Dispose(); }
public bool Send(INode node, ProduceMessage message) { return(_accumulator.Add(Tuple.Create(node, message))); }