m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas
diff options
context:
space:
mode:
authorMagdalena Grodzińska <mag.grodzinska@gmail.com>2020-01-10 20:51:13 +0100
committerMagdalena Grodzińska <mag.grodzinska@gmail.com>2020-01-10 20:51:13 +0100
commite2cfe0d9643c3a02223a9e9c4f7d6ed29f0e363a (patch)
treed2b2d045de1385a32701e4245709dea835f26149 /src/main/java/pl/edu/mimuw/cloudatlas
parent69fa53941cfa42f3b0f511f6abe549919241123b (diff)
Add setting sender address in udp
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/RemoteGossipGirlMessage.java7
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPServer.java4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/RemoteGossipGirlMessage.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/RemoteGossipGirlMessage.java
index 4c223f5..1d7c0c6 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/RemoteGossipGirlMessage.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/RemoteGossipGirlMessage.java
@@ -2,9 +2,12 @@ package pl.edu.mimuw.cloudatlas.agent.messages;
import pl.edu.mimuw.cloudatlas.model.ValueTime;
+import java.net.InetAddress;
+
public class RemoteGossipGirlMessage extends GossipGirlMessage {
private ValueTime sentTimestamp;
private ValueTime receivedTimestamp;
+ private InetAddress senderAddress;
public RemoteGossipGirlMessage(String messageId, long timestamp, Type type) {
super(messageId, timestamp, type);
@@ -27,4 +30,8 @@ public class RemoteGossipGirlMessage extends GossipGirlMessage {
public ValueTime getReceivedTimestamp() {
return receivedTimestamp;
}
+
+ public InetAddress getSenderAddress() { return senderAddress; }
+
+ public void setSenderAddress(InetAddress senderAddress) { this.senderAddress = senderAddress; }
}
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPServer.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPServer.java
index 94882e4..0c5bc86 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPServer.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPServer.java
@@ -59,7 +59,6 @@ public class UDUPServer implements Runnable {
if (packetNo == 1 && packet.getLength() < this.bufSize) {
msg = this.serializer.deserialize(packetData);
- msg.getContent().setReceivedTimestamp(ValueUtils.currentTime());
System.out.println("UDP received message " + msg.getContent().getMessageId());
} else {
System.out.println("UDP received partial message with transmission id " + transmissionID + " packet no " + packetNo);
@@ -67,6 +66,8 @@ public class UDUPServer implements Runnable {
}
if (msg != null) {
+ msg.getContent().setReceivedTimestamp(ValueUtils.currentTime());
+ msg.getContent().setSenderAddress(packet.getAddress());
sendMessageFurther(msg);
}
}
@@ -137,7 +138,6 @@ public class UDUPServer implements Runnable {
try {
byte[] allPacketData = concatPacketData(transmissionID, newPacketNo, packetData);
msg = this.serializer.deserialize(allPacketData);
- msg.getContent().setReceivedTimestamp(ValueUtils.currentTime());
this.partialPackets.remove(transmissionID);
System.out.println("Kryo put together whole transmission for msg " + msg.getContent().getMessageId());
} catch (Error | Exception e) {