Search in sources :

Example 1 with GlobalStateManagerStub

use of org.apache.kafka.test.GlobalStateManagerStub in project kafka by apache.

the class GlobalStateTaskTest method before.

@Before
public void before() {
    sourceOne = new MockSourceNode<>(new String[] { "t1" }, new StringDeserializer(), new StringDeserializer());
    sourceTwo = new MockSourceNode<>(new String[] { "t2" }, new IntegerDeserializer(), new IntegerDeserializer());
    processorNodes = Arrays.asList(sourceOne, sourceTwo, new MockProcessorNode<>(-1), new MockProcessorNode<>(-1));
    final Set<String> storeNames = Utils.mkSet("t1-store", "t2-store");
    final Map<String, SourceNode> sourceByTopics = new HashMap<>();
    sourceByTopics.put("t1", sourceOne);
    sourceByTopics.put("t2", sourceTwo);
    final Map<String, String> storeToTopic = new HashMap<>();
    storeToTopic.put("t1-store", "t1");
    storeToTopic.put("t2-store", "t2");
    final ProcessorTopology topology = new ProcessorTopology(processorNodes, sourceByTopics, Collections.<String, SinkNode>emptyMap(), Collections.<StateStore>emptyList(), storeToTopic, Collections.<StateStore>emptyList());
    context = new NoOpProcessorContext();
    t1 = new TopicPartition("t1", 1);
    t2 = new TopicPartition("t2", 1);
    offsets = new HashMap<>();
    offsets.put(t1, 50L);
    offsets.put(t2, 100L);
    stateMgr = new GlobalStateManagerStub(storeNames, offsets);
    globalStateTask = new GlobalStateUpdateTask(topology, context, stateMgr);
}
Also used : IntegerDeserializer(org.apache.kafka.common.serialization.IntegerDeserializer) MockProcessorNode(org.apache.kafka.test.MockProcessorNode) HashMap(java.util.HashMap) StringDeserializer(org.apache.kafka.common.serialization.StringDeserializer) NoOpProcessorContext(org.apache.kafka.test.NoOpProcessorContext) GlobalStateManagerStub(org.apache.kafka.test.GlobalStateManagerStub) MockSourceNode(org.apache.kafka.test.MockSourceNode) TopicPartition(org.apache.kafka.common.TopicPartition) Before(org.junit.Before)

Aggregations

HashMap (java.util.HashMap)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 IntegerDeserializer (org.apache.kafka.common.serialization.IntegerDeserializer)1 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)1 GlobalStateManagerStub (org.apache.kafka.test.GlobalStateManagerStub)1 MockProcessorNode (org.apache.kafka.test.MockProcessorNode)1 MockSourceNode (org.apache.kafka.test.MockSourceNode)1 NoOpProcessorContext (org.apache.kafka.test.NoOpProcessorContext)1 Before (org.junit.Before)1