Search in sources :

Example 6 with MonitorProfileCreateOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateOutput 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

MonitorProfileCreateOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateOutput)6 MonitorProfileBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfileBuilder)4 MonitorProfileCreateInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateInput)3 MonitorProfileCreateInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateInputBuilder)3 Profile (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profile.create.input.Profile)3 ProfileBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profile.create.input.ProfileBuilder)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 Optional (com.google.common.base.Optional)2 ExecutionException (java.util.concurrent.ExecutionException)2 Test (org.junit.Test)2 MonitorProfileGetOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutput)2 MonitorProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfile)2 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 EtherTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.EtherTypes)1 MonitorProfileCreateOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateOutputBuilder)1 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)1