Skip to content
Snippets Groups Projects
Commit 9e4e5d71 authored by Simon Spinner's avatar Simon Spinner
Browse files

Implement correcty routing key extraction for sensors.

parent 98d93028
No related branches found
No related tags found
No related merge requests found
...@@ -6,10 +6,11 @@ import java.util.LinkedList; ...@@ -6,10 +6,11 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.Resource;
import edu.kit.ipd.descartes.core.NamedElement; import edu.kit.ipd.descartes.core.CorePackage;
import edu.kit.ipd.descartes.mm.adaptationpoints.AdaptationPointDescriptions; import edu.kit.ipd.descartes.mm.adaptationpoints.AdaptationPointDescriptions;
import edu.kit.ipd.descartes.mm.adaptationpoints.AdaptationpointsFactory; import edu.kit.ipd.descartes.mm.adaptationpoints.AdaptationpointsFactory;
import tools.descartes.prisma.core.MessageBus; import tools.descartes.prisma.core.MessageBus;
...@@ -51,12 +52,18 @@ public abstract class AgentScope extends Scope { ...@@ -51,12 +52,18 @@ public abstract class AgentScope extends Scope {
private final List<NotificationDefinition> notifications = new ArrayList<>(); private final List<NotificationDefinition> notifications = new ArrayList<>();
protected class NotificationDefinition { protected class NotificationDefinition {
private EAttribute routingKey;
private final Class<?> key; private final Class<?> key;
private final String exchange; private final String exchange;
public NotificationDefinition(Class<?> key, String exchange) { public NotificationDefinition(Class<?> key, String exchange) {
this(key, exchange, CorePackage.Literals.NAMED_ELEMENT__NAME);
}
public NotificationDefinition(Class<?> key, String exchange, EAttribute routingKey) {
this.key = key; this.key = key;
this.exchange = exchange; this.exchange = exchange;
this.routingKey = routingKey;
} }
public void create() { public void create() {
...@@ -67,13 +74,13 @@ public abstract class AgentScope extends Scope { ...@@ -67,13 +74,13 @@ public abstract class AgentScope extends Scope {
return key.isInstance(o); return key.isInstance(o);
} }
public void send(String notificationType, Object o) { public void send(String notificationType, EObject o) {
getMessageBus().publishMessage(exchange, getRoutingKey(o), "", getMessageBus().publishMessage(exchange, getRoutingKey(o), "",
new ModelNotification(getModelRepository(), notificationType, key, o)); new ModelNotification(getModelRepository(), notificationType, key, o));
} }
public String getRoutingKey(Object o) { public String getRoutingKey(EObject o) {
return ((NamedElement) o).getName(); return o.eGet(routingKey).toString();
} }
} }
......
package tools.descartes.prisma.core.scopes; package tools.descartes.prisma.core.scopes;
import org.eclipse.emf.ecore.EObject;
import edu.kit.ipd.descartes.mm.resourcelandscape.RuntimeEnvironment; import edu.kit.ipd.descartes.mm.resourcelandscape.RuntimeEnvironment;
import edu.kit.ipd.descartes.mm.runtimeenvironmentclasses.RuntimeEnvironmentClasses; import edu.kit.ipd.descartes.mm.runtimeenvironmentclasses.RuntimeEnvironmentClasses;
import tools.descartes.prisma.core.MessageBus; import tools.descartes.prisma.core.MessageBus;
...@@ -70,7 +72,12 @@ public class LogicalInfrastructureScope extends ContainerScope { ...@@ -70,7 +72,12 @@ public class LogicalInfrastructureScope extends ContainerScope {
} }
}); });
declareNotification( declareNotification(
new NotificationDefinition(Sensor.class, getHypervisorSensorExchange())); new NotificationDefinition(Sensor.class, getHypervisorSensorExchange()) {
@Override
public String getRoutingKey(EObject o) {
return ((Sensor<?>) o).getMetric().getId();
}
});
declareIncomingPort(getHypervisorExchange()); declareIncomingPort(getHypervisorExchange());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment