forked from apache/camel-quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Debezium PostgresSQL Connector native support apache#1191
- Loading branch information
1 parent
4994632
commit 9691ae9
Showing
24 changed files
with
664 additions
and
101 deletions.
There are no files selected for viewing
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
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
47 changes: 0 additions & 47 deletions
47
...pache/camel/quarkus/component/debezium/postgres/deployment/DebeziumPostgresProcessor.java
This file was deleted.
Oops, something went wrong.
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
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
74 changes: 74 additions & 0 deletions
74
...pache/camel/quarkus/component/debezium/postgres/deployment/DebeziumPostgresProcessor.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,74 @@ | ||
/* | ||
* 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.camel.quarkus.component.debezium.postgres.deployment; | ||
|
||
import io.quarkus.arc.deployment.BeanContainerBuildItem; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.ExecutionTime; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.deployment.builditem.CombinedIndexBuildItem; | ||
import io.quarkus.deployment.builditem.FeatureBuildItem; | ||
import io.quarkus.deployment.builditem.IndexDependencyBuildItem; | ||
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; | ||
import org.apache.camel.component.debezium.DebeziumPostgresComponent; | ||
import org.apache.camel.quarkus.component.debezium.postgres.graal.DebeziumPostgresRecorder; | ||
import org.apache.camel.quarkus.core.deployment.CamelRuntimeBeanBuildItem; | ||
import org.jboss.jandex.IndexView; | ||
|
||
class DebeziumPostgresProcessor { | ||
|
||
private static final String FEATURE = "camel-debezium-postgres"; | ||
|
||
@BuildStep | ||
FeatureBuildItem feature() { | ||
return new FeatureBuildItem(FEATURE); | ||
} | ||
|
||
@BuildStep | ||
ReflectiveClassBuildItem registerForReflection(CombinedIndexBuildItem combinedIndex) { | ||
IndexView index = combinedIndex.getIndex(); | ||
|
||
String[] dtos = index.getKnownClasses().stream() | ||
.map(ci -> ci.name().toString()) | ||
//todo validate which are necessary | ||
.filter(n -> n.startsWith("org.apache.kafka.connect.json") || n.startsWith("io.debezium.connector") | ||
|| n.startsWith("io.debezium.embedded")) | ||
.sorted() | ||
.toArray(String[]::new); | ||
|
||
return new ReflectiveClassBuildItem(false, true, dtos); | ||
} | ||
|
||
@BuildStep | ||
void addDependencies(BuildProducer<IndexDependencyBuildItem> indexDependency) { | ||
indexDependency.produce(new IndexDependencyBuildItem("org.apache.kafka", "connect-json")); | ||
indexDependency.produce(new IndexDependencyBuildItem("io.debezium", "debezium-connector-postgres")); | ||
indexDependency.produce(new IndexDependencyBuildItem("io.debezium", "debezium-embedded")); | ||
} | ||
|
||
@Record(ExecutionTime.STATIC_INIT) | ||
@BuildStep | ||
CamelRuntimeBeanBuildItem debeziumPostgresComponent(BeanContainerBuildItem beanContainer, | ||
DebeziumPostgresRecorder recorder) { | ||
return new CamelRuntimeBeanBuildItem( | ||
"debezium-postgres", | ||
DebeziumPostgresComponent.class.getName(), | ||
recorder.createDebeziumPostgresComponent(beanContainer.getValue())); | ||
} | ||
|
||
} |
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
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
59 changes: 59 additions & 0 deletions
59
.../org/apache/camel/quarkus/component/debezium/postgres/graal/DebeziumPostgresRecorder.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,59 @@ | ||
/* | ||
* 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.camel.quarkus.component.debezium.postgres.graal; | ||
|
||
import io.quarkus.arc.runtime.BeanContainer; | ||
import io.quarkus.runtime.RuntimeValue; | ||
import io.quarkus.runtime.annotations.Recorder; | ||
import org.apache.camel.component.debezium.DebeziumPostgresComponent; | ||
import org.apache.camel.component.debezium.configuration.ConfigurationValidation; | ||
import org.apache.camel.component.debezium.configuration.PostgresConnectorEmbeddedDebeziumConfiguration; | ||
import org.apache.camel.quarkus.component.debezium.postgres.graal.storage.NativeFileOffsetBackingStore; | ||
|
||
/** | ||
* Recorder initializes configuration with different default method for offsetStore | ||
*/ | ||
@Recorder | ||
public class DebeziumPostgresRecorder { | ||
|
||
public RuntimeValue<DebeziumPostgresComponent> createDebeziumPostgresComponent(BeanContainer container) { | ||
DebeziumPostgresComponent comp = container.instance(DebeziumPostgresComponent.class); | ||
comp.setConfiguration(new QuarkusPostgresConnectorEmbeddedDebeziumConfiguration()); | ||
return new RuntimeValue<>(comp); | ||
} | ||
|
||
static class QuarkusPostgresConnectorEmbeddedDebeziumConfiguration extends PostgresConnectorEmbeddedDebeziumConfiguration { | ||
|
||
public QuarkusPostgresConnectorEmbeddedDebeziumConfiguration() { | ||
//change default value | ||
setOffsetStorage(NativeFileOffsetBackingStore.class.getName()); | ||
} | ||
|
||
@Override | ||
protected ConfigurationValidation validateConnectorConfiguration() { | ||
ConfigurationValidation validation = super.validateConnectorConfiguration(); | ||
// check for offsetStorageFileName | ||
if (validation.isValid() && getOffsetStorage().equals(NativeFileOffsetBackingStore.class.getName()) | ||
&& isFieldValueNotSet(getOffsetStorageFileName())) { | ||
return ConfigurationValidation.notValid(String | ||
.format("Required field 'offsetStorageFileName' must be set since 'offsetStorage' is set to '%s'", | ||
NativeFileOffsetBackingStore.class.getName())); | ||
} | ||
return validation; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...el/quarkus/component/debezium/postgres/graal/SubstituteEmbeddedDebeziumConfiguration.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,28 @@ | ||
/* | ||
* 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.camel.quarkus.component.debezium.postgres.graal; | ||
|
||
import com.oracle.svm.core.annotate.Alias; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
import org.apache.camel.quarkus.component.debezium.postgres.graal.storage.NativeFileOffsetBackingStore; | ||
|
||
@TargetClass(org.apache.camel.component.debezium.configuration.EmbeddedDebeziumConfiguration.class) | ||
final class SubstituteEmbeddedDebeziumConfiguration { | ||
|
||
@Alias | ||
private String offsetStorage = NativeFileOffsetBackingStore.class.getName(); | ||
} |
35 changes: 35 additions & 0 deletions
35
...in/java/org/apache/camel/quarkus/component/debezium/postgres/graal/SubstituteMetrics.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,35 @@ | ||
/* | ||
* 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.camel.quarkus.component.debezium.postgres.graal; | ||
|
||
import com.oracle.svm.core.annotate.Substitute; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
import org.slf4j.Logger; | ||
|
||
@TargetClass(io.debezium.metrics.Metrics.class) | ||
final class SubstituteMetrics { | ||
|
||
@Substitute | ||
public synchronized void register(Logger logger) { | ||
logger.debug("Metrics are not registered in native mode."); | ||
} | ||
|
||
@Substitute | ||
public final void unregister(Logger logger) { | ||
logger.debug("Metrics are not unregistered in native mode."); | ||
} | ||
} |
Oops, something went wrong.