[ 
https://issues.apache.org/jira/browse/FLINK-9697?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16649168#comment-16649168
 ] 

ASF GitHub Bot commented on FLINK-9697:
---------------------------------------

eliaslevy commented on a change in pull request #6703: [FLINK-9697] Provide 
connector for Kafka 2.0.0
URL: https://github.com/apache/flink/pull/6703#discussion_r224965118
 
 

 ##########
 File path: 
flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducer.java
 ##########
 @@ -0,0 +1,1351 @@
+/*
+ * 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.kafka;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.common.functions.RuntimeContext;
+import org.apache.flink.api.common.serialization.SerializationSchema;
+import org.apache.flink.api.common.state.ListState;
+import org.apache.flink.api.common.state.ListStateDescriptor;
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.base.TypeSerializerSingleton;
+import org.apache.flink.api.java.ClosureCleaner;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.runtime.state.FunctionInitializationContext;
+import org.apache.flink.runtime.state.FunctionSnapshotContext;
+import 
org.apache.flink.streaming.api.functions.sink.TwoPhaseCommitSinkFunction;
+import org.apache.flink.streaming.api.operators.StreamingRuntimeContext;
+import 
org.apache.flink.streaming.connectors.kafka.internal.FlinkKafkaInnerProducer;
+import 
org.apache.flink.streaming.connectors.kafka.internal.TransactionalIdsGenerator;
+import 
org.apache.flink.streaming.connectors.kafka.internal.metrics.KafkaMetricMuttableWrapper;
+import 
org.apache.flink.streaming.connectors.kafka.partitioner.FlinkFixedPartitioner;
+import 
org.apache.flink.streaming.connectors.kafka.partitioner.FlinkKafkaDelegatePartitioner;
+import 
org.apache.flink.streaming.connectors.kafka.partitioner.FlinkKafkaPartitioner;
+import org.apache.flink.streaming.util.serialization.KeyedSerializationSchema;
+import 
org.apache.flink.streaming.util.serialization.KeyedSerializationSchemaWrapper;
+import org.apache.flink.util.ExceptionUtils;
+import org.apache.flink.util.NetUtils;
+
+import org.apache.flink.shaded.guava18.com.google.common.collect.Lists;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.kafka.clients.producer.Callback;
+import org.apache.kafka.clients.producer.Producer;
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.clients.producer.RecordMetadata;
+import org.apache.kafka.common.Metric;
+import org.apache.kafka.common.MetricName;
+import org.apache.kafka.common.PartitionInfo;
+import org.apache.kafka.common.errors.InvalidTxnStateException;
+import org.apache.kafka.common.errors.ProducerFencedException;
+import org.apache.kafka.common.serialization.ByteArraySerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.BlockingDeque;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.atomic.AtomicLong;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * Flink Sink to produce data into a Kafka topic. This producer is compatible 
with Kafka 2.0.x. By default producer
+ * will use {@link FlinkKafkaProducer.Semantic#AT_LEAST_ONCE} semantic.
+ * Before using {@link FlinkKafkaProducer.Semantic#EXACTLY_ONCE} please refer 
to Flink's
+ * Kafka connector documentation.
+ */
+@PublicEvolving
+public class FlinkKafkaProducer<IN>
+       extends TwoPhaseCommitSinkFunction<IN, 
FlinkKafkaProducer.KafkaTransactionState, 
FlinkKafkaProducer.KafkaTransactionContext> {
+
+       /**
+        *  Semantics that can be chosen.
+        *  <li>{@link #EXACTLY_ONCE}</li>
+        *  <li>{@link #AT_LEAST_ONCE}</li>
+        *  <li>{@link #NONE}</li>
+        */
+       public enum Semantic {
+
+               /**
+                * Semantic.EXACTLY_ONCE the Flink producer will write all 
messages in a Kafka transaction that will be
+                * committed to the Kafka on a checkpoint.
+                *
+                * <p>In this mode {@link FlinkKafkaProducer} sets up a pool of 
{@link FlinkKafkaInnerProducer}. Between each
+                * checkpoint there is created new Kafka transaction, which is 
being committed on
+                * {@link FlinkKafkaProducer#notifyCheckpointComplete(long)}. 
If checkpoint complete notifications are
+                * running late, {@link FlinkKafkaProducer} can run out of 
{@link FlinkKafkaInnerProducer}s in the pool. In that
+                * case any subsequent {@link 
FlinkKafkaProducer#snapshotState(FunctionSnapshotContext)} requests will fail
+                * and {@link FlinkKafkaProducer} will keep using the {@link 
FlinkKafkaInnerProducer} from previous checkpoint.
+                * To decrease chances of failing checkpoints there are three 
options:
+                * <li>decrease number of max concurrent checkpoints</li>
+                * <li>make checkpoints more reliable (so that they complete 
faster)</li>
+                * <li>increase delay between checkpoints</li>
+                * <li>increase size of {@link FlinkKafkaInnerProducer}s 
pool</li>
 
 Review comment:
   increase size -> increase the size

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Provide connector for Kafka 2.0.0
> ---------------------------------
>
>                 Key: FLINK-9697
>                 URL: https://issues.apache.org/jira/browse/FLINK-9697
>             Project: Flink
>          Issue Type: Improvement
>            Reporter: Ted Yu
>            Assignee: vinoyang
>            Priority: Major
>              Labels: pull-request-available
>
> Kafka 2.0.0 would be released soon.
> Here is vote thread:
> [http://search-hadoop.com/m/Kafka/uyzND1vxnEd23QLxb?subj=+VOTE+2+0+0+RC1]
> We should provide connector for Kafka 2.0.0 once it is released.
> Upgrade to 2.0 documentation : 
> http://kafka.apache.org/20/documentation.html#upgrade_2_0_0



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to