use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project genius by opendaylight.
the class AlivenessMonitorUtils method removeMonitorIdFromInterfaceMonitorIdMap.
private void removeMonitorIdFromInterfaceMonitorIdMap(ReadWriteTransaction tx, String infName, long monitorId) throws ReadFailedException {
InstanceIdentifier<InterfaceMonitorId> id = InstanceIdentifier.builder(InterfaceMonitorIdMap.class).child(InterfaceMonitorId.class, new InterfaceMonitorIdKey(infName)).build();
Optional<InterfaceMonitorId> interfaceMonitorIdMap = tx.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet();
if (interfaceMonitorIdMap.isPresent()) {
InterfaceMonitorId interfaceMonitorIdInstance = interfaceMonitorIdMap.get();
List<Long> existingMonitorIds = interfaceMonitorIdInstance.getMonitorId();
if (existingMonitorIds != null && existingMonitorIds.contains(monitorId)) {
existingMonitorIds.remove(monitorId);
InterfaceMonitorIdBuilder interfaceMonitorIdBuilder = new InterfaceMonitorIdBuilder();
interfaceMonitorIdInstance = interfaceMonitorIdBuilder.setKey(new InterfaceMonitorIdKey(infName)).setMonitorId(existingMonitorIds).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, id, interfaceMonitorIdInstance, WriteTransaction.CREATE_MISSING_PARENTS);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project genius by opendaylight.
the class AlivenessMonitorUtils method stopLLDPMonitoring.
public void stopLLDPMonitoring(IfTunnel ifTunnel, String trunkInterface) {
if (!lldpMonitoringEnabled(ifTunnel)) {
return;
}
LOG.debug("stop LLDP monitoring for {}", trunkInterface);
ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
List<Long> monitorIds = getMonitorIdForInterface(tx, trunkInterface);
if (monitorIds == null) {
LOG.error("Monitor Id doesn't exist for Interface {}", trunkInterface);
return;
}
for (Long monitorId : monitorIds) {
String interfaceName = getInterfaceFromMonitorId(tx, monitorId);
if (interfaceName != null) {
MonitorStopInput input = new MonitorStopInputBuilder().setMonitorId(monitorId).build();
Future<RpcResult<Void>> future = alivenessMonitorService.monitorStop(input);
ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(future), LOG, "Stop LLDP monitoring for {}", trunkInterface);
removeMonitorIdInterfaceMap(tx, monitorId);
removeMonitorIdFromInterfaceMonitorIdMap(tx, interfaceName, monitorId);
return;
}
}
}), LOG, "Error stopping LLDP monitoring for {}", trunkInterface);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project genius by opendaylight.
the class AlivenessMonitorUtils method createOrUpdateMonitorIdInterfaceMap.
private static void createOrUpdateMonitorIdInterfaceMap(ReadWriteTransaction tx, String infName, long monitorId) throws ReadFailedException {
MonitorIdInterface monitorIdInterfaceInstance;
String existinginterfaceName;
MonitorIdInterfaceBuilder monitorIdInterfaceBuilder = new MonitorIdInterfaceBuilder();
InstanceIdentifier<MonitorIdInterface> id = InstanceIdentifier.builder(MonitorIdInterfaceMap.class).child(MonitorIdInterface.class, new MonitorIdInterfaceKey(monitorId)).build();
Optional<MonitorIdInterface> monitorIdInterfaceMap = tx.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet();
if (monitorIdInterfaceMap.isPresent()) {
monitorIdInterfaceInstance = monitorIdInterfaceMap.get();
existinginterfaceName = monitorIdInterfaceInstance.getInterfaceName();
if (!existinginterfaceName.equals(infName)) {
monitorIdInterfaceInstance = monitorIdInterfaceBuilder.setKey(new MonitorIdInterfaceKey(monitorId)).setInterfaceName(infName).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, id, monitorIdInterfaceInstance, WriteTransaction.CREATE_MISSING_PARENTS);
}
} else {
monitorIdInterfaceInstance = monitorIdInterfaceBuilder.setMonitorId(monitorId).setKey(new MonitorIdInterfaceKey(monitorId)).setInterfaceName(infName).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, id, monitorIdInterfaceInstance, WriteTransaction.CREATE_MISSING_PARENTS);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project netvirt by opendaylight.
the class IpMonitorStopTask method call.
@Override
public List<ListenableFuture<Void>> call() {
final List<ListenableFuture<Void>> futures = new ArrayList<>();
java.util.Optional<Uint32> monitorIdOptional = alivenessMonitorUtils.getMonitorIdFromInterface(macEntry);
if (monitorIdOptional.isPresent()) {
alivenessMonitorUtils.stopIpMonitoring(monitorIdOptional.get());
} else {
LOG.warn("MonitorId not available for IP {} interface {}. IpMonitoring not stopped", macEntry.getIpAddress(), macEntry.getInterfaceName());
}
String learntIp = macEntry.getIpAddress().getHostAddress();
if (this.isRemoveMipAdjAndLearntIp) {
String vpnName = macEntry.getVpnName();
LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
if (vpnVipToPort != null && !Objects.equals(vpnVipToPort.getCreationTime(), macEntry.getCreatedTime())) {
LOG.warn("The MIP {} over vpn {} has been learnt again and processed. " + "Ignoring this remove event.", learntIp, vpnName);
return futures;
}
vpnUtil.removeLearntVpnVipToPort(macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
vpnUtil.removeVpnPortFixedIpToPort(dataBroker, macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> vpnUtil.removeMipAdjacency(macEntry.getVpnName(), macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), tx)), LOG, "ArpMonitorStopTask: Error writing to datastore for Vpn {} IP {}", macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress());
} else {
// Delete only MIP adjacency
vpnUtil.removeMipAdjacency(macEntry.getInterfaceName(), learntIp);
}
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project bgpcep by opendaylight.
the class BmpMonitorImplTest method deploySecondInstance.
@Test
public void deploySecondInstance() throws Exception {
final BmpMonitoringStation monitoringStation2 = new BmpMonitoringStationImpl(getDomBroker(), dispatcher, ribExtension, mappingService.currentSerializer(), clusterSSProv2, new MonitorId("monitor2"), new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS_2), MONITOR_LOCAL_PORT), null);
readDataOperational(getDataBroker(), BMP_II, monitor -> {
assertEquals(2, monitor.nonnullMonitor().size());
return monitor;
});
monitoringStation2.close();
}
Aggregations