use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class StreamConsumerRegistrarTest method testRegistrationBackoffForLazy.
@Test
public void testRegistrationBackoffForLazy() throws Exception {
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
KinesisProxyV2Interface kinesis = FakeKinesisFanOutBehavioursFactory.existingActiveConsumer();
Properties efoProperties = createEfoProperties();
efoProperties.setProperty(EFO_REGISTRATION_TYPE, LAZY.name());
FanOutRecordPublisherConfiguration configuration = new FanOutRecordPublisherConfiguration(efoProperties, emptyList());
StreamConsumerRegistrar registrar = new StreamConsumerRegistrar(kinesis, configuration, backoff);
String result = registrar.registerStreamConsumer(STREAM, "name");
verify(backoff).sleep(anyLong());
assertEquals(STREAM_CONSUMER_ARN_EXISTING, result);
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class StreamConsumerRegistrarTest method testDeregisterStreamConsumerNotFound.
@Test
public void testDeregisterStreamConsumerNotFound() throws Exception {
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
StreamConsumerFakeKinesis kinesis = FakeKinesisFanOutBehavioursFactory.streamConsumerNotFound();
StreamConsumerRegistrar registrar = createRegistrar(kinesis, backoff);
registrar.deregisterStreamConsumer(STREAM);
assertEquals(1, kinesis.getNumberOfDescribeStreamConsumerInvocations());
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class StreamConsumerRegistrarTest method testDeregistrationBackoff.
@Test
public void testDeregistrationBackoff() throws Exception {
FanOutRecordPublisherConfiguration configuration = createConfiguration();
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
when(backoff.calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), anyInt())).thenReturn(5L);
StreamConsumerRegistrar registrar = new StreamConsumerRegistrar(mock(KinesisProxyV2Interface.class), configuration, backoff);
registrar.deregistrationBackoff(configuration, backoff, 11);
verify(backoff).sleep(5);
verify(backoff).calculateFullJitterBackoff(EXPECTED_DEREGISTRATION_BASE, EXPECTED_DEREGISTRATION_MAX, EXPECTED_DEREGISTRATION_POW, 11);
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class StreamConsumerRegistrarTest method backoffFor.
private FullJitterBackoff backoffFor(final long millisToBackoffFor) {
FullJitterBackoff backoff = spy(new FullJitterBackoff());
when(backoff.calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), anyInt())).thenReturn(millisToBackoffFor);
return backoff;
}
use of org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff in project flink by apache.
the class FanOutRecordPublisherTest method testSubscribeToShardFailsWhenMaxRetriesExceeded.
@Test
public void testSubscribeToShardFailsWhenMaxRetriesExceeded() throws Exception {
thrown.expect(RuntimeException.class);
thrown.expectMessage("Maximum retries exceeded for SubscribeToShard. Failed 3 times.");
Properties efoProperties = createEfoProperties();
efoProperties.setProperty(SUBSCRIBE_TO_SHARD_RETRIES, String.valueOf(EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES));
FanOutRecordPublisherConfiguration configuration = new FanOutRecordPublisherConfiguration(efoProperties, emptyList());
LimitExceededException retryableError = LimitExceededException.builder().build();
SubscriptionErrorKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(retryableError);
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
FanOutRecordPublisher recordPublisher = new FanOutRecordPublisher(latest(), "arn", createDummyStreamShardHandle(), kinesis, configuration, backoff);
int count = 0;
while (recordPublisher.run(new TestConsumer()) == INCOMPLETE) {
if (++count > EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES) {
break;
}
}
}
Aggregations