1. Decouple NBI neutron commands and QoS alert cache creation.
2. Port is added/deleted from the cache based on ovsdb notification.
3. Handle the case where counters get wrapped.
Change-Id: I2172613574f343cd13860065ee30ca517bfd61df
Signed-off-by: Arun Sharma <arun.e.sharma@ericsson.com>
import java.math.BigInteger;
import java.util.List;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
import org.opendaylight.genius.interfacemanager.globals.IfmConstants;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
+import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
-import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.OpendaylightDirectStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.qosalert.config.rev170301.QosalertConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.qosalert.config.rev170301.QosalertConfigBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private final OpendaylightDirectStatisticsService odlDirectStatisticsService;
private final QosNeutronUtils qosNeutronUtils;
private final QosEosHandler qosEosHandler;
- private final INeutronVpnManager neutronVpnManager;
+ private final IInterfaceManager interfaceManager;
+ private final Set unprocessedInterfaceIds = ConcurrentHashMap.newKeySet();
private final ConcurrentMap<BigInteger, ConcurrentMap<String, QosAlertPortData>> qosAlertDpnPortNumberMap =
new ConcurrentHashMap<>();
private final AlertThresholdSupplier alertThresholdSupplier = new AlertThresholdSupplier();
public QosAlertManager(final DataBroker dataBroker,
final OpendaylightDirectStatisticsService odlDirectStatisticsService, final QosalertConfig defaultConfig,
final QosNeutronUtils qosNeutronUtils, final QosEosHandler qosEosHandler,
- final INeutronVpnManager neutronVpnManager) {
-
+ final IInterfaceManager interfaceManager) {
LOG.debug("{} created", getClass().getSimpleName());
this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
this.odlDirectStatisticsService = odlDirectStatisticsService;
+ this.interfaceManager = interfaceManager;
this.defaultConfig = defaultConfig;
this.qosNeutronUtils = qosNeutronUtils;
this.qosEosHandler = qosEosHandler;
- this.neutronVpnManager = neutronVpnManager;
LOG.debug("QosAlert default config poll alertEnabled:{} threshold:{} pollInterval:{}",
defaultConfig.isQosAlertEnabled(), defaultConfig.getQosDropPacketThreshold(),
defaultConfig.getQosAlertPollInterval());
writeConfigDataStore(enable, alertThresholdSupplier.get().shortValue(), pollInterval);
}
- public void addToQosAlertCache(Port port) {
- LOG.trace("Adding port {} in cache", port.getUuid());
+ public void addInterfaceIdInQoSAlertCache(String ifaceId) {
+ LOG.trace("Adding interface id {} in cache", ifaceId);
+ InterfaceInfo interfaceInfo =
+ interfaceManager.getInterfaceInfoFromOperationalDataStore(ifaceId);
+ if (interfaceInfo == null) {
+ LOG.debug("Interface not found {}. Add in cache now and process later ", ifaceId);
+ unprocessedInterfaceIds.add(ifaceId);
+ } else {
+ addToQosAlertCache(interfaceInfo);
+ }
+ }
- BigInteger dpnId = qosNeutronUtils.getDpnForInterface(port.getUuid().getValue());
+ public void processInterfaceUpEvent(String ifaceId) {
+ LOG.trace("processInterfaceUpEvent {}", ifaceId);
+ if (unprocessedInterfaceIds.remove(ifaceId)) {
+ addInterfaceIdInQoSAlertCache(ifaceId);
+ }
+ }
+
+ private void addToQosAlertCache(InterfaceInfo interfaceInfo) {
+ BigInteger dpnId = interfaceInfo.getDpId();
+ if (dpnId.equals(IfmConstants.INVALID_DPID)) {
+ LOG.error("Interface {} has INVALID_DPID", interfaceInfo.getInterfaceName());
+ return;
+ }
- if (dpnId.equals(BigInteger.ZERO)) {
- LOG.debug("DPN ID for port {} not found", port.getUuid());
+ Port port = qosNeutronUtils.getNeutronPort(interfaceInfo.getInterfaceName());
+ if (port == null) {
+ LOG.error("Port {} not found", interfaceInfo.getInterfaceName());
return;
}
- String portNumber = qosNeutronUtils.getPortNumberForInterface(port.getUuid().getValue());
+ String portNumber = String.valueOf(interfaceInfo.getPortNo());
LOG.trace("Adding DPN ID {} with port {} port number {}", dpnId, port.getUuid(), portNumber);
.put(portNumber, new QosAlertPortData(port, qosNeutronUtils, alertThresholdSupplier));
}
- public void addToQosAlertCache(Network network) {
- LOG.trace("Adding network {} in cache", network.getUuid());
+ public void removeInterfaceIdFromQosAlertCache(String ifaceId) {
- List<Uuid> subnetIds = qosNeutronUtils.getSubnetIdsFromNetworkId(network.getUuid());
-
- for (Uuid subnetId : subnetIds) {
- List<Uuid> portIds = qosNeutronUtils.getPortIdsFromSubnetId(subnetId);
- for (Uuid portId : portIds) {
- Port port = qosNeutronUtils.getNeutronPort(portId);
- if (port != null && !qosNeutronUtils.portHasQosPolicy(port)) {
- LOG.trace("Adding network {} port {} in cache", network.getUuid(), port.getUuid());
- addToQosAlertCache(port);
- }
- }
- }
- }
-
- public void removeFromQosAlertCache(Port port) {
- LOG.trace("Removing port {} from cache", port.getUuid());
-
- BigInteger dpnId = qosNeutronUtils.getDpnForInterface(port.getUuid().getValue());
-
- if (dpnId.equals(BigInteger.ZERO)) {
- LOG.debug("DPN ID for port {} not found", port.getUuid());
+ LOG.trace("If present, remove interface {} from cache", ifaceId);
+ unprocessedInterfaceIds.remove(ifaceId);
+ InterfaceInfo interfaceInfo =
+ interfaceManager.getInterfaceInfoFromOperationalDataStore(ifaceId);
+ if (interfaceInfo == null) {
return;
}
-
- String portNumber = qosNeutronUtils.getPortNumberForInterface(port.getUuid().getValue());
-
+ BigInteger dpnId = interfaceInfo.getDpId();
+ String portNumber = String.valueOf(interfaceInfo.getPortNo());
removeFromQosAlertCache(dpnId, portNumber);
}
- public void removeFromQosAlertCache(NodeConnectorId nodeConnectorId) {
- LOG.trace("Removing node connector {} from cache", nodeConnectorId.getValue());
-
- long nodeId = MDSALUtil.getDpnIdFromPortName(nodeConnectorId);
-
- if (nodeId == -1) {
- LOG.debug("Node ID for node connector {} not found", nodeConnectorId.getValue());
+ public void removeLowerLayerIfFromQosAlertCache(String lowerLayerIf) {
+ LOG.trace("If present, remove lowerLayerIf {} from cache", lowerLayerIf);
+ BigInteger dpnId = qosNeutronUtils.getDpnIdFromLowerLayerIf(lowerLayerIf);
+ String portNumber = qosNeutronUtils.getPortNumberFromLowerLayerIf(lowerLayerIf);
+ if (dpnId == null || portNumber == null) {
+ LOG.error("interface {} not in openflow:dpnid:portnum format", lowerLayerIf);
return;
}
-
- BigInteger dpnId = new BigInteger(String.valueOf(nodeId));
-
- long portId = MDSALUtil.getOfPortNumberFromPortName(nodeConnectorId);
-
- String portNumber = String.valueOf(portId);
-
removeFromQosAlertCache(dpnId, portNumber);
}
private void removeFromQosAlertCache(BigInteger dpnId, String portNumber) {
- boolean removed = false;
- ConcurrentMap<String, QosAlertPortData> portDataMap = qosAlertDpnPortNumberMap.get(dpnId);
- if (portDataMap != null) {
- removed = portDataMap.remove(portNumber) != null;
- if (portDataMap.isEmpty()) {
- LOG.trace("DPN {} empty. Removing from cache", dpnId);
- qosAlertDpnPortNumberMap.remove(dpnId, portDataMap);
- }
- }
-
- if (removed) {
- LOG.trace("Removed DPN {} port number {} from cache", dpnId, portNumber);
- } else {
- LOG.trace("DPN {} port number {} not found in cache", dpnId, portNumber);
- }
- }
-
- public void removeFromQosAlertCache(Network network) {
- LOG.trace("Removing network {} from cache", network.getUuid());
-
- List<Uuid> subnetIds = qosNeutronUtils.getSubnetIdsFromNetworkId(network.getUuid());
-
- for (Uuid subnetId : subnetIds) {
- List<Uuid> portIds = qosNeutronUtils.getPortIdsFromSubnetId(subnetId);
- for (Uuid portId : portIds) {
- Port port = qosNeutronUtils.getNeutronPort(portId);
- if (port != null && !qosNeutronUtils.portHasQosPolicy(port)) {
- LOG.trace("Removing network {} port {} from cache", network.getUuid(), port.getUuid());
- removeFromQosAlertCache(port);
- }
+ if (qosAlertDpnPortNumberMap.containsKey(dpnId)
+ && qosAlertDpnPortNumberMap.get(dpnId).containsKey(portNumber)) {
+ qosAlertDpnPortNumberMap.get(dpnId).remove(portNumber);
+ LOG.debug("Removed interace {}:{} from cache", dpnId, portNumber);
+ if (qosAlertDpnPortNumberMap.get(dpnId).isEmpty()) {
+ LOG.debug("DPN {} empty. Removing dpn from cache as well", dpnId);
+ qosAlertDpnPortNumberMap.remove(dpnId);
}
}
}
statsData.getReceiveDrops(), statsData.getTransmitDrops());
if (statsDataInit) {
calculateAlertCondition(statsData);
+ } else {
+ statsDataInit = true;
}
rxPackets = statsData.getPackets().getReceived();
rxDroppedPackets = statsData.getReceiveDrops();
- statsDataInit = true;
}
private void calculateAlertCondition(NodeConnectorStatisticsAndPortNumberMap statsData) {
BigInteger rxDiff = statsData.getPackets().getReceived().subtract(rxPackets);
BigInteger rxDroppedDiff = statsData.getReceiveDrops().subtract(rxDroppedPackets);
+ if ((rxDiff.signum() < 0) || (rxDroppedDiff.signum() < 0)) {
+ LOG.debug("Port {} counters reset", port.getUuid());
+ initPortData(); // counters wrapped. wait for one more poll.
+ return;
+ }
BigInteger rxTotalDiff = rxDiff.add(rxDroppedDiff);
LOG.trace("Port {} rxDiff:{} rxDropped diff:{} total diff:{}", port.getUuid(), rxDiff,
rxDroppedDiff, rxTotalDiff);
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosNetworkExtension;
}
}
}
- if (qosNeutronUtils.hasBandwidthLimitRule(port)) {
- qosAlertManager.addToQosAlertCache(port);
- }
+ qosAlertManager.processInterfaceUpEvent(interfaceName);
});
}
} catch (Exception e) {
String lowerLayerIf = intrf.getLowerLayerIf().get(0);
LOG.trace("lowerLayerIf {}", lowerLayerIf);
- qosAlertManager.removeFromQosAlertCache(new NodeConnectorId(lowerLayerIf));
+ qosAlertManager.removeLowerLayerIfFromQosAlertCache(lowerLayerIf);
QosPortExtension removeQos = port.getAugmentation(QosPortExtension.class);
if (removeQos != null) {
qosNeutronUtils.handleNeutronPortRemove(port, removeQos.getQosPolicyId(), intrf);
QosNeutronNetworkChangeListener> implements RecoverableListener {
private static final Logger LOG = LoggerFactory.getLogger(QosNeutronNetworkChangeListener.class);
private final DataBroker dataBroker;
- private final QosAlertManager qosAlertManager;
private final QosNeutronUtils qosNeutronUtils;
@Inject
- public QosNeutronNetworkChangeListener(final DataBroker dataBroker, final QosAlertManager qosAlertManager,
+ public QosNeutronNetworkChangeListener(final DataBroker dataBroker,
final QosNeutronUtils qosNeutronUtils,
final ServiceRecoveryRegistry serviceRecoveryRegistry,
final QosServiceRecoveryHandler qosServiceRecoveryHandler) {
super(Network.class, QosNeutronNetworkChangeListener.class);
this.dataBroker = dataBroker;
- this.qosAlertManager = qosAlertManager;
this.qosNeutronUtils = qosNeutronUtils;
serviceRecoveryRegistry.addRecoverableListener(qosServiceRecoveryHandler.buildServiceRegistryKey(),
this);
@Override
protected void remove(InstanceIdentifier<Network> instanceIdentifier, Network network) {
qosNeutronUtils.removeFromNetworkCache(network);
- if (qosNeutronUtils.hasBandwidthLimitRule(network)) {
- qosAlertManager.removeFromQosAlertCache(network);
- }
}
@Override
// qosservice policy add
qosNeutronUtils.addToQosNetworksCache(updateQos.getQosPolicyId(), update);
qosNeutronUtils.handleNeutronNetworkQosUpdate(update, updateQos.getQosPolicyId());
- if (qosNeutronUtils.hasBandwidthLimitRule(update)) {
- qosAlertManager.addToQosAlertCache(update);
- }
} else if (originalQos != null && updateQos != null
&& !originalQos.getQosPolicyId().equals(updateQos.getQosPolicyId())) {
-
// qosservice policy update
-
qosNeutronUtils.removeFromQosNetworksCache(originalQos.getQosPolicyId(), original);
qosNeutronUtils.addToQosNetworksCache(updateQos.getQosPolicyId(), update);
qosNeutronUtils.handleNeutronNetworkQosUpdate(update, updateQos.getQosPolicyId());
-
- if (qosNeutronUtils.hasBandwidthLimitRule(original)
- && !qosNeutronUtils.hasBandwidthLimitRule(update)) {
- qosAlertManager.removeFromQosAlertCache(original);
- } else if (!qosNeutronUtils.hasBandwidthLimitRule(original)
- && qosNeutronUtils.hasBandwidthLimitRule(update)) {
- qosAlertManager.addToQosAlertCache(update);
- }
-
} else if (originalQos != null && updateQos == null) {
// qosservice policy delete
- if (qosNeutronUtils.hasBandwidthLimitRule(original)) {
- qosAlertManager.removeFromQosAlertCache(original);
- }
qosNeutronUtils.handleNeutronNetworkQosRemove(original, originalQos.getQosPolicyId());
qosNeutronUtils.removeFromQosNetworksCache(originalQos.getQosPolicyId(), original);
}
if (networkQos != null) {
qosNeutronUtils.addToQosNetworksCache(networkQos.getQosPolicyId(), network);
qosNeutronUtils.handleNeutronNetworkQosUpdate(network, networkQos.getQosPolicyId());
- if (qosNeutronUtils.hasBandwidthLimitRule(network)) {
- qosAlertManager.addToQosAlertCache(network);
- }
-
}
}
}
QosNeutronPortChangeListener> implements RecoverableListener {
private static final Logger LOG = LoggerFactory.getLogger(QosNeutronPortChangeListener.class);
private final DataBroker dataBroker;
- private final QosAlertManager qosAlertManager;
private final QosNeutronUtils qosNeutronUtils;
@Inject
- public QosNeutronPortChangeListener(final DataBroker dataBroker, final QosAlertManager qosAlertManager,
+ public QosNeutronPortChangeListener(final DataBroker dataBroker,
final QosNeutronUtils qosNeutronUtils, final QosServiceRecoveryHandler qosServiceRecoveryHandler,
final ServiceRecoveryRegistry serviceRecoveryRegistry) {
super(Port.class, QosNeutronPortChangeListener.class);
this.dataBroker = dataBroker;
- this.qosAlertManager = qosAlertManager;
this.qosNeutronUtils = qosNeutronUtils;
serviceRecoveryRegistry.addRecoverableListener(qosServiceRecoveryHandler.buildServiceRegistryKey(),
this);
@Override
protected void add(InstanceIdentifier<Port> instanceIdentifier, Port port) {
qosNeutronUtils.addToPortCache(port);
- if (qosNeutronUtils.hasBandwidthLimitRule(port)) {
- qosAlertManager.addToQosAlertCache(port);
- }
}
@Override
protected void remove(InstanceIdentifier<Port> instanceIdentifier, Port port) {
qosNeutronUtils.removeFromPortCache(port);
- if (qosNeutronUtils.hasBandwidthLimitRule(port)) {
- qosAlertManager.removeFromQosAlertCache(port);
- }
}
@Override
qosNeutronUtils.removeFromQosPortsCache(originalQos.getQosPolicyId(), original);
}
- if (qosNeutronUtils.hasBandwidthLimitRule(original)
- && !qosNeutronUtils.hasBandwidthLimitRule(update)) {
- qosAlertManager.removeFromQosAlertCache(original);
- } else if (!qosNeutronUtils.hasBandwidthLimitRule(original)
- && qosNeutronUtils.hasBandwidthLimitRule(update)) {
- qosAlertManager.addToQosAlertCache(update);
- }
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceBindings;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress;
return String.valueOf(tableId) + dpId + lportTag;
}
- public String getPortNumberForInterface(String ifName) {
- GetPortFromInterfaceInput portNumberInput = new GetPortFromInterfaceInputBuilder().setIntfName(ifName).build();
- Future<RpcResult<GetPortFromInterfaceOutput>> portNumberOutput =
- odlInterfaceRpcService.getPortFromInterface(portNumberInput);
- try {
- RpcResult<GetPortFromInterfaceOutput> portResult = portNumberOutput.get();
- if (portResult.isSuccessful()) {
- return portResult.getResult().getPortno().toString();
- }
- } catch (NullPointerException | InterruptedException | ExecutionException e) {
- LOG.warn("Exception when getting port for interface {}", e);
- }
- return null;
- }
-
public boolean portHasQosPolicy(Port port) {
LOG.trace("checking qos policy for port: {}", port.getUuid());
return isQosPolicy;
}
-
-
- public boolean hasBandwidthLimitRule(Port port) {
- Uuid qosUuid = null;
- boolean bwLimitRule = false;
-
- LOG.trace("checking bandwidth limit rule for port: {}", port.getUuid());
-
- if (port.getAugmentation(QosPortExtension.class) != null) {
- qosUuid = port.getAugmentation(QosPortExtension.class).getQosPolicyId();
- } else {
- Network network = neutronVpnManager.getNeutronNetwork(port.getNetworkId());
-
- if (network.getAugmentation(QosNetworkExtension.class) != null) {
- qosUuid = network.getAugmentation(QosNetworkExtension.class).getQosPolicyId();
- }
- }
-
- if (qosUuid != null) {
- QosPolicy qosPolicy = qosPolicyMap.get(qosUuid);
- if (qosPolicy != null && qosPolicy.getBandwidthLimitRules() != null
- && !qosPolicy.getBandwidthLimitRules().isEmpty()) {
- bwLimitRule = true;
- }
- }
-
- LOG.trace("Bandwidth limit rule for port: {} return value {}", port.getUuid(), bwLimitRule);
- return bwLimitRule;
- }
-
- public boolean hasBandwidthLimitRule(Network network) {
- boolean bwLimitRule = false;
-
- LOG.trace("checking bandwidth limit rule for network: {}", network.getUuid());
-
- if (network.getAugmentation(QosNetworkExtension.class) != null) {
- Uuid qosUuid = network.getAugmentation(QosNetworkExtension.class).getQosPolicyId();
-
- if (qosUuid != null) {
- QosPolicy qosPolicy = qosPolicyMap.get(qosUuid);
- if (qosPolicy != null && qosPolicy.getBandwidthLimitRules() != null
- && !qosPolicy.getBandwidthLimitRules().isEmpty()) {
- bwLimitRule = true;
- }
- }
- }
-
- LOG.trace("Bandwidth limit rule for network: {} return value {}", network.getUuid(), bwLimitRule);
- return bwLimitRule;
- }
-
@Nullable
public QosPolicy getQosPolicy(Port port) {
Uuid qosUuid = null;
public Network getNeutronNetwork(Uuid networkUuid) {
return neutronNetworkMap.get(networkUuid);
}
+
+ public static BigInteger getDpnIdFromLowerLayerIf(String lowerLayerIf) {
+ try {
+ return new BigInteger(lowerLayerIf.substring(lowerLayerIf.indexOf(":") + 1, lowerLayerIf.lastIndexOf(":")));
+ } catch (NullPointerException e) {
+ return null;
+ }
+ }
+
+ public static String getPortNumberFromLowerLayerIf(String lowerLayerIf) {
+ try {
+ return (lowerLayerIf.substring(lowerLayerIf.lastIndexOf(":") + 1));
+ } catch (NullPointerException e) {
+ return null;
+ }
+ }
+
}
private static final Logger LOG = LoggerFactory.getLogger(QosPolicyChangeListener.class);
private final DataBroker dataBroker;
private final ManagedNewTransactionRunner txRunner;
- private final QosAlertManager qosAlertManager;
private final QosNeutronUtils qosNeutronUtils;
private final JobCoordinator jobCoordinator;
@Inject
- public QosPolicyChangeListener(final DataBroker dataBroker, final QosAlertManager qosAlertManager,
+ public QosPolicyChangeListener(final DataBroker dataBroker,
final QosNeutronUtils qosNeutronUtils, final JobCoordinator jobCoordinator,
final ServiceRecoveryRegistry serviceRecoveryRegistry,
final QosServiceRecoveryHandler qosServiceRecoveryHandler) {
super(QosPolicy.class, QosPolicyChangeListener.class);
this.dataBroker = dataBroker;
this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
- this.qosAlertManager = qosAlertManager;
this.qosNeutronUtils = qosNeutronUtils;
this.jobCoordinator = jobCoordinator;
serviceRecoveryRegistry.addRecoverableListener(qosServiceRecoveryHandler.buildServiceRegistryKey(),
Uuid qosUuid = identifier.firstKeyOf(QosPolicy.class).getUuid();
for (Network network : qosNeutronUtils.getQosNetworks(qosUuid)) {
qosNeutronUtils.handleNeutronNetworkQosUpdate(network, qosUuid);
- qosAlertManager.addToQosAlertCache(network);
}
for (Port port : qosNeutronUtils.getQosPorts(qosUuid)) {
- qosAlertManager.addToQosAlertCache(port);
jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> Collections.singletonList(
txRunner.callWithNewWriteOnlyTransactionAndSubmit(
tx -> qosNeutronUtils.setPortBandwidthLimits(port, input, tx))));
bwLimitBuilder.setMaxBurstKbps(BigInteger.ZERO).setMaxKbps(BigInteger.ZERO).build();
for (Network network : qosNeutronUtils.getQosNetworks(qosUuid)) {
- qosAlertManager.removeFromQosAlertCache(network);
qosNeutronUtils.handleNeutronNetworkQosBwRuleRemove(network, zeroBwLimitRule);
}
for (Port port : qosNeutronUtils.getQosPorts(qosUuid)) {
- qosAlertManager.removeFromQosAlertCache(port);
jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> Collections.singletonList(
txRunner.callWithNewWriteOnlyTransactionAndSubmit(
tx -> qosNeutronUtils.setPortBandwidthLimits(port, zeroBwLimitRule, tx))));
private final DataBroker dataBroker;
private final QosNeutronUtils qosNeutronUtils;
private final QosEosHandler qosEosHandler;
+ private final QosAlertManager qosAlertManager;
private final ManagedNewTransactionRunner txRunner;
private final JobCoordinator jobCoordinator;
public QosTerminationPointListener(final DataBroker dataBroker,
final QosNeutronUtils qosNeutronUtils,
final QosEosHandler qosEosHandler,
+ final QosAlertManager qosAlertManager,
final JobCoordinator jobCoordinator) {
super(OvsdbTerminationPointAugmentation.class, QosTerminationPointListener.class);
this.dataBroker = dataBroker;
this.qosNeutronUtils = qosNeutronUtils;
this.qosEosHandler = qosEosHandler;
+ this.qosAlertManager = qosAlertManager;
this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
this.jobCoordinator = jobCoordinator;
}
@Override
protected void remove(InstanceIdentifier<OvsdbTerminationPointAugmentation> instanceIdentifier,
OvsdbTerminationPointAugmentation tp) {
-
+ if (isBandwidthRuleApplied(tp)) {
+ String ifaceId = getIfaceId(tp);
+ if (ifaceId != null) {
+ qosAlertManager.removeInterfaceIdFromQosAlertCache(ifaceId);
+ }
+ }
}
private boolean isBandwidthRuleCleared(OvsdbTerminationPointAugmentation original,
return false;
}
+ private boolean isBandwidthRuleApplied(OvsdbTerminationPointAugmentation tp) {
+ if (tp.getIngressPolicingRate() != 0 || tp.getIngressPolicingBurst() != 0) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isBandwidthRuleApplied(OvsdbTerminationPointAugmentation original,
+ OvsdbTerminationPointAugmentation update) {
+ if ((original.getIngressPolicingRate() == 0 && original.getIngressPolicingBurst() == 0)
+ && (update.getIngressPolicingRate() != 0 || update.getIngressPolicingBurst() != 0)) {
+ return true;
+ }
+ return false;
+ }
+
@Override
protected void update(InstanceIdentifier<OvsdbTerminationPointAugmentation> instanceIdentifier,
OvsdbTerminationPointAugmentation original,
OvsdbTerminationPointAugmentation update) {
+ String ifaceId = getIfaceId(update);
+ if (ifaceId != null) {
+ if (isBandwidthRuleCleared(original, update)) {
+ qosAlertManager.removeInterfaceIdFromQosAlertCache(ifaceId);
+ } else if (isBandwidthRuleApplied(original, update)) {
+ qosAlertManager.addInterfaceIdInQoSAlertCache(ifaceId);
+ }
+ }
if (!qosEosHandler.isQosClusterOwner()) {
return;
}
- String ifaceId = getIfaceId(update);
-
// switch restart scenario with openstack newton onwards results in deletion and addition
// of vhu ports with ovs-dpdk and as a side effect of that, qos parameters for rate limiting
// get cleared from the port.
@Override
protected void add(InstanceIdentifier<OvsdbTerminationPointAugmentation> instanceIdentifier,
OvsdbTerminationPointAugmentation tpAugment) {
- if (!qosEosHandler.isQosClusterOwner()) {
- return;
- }
String ifaceId = getIfaceId(tpAugment);
- if (ifaceId != null) {
+ if ((ifaceId != null) && isBandwidthRuleApplied(tpAugment)) {
+ qosAlertManager.addInterfaceIdInQoSAlertCache(ifaceId);
+ }
+ if ((ifaceId != null) && qosEosHandler.isQosClusterOwner()) {
Port port = qosNeutronUtils.getNeutronPort(ifaceId);
if (port != null) {
LOG.debug("add tp augmentation: iface-id: {}, name: {} ", ifaceId, tpAugment.getName());
interface="org.opendaylight.infrautils.jobcoordinator.JobCoordinator" />
<reference id="serviceRecoveryRegistry"
interface="org.opendaylight.genius.srm.ServiceRecoveryRegistry"/>
+ <reference id="iInterfaceManager"
+ interface="org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager" />
<odl:rpc-service id="odlInterfaceRpcService"
interface="org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService" />