Search in sources :

Example 86 with Errors

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors 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

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)45 ExecutionException (java.util.concurrent.ExecutionException)38 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)15 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)11 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)10 Errors (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors)10 ByteBuf (io.netty.buffer.ByteBuf)9 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)9 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)9 AllocateIdOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)9 ReleaseIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput)9 ReleaseIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder)9 ErrorsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder)9 PCEPErrors (org.opendaylight.protocol.pcep.spi.PCEPErrors)8 Rp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp)7 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)6 ErrorObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject)6 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 Preconditions (com.google.common.base.Preconditions)4