Yuta HIGUCHI | 533ec32 | 2014-09-30 13:29:52 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.store.cluster.messaging; |
| 2 | |
| 3 | import static org.onlab.onos.store.cluster.messaging.MessageSubject.AE_REPLY; |
| 4 | |
| 5 | import java.util.Map; |
| 6 | import java.util.Set; |
| 7 | |
| 8 | import org.onlab.onos.cluster.NodeId; |
| 9 | import org.onlab.onos.store.device.impl.VersionedValue; |
| 10 | |
| 11 | import com.google.common.collect.ImmutableMap; |
| 12 | import com.google.common.collect.ImmutableSet; |
| 13 | |
| 14 | public class AntiEntropyReply<ID, VALUE> extends ClusterMessage { |
| 15 | |
| 16 | private final NodeId sender; |
| 17 | private final ImmutableMap<ID, VersionedValue<VALUE>> suggestion; |
| 18 | private final ImmutableSet<ID> request; |
| 19 | |
| 20 | /** |
| 21 | * Creates a reply to anti-entropy message. |
| 22 | * |
| 23 | * @param sender sender of this message |
| 24 | * @param suggestion collection of more recent values, sender had |
| 25 | * @param request Collection of identifiers |
| 26 | */ |
| 27 | public AntiEntropyReply(NodeId sender, |
| 28 | Map<ID, VersionedValue<VALUE>> suggestion, |
| 29 | Set<ID> request) { |
| 30 | super(AE_REPLY); |
| 31 | this.sender = sender; |
| 32 | this.suggestion = ImmutableMap.copyOf(suggestion); |
| 33 | this.request = ImmutableSet.copyOf(request); |
| 34 | } |
| 35 | |
| 36 | public NodeId sender() { |
| 37 | return sender; |
| 38 | } |
| 39 | |
| 40 | public ImmutableMap<ID, VersionedValue<VALUE>> suggestion() { |
| 41 | return suggestion; |
| 42 | } |
| 43 | |
| 44 | public ImmutableSet<ID> request() { |
| 45 | return request; |
| 46 | } |
| 47 | |
| 48 | // Default constructor for serializer |
| 49 | protected AntiEntropyReply() { |
| 50 | super(AE_REPLY); |
| 51 | this.sender = null; |
| 52 | this.suggestion = null; |
| 53 | this.request = null; |
| 54 | } |
| 55 | } |