Skip to content

Commit

Permalink
Add elasticsearch-rest-client native support
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Jun 11, 2024
1 parent 7ec0426 commit f9195b5
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-elasticsearch-rest-client
cqArtifactIdBase: elasticsearch-rest-client
cqNativeSupported: false
cqStatus: Preview
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
cqJvmSince: 3.8.0
cqNativeSince: n/a
cqNativeSince: 3.12.0
cqCamelPartName: elasticsearch-rest-client
cqCamelPartTitle: Elasticsearch Low level Rest Client
cqCamelPartDescription: Perform queries and other operations on Elasticsearch or OpenSearch (uses low-level client).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
= Elasticsearch Low level Rest Client
:linkattrs:
:cq-artifact-id: camel-quarkus-elasticsearch-rest-client
:cq-native-supported: false
:cq-status: Preview
:cq-status-deprecation: Preview
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Perform queries and other operations on Elasticsearch or OpenSearch (uses low-level client).
:cq-deprecated: false
:cq-jvm-since: 3.8.0
:cq-native-since: n/a
:cq-native-since: 3.12.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##3.8.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
[.badge-key]##JVM since##[.badge-supported]##3.8.0## [.badge-key]##Native since##[.badge-supported]##3.12.0##
endif::[]

Perform queries and other operations on Elasticsearch or OpenSearch (uses low-level client).
Expand All @@ -29,6 +29,10 @@ Please refer to the above link for usage and configuration details.
[id="extensions-elasticsearch-rest-client-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-elasticsearch-rest-client[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
Expand Down
1 change: 0 additions & 1 deletion extensions-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<module>dsl-modeline</module>
<module>ehcache</module>
<module>elasticsearch</module>
<module>elasticsearch-rest-client</module>
<module>etcd3</module>
<module>fastjson</module>
<module>flink</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,13 @@
package org.apache.camel.quarkus.component.elasticsearch.rest.client.deployment;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
import org.apache.camel.quarkus.core.JvmOnlyRecorder;
import org.jboss.logging.Logger;

class ElasticsearchRestClientProcessor {

private static final Logger LOG = Logger.getLogger(ElasticsearchRestClientProcessor.class);
private static final String FEATURE = "camel-elasticsearch-rest-client";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

/**
* Remove this once this extension starts supporting the native mode.
*/
@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
recorder.warnJvmInNative(FEATURE); // warn at runtime
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-extensions-jvm</artifactId>
<artifactId>camel-quarkus-extensions</artifactId>
<version>3.12.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

<properties>
<camel.quarkus.jvmSince>3.8.0</camel.quarkus.jvmSince>
<camel.quarkus.nativeSince>3.12.0</camel.quarkus.nativeSince>
</properties>

<dependencies>
Expand Down
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<module>direct</module>
<module>disruptor</module>
<module>dropbox</module>
<module>elasticsearch-rest-client</module>
<module>exec</module>
<module>fhir</module>
<module>file</module>
Expand Down
1 change: 0 additions & 1 deletion integration-tests-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<module>dsl-modeline</module>
<module>ehcache</module>
<module>elasticsearch</module>
<module>elasticsearch-rest-client</module>
<module>etcd3</module>
<module>fastjson</module>
<module>flink</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,32 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.native.enabled>true</quarkus.native.enabled>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.elasticsearch.rest.client.it;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
class ElasticsearchRestClientIT extends ElasticsearchRestClientTest {

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@
import java.util.Base64;
import java.util.Map;

import com.github.dockerjava.api.model.ExposedPort;
import com.github.dockerjava.api.model.HostConfig;
import com.github.dockerjava.api.model.Ports;
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import org.apache.camel.util.CollectionHelper;
import org.eclipse.microprofile.config.ConfigProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.builder.Transferable;
Expand All @@ -58,10 +63,13 @@ public Map<String, String> start() {
exportCertificateCAForClient();

try {
Network elasticSearchNetwork = Network.newNetwork();

container = new GenericContainer<>(ELASTICSEARCH_IMAGE)
.withExposedPorts(ELASTICSEARCH_PORT)
.withLogConsumer(new Slf4jLogConsumer(LOGGER))
.withEnv("discovery.type", "single-node")
.withEnv("http.publish_host", DockerClientFactory.instance().dockerHostIpAddress())
.withEnv("xpack.security.enabled", "true")
.withEnv("xpack.security.transport.ssl.enabled", "true")
.withEnv("xpack.security.transport.ssl.verification_mode", "certificate")
Expand All @@ -78,6 +86,14 @@ public Map<String, String> start() {
.withCopyToContainer(
Transferable.of(Files.readAllBytes(Paths.get("target/certs/elasticsearch-truststore.p12"))),
"/usr/share/elasticsearch/config/certs/elasticsearch-truststore.p12")
.withCreateContainerCmdModifier(createContainerCmd -> {
Ports portBindings = new Ports();
portBindings.bind(ExposedPort.tcp(ELASTICSEARCH_PORT), Ports.Binding.bindPort(ELASTICSEARCH_PORT));
HostConfig hostConfig = HostConfig.newHostConfig()
.withPortBindings(portBindings)
.withNetworkMode(elasticSearchNetwork.getId());
createContainerCmd.withHostConfig(hostConfig);
})
.waitingFor(Wait.forListeningPort());

container.start();
Expand Down
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<module>digitalocean</module>
<module>disruptor</module>
<module>dropbox</module>
<module>elasticsearch-rest-client</module>
<module>exec</module>
<module>fhir</module>
<module>file</module>
Expand Down
1 change: 1 addition & 0 deletions tooling/scripts/test-categories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ group-04:
- debezium
- cassandraql
- couchdb
- elasticsearch-rest-client
- influxdb
- jms-qpid-amqp-client
- jpa
Expand Down

0 comments on commit f9195b5

Please sign in to comment.