pltbkd commented on code in PR #20374:
URL: https://github.com/apache/flink/pull/20374#discussion_r936494305


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/dynamicfiltering/DynamicFilteringDataCollectorOperatorCoordinator.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.table.runtime.operators.dynamicfiltering;
+
+import org.apache.flink.runtime.jobgraph.OperatorID;
+import org.apache.flink.runtime.operators.coordination.CoordinationRequest;
+import 
org.apache.flink.runtime.operators.coordination.CoordinationRequestHandler;
+import org.apache.flink.runtime.operators.coordination.CoordinationResponse;
+import org.apache.flink.runtime.operators.coordination.CoordinatorStore;
+import org.apache.flink.runtime.operators.coordination.OperatorCoordinator;
+import org.apache.flink.runtime.operators.coordination.OperatorEvent;
+import org.apache.flink.table.connector.source.DynamicFilteringEvent;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * The operator coordinator for {@link DynamicFilteringDataCollectorOperator}. 
The coordinator
+ * collects {@link DynamicFilteringEvent} then redistributes to listening 
source coordinators.
+ */
+public class DynamicFilteringDataCollectorOperatorCoordinator
+        implements OperatorCoordinator, CoordinationRequestHandler {
+
+    private static final Logger LOG =
+            
LoggerFactory.getLogger(DynamicFilteringDataCollectorOperatorCoordinator.class);
+
+    private final CoordinatorStore coordinatorStore;
+    private final List<String> dynamicFilteringDataListenerIDs;
+
+    private boolean hasReceivedFilteringData;
+
+    public DynamicFilteringDataCollectorOperatorCoordinator(
+            Context context, List<String> dynamicFilteringDataListenerIDs) {
+        this.coordinatorStore = checkNotNull(context.getCoordinatorStore());
+        this.dynamicFilteringDataListenerIDs = 
checkNotNull(dynamicFilteringDataListenerIDs);
+    }
+
+    @Override
+    public void start() throws Exception {}
+
+    @Override
+    public void close() throws Exception {}
+
+    @Override
+    public void handleEventFromOperator(int subtask, int attemptNumber, 
OperatorEvent event)
+            throws Exception {
+        // Since there might be speculative execution, once the dynamic filter 
collectors operator
+        // has been executed for multiple attempts, we only keep the first 
notification.
+        if (hasReceivedFilteringData) {
+            return;
+        }
+
+        for (String listenerID : dynamicFilteringDataListenerIDs) {
+            // Push event to listening source coordinators.
+            OperatorCoordinator listener = (OperatorCoordinator) 
coordinatorStore.get(listenerID);
+            if (listener == null) {
+                LOG.error("Dynamic filtering data listener is missing: {}", 
listenerID);

Review Comment:
   Yes, it can't more than a bug indeed. I'll make it throw exception.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to