Merge pull request #62 from SCS-ASSE-FS21-Group1/auction_house_handle_executor_removed_event

Implemented the handling of the mqtt executor removed event
This commit is contained in:
reynisson 2021-11-14 21:07:04 +01:00 committed by GitHub
commit f845440568
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -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());
}
/**

View File

@ -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;

View File

@ -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) {
}
}