import java.util.List;
import java.util.Set;
+import javax.annotation.Nullable;
import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
void addL2GatewayConnection(L2gatewayConnection input);
void addL2GatewayConnection(L2gatewayConnection input,
- String l2GwDeviceName,
+ @Nullable String l2GwDeviceName,
L2gateway l2Gateway);
List<L2gatewayConnection> getAssociatedL2GwConnections(Set<Uuid> l2GatewayIds);
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import javax.annotation.Nullable;
import org.opendaylight.genius.utils.cache.CacheUtil;
import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
cachedMap.values().forEach(deviceMap -> deviceMap.remove(deviceName));
}
-
+ @Nullable
public static L2GatewayDevice removeL2GatewayDeviceFromCache(String elanName, String l2gwDeviceNodeId) {
ConcurrentMap<String, ConcurrentMap<String, L2GatewayDevice>> cachedMap =
(ConcurrentMap<String, ConcurrentMap<String, L2GatewayDevice>>) CacheUtil.getCache(
}
}
+ @Nullable
public static L2GatewayDevice getL2GatewayDeviceFromCache(String elanName, String l2gwDeviceNodeId) {
ConcurrentMap<String, ConcurrentMap<String, L2GatewayDevice>> cachedMap =
(ConcurrentMap<String, ConcurrentMap<String, L2GatewayDevice>>) CacheUtil.getCache(
return result;
}
+ @Nullable
public static List<L2GatewayDevice> getAllElanDevicesFromCache() {
ConcurrentMap<String, ConcurrentMap<String, L2GatewayDevice>> cachedMap =
(ConcurrentMap<String, ConcurrentMap<String, L2GatewayDevice>>) CacheUtil.getCache(
*/
package org.opendaylight.netvirt.elan.cli;
+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() {
if (macTimeOut == -1) {
macTimeOut = 30;
*/
package org.opendaylight.netvirt.elan.cli;
+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("Executing the Deletion of ElanInstance command for elanName: {}", elanName);
boolean isSuccess = elanProvider.deleteElanInstance(elanName);
package org.opendaylight.netvirt.elan.cli;
import java.util.List;
+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("Executing Get ElanInstance command for elanName: {}", elanName);
if (elanName != null) {
package org.opendaylight.netvirt.elan.cli;
import java.util.List;
+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("Executing create ElanInterface command for elanName:{}, interfaceName:{}, staticMacAddresses:{},"
+ "elanInterfaceDescr:{}",elanName, interfaceName, staticMacAddresses, elanInterfaceDescr);
*/
package org.opendaylight.netvirt.elan.cli;
+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("Deleting ElanInterface command for elanName:{}, interfaceName:{}", elanName, interfaceName);
elanProvider.deleteElanInterface(interfaceName);
package org.opendaylight.netvirt.elan.cli;
import java.util.List;
+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("Executing Get ElanInterface command for the corresponding Elan Instance for {}", elanName);
if (elanName != null) {
package org.opendaylight.netvirt.elan.cli;
import java.util.List;
+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("Executing elanInterface update command for elanName:{}, interfaceName:{}, staticMacAddresses:{},"
+ "elanInterfaceDescr:{}", elanName, interfaceName, staticMacAddresses, elanInterfaceDescr);
*/
package org.opendaylight.netvirt.elan.cli;
+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("Executing mac table flush command for {}", elanName);
elanProvider.flushMACTable(elanName);
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
+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("Executing elan mac table get command for {}", elanName);
Collection<MacEntry> macTables = elanProvider.getElanMacTable(elanName);
*/
package org.opendaylight.netvirt.elan.cli;
+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("Updating elanInstance update command for elanName:{}, macTimeOut:{}, elanDescr:{}",
elanName, macTimeOut, elanDescr);
*/
package org.opendaylight.netvirt.elan.cli;
+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("Executing static mac add command for elanName:{}, interfaceName:{}, staticMacAddress:{}",
elanName, interfaceName, staticMacAddress);
*/
package org.opendaylight.netvirt.elan.cli;
+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("Executing static mac delete command for elanName:{}, interfaceName:{}, staticMacAddress:{}",
elanName, interfaceName, staticMacAddress);
*/
package org.opendaylight.netvirt.elan.cli.etree;
+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() {
if (macTimeOut == -1) {
macTimeOut = 30;
*/
package org.opendaylight.netvirt.elan.cli.etree;
+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("Executing the Deletion of EtreeInstance command {}", etreeName);
boolean isSuccess = elanProvider.deleteEtreeInstance(etreeName);
package org.opendaylight.netvirt.elan.cli.etree;
import java.util.List;
+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("Executing Get EtreeInstance command for {}", etreeName);
if (etreeName != null) {
package org.opendaylight.netvirt.elan.cli.etree;
import java.util.List;
+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() {
EtreeInterfaceType inputType = null;
for (EtreeInterfaceType type : EtreeInterfaceType.values()) {
*/
package org.opendaylight.netvirt.elan.cli.etree;
+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("Deleting EtreeInterface command etreeName:{}, interfaceName:{}", etreeName, interfaceName);
ElanInterface existingInterface =
package org.opendaylight.netvirt.elan.cli.etree;
import java.util.List;
+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("Executing Get EtreeInterface command for the corresponding Etree Instance {}", etreeName);
if (etreeName != null) {
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentMap;
+import javax.annotation.Nullable;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.console.OsgiCommandSupport;
}
@Override
+ @Nullable
protected Object doExecute() throws IOException {
if (cacheName == null) {
session.getConsole().println("Available caches");
package org.opendaylight.netvirt.elan.cli.l2gw;
+import static java.util.Collections.emptyList;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
+
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.Sets;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
+import javax.annotation.Nullable;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@Override
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
+ @Nullable
public Object doExecute() throws Exception {
try {
pw = new PrintWriter(new FileOutputStream(new File("l2gw.validation.txt")));
Optional<Topology> configTopoOptional = tx.read(LogicalDatastoreType.CONFIGURATION, topoId).checkedGet();
if (operationalTopoOptional.isPresent()) {
- for (Node node : operationalTopoOptional.get().getNode()) {
+ for (Node node : requireNonNullElse(operationalTopoOptional.get().getNode(),
+ Collections.<Node>emptyList())) {
InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.key());
operationalNodes.put(nodeIid, node);
}
}
if (configTopoOptional.isPresent()) {
- for (Node node : configTopoOptional.get().getNode()) {
+ for (Node node : requireNonNullElse(configTopoOptional.get().getNode(),
+ Collections.<Node>emptyList())) {
InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.key());
configNodes.put(nodeIid, node);
}
return false;
}
+ @Nullable
private DataObject getData(Map<InstanceIdentifier<Node>, Map<InstanceIdentifier, DataObject>> dataMap,
InstanceIdentifier<Node> nodeIid, InstanceIdentifier dataIid) {
if (dataMap.containsKey(nodeIid)) {
L2gateway l2gateway = uuidToL2Gateway.get(l2gatewayConnection.getL2gatewayId());
String logicalSwitchName = l2gatewayConnection.getNetworkId().getValue();
- List<Devices> devices = l2gateway.getDevices();
+ List<Devices> devices = requireNonNullElse(l2gateway.getDevices(), emptyList());
for (Devices device : devices) {
}
VlanBindings expectedBindings = !expectedVlans.isEmpty() ? expectedVlans.get(0) : null;
boolean foundBindings = false;
- List<VlanBindings> vlanBindingses = configTerminationPoint.augmentation(
- HwvtepPhysicalPortAugmentation.class).getVlanBindings();
+ List<VlanBindings> vlanBindingses = requireNonNullElse(configTerminationPoint.augmentation(
+ HwvtepPhysicalPortAugmentation.class).getVlanBindings(), emptyList());
for (VlanBindings actual : vlanBindingses) {
if (actual.equals(expectedBindings)) {
foundBindings = true;
package org.opendaylight.netvirt.elan.cli.l2gw;
+import static java.util.Collections.emptyList;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
+
import com.google.common.base.Optional;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.annotation.Nullable;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.console.OsgiCommandSupport;
}
@Override
+ @Nullable
protected Object doExecute() {
List<Node> nodes = new ArrayList<>();
Set<String> networks = new HashSet<>();
Optional<Topology> topologyOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
createHwvtepTopologyInstanceIdentifier());
if (topologyOptional.isPresent()) {
- nodes = topologyOptional.get().getNode();
+ nodes = requireNonNullElse(topologyOptional.get().getNode(), emptyList());
}
} else {
Optional<Node> nodeOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
if (elanName.equals(lsFromLocalMac)) {
String mac = localMac.getMacEntryKey().getValue();
List<String> locatorsets = new ArrayList<>();
- for (LocatorSet locatorSet : localMac.getLocatorSet()) {
+ for (LocatorSet locatorSet : requireNonNullElse(localMac.getLocatorSet(),
+ Collections.<LocatorSet>emptyList())) {
locatorsets.add(getLocatorValue(locatorSet.getLocatorRef()));
}
session.getConsole().println(mac + GAP + locatorsets.toString());
if (elanName.equals(lsFromremoteMac)) {
String mac = remoteMac.getMacEntryKey().getValue();
List<String> locatorsets = new ArrayList<>();
- for (LocatorSet locatorSet : remoteMac.getLocatorSet()) {
+ for (LocatorSet locatorSet : requireNonNullElse(remoteMac.getLocatorSet(),
+ Collections.<LocatorSet>emptyList())) {
locatorsets.add(getLocatorValue(locatorSet.getLocatorRef()));
}
session.getConsole().println(mac + GAP + locatorsets.toString());
}
+ @Nullable
String getLocatorValue(HwvtepPhysicalLocatorRef locatorRef) {
if (locatorRef == null) {
return null;
.firstKeyOf(TerminationPoint.class).getTpId().getValue();
}
+ @Nullable
String getLogicalSwitchValue(HwvtepLogicalSwitchRef logicalSwitchRef) {
if (logicalSwitchRef == null) {
return null;
.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue();
}
+ @Nullable
Node getPSnode(Node hwvtepNode, LogicalDatastoreType datastoreType) {
- if (hwvtepNode.augmentation(HwvtepGlobalAugmentation.class) != null
- && hwvtepNode.augmentation(HwvtepGlobalAugmentation.class).getSwitches() != null) {
- for (Switches switches : hwvtepNode.augmentation(HwvtepGlobalAugmentation.class).getSwitches()) {
- NodeId psNodeId = switches.getSwitchRef().getValue().firstKeyOf(Node.class).getNodeId();
- return HwvtepUtils.getHwVtepNode(dataBroker, datastoreType, psNodeId);
+ if (hwvtepNode.augmentation(HwvtepGlobalAugmentation.class) != null) {
+ List<Switches> switches = hwvtepNode.augmentation(HwvtepGlobalAugmentation.class).getSwitches();
+ if (switches != null) {
+ return HwvtepUtils.getHwVtepNode(dataBroker, datastoreType,
+ switches.iterator().next().getSwitchRef().getValue().firstKeyOf(Node.class).getNodeId());
}
}
return null;
}
}
+ @Nullable
public String getRoutePathNexthopIp(MacVrfEntry macVrfEntry) {
if (macVrfEntry.getRoutePaths() == null || macVrfEntry.getRoutePaths().isEmpty()) {
LOG.debug("RoutePaths is null or empty for macvrfentry {}", macVrfEntry);
*/
package org.opendaylight.netvirt.elan.evpn.utils;
+import static java.util.Collections.emptyList;
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.Futures;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Predicate;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
});
}
+ @Nullable
public String getEndpointIpAddressForDPN(BigInteger dpnId) {
Future<RpcResult<GetDpnEndpointIpsOutput>> result = itmRpcService.getDpnEndpointIps(
: interfaceManager.getInterfaceInfoFromOperationalDataStore(ifName).getMacAddress());
}
+ @Nullable
public String getL3vpnNameFromElan(ElanInstance elanInfo) {
if (elanInfo == null) {
LOG.debug("getL3vpnNameFromElan :elanInfo is NULL");
return evpnAugmentation != null ? evpnAugmentation.getL3vpnName() : null;
}
+ @Nullable
public static String getEvpnNameFromElan(ElanInstance elanInfo) {
if (elanInfo == null) {
LOG.debug("getEvpnNameFromElan :elanInfo is NULL");
return evpnAugmentation != null ? evpnAugmentation.getEvpnName() : null;
}
+ @Nullable
public String getEvpnRd(ElanInstance elanInfo) {
String evpnName = getEvpnNameFromElan(elanInfo);
if (evpnName == null) {
LOG.info("No External Tunnel Configured while programming the l2vni table.");
return tunnelInterfaceNameList;
}
- List<ExternalTunnel> externalTunnels = externalTunnelListOptional.get().getExternalTunnel();
+ List<ExternalTunnel> externalTunnels =
+ requireNonNullElse(externalTunnelListOptional.get().getExternalTunnel(), emptyList());
- dcGatewayIps
+ requireNonNullElse(dcGatewayIps, Collections.<DcGatewayIp>emptyList())
.forEach(dcIp -> externalTunnels
.stream()
.filter(externalTunnel -> externalTunnel.getDestinationDevice()
import java.util.Map;
import java.util.Optional;
import java.util.Random;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
}
+ @Nullable
private List<ManagedNodeEntry> getManagedNodeEntries(Node node) {
OvsdbNodeAugmentation ovsdbNode = southboundUtils.extractNodeAugmentation(node);
if (ovsdbNode == null) {
* @param mac mac address to set on the bridge or null
* @return true if no errors occurred
*/
- public boolean addBridge(Node ovsdbNode, String bridgeName, String mac) {
+ public boolean addBridge(Node ovsdbNode, String bridgeName, @Nullable String mac) {
boolean rv = true;
if (southboundUtils.getBridgeFromConfig(ovsdbNode, bridgeName) == null) {
Class<? extends DatapathTypeBase> dpType = null;
* @param physicalNetworkName name of physical network
* @return physical network name
*/
+ @Nullable
public String getProviderMappingValue(Node node, String physicalNetworkName) {
Map<String, String> providerMappings = getOpenvswitchOtherConfigMap(node, PROVIDER_MAPPINGS_KEY);
String providerMappingValue = providerMappings.get(physicalNetworkName);
* {@inheritDoc}.
*/
@Override
+ @Nullable
public Node getBridgeNode(BigInteger dpId) {
List<Node> ovsdbNodes = southboundUtils.getOvsdbNodes();
if (null == ovsdbNodes) {
return null;
}
+ @Nullable
public String getProviderInterfaceName(BigInteger dpId, String physicalNetworkName) {
Node brNode;
return getProviderInterfaceName(brNode, physicalNetworkName);
}
+ @Nullable
public String getProviderInterfaceName(Node bridgeNode, String physicalNetworkName) {
if (physicalNetworkName == null) {
return null;
}
public boolean hasDatapathID(Node node) {
- return southboundUtils.getDataPathId(node) > 0 ? true : false;
+ return southboundUtils.getDataPathId(node) > 0;
}
- public Boolean isBridgeOnOvsdbNode(Node ovsdbNode, String bridgename) {
+ public boolean isBridgeOnOvsdbNode(Node ovsdbNode, String bridgename) {
return southboundUtils.isBridgeOnOvsdbNode(ovsdbNode, bridgename);
}
*/
package org.opendaylight.netvirt.elan.internal;
-import java.util.Collections;
+import static java.util.Collections.emptyList;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
+
+import java.util.List;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
elanClusterUtils.runOnlyInOwnerNode(elanName, "updating mcast mac upon tunnel event",
() -> {
elanL2GatewayMulticastUtils.updateRemoteMcastMacOnElanL2GwDevices(elanName);
- return Collections.emptyList();
+ return emptyList();
});
}
@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original,
final DpnInterfaces dpnInterfaces) {
- LOG.debug("dpninterfaces update fired new size {}", dpnInterfaces.getInterfaces().size());
- if (dpnInterfaces.getInterfaces().isEmpty()) {
+ List<String> interfaces = requireNonNullElse(dpnInterfaces.getInterfaces(), emptyList());
+ LOG.debug("dpninterfaces update fired new size {}", interfaces.size());
+ if (interfaces.isEmpty()) {
elanInstanceDpnsCache.remove(getElanName(identifier), dpnInterfaces);
LOG.debug("dpninterfaces last dpn interface on this elan {} ", dpnInterfaces.key());
// this is the last dpn interface on this elan
elanL2GatewayMulticastUtils.updateRemoteMcastMacOnElanL2GwDevices(elanName);
}
}
- return null;
+ return emptyList();
});
}
package org.opendaylight.netvirt.elan.internal;
+import static java.util.Collections.emptyList;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
+
import java.math.BigInteger;
-import java.util.Collections;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
- List<String> interfaces = update.getInterfaces();
+ List<String> interfaces = requireNonNullElse(update.getInterfaces(), emptyList());
// trigger deletion for vlan provider intf on the DPN for the vlan provider network
if (interfaces.size() == 1 && interfaceManager.isExternalInterface(interfaces.get(0))) {
LOG.debug("deleting vlan prv intf for elan {}, dpn {}", elanInstanceName, dpnId);
jobCoordinator.enqueueJob(dpnId.toString(), () -> {
elanService.deleteExternalElanNetwork(elanInstance, dpnId);
- return Collections.emptyList();
+ return emptyList();
});
}
}
LOG.debug("creating vlan member intf for elan {}, dpn {}",
elanInstance.getPhysicalNetworkName(), dpnId);
elanService.createExternalElanNetwork(elanInstance, dpnId);
- return Collections.emptyList();
+ return emptyList();
});
}
}
*/
package org.opendaylight.netvirt.elan.internal;
+import static java.util.Collections.emptyList;
import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
import static org.opendaylight.netvirt.elan.utils.ElanUtils.isVxlanNetworkOrVxlanSegment;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
return;
}
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, flowTx -> {
- List<String> elanInterfaces = elanState.getElanInterfaces();
+ List<String> elanInterfaces = requireNonNullElse(elanState.getElanInterfaces(), emptyList());
if (elanInterfaces.isEmpty()) {
holder.isLastElanInterface = true;
}
if (elanState == null) {
return elanState;
}
- List<String> elanInterfaces = elanState.getElanInterfaces();
+ List<String> elanInterfaces = requireNonNullElse(elanState.getElanInterfaces(), emptyList());
boolean isRemoved = elanInterfaces.remove(interfaceName);
if (!isRemoved) {
return elanState;
for (DpnInterfaces dpnInterface : dpnInterfaces) {
BigInteger currentDpId = dpnInterface.getDpId();
if (!currentDpId.equals(dpId)) {
- for (String elanInterface : dpnInterface.getInterfaces()) {
+ for (String elanInterface : requireNonNullElse(dpnInterface.getInterfaces(),
+ Collections.<String>emptyList())) {
ElanInterfaceMac macs = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
if (macs == null || macs.getMacEntry() == null) {
continue;
}
for (DpnInterfaces dpnInterfaces : dpnInterfaceLists) {
BigInteger dstDpId = interfaceInfo.getDpId();
- if (dpnInterfaces.getDpId().equals(dstDpId)) {
+ if (Objects.equals(dpnInterfaces.getDpId(), dstDpId)) {
continue;
}
List<String> remoteElanInterfaces = dpnInterfaces.getInterfaces();
holder.dpnInterfaces =
createElanInterfacesList(elanInstanceName, interfaceName, holder.dpId, operTx);
} else {
- List<String> elanInterfaces = existingElanDpnInterfaces.get().getInterfaces();
+ List<String> elanInterfaces =
+ requireNonNullElse(existingElanDpnInterfaces.get().getInterfaces(), emptyList());
elanInterfaces.add(interfaceName);
holder.dpnInterfaces = updateElanDpnInterfacesList(elanInstanceName, holder.dpId,
elanInterfaces, operTx);
elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(holder.dpId, elanInstance,
interfaceName);
} else {
- List<String> elanInterfaces = existingElanDpnInterfaces.get().getInterfaces();
+ List<String> elanInterfaces =
+ requireNonNullElse(existingElanDpnInterfaces.get().getInterfaces(), emptyList());
elanInterfaces.add(interfaceName);
if (elanInterfaces.size() == 1) { // 1st dpn interface
elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(holder.dpId, elanInstance,
}
DpnInterfaces dpnInterfaces = existingElanDpnInterfaces.get();
int dummyInterfaceCount = 0;
- if (dpnInterfaces.getInterfaces().contains(routerPortUuid)) {
+ List<String> interfaces = requireNonNullElse(dpnInterfaces.getInterfaces(), emptyList());
+ if (interfaces.contains(routerPortUuid)) {
dummyInterfaceCount++;
}
- if (dpnInterfaces.getInterfaces().contains(elanInstanceName)) {
+ if (interfaces.contains(elanInstanceName)) {
dummyInterfaceCount++;
}
- return dpnInterfaces.getInterfaces().size() - dummyInterfaceCount == 0;
+ return interfaces.size() - dummyInterfaceCount == 0;
}
private InstanceIdentifier<MacEntry> getMacEntryOperationalDataPath(String elanName, PhysAddress physAddress) {
int bucketId = 0;
ElanDpnInterfacesList elanDpns = elanUtils.getElanDpnInterfacesList(elanInfo.getElanInstanceName());
if (elanDpns != null) {
- List<DpnInterfaces> dpnInterfaces = elanDpns.getDpnInterfaces();
+ List<DpnInterfaces> dpnInterfaces = requireNonNullElse(elanDpns.getDpnInterfaces(), emptyList());
for (DpnInterfaces dpnInterface : dpnInterfaces) {
List<Bucket> remoteListBucketInfo = new ArrayList<>();
if (elanUtils.isDpnPresent(dpnInterface.getDpId()) && !Objects.equals(dpnInterface.getDpId(), dpId)
}
})));
}
- return Collections.emptyList();
+ return emptyList();
}
private void createDropBucket(List<Bucket> listBucket) {
long groupId = ElanUtils.getElanLocalBCGId(elanInfo.getElanTag());
List<String> interfaces = new ArrayList<>();
- if (newDpnInterface != null) {
+ if (newDpnInterface != null && newDpnInterface.getInterfaces() != null) {
interfaces = newDpnInterface.getInterfaces();
}
for (String ifName : interfaces) {
int bucketId = 0;
List<String> interfaces = new ArrayList<>();
- if (newDpnInterface != null) {
+ if (newDpnInterface != null && newDpnInterface.getInterfaces() != null) {
interfaces = newDpnInterface.getInterfaces();
}
for (String ifName : interfaces) {
if (dpnInterfaceLists == null) {
return;
}
- List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.getElanDpnInterfacesList();
+ List<ElanDpnInterfacesList> elanDpnIf =
+ requireNonNullElse(dpnInterfaceLists.getElanDpnInterfacesList(), emptyList());
for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
int cnt = 0;
String elanName = elanDpns.getElanInstanceName();
DpnInterfaces dstDpnIf = null;
for (DpnInterfaces dpnIf : dpnInterfaces) {
BigInteger dpnIfDpId = dpnIf.getDpId();
- if (dpnIfDpId.equals(srcDpId)) {
+ if (Objects.equals(dpnIfDpId, srcDpId)) {
cnt++;
- } else if (dpnIfDpId.equals(dstDpId)) {
+ } else if (Objects.equals(dpnIfDpId, dstDpId)) {
cnt++;
dstDpnIf = dpnIf;
}
if (isOperational(interfaceInfo)) {
return installDMacAddressTables(elanInfo, interfaceInfo, srcDpId);
}
- return Collections.emptyList();
+ return emptyList();
}, ElanConstants.JOB_MAX_RETRIES);
}
- return Collections.emptyList();
+ return emptyList();
}, ElanConstants.JOB_MAX_RETRIES);
}
if (dpnInterfaceLists == null) {
return;
}
- List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.getElanDpnInterfacesList();
+ List<ElanDpnInterfacesList> elanDpnIf =
+ requireNonNullElse(dpnInterfaceLists.getElanDpnInterfacesList(), emptyList());
for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
String elanName = elanDpns.getElanInstanceName();
ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
@Override
protected void add(InstanceIdentifier<Interface> identifier, final Interface intrf) {
if (intrf.getType() != null && intrf.getType().equals(Tunnel.class)) {
- if (intrf.getOperStatus().equals(Interface.OperStatus.Up)) {
+ if (Interface.OperStatus.Up.equals(intrf.getOperStatus())) {
final String interfaceName = intrf.getName();
elanClusterUtils.runOnlyInOwnerNode("external tunnel update", () -> {
@Override
protected void update(InstanceIdentifier<Node> identifier, Node original, Node update) {
LOG.debug("ElanOvsdbNodeListener.update, updated node detected. original: {} new: {}", original, update);
- Boolean integrationBridgeExist = bridgeMgr.isBridgeOnOvsdbNode(update, bridgeMgr.getIntegrationBridgeName());
+ boolean integrationBridgeExist = bridgeMgr.isBridgeOnOvsdbNode(update, bridgeMgr.getIntegrationBridgeName());
// ignore updates where the bridge was deleted
if (!(bridgeMgr.isBridgeOnOvsdbNode(original, bridgeMgr.getIntegrationBridgeName())
&& !integrationBridgeExist)) {
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
final boolean isVlanOrFlatProviderIface) {
jobCoordinator.enqueueJob(ElanUtils.getElanMacKey(elanTag, macAddress),
() -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
- if (oldMacEntry != null && oldMacEntry.getInterface().equals(interfaceName)) {
+ if (oldMacEntry != null && Objects.equals(oldMacEntry.getInterface(), interfaceName)) {
// This should never occur because of ovs temporary mac learning
elanManagerCounters.unknownSmacPktinForwardingEntriesRemoved();
} else if (oldMacEntry != null && !isVlanOrFlatProviderIface) {
private void macMigrationFlowsCleanup(String interfaceName, ElanInstance elanInstance, MacEntry macEntry,
boolean isVlanOrFlatProviderIface) {
- if (macEntry != null && !macEntry.getInterface().equals(interfaceName)
+ if (macEntry != null && !Objects.equals(macEntry.getInterface(), interfaceName)
&& !isVlanOrFlatProviderIface) {
tryAndRemoveInvalidMacEntry(elanInstance.getElanInstanceName(), macEntry);
elanManagerCounters.unknownSmacPktinFlowsRemovedForRelearned();
package org.opendaylight.netvirt.elan.internal;
+import static java.util.Collections.emptyList;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
+
import com.google.common.base.Optional;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.function.BiFunction;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
candidateRegistration = registerCandidate(entityOwnershipService);
}
+ @Nullable
private static EntityOwnershipCandidateRegistration registerCandidate(
EntityOwnershipService entityOwnershipService) {
try {
}
@Override
+ @Nullable
public EtreeInterface getEtreeInterfaceByElanInterfaceName(String elanInterface) {
return elanInterfaceCache.getEtreeInterface(elanInterface).orNull();
}
String description) {
boolean isEqual = false;
if (existingElanInstance.getMacTimeout() == macTimeOut
- && existingElanInstance.getDescription().equals(description)) {
+ && Objects.equals(existingElanInstance.getDescription(), description)) {
isEqual = true;
}
return isEqual;
@Override
public boolean deleteElanInstance(String elanInstanceName) {
- boolean isSuccess = false;
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(elanInstanceName);
if (!existingElanInstance.isPresent()) {
LOG.debug("Elan Instance is not present for {}", elanInstanceName);
- return isSuccess;
+ return false;
}
LOG.debug("Deletion of the existing Elan Instance {}", existingElanInstance);
ElanUtils.delete(broker, LogicalDatastoreType.CONFIGURATION,
ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName));
- isSuccess = true;
- return isSuccess;
+ return true;
}
@Override
}
@Override
- public void addElanInterface(String elanInstanceName, String interfaceName, List<String> staticMacAddresses,
- String description) {
+ public void addElanInterface(String elanInstanceName, String interfaceName,
+ @Nullable List<String> staticMacAddresses, @Nullable String description) {
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(elanInstanceName);
if (existingElanInstance.isPresent()) {
ElanInterfaceBuilder elanInterfaceBuilder = new ElanInterfaceBuilder()
}
@Override
+ @Nullable
public ElanInstance getElanInstance(String elanName) {
return elanInstanceCache.get(elanName).orNull();
}
InstanceIdentifier<ElanInstances> elanInstancesIdentifier = InstanceIdentifier.builder(ElanInstances.class)
.build();
return ElanUtils.read(broker, LogicalDatastoreType.CONFIGURATION, elanInstancesIdentifier).toJavaUtil().map(
- ElanInstances::getElanInstance).orElse(Collections.emptyList());
+ ElanInstances::getElanInstance).orElse(emptyList());
}
@Override
if (!elanInterfacesOptional.isPresent()) {
return elanInterfaces;
}
- List<ElanInterface> elanInterfaceList = elanInterfacesOptional.get().getElanInterface();
+ List<ElanInterface> elanInterfaceList =
+ requireNonNullElse(elanInterfacesOptional.get().getElanInterface(), emptyList());
for (ElanInterface elanInterface : elanInterfaceList) {
- if (elanInterface.getElanInstanceName().equals(elanInstanceName)) {
+ if (Objects.equals(elanInterface.getElanInstanceName(), elanInstanceName)) {
elanInterfaces.add(elanInterface.getName());
}
}
}
@Override
+ @Nullable
public ElanInterface getElanInterfaceByElanInterfaceName(String interfaceName) {
return elanInterfaceCache.get(interfaceName).orNull();
}
ElanInstance elanInstance = getElanInstance(elanInstanceName);
if (elanInstance == null) {
LOG.debug("No ELAN instance found for {}", elanInstanceName);
- return Collections.emptyList();
+ return emptyList();
}
Long elanTag = elanInstance.getElanTag();
if (elanTag == null) {
LOG.debug("No ELAN tag found for {}", elanInstanceName);
- return Collections.emptyList();
+ return emptyList();
}
return Collections.singletonList(
new NxMatchRegister(ElanConstants.ELAN_REG_ID, elanTag, MetaDataUtil.getElanMaskForReg()));
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
+import javax.annotation.Nullable;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
return physicalLocatorRef;
}
- public static boolean isEmptyList(List list) {
+ public static boolean isEmptyList(@Nullable List list) {
return list == null || list.isEmpty();
}
return collection == null || collection.isEmpty();
}
+ @Nullable
public static Node getOriginal(DataObjectModification<Node> mod) {
Node node = null;
switch (mod.getModificationType()) {
return node;
}
+ @Nullable
public static Node getUpdated(DataObjectModification<Node> mod) {
Node node = null;
switch (mod.getModificationType()) {
return node;
}
+ @Nullable
public static Node getCreated(DataObjectModification<Node> mod) {
if (mod.getModificationType() == DataObjectModification.ModificationType.WRITE
&& mod.getDataBefore() == null) {
return null;
}
+ @Nullable
public static Node getRemoved(DataObjectModification<Node> mod) {
if (mod.getModificationType() == DataObjectModification.ModificationType.DELETE) {
return mod.getDataBefore();
return null;
}
+ @Nullable
public static String getPsName(Node psNode) {
String psNodeId = psNode.getNodeId().getValue();
if (psNodeId.contains(PHYSICALSWITCH)) {
return null;
}
+ @Nullable
public static String getPsName(InstanceIdentifier<Node> psNodeIid) {
String psNodeId = psNodeIid.firstKeyOf(Node.class).getNodeId().getValue();
if (psNodeId.contains(PHYSICALSWITCH)) {
return convertToInstanceIdentifier(psNodeId);
}
+ @Nullable
public static InstanceIdentifier<Node> convertPsPath(Node psNode, InstanceIdentifier<Node> nodePath) {
String psNodeId = psNode.getNodeId().getValue();
if (psNodeId.contains(PHYSICALSWITCH)) {
return nodeBuilder;
}
+ @Nullable
public static String getHAIdFromManagerOtherConfig(Node node) {
if (node.augmentation(HwvtepGlobalAugmentation.class) == null) {
return null;
HwvtepGlobalAugmentation globalAugmentation = node.augmentation(HwvtepGlobalAugmentation.class);
if (globalAugmentation != null) {
List<Managers> managers = globalAugmentation.getManagers();
- if (managers != null && managers.size() > 0 && managers.get(0).getManagerOtherConfigs() != null) {
+ if (managers != null && !managers.isEmpty() && managers.get(0).getManagerOtherConfigs() != null) {
for (ManagerOtherConfigs configs : managers.get(0).getManagerOtherConfigs()) {
- if (configs.getOtherConfigKey().equals(HA_ID)) {
+ if (HA_ID.equals(configs.getOtherConfigKey())) {
return configs.getOtherConfigValue();
}
}
return childNodeIds;
}
for (ManagerOtherConfigs otherConfigs : managers.getManagerOtherConfigs()) {
- if (otherConfigs.getOtherConfigKey().equals(HA_CHILDREN)) {
+ if (HA_CHILDREN.equals(otherConfigs.getOtherConfigKey())) {
String nodeIdsVal = otherConfigs.getOtherConfigValue();
if (nodeIdsVal != null) {
String[] parts = nodeIdsVal.split(",");
import java.util.Comparator;
import java.util.List;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
public abstract class BaseCommand<T> {
* @param updated Updated List
* @param original Origina list to be compared with
* @param comparator based on which diff will be returned
- * @param <T> T extends DataObject
+ * @param <U> U extends DataObject
* @return List of diff based on comparator
*/
- public <T> List<T> diffOf(List<T> updated, final List<T> original, final Comparator comparator) {
+ public <U> List<U> diffOf(@Nullable List<U> updated, @Nullable final List<U> original,
+ final Comparator<U> comparator) {
if (updated == null) {
return new ArrayList<>();
}
return new ArrayList<>(updated);
}
- List<T> result = new ArrayList<>();
- for (T ele : updated) {
+ List<U> result = new ArrayList<>();
+ for (U ele : updated) {
boolean present = false;
- for (T orig : original) {
+ for (U orig : original) {
if (0 == comparator.compare(ele, orig)) {
present = true;
break;
*/
package org.opendaylight.netvirt.elan.l2gw.ha.commands;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
+
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Objects;
+import javax.annotation.Nullable;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
}
@Override
+ @Nullable
public List<LocalMcastMacs> getData(HwvtepGlobalAugmentation node) {
if (node != null) {
return node.getLocalMcastMacs();
public LocalMcastMacs transform(InstanceIdentifier<Node> nodePath, LocalMcastMacs src) {
LocalMcastMacsBuilder ucmlBuilder = new LocalMcastMacsBuilder(src);
List<LocatorSet> locatorSet = new ArrayList<>();
- for (LocatorSet locator : src.getLocatorSet()) {
+ for (LocatorSet locator : requireNonNullElse(src.getLocatorSet(), Collections.<LocatorSet>emptyList())) {
locatorSet.add(new LocatorSetBuilder().setLocatorRef(HwvtepHAUtil.buildLocatorRef(nodePath,
HwvtepHAUtil.getTepIpVal(locator.getLocatorRef()))).build());
}
.getHwvtepNodeName();
InstanceIdentifier<?> origMacRefIdentifier = orig.getLogicalSwitchRef().getValue();
HwvtepNodeName origMacNodeName = origMacRefIdentifier.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName();
- if (updated.getMacEntryKey().equals(orig.getMacEntryKey())
+ if (Objects.equals(updated.getMacEntryKey(), orig.getMacEntryKey())
&& updatedMacNodeName.equals(origMacNodeName)) {
List<LocatorSet> updatedLocatorSet = updated.getLocatorSet();
List<LocatorSet> origLocatorSet = orig.getLocatorSet();
package org.opendaylight.netvirt.elan.l2gw.ha.commands;
import java.util.List;
+import javax.annotation.Nullable;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
}
@Override
+ @Nullable
public List<LocalUcastMacs> getData(HwvtepGlobalAugmentation node) {
if (node != null) {
return node.getLocalUcastMacs();
package org.opendaylight.netvirt.elan.l2gw.ha.commands;
import java.util.List;
+import javax.annotation.Nullable;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
}
@Override
+ @Nullable
public List<LogicalSwitches> getData(HwvtepGlobalAugmentation node) {
if (node != null) {
return node.getLogicalSwitches();
import java.util.Objects;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
transformUpdate(existingData, updatedData, origData, nodePath, OPERATIONAL, tx);
}
- boolean areSameSize(List objA, List objB) {
+ boolean areSameSize(@Nullable List objA, @Nullable List objB) {
if (HwvtepHAUtil.isEmptyList(objA) && HwvtepHAUtil.isEmptyList(objB)) {
return true;
}
}
}
+ @Nullable
public abstract List<T> getData(Z node);
public abstract void setData(Y builder, List<T> data);
package org.opendaylight.netvirt.elan.l2gw.ha.commands;
import java.util.List;
+import java.util.Objects;
+import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
}
@Override
+ @Nullable
public List<TerminationPoint> getData(Node node) {
if (node != null) {
return node.getTerminationPoint();
updated.augmentation(HwvtepPhysicalLocatorAugmentation.class);
HwvtepPhysicalLocatorAugmentation origPhysicalLocator =
orig.augmentation(HwvtepPhysicalLocatorAugmentation.class);
- return updatedPhysicalLocator.getDstIp().equals(origPhysicalLocator.getDstIp())
+ return Objects.equals(updatedPhysicalLocator.getDstIp(), origPhysicalLocator.getDstIp())
&& updatedPhysicalLocator.getEncapsulationType() == origPhysicalLocator.getEncapsulationType();
}
*/
package org.opendaylight.netvirt.elan.l2gw.ha.commands;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
+
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Objects;
+import javax.annotation.Nullable;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
}
@Override
+ @Nullable
public List<RemoteMcastMacs> getData(HwvtepGlobalAugmentation augmentation) {
if (augmentation != null) {
return augmentation.getRemoteMcastMacs();
public RemoteMcastMacs transform(InstanceIdentifier<Node> nodePath, RemoteMcastMacs src) {
RemoteMcastMacsBuilder ucmlBuilder = new RemoteMcastMacsBuilder(src);
List<LocatorSet> locatorSet = new ArrayList<>();
- for (LocatorSet locator : src.getLocatorSet()) {
+ for (LocatorSet locator : requireNonNullElse(src.getLocatorSet(), Collections.<LocatorSet>emptyList())) {
locatorSet.add(new LocatorSetBuilder().setLocatorRef(HwvtepHAUtil.buildLocatorRef(nodePath,
HwvtepHAUtil.getTepIpVal(locator.getLocatorRef()))).build());
}
.getHwvtepNodeName();
InstanceIdentifier<?> origMacRefIdentifier = orig.getLogicalSwitchRef().getValue();
HwvtepNodeName origMacNodeName = origMacRefIdentifier.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName();
- if (updated.getMacEntryKey().equals(orig.getMacEntryKey())
+ if (Objects.equals(updated.getMacEntryKey(), orig.getMacEntryKey())
&& updatedMacNodeName.equals(origMacNodeName)) {
List<LocatorSet> updatedLocatorSet = updated.getLocatorSet();
List<LocatorSet> origLocatorSet = orig.getLocatorSet();
package org.opendaylight.netvirt.elan.l2gw.ha.commands;
import java.util.List;
+import java.util.Objects;
+import javax.annotation.Nullable;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
}
@Override
+ @Nullable
public List<RemoteUcastMacs> getData(HwvtepGlobalAugmentation node) {
if (node != null) {
return node.getRemoteUcastMacs();
.getHwvtepNodeName();
InstanceIdentifier<?> origMacRefIdentifier = orig.getLogicalSwitchRef().getValue();
HwvtepNodeName origMacNodeName = origMacRefIdentifier.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName();
- return updated.getMacEntryKey().equals(orig.getMacEntryKey())
+ return Objects.equals(updated.getMacEntryKey(), orig.getMacEntryKey())
&& updatedMacNodeName.equals(origMacNodeName);
}
package org.opendaylight.netvirt.elan.l2gw.ha.commands;
import java.util.List;
+import javax.annotation.Nullable;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
}
@Override
+ @Nullable
public List<Switches> getData(HwvtepGlobalAugmentation node) {
if (node != null) {
return node.getSwitches();
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
+import javax.annotation.Nullable;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentationBuilder;
}
@Override
+ @Nullable
public List<TerminationPoint> getData(Node node) {
if (node != null) {
return node.getTerminationPoint();
package org.opendaylight.netvirt.elan.l2gw.ha.commands;
import java.util.List;
+import javax.annotation.Nullable;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
}
@Override
+ @Nullable
public List<Tunnels> getData(PhysicalSwitchAugmentation node) {
if (node != null) {
return node.getTunnels();
import java.util.List;
import java.util.Objects;
+import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps;
}
@Override
+ @Nullable
public List<TunnelIps> getData(PhysicalSwitchAugmentation node) {
if (node != null) {
return node.getTunnelIps();
*/
HwvtepHAUtil.deleteNodeIfPresent(tx, dstPsPath);
}
- }), LOG, "Failed to read source node {}", srcPsNodeOptional.get());
+ }), LOG, "Failed to read source node {}", srcPsPath);
});
}
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import javax.annotation.Nullable;
import javax.annotation.PreDestroy;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
}
}
+ @Nullable
protected DataObjectModification.ModificationType getModificationType(
final DataObjectModification<? extends DataObject> mod) {
try {
import java.math.BigInteger;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
public class ElanGroupListener extends AsyncClusteredDataTreeChangeListenerBase<Group, ElanGroupListener> {
private static final Logger LOG = LoggerFactory.getLogger(ElanGroupListener.class);
- private final DataBroker broker;
private final ManagedNewTransactionRunner txRunner;
private final ElanClusterUtils elanClusterUtils;
private final ElanUtils elanUtils;
public ElanGroupListener(DataBroker db, ElanClusterUtils elanClusterUtils, ElanUtils elanUtils,
ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils, ElanInstanceCache elanInstanceCache) {
super(Group.class, ElanGroupListener.class);
- broker = db;
this.txRunner = new ManagedNewTransactionRunnerImpl(db);
this.elanClusterUtils = elanClusterUtils;
this.elanUtils = elanUtils;
this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
this.elanInstanceCache = elanInstanceCache;
- registerListener(LogicalDatastoreType.CONFIGURATION, broker);
+ registerListener(LogicalDatastoreType.CONFIGURATION, db);
LOG.trace("ElanGroupListener registered");
}
}
+ @Nullable
ElanInstance getElanInstanceFromGroupId(Group update) {
for (ElanInstance elanInstance : elanInstanceCache.getAllPresent()) {
if (elanInstance.getElanTag() != null) {
return null;
}
+ @Nullable
private BigInteger getDpnId(String node) {
//openflow:1]
String[] temp = node.split(":");
}
@Override
- protected void update(InstanceIdentifier<Group> identifier, Group original, Group update) {
+ protected void update(InstanceIdentifier<Group> identifier, @Nullable Group original, Group update) {
LOG.trace("received group updated {}", update.key().getGroupId());
final BigInteger dpnId = getDpnId(identifier.firstKeyOf(Node.class).getId().getValue());
if (dpnId == null) {
import java.util.Set;
import java.util.function.BiPredicate;
import java.util.function.Predicate;
+import javax.annotation.Nullable;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
return psNodeId;
}
+ @Nullable
private InstanceIdentifier<Node> getManagedByNodeIid(InstanceIdentifier<PhysicalSwitchAugmentation> identifier) {
String psNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
if (psNodeId.contains(HwvtepHAUtil.PHYSICALSWITCH)) {
return null;
}
+ @Nullable
private String getPsName(InstanceIdentifier<PhysicalSwitchAugmentation> identifier) {
String psNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
if (psNodeId.contains(HwvtepHAUtil.PHYSICALSWITCH)) {
*/
package org.opendaylight.netvirt.elan.l2gw.listeners;
+import static java.util.Collections.emptyList;
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
} else {
LOG.error("{} entry not in config datastore", psNodeId);
}
- return Collections.emptyList();
+ return emptyList();
}
private List<ListenableFuture<Void>> handlePortDeleted(InstanceIdentifier<TerminationPoint> identifier) {
} else {
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(
l2GwConn.getNetworkId().getValue());
- List<Devices> l2Devices = l2Gateway.getDevices();
+ List<Devices> l2Devices = requireNonNullElse(l2Gateway.getDevices(), emptyList());
for (Devices l2Device : l2Devices) {
String l2DeviceName = l2Device.getDeviceName();
if (l2DeviceName != null && l2DeviceName.equals(psName)) {
- for (Interfaces deviceInterface : l2Device.getInterfaces()) {
- if (deviceInterface.getInterfaceName().equals(newPortId)) {
+ for (Interfaces deviceInterface : requireNonNullElse(l2Device.getInterfaces(),
+ Collections.<Interfaces>emptyList())) {
+ if (Objects.equals(deviceInterface.getInterfaceName(), newPortId)) {
if (deviceInterface.getSegmentationIds() != null
&& !deviceInterface.getSegmentationIds().isEmpty()) {
for (Integer vlanId : deviceInterface.getSegmentationIds()) {
import static java.util.Collections.emptyList;
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import static org.opendaylight.netvirt.elan.utils.ElanUtils.isVxlanNetworkOrVxlanSegment;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ConcurrentMap;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
setupElanBroadcastGroups(elanInfo, null, dpnId, confTx);
}
- public void setupElanBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId,
+ public void setupElanBroadcastGroups(ElanInstance elanInfo, @Nullable DpnInterfaces dpnInterfaces, BigInteger dpnId,
TypedWriteTransaction<Datastore.Configuration> confTx) {
setupStandardElanBroadcastGroups(elanInfo, dpnInterfaces, dpnId, confTx);
setupLeavesEtreeBroadcastGroups(elanInfo, dpnInterfaces, dpnId, confTx);
}
- public void setupStandardElanBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId,
- TypedWriteTransaction<Datastore.Configuration> confTx) {
+ public void setupStandardElanBroadcastGroups(ElanInstance elanInfo, @Nullable DpnInterfaces dpnInterfaces,
+ BigInteger dpnId, TypedWriteTransaction<Datastore.Configuration> confTx) {
List<Bucket> listBucket = new ArrayList<>();
int bucketId = 0;
int actionKey = 0;
mdsalManager.addGroup(confTx, dpnId, group);
}
- public void setupLeavesEtreeBroadcastGroups(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId,
- TypedWriteTransaction<Datastore.Configuration> confTx) {
+ public void setupLeavesEtreeBroadcastGroups(ElanInstance elanInfo, @Nullable DpnInterfaces dpnInterfaces,
+ BigInteger dpnId, TypedWriteTransaction<Datastore.Configuration> confTx) {
EtreeInstance etreeInstance = elanInfo.augmentation(EtreeInstance.class);
if (etreeInstance != null) {
long etreeLeafTag = etreeInstance.getEtreeLeafTagVal().getValue();
}
}
+ @Nullable
private DpnInterfaces getDpnInterfaces(ElanDpnInterfacesList elanDpns, BigInteger dpnId) {
if (elanDpns != null) {
- for (DpnInterfaces dpnInterface : elanDpns.getDpnInterfaces()) {
- if (dpnInterface.getDpId().equals(dpnId)) {
+ for (DpnInterfaces dpnInterface : requireNonNullElse(elanDpns.getDpnInterfaces(),
+ Collections.<DpnInterfaces>emptyList())) {
+ if (Objects.equals(dpnInterface.getDpId(), dpnId)) {
return dpnInterface;
}
}
}
@Nonnull
- public List<Bucket> getRemoteBCGroupBuckets(ElanInstance elanInfo, DpnInterfaces dpnInterfaces, BigInteger dpnId,
- int bucketId, long elanTag) {
+ public List<Bucket> getRemoteBCGroupBuckets(ElanInstance elanInfo, @Nullable DpnInterfaces dpnInterfaces,
+ BigInteger dpnId, int bucketId, long elanTag) {
List<Bucket> listBucketInfo = new ArrayList<>();
ElanDpnInterfacesList elanDpns = elanUtils.getElanDpnInterfacesList(elanInfo.getElanInstanceName());
long elanTagOrVni) {
List<Bucket> listBucketInfo = new ArrayList<>();
if (elanDpns != null) {
- for (DpnInterfaces dpnInterface : elanDpns.getDpnInterfaces()) {
+ for (DpnInterfaces dpnInterface : requireNonNullElse(elanDpns.getDpnInterfaces(),
+ Collections.<DpnInterfaces>emptyList())) {
if (elanUtils.isDpnPresent(dpnInterface.getDpId()) && !Objects.equals(dpnInterface.getDpId(), dpnId)
&& dpnInterface.getInterfaces() != null && !dpnInterface.getInterfaces().isEmpty()) {
try {
package org.opendaylight.netvirt.elan.l2gw.utils;
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
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.OdlInterfaceRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceOutput;
HwvtepSouthboundUtils.createPhysicalLocatorInstanceIdentifier(nodeId, expectedPhyLocatorAug));
if (remoteMcastMac.getLocatorSet() != null) {
for (LocatorSet locatorSet : remoteMcastMac.getLocatorSet()) {
- if (locatorSet.getLocatorRef().equals(expectedPhyLocRef)) {
+ if (Objects.equals(locatorSet.getLocatorRef(), expectedPhyLocRef)) {
LOG.trace("matched phyLocRef: {}", expectedPhyLocRef);
return true;
}
return HwvtepUtils.deleteRemoteUcastMacs(broker, nodeId, logicalSwitchName, lstMac);
}
+ @Nullable
public ElanInstance getElanInstanceForUcastLocalMac(LocalUcastMacs localUcastMac) {
Optional<LogicalSwitches> lsOpc = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL,
(InstanceIdentifier<LogicalSwitches>) localUcastMac.getLogicalSwitchRef().getValue());
}
public void installL2GwUcastMacInElan(final ElanInstance elan, final L2GatewayDevice extL2GwDevice,
- final String macToBeAdded, final LocalUcastMacs localUcastMacs, String interfaceName) {
+ final String macToBeAdded, final LocalUcastMacs localUcastMacs, @Nullable String interfaceName) {
final String extDeviceNodeId = extL2GwDevice.getHwvtepNodeId();
final String elanInstanceName = elan.getElanInstanceName();
final Collection<DpnInterfaces> elanDpns = getElanDpns(elanInstanceName);
* the interface name
* @return the dpid from interface
*/
+ @Nullable
public BigInteger getDpidFromInterface(String interfaceName) {
BigInteger dpId = null;
Future<RpcResult<GetDpidFromInterfaceOutput>> output = interfaceManagerRpcService
return interfaceInstanceIdentifierBuilder.build();
}
+ @Nullable
public static Interface getInterfaceFromConfigDS(InterfaceKey interfaceKey, DataBroker dataBroker) {
InstanceIdentifier<Interface> interfaceId = getInterfaceIdentifier(interfaceKey);
try {
return;
}
String psNodeId = globalNodeId + HwvtepHAUtil.PHYSICALSWITCH + psName;
- tzonesoptional.get().getTransportZone().stream()
+ requireNonNullElse(tzonesoptional.get().getTransportZone(),
+ Collections.<TransportZone>emptyList()).stream()
.filter(transportZone -> transportZone.getSubnets() != null)
.flatMap(transportZone -> transportZone.getSubnets().stream())
.filter(subnet -> subnet.getDeviceVteps() != null)
}
JdkFutures.addErrorLogging(
new ManagedNewTransactionRunnerImpl(dataBroker).callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
- tx -> {
- optionalElan.get().getElanInstance().stream()
- .flatMap(elan -> elan.getExternalTeps().stream()
- .map(externalTep -> ElanL2GatewayMulticastUtils.buildExternalTepPath(
- elan.getElanInstanceName(), externalTep.getTepIp())))
+ tx -> requireNonNullElse(optionalElan.get().getElanInstance(),
+ Collections.<ElanInstance>emptyList()).stream()
+ .flatMap(elan -> requireNonNullElse(elan.getExternalTeps(),
+ Collections.<ExternalTeps>emptyList()).stream()
+ .map(externalTep -> ElanL2GatewayMulticastUtils.buildExternalTepPath(
+ elan.getElanInstanceName(), externalTep.getTepIp())))
.filter(externalTepIid -> Objects.equals(
- deviceVteps.getIpAddress(), externalTepIid.firstKeyOf(ExternalTeps.class).getTepIp()))
+ deviceVteps.getIpAddress(), externalTepIid.firstKeyOf(ExternalTeps.class).getTepIp()))
.peek(externalTepIid -> LOG.info("Deleting stale external tep {}", externalTepIid))
- .forEach(externalTepIid -> tx.delete(externalTepIid));
- }), LOG, "Failed to delete stale external teps {}", deviceVteps);
+ .forEach(tx::delete)), LOG,
+ "Failed to delete stale external teps {}", deviceVteps);
Thread.sleep(10000);//TODO remove the sleep currently it waits for interfacemgr to finish the cleanup
} catch (ReadFailedException | InterruptedException e) {
LOG.error("Failed to delete stale l2gw tep {}", deviceVteps, e);
package org.opendaylight.netvirt.elan.l2gw.utils;
+import static java.util.Collections.emptyList;
import static org.opendaylight.netvirt.elan.utils.ElanUtils.isVxlanNetworkOrVxlanSegment;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
}
public static boolean isGatewayAssociatedToL2Device(L2GatewayDevice l2GwDevice) {
- return l2GwDevice.getL2GatewayIds().size() > 0;
+ return !l2GwDevice.getL2GatewayIds().isEmpty();
}
+ @Nullable
public static L2gateway getNeutronL2gateway(DataBroker broker, Uuid l2GatewayId) {
LOG.debug("getNeutronL2gateway for {}", l2GatewayId.getValue());
InstanceIdentifier<L2gateway> inst = InstanceIdentifier.create(Neutron.class).child(L2gateways.class)
public static List<L2gateway> getL2gatewayList(DataBroker broker) {
InstanceIdentifier<L2gateways> inst = InstanceIdentifier.create(Neutron.class).child(L2gateways.class);
return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, inst).toJavaUtil().map(
- L2gateways::getL2gateway).orElse(Collections.emptyList());
+ L2gateways::getL2gateway).orElse(emptyList());
}
@Nonnull
InstanceIdentifier<L2gatewayConnections> inst = InstanceIdentifier.create(Neutron.class)
.child(L2gatewayConnections.class);
return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, inst).toJavaUtil().map(
- L2gatewayConnections::getL2gatewayConnection).orElse(Collections.emptyList());
+ L2gatewayConnections::getL2gatewayConnection).orElse(emptyList());
}
/**
List<L2gatewayConnection> l2GwConnections = new ArrayList<>();
for (Uuid l2GatewayId : l2GatewayIds) {
for (L2gatewayConnection l2GwConn : allL2GwConns) {
- if (l2GwConn.getL2gatewayId().equals(l2GatewayId)) {
+ if (Objects.equals(l2GwConn.getL2gatewayId(), l2GatewayId)) {
l2GwConnections.add(l2GwConn);
}
}
}
public void addL2GatewayConnection(final L2gatewayConnection input,
- final String l2GwDeviceName ,
- L2gateway l2Gateway) {
+ @Nullable final String l2GwDeviceName ,
+ @Nullable L2gateway l2Gateway) {
LOG.info("Adding L2gateway Connection with ID: {}", input.key().getUuid());
Uuid networkUuid = input.getNetworkId();
private void disAssociateHwvtepsFromElan(String elanName, L2gatewayConnection input) {
Integer defaultVlan = input.getSegmentId();
- List<L2GatewayDevice> l2Devices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
+ List<L2GatewayDevice> l2Devices =
+ requireNonNullElse(ElanL2GwCacheUtils.getAllElanDevicesFromCache(), emptyList());
List<Devices> l2gwDevicesToBeDeleted = new ArrayList<>();
for (L2GatewayDevice elanL2gwDevice : l2Devices) {
if (elanL2gwDevice.getL2GatewayIds().contains(input.key().getUuid())) {
if (l2Gateway == null) {
LOG.error("Failed to find the l2gateway for the connection {}", input.getUuid());
return;
- } else {
+ } else if (l2Gateway.getDevices() != null) {
l2gwDevicesToBeDeleted.addAll(l2Gateway.getDevices());
}
}
}
private void associateHwvtepsToElan(ElanInstance elanInstance,
- L2gateway l2Gateway, L2gatewayConnection input, String l2GwDeviceName) {
+ L2gateway l2Gateway, L2gatewayConnection input, @Nullable String l2GwDeviceName) {
String elanName = elanInstance.getElanInstanceName();
Integer defaultVlan = input.getSegmentId();
Uuid l2GwConnId = input.key().getUuid();
- List<Devices> l2Devices = l2Gateway.getDevices();
+ List<Devices> l2Devices = requireNonNullElse(l2Gateway.getDevices(), emptyList());
LOG.trace("Associating ELAN {} with L2Gw Conn Id {} having below L2Gw devices {}", elanName, l2GwConnId,
l2Devices);
List<L2gatewayConnection> l2GwConnections = new ArrayList<>();
List<L2gatewayConnection> allL2GwConns = getAllL2gatewayConnections(broker);
for (L2gatewayConnection l2GwConn : allL2GwConns) {
- if (l2GwConn.getL2gatewayId().equals(l2GatewayId)) {
+ if (Objects.equals(l2GwConn.getL2gatewayId(), l2GatewayId)) {
l2GwConnections.add(l2GwConn);
}
}
import com.google.common.base.Optional;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
.withResult(queryforElanInterfaceStatistics(tableId, elanInstanceName, interfaceInfo)).build());
}
+ @Nullable
private GetElanInterfaceStatisticsOutput queryforElanInterfaceStatistics(short tableId, String elanInstanceName,
InterfaceInfo interfaceInfo) {
// BigInteger dpId = interfaceInfo.getDpId();
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
private ListenableFuture<Void> buildEtreeDmacFlowForExternalRemoteMacWithBatch(
BigInteger dpnId, String extDeviceNodeId, Long vni, String macAddress, String displayName,
- String interfaceName, EtreeLeafTagName etreeLeafTag) {
+ @Nullable String interfaceName, EtreeLeafTagName etreeLeafTag) {
boolean isRoot;
if (interfaceName == null) {
isRoot = true;
} else {
Optional<EtreeInterface> etreeInterface = elanInterfaceCache.getEtreeInterface(interfaceName);
- isRoot = etreeInterface.isPresent() ? etreeInterface.get().getEtreeInterfaceType()
- == EtreeInterface.EtreeInterfaceType.Root : false;
+ isRoot = etreeInterface.isPresent()
+ && etreeInterface.get().getEtreeInterfaceType() == EtreeInterface.EtreeInterfaceType.Root;
}
if (isRoot) {
Flow flow = buildDmacFlowForExternalRemoteMac(dpnId, extDeviceNodeId,
public List<ListenableFuture<Void>> installDmacFlowsToExternalRemoteMacInBatch(
BigInteger dpnId, String extDeviceNodeId, Long elanTag, Long vni, String macAddress, String displayName,
- String interfaceName) {
+ @Nullable String interfaceName) {
Flow flow = buildDmacFlowForExternalRemoteMac(dpnId, extDeviceNodeId, elanTag, vni, macAddress,
displayName);
private List<ListenableFuture<Void>> installEtreeDmacFlowsToExternalRemoteMacInBatch(
BigInteger dpnId, String extDeviceNodeId, Long elanTag, Long vni, String macAddress, String displayName,
- String interfaceName) {
+ @Nullable String interfaceName) {
EtreeLeafTagName etreeLeafTag = elanEtreeUtils.getEtreeLeafTagByElanTag(elanTag);
if (etreeLeafTag != null) {
package org.opendaylight.netvirt.elan.utils;
import com.google.common.base.Optional;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
this.broker = broker;
}
+ @Nullable
public EtreeLeafTagName getEtreeLeafTagByElanTag(long elanTag) {
InstanceIdentifier<ElanTagName> elanId = ElanUtils.getElanInfoEntriesOperationalDataPath(elanTag);
Optional<ElanTagName> existingElanInfo = ElanUtils.read(broker,
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
* @return the list
*/
@SuppressWarnings("checkstyle:IllegalCatch")
- public List<Action> buildItmEgressActions(String interfaceName, Long tunnelKey, boolean internal) {
+ public List<Action> buildItmEgressActions(String interfaceName, @Nullable Long tunnelKey, boolean internal) {
try {
if (internal && interfaceManager.isItmDirectTunnelsEnabled()) {
GetEgressActionsForTunnelInput getEgressActInputItm = new GetEgressActionsForTunnelInputBuilder()
*/
package org.opendaylight.netvirt.elan.utils;
+import static java.util.Collections.emptyList;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
}
// elan-state Operational container
+ @Nullable
public static Elan getElanByName(DataBroker broker, String elanInstanceName) {
InstanceIdentifier<Elan> elanIdentifier = getElanInstanceOperationalDataPath(elanInstanceName);
return MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, elanIdentifier).orNull();
}
// grouping of forwarding-entries
+ @Nullable
public MacEntry getInterfaceMacEntriesOperationalDataPath(String interfaceName, PhysAddress physAddress) {
InstanceIdentifier<MacEntry> existingMacEntryId = getInterfaceMacEntriesIdentifierOperationalDataPath(
interfaceName, physAddress);
return read(broker, LogicalDatastoreType.OPERATIONAL, existingMacEntryId).orNull();
}
- public MacEntry getInterfaceMacEntriesOperationalDataPathFromId(InstanceIdentifier identifier) {
- Optional<MacEntry> existingInterfaceMacEntry = read(broker,
- LogicalDatastoreType.OPERATIONAL, identifier);
- return existingInterfaceMacEntry.orNull();
- }
-
+ @Nullable
public MacEntry getInterfaceMacEntriesOperationalDataPathFromId(TypedReadTransaction<Operational> tx,
InstanceIdentifier<MacEntry> identifier) throws ExecutionException, InterruptedException {
return tx.read(identifier).get().orNull();
return tx.read(macId).get();
}
- public MacEntry getMacEntryFromElanMacId(InstanceIdentifier identifier) {
- Optional<MacEntry> existingInterfaceMacEntry = read(broker,
- LogicalDatastoreType.OPERATIONAL, identifier);
- return existingInterfaceMacEntry.orNull();
- }
-
+ @Nullable
public MacEntry getMacEntryFromElanMacId(TypedReadTransaction<Operational> tx,
InstanceIdentifier<MacEntry> identifier) throws ExecutionException, InterruptedException {
return tx.read(identifier).get().orNull();
/**
* Returns the list of Interfaces that belong to an Elan on an specific DPN.
- * Data retrieved from Elan's operational DS: elan-dpn-interfaces container
+ * Data retrieved from Elan's operational DS: elan-dpn-interfaces container.
*
* @param elanInstanceName
* name of the Elan to which the interfaces must belong to
* Id of the DPN where the interfaces are located
* @return the elan interface Info
*/
+ @Nullable
public DpnInterfaces getElanInterfaceInfoByElanDpn(String elanInstanceName, BigInteger dpId) {
InstanceIdentifier<DpnInterfaces> elanDpnInterfacesId = getElanDpnInterfaceOperationalDataPath(elanInstanceName,
dpId);
}
// elan-tag-name-map Operational Container
+ @Nullable
public ElanTagName getElanInfoByElanTag(long elanTag) {
InstanceIdentifier<ElanTagName> elanId = getElanInfoEntriesOperationalDataPath(elanTag);
Optional<ElanTagName> existingElanInfo = read(broker,
.child(ElanDpnInterfacesList.class, new ElanDpnInterfacesListKey(elanInstanceName)).build();
}
+ @Nullable
public ElanDpnInterfacesList getElanDpnInterfacesList(String elanName) {
InstanceIdentifier<ElanDpnInterfacesList> elanDpnInterfaceId = getElanDpnOperationDataPath(elanName);
return read(broker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId).orNull();
}
+ @Nullable
public ElanDpnInterfaces getElanDpnInterfacesList() {
InstanceIdentifier<ElanDpnInterfaces> elanDpnInterfaceId = InstanceIdentifier.builder(ElanDpnInterfaces.class)
.build();
if (!existingElanDpnInterfaces.isPresent()) {
return dpIds;
}
- List<DpnInterfaces> dpnInterfaces = existingElanDpnInterfaces.get().getDpnInterfaces();
+ List<DpnInterfaces> dpnInterfaces =
+ requireNonNullElse(existingElanDpnInterfaces.get().getDpnInterfaces(), emptyList());
for (DpnInterfaces dpnInterface : dpnInterfaces) {
dpIds.add(dpnInterface.getDpId());
}
if (!existingElanDpnInterfaces.isPresent()) {
return false;
}
- List<DpnInterfaces> dpnInterfaces = existingElanDpnInterfaces.get().getDpnInterfaces();
+ List<DpnInterfaces> dpnInterfaces =
+ requireNonNullElse(existingElanDpnInterfaces.get().getDpnInterfaces(), emptyList());
for (DpnInterfaces dpnInterface : dpnInterfaces) {
- if (dpnInterface.getDpId().equals(dpId)) {
+ if (Objects.equals(dpnInterface.getDpId(), dpId)) {
return true;
}
}
return false;
}
+ @Nullable
public ElanForwardingTables getElanForwardingList() {
InstanceIdentifier<ElanForwardingTables> elanForwardingTableId = InstanceIdentifier
.builder(ElanForwardingTables.class).build();
* the elan name
* @return the elan mac table
*/
+ @Nullable
public MacTable getElanMacTable(String elanName) {
return getElanMacTable(broker, elanName);
}
* @return the egress actions for interface
*/
@SuppressWarnings("checkstyle:IllegalCatch")
- public List<Action> getEgressActionsForInterface(String ifName, Long tunnelKey) {
+ @Nonnull
+ public List<Action> getEgressActionsForInterface(String ifName, @Nullable Long tunnelKey) {
List<Action> listAction = new ArrayList<>();
try {
GetEgressActionsForInterfaceInput getEgressActionInput = new GetEgressActionsForInterfaceInputBuilder()
LOG.debug("RPC Call to Get egress actions for interface {} returned with Errors {}", ifName,
rpcResult.getErrors());
} else {
- List<Action> actions = rpcResult.getResult().getAction();
- listAction = actions;
+ listAction = requireNonNullElse(rpcResult.getResult().getAction(), emptyList());
}
} catch (Exception e) {
LOG.warn("Exception when egress actions for interface {}", ifName, e);
List<DpnInterfaces> elanDpns = getInvolvedDpnsInElan(elanInstanceName);
for (DpnInterfaces elanDpn : elanDpns) {
- if (elanDpn.getDpId().equals(dpId)) {
+ if (Objects.equals(elanDpn.getDpId(), dpId)) {
continue;
}
public List<DpnInterfaces> getElanDPNByName(String elanInstanceName) {
InstanceIdentifier<ElanDpnInterfacesList> elanIdentifier = getElanDpnOperationDataPath(elanInstanceName);
return MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, elanIdentifier).toJavaUtil().map(
- ElanDpnInterfacesList::getDpnInterfaces).orElse(Collections.emptyList());
+ ElanDpnInterfacesList::getDpnInterfaces).orElse(emptyList());
}
private void setupLocalDmacFlow(long elanTag, BigInteger dpId, String ifName, String macAddress,
* the datastore type
* @return the external tunnel
*/
+ @Nullable
public ExternalTunnel getExternalTunnel(String sourceDevice, String destinationDevice,
LogicalDatastoreType datastoreType) {
Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
* the datastore type
* @return the external tunnel
*/
+ @Nullable
public ExternalTunnel getExternalTunnel(String interfaceName, LogicalDatastoreType datastoreType) {
ExternalTunnel externalTunnel = null;
List<ExternalTunnel> externalTunnels = getAllExternalTunnels(datastoreType);
public List<ExternalTunnel> getAllExternalTunnels(LogicalDatastoreType datastoreType) {
InstanceIdentifier<ExternalTunnelList> iid = InstanceIdentifier.builder(ExternalTunnelList.class).build();
return read(broker, datastoreType, iid).toJavaUtil().map(ExternalTunnelList::getExternalTunnel).orElse(
- Collections.emptyList());
+ emptyList());
}
public static List<MatchInfo> buildMatchesForElanTagShFlagAndDstMac(long elanTag, boolean shFlag, String macAddr) {
* the data broker
* @return the interface state from oper ds
*/
+ @Nullable
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
.ietf.interfaces.rev140508.interfaces.state.Interface getInterfaceStateFromOperDS(
String interfaceName, DataBroker dataBroker) {
&& elanInstance.getSegmentationId() != null && elanInstance.getSegmentationId() != 0;
}
- private static boolean isVxlanSegment(ElanInstance elanInstance) {
+ private static boolean isVxlanSegment(@Nullable ElanInstance elanInstance) {
if (elanInstance != null) {
List<ElanSegments> elanSegments = elanInstance.getElanSegments();
if (elanSegments != null) {
return false;
}
- public static boolean isVxlanNetworkOrVxlanSegment(ElanInstance elanInstance) {
+ public static boolean isVxlanNetworkOrVxlanSegment(@Nullable ElanInstance elanInstance) {
return isVxlan(elanInstance) || isVxlanSegment(elanInstance);
}
matches, instructions);
}
+ @Nullable
public String getExternalElanInterface(String elanInstanceName, BigInteger dpnId) {
DpnInterfaces dpnInterfaces = getElanInterfaceInfoByElanDpn(elanInstanceName, dpnId);
if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null) {
public List<MacEntry> getElanMacEntries(String elanName) {
MacTable macTable = getElanMacTable(elanName);
if (macTable == null) {
- return Collections.emptyList();
+ return emptyList();
}
return macTable.getMacEntry();
}
NwConstants.ARP_RESPONDER_TABLE)), LOG, "Error removing ARP responder flow");
}
+ @Nullable
public static String getRouterPordIdFromElanInstance(DataBroker dataBroker, String elanInstanceName) {
Optional<Subnetmaps> subnetMapsData =
read(dataBroker, LogicalDatastoreType.CONFIGURATION, buildSubnetMapsWildCardPath());
return InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId)))
.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(new GroupId(groupId))).build();
}
-}
-
+ // Use Objects.requireNonNullElse instead with JDK9+
+ @Nonnull
+ public static <T> T requireNonNullElse(@Nullable T obj, @Nonnull T defaultObj) {
+ return obj != null ? obj : requireNonNull(defaultObj);
+ }
+}
package org.opendaylight.netvirt.elan.utils;
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
import com.google.common.base.Optional;
import com.google.common.collect.MapDifference;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
}
Subnets subnets = getOrAddSubnet(zoneSubnets, subnetIp);
- for (Vteps existingVtep : subnets.getVteps()) {
- if (existingVtep.getDpnId().equals(dpnId)) {
+ for (Vteps existingVtep : requireNonNullElse(subnets.getVteps(), Collections.<Vteps>emptyList())) {
+ if (Objects.equals(existingVtep.getDpnId(), dpnId)) {
return false;
}
}
IpPrefix subnetPrefix = IpPrefixBuilder.getDefaultInstance(subnetIp);
for (Subnets subnet : subnets) {
- if (subnet.getPrefix().equals(subnetPrefix)) {
+ if (Objects.equals(subnet.getPrefix(), subnetPrefix)) {
return subnet;
}
}
return subnetsBuilder.build();
}
+ @Nullable
private String getDpnLocalIp(BigInteger dpId) throws ReadFailedException {
Optional<Node> node = getPortsNode(dpId);