org.apache.flink.core.testutils.MultiShotLatch Java Examples
The following examples show how to use
org.apache.flink.core.testutils.MultiShotLatch.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlinkKafkaProducerBaseTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") DummyFlinkKafkaProducer(Properties producerConfig, KeyedSerializationSchema<T> schema, FlinkKafkaPartitioner partitioner) { super(DUMMY_TOPIC, schema, producerConfig, partitioner); this.mockProducer = mock(KafkaProducer.class); when(mockProducer.send(any(ProducerRecord.class), any(Callback.class))).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { pendingCallbacks.add(invocationOnMock.getArgument(1)); return null; } }); this.pendingCallbacks = new ArrayList<>(); this.flushLatch = new MultiShotLatch(); }
Example #2
Source File: FlinkKafkaProducerBaseTest.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") DummyFlinkKafkaProducer(Properties producerConfig, KeyedSerializationSchema<T> schema, FlinkKafkaPartitioner partitioner) { super(DUMMY_TOPIC, schema, producerConfig, partitioner); this.mockProducer = mock(KafkaProducer.class); when(mockProducer.send(any(ProducerRecord.class), any(Callback.class))).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { pendingCallbacks.add(invocationOnMock.getArgument(1)); return null; } }); this.pendingCallbacks = new ArrayList<>(); this.flushLatch = new MultiShotLatch(); }
Example #3
Source File: FlinkKafkaProducerBaseTest.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") DummyFlinkKafkaProducer(Properties producerConfig, KeyedSerializationSchema<T> schema, FlinkKafkaPartitioner partitioner) { super(DUMMY_TOPIC, schema, producerConfig, partitioner); this.mockProducer = mock(KafkaProducer.class); when(mockProducer.send(any(ProducerRecord.class), any(Callback.class))).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { pendingCallbacks.add(invocationOnMock.getArgument(1)); return null; } }); this.pendingCallbacks = new ArrayList<>(); this.flushLatch = new MultiShotLatch(); }
Example #4
Source File: KafkaConsumerThreadTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test(timeout = 10000) public void testCloseWithoutAssignedPartitions() throws Exception { // no initial assignment final KafkaConsumer<byte[], byte[]> mockConsumer = createMockConsumer( new LinkedHashMap<TopicPartition, Long>(), Collections.<TopicPartition, Long>emptyMap(), false, null, null); // setup latch so the test waits until testThread is blocked on getBatchBlocking method final MultiShotLatch getBatchBlockingInvoked = new MultiShotLatch(); final ClosableBlockingQueue<KafkaTopicPartitionState<TopicPartition>> unassignedPartitionsQueue = new ClosableBlockingQueue<KafkaTopicPartitionState<TopicPartition>>() { @Override public List<KafkaTopicPartitionState<TopicPartition>> getBatchBlocking() throws InterruptedException { getBatchBlockingInvoked.trigger(); return super.getBatchBlocking(); } }; final TestKafkaConsumerThread testThread = new TestKafkaConsumerThread(mockConsumer, unassignedPartitionsQueue, new Handover()); testThread.start(); getBatchBlockingInvoked.await(); testThread.shutdown(); testThread.join(); }
Example #5
Source File: KafkaConsumerThreadTest.java From flink with Apache License 2.0 | 5 votes |
@Test(timeout = 10000) public void testCloseWithoutAssignedPartitions() throws Exception { // no initial assignment final KafkaConsumer<byte[], byte[]> mockConsumer = createMockConsumer( new LinkedHashMap<TopicPartition, Long>(), Collections.<TopicPartition, Long>emptyMap(), false, null, null); // setup latch so the test waits until testThread is blocked on getBatchBlocking method final MultiShotLatch getBatchBlockingInvoked = new MultiShotLatch(); final ClosableBlockingQueue<KafkaTopicPartitionState<TopicPartition>> unassignedPartitionsQueue = new ClosableBlockingQueue<KafkaTopicPartitionState<TopicPartition>>() { @Override public List<KafkaTopicPartitionState<TopicPartition>> getBatchBlocking() throws InterruptedException { getBatchBlockingInvoked.trigger(); return super.getBatchBlocking(); } }; final TestKafkaConsumerThread testThread = new TestKafkaConsumerThread(mockConsumer, unassignedPartitionsQueue, new Handover()); testThread.start(); getBatchBlockingInvoked.await(); testThread.shutdown(); testThread.join(); }
Example #6
Source File: KafkaConsumerThreadTest.java From flink with Apache License 2.0 | 5 votes |
@Test(timeout = 10000) public void testCloseWithoutAssignedPartitions() throws Exception { // no initial assignment final Consumer<byte[], byte[]> mockConsumer = createMockConsumer( new LinkedHashMap<TopicPartition, Long>(), Collections.<TopicPartition, Long>emptyMap(), false, null, null); // setup latch so the test waits until testThread is blocked on getBatchBlocking method final MultiShotLatch getBatchBlockingInvoked = new MultiShotLatch(); final ClosableBlockingQueue<KafkaTopicPartitionState<Object, TopicPartition>> unassignedPartitionsQueue = new ClosableBlockingQueue<KafkaTopicPartitionState<Object, TopicPartition>>() { @Override public List<KafkaTopicPartitionState<Object, TopicPartition>> getBatchBlocking() throws InterruptedException { getBatchBlockingInvoked.trigger(); return super.getBatchBlocking(); } }; final TestKafkaConsumerThread testThread = new TestKafkaConsumerThread(mockConsumer, unassignedPartitionsQueue, new Handover()); testThread.start(); getBatchBlockingInvoked.await(); testThread.shutdown(); testThread.join(); }
Example #7
Source File: TimestampITCase.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Before public void setupLatch() { // ensure that we get a fresh latch for each test latch = new MultiShotLatch(); }
Example #8
Source File: SourceExternalCheckpointTriggerTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Before public void resetLatches() { ready = new OneShotLatch(); sync = new MultiShotLatch(); }
Example #9
Source File: TimestampITCase.java From flink with Apache License 2.0 | 4 votes |
@Before public void setupLatch() { // ensure that we get a fresh latch for each test latch = new MultiShotLatch(); }
Example #10
Source File: SourceTaskTerminationTest.java From flink with Apache License 2.0 | 4 votes |
@Before public void initialize() { ready = new OneShotLatch(); runLoopStart = new MultiShotLatch(); runLoopEnd = new MultiShotLatch(); }
Example #11
Source File: SourceExternalCheckpointTriggerTest.java From flink with Apache License 2.0 | 4 votes |
@Before public void resetLatches() { ready = new OneShotLatch(); sync = new MultiShotLatch(); }
Example #12
Source File: TimestampITCase.java From flink with Apache License 2.0 | 4 votes |
@Before public void setupLatch() { // ensure that we get a fresh latch for each test latch = new MultiShotLatch(); }
Example #13
Source File: SourceStreamTaskTest.java From flink with Apache License 2.0 | 4 votes |
public static MultiShotLatch getDataProcessing() { return dataProcessing; }
Example #14
Source File: SourceTaskTerminationTest.java From flink with Apache License 2.0 | 4 votes |
@Before public void initialize() { ready = new OneShotLatch(); runLoopStart = new MultiShotLatch(); runLoopEnd = new MultiShotLatch(); }
Example #15
Source File: SourceExternalCheckpointTriggerTest.java From flink with Apache License 2.0 | 4 votes |
@Before public void resetLatches() { ready = new OneShotLatch(); sync = new MultiShotLatch(); }