use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutput in project genius by opendaylight.
the class AlivenessMonitor method monitorProfileGet.
@Override
public Future<RpcResult<MonitorProfileGetOutput>> monitorProfileGet(MonitorProfileGetInput input) {
LOG.debug("Monitor Profile Get operation for input profile- {}", input.getProfile());
RpcResultBuilder<MonitorProfileGetOutput> rpcResultBuilder;
final Long profileId = getExistingProfileId(input);
MonitorProfileGetOutputBuilder output = new MonitorProfileGetOutputBuilder().setProfileId(profileId);
rpcResultBuilder = RpcResultBuilder.success();
rpcResultBuilder.withResult(output.build());
return Futures.immediateFuture(rpcResultBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutput in project netvirt by opendaylight.
the class AlivenessMonitorUtils method createMonitorProfile.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public static Optional<Long> createMonitorProfile(AlivenessMonitorService alivenessMonitor, MonitorProfileCreateInput monitorProfileCreateInput) {
try {
Future<RpcResult<MonitorProfileCreateOutput>> result = alivenessMonitor.monitorProfileCreate(monitorProfileCreateInput);
RpcResult<MonitorProfileCreateOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
return Optional.of(rpcResult.getResult().getProfileId());
} else {
LOG.warn("RPC Call to Get Profile Id Id returned with Errors {}.. Trying to fetch existing profile ID", rpcResult.getErrors());
try {
Profile createProfile = monitorProfileCreateInput.getProfile();
Future<RpcResult<MonitorProfileGetOutput>> existingProfile = alivenessMonitor.monitorProfileGet(buildMonitorGetProfile(createProfile.getMonitorInterval(), createProfile.getMonitorWindow(), createProfile.getFailureThreshold(), createProfile.getProtocolType()));
RpcResult<MonitorProfileGetOutput> rpcGetResult = existingProfile.get();
if (rpcGetResult.isSuccessful()) {
return Optional.of(rpcGetResult.getResult().getProfileId());
} else {
LOG.warn("RPC Call to Get Existing Profile Id returned with Errors {}", rpcGetResult.getErrors());
}
} catch (Exception e) {
LOG.warn("Exception when getting existing profile", e);
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when allocating profile Id", e);
}
return Optional.absent();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutput 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;
}
Aggregations