Skip to content

Commit

Permalink
Split services/command-router module into services/command-router-bas…
Browse files Browse the repository at this point in the history
…e and services/command-router-infinispan. Unit tests and integration tests run.
  • Loading branch information
StFS committed Apr 3, 2024
1 parent d29a8a1 commit 8766a49
Show file tree
Hide file tree
Showing 50 changed files with 153 additions and 77 deletions.
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ quarkus.vertx.max-event-loop-execute-time=${max.event-loop.execute-time:20000}
</dependency>
<dependency>
<groupId>org.eclipse.hono</groupId>
<artifactId>hono-service-command-router</artifactId>
<artifactId>hono-service-command-router-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@
SPDX-License-Identifier: EPL-2.0
-->
<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/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.hono</groupId>
<artifactId>hono-services-parent</artifactId>
<version>2.6.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>hono-service-command-router</artifactId>
<name>Hono Command Router</name>
<description>A Quarkus based implementation of Hono's Command Router API that is using Infinispan for storing data.</description>
<artifactId>hono-service-command-router-base</artifactId>
<name>Hono Service Command Router Base</name>
<description>Base classes for implementing a Quarkus based Hono Command Router</description>

<dependencies>
<dependency>
<groupId>org.eclipse.hono</groupId>
<artifactId>client-device-connection-infinispan</artifactId>
<artifactId>client-device-connection-base</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.hono</groupId>
<artifactId>hono-client-command-amqp</artifactId>
Expand Down Expand Up @@ -104,58 +105,4 @@

</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<build>
<labels>
<implemented.api.1>Command Router</implemented.api.1>
</labels>
<ports>
<port>5671</port>
<port>5672</port>
<port>${health.check.port}</port>
</ports>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</pluginManagement>

</build>

<profiles>
<profile>
<id>build-docker-image</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>build-native-image</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,15 @@
import io.vertx.core.buffer.Buffer;
import io.vertx.ext.healthchecks.HealthCheckHandler;
import io.vertx.proton.sasl.ProtonSaslAuthenticatorFactory;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

/**
* The Quarkus based Command Router main application class.
*/
@ApplicationScoped
public class Application extends NotificationSupportingServiceApplication {
public abstract class AbstractApplication extends NotificationSupportingServiceApplication {

private static final String COMPONENT_NAME = "Hono Command Router";
private static final Logger LOG = LoggerFactory.getLogger(Application.class);

@Inject
DeviceConnectionInfo deviceConnectionInfo;
private static final Logger LOG = LoggerFactory.getLogger(AbstractApplication.class);

@Inject
ProtonSaslAuthenticatorFactory saslAuthenticatorFactory;
Expand Down Expand Up @@ -349,16 +344,23 @@ public void registerReadinessChecks(final HealthCheckHandler handler) {
return endpoint;
}

/**
* Gets the repository storing device connection info.
*
* @return The device connection info repository.
*/
protected abstract DeviceConnectionInfo getDeviceConnectionInfo();

private CommandRouterService commandRouterService() {
final DeviceRegistrationClient registrationClient = registrationClient();
final TenantClient tenantClient = tenantClient();

final var commandTargetMapper = CommandTargetMapper.create(registrationClient, deviceConnectionInfo, tracer);
final var commandTargetMapper = CommandTargetMapper.create(registrationClient, getDeviceConnectionInfo(), tracer);
return new CommandRouterServiceImpl(
amqpServerProperties,
registrationClient,
tenantClient,
deviceConnectionInfo,
getDeviceConnectionInfo(),
commandConsumerFactoryProvider(tenantClient, commandTargetMapper),
eventSenderProvider(),
adapterInstanceStatusService,
Expand Down
92 changes: 92 additions & 0 deletions services/command-router-infinispan/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<!--
Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation
See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0
SPDX-License-Identifier: EPL-2.0
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.hono</groupId>
<artifactId>hono-services-parent</artifactId>
<version>2.6.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>hono-service-command-router-infinispan</artifactId>
<name>Hono Infinispan Based Command Router</name>
<description>A Quarkus based implementation of Hono's Command Router API that is using Infinispan for storing data.</description>

<dependencies>
<dependency>
<groupId>org.eclipse.hono</groupId>
<artifactId>hono-service-command-router-base</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.hono</groupId>
<artifactId>client-device-connection-infinispan</artifactId>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<build>
<labels>
<implemented.api.1>Command Router</implemented.api.1>
</labels>
<ports>
<port>5671</port>
<port>5672</port>
<port>${health.check.port}</port>
</ports>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</pluginManagement>

</build>

<profiles>
<profile>
<id>build-docker-image</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>build-native-image</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hono.commandrouter.infinispan.app;

import org.eclipse.hono.commandrouter.app.AbstractApplication;
import org.eclipse.hono.deviceconnection.common.DeviceConnectionInfo;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

/**
* The Quarkus based Command Router main application class (Infinispan variant).
*/
@ApplicationScoped
public class Application extends AbstractApplication {

@Inject
DeviceConnectionInfo deviceConnectionInfo;

@Override
protected DeviceConnectionInfo getDeviceConnectionInfo() {
return deviceConnectionInfo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/


package org.eclipse.hono.commandrouter.app;
package org.eclipse.hono.commandrouter.infinispan.app;

import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -55,9 +55,9 @@
* on whether a remote cache config with a non-empty server list is used or not.
*/
@ApplicationScoped
public class DeviceConnectionInfoProducer {
public class InfinispanDeviceConnectionInfoProducer {

private static final Logger LOG = LoggerFactory.getLogger(DeviceConnectionInfoProducer.class);
private static final Logger LOG = LoggerFactory.getLogger(InfinispanDeviceConnectionInfoProducer.class);

@ConfigProperty(name = "hono.commandRouter.cache.embedded.configurationFile", defaultValue = "/etc/hono/cache-config.xml")
String configFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| |
|_|

Eclipse Hono Command Router
Eclipse Hono Infinispan Based Command Router

Go to https://www.eclipse.org/hono for more information.

3 changes: 2 additions & 1 deletion services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
<module>auth</module>
<module>auth-base</module>
<module>base-jdbc</module>
<module>command-router</module>
<module>command-router-base</module>
<module>command-router-infinispan</module>
<module>device-registry-base</module>
<module>device-registry-jdbc</module>
<module>device-registry-mongodb</module>
Expand Down
4 changes: 2 additions & 2 deletions tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
Command Router related properties.
-->
<hono.command-router.config-src>clustered-cache</hono.command-router.config-src>
<hono.command-router.image>hono-service-command-router</hono.command-router.image>
<hono.command-router.image>hono-service-command-router-infinispan</hono.command-router.image>
<hono.command-router.max-mem>300000000</hono.command-router.max-mem>
<hono.command-router.java-options>${default.java-options}</hono.command-router.java-options>
<hono.command-router.native-image-args></hono.command-router.native-image-args>
Expand Down Expand Up @@ -264,7 +264,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.hono</groupId>
<artifactId>hono-service-command-router</artifactId>
<artifactId>hono-service-command-router-base</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down

0 comments on commit 8766a49

Please sign in to comment.