use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInputBuilder in project netvirt by opendaylight.
the class AlivenessMonitorUtils method stopArpMonitoring.
public static void stopArpMonitoring(AlivenessMonitorService alivenessMonitorService, Long monitorId) {
MonitorStopInput input = new MonitorStopInputBuilder().setMonitorId(monitorId).build();
JdkFutures.addErrorLogging(alivenessMonitorService.monitorStop(input), LOG, "Stop monitoring");
alivenessCache.remove(monitorId);
return;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInputBuilder in project genius by opendaylight.
the class AlivenessMonitorTest method testMonitorStop.
@Test
public void testMonitorStop() throws InterruptedException, ExecutionException {
MonitorStopInput input = new MonitorStopInputBuilder().setMonitorId(2L).build();
Optional<MonitoringInfo> optInfo = Optional.of(new MonitoringInfoBuilder().setSource(new SourceBuilder().setEndpointType(getInterface("testInterface", "10.1.1.1")).build()).build());
CheckedFuture<Optional<MonitoringInfo>, ReadFailedException> outFuture = Futures.immediateCheckedFuture(optInfo);
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitoringInfo.class)))).thenReturn(outFuture);
Optional<MonitoridKeyEntry> optMap = Optional.of(new MonitoridKeyEntryBuilder().setMonitorId(2L).setMonitorKey("Test monitor Key").build());
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitoridKeyEntry.class)))).thenReturn(Futures.immediateCheckedFuture(optMap));
Optional<MonitorProfile> optProfile = Optional.of(getTestMonitorProfile());
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitorProfile.class)))).thenReturn(Futures.immediateCheckedFuture(optProfile));
Optional<InterfaceMonitorEntry> optEntry = Optional.of(getInterfaceMonitorEntry());
when(readWriteTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(InterfaceMonitorEntry.class)))).thenReturn(Futures.immediateCheckedFuture(optEntry));
RpcResult<Void> result = alivenessMonitor.monitorStop(input).get();
verify(idManager).releaseId(any(ReleaseIdInput.class));
verify(writeTx, times(2)).delete(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class));
assertTrue("Monitor stop rpc result", result.isSuccessful());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInputBuilder 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);
}
Aggregations