mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-05 04:06:49 +02:00
Use single counter for host probe index to avoid unnecessary Raft session creation
Change-Id: I59829879e291caf33fc3abd4b5bbb69f0be92261 (cherry picked from commit 14c832b664c407015798f49a787cae184639a9f1)
This commit is contained in:
parent
32e73d7783
commit
dc49cfd104
@ -47,6 +47,7 @@ import org.onosproject.net.host.HostLocationProbingService.ProbeMode;
|
||||
import org.onosproject.net.provider.ProviderId;
|
||||
import org.onosproject.store.AbstractStore;
|
||||
import org.onosproject.store.serializers.KryoNamespaces;
|
||||
import org.onosproject.store.service.AtomicCounter;
|
||||
import org.onosproject.store.service.ConsistentMap;
|
||||
import org.onosproject.store.service.MapEvent;
|
||||
import org.onosproject.store.service.MapEventListener;
|
||||
@ -94,6 +95,7 @@ public class DistributedHostStore
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
protected StorageService storageService;
|
||||
|
||||
private AtomicCounter hostProbeIndex;
|
||||
private ConsistentMap<HostId, DefaultHost> hostsConsistentMap;
|
||||
private Map<HostId, DefaultHost> hosts;
|
||||
private Map<IpAddress, Set<Host>> hostsByIp;
|
||||
@ -158,6 +160,11 @@ public class DistributedHostStore
|
||||
pendingHostsConsistentMap.addListener(pendingHostListener);
|
||||
pendingHosts = pendingHostsConsistentMap.asJavaMap();
|
||||
|
||||
hostProbeIndex = storageService.atomicCounterBuilder()
|
||||
.withName("onos-hosts-probe-index")
|
||||
.build()
|
||||
.asAtomicCounter();
|
||||
|
||||
cacheCleaner.scheduleAtFixedRate(pendingHostsCache::cleanUp, 0,
|
||||
PROBE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
|
||||
@ -412,7 +419,7 @@ public class DistributedHostStore
|
||||
@Override
|
||||
public MacAddress addPendingHostLocation(HostId hostId, ConnectPoint connectPoint, ProbeMode probeMode) {
|
||||
// Use ONLab OUI (3 bytes) + atomic counter (3 bytes) as the source MAC of the probe
|
||||
long nextIndex = storageService.getAtomicCounter("onos-hosts-probe-index").getAndIncrement();
|
||||
long nextIndex = hostProbeIndex.getAndIncrement();
|
||||
MacAddress probeMac = MacAddress.valueOf(MacAddress.NONE.toLong() + nextIndex);
|
||||
PendingHostLocation phl = new PendingHostLocation(hostId, connectPoint, probeMode);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user