Skip to content

Commit

Permalink
improvement: Harmonize minimal setup (#2134)
Browse files Browse the repository at this point in the history
* improvement: Rename core-nats to core-minimal module, add MQTT as protocol

* Improve exception logging, remove startup check

* Fix checkstyle
  • Loading branch information
dominikriemer authored Nov 5, 2023
1 parent 55a0d0e commit 5a6beba
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ jobs:
push: true
tags: ${{ env.DOCKERHUB_APACHE_REPO }}/backend:${{ env.MVN_VERSION }}

- name: Build and Push Docker Backend Nats Image
- name: Build and Push Docker Core Minimal Image
uses: docker/build-push-action@v5
with:
context: ./streampipes-service-core-nats
context: ./streampipes-service-core-minimal
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7
push: true
tags: ${{ env.DOCKERHUB_APACHE_REPO }}/backend-nats:${{ env.MVN_VERSION }}
tags: ${{ env.DOCKERHUB_APACHE_REPO }}/backend-minimal:${{ env.MVN_VERSION }}

- name: Build UI
working-directory: ./ui
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@
<module>streampipes-serializers-json</module>
<module>streampipes-service-base</module>
<module>streampipes-service-core</module>
<module>streampipes-service-core-nats</module>
<module>streampipes-service-core-minimal</module>
<module>streampipes-service-discovery</module>
<module>streampipes-service-discovery-consul</module>
<module>streampipes-service-discovery-api</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<version>0.93.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-messaging-mqtt</artifactId>
<version>0.93.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-processors-filters-jvm</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.streampipes.extensions.connectors.plc.PlcConnectorsModuleExport;
import org.apache.streampipes.extensions.management.model.SpServiceDefinition;
import org.apache.streampipes.extensions.management.model.SpServiceDefinitionBuilder;
import org.apache.streampipes.messaging.mqtt.SpMqttProtocolFactory;
import org.apache.streampipes.messaging.nats.SpNatsProtocolFactory;
import org.apache.streampipes.processors.changedetection.jvm.ChangeDetectionExtensionModuleExport;
import org.apache.streampipes.processors.enricher.jvm.EnricherExtensionModuleExport;
Expand Down Expand Up @@ -79,7 +80,8 @@ public SpServiceDefinition provideServiceDefinition() {
new SmileDataFormatFactory(),
new FstDataFormatFactory())
.registerMessagingProtocols(
new SpNatsProtocolFactory()
new SpNatsProtocolFactory(),
new SpMqttProtocolFactory()
)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ private List<ExtensionsServiceEndpointItem> getEndpointItems(ExtensionsServiceEn
.readValue(result, new TypeReference<>() {
});
} catch (IOException e1) {
logger.warn("Processing Element Descriptions could not be fetched from endpoint: " + e.getEndpointUrl(), e1);
logger.warn(
"Processing Element Descriptions could not be fetched from endpoint {}: {} ",
e.getEndpointUrl(),
e1.getMessage()
);
return Collections.emptyList();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void checkServiceHealth(SpServiceRegistration service) {
try {
var request = ExtensionServiceExecutions.extServiceGetRequest(healthCheckUrl);
var response = request.execute();
if (response.returnResponse().getStatusLine().getStatusCode() != HttpStatus.SC_OK && !isStarting(service)) {
if (response.returnResponse().getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
processUnhealthyService(service);
} else {
if (service.getStatus() == SpServiceStatus.UNHEALTHY) {
Expand All @@ -68,10 +68,6 @@ private void checkServiceHealth(SpServiceRegistration service) {
}
}

private boolean isStarting(SpServiceRegistration service) {
return service.getStatus() == SpServiceStatus.REGISTERED || service.getStatus() == SpServiceStatus.MIGRATING;
}

private void processUnhealthyService(SpServiceRegistration service) {
if (service.getStatus() == SpServiceStatus.HEALTHY) {
serviceRegistrationManager.applyServiceStatus(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

FROM eclipse-temurin:17-jre-focal

COPY target/streampipes-core-nats.jar /streampipes-core.jar
COPY target/streampipes-core-minimal.jar /streampipes-core.jar

ENTRYPOINT ["java", "-jar", "/streampipes-core.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<version>0.93.0-SNAPSHOT</version>
</parent>

<artifactId>streampipes-service-core-nats</artifactId>
<artifactId>streampipes-service-core-minimal</artifactId>

<dependencies>
<dependency>
Expand All @@ -40,10 +40,6 @@
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-messaging-jms</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-messaging-mqtt</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-messaging-kafka</artifactId>
Expand All @@ -54,6 +50,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-messaging-mqtt</artifactId>
<version>0.93.0-SNAPSHOT</version>
</dependency>
</dependencies>

<build>
Expand All @@ -67,7 +68,7 @@
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>org.apache.streampipes.service.core.nats.StreamPipesCoreApplicationNats
<mainClass>org.apache.streampipes.service.core.minimal.StreamPipesCoreApplicationMinimal
</mainClass>
</configuration>
</execution>
Expand All @@ -88,7 +89,7 @@
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
<finalName>streampipes-core-nats</finalName>
<finalName>streampipes-core-minimal</finalName>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
*
*/

package org.apache.streampipes.service.core.nats;
package org.apache.streampipes.service.core.minimal;

import org.apache.streampipes.messaging.mqtt.SpMqttProtocolFactory;
import org.apache.streampipes.messaging.nats.SpNatsProtocolFactory;
import org.apache.streampipes.rest.security.SpPermissionEvaluator;
import org.apache.streampipes.service.core.StreamPipesCoreApplication;
Expand All @@ -42,12 +43,13 @@
SpPermissionEvaluator.class
})
@ComponentScan({"org.apache.streampipes.rest.*"})
public class StreamPipesCoreApplicationNats extends StreamPipesCoreApplication {
public class StreamPipesCoreApplicationMinimal extends StreamPipesCoreApplication {

public static void main(String[] args) {
var application = new StreamPipesCoreApplicationNats();
var application = new StreamPipesCoreApplicationMinimal();
application.initialize(() -> List.of(
new SpNatsProtocolFactory()
new SpNatsProtocolFactory(),
new SpMqttProtocolFactory()
));
}
}

0 comments on commit 5a6beba

Please sign in to comment.