Commit 534059a6 authored by Vasilis Katopodis's avatar Vasilis Katopodis
Browse files

Automation component: Handle event in case device not found

parent 4bd4db2e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 AS release
ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
ENV QUARKUS_LAUNCH_DEVMODE="true"
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
+21 −1
Original line number Diff line number Diff line
@@ -41,15 +41,21 @@ public class AutomationServiceImpl implements AutomationService {

    @Override
    public Uni<Device> addDevice(String deviceId) {

        final var deserializedDeviceUni = contextService.getDevice(deviceId);

        deserializedDeviceUni
                .onFailure()
                .recoverWithNull()
                .subscribe()
                .with(
                        device -> {
                            final var id = deviceId;

                            if (device == null) {
                                LOGGER.warnf("%s is null. Ignoring...", device);
                                return;
                            }

                            if (device.isEnabled()) {
                                LOGGER.warnf("%s has already been enabled. Ignoring...", device);
                                return;
@@ -88,11 +94,18 @@ public class AutomationServiceImpl implements AutomationService {
        final var deserializedDeviceUni = contextService.getDevice(deviceId);

        deserializedDeviceUni
                .onFailure()
                .recoverWithNull()
                .subscribe()
                .with(
                        device -> {
                            final var id = deviceId;

                            if (device == null) {
                                LOGGER.warnf("%s is null. Ignoring...", device);
                                return;
                            }

                            if (device.isDisabled()) {
                                LOGGER.warnf("%s has already been disabled. Ignoring...", device);
                                return;
@@ -120,11 +133,18 @@ public class AutomationServiceImpl implements AutomationService {
        final var deserializedDeviceUni = contextService.getDevice(deviceId);

        deserializedDeviceUni
                .onFailure()
                .recoverWithNull()
                .subscribe()
                .with(
                        device -> {
                            final var id = deviceId;

                            if (device == null) {
                                LOGGER.warnf("%s is null. Ignoring...", device);
                                return;
                            }

                            if (!device.isEnabled()) {
                                LOGGER.warnf("Cannot update disabled device %s. Ignoring...", device);
                                return;
+5 −0
Original line number Diff line number Diff line
@@ -15,6 +15,11 @@
automation:
  should-subscribe-to-context-component: true
quarkus:
  package:
    type: mutable-jar
  live-reload:
    password: 1234
    url: http://0.0.0.0:8080
  banner:
    path: teraflow-automation-banner.txt
  grpc:
+27235 −20442

File changed.

Preview size limit exceeded, changes collapsed.

+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ public interface ContextService extends MutinyService {
    
    io.smallrye.mutiny.Uni<context.ContextOuterClass.Topology> getTopology(context.ContextOuterClass.TopologyId request);
    
    io.smallrye.mutiny.Uni<context.ContextOuterClass.TopologyDetails> getTopologyDetails(context.ContextOuterClass.TopologyId request);
    
    io.smallrye.mutiny.Uni<context.ContextOuterClass.TopologyId> setTopology(context.ContextOuterClass.Topology request);
    
    io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeTopology(context.ContextOuterClass.TopologyId request);
@@ -38,6 +40,8 @@ public interface ContextService extends MutinyService {
    
    io.smallrye.mutiny.Uni<context.ContextOuterClass.Empty> removeDevice(context.ContextOuterClass.DeviceId request);
    
    io.smallrye.mutiny.Uni<context.ContextOuterClass.EndPointNameList> listEndPointNames(context.ContextOuterClass.EndPointIdList request);
    
    io.smallrye.mutiny.Uni<context.ContextOuterClass.LinkIdList> listLinkIds(context.ContextOuterClass.Empty request);
    
    io.smallrye.mutiny.Uni<context.ContextOuterClass.LinkList> listLinks(context.ContextOuterClass.Empty request);
Loading