programAclDispatcherTable(port, NwConstants.ADD_FLOW);
}
}
- Set<BigInteger> dpns = interfaceList.stream().map(port -> port.getDpId()).collect(Collectors.toSet());
+ Set<BigInteger> dpns = interfaceList.stream().map(AclInterface::getDpId).collect(Collectors.toSet());
programRemoteAclTable(aclName, remoteAclsDeleted, dpns, NwConstants.DEL_FLOW);
programRemoteAclTable(aclName, remoteAclsAdded, dpns, NwConstants.ADD_FLOW);
continue;
}
Set<AllowedAddressPairs> aaps =
- remoteAclInterfaces.stream().map(port -> port.getAllowedAddressPairs()).flatMap(List::stream)
- .filter(aap -> AclServiceUtils.isNotIpAllNetwork(aap)).collect(Collectors.toSet());
+ remoteAclInterfaces.stream().map(AclInterface::getAllowedAddressPairs).flatMap(List::stream)
+ .filter(AclServiceUtils::isNotIpAllNetwork).collect(Collectors.toSet());
Integer aclTag = aclServiceUtils.getAclTag(remoteAclId);
if (addOrRemove == NwConstants.ADD_FLOW) {
BigInteger dpId = port.getDpId();
int lportTag = port.getLPortTag();
List<AllowedAddressPairs> allowedAddresses = port.getAllowedAddressPairs();
- Set<MacAddress> macs = allowedAddresses.stream().map(aap -> aap.getMacAddress()).collect(Collectors.toSet());
+ Set<MacAddress> macs =
+ allowedAddresses.stream().map(AllowedAddressPairs::getMacAddress).collect(Collectors.toSet());
for (MacAddress mac : macs) {
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(new MatchEthernetSource(mac));
List<PortIds> portIds = new ArrayList<>(aclIpPrefixes.getPortIds());
// Checking if there are any other ports excluding ignorePorts
long noOfRemotePorts =
- portIds.stream().map(x -> x.getPortId()).filter(y -> !ignorePorts.contains(y)).count();
+ portIds.stream().map(PortIds::getPortId).filter(y -> !ignorePorts.contains(y)).count();
if (noOfRemotePorts > 0) {
skipDelete = true;
}
private static final String REM_ID_TAB_FOR = KEY_TAB + REM_ID_TAB;
private static final String REM_ID_HEAD = String.format(REM_ID_TAB_FOR, "Remote-ACL-ID", "ACL-ID")
+ "\n -------------------------------------------------------------------------";
- private static final String ACL_DATA_TAB_FOR = " %-8s %-8s ";
+ private static final String ACL_DATA_TAB_FOR = " %-8s %-8s %n";
private static final String ACL_DATA_HEAD = String.format(ACL_DATA_TAB_FOR, "ACL-ID", "ACL-TAG")
+ "\n -------------------------------------------------------------------------";
private static final String ACL_HEAD = String.format(ACL_DATA_TAB_FOR, "ACL-ID", "ACL")
session.getConsole().println("No data found");
return;
}
- session.getConsole().println(ACL_DATA_HEAD);
+ session.getConsole().print(ACL_DATA_HEAD);
session.getConsole().println(String.format(ACL_DATA_TAB_FOR, key, val));
} else if (key == null) {
if (!validateAll()) {
if (map.isEmpty()) {
session.getConsole().println("No data found");
} else {
- session.getConsole().println(ACL_DATA_HEAD);
+ session.getConsole().print(ACL_DATA_HEAD);
map.entrySet().stream().sorted(Map.Entry.comparingByValue()).forEach(entry -> session.getConsole()
.println(String.format(ACL_DATA_TAB_FOR, entry.getKey(), entry.getValue())));
}
session.getConsole().println("No data found");
return;
}
- session.getConsole().println(ACL_HEAD);
- session.getConsole().println(String.format(ACL_DATA_TAB_FOR, key, acl));
+ session.getConsole().print(ACL_HEAD);
+ session.getConsole().printf(ACL_DATA_TAB_FOR, key, acl);
} else if (key == null) {
if (!validateAll()) {
printAclMapHelp();
if (map.isEmpty()) {
session.getConsole().println("No data found");
} else {
- session.getConsole().println(ACL_HEAD);
- map.entrySet().stream().forEach(entry -> session.getConsole()
- .println(String.format(ACL_DATA_TAB_FOR, entry.getKey(), entry.getValue())));
+ session.getConsole().print(ACL_HEAD);
+ map.forEach((string, acl) -> session.getConsole().printf(ACL_DATA_TAB_FOR, string, acl));
}
}
}
private static final Predicate<List<?>> EMPTY_LIST = (list) -> list == null || list.isEmpty();
- private static final Predicate<Optional<Node>> CONTAINS_GLOBAL_AUGMENTATION = (optionalNode) -> {
- return optionalNode.isPresent() && optionalNode.get().getAugmentation(HwvtepGlobalAugmentation.class) != null;
- };
+ private static final Predicate<Optional<Node>> CONTAINS_GLOBAL_AUGMENTATION =
+ (optionalNode) -> optionalNode.isPresent()
+ && optionalNode.get().getAugmentation(HwvtepGlobalAugmentation.class) != null;
- private static final Predicate<Optional<Node>> CONTAINS_SWITCH_AUGMENTATION = (optionalNode) -> {
- return optionalNode.isPresent() && optionalNode.get().getAugmentation(PhysicalSwitchAugmentation.class) != null;
- };
+ private static final Predicate<Optional<Node>> CONTAINS_SWITCH_AUGMENTATION =
+ (optionalNode) -> optionalNode.isPresent()
+ && optionalNode.get().getAugmentation(PhysicalSwitchAugmentation.class) != null;
private final DataBroker dataBroker;
private final L2GatewayCache l2GatewayCache;
import com.google.common.base.Function;
import com.google.common.base.Optional;
-import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.File;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
data2 = cmd.transform(nodeIid1, data2);
}
Function<DataObject, DataObject> withoutUuidTransformer = cmd::withoutUuid;
- data1 = Lists.transform(data1, withoutUuidTransformer);
- data2 = Lists.transform(data2, withoutUuidTransformer);
+ data1 = data1.stream().map(withoutUuidTransformer).collect(Collectors.toList());
+ data2 = data2.stream().map(withoutUuidTransformer).collect(Collectors.toList());
Map<Identifier<?>, DataObject> map1 = new HashMap<>();
Map<Identifier<?>, DataObject> map2 = new HashMap<>();
evpnMacVrfUtils.updateEvpnDmacFlows(original, false);
evpnUtils.programEvpnL2vniDemuxTable(elanName,
(elan, interfaceName) -> evpnUtils.bindElanServiceToExternalTunnel(elanName, interfaceName),
- (dpnId, flowEntity) -> mdsalManager.installFlow(dpnId, flowEntity));
+ mdsalManager::installFlow);
} else if (evpnUtils.isAdvertiseEvpnRT2Routes(original, update)) {
evpnUtils.advertiseEvpnRT2Routes(update.getAugmentation(EvpnAugmentation.class), elanName);
evpnMacVrfUtils.updateEvpnDmacFlows(update, true);
evpnUtils.programEvpnL2vniDemuxTable(elanName,
(elan, interfaceName) -> evpnUtils.unbindElanServiceFromExternalTunnel(elanName, interfaceName),
- (dpnId, flowEntity) -> mdsalManager.removeFlow(dpnId, flowEntity));
+ mdsalManager::removeFlow);
}
}
return;
}
- tunnelInterfaceNameList.forEach(tunnelInterfaceName -> {
- serviceHandler.accept(elanName, tunnelInterfaceName);
- });
+ tunnelInterfaceNameList.forEach(tunnelInterfaceName -> serviceHandler.accept(elanName, tunnelInterfaceName));
programEvpnL2vniFlow(elanInfo, flowHandler);
}
haBuilder.setManagers(HwvtepHAUtil.buildManagersForHANode(srcGlobalNodeOptional.get(),
existingDstGlobalNodeOptional));
//Also update the manager section in config which helps in cluster reboot scenarios
- haBuilder.getManagers().stream().forEach((manager) -> {
+ haBuilder.getManagers().forEach((manager) -> {
InstanceIdentifier<Managers> managerIid = dstPath.augmentation(HwvtepGlobalAugmentation.class)
.child(Managers.class, manager.getKey());
tx.put(CONFIGURATION, managerIid, manager, true);
haOpClusteredListener.getConnectedNodes()
.stream()
.filter((connectedIid) -> IS_PS_CHILD_TO_GLOBAL_NODE.test(childGlobalNodeId, connectedIid))
- .forEach((connectedIid) -> childPsIids.add(connectedIid));
+ .forEach(childPsIids::add);
} else {
hwvtepGlobalAugmentation.getSwitches().forEach(
(switches) -> childPsIids.add(switches.getSwitchRef().getValue()));
&& managers.getManagerOtherConfigs() != null) {
managers.getManagerOtherConfigs().stream()
.filter(otherConfig -> otherConfig.getKey().getOtherConfigKey().contains(HwvtepHAUtil.HA_CHILDREN))
- .flatMap(otherConfig -> Arrays.asList(otherConfig.getOtherConfigValue().split(",")).stream())
+ .flatMap(otherConfig -> Arrays.stream(otherConfig.getOtherConfigValue().split(",")))
.map(HwvtepHAUtil::convertToInstanceIdentifier)
.forEach(childIid -> HwvtepHACache.getInstance().addChild(parent, childIid));
}
protected Map<Class<?>, MergeCommand> commands = new HashMap<>();
- private final BiPredicate<LogicalDatastoreType, Class> skipCopy = (dsType, cmdType) -> {
- return (dsType == CONFIGURATION ? commands.get(cmdType) instanceof LocalUcastCmd :
- commands.get(cmdType) instanceof RemoteUcastCmd);
- };
+ private final BiPredicate<LogicalDatastoreType, Class> skipCopy =
+ (dsType, cmdType) -> (dsType == CONFIGURATION ? commands.get(cmdType) instanceof LocalUcastCmd
+ : commands.get(cmdType) instanceof RemoteUcastCmd);
protected MergeCommandsAggregator() {
}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.genius.datastoreutils.hwvtep.HwvtepAbstractDataTreeChangeListener;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
private static final Logger LOG = LoggerFactory.getLogger(HwvtepPhysicalSwitchListener.class);
private static final BiPredicate<L2GatewayDevice, InstanceIdentifier<Node>> DEVICE_NOT_CACHED_OR_PARENT_CONNECTED =
- (l2GatewayDevice, globalIid) -> {
- return l2GatewayDevice == null || l2GatewayDevice.getHwvtepNodeId() == null
- || !Objects.equals(l2GatewayDevice.getHwvtepNodeId(),
- globalIid.firstKeyOf(Node.class).getNodeId().getValue());
- };
+ (l2GatewayDevice, globalIid) -> l2GatewayDevice == null || l2GatewayDevice.getHwvtepNodeId() == null
+ || !Objects.equals(l2GatewayDevice.getHwvtepNodeId(),
+ globalIid.firstKeyOf(Node.class).getNodeId().getValue());
private static final Predicate<PhysicalSwitchAugmentation> TUNNEL_IP_AVAILABLE =
phySwitch -> !HwvtepHAUtil.isEmpty(phySwitch.getTunnelIps());
private static final Predicate<PhysicalSwitchAugmentation> TUNNEL_IP_NOT_AVAILABLE = TUNNEL_IP_AVAILABLE.negate();
private static final BiPredicate<PhysicalSwitchAugmentation, L2GatewayDevice> TUNNEL_IP_CHANGED =
- (phySwitchAfter, existingDevice) -> {
- return TUNNEL_IP_AVAILABLE.test(phySwitchAfter)
- && !Objects.equals(
- existingDevice.getTunnelIp(), phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
- };
+ (phySwitchAfter, existingDevice) -> TUNNEL_IP_AVAILABLE.test(phySwitchAfter)
+ && !Objects.equals(
+ existingDevice.getTunnelIp(), phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
/** The data broker. */
private final DataBroker dataBroker;
};
private final Predicate<L2GatewayDevice> alreadyHasL2Gwids =
- (l2GwDevice) -> {
- return l2GwDevice != null && HwvtepHAUtil.isEmpty(l2GwDevice.getL2GatewayIds());
- };
+ (l2GwDevice) -> l2GwDevice != null && HwvtepHAUtil.isEmpty(l2GwDevice.getL2GatewayIds());
private final BiPredicate<L2GatewayDevice, InstanceIdentifier<Node>> parentConnectedAfterChild =
(l2GwDevice, globalIid) -> {
}
handleAdd(l2GwDevice);
- elanClusterUtils.runOnlyInOwnerNode("Update config tunnels IP ", () -> {
- try {
- updateConfigTunnelIp(identifier, phySwitchAdded);
- } catch (ReadFailedException e) {
- LOG.error("Failed to update tunnel ips {}", identifier);
- }
- });
- return;
+ elanClusterUtils.runOnlyInOwnerNode("Update config tunnels IP ",
+ () -> updateConfigTunnelIp(identifier, phySwitchAdded));
});
}
}
private void updateConfigTunnelIp(InstanceIdentifier<PhysicalSwitchAugmentation> identifier,
- PhysicalSwitchAugmentation phySwitchAdded) throws ReadFailedException {
+ PhysicalSwitchAugmentation phySwitchAdded) {
if (phySwitchAdded.getTunnelIps() != null) {
ListenableFutures.addErrorLogging(
txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
private static final Logger LOG = LoggerFactory.getLogger(L2GatewayConnectionListener.class);
private static final int MAX_READ_TRIALS = 120;
- private static final Function<Node, InstanceIdentifier<Node>> TO_GLOBAL_PATH = (psNode) -> {
- return HwvtepHAUtil.getGlobalNodePathFromPSNode(psNode);
- };
+ private static final Function<Node, InstanceIdentifier<Node>> TO_GLOBAL_PATH =
+ HwvtepHAUtil::getGlobalNodePathFromPSNode;
- private static final Function<Node, InstanceIdentifier<Node>> TO_NODE_PATH = (node) -> {
- return HwvtepSouthboundUtils.createInstanceIdentifier(node.getNodeId());
- };
+ private static final Function<Node, InstanceIdentifier<Node>> TO_NODE_PATH =
+ (node) -> HwvtepSouthboundUtils.createInstanceIdentifier(node.getNodeId());
- private static final Function<InstanceIdentifier<Node>, String> GET_DEVICE_NAME = (psIid) -> {
- return HwvtepHAUtil.getPsName(psIid);
- };
+ private static final Function<InstanceIdentifier<Node>, String> GET_DEVICE_NAME = HwvtepHAUtil::getPsName;
- private static final Predicate<InstanceIdentifier<Node>> IS_PS_NODE = (psIid) -> {
- return HwvtepHAUtil.getPsName(psIid) != null;
- };
+ private static final Predicate<InstanceIdentifier<Node>> IS_PS_NODE = (psIid) ->
+ HwvtepHAUtil.getPsName(psIid) != null;
private static final Predicate<Node> IS_HA_PARENT_NODE = (node) -> {
HwvtepGlobalAugmentation augmentation = node.getAugmentation(HwvtepGlobalAugmentation.class);
return false;
};
- private static final BiPredicate<InstanceIdentifier<Node>, Node> PS_NODE_OF_PARENT_NODE = (psIid, node) -> {
- return psIid.firstKeyOf(Node.class).getNodeId().getValue().contains(node.getNodeId().getValue());
- };
+ private static final BiPredicate<InstanceIdentifier<Node>, Node> PS_NODE_OF_PARENT_NODE =
+ (psIid, node) -> psIid.firstKeyOf(Node.class).getNodeId().getValue().contains(node.getNodeId().getValue());
private final DataBroker broker;
private final L2GatewayConnectionUtils l2GatewayConnectionUtils;
//Process HA nodes
allNodes.values().stream()
.filter(IS_HA_PARENT_NODE)
- .forEach(parentNode -> {
- allIids.stream()
- .filter(IS_PS_NODE)
- .filter(psIid -> PS_NODE_OF_PARENT_NODE.test(psIid, parentNode))
- .forEach(psIid -> {
- addL2DeviceToCache(psIid, parentNode, allNodes.get(psIid));
- });
- });
+ .forEach(parentNode -> allIids.stream()
+ .filter(IS_PS_NODE)
+ .filter(psIid -> PS_NODE_OF_PARENT_NODE.test(psIid, parentNode))
+ .forEach(psIid -> addL2DeviceToCache(psIid, parentNode, allNodes.get(psIid))));
//Process non HA nodes there will be only one ps node iid for each device for non ha nodes
psNodesByDeviceName.values().stream()
if (augmentation != null && augmentation.getLocalUcastMacs() != null) {
macs.addAll(augmentation.getLocalUcastMacs().stream()
.filter(mac -> getLogicalSwitchName(mac).equals(elanName))
- .map(mac -> mac.getMacEntryKey())
+ .map(HwvtepMacTableGenericAttributes::getMacEntryKey)
.collect(Collectors.toSet()));
}
function.apply(macs);
public void scheduleDeleteLogicalSwitch(final NodeId hwvtepNodeId, final String lsName, final boolean clearUcast) {
final Pair<NodeId, String> nodeIdLogicalSwitchNamePair = new ImmutablePair<>(hwvtepNodeId, lsName);
- logicalSwitchDeletedTasks.computeIfAbsent(nodeIdLogicalSwitchNamePair, (key) -> {
- return scheduler.getScheduledExecutorService().schedule(() -> {
+ logicalSwitchDeletedTasks.computeIfAbsent(nodeIdLogicalSwitchNamePair,
+ (key) -> scheduler.getScheduledExecutorService().schedule(() -> {
DeleteLogicalSwitchJob deleteLsJob = new DeleteLogicalSwitchJob(broker,
ElanL2GatewayUtils.this, hwvtepNodeId, lsName, clearUcast);
jobCoordinator.enqueueJob(deleteLsJob.getJobKey(), deleteLsJob,
SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
deleteJobs.put(nodeIdLogicalSwitchNamePair, deleteLsJob);
logicalSwitchDeletedTasks.remove(nodeIdLogicalSwitchNamePair);
- }, getLogicalSwitchDeleteDelaySecs(), TimeUnit.SECONDS);
- });
+ }, getLogicalSwitchDeleteDelaySecs(), TimeUnit.SECONDS));
}
public void cancelDeleteLogicalSwitch(final NodeId hwvtepNodeId, final String lsName) {
if (augmentation != null && augmentation.getLocalUcastMacs() != null) {
macs.addAll(augmentation.getLocalUcastMacs().stream()
.filter(mac -> getLogicalSwitchName(mac).equals(elanName))
- .map(mac -> mac.getMacEntryKey())
+ .map(HwvtepMacTableGenericAttributes::getMacEntryKey)
.collect(Collectors.toSet()));
}
}
return;
}
localUcastMacs.stream()
- .filter((mac) -> {
- return macBelongsToLogicalSwitch(mac, elanName);
- })
+ .filter((mac) -> macBelongsToLogicalSwitch(mac, elanName))
.forEach((mac) -> {
InstanceIdentifier<LocalUcastMacs> macIid = getMacIid(nodeIid, mac);
localUcastMacListener.added(macIid, mac);
Map<String, List<InstanceIdentifier<VlanBindings>>> vlans = new HashMap<>();
ports.stream()
.filter(CONTAINS_VLANBINDINGS)
- .forEach((port) -> {
- port.getAugmentation(HwvtepPhysicalPortAugmentation.class)
- .getVlanBindings()
- .forEach((binding) -> putVlanBindingVsLogicalSwitch(configPsNode, vlans, port, binding));
- });
+ .forEach((port) -> port.getAugmentation(HwvtepPhysicalPortAugmentation.class)
+ .getVlanBindings()
+ .forEach((binding) -> putVlanBindingVsLogicalSwitch(configPsNode, vlans, port, binding)));
return vlans;
}
prefixIpList = Collections.singletonList(vrfEntry.getDestPrefix());
} else {
List<String> prefixIpListLocal = new ArrayList<>();
- vpnExtraRoutes.stream().forEach(route -> {
- route.getNexthopIpList().stream().forEach(extraRouteIp -> {
- String ipPrefix;
- if (isIpv4Address(extraRouteIp)) {
- ipPrefix = extraRouteIp + NwConstants.IPV4PREFIX;
- } else {
- ipPrefix = extraRouteIp + NwConstants.IPV6PREFIX;
- }
- prefixIpListLocal.add(ipPrefix);
- });
- });
+ vpnExtraRoutes.forEach(route -> route.getNexthopIpList().forEach(extraRouteIp -> {
+ String ipPrefix;
+ if (isIpv4Address(extraRouteIp)) {
+ ipPrefix = extraRouteIp + NwConstants.IPV4PREFIX;
+ } else {
+ ipPrefix = extraRouteIp + NwConstants.IPV6PREFIX;
+ }
+ prefixIpListLocal.add(ipPrefix);
+ }));
prefixIpList = prefixIpListLocal;
}
} else {
// ECMP Use case, point to LB group. Move the mpls label accordingly.
List<String> tunnelList =
adjacencyResults.stream()
- .map(adjacencyResult -> adjacencyResult.getNextHopIp())
+ .map(NexthopManager.AdjacencyResult::getNextHopIp)
.sorted().collect(toList());
String lbGroupKey = FibUtil.getGreLbGroupKey(tunnelList);
long groupId = nexthopManager.createNextHopPointer(lbGroupKey);
private final DataBroker dataBroker;
private final Ipv6ServiceEosHandler ipv6ServiceEosHandler;
private final PacketProcessingService packetService;
- private final Ipv6PeriodicTrQueue ipv6Queue = new Ipv6PeriodicTrQueue(portId -> transmitUnsolicitedRA(portId));
+ private final Ipv6PeriodicTrQueue ipv6Queue = new Ipv6PeriodicTrQueue(this::transmitUnsolicitedRA);
private final Ipv6TimerWheel timer = new Ipv6TimerWheel();
@Inject
private final Consumer<Uuid> onMessage;
private final ConcurrentLinkedQueue<Uuid> ipv6PeriodicQueue = new ConcurrentLinkedQueue<>();
- private final Thread transmitterThread = new Thread(() -> threadRunLoop());
+ private final Thread transmitterThread = new Thread(this::threadRunLoop);
private final ReentrantLock queueLock = new ReentrantLock();
private final Condition queueCondition = queueLock.newCondition();
private volatile boolean closed;
nbNextHops++;
nextHopList.add(new String(routeTmp.getNexthop().getValue()));
}
- final List<String> rdList = new ArrayList();
+ final List<String> rdList = new ArrayList<>();
if (vpnInstance.getIpv4Family() != null
&& vpnInstance.getIpv4Family().getRouteDistinguisher() != null) {
- vpnInstance.getIpv4Family().getRouteDistinguisher().stream().forEach(rd -> {
+ vpnInstance.getIpv4Family().getRouteDistinguisher().forEach(rd -> {
if (rd != null) {
rdList.add(rd);
}
});
}
if (vpnInstance.getIpv6Family() != null && vpnInstance.getIpv6Family().getRouteDistinguisher() != null) {
- vpnInstance.getIpv6Family().getRouteDistinguisher().stream().forEach(rd -> {
+ vpnInstance.getIpv6Family().getRouteDistinguisher().forEach(rd -> {
if (rd != null && !rdList.contains(rd)) {
rdList.add(rd);
}
return;
}
if (original.getDevices() == null) {
- connections.forEach(
- (connection) -> l2gwService.addL2GatewayConnection(connection));
+ connections.forEach(l2gwService::addL2GatewayConnection);
return;
}
jobCoordinator.enqueueJob("l2gw.update", () -> {
.stream()
.filter((intf) -> !updatedDeviceInterfaces.containsInterface(
deviceName, intf.getInterfaceName()))
- .forEach((intf) -> {
- connections.forEach((connection) -> {
- Integer vlanId = connection.getSegmentId();
- if (intf.getSegmentationIds() != null
- && !intf.getSegmentationIds().isEmpty()) {
- for (Integer vlan : intf.getSegmentationIds()) {
- HwvtepUtils.deleteVlanBinding(transaction,
- physicalSwitchNodeId, intf.getInterfaceName(), vlan);
- }
- } else {
- LOG.debug("Deleting vlan binding {} {} {}",
- physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
- HwvtepUtils.deleteVlanBinding(transaction, physicalSwitchNodeId,
- intf.getInterfaceName(), vlanId);
+ .forEach((intf) -> connections.forEach((connection) -> {
+ Integer vlanId = connection.getSegmentId();
+ if (intf.getSegmentationIds() != null
+ && !intf.getSegmentationIds().isEmpty()) {
+ for (Integer vlan : intf.getSegmentationIds()) {
+ HwvtepUtils.deleteVlanBinding(transaction,
+ physicalSwitchNodeId, intf.getInterfaceName(), vlan);
}
- });
- });
+ } else {
+ LOG.debug("Deleting vlan binding {} {} {}",
+ physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
+ HwvtepUtils.deleteVlanBinding(transaction, physicalSwitchNodeId,
+ intf.getInterfaceName(), vlanId);
+ }
+ }));
});
fts.add(transaction.submit());
Futures.addCallback(fts.get(0), new FutureCallback<Void>() {
private void initPortStatsData() {
qosAlertDpnPortNumberMap.values().forEach(portDataMap -> portDataMap.values()
- .forEach(portData -> portData.initPortData()));
+ .forEach(QosAlertPortData::initPortData));
}
private static class AlertThresholdSupplier implements Supplier<BigInteger> {
return;
}
- if (results.get(id).get(groupName) == null) {
- results.get(id).put(groupName, new HashMap<>());
- }
-
- results.get(id).get(groupName).put(counterName, counterValue);
+ results.get(id).computeIfAbsent(groupName, k -> new HashMap<>()).put(counterName, counterValue);
}
public Set<String> getGroupCounterNames(String groupName) {
final BigInteger inputDpId = dpId;
jobCoordinator.enqueueJob("VPNINTERFACE-" + ifName, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>(3);
- ListenableFuture<Void> configFuture = txRunner
- .callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> {
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
- VpnInterface cfgVpnInterface =
- VpnUtil.getConfiguredVpnInterface(dataBroker, ifName);
- if (cfgVpnInterface == null) {
- LOG.debug("Interface {} is not a vpninterface, ignoring.", ifName);
- return;
- }
- for (VpnInstanceNames vpnInterfaceVpnInstance :
- cfgVpnInterface.getVpnInstanceNames()) {
- String vpnName = vpnInterfaceVpnInstance.getVpnName();
- Optional<VpnInterfaceOpDataEntry> optVpnInterface =
- VpnUtil.getVpnInterfaceOpDataEntry(dataBroker, ifName, vpnName);
- if (!optVpnInterface.isPresent()) {
- LOG.debug("Interface {} vpn {} is not a vpninterface, or deletion"
- + " triggered by northbound agent. ignoring.", ifName, vpnName);
- continue;
+ ListenableFuture<Void> configFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+ writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+ writeOperTxn -> futures.add(
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
+ VpnInterface cfgVpnInterface =
+ VpnUtil.getConfiguredVpnInterface(dataBroker, ifName);
+ if (cfgVpnInterface == null) {
+ LOG.debug("Interface {} is not a vpninterface, ignoring.", ifName);
+ return;
}
- final VpnInterfaceOpDataEntry vpnInterface = optVpnInterface.get();
- String gwMac = intrf.getPhysAddress() != null ? intrf.getPhysAddress()
- .getValue() : vpnInterface.getGatewayMacAddress();
- BigInteger dpnId = inputDpId;
- if (dpnId == null || dpnId.equals(BigInteger.ZERO)) {
- dpnId = vpnInterface.getDpnId();
+ for (VpnInstanceNames vpnInterfaceVpnInstance :
+ cfgVpnInterface.getVpnInstanceNames()) {
+ String vpnName = vpnInterfaceVpnInstance.getVpnName();
+ Optional<VpnInterfaceOpDataEntry> optVpnInterface =
+ VpnUtil.getVpnInterfaceOpDataEntry(dataBroker, ifName, vpnName);
+ if (!optVpnInterface.isPresent()) {
+ LOG.debug("Interface {} vpn {} is not a vpninterface, or deletion"
+ + " triggered by northbound agent. ignoring.", ifName, vpnName);
+ continue;
+ }
+ final VpnInterfaceOpDataEntry vpnInterface = optVpnInterface.get();
+ String gwMac = intrf.getPhysAddress() != null ? intrf.getPhysAddress()
+ .getValue() : vpnInterface.getGatewayMacAddress();
+ BigInteger dpnId = inputDpId;
+ if (dpnId == null || dpnId.equals(BigInteger.ZERO)) {
+ dpnId = vpnInterface.getDpnId();
+ }
+ final int ifIndex = intrf.getIfIndex();
+ LOG.info("VPN Interface remove event - intfName {} onto vpnName {}"
+ + " running oper-driver", vpnInterface.getName(), vpnName);
+ vpnInterfaceManager.processVpnInterfaceDown(dpnId, ifName, ifIndex, gwMac,
+ vpnInterface, false, writeConfigTxn, writeOperTxn, writeInvTxn);
}
- final int ifIndex = intrf.getIfIndex();
- LOG.info("VPN Interface remove event - intfName {} onto vpnName {}"
- + " running oper-driver", vpnInterface.getName(), vpnName);
- vpnInterfaceManager.processVpnInterfaceDown(dpnId, ifName, ifIndex, gwMac,
- vpnInterface, false, writeConfigTxn, writeOperTxn, writeInvTxn);
- }
- }));
- }));
- });
+ })))));
futures.add(configFuture);
Futures.addCallback(configFuture, new PostVpnInterfaceThreadWorker(intrf.getName(), false,
"Operational"));
update.getName());
jobCoordinator.enqueueJob("VPNINTERFACE-" + ifName, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>(3);
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> {
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
- final VpnInterface vpnIf =
- VpnUtil.getConfiguredVpnInterface(dataBroker, ifName);
- if (vpnIf != null) {
- final int ifIndex = update.getIfIndex();
- BigInteger dpnId = BigInteger.ZERO;
- try {
- dpnId = InterfaceUtils.getDpIdFromInterface(update);
- } catch (Exception e) {
- LOG.error("remove: Unable to retrieve dpnId for interface {}", ifName, e);
- return;
- }
- if (update.getOperStatus().equals(Interface.OperStatus.Up)) {
- for (VpnInstanceNames vpnInterfaceVpnInstance : vpnIf.getVpnInstanceNames()) {
- String vpnName = vpnInterfaceVpnInstance.getVpnName();
- String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
- if (!vpnInterfaceManager.isVpnInstanceReady(vpnName)) {
- LOG.error("VPN Interface update event - intfName {} onto vpnName {} "
- + "running oper-driven UP, VpnInstance not ready,"
- + " holding on", vpnIf.getName(), vpnName);
- } else if (VpnUtil.isVpnPendingDelete(dataBroker, primaryRd)) {
- LOG.error("update: Ignoring UP event for vpnInterface {}, as "
- + "vpnInstance {} with primaryRd {} is already marked for"
- + " deletion", vpnIf.getName(), vpnName, primaryRd);
- } else {
- vpnInterfaceManager.processVpnInterfaceUp(dpnId, vpnIf, primaryRd,
- ifIndex, true, writeConfigTxn, writeOperTxn, writeInvTxn,
- update, vpnName);
- }
+ futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> futures.add(
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> futures.add(
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
+ final VpnInterface vpnIf =
+ VpnUtil.getConfiguredVpnInterface(dataBroker, ifName);
+ if (vpnIf != null) {
+ final int ifIndex = update.getIfIndex();
+ BigInteger dpnId = BigInteger.ZERO;
+ try {
+ dpnId = InterfaceUtils.getDpIdFromInterface(update);
+ } catch (Exception e) {
+ LOG.error("remove: Unable to retrieve dpnId for interface {}", ifName, e);
+ return;
}
- } else if (update.getOperStatus().equals(Interface.OperStatus.Down)) {
- for (VpnInstanceNames vpnInterfaceVpnInstance : vpnIf.getVpnInstanceNames()) {
- String vpnName = vpnInterfaceVpnInstance.getVpnName();
- LOG.info("VPN Interface update event - intfName {} onto vpnName {}"
- + " running oper-driven DOWN", vpnIf.getName(), vpnName);
- Optional<VpnInterfaceOpDataEntry> optVpnInterface =
- VpnUtil.getVpnInterfaceOpDataEntry(dataBroker,
- vpnIf.getName(), vpnName);
- if (optVpnInterface.isPresent()) {
- VpnInterfaceOpDataEntry vpnOpInterface = optVpnInterface.get();
- vpnInterfaceManager.processVpnInterfaceDown(dpnId, vpnIf.getName(),
- ifIndex, update.getPhysAddress().getValue(), vpnOpInterface,
- true, writeConfigTxn, writeOperTxn, writeInvTxn);
- } else {
- LOG.error("InterfaceStateChangeListener Update DOWN - vpnInterface {}"
- + " not available, ignoring event", vpnIf.getName());
- continue;
+ if (update.getOperStatus().equals(OperStatus.Up)) {
+ for (VpnInstanceNames vpnInterfaceVpnInstance :
+ vpnIf.getVpnInstanceNames()) {
+ String vpnName = vpnInterfaceVpnInstance.getVpnName();
+ String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
+ if (!vpnInterfaceManager.isVpnInstanceReady(vpnName)) {
+ LOG.error(
+ "VPN Interface update event - intfName {} onto vpnName {} "
+ + "running oper-driven UP, VpnInstance not ready,"
+ + " holding on", vpnIf.getName(), vpnName);
+ } else if (VpnUtil.isVpnPendingDelete(dataBroker, primaryRd)) {
+ LOG.error("update: Ignoring UP event for vpnInterface {}, as "
+ + "vpnInstance {} with primaryRd {} is already marked for"
+ + " deletion", vpnIf.getName(), vpnName, primaryRd);
+ } else {
+ vpnInterfaceManager.processVpnInterfaceUp(dpnId, vpnIf, primaryRd,
+ ifIndex, true, writeConfigTxn, writeOperTxn, writeInvTxn,
+ update, vpnName);
+ }
+ }
+ } else if (update.getOperStatus().equals(OperStatus.Down)) {
+ for (VpnInstanceNames vpnInterfaceVpnInstance :
+ vpnIf.getVpnInstanceNames()) {
+ String vpnName = vpnInterfaceVpnInstance.getVpnName();
+ LOG.info("VPN Interface update event - intfName {} onto vpnName {}"
+ + " running oper-driven DOWN", vpnIf.getName(), vpnName);
+ Optional<VpnInterfaceOpDataEntry> optVpnInterface =
+ VpnUtil.getVpnInterfaceOpDataEntry(dataBroker,
+ vpnIf.getName(), vpnName);
+ if (optVpnInterface.isPresent()) {
+ VpnInterfaceOpDataEntry vpnOpInterface = optVpnInterface.get();
+ vpnInterfaceManager.processVpnInterfaceDown(dpnId, vpnIf.getName(),
+ ifIndex, update.getPhysAddress().getValue(), vpnOpInterface,
+ true, writeConfigTxn, writeOperTxn, writeInvTxn);
+ } else {
+ LOG.error(
+ "InterfaceStateChangeListener Update DOWN - vpnInterface {}"
+ + " not available, ignoring event", vpnIf.getName());
+ continue;
+ }
}
}
+ } else {
+ LOG.debug("Interface {} is not a vpninterface, ignoring.", ifName);
}
- } else {
- LOG.debug("Interface {} is not a vpninterface, ignoring.", ifName);
- }
- }));
- }));
- }));
+ }))))));
return futures;
});
}
jobCoordinator.enqueueJob("VPNINTERFACE-" + interfaceName,
() -> {
List<ListenableFuture<Void>> futures = new ArrayList<>(3);
- ListenableFuture<Void> configFuture = txRunner
- .callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> {
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
- LOG.info("remove: - intfName {} onto vpnName {} running config-driven",
- interfaceName, vpnName);
- BigInteger dpId = BigInteger.ZERO;
- int ifIndex = 0;
- String gwMacAddress = null;
- InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
- VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
- final Optional<VpnInterfaceOpDataEntry> optVpnInterface =
- VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, interfaceId);
- if (interfaceState != null) {
- try {
- dpId = InterfaceUtils.getDpIdFromInterface(interfaceState);
- } catch (NumberFormatException | IllegalStateException e) {
- LOG.error("remove: Unable to retrieve dpnId from interface operational"
- + " data store for interface {} on dpn {} for vpn {} Fetching"
- + " from vpn interface op data store. ", interfaceName,
- vpnInterface.getDpnId(), vpnName, e);
- dpId = BigInteger.ZERO;
- }
- ifIndex = interfaceState.getIfIndex();
- gwMacAddress = interfaceState.getPhysAddress().getValue();
- } else {
- LOG.info("remove: Interface state not available for {}. Trying to fetch data"
- + " from vpn interface op.", interfaceName);
- if (optVpnInterface.isPresent()) {
- VpnInterfaceOpDataEntry vpnOpInterface = optVpnInterface.get();
- dpId = vpnOpInterface.getDpnId();
- ifIndex = vpnOpInterface.getLportTag().intValue();
- gwMacAddress = vpnOpInterface.getGatewayMacAddress();
- } else {
- LOG.error("remove: Handling removal of VPN interface {} for vpn {} skipped"
- + " as interfaceState and vpn interface op is not"
- + " available", interfaceName, vpnName);
- return;
- }
- }
- processVpnInterfaceDown(dpId, interfaceName, ifIndex, gwMacAddress,
- optVpnInterface.isPresent() ? optVpnInterface.get() : null, false,
- writeConfigTxn, writeOperTxn, writeInvTxn);
- LOG.info(
- "remove: Removal of vpn interface {} on dpn {} for vpn {} processed "
- + "successfully",
- interfaceName, vpnInterface.getDpnId(), vpnName);
- }));
- }));
- });
+ ListenableFuture<Void> configFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+ writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+ writeOperTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
+ LOG.info("remove: - intfName {} onto vpnName {} running config-driven",
+ interfaceName, vpnName);
+ BigInteger dpId = BigInteger.ZERO;
+ int ifIndex = 0;
+ String gwMacAddress = null;
+ InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
+ VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
+ final Optional<VpnInterfaceOpDataEntry> optVpnInterface =
+ VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, interfaceId);
+ if (interfaceState != null) {
+ try {
+ dpId = InterfaceUtils.getDpIdFromInterface(interfaceState);
+ } catch (NumberFormatException | IllegalStateException e) {
+ LOG.error("remove: Unable to retrieve dpnId from interface operational"
+ + " data store for interface {} on dpn {} for vpn {} Fetching"
+ + " from vpn interface op data store. ", interfaceName,
+ vpnInterface.getDpnId(), vpnName, e);
+ dpId = BigInteger.ZERO;
+ }
+ ifIndex = interfaceState.getIfIndex();
+ gwMacAddress = interfaceState.getPhysAddress().getValue();
+ } else {
+ LOG.info("remove: Interface state not available for {}. Trying to fetch data"
+ + " from vpn interface op.", interfaceName);
+ if (optVpnInterface.isPresent()) {
+ VpnInterfaceOpDataEntry vpnOpInterface = optVpnInterface.get();
+ dpId = vpnOpInterface.getDpnId();
+ ifIndex = vpnOpInterface.getLportTag().intValue();
+ gwMacAddress = vpnOpInterface.getGatewayMacAddress();
+ } else {
+ LOG.error("remove: Handling removal of VPN interface {} for vpn {} skipped"
+ + " as interfaceState and vpn interface op is not"
+ + " available", interfaceName, vpnName);
+ return;
+ }
+ }
+ processVpnInterfaceDown(dpId, interfaceName, ifIndex, gwMacAddress,
+ optVpnInterface.isPresent() ? optVpnInterface.get() : null, false,
+ writeConfigTxn, writeOperTxn, writeInvTxn);
+ LOG.info(
+ "remove: Removal of vpn interface {} on dpn {} for vpn {} processed "
+ + "successfully",
+ interfaceName, vpnInterface.getDpnId(), vpnName);
+ })))));
futures.add(configFuture);
Futures.addCallback(configFuture, new PostVpnInterfaceWorker(interfaceName, false, "Config"));
return futures;
}
final String extIfcFinal = extIfc;
- ListenableFuture<Void> listenableFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
- doAddArpResponderFlowsToExternalNetworkIps(
- id, fixedIps, macAddress, dpnId, extNetworkId, tx, extIfcFinal);
- });
+ ListenableFuture<Void> listenableFuture =
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> doAddArpResponderFlowsToExternalNetworkIps(
+ id, fixedIps, macAddress, dpnId, extNetworkId, tx, extIfcFinal));
ListenableFutures.addErrorLogging(listenableFuture, LOG,
"Error while configuring arp responder for ext. interface");
java.util.Optional<String> allocatedRd = VpnExtraRouteHelper
.getRdAllocatedForExtraRoute(dataBroker, vpnId, prefix, nextHop);
if (allocatedRd.isPresent()) {
- return java.util.Optional.of(allocatedRd.get());
+ return allocatedRd;
}
//Check if rd is already allocated for this extraroute behind the same CSS. If yes, reuse it