Jonathan Hart | aaa5657 | 2015-01-28 21:56:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Jonathan Hart | 77bdd26 | 2015-02-03 09:07:48 -0800 | [diff] [blame] | 16 | package org.onosproject.store.ecmap; |
Jonathan Hart | aaa5657 | 2015-01-28 21:56:35 -0800 | [diff] [blame] | 17 | |
| 18 | import org.onosproject.cluster.NodeId; |
| 19 | import org.onosproject.store.Timestamp; |
| 20 | |
| 21 | import java.util.Map; |
| 22 | |
| 23 | import static com.google.common.base.Preconditions.checkNotNull; |
| 24 | |
| 25 | /** |
| 26 | * Anti-entropy advertisement message for eventually consistent map. |
| 27 | */ |
| 28 | public class AntiEntropyAdvertisement<K> { |
| 29 | |
| 30 | private final NodeId sender; |
| 31 | private final Map<K, Timestamp> timestamps; |
| 32 | private final Map<K, Timestamp> tombstones; |
| 33 | |
| 34 | /** |
| 35 | * Creates a new anti entropy advertisement message. |
| 36 | * |
| 37 | * @param sender the sender's node ID |
| 38 | * @param timestamps map of item key to timestamp for current items |
| 39 | * @param tombstones map of item key to timestamp for removed items |
| 40 | */ |
| 41 | public AntiEntropyAdvertisement(NodeId sender, |
| 42 | Map<K, Timestamp> timestamps, |
| 43 | Map<K, Timestamp> tombstones) { |
| 44 | this.sender = checkNotNull(sender); |
| 45 | this.timestamps = checkNotNull(timestamps); |
| 46 | this.tombstones = checkNotNull(tombstones); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns the sender's node ID. |
| 51 | * |
| 52 | * @return the sender's node ID |
| 53 | */ |
| 54 | public NodeId sender() { |
| 55 | return sender; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Returns the map of current item timestamps. |
| 60 | * |
| 61 | * @return current item timestamps |
| 62 | */ |
| 63 | public Map<K, Timestamp> timestamps() { |
| 64 | return timestamps; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Returns the map of removed item timestamps. |
| 69 | * |
| 70 | * @return removed item timestamps |
| 71 | */ |
| 72 | public Map<K, Timestamp> tombstones() { |
| 73 | return tombstones; |
| 74 | } |
| 75 | |
| 76 | // For serializer |
| 77 | @SuppressWarnings("unused") |
| 78 | private AntiEntropyAdvertisement() { |
| 79 | this.sender = null; |
| 80 | this.timestamps = null; |
| 81 | this.tombstones = null; |
| 82 | } |
| 83 | } |