mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-17 02:11:38 +02:00
[CORD-2607] Mcast buckets correction
Change-Id: Ib47b2d8e40babdbb2ccdba61b48365a141752016
This commit is contained in:
parent
ec6ac42337
commit
b72201bcda
@ -50,6 +50,7 @@ import org.onosproject.net.flowobjective.ForwardingObjective;
|
|||||||
import org.onosproject.net.flowobjective.NextObjective;
|
import org.onosproject.net.flowobjective.NextObjective;
|
||||||
import org.onosproject.net.flowobjective.ObjectiveContext;
|
import org.onosproject.net.flowobjective.ObjectiveContext;
|
||||||
import org.onosproject.net.mcast.McastEvent;
|
import org.onosproject.net.mcast.McastEvent;
|
||||||
|
import org.onosproject.net.mcast.McastRoute;
|
||||||
import org.onosproject.net.mcast.McastRouteInfo;
|
import org.onosproject.net.mcast.McastRouteInfo;
|
||||||
import org.onosproject.net.topology.TopologyService;
|
import org.onosproject.net.topology.TopologyService;
|
||||||
import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig;
|
import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig;
|
||||||
@ -62,6 +63,7 @@ import org.onosproject.store.service.Versioned;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -69,9 +71,15 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.locks.Lock;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static java.util.concurrent.Executors.newScheduledThreadPool;
|
||||||
|
import static org.onlab.util.Tools.groupedThreads;
|
||||||
import static org.onosproject.segmentrouting.SegmentRoutingManager.INTERNAL_VLAN;
|
import static org.onosproject.segmentrouting.SegmentRoutingManager.INTERNAL_VLAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,6 +95,49 @@ public class McastHandler {
|
|||||||
private final KryoNamespace.Builder mcastKryo;
|
private final KryoNamespace.Builder mcastKryo;
|
||||||
private final ConsistentMap<McastStoreKey, McastRole> mcastRoleStore;
|
private final ConsistentMap<McastStoreKey, McastRole> mcastRoleStore;
|
||||||
|
|
||||||
|
// Mcast lock to serialize local operations
|
||||||
|
private final Lock mcastLock = new ReentrantLock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acquires the lock used when making mcast changes.
|
||||||
|
*/
|
||||||
|
private void mcastLock() {
|
||||||
|
mcastLock.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the lock used when making mcast changes.
|
||||||
|
*/
|
||||||
|
private void mcastUnlock() {
|
||||||
|
mcastLock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stability threshold for Mcast. Seconds
|
||||||
|
private static final long MCAST_STABLITY_THRESHOLD = 5;
|
||||||
|
// Last change done
|
||||||
|
private Instant lastMcastChange = Instant.now();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if mcast in the network has been stable in the last
|
||||||
|
* MCAST_STABLITY_THRESHOLD seconds, by comparing the current time
|
||||||
|
* to the last mcast change timestamp.
|
||||||
|
*
|
||||||
|
* @return true if stable
|
||||||
|
*/
|
||||||
|
private boolean isMcastStable() {
|
||||||
|
long last = (long) (lastMcastChange.toEpochMilli() / 1000.0);
|
||||||
|
long now = (long) (Instant.now().toEpochMilli() / 1000.0);
|
||||||
|
log.debug("Mcast stable since {}s", now - last);
|
||||||
|
return (now - last) > MCAST_STABLITY_THRESHOLD;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify interval for Mcast
|
||||||
|
private static final long MCAST_VERIFY_INTERVAL = 30;
|
||||||
|
|
||||||
|
// Executor for mcast bucket corrector
|
||||||
|
private ScheduledExecutorService executorService
|
||||||
|
= newScheduledThreadPool(1, groupedThreads("mcastBktCorrector", "mcastbktC-%d", log));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Role in the multicast tree.
|
* Role in the multicast tree.
|
||||||
*/
|
*/
|
||||||
@ -129,6 +180,10 @@ public class McastHandler {
|
|||||||
.withName("onos-mcast-role-store")
|
.withName("onos-mcast-role-store")
|
||||||
.withSerializer(Serializer.using(mcastKryo.build("McastHandler-Role")))
|
.withSerializer(Serializer.using(mcastKryo.build("McastHandler-Role")))
|
||||||
.build();
|
.build();
|
||||||
|
// Init the executor service and the buckets corrector
|
||||||
|
executorService.scheduleWithFixedDelay(new McastBucketCorrector(), 10,
|
||||||
|
MCAST_VERIFY_INTERVAL,
|
||||||
|
TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,6 +199,13 @@ public class McastHandler {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up when deactivating the application.
|
||||||
|
*/
|
||||||
|
protected void terminate() {
|
||||||
|
executorService.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the SOURCE_ADDED event.
|
* Processes the SOURCE_ADDED event.
|
||||||
*
|
*
|
||||||
@ -160,9 +222,7 @@ public class McastHandler {
|
|||||||
Set<ConnectPoint> sinks = mcastRouteInfo.sinks();
|
Set<ConnectPoint> sinks = mcastRouteInfo.sinks();
|
||||||
IpAddress mcastIp = mcastRouteInfo.route().group();
|
IpAddress mcastIp = mcastRouteInfo.route().group();
|
||||||
|
|
||||||
sinks.forEach(sink -> {
|
sinks.forEach(sink -> processSinkAddedInternal(source, sink, mcastIp));
|
||||||
processSinkAddedInternal(source, sink, mcastIp);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,9 +260,24 @@ public class McastHandler {
|
|||||||
ConnectPoint sink = mcastRouteInfo.sink().orElse(null);
|
ConnectPoint sink = mcastRouteInfo.sink().orElse(null);
|
||||||
IpAddress mcastIp = mcastRouteInfo.route().group();
|
IpAddress mcastIp = mcastRouteInfo.route().group();
|
||||||
|
|
||||||
|
processSinkRemovedInternal(source, sink, mcastIp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a path from source to sink for given multicast group.
|
||||||
|
*
|
||||||
|
* @param source connect point of the multicast source
|
||||||
|
* @param sink connection point of the multicast sink
|
||||||
|
* @param mcastIp multicast group IP address
|
||||||
|
*/
|
||||||
|
private void processSinkRemovedInternal(ConnectPoint source, ConnectPoint sink,
|
||||||
|
IpAddress mcastIp) {
|
||||||
|
lastMcastChange = Instant.now();
|
||||||
|
mcastLock();
|
||||||
|
try {
|
||||||
// Continue only when this instance is the master of source device
|
// Continue only when this instance is the master of source device
|
||||||
if (!srManager.mastershipService.isLocalMaster(source.deviceId())) {
|
if (!srManager.mastershipService.isLocalMaster(source.deviceId())) {
|
||||||
log.info("Skip {} due to lack of mastership of the source device {}",
|
log.debug("Skip {} due to lack of mastership of the source device {}",
|
||||||
mcastIp, source.deviceId());
|
mcastIp, source.deviceId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -211,7 +286,8 @@ public class McastHandler {
|
|||||||
if (source.deviceId().equals(sink.deviceId())) {
|
if (source.deviceId().equals(sink.deviceId())) {
|
||||||
// Source and sink are on even the same port. There must be something wrong.
|
// Source and sink are on even the same port. There must be something wrong.
|
||||||
if (source.port().equals(sink.port())) {
|
if (source.port().equals(sink.port())) {
|
||||||
log.warn("Sink is on the same port of source. Abort");
|
log.warn("Skip {} since sink {} is on the same port of source {}. Abort",
|
||||||
|
mcastIp, sink, source);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
removePortFromDevice(sink.deviceId(), sink.port(), mcastIp, assignedVlan(source));
|
removePortFromDevice(sink.deviceId(), sink.port(), mcastIp, assignedVlan(source));
|
||||||
@ -231,13 +307,19 @@ public class McastHandler {
|
|||||||
Collections.reverse(links);
|
Collections.reverse(links);
|
||||||
for (Link link : links) {
|
for (Link link : links) {
|
||||||
if (isLast) {
|
if (isLast) {
|
||||||
isLast = removePortFromDevice(link.src().deviceId(), link.src().port(),
|
isLast = removePortFromDevice(
|
||||||
|
link.src().deviceId(),
|
||||||
|
link.src().port(),
|
||||||
mcastIp,
|
mcastIp,
|
||||||
assignedVlan(link.src().deviceId().equals(source.deviceId()) ? source : null));
|
assignedVlan(link.src().deviceId().equals(source.deviceId()) ? source : null)
|
||||||
|
);
|
||||||
mcastRoleStore.remove(new McastStoreKey(mcastIp, link.src().deviceId()));
|
mcastRoleStore.remove(new McastStoreKey(mcastIp, link.src().deviceId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
mcastUnlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -249,10 +331,13 @@ public class McastHandler {
|
|||||||
*/
|
*/
|
||||||
private void processSinkAddedInternal(ConnectPoint source, ConnectPoint sink,
|
private void processSinkAddedInternal(ConnectPoint source, ConnectPoint sink,
|
||||||
IpAddress mcastIp) {
|
IpAddress mcastIp) {
|
||||||
|
lastMcastChange = Instant.now();
|
||||||
|
mcastLock();
|
||||||
|
try {
|
||||||
// Continue only when this instance is the master of source device
|
// Continue only when this instance is the master of source device
|
||||||
if (!srManager.mastershipService.isLocalMaster(source.deviceId())) {
|
if (!srManager.mastershipService.isLocalMaster(source.deviceId())) {
|
||||||
log.info("Skip {} due to lack of mastership of the source device {}",
|
log.debug("Skip {} due to lack of mastership of the source device {}",
|
||||||
source.deviceId());
|
mcastIp, source.deviceId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +348,8 @@ public class McastHandler {
|
|||||||
if (source.deviceId().equals(sink.deviceId())) {
|
if (source.deviceId().equals(sink.deviceId())) {
|
||||||
// Source and sink are on even the same port. There must be something wrong.
|
// Source and sink are on even the same port. There must be something wrong.
|
||||||
if (source.port().equals(sink.port())) {
|
if (source.port().equals(sink.port())) {
|
||||||
log.warn("Sink is on the same port of source. Abort");
|
log.warn("Skip {} since sink {} is on the same port of source {}. Abort",
|
||||||
|
mcastIp, sink, source);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addPortToDevice(sink.deviceId(), sink.port(), mcastIp, assignedVlan(source));
|
addPortToDevice(sink.deviceId(), sink.port(), mcastIp, assignedVlan(source));
|
||||||
@ -298,6 +384,9 @@ public class McastHandler {
|
|||||||
log.warn("Unable to find a path from {} to {}. Abort sinkAdded",
|
log.warn("Unable to find a path from {} to {}. Abort sinkAdded",
|
||||||
source.deviceId(), sink.deviceId());
|
source.deviceId(), sink.deviceId());
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
mcastUnlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,6 +395,10 @@ public class McastHandler {
|
|||||||
* @param affectedLink Link that is going down
|
* @param affectedLink Link that is going down
|
||||||
*/
|
*/
|
||||||
protected void processLinkDown(Link affectedLink) {
|
protected void processLinkDown(Link affectedLink) {
|
||||||
|
lastMcastChange = Instant.now();
|
||||||
|
mcastLock();
|
||||||
|
try {
|
||||||
|
// Get groups affected by the link down event
|
||||||
getAffectedGroups(affectedLink).forEach(mcastIp -> {
|
getAffectedGroups(affectedLink).forEach(mcastIp -> {
|
||||||
// TODO Optimize when the group editing is in place
|
// TODO Optimize when the group editing is in place
|
||||||
log.debug("Processing link down {} for group {}",
|
log.debug("Processing link down {} for group {}",
|
||||||
@ -329,7 +422,7 @@ public class McastHandler {
|
|||||||
|
|
||||||
// Continue only when this instance is the master of source device
|
// Continue only when this instance is the master of source device
|
||||||
if (!srManager.mastershipService.isLocalMaster(source.deviceId())) {
|
if (!srManager.mastershipService.isLocalMaster(source.deviceId())) {
|
||||||
log.info("Skip {} due to lack of mastership of the source device {}",
|
log.debug("Skip {} due to lack of mastership of the source device {}",
|
||||||
source.deviceId());
|
source.deviceId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -356,6 +449,9 @@ public class McastHandler {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
mcastUnlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -364,6 +460,9 @@ public class McastHandler {
|
|||||||
* @param deviceDown device going down
|
* @param deviceDown device going down
|
||||||
*/
|
*/
|
||||||
protected void processDeviceDown(DeviceId deviceDown) {
|
protected void processDeviceDown(DeviceId deviceDown) {
|
||||||
|
lastMcastChange = Instant.now();
|
||||||
|
mcastLock();
|
||||||
|
try {
|
||||||
// Get the mcast groups affected by the device going down
|
// Get the mcast groups affected by the device going down
|
||||||
getAffectedGroups(deviceDown).forEach(mcastIp -> {
|
getAffectedGroups(deviceDown).forEach(mcastIp -> {
|
||||||
// TODO Optimize when the group editing is in place
|
// TODO Optimize when the group editing is in place
|
||||||
@ -391,7 +490,7 @@ public class McastHandler {
|
|||||||
if (!srManager.mastershipService.isLocalMaster(source.deviceId())) {
|
if (!srManager.mastershipService.isLocalMaster(source.deviceId())) {
|
||||||
// When the source is available we just check the mastership
|
// When the source is available we just check the mastership
|
||||||
if (srManager.deviceService.isAvailable(source.deviceId())) {
|
if (srManager.deviceService.isAvailable(source.deviceId())) {
|
||||||
log.info("Skip {} due to lack of mastership of the source device {}",
|
log.debug("Skip {} due to lack of mastership of the source device {}",
|
||||||
mcastIp, source.deviceId());
|
mcastIp, source.deviceId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -401,7 +500,7 @@ public class McastHandler {
|
|||||||
source.deviceId().toString()).leaderNodeId();
|
source.deviceId().toString()).leaderNodeId();
|
||||||
// Verify if this node is the leader
|
// Verify if this node is the leader
|
||||||
if (!srManager.clusterService.getLocalNode().id().equals(leader)) {
|
if (!srManager.clusterService.getLocalNode().id().equals(leader)) {
|
||||||
log.info("Skip {} due to lack of leadership on the topic {}",
|
log.debug("Skip {} due to lack of leadership on the topic {}",
|
||||||
mcastIp, source.deviceId());
|
mcastIp, source.deviceId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -461,6 +560,9 @@ public class McastHandler {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
mcastUnlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1056,7 +1158,9 @@ public class McastHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds or removes filtering objective for given device and port.
|
* Updates filtering objective for given device and port.
|
||||||
|
* It is called in general when the mcast config has been
|
||||||
|
* changed.
|
||||||
*
|
*
|
||||||
* @param deviceId device ID
|
* @param deviceId device ID
|
||||||
* @param portNum ingress port number
|
* @param portNum ingress port number
|
||||||
@ -1065,6 +1169,11 @@ public class McastHandler {
|
|||||||
*/
|
*/
|
||||||
protected void updateFilterToDevice(DeviceId deviceId, PortNumber portNum,
|
protected void updateFilterToDevice(DeviceId deviceId, PortNumber portNum,
|
||||||
VlanId vlanId, boolean install) {
|
VlanId vlanId, boolean install) {
|
||||||
|
lastMcastChange = Instant.now();
|
||||||
|
mcastLock();
|
||||||
|
try {
|
||||||
|
// Iterates over the route and updates properly the filtering objective
|
||||||
|
// on the source device.
|
||||||
srManager.multicastRouteService.getRoutes().forEach(mcastRoute -> {
|
srManager.multicastRouteService.getRoutes().forEach(mcastRoute -> {
|
||||||
ConnectPoint source = srManager.multicastRouteService.fetchSource(mcastRoute);
|
ConnectPoint source = srManager.multicastRouteService.fetchSource(mcastRoute);
|
||||||
if (source.deviceId().equals(deviceId) && source.port().equals(portNum)) {
|
if (source.deviceId().equals(deviceId) && source.port().equals(portNum)) {
|
||||||
@ -1075,5 +1184,103 @@ public class McastHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
mcastUnlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs bucket verification operation for all mcast groups in the devices.
|
||||||
|
* Firstly, it verifies that mcast is stable before trying verification operation.
|
||||||
|
* Verification consists in creating new nexts with VERIFY operation. Actually,
|
||||||
|
* the operation is totally delegated to the driver.
|
||||||
|
*/
|
||||||
|
private final class McastBucketCorrector implements Runnable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Verify if the Mcast has been stable for MCAST_STABLITY_THRESHOLD
|
||||||
|
if (!isMcastStable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Acquires lock
|
||||||
|
mcastLock();
|
||||||
|
try {
|
||||||
|
// Iterates over the routes and verify the related next objectives
|
||||||
|
srManager.multicastRouteService.getRoutes()
|
||||||
|
.stream()
|
||||||
|
.map(McastRoute::group)
|
||||||
|
.forEach(mcastIp -> {
|
||||||
|
log.trace("Running mcast buckets corrector for mcast group: {}",
|
||||||
|
mcastIp);
|
||||||
|
|
||||||
|
// For each group we get current information in the store
|
||||||
|
// and issue a check of the next objectives in place
|
||||||
|
DeviceId ingressDevice = getDevice(mcastIp, McastRole.INGRESS)
|
||||||
|
.stream().findAny().orElse(null);
|
||||||
|
DeviceId transitDevice = getDevice(mcastIp, McastRole.TRANSIT)
|
||||||
|
.stream().findAny().orElse(null);
|
||||||
|
Set<DeviceId> egressDevices = getDevice(mcastIp, McastRole.EGRESS);
|
||||||
|
ConnectPoint source = getSource(mcastIp);
|
||||||
|
|
||||||
|
// Do not proceed if ingress device or source of this group are missing
|
||||||
|
if (ingressDevice == null || source == null) {
|
||||||
|
log.warn("Unable to run buckets corrector. " +
|
||||||
|
"Missing ingress {} or source {} for group {}",
|
||||||
|
ingressDevice, source, mcastIp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Continue only when this instance is the master of source device
|
||||||
|
if (!srManager.mastershipService.isLocalMaster(source.deviceId())) {
|
||||||
|
log.trace("Unable to run buckets corrector. " +
|
||||||
|
"Skip {} due to lack of mastership " +
|
||||||
|
"of the source device {}",
|
||||||
|
mcastIp, source.deviceId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the set of the devices to be processed
|
||||||
|
ImmutableSet.Builder<DeviceId> devicesBuilder = ImmutableSet.builder();
|
||||||
|
devicesBuilder.add(ingressDevice);
|
||||||
|
if (transitDevice != null) {
|
||||||
|
devicesBuilder.add(transitDevice);
|
||||||
|
}
|
||||||
|
if (!egressDevices.isEmpty()) {
|
||||||
|
devicesBuilder.addAll(egressDevices);
|
||||||
|
}
|
||||||
|
Set<DeviceId> devicesToProcess = devicesBuilder.build();
|
||||||
|
|
||||||
|
// Iterate over the devices
|
||||||
|
devicesToProcess.forEach(deviceId -> {
|
||||||
|
McastStoreKey currentKey = new McastStoreKey(mcastIp, deviceId);
|
||||||
|
// If next exists in our store verify related next objective
|
||||||
|
if (mcastNextObjStore.containsKey(currentKey)) {
|
||||||
|
NextObjective currentNext = mcastNextObjStore.get(currentKey).value();
|
||||||
|
// Get current ports
|
||||||
|
Set<PortNumber> currentPorts = getPorts(currentNext.next());
|
||||||
|
// Rebuild the next objective
|
||||||
|
currentNext = nextObjBuilder(
|
||||||
|
mcastIp,
|
||||||
|
assignedVlan(deviceId.equals(source.deviceId()) ? source : null),
|
||||||
|
currentPorts,
|
||||||
|
currentNext.id()
|
||||||
|
).verify();
|
||||||
|
// Send to the flowobjective service
|
||||||
|
srManager.flowObjectiveService.next(deviceId, currentNext);
|
||||||
|
} else {
|
||||||
|
log.warn("Unable to run buckets corrector." +
|
||||||
|
"Missing next for {} and group {}",
|
||||||
|
deviceId, mcastIp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
// Finally, it releases the lock
|
||||||
|
mcastUnlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -490,6 +490,8 @@ public class SegmentRoutingManager implements SegmentRoutingService {
|
|||||||
portNextObjStore.destroy();
|
portNextObjStore.destroy();
|
||||||
tunnelStore.destroy();
|
tunnelStore.destroy();
|
||||||
policyStore.destroy();
|
policyStore.destroy();
|
||||||
|
|
||||||
|
mcastHandler.terminate();
|
||||||
log.info("Stopped");
|
log.info("Stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1588,8 +1588,8 @@ public class Ofdpa2GroupHandler {
|
|||||||
* modified to match the given next objective
|
* modified to match the given next objective
|
||||||
*/
|
*/
|
||||||
protected void verifyGroup(NextObjective nextObjective, NextGroup next) {
|
protected void verifyGroup(NextObjective nextObjective, NextGroup next) {
|
||||||
if (nextObjective.type() != NextObjective.Type.HASHED) {
|
if (nextObjective.type() == NextObjective.Type.SIMPLE) {
|
||||||
log.warn("verification not supported for {} group", nextObjective.type());
|
log.warn("verification not supported for indirect group");
|
||||||
fail(nextObjective, ObjectiveError.UNSUPPORTED);
|
fail(nextObjective, ObjectiveError.UNSUPPORTED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1640,17 +1640,25 @@ public class Ofdpa2GroupHandler {
|
|||||||
indicesToRemove.addAll(otherIndices);
|
indicesToRemove.addAll(otherIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.debug("Buckets to create {}", bucketsToCreate);
|
||||||
|
log.debug("Indices to remove {}", indicesToRemove);
|
||||||
|
|
||||||
if (!bucketsToCreate.isEmpty()) {
|
if (!bucketsToCreate.isEmpty()) {
|
||||||
log.info("creating {} buckets as part of nextId: {} verification",
|
log.info("creating {} buckets as part of nextId: {} verification",
|
||||||
bucketsToCreate.size(), nextObjective.id());
|
bucketsToCreate.size(), nextObjective.id());
|
||||||
//create a nextObjective only with these buckets
|
//create a nextObjective only with these buckets
|
||||||
NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder()
|
NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder()
|
||||||
.withId(nextObjective.id())
|
.withId(nextObjective.id())
|
||||||
.withType(NextObjective.Type.HASHED)
|
.withType(nextObjective.type())
|
||||||
.withMeta(nextObjective.meta())
|
.withMeta(nextObjective.meta())
|
||||||
.fromApp(nextObjective.appId());
|
.fromApp(nextObjective.appId());
|
||||||
bucketsToCreate.forEach(bucket -> nextObjBuilder.addTreatment(bucket));
|
bucketsToCreate.forEach(nextObjBuilder::addTreatment);
|
||||||
|
// According to the next type we call the proper add function
|
||||||
|
if (nextObjective.type() == NextObjective.Type.HASHED) {
|
||||||
addBucketToHashGroup(nextObjBuilder.addToExisting(), allActiveKeys);
|
addBucketToHashGroup(nextObjBuilder.addToExisting(), allActiveKeys);
|
||||||
|
} else {
|
||||||
|
addBucketToBroadcastGroup(nextObjBuilder.addToExisting(), allActiveKeys);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indicesToRemove.isEmpty()) {
|
if (!indicesToRemove.isEmpty()) {
|
||||||
@ -1667,9 +1675,9 @@ public class Ofdpa2GroupHandler {
|
|||||||
// Nevertheless groupStore may not be in sync due to bug in the store
|
// Nevertheless groupStore may not be in sync due to bug in the store
|
||||||
// - see CORD-1844. XXX When this bug is fixed, the rest of this verify
|
// - see CORD-1844. XXX When this bug is fixed, the rest of this verify
|
||||||
// method will not be required.
|
// method will not be required.
|
||||||
GroupKey hashGroupKey = allActiveKeys.get(0).peekFirst();
|
GroupKey topGroupKey = allActiveKeys.get(0).peekFirst();
|
||||||
Group hashGroup = groupService.getGroup(deviceId, hashGroupKey);
|
Group topGroup = groupService.getGroup(deviceId, topGroupKey);
|
||||||
int actualGroupSize = hashGroup.buckets().buckets().size();
|
int actualGroupSize = topGroup.buckets().buckets().size();
|
||||||
int objGroupSize = nextObjective.next().size();
|
int objGroupSize = nextObjective.next().size();
|
||||||
if (actualGroupSize != objGroupSize) {
|
if (actualGroupSize != objGroupSize) {
|
||||||
log.warn("Mismatch detected in device:{}, nextId:{}, nextObjective-size"
|
log.warn("Mismatch detected in device:{}, nextId:{}, nextObjective-size"
|
||||||
@ -1677,9 +1685,10 @@ public class Ofdpa2GroupHandler {
|
|||||||
objGroupSize, actualGroupSize);
|
objGroupSize, actualGroupSize);
|
||||||
}
|
}
|
||||||
if (actualGroupSize > objGroupSize) {
|
if (actualGroupSize > objGroupSize) {
|
||||||
|
// Group in the device has more chains
|
||||||
List<GroupBucket> bucketsToRemove = Lists.newArrayList();
|
List<GroupBucket> bucketsToRemove = Lists.newArrayList();
|
||||||
//check every bucket in the actual group
|
//check every bucket in the actual group
|
||||||
for (GroupBucket bucket : hashGroup.buckets().buckets()) {
|
for (GroupBucket bucket : topGroup.buckets().buckets()) {
|
||||||
GroupInstruction g = (GroupInstruction) bucket.treatment()
|
GroupInstruction g = (GroupInstruction) bucket.treatment()
|
||||||
.allInstructions().iterator().next();
|
.allInstructions().iterator().next();
|
||||||
GroupId gidToCheck = g.groupId(); // the group pointed to
|
GroupId gidToCheck = g.groupId(); // the group pointed to
|
||||||
@ -1707,11 +1716,12 @@ public class Ofdpa2GroupHandler {
|
|||||||
+ "buckets to remove");
|
+ "buckets to remove");
|
||||||
} else {
|
} else {
|
||||||
GroupBuckets removeBuckets = new GroupBuckets(bucketsToRemove);
|
GroupBuckets removeBuckets = new GroupBuckets(bucketsToRemove);
|
||||||
groupService.removeBucketsFromGroup(deviceId, hashGroupKey,
|
groupService.removeBucketsFromGroup(deviceId, topGroupKey,
|
||||||
removeBuckets, hashGroupKey,
|
removeBuckets, topGroupKey,
|
||||||
nextObjective.appId());
|
nextObjective.appId());
|
||||||
}
|
}
|
||||||
} else if (actualGroupSize < objGroupSize) {
|
} else if (actualGroupSize < objGroupSize) {
|
||||||
|
// Group in the device has less chains
|
||||||
// should also add buckets not in group-store but in obj-store
|
// should also add buckets not in group-store but in obj-store
|
||||||
List<GroupBucket> bucketsToAdd = Lists.newArrayList();
|
List<GroupBucket> bucketsToAdd = Lists.newArrayList();
|
||||||
//check every bucket in the obj
|
//check every bucket in the obj
|
||||||
@ -1727,7 +1737,7 @@ public class Ofdpa2GroupHandler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean matches = false;
|
boolean matches = false;
|
||||||
for (GroupBucket bucket : hashGroup.buckets().buckets()) {
|
for (GroupBucket bucket : topGroup.buckets().buckets()) {
|
||||||
GroupInstruction g = (GroupInstruction) bucket.treatment()
|
GroupInstruction g = (GroupInstruction) bucket.treatment()
|
||||||
.allInstructions().iterator().next();
|
.allInstructions().iterator().next();
|
||||||
GroupId gidToCheck = g.groupId(); // the group pointed to
|
GroupId gidToCheck = g.groupId(); // the group pointed to
|
||||||
@ -1741,7 +1751,12 @@ public class Ofdpa2GroupHandler {
|
|||||||
TrafficTreatment t = DefaultTrafficTreatment.builder()
|
TrafficTreatment t = DefaultTrafficTreatment.builder()
|
||||||
.group(pointedGroup.id())
|
.group(pointedGroup.id())
|
||||||
.build();
|
.build();
|
||||||
|
// Create the proper bucket according to the next type
|
||||||
|
if (nextObjective.type() == NextObjective.Type.HASHED) {
|
||||||
bucketsToAdd.add(DefaultGroupBucket.createSelectGroupBucket(t));
|
bucketsToAdd.add(DefaultGroupBucket.createSelectGroupBucket(t));
|
||||||
|
} else {
|
||||||
|
bucketsToAdd.add(DefaultGroupBucket.createAllGroupBucket(t));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bucketsToAdd.isEmpty()) {
|
if (bucketsToAdd.isEmpty()) {
|
||||||
@ -1749,8 +1764,8 @@ public class Ofdpa2GroupHandler {
|
|||||||
+ "buckets to add");
|
+ "buckets to add");
|
||||||
} else {
|
} else {
|
||||||
GroupBuckets addBuckets = new GroupBuckets(bucketsToAdd);
|
GroupBuckets addBuckets = new GroupBuckets(bucketsToAdd);
|
||||||
groupService.addBucketsToGroup(deviceId, hashGroupKey,
|
groupService.addBucketsToGroup(deviceId, topGroupKey,
|
||||||
addBuckets, hashGroupKey,
|
addBuckets, topGroupKey,
|
||||||
nextObjective.appId());
|
nextObjective.appId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user