Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Feb 12, 2024
1 parent 4ef3bf1 commit 2162001
Show file tree
Hide file tree
Showing 131 changed files with 7,039 additions and 7 deletions.
10 changes: 10 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,16 @@
<artifactId>quarkus-hibernate-search-orm-outbox-polling-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-search-standalone-elasticsearch</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-search-standalone-elasticsearch-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public enum Feature {
HIBERNATE_REACTIVE_PANACHE_KOTLIN,
HIBERNATE_REACTIVE_REST_DATA_PANACHE,
HIBERNATE_SEARCH_ELASTICSEARCH,
HIBERNATE_SEARCH_STANDALONE_ELASTICSEARCH,
HIBERNATE_VALIDATOR,
INFINISPAN_CLIENT,
INFINISPAN_EMBEDDED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import io.quarkus.hibernate.orm.PersistenceUnit;

/**
* CDI qualifier for beans representing an "extension" of Hibernate Search in a given persistence unit,
* CDI qualifier for beans representing an "extension" of Hibernate Search
* in a given persistence unit of Hibernate ORM,
* i.e. beans injected into Hibernate Search as part of its configuration.
* <p>
* See the reference documentation for information about extensions that supports this annotation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import io.quarkus.deployment.builditem.AdditionalIndexedClassesBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.hibernate.orm.deployment.spi.AdditionalJpaModelBuildItem;
import io.quarkus.hibernate.search.orm.elasticsearch.deployment.HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem;
import io.quarkus.hibernate.search.orm.elasticsearch.deployment.HibernateSearchOrmElasticsearchPersistenceUnitConfiguredBuildItem;
import io.quarkus.hibernate.search.orm.elasticsearch.deployment.HibernateSearchEnabled;
import io.quarkus.hibernate.search.orm.elasticsearch.deployment.HibernateSearchIntegrationRuntimeConfiguredBuildItem;
import io.quarkus.hibernate.search.orm.elasticsearch.deployment.HibernateSearchIntegrationStaticConfiguredBuildItem;
Expand Down Expand Up @@ -45,9 +45,9 @@ void registerInternalModel(BuildProducer<AdditionalIndexedClassesBuildItem> addi
@Record(ExecutionTime.STATIC_INIT)
void setStaticConfig(HibernateSearchOutboxPollingRecorder recorder,
HibernateSearchOutboxPollingBuildTimeConfig buildTimeConfig,
List<HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem> configuredPersistenceUnits,
List<HibernateSearchOrmElasticsearchPersistenceUnitConfiguredBuildItem> configuredPersistenceUnits,
BuildProducer<HibernateSearchIntegrationStaticConfiguredBuildItem> staticConfigured) {
for (HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem configuredPersistenceUnit : configuredPersistenceUnits) {
for (HibernateSearchOrmElasticsearchPersistenceUnitConfiguredBuildItem configuredPersistenceUnit : configuredPersistenceUnits) {
if (!isUsingOutboxPolling(configuredPersistenceUnit)) {
continue;
}
Expand All @@ -65,9 +65,9 @@ void setStaticConfig(HibernateSearchOutboxPollingRecorder recorder,
@Record(ExecutionTime.RUNTIME_INIT)
void setRuntimeConfig(HibernateSearchOutboxPollingRecorder recorder,
HibernateSearchOutboxPollingRuntimeConfig runtimeConfig,
List<HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem> configuredPersistenceUnits,
List<HibernateSearchOrmElasticsearchPersistenceUnitConfiguredBuildItem> configuredPersistenceUnits,
BuildProducer<HibernateSearchIntegrationRuntimeConfiguredBuildItem> runtimeConfigured) {
for (HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem configuredPersistenceUnit : configuredPersistenceUnits) {
for (HibernateSearchOrmElasticsearchPersistenceUnitConfiguredBuildItem configuredPersistenceUnit : configuredPersistenceUnits) {
if (!isUsingOutboxPolling(configuredPersistenceUnit)) {
continue;
}
Expand All @@ -78,7 +78,7 @@ void setRuntimeConfig(HibernateSearchOutboxPollingRecorder recorder,
}
}

private boolean isUsingOutboxPolling(HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem persistenceUnit) {
private boolean isUsingOutboxPolling(HibernateSearchOrmElasticsearchPersistenceUnitConfiguredBuildItem persistenceUnit) {
HibernateSearchElasticsearchBuildTimeConfigPersistenceUnit puConfig = persistenceUnit.getBuildTimeConfig();
if (puConfig == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-hibernate-search-standalone-elasticsearch-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-hibernate-search-standalone-elasticsearch-deployment</artifactId>
<name>Quarkus - Hibernate Search - Standalone + Elasticsearch - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-elasticsearch-rest-client-common-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-search-standalone-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-dev-ui-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-deployment-spi</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>


<profiles>
<profile>
<id>test-elasticsearch</id>
<activation>
<property>
<name>test-containers</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>docker-elasticsearch</id>
<activation>
<property>
<name>start-containers</name>
</property>
</activation>
<properties>
<elasticsearch.hosts>localhost:9200</elasticsearch.hosts>
<elasticsearch.protocol>http</elasticsearch.protocol>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<name>${elasticsearch.image}</name>
<alias>elasticsearch</alias>
<run>
<env>
<discovery.type>single-node</discovery.type>
<xpack.security.enabled>false</xpack.security.enabled>
<ES_JAVA_OPTS>-Xms512m -Xmx512m</ES_JAVA_OPTS>
<!-- Disable disk-based shard allocation thresholds:
in a single-node setup they just don't make sense,
and lead to problems on large disks with little space left.
See https://www.elastic.co/guide/en/elasticsearch/reference/8.8/modules-cluster.html#disk-based-shard-allocation
-->
<cluster.routing.allocation.disk.threshold_enabled>false</cluster.routing.allocation.disk.threshold_enabled>
<!-- Disable some features that are not needed in our tests and just slow down startup -->
<xpack.profiling.enabled>false</xpack.profiling.enabled>
<xpack.monitoring.templates.enabled>false</xpack.monitoring.templates.enabled>
<xpack.ml.enabled>false</xpack.ml.enabled>
<xpack.watcher.enabled>false</xpack.watcher.enabled>
<xpack.ent_search.enabled>false</xpack.ent_search.enabled>
<stack.templates.enabled>false</stack.templates.enabled>
<cluster.deprecation_indexing.enabled>false</cluster.deprecation_indexing.enabled>
<indices.lifecycle.history_index_enabled>false</indices.lifecycle.history_index_enabled>
<slm.history_index_enabled>false</slm.history_index_enabled>
</env>
<ports>
<port>9200:9200</port>
</ports>
<log>
<prefix>Elasticsearch: </prefix>
<date>default</date>
<color>cyan</color>
</log>
<wait>
<http>
<url>http://localhost:9200</url>
<method>GET</method>
<status>200</status>
</http>
<time>30000</time>
</wait>
</run>
</image>
</images>
<allContainers>true</allContainers>
</configuration>
<executions>
<execution>
<id>docker-start</id>
<phase>process-test-classes</phase>
<goals>
<goal>stop</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker-stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>docker-prune</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${docker-prune.location}</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkus.hibernate.search.standalone.elasticsearch.deployment;

import io.quarkus.deployment.Feature;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.FeatureBuildItem;

// Executed even if the extension is disabled, see https://github.com/quarkusio/quarkus/pull/26966/
class HibernateSearchStandaloneAlwaysEnabledProcessor {

@BuildStep
public FeatureBuildItem featureBuildItem() {
return new FeatureBuildItem(Feature.HIBERNATE_SEARCH_ELASTICSEARCH);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.quarkus.hibernate.search.standalone.elasticsearch.deployment;

import java.util.Map;
import java.util.Set;

import io.quarkus.builder.item.SimpleBuildItem;

public final class HibernateSearchStandaloneConfiguredBuildItem extends SimpleBuildItem {

private final Set<String> backendNamesForIndexedEntities;
private final Map<String, Set<String>> backendAndIndexNamesForSearchExtensions;
private final Map<String, Object> preBootProperties;

public HibernateSearchStandaloneConfiguredBuildItem(Set<String> backendNamesForIndexedEntities,
Map<String, Set<String>> backendAndIndexNamesForSearchExtensions,
Map<String, Object> preBootProperties) {
this.backendNamesForIndexedEntities = backendNamesForIndexedEntities;
this.backendAndIndexNamesForSearchExtensions = backendAndIndexNamesForSearchExtensions;
this.preBootProperties = preBootProperties;
}

public Set<String> getBackendNamesForIndexedEntities() {
return backendNamesForIndexedEntities;
}

public Map<String, Set<String>> getBackendAndIndexNamesForSearchExtensions() {
return backendAndIndexNamesForSearchExtensions;
}

public Map<String, Object> getPreBootProperties() {
return preBootProperties;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.quarkus.hibernate.search.standalone.elasticsearch.deployment;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneRecorder;
import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneRuntimeConfig;

@BuildSteps(onlyIfNot = HibernateSearchStandaloneEnabled.class)
class HibernateSearchStandaloneDisabledProcessor {
@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
public void disableHibernateSearch(HibernateSearchStandaloneRecorder recorder,
HibernateSearchStandaloneRuntimeConfig runtimeConfig) {
recorder.checkNoExplicitActiveTrue(runtimeConfig);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.hibernate.search.standalone.elasticsearch.deployment;

import java.util.function.BooleanSupplier;

import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneBuildTimeConfig;

/**
* Supplier that can be used to only run build steps
* if the Hibernate Search extension is enabled.
*/
public class HibernateSearchStandaloneEnabled implements BooleanSupplier {

private final HibernateSearchStandaloneBuildTimeConfig config;

HibernateSearchStandaloneEnabled(HibernateSearchStandaloneBuildTimeConfig config) {
this.config = config;
}

@Override
public boolean getAsBoolean() {
return config.enabled();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.quarkus.hibernate.search.standalone.elasticsearch.deployment;

import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneBuildTimeConfig;
import io.quarkus.hibernate.search.standalone.elasticsearch.management.HibernateSearchStandaloneManagementConfig;

/**
* Supplier that can be used to only run build steps
* if the Hibernate Search extension and its management is enabled.
*/
public class HibernateSearchStandaloneManagementEnabled extends HibernateSearchStandaloneEnabled {

private final HibernateSearchStandaloneManagementConfig config;

HibernateSearchStandaloneManagementEnabled(HibernateSearchStandaloneBuildTimeConfig config,
HibernateSearchStandaloneManagementConfig managementConfig) {
super(config);
this.config = managementConfig;
}

@Override
public boolean getAsBoolean() {
return super.getAsBoolean() && config.enabled();
}

}
Loading

0 comments on commit 2162001

Please sign in to comment.