use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profile.create.input.Profile in project genius by opendaylight.
the class AlivenessMonitorTest method testMonitorProfileDelete.
@Test
public void testMonitorProfileDelete() throws InterruptedException, ExecutionException {
MonitorProfileDeleteInput input = new MonitorProfileDeleteInputBuilder().setProfileId(1L).build();
Optional<MonitorProfile> optProfile = Optional.of(getTestMonitorProfile());
when(readWriteTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitorProfile.class)))).thenReturn(Futures.immediateCheckedFuture(optProfile));
RpcResult<Void> result = alivenessMonitor.monitorProfileDelete(input).get();
verify(idManager).releaseId(any(ReleaseIdInput.class));
verify(readWriteTx).delete(eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<MonitorProfile>>any());
assertTrue("Monitor profile delete result", result.isSuccessful());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profile.create.input.Profile in project genius by opendaylight.
the class AlivenessMonitorUtils method createMonitorProfile.
public long createMonitorProfile(MonitorProfileCreateInput monitorProfileCreateInput) {
try {
Future<RpcResult<MonitorProfileCreateOutput>> result = alivenessMonitorService.monitorProfileCreate(monitorProfileCreateInput);
RpcResult<MonitorProfileCreateOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
return rpcResult.getResult().getProfileId();
} else {
LOG.warn("RPC Call to Get Profile Id Id returned with Errors {}.. Trying to fetch existing profile ID", rpcResult.getErrors());
Profile createProfile = monitorProfileCreateInput.getProfile();
Future<RpcResult<MonitorProfileGetOutput>> existingProfile = alivenessMonitorService.monitorProfileGet(buildMonitorGetProfile(createProfile.getMonitorInterval(), createProfile.getMonitorWindow(), createProfile.getFailureThreshold(), createProfile.getProtocolType()));
RpcResult<MonitorProfileGetOutput> rpcGetResult = existingProfile.get();
if (rpcGetResult.isSuccessful()) {
return rpcGetResult.getResult().getProfileId();
} else {
LOG.warn("RPC Call to Get Existing Profile Id returned with Errors {}", rpcGetResult.getErrors());
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when allocating profile Id", e);
}
return 0;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profile.create.input.Profile in project genius by opendaylight.
the class AlivenessMonitorUtils method handleTunnelMonitorUpdates.
public void handleTunnelMonitorUpdates(Interface interfaceOld, Interface interfaceNew) {
String interfaceName = interfaceNew.getName();
IfTunnel ifTunnelNew = interfaceNew.getAugmentation(IfTunnel.class);
if (!lldpMonitoringEnabled(ifTunnelNew)) {
return;
}
LOG.debug("handling tunnel monitoring updates for interface {}", interfaceName);
stopLLDPMonitoring(ifTunnelNew, interfaceOld.getName());
if (ifTunnelNew.isMonitorEnabled()) {
startLLDPMonitoring(ifTunnelNew, interfaceName);
// Delete old profile from Aliveness Manager
IfTunnel ifTunnelOld = interfaceOld.getAugmentation(IfTunnel.class);
if (!ifTunnelNew.getMonitorInterval().equals(ifTunnelOld.getMonitorInterval())) {
LOG.debug("deleting older monitor profile for interface {}", interfaceName);
long profileId = allocateProfile(FAILURE_THRESHOLD, ifTunnelOld.getMonitorInterval(), MONITORING_WINDOW, EtherTypes.Lldp);
MonitorProfileDeleteInput profileDeleteInput = new MonitorProfileDeleteInputBuilder().setProfileId(profileId).build();
Future<RpcResult<Void>> future = alivenessMonitorService.monitorProfileDelete(profileDeleteInput);
ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(future), LOG, "Delete monitor profile {}", interfaceName);
}
}
}
Aggregations