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

Update to new notification definitions.

parent 32e9a0e8
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,6 @@ package tools.descartes.prisma.core.scopes;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import edu.kit.ipd.descartes.mm.resourcelandscape.ComputeNode;
......@@ -98,10 +97,18 @@ public class PhysicalInfrastructureScope extends InfrastructureScope {
@Override
protected void createMessageExchanges() {
super.createMessageExchanges();
getMessageBus().createExchange(getComputeNodeExchange(), ExchangeType.DIRECT);
getMessageBus().createExchange(getStorageNodeExchange(), ExchangeType.DIRECT);
getMessageBus().createExchange(getHypervisorExchange(), ExchangeType.DIRECT);
declareNotification(new NotificationDefinition(ComputeNode.class, getComputeNodeExchange(), ExchangeType.DIRECT));
declareNotification(new NotificationDefinition(StorageNode.class, getStorageNodeExchange(), ExchangeType.DIRECT));
declareNotification(new NotificationDefinition(RuntimeEnvironment.class, getHypervisorExchange(), ExchangeType.DIRECT) {
@Override
public boolean isActive(Object o) {
if (super.isActive(o)) {
return ((RuntimeEnvironment) o).getOfClass() == RuntimeEnvironmentClasses.HYPERVISOR;
}
return false;
}
});
// Add a queue for delegation of hypervisors to other scopes.
String hypervisorQueueName = getHypervisorExchange() + ".Delegation";
......@@ -110,35 +117,4 @@ public class PhysicalInfrastructureScope extends InfrastructureScope {
getMessageBus().addMessageListener(hypervisorQueueName, new DelegationListener());
}
@Override
public void sendNotifications(String notificationType, EObject object) {
if (object instanceof ComputeNode) {
sendComputeNodeNotification(notificationType, (ComputeNode) object);
}
if (object instanceof StorageNode) {
sendStorageNodeNotification(notificationType, (StorageNode) object);
}
if (object instanceof RuntimeEnvironment) {
RuntimeEnvironment env = (RuntimeEnvironment) object;
if (env.getOfClass() == RuntimeEnvironmentClasses.HYPERVISOR) {
sendHypervisorNotification(notificationType, (RuntimeEnvironment) object);
}
}
}
private void sendComputeNodeNotification(String notificationType, ComputeNode node) {
sendNotificationMessage(getComputeNodeExchange(), node.getName(),
new ModelNotification(getModelRepository(), notificationType, ComputeNode.class, node));
}
private void sendStorageNodeNotification(String notificationType, StorageNode node) {
sendNotificationMessage(getStorageNodeExchange(), node.getName(),
new ModelNotification(getModelRepository(), notificationType, StorageNode.class, node));
}
private void sendHypervisorNotification(String notificationType, RuntimeEnvironment node) {
sendNotificationMessage(getStorageNodeExchange(), node.getName(),
new ModelNotification(getModelRepository(), notificationType, RuntimeEnvironment.class, node));
}
}
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