xiaolong-sn commented on a change in pull request #12920:
URL: https://github.com/apache/flink/pull/12920#discussion_r457140642
##########
File path:
flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/fanout/FanOutProperties.java
##########
@@ -0,0 +1,127 @@
+package org.apache.flink.streaming.connectors.kinesis.internals.fanout;
+
+import
org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants;
+import
org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.EFORegistrationType;
+import
org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants.RecordPublisherType;
+import org.apache.flink.streaming.connectors.kinesis.util.KinesisConfigUtil;
+import org.apache.flink.util.Preconditions;
+
+import javax.annotation.Nullable;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+
+/**
+ * This is a configuration class for enhanced fan-out components.
+ */
+public class FanOutProperties implements Serializable {
+ private static final long serialVersionUID = 3204635913413261619L;
+
+ private EFORegistrationType efoRegistrationType;
+ @Nullable
+ private String consumerName;
+ @Nullable
+ private List<String> streamConsumerArns;
+
+ private int subscribeToShardMaxRetries;
+
+ private long subscribeToShardMaxBackoffMillis;
+
+ private long subscribeToShardBaseBackoffMillis;
+
+ private double subscribeToShardExpConstant;
+
+ public FanOutProperties(Properties properties, List<String> streams) {
+ //validate the properties
+
Preconditions.checkArgument(properties.getProperty(ConsumerConfigConstants.RECORD_PUBLISHER_TYPE).equals(RecordPublisherType.EFO.toString()),
"Only efo record publisher can register a FanOutProperties.");
+ KinesisConfigUtil.validateEFOConfiguration(properties, streams);
+
+ efoRegistrationType =
EFORegistrationType.valueOf(properties.getProperty(ConsumerConfigConstants.EFO_REGISTRATION_TYPE,
EFORegistrationType.EAGER.toString()));
+ //if efo registration type is EAGER|LAZY, then user should
explicitly provide a consumer name for each stream.
+ if (efoRegistrationType == EFORegistrationType.EAGER ||
efoRegistrationType == EFORegistrationType.LAZY) {
+ consumerName =
properties.getProperty(ConsumerConfigConstants.EFO_CONSUMER_NAME);
+ } else {
+ //else users should explicitly provide consumer arns.
+ streamConsumerArns = new ArrayList<>();
+ for (String stream:streams) {
+ String key =
ConsumerConfigConstants.EFO_CONSUMER_ARN_PREFIX + "." + stream;
+
streamConsumerArns.add(properties.getProperty(key));
+ }
+ }
+
+ this.subscribeToShardMaxRetries = Integer.parseInt(
+ properties.getProperty(
+
ConsumerConfigConstants.SUBSCRIBE_TO_SHARD_RETRIES,
+
Long.toString(ConsumerConfigConstants.DEFAULT_SUBSCRIBE_TO_SHARD_RETRIES)));
+ this.subscribeToShardBaseBackoffMillis = Long.parseLong(
+
properties.getProperty(ConsumerConfigConstants.SUBSCRIBE_TO_SHARD_BACKOFF_BASE,
+
Long.toString(ConsumerConfigConstants.DEFAULT_SUBSCRIBE_TO_SHARD_BACKOFF_BASE)));
+ this.subscribeToShardMaxBackoffMillis = Long.parseLong(
+
properties.getProperty(ConsumerConfigConstants.SUBSCRIBE_TO_SHARD_BACKOFF_MAX,
+
Long.toString(ConsumerConfigConstants.DEFAULT_SUBSCRIBE_TO_SHARD_BACKOFF_MAX)));
+ this.subscribeToShardExpConstant = Double.parseDouble(
+
properties.getProperty(ConsumerConfigConstants.SUBSCRIBE_TO_SHARD_BACKOFF_EXPONENTIAL_CONSTANT,
+
Double.toString(ConsumerConfigConstants.DEFAULT_SUBSCRIBE_TO_SHARD_BACKOFF_EXPONENTIAL_CONSTANT)));
+ }
+
+ public void setEfoRegistrationType(EFORegistrationType
efoRegistrationType) {
+ this.efoRegistrationType = efoRegistrationType;
+ }
+
+ public void setConsumerName(@Nullable String consumerName) {
+ this.consumerName = consumerName;
+ }
+
+ public void setStreamConsumerArns(@Nullable List<String>
streamConsumerArns) {
+ this.streamConsumerArns = streamConsumerArns;
+ }
+
+ public void setSubscribeToShardMaxRetries(int
subscribeToShardMaxRetries) {
+ this.subscribeToShardMaxRetries = subscribeToShardMaxRetries;
+ }
+
+ public void setSubscribeToShardMaxBackoffMillis(long
subscribeToShardMaxBackoffMillis) {
+ this.subscribeToShardMaxBackoffMillis =
subscribeToShardMaxBackoffMillis;
+ }
+
+ public void setSubscribeToShardBaseBackoffMillis(long
subscribeToShardBaseBackoffMillis) {
+ this.subscribeToShardBaseBackoffMillis =
subscribeToShardBaseBackoffMillis;
+ }
+
+ public void setSubscribeToShardExpConstant(double
subscribeToShardExpConstant) {
+ this.subscribeToShardExpConstant = subscribeToShardExpConstant;
+ }
+
+ public EFORegistrationType getEfoRegistrationType() {
+ return efoRegistrationType;
+ }
+
+ @Nullable
+ public String getConsumerName() {
+ return consumerName;
+ }
+
+ @Nullable
+ public List<String> getStreamConsumerArns() {
Review comment:
Yes, I added one.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]