package org.opendaylight.netvirt.qosservice;
+import javax.annotation.Nullable;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
}
@Override
+ @Nullable
protected Object doExecute() {
LOG.debug("Setting poll enable in qos alert manager:{}", value);
qosAlertManager.setEnable(Boolean.parseBoolean(value));
package org.opendaylight.netvirt.qosservice;
+import javax.annotation.Nullable;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
}
@Override
+ @Nullable
protected Object doExecute() {
LOG.debug("setting threshold in qos alert manager:{}", interval);
qosAlertManager.setPollInterval(Integer.parseInt(interval));
package org.opendaylight.netvirt.qosservice;
+import javax.annotation.Nullable;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
}
@Override
+ @Nullable
protected Object doExecute() {
LOG.debug("setting threshold in qos alert manager:{}", threshold);
qosAlertManager.setThreshold(Short.parseShort(threshold));
*/
package org.opendaylight.netvirt.qosservice;
+import java.util.Objects;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
qosNeutronUtils.addToQosNetworksCache(updateQos.getQosPolicyId(), update);
qosNeutronUtils.handleNeutronNetworkQosUpdate(update, updateQos.getQosPolicyId());
} else if (originalQos != null && updateQos != null
- && !originalQos.getQosPolicyId().equals(updateQos.getQosPolicyId())) {
+ && !Objects.equals(originalQos.getQosPolicyId(), updateQos.getQosPolicyId())) {
// qosservice policy update
qosNeutronUtils.removeFromQosNetworksCache(originalQos.getQosPolicyId(), original);
qosNeutronUtils.addToQosNetworksCache(updateQos.getQosPolicyId(), update);
import java.math.BigInteger;
import java.util.Collections;
+import java.util.Objects;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
qosNeutronUtils.addToQosPortsCache(updateQos.getQosPolicyId(), update);
qosNeutronUtils.handleNeutronPortQosAdd(update, updateQos.getQosPolicyId());
} else if (originalQos != null && updateQos != null
- && !originalQos.getQosPolicyId().equals(updateQos.getQosPolicyId())) {
+ && !Objects.equals(originalQos.getQosPolicyId(), updateQos.getQosPolicyId())) {
// qosservice policy update
qosNeutronUtils.removeFromQosPortsCache(originalQos.getQosPolicyId(), original);
*/
package org.opendaylight.netvirt.qosservice;
+import static java.util.Collections.emptyList;
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import com.google.common.base.Optional;
public Collection<Port> getQosPorts(Uuid qosUuid) {
final ConcurrentMap<Uuid, Port> portMap = qosPortsMap.get(qosUuid);
- return portMap != null ? portMap.values() : Collections.emptyList();
+ return portMap != null ? portMap.values() : emptyList();
}
public void addToQosPortsCache(Uuid qosUuid, Port port) {
@Nonnull
public Collection<Network> getQosNetworks(Uuid qosUuid) {
final ConcurrentMap<Uuid, Network> networkMap = qosNetworksMap.get(qosUuid);
- return networkMap != null ? networkMap.values() : Collections.emptyList();
+ return networkMap != null ? networkMap.values() : emptyList();
}
@Nonnull
.child(NetworkMap.class, new NetworkMapKey(networkId)).build();
Optional<NetworkMap> optionalNetworkMap = MDSALUtil.read(LogicalDatastoreType.CONFIGURATION,
networkMapId, dataBroker);
- return optionalNetworkMap.isPresent() ? optionalNetworkMap.get().getSubnetIdList() : Collections.emptyList();
+ return optionalNetworkMap.isPresent() ? nullToEmpty(optionalNetworkMap.get().getSubnetIdList()) : emptyList();
}
@Nonnull
.child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
Optional<Subnetmap> optionalSubnetmap = MDSALUtil.read(LogicalDatastoreType.CONFIGURATION,
subnetMapId,dataBroker);
- return optionalSubnetmap.isPresent() ? optionalSubnetmap.get().getPortList() : Collections.emptyList();
+ return optionalSubnetmap.isPresent() ? nullToEmpty(optionalSubnetmap.get().getPortList()) : emptyList();
}
public void handleNeutronPortQosAdd(Port port, Uuid qosUuid) {
&& !qosPolicy.getDscpmarkingRules().isEmpty()) {
setPortDscpMarking(port, qosPolicy.getDscpmarkingRules().get(0));
}
- return Collections.emptyList();
+ return emptyList();
});
}
&& !qosPolicy.getDscpmarkingRules().isEmpty()) {
unsetPortDscpMark(port);
}
- return Collections.emptyList();
+ return emptyList();
});
}
&& !qosPolicy.getDscpmarkingRules().isEmpty()) {
unsetPortDscpMark(port, intrf);
}
- return Collections.emptyList();
+ return emptyList();
});
}
|| port.augmentation(QosPortExtension.class).getQosPolicyId() == null)) {
jobCoordinator.enqueueJob("QosPort-" + portId.getValue(), () -> {
unsetPortDscpMark(port);
- return Collections.emptyList();
+ return emptyList();
});
}
}
return neutronNetworkMap.get(networkUuid);
}
+ @Nullable
public static BigInteger getDpnIdFromLowerLayerIf(String lowerLayerIf) {
try {
return new BigInteger(lowerLayerIf.substring(lowerLayerIf.indexOf(":") + 1, lowerLayerIf.lastIndexOf(":")));
}
}
+ @Nullable
public static String getPortNumberFromLowerLayerIf(String lowerLayerIf) {
try {
return (lowerLayerIf.substring(lowerLayerIf.lastIndexOf(":") + 1));
}
public boolean hasIpv4Addr(int versions) {
- if ((versions & (1 << QosConstants.IPV4_ADDR_MASK_BIT)) != 0) {
- return true;
- }
- return false;
+ return (versions & (1 << QosConstants.IPV4_ADDR_MASK_BIT)) != 0;
}
public boolean hasIpv6Addr(int versions) {
- if ((versions & (1 << QosConstants.IPV6_ADDR_MASK_BIT)) != 0) {
- return true;
- }
- return false;
+ return (versions & (1 << QosConstants.IPV6_ADDR_MASK_BIT)) != 0;
+ }
+
+ // TODO Replace this with mdsal's DataObjectUtils.nullToEmpty when upgrading to mdsal 3
+ @Nonnull
+ public static <T> List<T> nullToEmpty(final @Nullable List<T> input) {
+ return input != null ? input : emptyList();
}
}
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+import static org.opendaylight.netvirt.qosservice.QosNeutronUtils.nullToEmpty;
import java.math.BigInteger;
import java.util.ArrayList;
return;
}
- if (!qosNeutronUtils.getQosPolicyMap().get(policyUuid).getBandwidthLimitRules().isEmpty()) {
+ if (!nullToEmpty(qosNeutronUtils.getQosPolicyMap().get(policyUuid).getBandwidthLimitRules()).isEmpty()) {
BandwidthLimitRules bandwidthLimitRules =
qosNeutronUtils.getQosPolicyMap().get(policyUuid).getBandwidthLimitRules().get(0);
update(policyUuid, bandwidthLimitRules);
}
- if (!qosNeutronUtils.getQosPolicyMap().get(policyUuid).getDscpmarkingRules().isEmpty()) {
+ if (!nullToEmpty(qosNeutronUtils.getQosPolicyMap().get(policyUuid).getDscpmarkingRules()).isEmpty()) {
DscpmarkingRules dscpmarkingRules =
qosNeutronUtils.getQosPolicyMap().get(policyUuid).getDscpmarkingRules().get(0);
update(policyUuid, dscpmarkingRules);
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import java.util.Collections;
+import javax.annotation.Nullable;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
})));
}
+ @Nullable
private String getIfaceId(OvsdbTerminationPointAugmentation tpAugmentation) {
if (tpAugmentation.getInterfaceExternalIds() != null) {
for (InterfaceExternalIds entry: tpAugmentation.getInterfaceExternalIds()) {
- if (entry.getExternalIdKey().equals(EXTERNAL_ID_INTERFACE_ID)) {
+ if (EXTERNAL_ID_INTERFACE_ID.equals(entry.getExternalIdKey())) {
return entry.getExternalIdValue();
}
}