leonardBang commented on code in PR #3339:
URL: https://github.com/apache/flink-cdc/pull/3339#discussion_r1687943729
##########
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/sink/DataSink.java:
##########
@@ -30,5 +33,5 @@ public interface DataSink {
EventSinkProvider getEventSinkProvider();
/** Get the {@link MetadataApplier} for applying metadata changes to
external systems. */
- MetadataApplier getMetadataApplier();
+ MetadataApplier getMetadataApplier(Set<SchemaChangeEventType>
enabledEventTypes);
Review Comment:
This is a public API, we should keep the backward compatibility
##########
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/sink/MetadataApplier.java:
##########
@@ -19,13 +19,22 @@
import org.apache.flink.cdc.common.annotation.PublicEvolving;
import org.apache.flink.cdc.common.event.SchemaChangeEvent;
+import org.apache.flink.cdc.common.event.SchemaChangeEventType;
+import org.apache.flink.cdc.common.exceptions.SchemaEvolveException;
import java.io.Serializable;
+import java.util.Set;
/** {@code MetadataApplier} is used to apply metadata changes to external
systems. */
@PublicEvolving
public interface MetadataApplier extends Serializable {
+ /** Checks if this metadata applier should handle this event type. */
+ boolean acceptsSchemaEvolutionType(SchemaChangeEventType
schemaChangeEventType);
+
+ /** Checks what kind of schema change events downstream can handle. */
+ Set<SchemaChangeEventType> getSupportedSchemaEvolutionTypes();
+
Review Comment:
Please consider the compatibility when change existing public API. Imaging
the case that user has a custom pipeline connector, is it still work after
he/she bump the flink cdc version?
##########
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/exceptions/SchemaEvolveException.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.cdc.common.exceptions;
+
+import org.apache.flink.cdc.common.event.SchemaChangeEvent;
+
+import javax.annotation.Nullable;
+
+/** An exception occurred during schema evolution. */
+public class SchemaEvolveException extends Exception {
Review Comment:
extends `FlinkRuntimeException` or `CDCRuntimeException` ?
##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-doris/src/main/java/org/apache/flink/cdc/connectors/doris/sink/DorisDataSink.java:
##########
@@ -74,7 +76,7 @@ public EventSinkProvider getEventSinkProvider() {
}
@Override
- public MetadataApplier getMetadataApplier() {
- return new DorisMetadataApplier(dorisOptions, configuration);
+ public MetadataApplier getMetadataApplier(Set<SchemaChangeEventType>
enabledEventTypes) {
+ return new DorisMetadataApplier(dorisOptions, configuration,
enabledEventTypes);
}
Review Comment:
You need change all connectors in one PR if you bring an incompatible change
in public API, we should avoid this kind of change.
##########
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/pipeline/SchemaChangeBehavior.java:
##########
@@ -22,7 +22,9 @@
/** Behavior for handling schema changes. */
@PublicEvolving
public enum SchemaChangeBehavior {
- EVOLVE,
IGNORE,
Review Comment:
you can add a note about the order adjustment
##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/operators/schema/metrics/SchemaOperatorMetrics.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.cdc.runtime.operators.schema.metrics;
+
+import org.apache.flink.cdc.common.pipeline.SchemaChangeBehavior;
+import org.apache.flink.cdc.runtime.operators.schema.SchemaOperator;
+import org.apache.flink.metrics.Counter;
+import org.apache.flink.metrics.MetricGroup;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/** A collection class for handling metrics in {@link SchemaOperator}. */
+public class SchemaOperatorMetrics {
Review Comment:
We can split the metric logic to another PR in next time, it's totally
independent with SE behavior. But, I like the idea to report metrics for
SchemaOperator.
##########
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/event/SchemaChangeEventType.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.cdc.common.event;
+
+/** An enumeration of schema change event types for {@link SchemaChangeEvent}.
*/
+public enum SchemaChangeEventType {
Review Comment:
This should be a public interface from my point.
##########
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/event/SchemaChangeEventTypeFamily.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.cdc.common.event;
+
+/**
+ * An enumeration of schema change event families for clustering {@link
SchemaChangeEvent}s into
+ * categories.
+ */
+public class SchemaChangeEventTypeFamily {
+
+ public static final SchemaChangeEventType[] ADD =
{SchemaChangeEventType.ADD_COLUMN};
+
+ public static final SchemaChangeEventType[] ALTER =
{SchemaChangeEventType.ALTER_COLUMN_TYPE};
+
+ public static final SchemaChangeEventType[] CREATE =
{SchemaChangeEventType.CREATE_TABLE};
+
+ public static final SchemaChangeEventType[] DROP =
{SchemaChangeEventType.DROP_COLUMN};
+
+ public static final SchemaChangeEventType[] RENAME =
{SchemaChangeEventType.RENAME_COLUMN};
+
+ public static final SchemaChangeEventType[] TABLE =
{SchemaChangeEventType.CREATE_TABLE};
Review Comment:
Could you share the basis of the categories ? current hierarchy confuse me
a bit.
##########
flink-cdc-runtime/src/test/resources/log4j2-test.properties:
##########
@@ -15,7 +15,7 @@
# Set root logger level to OFF to not flood build logs
# set manually to INFO for debugging purposes
-rootLogger.level = OFF
+rootLogger.level = DEBUG
Review Comment:
INFO ?
##########
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/event/SchemaChangeEventType.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.cdc.common.event;
+
+/** An enumeration of schema change event types for {@link SchemaChangeEvent}.
*/
+public enum SchemaChangeEventType {
+ ADD_COLUMN,
+ ALTER_COLUMN_TYPE,
+ CREATE_TABLE,
+ DROP_COLUMN,
+ RENAME_COLUMN;
+
+ public static SchemaChangeEventType ofEvent(SchemaChangeEvent event) {
+ if (event instanceof AddColumnEvent) {
+ return ADD_COLUMN;
+ } else if (event instanceof AlterColumnTypeEvent) {
+ return ALTER_COLUMN_TYPE;
+ } else if (event instanceof CreateTableEvent) {
+ return CREATE_TABLE;
+ } else if (event instanceof DropColumnEvent) {
+ return DROP_COLUMN;
+ } else if (event instanceof RenameColumnEvent) {
+ return RENAME_COLUMN;
+ } else {
+ throw new RuntimeException("Unknown schema change event type: " +
event.getClass());
Review Comment:
Why a RuntimeException thrown here but `ofTag()` method return a `null`
object?
--
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]