Resolve false probing timeout by delaying the proble a little bit
Change-Id: Ib087f72fa742c614e8b6916a9ea0be4ee08ab064
(cherry picked from commit 17a200e0c12fefe03978c2a595905a7e3bf87171)
diff --git a/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java b/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java
index 8a913cd..5f59921 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java
@@ -108,7 +108,7 @@
private Consumer<Status> statusChangeListener;
// TODO make this configurable
- private static final int PROBE_TIMEOUT_MS = 1000;
+ private static final int PROBE_TIMEOUT_MS = 1500;
private Cache<MacAddress, PendingHostLocation> pendingHostsCache = CacheBuilder.newBuilder()
.expireAfterWrite(PROBE_TIMEOUT_MS, TimeUnit.MILLISECONDS)
diff --git a/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java b/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
index a0d6e37..227415e 100644
--- a/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
+++ b/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
@@ -90,6 +90,9 @@
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import java.util.Set;
@@ -447,7 +450,10 @@
IPv6.getMCastMacAddress(ip.getIp6Address().toOctets()),
host.id().vlanId());
}
- sendProbe(probe, location);
+
+ // NOTE: delay the probe a little bit to wait for the store synchronization is done
+ ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
+ executorService.schedule(() -> sendProbe(probe, location), 1000, TimeUnit.MILLISECONDS);
});
});
}