|
|
|
@ -158,6 +158,10 @@ public class StreamThreadTest {
@@ -158,6 +158,10 @@ public class StreamThreadTest {
|
|
|
|
|
// assign single partition
|
|
|
|
|
assignedPartitions = Collections.singletonList(t1p1); |
|
|
|
|
thread.taskManager().setAssignmentMetadata(Collections.<TaskId, Set<TopicPartition>>emptyMap(), Collections.<TaskId, Set<TopicPartition>>emptyMap()); |
|
|
|
|
|
|
|
|
|
final MockConsumer<byte[], byte[]> mockConsumer = (MockConsumer<byte[], byte[]>) thread.consumer; |
|
|
|
|
mockConsumer.assign(assignedPartitions); |
|
|
|
|
mockConsumer.updateBeginningOffsets(Collections.singletonMap(t1p1, 0L)); |
|
|
|
|
rebalanceListener.onPartitionsAssigned(assignedPartitions); |
|
|
|
|
thread.runOnce(-1); |
|
|
|
|
assertEquals(thread.state(), StreamThread.State.RUNNING); |
|
|
|
@ -378,8 +382,13 @@ public class StreamThreadTest {
@@ -378,8 +382,13 @@ public class StreamThreadTest {
|
|
|
|
|
activeTasks.put(task2, Collections.singleton(t1p2)); |
|
|
|
|
|
|
|
|
|
thread.taskManager().setAssignmentMetadata(activeTasks, Collections.<TaskId, Set<TopicPartition>>emptyMap()); |
|
|
|
|
thread.taskManager().createTasks(assignedPartitions); |
|
|
|
|
|
|
|
|
|
final MockConsumer<byte[], byte[]> mockConsumer = (MockConsumer<byte[], byte[]>) thread.consumer; |
|
|
|
|
mockConsumer.assign(assignedPartitions); |
|
|
|
|
Map<TopicPartition, Long> beginOffsets = new HashMap<>(); |
|
|
|
|
beginOffsets.put(t1p1, 0L); |
|
|
|
|
beginOffsets.put(t1p2, 0L); |
|
|
|
|
mockConsumer.updateBeginningOffsets(beginOffsets); |
|
|
|
|
thread.rebalanceListener.onPartitionsAssigned(new HashSet<>(assignedPartitions)); |
|
|
|
|
|
|
|
|
|
assertEquals(1, clientSupplier.producers.size()); |
|
|
|
@ -411,6 +420,12 @@ public class StreamThreadTest {
@@ -411,6 +420,12 @@ public class StreamThreadTest {
|
|
|
|
|
|
|
|
|
|
thread.taskManager().setAssignmentMetadata(activeTasks, Collections.<TaskId, Set<TopicPartition>>emptyMap()); |
|
|
|
|
|
|
|
|
|
final MockConsumer<byte[], byte[]> mockConsumer = (MockConsumer<byte[], byte[]>) thread.consumer; |
|
|
|
|
mockConsumer.assign(assignedPartitions); |
|
|
|
|
Map<TopicPartition, Long> beginOffsets = new HashMap<>(); |
|
|
|
|
beginOffsets.put(t1p1, 0L); |
|
|
|
|
beginOffsets.put(t1p2, 0L); |
|
|
|
|
mockConsumer.updateBeginningOffsets(beginOffsets); |
|
|
|
|
thread.rebalanceListener.onPartitionsAssigned(new HashSet<>(assignedPartitions)); |
|
|
|
|
|
|
|
|
|
thread.runOnce(-1); |
|
|
|
@ -439,7 +454,12 @@ public class StreamThreadTest {
@@ -439,7 +454,12 @@ public class StreamThreadTest {
|
|
|
|
|
activeTasks.put(task2, Collections.singleton(t1p2)); |
|
|
|
|
|
|
|
|
|
thread.taskManager().setAssignmentMetadata(activeTasks, Collections.<TaskId, Set<TopicPartition>>emptyMap()); |
|
|
|
|
thread.taskManager().createTasks(assignedPartitions); |
|
|
|
|
final MockConsumer<byte[], byte[]> mockConsumer = (MockConsumer<byte[], byte[]>) thread.consumer; |
|
|
|
|
mockConsumer.assign(assignedPartitions); |
|
|
|
|
Map<TopicPartition, Long> beginOffsets = new HashMap<>(); |
|
|
|
|
beginOffsets.put(t1p1, 0L); |
|
|
|
|
beginOffsets.put(t1p2, 0L); |
|
|
|
|
mockConsumer.updateBeginningOffsets(beginOffsets); |
|
|
|
|
|
|
|
|
|
thread.rebalanceListener.onPartitionsAssigned(assignedPartitions); |
|
|
|
|
|
|
|
|
@ -595,6 +615,9 @@ public class StreamThreadTest {
@@ -595,6 +615,9 @@ public class StreamThreadTest {
|
|
|
|
|
|
|
|
|
|
thread.taskManager().setAssignmentMetadata(activeTasks, Collections.<TaskId, Set<TopicPartition>>emptyMap()); |
|
|
|
|
|
|
|
|
|
final MockConsumer<byte[], byte[]> mockConsumer = (MockConsumer<byte[], byte[]>) thread.consumer; |
|
|
|
|
mockConsumer.assign(assignedPartitions); |
|
|
|
|
mockConsumer.updateBeginningOffsets(Collections.singletonMap(t1p1, 0L)); |
|
|
|
|
thread.rebalanceListener.onPartitionsAssigned(assignedPartitions); |
|
|
|
|
|
|
|
|
|
thread.runOnce(-1); |
|
|
|
@ -659,6 +682,10 @@ public class StreamThreadTest {
@@ -659,6 +682,10 @@ public class StreamThreadTest {
|
|
|
|
|
activeTasks.put(task1, Collections.singleton(t1p1)); |
|
|
|
|
|
|
|
|
|
thread.taskManager().setAssignmentMetadata(activeTasks, Collections.<TaskId, Set<TopicPartition>>emptyMap()); |
|
|
|
|
|
|
|
|
|
final MockConsumer<byte[], byte[]> mockConsumer = (MockConsumer<byte[], byte[]>) thread.consumer; |
|
|
|
|
mockConsumer.assign(assignedPartitions); |
|
|
|
|
mockConsumer.updateBeginningOffsets(Collections.singletonMap(t1p1, 0L)); |
|
|
|
|
thread.rebalanceListener.onPartitionsAssigned(assignedPartitions); |
|
|
|
|
|
|
|
|
|
thread.runOnce(-1); |
|
|
|
@ -714,8 +741,10 @@ public class StreamThreadTest {
@@ -714,8 +741,10 @@ public class StreamThreadTest {
|
|
|
|
|
activeTasks.put(task1, Collections.singleton(t1p1)); |
|
|
|
|
|
|
|
|
|
thread.taskManager().setAssignmentMetadata(activeTasks, Collections.<TaskId, Set<TopicPartition>>emptyMap()); |
|
|
|
|
thread.taskManager().createTasks(assignedPartitions); |
|
|
|
|
|
|
|
|
|
final MockConsumer<byte[], byte[]> mockConsumer = (MockConsumer<byte[], byte[]>) thread.consumer; |
|
|
|
|
mockConsumer.assign(assignedPartitions); |
|
|
|
|
mockConsumer.updateBeginningOffsets(Collections.singletonMap(t1p1, 0L)); |
|
|
|
|
thread.rebalanceListener.onPartitionsAssigned(assignedPartitions); |
|
|
|
|
|
|
|
|
|
thread.runOnce(-1); |
|
|
|
@ -883,9 +912,9 @@ public class StreamThreadTest {
@@ -883,9 +912,9 @@ public class StreamThreadTest {
|
|
|
|
|
|
|
|
|
|
thread.taskManager().setAssignmentMetadata(activeTasks, Collections.<TaskId, Set<TopicPartition>>emptyMap()); |
|
|
|
|
|
|
|
|
|
thread.rebalanceListener.onPartitionsAssigned(assignedPartitions); |
|
|
|
|
clientSupplier.consumer.assign(assignedPartitions); |
|
|
|
|
clientSupplier.consumer.updateBeginningOffsets(Collections.singletonMap(t1p1, 0L)); |
|
|
|
|
thread.rebalanceListener.onPartitionsAssigned(assignedPartitions); |
|
|
|
|
|
|
|
|
|
thread.runOnce(-1); |
|
|
|
|
|
|
|
|
@ -1074,17 +1103,18 @@ public class StreamThreadTest {
@@ -1074,17 +1103,18 @@ public class StreamThreadTest {
|
|
|
|
|
thread.setState(StreamThread.State.RUNNING); |
|
|
|
|
thread.setState(StreamThread.State.PARTITIONS_REVOKED); |
|
|
|
|
|
|
|
|
|
final Set<TopicPartition> assignedPartitions = Collections.singleton(new TopicPartition(t1p1.topic(), t1p1.partition())); |
|
|
|
|
final Set<TopicPartition> assignedPartitions = Collections.singleton(t1p1); |
|
|
|
|
thread.taskManager().setAssignmentMetadata( |
|
|
|
|
Collections.singletonMap( |
|
|
|
|
new TaskId(0, t1p1.partition()), |
|
|
|
|
assignedPartitions), |
|
|
|
|
Collections.<TaskId, Set<TopicPartition>>emptyMap()); |
|
|
|
|
thread.rebalanceListener.onPartitionsAssigned(assignedPartitions); |
|
|
|
|
|
|
|
|
|
final MockConsumer<byte[], byte[]> mockConsumer = (MockConsumer<byte[], byte[]>) thread.consumer; |
|
|
|
|
mockConsumer.assign(Collections.singleton(t1p1)); |
|
|
|
|
mockConsumer.updateBeginningOffsets(Collections.singletonMap(t1p1, 0L)); |
|
|
|
|
thread.rebalanceListener.onPartitionsAssigned(assignedPartitions); |
|
|
|
|
thread.runOnce(-1); |
|
|
|
|
|
|
|
|
|
final MetricName skippedTotalMetric = metrics.metricName("skipped-records-total", "stream-metrics", Collections.singletonMap("client-id", thread.getName())); |
|
|
|
|
assertEquals(0.0, metrics.metric(skippedTotalMetric).metricValue()); |
|
|
|
|