blob: 94c20eaa7366c674c8f82da5c15fd341ec895491 [file] [log] [blame]
Yuta HIGUCHI533ec322014-09-30 13:29:52 -07001package org.onlab.onos.store.cluster.messaging;
2
3import static org.onlab.onos.store.cluster.messaging.MessageSubject.AE_REPLY;
4
5import java.util.Map;
6import java.util.Set;
7
8import org.onlab.onos.cluster.NodeId;
9import org.onlab.onos.store.device.impl.VersionedValue;
10
11import com.google.common.collect.ImmutableMap;
12import com.google.common.collect.ImmutableSet;
13
Yuta HIGUCHIeeb75a02014-09-30 15:58:08 -070014/**
15 * Anti-Entropy reply message.
16 * <p>
17 * Message to send in reply to advertisement or another reply.
18 * Suggest to the sender about the more up-to-date data this node has,
19 * and request for more recent data that the receiver has.
20 */
Yuta HIGUCHI533ec322014-09-30 13:29:52 -070021public class AntiEntropyReply<ID, VALUE> extends ClusterMessage {
22
23 private final NodeId sender;
24 private final ImmutableMap<ID, VersionedValue<VALUE>> suggestion;
25 private final ImmutableSet<ID> request;
26
27 /**
28 * Creates a reply to anti-entropy message.
29 *
30 * @param sender sender of this message
31 * @param suggestion collection of more recent values, sender had
32 * @param request Collection of identifiers
33 */
34 public AntiEntropyReply(NodeId sender,
35 Map<ID, VersionedValue<VALUE>> suggestion,
36 Set<ID> request) {
37 super(AE_REPLY);
38 this.sender = sender;
39 this.suggestion = ImmutableMap.copyOf(suggestion);
40 this.request = ImmutableSet.copyOf(request);
41 }
42
43 public NodeId sender() {
44 return sender;
45 }
46
47 public ImmutableMap<ID, VersionedValue<VALUE>> suggestion() {
48 return suggestion;
49 }
50
51 public ImmutableSet<ID> request() {
52 return request;
53 }
54
55 // Default constructor for serializer
56 protected AntiEntropyReply() {
57 super(AE_REPLY);
58 this.sender = null;
59 this.suggestion = null;
60 this.request = null;
61 }
62}