AHeise commented on code in PR #101: URL: https://github.com/apache/flink-connector-kafka/pull/101#discussion_r1764619447
########## flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/sink/ClientIdFactory.java: ########## @@ -0,0 +1,43 @@ +/* + * 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.connector.kafka.sink; + +/** + * Construct a Kafka ClientId using a prefix + * and a subtask id. + */ +public class ClientIdFactory { + private static final String CLIENT_ID_DELIMITER = "-"; + + /** + * Construct a Kafka client id in the following format + * {@code clientIdPrefix-subtaskId}. + * + * @param clientIdPrefix prefix for the id + * @param subtaskId id of the Kafka producer subtask + * @return clientId + */ + public static String buildClientId( Review Comment: Do we need to include checkpoint id? At any given time we have at least 2 producers open. ########## flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/sink/KafkaSinkBuilder.java: ########## @@ -202,6 +217,25 @@ private void sanityCheck() { checkNotNull(recordSerializer, "recordSerializer"); } + private static void overwriteConfig(Properties properties, String clientIdPrefix, int subtaskId) { + if (clientIdPrefix == null) { + return; + } + String updatedClientId = ClientIdFactory.buildClientId(clientIdPrefix, subtaskId); + overrideProperty(properties, ProducerConfig.CLIENT_ID_CONFIG, updatedClientId); + } + + private static void overrideProperty(Properties properties, String key, String value) { + String userValue = properties.getProperty(key); + if (userValue != null) { + LOG.warn( + String.format( + "Property %s is provided but will be overridden from %s to %s", + key, userValue, value)); + } + properties.setProperty(key, value); + } + Review Comment: Is this still needed? looks dead to me. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
