public void TestAll() { var dt = DateTime.Now; var id = new TaskId { Id = 0, Partition = 0 }; var stateManager = new ProcessorStateManager(id, new List <Confluent.Kafka.TopicPartition> { new Confluent.Kafka.TopicPartition("test", 0) }, null, null, null); var context = new ProcessorContext(UnassignedStreamTask.Create(), config, stateManager, new StreamMetricsRegistry()); wrapped.Init(context, inmemorystore); wrapped.Put("coucou", 120, dt.GetMilliseconds()); wrapped.Put("coucou-toto", 5, dt.GetMilliseconds()); var list = wrapped.All().ToList(); Assert.AreEqual(2, list.Count); Assert.AreEqual(dt.GetMilliseconds(), list[0].Key.Window.StartMs); Assert.AreEqual(dt.GetMilliseconds(), list[1].Key.Window.StartMs); Assert.AreEqual("coucou", list[0].Key.Key); Assert.AreEqual("coucou-toto", list[1].Key.Key); Assert.AreEqual(120, list[0].Value); Assert.AreEqual(5, list[1].Value); }
public void TestFetch() { var id = new TaskId { Id = 0, Partition = 0 }; var stateManager = new ProcessorStateManager(id, new List <Confluent.Kafka.TopicPartition> { new Confluent.Kafka.TopicPartition("test", 0) }, null, null, null); var context = new ProcessorContext(UnassignedStreamTask.Create(), config, stateManager, new StreamMetricsRegistry()); wrapped.Init(context, inmemorystore); wrapped.Put("coucou", 120, 1300); Assert.AreEqual(120, wrapped.Fetch("coucou", 1300)); }
public void TestWithUnknwonSerdes() { wrapped = new MeteredWindowStore <string, int>(inmemorystore, 1000 * 2, null, null, "in-memory-window"); var id = new TaskId { Id = 0, Partition = 0 }; var stateManager = new ProcessorStateManager(id, new List <Confluent.Kafka.TopicPartition> { new Confluent.Kafka.TopicPartition("test", 0) }, null, null, null); var context = new ProcessorContext(UnassignedStreamTask.Create(), config, stateManager, new StreamMetricsRegistry()); wrapped.Init(context, inmemorystore); Assert.Throws <StreamsException>(() => wrapped.Put("coucou", 120, 1300)); }
public void Initialize() { streamMetricsRegistry = new StreamMetricsRegistry(Guid.NewGuid().ToString(), MetricsRecordingLevel.DEBUG); config.ApplicationId = "test-stream-thread"; config.StateDir = Guid.NewGuid().ToString(); config.Guarantee = ProcessingGuarantee.AT_LEAST_ONCE; config.PollMs = 10; config.CommitIntervalMs = 1; id = new TaskId { Id = 0, Partition = 0 }; topicPartition = new TopicPartition("topic", 0); sourceProcessor = new SourceProcessor <string, string>( processorNodeName, "topic", new StringSerDes(), new StringSerDes(), new FailOnInvalidTimestamp()); sourceProcessor.AddNextProcessor(new KStreamPeekProcessor <string, string>((k, v) => { }, false)); context = new ProcessorContext( UnassignedStreamTask.Create(id), config, new ProcessorStateManager( id, new List <TopicPartition> { topicPartition }, null, new StoreChangelogReader(config, null, threadId, streamMetricsRegistry), new MockOffsetCheckpointManager() ), streamMetricsRegistry); sourceProcessor.Init(context); }
public void Initialize() { threadId = Thread.CurrentThread.Name ?? StreamMetricsRegistry.UNKNOWN_THREAD; streamMetricsRegistry = new StreamMetricsRegistry(Guid.NewGuid().ToString(), MetricsRecordingLevel.DEBUG); config.ApplicationId = "test-stream-thread"; config.StateDir = Guid.NewGuid().ToString(); config.Guarantee = ProcessingGuarantee.AT_LEAST_ONCE; config.PollMs = 10; config.CommitIntervalMs = 1; var builder = new StreamBuilder(); builder.Stream <string, string>("topic").To("topic2"); var topo = builder.Build(); id = new TaskId { Id = 0, Partition = 0 }; topicPartition = new TopicPartition("topic", 0); context = new ProcessorContext( UnassignedStreamTask.Create(id), config, new ProcessorStateManager( id, new List <TopicPartition> { topicPartition }, null, new StoreChangelogReader(config, null, threadId, streamMetricsRegistry), new MockOffsetCheckpointManager() ), streamMetricsRegistry); }