Search in sources :

Example 1 with MonitorProfileGetOutput

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());
}
Also used : MonitorProfileGetOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutputBuilder) MonitorProfileGetOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutput)

Example 2 with MonitorProfileGetOutput

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();
}
Also used : MonitorProfileCreateOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MonitorProfileGetOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutput) ExecutionException(java.util.concurrent.ExecutionException) Profile(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profile.create.input.Profile) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with MonitorProfileGetOutput

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;
}
Also used : MonitorProfileCreateOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MonitorProfileGetOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutput) ExecutionException(java.util.concurrent.ExecutionException) Profile(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profile.create.input.Profile)

Aggregations

MonitorProfileGetOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutput)3 ExecutionException (java.util.concurrent.ExecutionException)2 MonitorProfileCreateOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateOutput)2 Profile (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profile.create.input.Profile)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 MonitorProfileGetOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutputBuilder)1