You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/08/13 07:08:08 UTC

[GitHub] [flink] xiaolong-sn commented on a change in pull request #13015: [FLINK-18536][kinesis] Adding enhanced fan-out related configurations.

xiaolong-sn commented on a change in pull request #13015:
URL: https://github.com/apache/flink/pull/13015#discussion_r469741218



##########
File path: flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/FanOutRecordPublisherConfiguration.java
##########
@@ -0,0 +1,438 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.streaming.connectors.kinesis.internals.publisher.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.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+
+
+/**
+ * This is a configuration class for enhanced fan-out components.
+ */
+public class FanOutRecordPublisherConfiguration {
+
+	/**
+	 * The efo registration type for de-/registration of streams.
+	 */
+	private final EFORegistrationType efoRegistrationType;
+
+	/**
+	 * The efo stream consumer name. Should not be Null if the efoRegistrationType is either LAZY or EAGER.
+	 */
+	@Nullable
+	private String consumerName;
+
+	/**
+	 * The manual set efo consumer arns for each stream. Should not be Null if the efoRegistrationType is NONE
+	 */
+	@Nullable
+	private Map<String, String> streamConsumerArns;
+
+	/**
+	 * Base backoff millis for the deregister stream operation.
+	 */
+	private final int subscribeToShardMaxRetries;
+
+	/**
+	 * Maximum backoff millis for the subscribe to shard operation.
+	 */
+	private final long subscribeToShardMaxBackoffMillis;
+
+	/**
+	 * Base backoff millis for the subscribe to shard operation.
+	 */
+	private final long subscribeToShardBaseBackoffMillis;
+
+	/**
+	 * Exponential backoff power constant for the subscribe to shard operation.
+	 */
+	private final double subscribeToShardExpConstant;
+
+	/**
+	 * Base backoff millis for the register stream operation.
+	 */
+	private final long registerStreamBaseBackoffMillis;
+
+	/**
+	 * Maximum backoff millis for the register stream operation.
+	 */
+	private final long registerStreamMaxBackoffMillis;
+
+	/**
+	 * Exponential backoff power constant for the register stream operation.
+	 */
+	private final double registerStreamExpConstant;
+
+	/**
+	 * Maximum retry attempts for the register stream operation.
+	 */
+	private final int registerStreamMaxRetries;
+
+	/**
+	 * Base backoff millis for the deregister stream operation.
+	 */
+	private final long deregisterStreamBaseBackoffMillis;
+
+	/**
+	 * Maximum backoff millis for the deregister stream operation.
+	 */
+	private final long deregisterStreamMaxBackoffMillis;
+
+	/**
+	 * Exponential backoff power constant for the deregister stream operation.
+	 */
+	private final double deregisterStreamExpConstant;
+
+	/**
+	 * Maximum retry attempts for the deregister stream operation.
+	 */
+	private final int deregisterStreamMaxRetries;
+
+	/**
+	 * Max retries for the describe stream operation.
+	 */
+	private final int describeStreamMaxRetries;
+
+	/**
+	 * Backoff millis for the describe stream operation.
+	 */
+	private final long describeStreamBaseBackoffMillis;
+
+	/**
+	 *  Maximum backoff millis for the describe stream operation.
+	 */
+	private final long describeStreamMaxBackoffMillis;
+
+	/**
+	 * Exponential backoff power constant for the describe stream operation.
+	 */
+	private final double describeStreamExpConstant;
+
+	/**
+	 * Max retries for the describe stream consumer operation.
+	 */
+	private final int describeStreamConsumerMaxRetries;
+
+	/**
+	 * Backoff millis for the describe stream consumer operation.
+	 */
+	private final long describeStreamConsumerBaseBackoffMillis;
+
+	/**
+	 *  Maximum backoff millis for the describe stream consumer operation.
+	 */
+	private final long describeStreamConsumerMaxBackoffMillis;
+
+	/**
+	 * Exponential backoff power constant for the describe stream consumer operation.
+	 */
+	private final double describeStreamConsumerExpConstant;
+
+	/**
+	 * Creates a FanOutProperties.
+	 *
+	 * @param configProps the configuration properties from config file.
+	 * @param streams     the streams which is sent to match the EFO consumer arn if the EFO registration mode is set to `NONE`.
+	 */
+	public FanOutRecordPublisherConfiguration(Properties configProps, List<String> streams) {
+		Preconditions.checkArgument(configProps.getProperty(ConsumerConfigConstants.RECORD_PUBLISHER_TYPE).equals(RecordPublisherType.EFO.toString()), "Only efo record publisher can register a FanOutProperties.");
+		KinesisConfigUtil.validateEfoConfiguration(configProps, streams);
+
+		efoRegistrationType = EFORegistrationType.valueOf(configProps.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 = configProps.getProperty(ConsumerConfigConstants.EFO_CONSUMER_NAME);
+		} else {
+			//else users should explicitly provide consumer arns.
+			streamConsumerArns = new HashMap<>();
+			for (String stream : streams) {
+				String key = ConsumerConfigConstants.EFO_CONSUMER_ARN_PREFIX + "." + stream;
+				streamConsumerArns.put(stream, configProps.getProperty(key));
+			}
+		}
+
+		this.subscribeToShardMaxRetries = Integer.parseInt(

Review comment:
       Done.




----------------------------------------------------------------
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:
users@infra.apache.org