Jonathan Hart
Committed by Brian O'Connor

Add a configuration option to vary how heavyweight anti-entropy is.

Change-Id: I57cea61182b3d19deb47608ffb7dd617529ae34c
......@@ -98,6 +98,7 @@ public class EventuallyConsistentMapImpl<K, V>
// TODO: Make these anti-entropy params configurable
private long initialDelaySec = 5;
private long periodSec = 5;
private boolean lightweightAntiEntropy = true;
/**
* Creates a new eventually consistent map shared amongst multiple instances.
......@@ -567,24 +568,18 @@ public class EventuallyConsistentMapImpl<K, V>
private void handleAntiEntropyAdvertisement(AntiEntropyAdvertisement<K> ad) {
List<EventuallyConsistentMapEvent<K, V>> externalEvents;
boolean sync = false;
externalEvents = antiEntropyCheckLocalItems(ad);
antiEntropyCheckLocalRemoved(ad);
if (!lightweightAntiEntropy) {
externalEvents.addAll(antiEntropyCheckRemoteRemoved(ad));
// if remote ad has something unknown, actively sync
for (K key : ad.timestamps().keySet()) {
if (!items.containsKey(key)) {
sync = true;
break;
}
}
// Send the advertisement back if this peer is out-of-sync
if (sync) {
final NodeId sender = ad.sender();
AntiEntropyAdvertisement<K> myAd = createAdvertisement();
try {
......@@ -594,8 +589,11 @@ public class EventuallyConsistentMapImpl<K, V>
"Failed to send reactive anti-entropy advertisement to {}",
sender);
}
}
break;
}
}
}
externalEvents.forEach(this::notifyListeners);
}
......