Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync main branch with Apache main branch #15

Merged
merged 6 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ private ProcessInstanceStateDataEvent toProcessInstanceStateEvent(ProcessEvent e
.rootProcessId(pi.getRootProcessId())
.rootProcessInstanceId(pi.getRootProcessInstanceId())
.state(event.getProcessInstance().getState())
.businessKey(pi.getBusinessKey())
.slaDueDate(pi.getSlaDueDate());

String securityRoles = (String) event.getProcessInstance().getProcess().getMetaData().get("securityRoles");
Expand Down
40 changes: 40 additions & 0 deletions kogito-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,46 @@
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-common-health</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-common-health</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-common-health</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-jobs-service-health</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-jobs-service-health</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-data-index-health</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-data-index-health</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-springboot-jobs-management</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions kogito-build/kogito-dependencies-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
<version.com.networknt>1.0.86</version.com.networknt>
<version.com.fasterxml.jackson>2.15.2</version.com.fasterxml.jackson>
<version.com.fasterxml.jackson.databind>2.15.2</version.com.fasterxml.jackson.databind>
<version.com.jayway.jsonpath>2.8.0</version.com.jayway.jsonpath>
<version.com.jayway.jsonpath>2.9.0</version.com.jayway.jsonpath>
<version.net.minidev.jsonsmart>2.4.10</version.net.minidev.jsonsmart>
<version.net.thisptr.jackson-jq>1.0.0-preview.20220705</version.net.thisptr.jackson-jq>
<version.io.quarkiverse.jackson-jq>2.0.1</version.io.quarkiverse.jackson-jq>
<version.io.quarkiverse.openapi.generator>2.2.15</version.io.quarkiverse.openapi.generator>
<version.io.quarkiverse.openapi.generator>2.3.0</version.io.quarkiverse.openapi.generator>
<version.io.quarkiverse.asyncapi>0.2.0</version.io.quarkiverse.asyncapi>
<version.io.quarkiverse.reactivemessaging.http>2.0.2</version.io.quarkiverse.reactivemessaging.http>
<version.io.quarkiverse.embedded.postgresql>0.1.3</version.io.quarkiverse.embedded.postgresql>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
59 changes: 59 additions & 0 deletions quarkus/addons/common/kogito-addons-quarkus-common-health/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-common-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>kogito-addons-quarkus-common-health</artifactId>
<name>kogito-addons-quarkus-common-health</name>
<properties>
<java.module.name>org.kie.kogito.addons.quarkus.common.health</java.module.name>
</properties>

<dependencies>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.health</groupId>
<artifactId>microprofile-health-api</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye.config</groupId>
<artifactId>smallrye-config-core</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-mutiny-vertx-web-client</artifactId>
</dependency>
<!-- Testing dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.kie.kogito.addon.quarkus.common.config;

import java.util.HashSet;
import java.util.Set;

import org.eclipse.microprofile.config.spi.ConfigSource;

public abstract class AbstractAliasConfigSource implements ConfigSource {

protected int ordinal;
protected String configValue;
protected final Set<String> propertyNames = new HashSet<>();

public AbstractAliasConfigSource(Set<String> propertyNames) {
this.propertyNames.addAll(propertyNames);
}

public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}

public void setConfigValue(String configValue) {
this.configValue = configValue;
}

public abstract String getConfigAlias();

@Override
public Set<String> getPropertyNames() {
return propertyNames;
}

@Override
public String getValue(String propertyName) {
return propertyNames.contains(propertyName) ? configValue : null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.kie.kogito.addon.quarkus.common.config;

import java.util.List;

import org.eclipse.microprofile.config.spi.ConfigSource;

import io.smallrye.config.ConfigSourceContext;
import io.smallrye.config.ConfigSourceFactory;
import io.smallrye.config.ConfigValue;

public class AbstractAliasConfigSourceFactory<T extends AbstractAliasConfigSource> implements ConfigSourceFactory {

protected T configSource;

public AbstractAliasConfigSourceFactory(T configSource) {
this.configSource = configSource;
}

@Override
public Iterable<ConfigSource> getConfigSources(ConfigSourceContext context) {
ConfigValue configValue = context.getValue(configSource.getConfigAlias());
String value = configValue.getValue();
if (value == null || value.isEmpty()) {
return List.of();
} else {
configSource.setConfigValue(value);
configSource.setOrdinal(configValue.getSourceOrdinal());
return List.of(configSource);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* 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.kie.kogito.addon.quarkus.common.health;

import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;

import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.HealthCheckResponseBuilder;

import io.vertx.core.http.HttpMethod;
import io.vertx.core.json.JsonObject;
import io.vertx.mutiny.core.Vertx;
import io.vertx.mutiny.core.buffer.Buffer;
import io.vertx.mutiny.ext.web.client.HttpResponse;
import io.vertx.mutiny.ext.web.client.WebClient;

public abstract class AbstractAvailabilityHealthCheck implements HealthCheck {

private static final Duration DEFAULT_TIMEOUT = Duration.ofMillis(500);
private static final int DEFAULT_PORT = 80;

protected String serviceName;

protected String serviceUrl;

protected String healthPath;

protected String checkType;

protected Vertx vertx;

protected WebClient webClient;

protected Duration requestTimeout;

public AbstractAvailabilityHealthCheck() {
// CDI
}

public AbstractAvailabilityHealthCheck(String serviceName, String serviceUrl, String healthPath, String checkType,
Vertx vertx, Duration requestTimeout) {
this.serviceName = serviceName;
this.serviceUrl = serviceUrl;
this.healthPath = healthPath;
this.checkType = checkType;
this.vertx = vertx;
this.requestTimeout = requestTimeout != null ? requestTimeout : DEFAULT_TIMEOUT;
this.webClient = createClient();
}

/**
* facilitates tests.
*/
protected WebClient createClient() {
return WebClient.create(vertx);
}

@Override
public HealthCheckResponse call() {
HealthCheckResponseBuilder builder = HealthCheckResponse.named(serviceName + " Availability - " + checkType).up();
if (serviceUrl == null) {
builder.down().withData("error", serviceName + " url is not configured");
} else {
URL url;
try {
url = new URL(serviceUrl);
HttpResponse<Buffer> response = webClient.request(HttpMethod.GET,
url.getPort() > 0 ? url.getPort() : DEFAULT_PORT,
url.getHost(),
healthPath)
.send()
.await()
.atMost(requestTimeout);
if (response.statusCode() != 200) {
String data = "[" + response.statusCode() + "] - " + response.statusMessage();
builder.down().withData("error", data);
} else {
JsonObject jsonResponse = response.bodyAsJsonObject();
if (jsonResponse == null || !HealthCheckResponse.Status.UP.name().equals(jsonResponse.getString("status"))) {
builder.down();
}
}
} catch (Exception e) {
if (e instanceof MalformedURLException) {
builder.down().withData("error", serviceName + " url configuration error: " + e.getMessage());
} else {
builder.down().withData("error", "[unknown] - " + e.getMessage());
}
}
}
return builder.build();
}
}
Loading
Loading