use of org.opendaylight.genius.itm.utils.TunnelStateInfoBuilder in project genius by opendaylight.
the class DPNTEPsInfoCache method added.
@Override
protected void added(InstanceIdentifier<DPNTEPsInfo> path, DPNTEPsInfo dpnTepsInfo) {
final Uint64 dpnId = dpnTepsInfo.getDPNID();
final String dpnIdStr = dpnId.toString();
LOG.info("DPNTepsInfo Add Received for {}", dpnIdStr);
Collection<TunnelStateInfo> tunnelStateInfoList;
try (Acquired lock = directTunnelUtils.lockTunnel(dpnIdStr)) {
tunnelStateInfoList = unprocessedNodeConnectorEndPointCache.remove(dpnIdStr);
}
if (tunnelStateInfoList != null) {
for (TunnelStateInfo tsInfo : tunnelStateInfoList) {
String interfaceName = tsInfo.getDpnTepInterfaceInfo().getTunnelName();
DPNTEPsInfo srcDpnTepsInfo = null;
DPNTEPsInfo dstDpnTepsInfo = null;
LOG.debug("Processing the Unprocessed NodeConnector EndPoint Cache for DPN {}", dpnTepsInfo.getDPNID());
TunnelEndPointInfo tunnelEndPointInfo = tsInfo.getTunnelEndPointInfo();
if (dpnId.equals(tunnelEndPointInfo.getSrcEndPointInfo())) {
srcDpnTepsInfo = dpnTepsInfo;
dstDpnTepsInfo = tsInfo.getDstDpnTepsInfo();
if (dstDpnTepsInfo == null) {
// Check if the destination End Point has come
final String dstEndpoint = tunnelEndPointInfo.getDstEndPointName();
try (Acquired lock = directTunnelUtils.lockTunnel(dstEndpoint)) {
Optional<DPNTEPsInfo> dstInfoOpt = getDPNTepFromDPNId(tunnelEndPointInfo.getDstEndPointInfo());
if (dstInfoOpt.isPresent()) {
dstDpnTepsInfo = dstInfoOpt.get();
} else {
TunnelStateInfo tunnelStateInfoNew = new TunnelStateInfoBuilder().setNodeConnectorInfo(tsInfo.getNodeConnectorInfo()).setDpnTepInterfaceInfo(tsInfo.getDpnTepInterfaceInfo()).setTunnelEndPointInfo(tsInfo.getTunnelEndPointInfo()).setSrcDpnTepsInfo(srcDpnTepsInfo).build();
LOG.trace("Destination DPNTepsInfo is null for tunnel {}. Hence Parking with key {}", interfaceName, dstEndpoint);
unprocessedNodeConnectorEndPointCache.add(dstEndpoint, tunnelStateInfoNew);
}
}
}
} else if (dpnId.equals(tunnelEndPointInfo.getDstEndPointInfo())) {
dstDpnTepsInfo = dpnTepsInfo;
srcDpnTepsInfo = tsInfo.getSrcDpnTepsInfo();
// Check if the destination End Point has come
if (srcDpnTepsInfo == null) {
final String srcEndpoint = tunnelEndPointInfo.getSrcEndPointName();
try (Acquired lock = directTunnelUtils.lockTunnel(srcEndpoint)) {
Optional<DPNTEPsInfo> srcInfoOpt = getDPNTepFromDPNId(tunnelEndPointInfo.getSrcEndPointInfo());
if (srcInfoOpt.isPresent()) {
srcDpnTepsInfo = srcInfoOpt.get();
} else {
TunnelStateInfo tunnelStateInfoNew = new TunnelStateInfoBuilder().setNodeConnectorInfo(tsInfo.getNodeConnectorInfo()).setDpnTepInterfaceInfo(tsInfo.getDpnTepInterfaceInfo()).setTunnelEndPointInfo(tsInfo.getTunnelEndPointInfo()).setDstDpnTepsInfo(dstDpnTepsInfo).build();
LOG.trace("Source DPNTepsInfo is null for tunnel {}. Hence Parking with key {}", interfaceName, tsInfo.getTunnelEndPointInfo().getSrcEndPointInfo());
unprocessedNodeConnectorEndPointCache.add(srcEndpoint, tunnelStateInfoNew);
}
}
}
}
if (srcDpnTepsInfo != null && dstDpnTepsInfo != null && directTunnelUtils.isEntityOwner()) {
TunnelStateInfo tunnelStateInfoNew = new TunnelStateInfoBuilder().setNodeConnectorInfo(tsInfo.getNodeConnectorInfo()).setDpnTepInterfaceInfo(tsInfo.getDpnTepInterfaceInfo()).setTunnelEndPointInfo(tsInfo.getTunnelEndPointInfo()).setSrcDpnTepsInfo(srcDpnTepsInfo).setDstDpnTepsInfo(dstDpnTepsInfo).build();
LOG.debug("Queueing TunnelStateAddWorker to DJC for tunnel {}", interfaceName);
EVENT_LOGGER.debug("ITM-DpnTepsInfoCache,ADD {}", interfaceName);
coordinator.enqueueJob(interfaceName, new TunnelStateAddWorkerForNodeConnector(new TunnelStateAddWorker(directTunnelUtils, txRunner), tunnelStateInfoNew), ITMConstants.JOB_MAX_RETRIES);
}
}
}
}
use of org.opendaylight.genius.itm.utils.TunnelStateInfoBuilder in project genius by opendaylight.
the class DpnTepStateCache method added.
@Override
protected void added(InstanceIdentifier<DpnsTeps> path, DpnsTeps dpnsTeps) {
String srcOfTunnel = dpnsTeps.getOfTunnel();
for (RemoteDpns remoteDpns : dpnsTeps.nonnullRemoteDpns().values()) {
DpnTepInterfaceInfo value = new DpnTepInterfaceInfoBuilder().setTunnelName(remoteDpns.getTunnelName()).setIsMonitoringEnabled(remoteDpns.isMonitoringEnabled()).setIsInternal(remoteDpns.isInternal()).setTunnelType(dpnsTeps.getTunnelType()).setRemoteDPN(remoteDpns.getDestinationDpnId()).build();
final CacheKey key = new CacheKey(dpnsTeps.getSourceDpnId(), remoteDpns.getDestinationDpnId());
dpnTepInterfaceMap.put(key, value);
addTunnelEndPointInfoToCache(remoteDpns.getTunnelName(), dpnsTeps.getSourceDpnId(), remoteDpns.getDestinationDpnId());
// Process the unprocessed NodeConnector for the Tunnel, if present in the UnprocessedNodeConnectorCache
final String dpn = key.toString();
TunnelStateInfo tunnelStateInfoNew = null;
TunnelStateInfo tunnelStateInfo;
try (Acquired lock = directTunnelUtils.lockTunnel(remoteDpns.getTunnelName())) {
if (srcOfTunnel != null) {
tunnelStateInfo = unprocessedNCCache.remove(dpn);
if (tunnelStateInfo == null) {
tunnelStateInfo = unprocessedNCCache.remove(remoteDpns.getTunnelName());
}
} else {
tunnelStateInfo = unprocessedNCCache.remove(remoteDpns.getTunnelName());
}
}
if (tunnelStateInfo != null) {
LOG.debug("Processing the Unprocessed NodeConnector for Tunnel {}", remoteDpns.getTunnelName());
TunnelEndPointInfo tunnelEndPtInfo = getTunnelEndPointInfo(dpnsTeps.getSourceDpnId(), remoteDpns.getDestinationDpnId());
TunnelStateInfoBuilder builder = new TunnelStateInfoBuilder().setNodeConnectorInfo(tunnelStateInfo.getNodeConnectorInfo()).setDpnTepInterfaceInfo(value).setTunnelEndPointInfo(tunnelEndPtInfo);
dpnTepsInfoCache.getDPNTepFromDPNId(dpnsTeps.getSourceDpnId()).ifPresent(builder::setSrcDpnTepsInfo);
dpnTepsInfoCache.getDPNTepFromDPNId(remoteDpns.getDestinationDpnId()).ifPresent(builder::setDstDpnTepsInfo);
tunnelStateInfoNew = builder.build();
if (tunnelStateInfoNew.getSrcDpnTepsInfo() == null) {
String srcDpnId = tunnelStateInfoNew.getTunnelEndPointInfo().getSrcEndPointName();
try (Acquired lock = directTunnelUtils.lockTunnel(srcDpnId)) {
LOG.debug("Source DPNTepsInfo is null for tunnel {}. Hence Parking with key {}", remoteDpns.getTunnelName(), srcDpnId);
unprocessedNodeConnectorEndPointCache.add(srcDpnId, tunnelStateInfoNew);
}
}
if (tunnelStateInfoNew.getDstDpnTepsInfo() == null) {
String dstDpnId = tunnelStateInfoNew.getTunnelEndPointInfo().getDstEndPointName();
try (Acquired lock = directTunnelUtils.lockTunnel(dstDpnId)) {
LOG.debug("Destination DPNTepsInfo is null for tunnel {}. Hence Parking with key {}", remoteDpns.getTunnelName(), dstDpnId);
unprocessedNodeConnectorEndPointCache.add(dstDpnId, tunnelStateInfoNew);
}
}
}
if (tunnelStateInfoNew != null && tunnelStateInfoNew.getSrcDpnTepsInfo() != null && tunnelStateInfoNew.getDstDpnTepsInfo() != null && directTunnelUtils.isEntityOwner()) {
TunnelStateAddWorkerForNodeConnector ifStateAddWorker = new TunnelStateAddWorkerForNodeConnector(new TunnelStateAddWorker(directTunnelUtils, txRunner), tunnelStateInfoNew);
EVENT_LOGGER.debug("ITM-DpnTepStateCache,ADD {}", remoteDpns.getTunnelName());
coordinator.enqueueJob(remoteDpns.getTunnelName(), ifStateAddWorker, ITMConstants.JOB_MAX_RETRIES);
}
}
}
use of org.opendaylight.genius.itm.utils.TunnelStateInfoBuilder in project genius by opendaylight.
the class TunnelInventoryStateListener method addTunnelState.
private void addTunnelState(NodeConnectorInfo nodeConnectorInfo, String portName) {
TunnelStateInfo tunnelStateInfo = null;
TunnelEndPointInfo tunnelEndPtInfo = null;
try (Acquired lock = directTunnelUtils.lockTunnel(portName)) {
if (!dpnTepStateCache.isConfigAvailable(portName)) {
// Park the notification
LOG.debug("Unable to process the NodeConnector ADD event for {} as Config not available." + "Hence parking it", portName);
unprocessedNCCache.add(portName, new TunnelStateInfoBuilder().setNodeConnectorInfo(nodeConnectorInfo).build());
return;
} else if (!dpnTepStateCache.isInternal(portName)) {
LOG.debug("{} Interface is not a internal tunnel I/f, so no-op", portName);
return;
}
}
// to UP as previously the compute would have disconnected and so the state will be UNKNOWN.
try {
long portNo = tunnelStateCache.getNodeConnectorIdFromInterface(portName);
if (portNo != ITMConstants.INVALID_PORT_NO) {
coordinator.enqueueJob(portName, new TunnelInterfaceNodeReconnectWorker(portName), ITMConstants.JOB_MAX_RETRIES);
return;
}
} catch (ReadFailedException e) {
LOG.error("Exception occurred in reconnect for portName {}, reason: {}.", portName, e.getMessage());
}
if (DirectTunnelUtils.TUNNEL_PORT_PREDICATE.test(portName) && dpnTepStateCache.isInternal(portName)) {
tunnelEndPtInfo = dpnTepStateCache.getTunnelEndPointInfoFromCache(portName);
TunnelStateInfoBuilder builder = new TunnelStateInfoBuilder().setNodeConnectorInfo(nodeConnectorInfo);
dpntePsInfoCache.getDPNTepFromDPNId(tunnelEndPtInfo.getSrcEndPointInfo()).ifPresent(builder::setSrcDpnTepsInfo);
dpntePsInfoCache.getDPNTepFromDPNId(tunnelEndPtInfo.getDstEndPointInfo()).ifPresent(builder::setDstDpnTepsInfo);
tunnelStateInfo = builder.setTunnelEndPointInfo(tunnelEndPtInfo).setDpnTepInterfaceInfo(dpnTepStateCache.getTunnelFromCache(portName)).build();
if (tunnelStateInfo.getSrcDpnTepsInfo() == null) {
final String srcEndpoint = tunnelEndPtInfo.getSrcEndPointName();
try (Acquired lock = directTunnelUtils.lockTunnel(srcEndpoint)) {
LOG.debug("Source DPNTepsInfo is null for tunnel {}. Hence Parking with key {}", portName, tunnelEndPtInfo.getSrcEndPointInfo());
unprocessedNodeConnectorEndPointCache.add(srcEndpoint, tunnelStateInfo);
}
}
if (tunnelStateInfo.getDstDpnTepsInfo() == null) {
final String dstEndpoint = tunnelEndPtInfo.getDstEndPointName();
try (Acquired lock = directTunnelUtils.lockTunnel(dstEndpoint)) {
LOG.debug("Destination DPNTepsInfo is null for tunnel {}. Hence Parking with key {}", portName, tunnelEndPtInfo.getDstEndPointInfo());
unprocessedNodeConnectorEndPointCache.add(dstEndpoint, tunnelStateInfo);
}
}
}
if (tunnelEndPtInfo != null && tunnelStateInfo.getSrcDpnTepsInfo() != null && tunnelStateInfo.getDstDpnTepsInfo() != null) {
EVENT_LOGGER.debug("ITM-TunnelInventoryState Entity Owner,ADD {}", portName);
coordinator.enqueueJob(portName, new TunnelStateAddWorkerForNodeConnector(new TunnelStateAddWorker(directTunnelUtils, txRunner), tunnelStateInfo), ITMConstants.JOB_MAX_RETRIES);
}
}
Aggregations