Committed by
Brian O'Connor
Add a configuration option to vary how heavyweight anti-entropy is.
Change-Id: I57cea61182b3d19deb47608ffb7dd617529ae34c
Showing
1 changed file
with
6 additions
and
8 deletions
| ... | @@ -98,6 +98,7 @@ public class EventuallyConsistentMapImpl<K, V> | ... | @@ -98,6 +98,7 @@ public class EventuallyConsistentMapImpl<K, V> |
| 98 | // TODO: Make these anti-entropy params configurable | 98 | // TODO: Make these anti-entropy params configurable |
| 99 | private long initialDelaySec = 5; | 99 | private long initialDelaySec = 5; |
| 100 | private long periodSec = 5; | 100 | private long periodSec = 5; |
| 101 | + private boolean lightweightAntiEntropy = true; | ||
| 101 | 102 | ||
| 102 | /** | 103 | /** |
| 103 | * Creates a new eventually consistent map shared amongst multiple instances. | 104 | * Creates a new eventually consistent map shared amongst multiple instances. |
| ... | @@ -567,24 +568,18 @@ public class EventuallyConsistentMapImpl<K, V> | ... | @@ -567,24 +568,18 @@ public class EventuallyConsistentMapImpl<K, V> |
| 567 | 568 | ||
| 568 | private void handleAntiEntropyAdvertisement(AntiEntropyAdvertisement<K> ad) { | 569 | private void handleAntiEntropyAdvertisement(AntiEntropyAdvertisement<K> ad) { |
| 569 | List<EventuallyConsistentMapEvent<K, V>> externalEvents; | 570 | List<EventuallyConsistentMapEvent<K, V>> externalEvents; |
| 570 | - boolean sync = false; | ||
| 571 | 571 | ||
| 572 | externalEvents = antiEntropyCheckLocalItems(ad); | 572 | externalEvents = antiEntropyCheckLocalItems(ad); |
| 573 | 573 | ||
| 574 | antiEntropyCheckLocalRemoved(ad); | 574 | antiEntropyCheckLocalRemoved(ad); |
| 575 | 575 | ||
| 576 | + if (!lightweightAntiEntropy) { | ||
| 576 | externalEvents.addAll(antiEntropyCheckRemoteRemoved(ad)); | 577 | externalEvents.addAll(antiEntropyCheckRemoteRemoved(ad)); |
| 577 | 578 | ||
| 578 | // if remote ad has something unknown, actively sync | 579 | // if remote ad has something unknown, actively sync |
| 579 | for (K key : ad.timestamps().keySet()) { | 580 | for (K key : ad.timestamps().keySet()) { |
| 580 | if (!items.containsKey(key)) { | 581 | if (!items.containsKey(key)) { |
| 581 | - sync = true; | ||
| 582 | - break; | ||
| 583 | - } | ||
| 584 | - } | ||
| 585 | - | ||
| 586 | // Send the advertisement back if this peer is out-of-sync | 582 | // Send the advertisement back if this peer is out-of-sync |
| 587 | - if (sync) { | ||
| 588 | final NodeId sender = ad.sender(); | 583 | final NodeId sender = ad.sender(); |
| 589 | AntiEntropyAdvertisement<K> myAd = createAdvertisement(); | 584 | AntiEntropyAdvertisement<K> myAd = createAdvertisement(); |
| 590 | try { | 585 | try { |
| ... | @@ -594,8 +589,11 @@ public class EventuallyConsistentMapImpl<K, V> | ... | @@ -594,8 +589,11 @@ public class EventuallyConsistentMapImpl<K, V> |
| 594 | "Failed to send reactive anti-entropy advertisement to {}", | 589 | "Failed to send reactive anti-entropy advertisement to {}", |
| 595 | sender); | 590 | sender); |
| 596 | } | 591 | } |
| 597 | - } | ||
| 598 | 592 | ||
| 593 | + break; | ||
| 594 | + } | ||
| 595 | + } | ||
| 596 | + } | ||
| 599 | externalEvents.forEach(this::notifyListeners); | 597 | externalEvents.forEach(this::notifyListeners); |
| 600 | } | 598 | } |
| 601 | 599 | ... | ... |
-
Please register or login to post a comment