Search in sources :

Example 1 with InitiateEorOutput

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.InitiateEorOutput in project netvirt by opendaylight.

the class BgpConfigurationManager method initiateEor.

// private method extractMd5Secret
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public ListenableFuture<RpcResult<InitiateEorOutput>> initiateEor(InitiateEorInput input) {
    boolean returnError = false;
    String msg = null;
    String neighborIp = null;
    if (!isBGPEntityOwner()) {
        msg = String.format("RPC triggered in Non-EoS Owner");
        return Futures.immediateFuture(RpcResultBuilder.<InitiateEorOutput>failed().withError(RpcError.ErrorType.APPLICATION, msg).build());
    }
    if (input == null) {
        msg = String.format("BGP invalid input for EoR");
        LOG.error("Error : {}", msg);
        returnError = true;
    } else {
        neighborIp = input.getNeighborIp();
    }
    if (eorSupressedDuetoUpgradeFlag.get() == false) {
        msg = String.format("EoR triggerd by RBU-RPC call before replay" + "of BGP configuration (or) BGP not restarted");
        LOG.error("Error : {}", msg);
    }
    if ("ALL".compareToIgnoreCase(neighborIp) == 0) {
        // send EoR for all the neighbor
        LOG.error("EoR trigger received to ALL neighbors");
        final int numberOfEORRetries = 3;
        RetryOnException eorRetry = new RetryOnException(numberOfEORRetries);
        do {
            try {
                BgpRouter br = bgpRouter;
                br.sendEOR();
                LOG.debug("RPC: sendEOR {} successful", br);
                break;
            } catch (Exception e) {
                eorRetry.errorOccured();
                LOG.error("Replay:sedEOR() received exception:", e);
            }
        } while (eorRetry.shouldRetry());
        eorSupressedDuetoUpgradeFlag.set(false);
    } else if (InetAddresses.isInetAddress(neighborIp)) {
        // send EoR for only one neighbor
        msg = String.format("Inidividual neighbors EoR is not supported");
        LOG.warn("Error : {}", msg);
        returnError = true;
    } else {
        // error
        msg = String.format("RPC: initiateEor: Invalid input ");
        LOG.warn("Error : {}", msg);
        returnError = true;
    }
    if (returnError) {
        return Futures.immediateFuture(RpcResultBuilder.<InitiateEorOutput>failed().withError(RpcError.ErrorType.APPLICATION, msg).build());
    }
    InitiateEorOutput initiateEorOutput = new InitiateEorOutputBuilder().setRetVal(0L).build();
    return Futures.immediateFuture(RpcResultBuilder.<InitiateEorOutput>success().withResult(initiateEorOutput).build());
}
Also used : InitiateEorOutput(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.InitiateEorOutput) InitiateEorOutputBuilder(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.InitiateEorOutputBuilder) BgpRouter(org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouter) InvocationTargetException(java.lang.reflect.InvocationTargetException) SocketException(java.net.SocketException) TException(org.apache.thrift.TException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) BgpRouterException(org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException) CandidateAlreadyRegisteredException(org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException) TApplicationException(org.apache.thrift.TApplicationException) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SocketException (java.net.SocketException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 TApplicationException (org.apache.thrift.TApplicationException)1 TException (org.apache.thrift.TException)1 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)1 CandidateAlreadyRegisteredException (org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException)1 BgpRouter (org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouter)1 BgpRouterException (org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException)1 InitiateEorOutput (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.InitiateEorOutput)1 InitiateEorOutputBuilder (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.InitiateEorOutputBuilder)1