Dev #65
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user