yunfengzhou-hub commented on code in PR #6606: URL: https://github.com/apache/paimon/pull/6606#discussion_r2564542410
########## paimon-flink/paimon-flink-cdc/src/main/java/org/apache/paimon/flink/pipeline/cdc/source/enumerator/CDCSourceEnumerator.java: ########## @@ -0,0 +1,457 @@ +/* + * 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.paimon.flink.pipeline.cdc.source.enumerator; + +import org.apache.paimon.CoreOptions; +import org.apache.paimon.annotation.VisibleForTesting; +import org.apache.paimon.catalog.Catalog; +import org.apache.paimon.catalog.CatalogContext; +import org.apache.paimon.catalog.Identifier; +import org.apache.paimon.flink.metrics.FlinkMetricRegistry; +import org.apache.paimon.flink.pipeline.cdc.source.TableAwareFileStoreSourceSplit; +import org.apache.paimon.schema.TableSchema; +import org.apache.paimon.table.FileStoreTable; +import org.apache.paimon.table.Table; +import org.apache.paimon.table.source.DataSplit; +import org.apache.paimon.table.source.EndOfScanException; +import org.apache.paimon.table.source.SnapshotNotExistPlan; +import org.apache.paimon.table.source.Split; +import org.apache.paimon.table.source.StreamDataTableScan; +import org.apache.paimon.table.source.StreamTableScan; +import org.apache.paimon.table.source.TableScan; + +import org.apache.flink.api.connector.source.SourceEvent; +import org.apache.flink.api.connector.source.SplitEnumerator; +import org.apache.flink.api.connector.source.SplitEnumeratorContext; +import org.apache.flink.api.connector.source.SplitsAssignment; +import org.apache.flink.cdc.common.configuration.Configuration; +import org.apache.flink.metrics.groups.SplitEnumeratorMetricGroup; +import org.apache.flink.util.Preconditions; +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.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; + +import static org.apache.paimon.flink.pipeline.cdc.CDCOptions.DATABASE; +import static org.apache.paimon.flink.pipeline.cdc.CDCOptions.TABLE; +import static org.apache.paimon.flink.pipeline.cdc.CDCOptions.TABLE_DISCOVERY_INTERVAL; +import static org.apache.paimon.flink.pipeline.cdc.CDCOptions.toCDCOption; +import static org.apache.paimon.flink.pipeline.cdc.util.CDCUtils.createCatalog; + +/** {@link SplitEnumerator} for CDC source. */ +public class CDCSourceEnumerator + implements SplitEnumerator<TableAwareFileStoreSourceSplit, CDCCheckpoint> { + private static final Logger LOG = LoggerFactory.getLogger(CDCSourceEnumerator.class); + + private final SplitEnumeratorContext<TableAwareFileStoreSourceSplit> context; + private final long discoveryInterval; + private final long tableDiscoveryInterval; + private long lastTableDiscoveryTime = Long.MAX_VALUE; + private final AtomicInteger currentTableIndex = new AtomicInteger(0); + private final String database; + @Nullable private final String table; + private final Catalog catalog; + + private final int splitMaxNum; + private final CDCSplitAssigner splitAssigner; + private final Set<Integer> readersAwaitingSplit; + private final SplitIdGenerator splitIdGenerator; + private final Map<Identifier, TableStatus> tableStatusMap = new HashMap<>(); + private final Set<Identifier> discoveredNonFileStoreTables = new HashSet<>(); + private int numTablesWithSubtaskAssigned; + + private boolean stopTriggerScan = false; Review Comment: Thanks for the suggestion. I added description of this behavior to the "Usage Notes" section of `flink-cdc-paimon-pipeline-connector.md`. -- 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]
