-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cdc] Fix kafka canal-json cdc action cannot find confluent schema re…
…gistry client class when converting dataformat (#4024)
- Loading branch information
1 parent
b6e8963
commit 67032b3
Showing
23 changed files
with
640 additions
and
173 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/format/AbstractDataFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.paimon.flink.action.cdc.format; | ||
|
||
import org.apache.paimon.flink.action.cdc.CdcSourceRecord; | ||
import org.apache.paimon.flink.action.cdc.ComputedColumn; | ||
import org.apache.paimon.flink.action.cdc.TypeMapping; | ||
|
||
import org.apache.flink.api.common.serialization.DeserializationSchema; | ||
import org.apache.flink.configuration.Configuration; | ||
import org.apache.flink.streaming.connectors.kafka.KafkaDeserializationSchema; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
/** Data format common implementation of {@link DataFormat}. */ | ||
public abstract class AbstractDataFormat implements DataFormat { | ||
|
||
/** Factory for creating AbstractRecordParser. */ | ||
protected abstract RecordParserFactory parser(); | ||
|
||
/** Deserializer for Kafka Record. */ | ||
protected abstract Function<Configuration, KafkaDeserializationSchema<CdcSourceRecord>> | ||
kafkaDeserializer(); | ||
|
||
/** Deserializer for Pulsar Record. */ | ||
protected abstract Function<Configuration, DeserializationSchema<CdcSourceRecord>> | ||
pulsarDeserializer(); | ||
|
||
@Override | ||
public AbstractRecordParser createParser( | ||
TypeMapping typeMapping, List<ComputedColumn> computedColumns) { | ||
return parser().createParser(typeMapping, computedColumns); | ||
} | ||
|
||
@Override | ||
public KafkaDeserializationSchema<CdcSourceRecord> createKafkaDeserializer( | ||
Configuration cdcSourceConfig) { | ||
return kafkaDeserializer().apply(cdcSourceConfig); | ||
} | ||
|
||
@Override | ||
public DeserializationSchema<CdcSourceRecord> createPulsarDeserializer( | ||
Configuration cdcSourceConfig) { | ||
return pulsarDeserializer().apply(cdcSourceConfig); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...k-cdc/src/main/java/org/apache/paimon/flink/action/cdc/format/AbstractJsonDataFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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.action.cdc.format; | ||
|
||
import org.apache.paimon.flink.action.cdc.CdcSourceRecord; | ||
import org.apache.paimon.flink.action.cdc.kafka.KafkaDebeziumJsonDeserializationSchema; | ||
import org.apache.paimon.flink.action.cdc.serialization.CdcJsonDeserializationSchema; | ||
|
||
import org.apache.flink.api.common.serialization.DeserializationSchema; | ||
import org.apache.flink.configuration.Configuration; | ||
import org.apache.flink.streaming.connectors.kafka.KafkaDeserializationSchema; | ||
|
||
import java.util.function.Function; | ||
|
||
/** | ||
* The message queue's record json deserialization class common implementation of {@link | ||
* DataFormat}. | ||
*/ | ||
public abstract class AbstractJsonDataFormat extends AbstractDataFormat { | ||
|
||
@Override | ||
protected Function<Configuration, KafkaDeserializationSchema<CdcSourceRecord>> | ||
kafkaDeserializer() { | ||
return KafkaDebeziumJsonDeserializationSchema::new; | ||
} | ||
|
||
@Override | ||
protected Function<Configuration, DeserializationSchema<CdcSourceRecord>> pulsarDeserializer() { | ||
return CdcJsonDeserializationSchema::new; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...-flink-cdc/src/main/java/org/apache/paimon/flink/action/cdc/format/DataFormatFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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.action.cdc.format; | ||
|
||
import org.apache.paimon.factories.Factory; | ||
import org.apache.paimon.factories.FactoryException; | ||
import org.apache.paimon.factories.FactoryUtil; | ||
|
||
/** Factory to create {@link DataFormat}. */ | ||
public interface DataFormatFactory extends Factory { | ||
|
||
DataFormat create(); | ||
|
||
static DataFormat createDataFormat(String format) { | ||
String identifier = format.toLowerCase(); | ||
DataFormatFactory dataFormatFactory; | ||
try { | ||
dataFormatFactory = | ||
FactoryUtil.discoverFactory( | ||
DataFormatFactory.class.getClassLoader(), | ||
DataFormatFactory.class, | ||
identifier); | ||
} catch (FactoryException e) { | ||
throw new UnsupportedOperationException( | ||
String.format("This format: %s is not supported.", format)); | ||
} | ||
return dataFormatFactory.create(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...nk-cdc/src/main/java/org/apache/paimon/flink/action/cdc/format/canal/CanalDataFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* 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.action.cdc.format.canal; | ||
|
||
import org.apache.paimon.flink.action.cdc.format.AbstractJsonDataFormat; | ||
import org.apache.paimon.flink.action.cdc.format.RecordParserFactory; | ||
|
||
/** | ||
* Supports the message queue's canal json data format and provides definitions for the message | ||
* queue's record json deserialization class and parsing class {@link CanalRecordParser}. | ||
*/ | ||
public class CanalDataFormat extends AbstractJsonDataFormat { | ||
|
||
@Override | ||
protected RecordParserFactory parser() { | ||
return CanalRecordParser::new; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...src/main/java/org/apache/paimon/flink/action/cdc/format/canal/CanalDataFormatFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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.action.cdc.format.canal; | ||
|
||
import org.apache.paimon.flink.action.cdc.format.DataFormat; | ||
import org.apache.paimon.flink.action.cdc.format.DataFormatFactory; | ||
|
||
/** Factory to create {@link CanalDataFormat}. */ | ||
public class CanalDataFormatFactory implements DataFormatFactory { | ||
|
||
public static final String IDENTIFIER = "canal-json"; | ||
|
||
@Override | ||
public String identifier() { | ||
return IDENTIFIER; | ||
} | ||
|
||
@Override | ||
public DataFormat create() { | ||
return new CanalDataFormat(); | ||
} | ||
} |
Oops, something went wrong.