+
+ @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());
+ }