package org.opendaylight.netvirt.elanmanager.utils;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.genius.utils.cache.CacheUtil;
import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
return result;
}
- @Nullable
+ @Nonnull
public static List<L2GatewayDevice> getAllElanDevicesFromCache() {
ConcurrentMap<String, ConcurrentMap<String, L2GatewayDevice>> cachedMap =
(ConcurrentMap<String, ConcurrentMap<String, L2GatewayDevice>>) CacheUtil.getCache(
ElanL2GwCacheUtils.L2GATEWAY_CONN_CACHE_NAME);
if (cachedMap == null || cachedMap.isEmpty()) {
- return null;
+ return Collections.emptyList();
}
List<L2GatewayDevice> l2GwDevices = new ArrayList<>();
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;
Optional<Topology> configTopoOptional = tx.read(LogicalDatastoreType.CONFIGURATION, topoId).checkedGet();
if (operationalTopoOptional.isPresent()) {
- for (Node node : requireNonNullElse(operationalTopoOptional.get().getNode(),
- Collections.<Node>emptyList())) {
+ for (Node node : operationalTopoOptional.get().nonnullNode()) {
InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.key());
operationalNodes.put(nodeIid, node);
}
}
if (configTopoOptional.isPresent()) {
- for (Node node : requireNonNullElse(configTopoOptional.get().getNode(),
- Collections.<Node>emptyList())) {
+ for (Node node : configTopoOptional.get().nonnullNode()) {
InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.key());
configNodes.put(nodeIid, node);
}
L2gateway l2gateway = uuidToL2Gateway.get(l2gatewayConnection.getL2gatewayId());
String logicalSwitchName = l2gatewayConnection.getNetworkId().getValue();
- List<Devices> devices = requireNonNullElse(l2gateway.getDevices(), emptyList());
+ List<Devices> devices = l2gateway.nonnullDevices();
for (Devices device : devices) {
}
VlanBindings expectedBindings = !expectedVlans.isEmpty() ? expectedVlans.get(0) : null;
boolean foundBindings = false;
- List<VlanBindings> vlanBindingses = requireNonNullElse(configTerminationPoint.augmentation(
- HwvtepPhysicalPortAugmentation.class).getVlanBindings(), emptyList());
+ List<VlanBindings> vlanBindingses = configTerminationPoint.augmentation(
+ HwvtepPhysicalPortAugmentation.class).nonnullVlanBindings();
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;
Optional<Topology> topologyOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
createHwvtepTopologyInstanceIdentifier());
if (topologyOptional.isPresent()) {
- nodes = requireNonNullElse(topologyOptional.get().getNode(), emptyList());
+ nodes.addAll(topologyOptional.get().nonnullNode());
}
} 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 : requireNonNullElse(localMac.getLocatorSet(),
- Collections.<LocatorSet>emptyList())) {
+ for (LocatorSet locatorSet : localMac.nonnullLocatorSet()) {
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 : requireNonNullElse(remoteMac.getLocatorSet(),
- Collections.<LocatorSet>emptyList())) {
+ for (LocatorSet locatorSet : remoteMac.nonnullLocatorSet()) {
locatorsets.add(getLocatorValue(locatorSet.getLocatorRef()));
}
session.getConsole().println(mac + GAP + locatorsets.toString());
*/
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;
LOG.info("No DC gateways configured while programming the l2vni table.");
return tunnelInterfaceNameList;
}
- List<DcGatewayIp> dcGatewayIps = dcGatewayIpListOptional.get().getDcGatewayIp();
+ List<DcGatewayIp> dcGatewayIps = dcGatewayIpListOptional.get().nonnullDcGatewayIp();
Optional<ExternalTunnelList> externalTunnelListOptional = getExternalTunnelList();
if (!externalTunnelListOptional.isPresent()) {
LOG.info("No External Tunnel Configured while programming the l2vni table.");
return tunnelInterfaceNameList;
}
- List<ExternalTunnel> externalTunnels =
- requireNonNullElse(externalTunnelListOptional.get().getExternalTunnel(), emptyList());
+ List<ExternalTunnel> externalTunnels = externalTunnelListOptional.get().nonnullExternalTunnel();
- requireNonNullElse(dcGatewayIps, Collections.<DcGatewayIp>emptyList())
- .forEach(dcIp -> externalTunnels
+ dcGatewayIps.forEach(dcIp -> externalTunnels
.stream()
.filter(externalTunnel -> externalTunnel.getDestinationDevice()
.contains(dcIp.getIpAddress().getIpv4Address().toString()))
package org.opendaylight.netvirt.elan.internal;
import static java.util.Collections.emptyList;
-import static org.opendaylight.netvirt.elan.utils.ElanUtils.requireNonNullElse;
import java.util.List;
import javax.annotation.PostConstruct;
@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original,
final DpnInterfaces dpnInterfaces) {
- List<String> interfaces = requireNonNullElse(dpnInterfaces.getInterfaces(), emptyList());
- LOG.debug("dpninterfaces update fired new size {}", interfaces.size());
- if (interfaces.isEmpty()) {
+ List<String> interfaces = dpnInterfaces.getInterfaces();
+ if (interfaces != null && !interfaces.isEmpty()) {
+ LOG.debug("dpninterfaces update fired new size {}", interfaces.size());
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
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.List;
ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
- List<String> interfaces = requireNonNullElse(update.getInterfaces(), emptyList());
+ List<String> interfaces = update.getInterfaces();
// trigger deletion for vlan provider intf on the DPN for the vlan provider network
- if (interfaces.size() == 1 && interfaceManager.isExternalInterface(interfaces.get(0))) {
+ if (interfaces != null && 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);
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;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.locks.ReentrantLock;
+import javax.annotation.Nullable;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
return;
}
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, flowTx -> {
- List<String> elanInterfaces = requireNonNullElse(elanState.getElanInterfaces(), emptyList());
- if (elanInterfaces.isEmpty()) {
+ @Nullable List<String> elanInterfaces = elanState.getElanInterfaces();
+ if (elanInterfaces == null || elanInterfaces.isEmpty()) {
holder.isLastElanInterface = true;
}
if (interfaceInfo != null) {
if (elanState == null) {
return elanState;
}
- List<String> elanInterfaces = requireNonNullElse(elanState.getElanInterfaces(), emptyList());
- boolean isRemoved = elanInterfaces.remove(interfaceName);
+ List<String> elanInterfaces = elanState.getElanInterfaces();
+ boolean isRemoved = elanInterfaces != null && elanInterfaces.remove(interfaceName);
if (!isRemoved) {
return elanState;
}
ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> {
for (DpnInterfaces dpnInterface : dpnInterfaces) {
BigInteger currentDpId = dpnInterface.getDpId();
- if (!currentDpId.equals(dpId)) {
- for (String elanInterface : requireNonNullElse(dpnInterface.getInterfaces(),
- Collections.<String>emptyList())) {
+ if (!currentDpId.equals(dpId) && dpnInterface.getInterfaces() != null) {
+ for (String elanInterface : dpnInterface.getInterfaces()) {
ElanInterfaceMac macs = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
if (macs == null || macs.getMacEntry() == null) {
continue;
holder.dpnInterfaces =
createElanInterfacesList(elanInstanceName, interfaceName, holder.dpId, operTx);
} else {
+ @Nullable List<String> existingInterfaces = existingElanDpnInterfaces.get().getInterfaces();
List<String> elanInterfaces =
- requireNonNullElse(existingElanDpnInterfaces.get().getInterfaces(), emptyList());
+ existingInterfaces != null ? new ArrayList<>(existingInterfaces) : new ArrayList<>();
elanInterfaces.add(interfaceName);
holder.dpnInterfaces = updateElanDpnInterfacesList(elanInstanceName, holder.dpId,
elanInterfaces, operTx);
elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(holder.dpId, elanInstance,
interfaceName);
} else {
+ @Nullable List<String> existingInterfaces = existingElanDpnInterfaces.get().getInterfaces();
List<String> elanInterfaces =
- requireNonNullElse(existingElanDpnInterfaces.get().getInterfaces(), emptyList());
+ existingInterfaces != null ? new ArrayList<>(existingInterfaces) : new ArrayList<>();
elanInterfaces.add(interfaceName);
if (elanInterfaces.size() == 1) { // 1st dpn interface
elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(holder.dpId, elanInstance,
}
DpnInterfaces dpnInterfaces = existingElanDpnInterfaces.get();
int dummyInterfaceCount = 0;
- List<String> interfaces = requireNonNullElse(dpnInterfaces.getInterfaces(), emptyList());
+ List<String> interfaces = dpnInterfaces.getInterfaces();
+ if (interfaces == null) {
+ return true;
+ }
if (interfaces.contains(routerPortUuid)) {
dummyInterfaceCount++;
}
if (interfaces.contains(elanInstanceName)) {
dummyInterfaceCount++;
}
- return interfaces.size() - dummyInterfaceCount == 0;
+ return interfaces.size() == dummyInterfaceCount;
}
private InstanceIdentifier<MacEntry> getMacEntryOperationalDataPath(String elanName, PhysAddress physAddress) {
int bucketId = 0;
ElanDpnInterfacesList elanDpns = elanUtils.getElanDpnInterfacesList(elanInfo.getElanInstanceName());
if (elanDpns != null) {
- List<DpnInterfaces> dpnInterfaces = requireNonNullElse(elanDpns.getDpnInterfaces(), emptyList());
+ List<DpnInterfaces> dpnInterfaces = elanDpns.nonnullDpnInterfaces();
for (DpnInterfaces dpnInterface : dpnInterfaces) {
List<Bucket> remoteListBucketInfo = new ArrayList<>();
if (elanUtils.isDpnPresent(dpnInterface.getDpId()) && !Objects.equals(dpnInterface.getDpId(), dpId)
if (dpnInterfaceLists == null) {
return;
}
- List<ElanDpnInterfacesList> elanDpnIf =
- requireNonNullElse(dpnInterfaceLists.getElanDpnInterfacesList(), emptyList());
+ List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.nonnullElanDpnInterfacesList();
for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
int cnt = 0;
String elanName = elanDpns.getElanInstanceName();
if (dpnInterfaceLists == null) {
return;
}
- List<ElanDpnInterfacesList> elanDpnIf =
- requireNonNullElse(dpnInterfaceLists.getElanDpnInterfacesList(), emptyList());
+ List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.nonnullElanDpnInterfacesList();
for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
String elanName = elanDpns.getElanInstanceName();
ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
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;
if (!elanInterfacesOptional.isPresent()) {
return elanInterfaces;
}
- List<ElanInterface> elanInterfaceList =
- requireNonNullElse(elanInterfacesOptional.get().getElanInterface(), emptyList());
+ List<ElanInterface> elanInterfaceList = elanInterfacesOptional.get().nonnullElanInterface();
for (ElanInterface elanInterface : elanInterfaceList) {
if (Objects.equals(elanInterface.getElanInstanceName(), elanInstanceName)) {
elanInterfaces.add(elanInterface.getName());
*/
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;
public LocalMcastMacs transform(InstanceIdentifier<Node> nodePath, LocalMcastMacs src) {
LocalMcastMacsBuilder ucmlBuilder = new LocalMcastMacsBuilder(src);
List<LocatorSet> locatorSet = new ArrayList<>();
- for (LocatorSet locator : requireNonNullElse(src.getLocatorSet(), Collections.<LocatorSet>emptyList())) {
+ for (LocatorSet locator : src.nonnullLocatorSet()) {
locatorSet.add(new LocatorSetBuilder().setLocatorRef(HwvtepHAUtil.buildLocatorRef(nodePath,
HwvtepHAUtil.getTepIpVal(locator.getLocatorRef()))).build());
}
*/
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;
public RemoteMcastMacs transform(InstanceIdentifier<Node> nodePath, RemoteMcastMacs src) {
RemoteMcastMacsBuilder ucmlBuilder = new RemoteMcastMacsBuilder(src);
List<LocatorSet> locatorSet = new ArrayList<>();
- for (LocatorSet locator : requireNonNullElse(src.getLocatorSet(), Collections.<LocatorSet>emptyList())) {
+ for (LocatorSet locator : src.nonnullLocatorSet()) {
locatorSet.add(new LocatorSetBuilder().setLocatorRef(HwvtepHAUtil.buildLocatorRef(nodePath,
HwvtepHAUtil.getTepIpVal(locator.getLocatorRef()))).build());
}
}
List<L2GatewayDevice> allDevices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
- if (allDevices == null || allDevices.isEmpty()) {
+ if (allDevices.isEmpty()) {
LOG.trace("no elan devices present in cache {}", update.key().getGroupId());
return;
}
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;
} else {
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(
l2GwConn.getNetworkId().getValue());
- List<Devices> l2Devices = requireNonNullElse(l2Gateway.getDevices(), emptyList());
+ List<Devices> l2Devices = l2Gateway.nonnullDevices();
for (Devices l2Device : l2Devices) {
String l2DeviceName = l2Device.getDeviceName();
if (l2DeviceName != null && l2DeviceName.equals(psName)) {
- for (Interfaces deviceInterface : requireNonNullElse(l2Device.getInterfaces(),
- Collections.<Interfaces>emptyList())) {
+ for (Interfaces deviceInterface : l2Device.nonnullInterfaces()) {
if (Objects.equals(deviceInterface.getInterfaceName(), newPortId)) {
if (deviceInterface.getSegmentationIds() != null
&& !deviceInterface.getSegmentationIds().isEmpty()) {
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;
@Nullable
private DpnInterfaces getDpnInterfaces(ElanDpnInterfacesList elanDpns, BigInteger dpnId) {
if (elanDpns != null) {
- for (DpnInterfaces dpnInterface : requireNonNullElse(elanDpns.getDpnInterfaces(),
- Collections.<DpnInterfaces>emptyList())) {
+ for (DpnInterfaces dpnInterface : elanDpns.nonnullDpnInterfaces()) {
if (Objects.equals(dpnInterface.getDpId(), dpnId)) {
return dpnInterface;
}
long elanTagOrVni) {
List<Bucket> listBucketInfo = new ArrayList<>();
if (elanDpns != null) {
- for (DpnInterfaces dpnInterface : requireNonNullElse(elanDpns.getDpnInterfaces(),
- Collections.<DpnInterfaces>emptyList())) {
+ for (DpnInterfaces dpnInterface : elanDpns.nonnullDpnInterfaces()) {
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 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;
return;
}
String psNodeId = globalNodeId + HwvtepHAUtil.PHYSICALSWITCH + psName;
- requireNonNullElse(tzonesoptional.get().getTransportZone(),
- Collections.<TransportZone>emptyList()).stream()
+ tzonesoptional.get().nonnullTransportZone().stream()
.filter(transportZone -> transportZone.getSubnets() != null)
.flatMap(transportZone -> transportZone.getSubnets().stream())
.filter(subnet -> subnet.getDeviceVteps() != null)
}
JdkFutures.addErrorLogging(
new ManagedNewTransactionRunnerImpl(dataBroker).callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
- tx -> requireNonNullElse(optionalElan.get().getElanInstance(),
- Collections.<ElanInstance>emptyList()).stream()
- .flatMap(elan -> requireNonNullElse(elan.getExternalTeps(),
- Collections.<ExternalTeps>emptyList()).stream()
+ tx -> optionalElan.get().nonnullElanInstance().stream()
+ .flatMap(elan -> elan.nonnullExternalTeps().stream()
.map(externalTep -> ElanL2GatewayMulticastUtils.buildExternalTepPath(
elan.getElanInstanceName(), externalTep.getTepIp())))
.filter(externalTepIid -> Objects.equals(
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;
private void disAssociateHwvtepsFromElan(String elanName, L2gatewayConnection input) {
Integer defaultVlan = input.getSegmentId();
- List<L2GatewayDevice> l2Devices =
- requireNonNullElse(ElanL2GwCacheUtils.getAllElanDevicesFromCache(), emptyList());
+ List<L2GatewayDevice> l2Devices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
List<Devices> l2gwDevicesToBeDeleted = new ArrayList<>();
for (L2GatewayDevice elanL2gwDevice : l2Devices) {
if (elanL2gwDevice.getL2GatewayIds().contains(input.key().getUuid())) {
String elanName = elanInstance.getElanInstanceName();
Integer defaultVlan = input.getSegmentId();
Uuid l2GwConnId = input.key().getUuid();
- List<Devices> l2Devices = requireNonNullElse(l2Gateway.getDevices(), emptyList());
+ List<Devices> l2Devices = l2Gateway.getDevices();
LOG.trace("Associating ELAN {} with L2Gw Conn Id {} having below L2Gw devices {}", elanName, l2GwConnId,
l2Devices);
+ if (l2Devices == null) {
+ return;
+ }
+
for (Devices l2Device : l2Devices) {
String l2DeviceName = l2Device.getDeviceName();
// L2gateway can have more than one L2 Gw devices. Configure Logical Switch, VLAN mappings,...
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 com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
-
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
-
import org.apache.commons.lang3.StringUtils;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
if (!existingElanDpnInterfaces.isPresent()) {
return dpIds;
}
- List<DpnInterfaces> dpnInterfaces =
- requireNonNullElse(existingElanDpnInterfaces.get().getDpnInterfaces(), emptyList());
+ List<DpnInterfaces> dpnInterfaces = existingElanDpnInterfaces.get().nonnullDpnInterfaces();
for (DpnInterfaces dpnInterface : dpnInterfaces) {
dpIds.add(dpnInterface.getDpId());
}
if (!existingElanDpnInterfaces.isPresent()) {
return false;
}
- List<DpnInterfaces> dpnInterfaces =
- requireNonNullElse(existingElanDpnInterfaces.get().getDpnInterfaces(), emptyList());
+ List<DpnInterfaces> dpnInterfaces = existingElanDpnInterfaces.get().nonnullDpnInterfaces();
for (DpnInterfaces dpnInterface : dpnInterfaces) {
if (Objects.equals(dpnInterface.getDpId(), dpId)) {
return true;
LOG.debug("RPC Call to Get egress actions for interface {} returned with Errors {}", ifName,
rpcResult.getErrors());
} else {
- listAction = requireNonNullElse(rpcResult.getResult().getAction(), emptyList());
+ listAction = rpcResult.getResult().nonnullAction();
}
} catch (Exception e) {
LOG.warn("Exception when egress actions for interface {}", ifName, e);
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;
}
Subnets subnets = getOrAddSubnet(zoneSubnets, subnetIp);
- for (Vteps existingVtep : requireNonNullElse(subnets.getVteps(), Collections.<Vteps>emptyList())) {
+ for (Vteps existingVtep : subnets.nonnullVteps()) {
if (Objects.equals(existingVtep.getDpnId(), dpnId)) {
return false;
}