import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
import org.opendaylight.genius.utils.hwvtep.HwvtepUtils;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
-import org.opendaylight.infrautils.utils.concurrent.JdkFutures;
+import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.cache.ElanInstanceDpnsCache;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
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);
}
- public ElanInstance getElanInstanceForUcastLocalMac(LocalUcastMacs localUcastMac) {
- Optional<LogicalSwitches> lsOpc = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL,
- (InstanceIdentifier<LogicalSwitches>) localUcastMac.getLogicalSwitchRef().getValue());
- if (lsOpc.isPresent()) {
- LogicalSwitches ls = lsOpc.get();
- // Logical switch name is Elan name
- String elanName = getElanFromLogicalSwitch(ls.getHwvtepNodeName().getValue());
- return elanInstanceCache.get(elanName).orNull();
- }
- return null;
- }
-
/**
* Install external device local macs in dpn.
*
}
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 Futures.immediateFailedFuture(new RuntimeException(errMsg));
}
- return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ return txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712
.l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) {
//Removed the check for checking terminationPoint present in OP or not
*/
public ListenableFuture<Void> updateVlanBindingsInL2GatewayDevice(NodeId nodeId, String psName,
String interfaceName, List<VlanBindings> vlanBindings) {
- return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ return txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
HwvtepUtils.mergeVlanBindings(tx, nodeId, psName, interfaceName, vlanBindings);
LOG.info("Updated Hwvtep VlanBindings in config DS. NodeID: {}", nodeId.getValue());
});
}
NodeId physicalSwitchNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, hwVtepDevice.getDeviceName());
- return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ return txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712
.l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) {
String phyPortName = deviceInterface.getInterfaceName();
});
}
- /**
- * Gets the elan name from logical switch name.
- *
- * @param logicalSwitchName
- * the logical switch name
- * @return the elan name from logical switch name
- */
- public static String getElanFromLogicalSwitch(String logicalSwitchName) {
- // Assuming elan name is same as logical switch name
- String elanName = logicalSwitchName;
- return elanName;
- }
-
/**
* Gets the logical switch name from elan name.
*
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()
+ tzonesoptional.get().nonnullTransportZone().stream()
.filter(transportZone -> transportZone.getSubnets() != null)
.flatMap(transportZone -> transportZone.getSubnets().stream())
.filter(subnet -> subnet.getDeviceVteps() != null)
if (!optionalElan.isPresent()) {
return;
}
- JdkFutures.addErrorLogging(
+ LoggingFutures.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 -> optionalElan.get().nonnullElanInstance().stream()
+ .flatMap(elan -> elan.nonnullExternalTeps().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);
}
}
- public static String getNodeIdFromDpnId(BigInteger dpnId) {
- return MDSALUtil.NODE_PREFIX + MDSALUtil.SEPARATOR + dpnId.toString();
- }
-
public void scheduleAddDpnMacInExtDevices(String elanName, BigInteger dpId,
List<PhysAddress> staticMacAddresses) {
ConcurrentMap<String, L2GatewayDevice> elanDevices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
}
}
- @Nonnull
+ @NonNull
public Collection<DpnInterfaces> getElanDpns(String elanName) {
Collection<DpnInterfaces> dpnInterfaces = elanInstanceDpnsCache.get(elanName);
if (!dpnInterfaces.isEmpty()) {