Skip to content
Snippets Groups Projects
Commit 109488d4 authored by Britta Heymann's avatar Britta Heymann
Browse files

Add asserts for single recipient assumptions

refs #40
parent 2fe5396c
No related branches found
No related tags found
1 merge request!8WIP: Broadcast messages in application layer
Pipeline #
......@@ -116,6 +116,7 @@ public class EpidemicOracleRouter extends ActiveRouter {
if (m.isFinalRecipient(this.getHost())) {
for (EpidemicOracleRouter r : allRouters) {
if (r != this && r != from.getRouter()) {
this.ensureMessageHasSingleRecipient(m);
r.removeDeliveredMessage(id);
}
}
......@@ -156,10 +157,20 @@ public class EpidemicOracleRouter extends ActiveRouter {
/* was the message delivered to the final recipient? */
if (m.isFinalRecipient(con.getOtherNode(getHost()))) {
this.ensureMessageHasSingleRecipient(m);
this.deleteMessage(m.getId(), false);
}
}
/**
* Ensures that the given message only has a single recipient.
* @param msg Message to check.
*/
private void ensureMessageHasSingleRecipient(Message msg) {
assert msg instanceof OneToOneMessage :
  • Contributor

    MINOR Make this line start at column 9. rule

  • Please register or sign in to reply
"EpidemicOracleRouter only works with one to one messages";
}
@Override
public void update() {
/* nothing to do; all transfers are started only when new connections
......
......@@ -217,6 +217,7 @@ public class MaxPropRouter extends ActiveRouter {
/* was the message delivered to the final recipient? */
if (m.isFinalRecipient(recipient)) {
this.ensureMessageHasSingleRecipient(m);
this.ackedMessageIds.add(m.getId()); // yes, add to ACKed messages
this.deleteMessage(m.getId(), false); // delete from buffer
}
......@@ -459,6 +460,15 @@ public class MaxPropRouter extends ActiveRouter {
return (OneToOneMessage) msg;
}
/**
* Ensures that the given message only has a single recipient.
* @param msg Message to check.
*/
private void ensureMessageHasSingleRecipient(Message msg) {
assert msg instanceof OneToOneMessage :
"MaxPropRouter only works with one to one messages";
}
/**
* Message comparator for the MaxProp routing module.
* Messages that have a hop count smaller than the given
......
......@@ -353,6 +353,7 @@ public class MaxPropRouterWithEstimation extends ActiveRouter {
Message m = con.getMessage();
/* was the message delivered to the final recipient? */
if (m.isFinalRecipient(con.getOtherNode(getHost()))) {
this.ensureMessageHasSingleRecipient(m);
this.ackedMessageIds.add(m.getId()); // yes, add to ACKed messages
this.deleteMessage(m.getId(), false); // delete from buffer
}
......@@ -573,10 +574,19 @@ public class MaxPropRouterWithEstimation extends ActiveRouter {
*/
private OneToOneMessage castMessageToOneToOne(Message msg) {
assert msg instanceof OneToOneMessage :
"MaxPropRouter only works with one to one messages";
"MaxPropRouterWithEstimation only works with one to one messages";
return (OneToOneMessage) msg;
}
/**
* Ensures that the given message only has a single recipient.
* @param msg Message to check.
*/
private void ensureMessageHasSingleRecipient(Message msg) {
assert msg instanceof OneToOneMessage :
"MaxPropRouterWithEstimation only works with one to one messages";
}
/**
* Message comparator for the MaxProp routing module.
* Messages that have a hop count smaller than the given
......
  • Contributor
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment