From 1b7395ba0d04f244b530978bd27edd558ff47e5a Mon Sep 17 00:00:00 2001 From: reynisson Date: Sun, 14 Nov 2021 19:26:19 +0100 Subject: [PATCH] Implemented the handling of the mqtt executor removed event --- .../in/messaging/mqtt/AuctionEventsMqttDispatcher.java | 1 + .../mqtt/ExecutorRemovedEventListenerMqttAdapter.java | 8 +++++--- .../application/handler/ExecutorRemovedHandler.java | 3 --- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/adapter/in/messaging/mqtt/AuctionEventsMqttDispatcher.java b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/adapter/in/messaging/mqtt/AuctionEventsMqttDispatcher.java index 3e55d5e..7d30453 100644 --- a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/adapter/in/messaging/mqtt/AuctionEventsMqttDispatcher.java +++ b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/adapter/in/messaging/mqtt/AuctionEventsMqttDispatcher.java @@ -27,6 +27,7 @@ public class AuctionEventsMqttDispatcher { // TODO: Register here your topics and event listener adapters private void initRouter() { router.put("ch/unisg/tapas/executors/added", new ExecutorAddedEventListenerMqttAdapter()); + router.put("ch/unisg/tapas/executors/removed", new ExecutorRemovedEventListenerMqttAdapter()); } /** diff --git a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/adapter/in/messaging/mqtt/ExecutorRemovedEventListenerMqttAdapter.java b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/adapter/in/messaging/mqtt/ExecutorRemovedEventListenerMqttAdapter.java index 087479c..4f4db7a 100644 --- a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/adapter/in/messaging/mqtt/ExecutorRemovedEventListenerMqttAdapter.java +++ b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/adapter/in/messaging/mqtt/ExecutorRemovedEventListenerMqttAdapter.java @@ -11,6 +11,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.eclipse.paho.client.mqttv3.MqttMessage; +import java.net.URI; + /** * Listener that handles events when an executor was removed to this TAPAS application. * @@ -28,14 +30,14 @@ public class ExecutorRemovedEventListenerMqttAdapter extends AuctionEventMqttLis // representation that makes sense in the context of your application. JsonNode data = new ObjectMapper().readTree(payload); - String executorId = data.get("executorId").asText(); + String executorUri = data.get("executorUri").asText(); ExecutorRemovedEvent executorRemovedEvent = new ExecutorRemovedEvent( - new ExecutorRegistry.ExecutorIdentifier(executorId) + new ExecutorRegistry.ExecutorUri(URI.create(executorUri)) ); ExecutorRemovedHandler newExecutorHandler = new ExecutorRemovedHandler(); - newExecutorHandler.handleNewExecutorEvent(executorRemovedEvent); + newExecutorHandler.handleExecutorRemovedEvent(executorRemovedEvent); } catch (JsonProcessingException | NullPointerException e) { LOGGER.error(e.getMessage(), e); return false; diff --git a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/handler/ExecutorRemovedHandler.java b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/handler/ExecutorRemovedHandler.java index f63950d..9a68da1 100644 --- a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/handler/ExecutorRemovedHandler.java +++ b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/handler/ExecutorRemovedHandler.java @@ -16,7 +16,4 @@ public class ExecutorRemovedHandler implements ExecutorRemovedEventHandler { public boolean handleExecutorRemovedEvent(ExecutorRemovedEvent executorRemovedEvent) { return ExecutorRegistry.getInstance().removeExecutor(executorRemovedEvent.getExecutorUri()); } - - public void handleNewExecutorEvent(ExecutorRemovedEvent executorRemovedEvent) { - } } -- 2.45.1