AHeise commented on a change in pull request #19073:
URL: https://github.com/apache/flink/pull/19073#discussion_r826989099



##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/DataStream.java
##########
@@ -1265,10 +1282,26 @@ public ExecutionConfig getExecutionConfig() {
      */
     @PublicEvolving
     public DataStreamSink<T> sinkTo(Sink<T> sink) {
+        return this.sinkTo(sink, SinkOperatorsUidHashes.builder().build());

Review comment:
       I'd add a default value `CustomSinkOperatorUidHashes#DEFAULT` or so.

##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/translators/SinkTransformationTranslator.java
##########
@@ -257,7 +258,15 @@ private void expand() {
             List<Transformation<?>> expandedTransformations =
                     transformations.subList(numTransformsBefore, 
transformations.size());
 
+            final SinkOperatorsUidHashes operatorsUidHashes =
+                    transformation.getSinkOperatorsUidHashes();
+            final boolean hasWriterUidHash = 
operatorsUidHashes.getWriterUidHash() != null;
+            final boolean hasCommitterUidHash =
+                    operatorsUidHashes.getGlobalCommitterUidHash() != null;
+            final boolean hasGlobalCommitterUidHash =
+                    operatorsUidHashes.getGlobalCommitterUidHash() != null;

Review comment:
       I'd inline these variables.

##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/SinkOperatorsUidHashes.java
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.api.datastream;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.annotation.PublicEvolving;
+
+import javax.annotation.Nullable;
+
+/**
+ * This class is responsible to hold operator Uid hashes from the common 
operators of the sink. With
+ * this, users can recover a sink snapshot that did not bind uids to the 
operator before changing
+ * the topology.
+ */
+@PublicEvolving
+public class SinkOperatorsUidHashes {

Review comment:
       I'd call it `CustomSinkOperatorUidHashes`. It should be clear that this 
is purely optional.

##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/translators/SinkTransformationTranslator.java
##########
@@ -268,6 +277,26 @@ private void expand() {
                                     + " has set uid for some operators.");
                 }
 
+                // Set the operator uid hashes to support stateful upgrades 
without prior uids
+                if (hasWriterUidHash) {
+                    if (subTransformation.getName().equals(WRITER_NAME)) {

Review comment:
       Is this safe?

##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/translators/SinkTransformationTranslator.java
##########
@@ -268,6 +277,26 @@ private void expand() {
                                     + " has set uid for some operators.");
                 }
 
+                // Set the operator uid hashes to support stateful upgrades 
without prior uids
+                if (hasWriterUidHash) {
+                    if (subTransformation.getName().equals(WRITER_NAME)) {
+                        
subTransformation.setUidHash(operatorsUidHashes.getWriterUidHash());
+                    }
+                }
+                if (hasCommitterUidHash) {
+                    if (subTransformation.getName().equals(COMMITTER_NAME)) {
+                        
subTransformation.setUidHash(operatorsUidHashes.getCommitterUidHash());
+                    }
+                }

Review comment:
       You could extract a method with 2 params for all 3 cases afais.




-- 
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]


Reply via email to