Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.ospf.controller.impl; |
| 17 | |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 18 | import org.jboss.netty.bootstrap.ClientBootstrap; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 19 | import org.jboss.netty.channel.AdaptiveReceiveBufferSizePredictor; |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 20 | import org.jboss.netty.channel.ChannelFuture; |
| 21 | import org.jboss.netty.channel.ChannelFutureListener; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 22 | import org.jboss.netty.channel.ChannelPipelineFactory; |
| 23 | import org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory; |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 24 | import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; |
| 25 | import org.onlab.packet.Ip4Address; |
| 26 | import org.onlab.packet.TpPort; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 27 | import org.onosproject.net.driver.DriverService; |
| 28 | import org.onosproject.ospf.controller.OspfAgent; |
| 29 | import org.onosproject.ospf.controller.OspfArea; |
| 30 | import org.onosproject.ospf.controller.OspfInterface; |
| 31 | import org.onosproject.ospf.controller.OspfLinkTed; |
| 32 | import org.onosproject.ospf.controller.OspfProcess; |
| 33 | import org.onosproject.ospf.controller.OspfRouter; |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 34 | import org.onosproject.ospf.protocol.util.OspfUtil; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 35 | import org.slf4j.Logger; |
| 36 | import org.slf4j.LoggerFactory; |
| 37 | |
| 38 | import java.net.InetAddress; |
| 39 | import java.net.InetSocketAddress; |
| 40 | import java.net.NetworkInterface; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 41 | import java.util.Enumeration; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 42 | import java.util.List; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 43 | import java.util.concurrent.Executors; |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 44 | import java.util.concurrent.ScheduledExecutorService; |
| 45 | import java.util.concurrent.TimeUnit; |
| 46 | |
| 47 | import static org.onlab.util.Tools.groupedThreads; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 48 | |
| 49 | /** |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 50 | * Representation of an OSPF controller. |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 51 | */ |
| 52 | public class Controller { |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 53 | protected static final int BUFFER_SIZE = 4 * 1024 * 1024; |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 54 | private static final Logger log = LoggerFactory.getLogger(Controller.class); |
| 55 | private static final int RETRY_INTERVAL = 4; |
| 56 | private final int peerWorkerThreads = 16; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 57 | protected long systemStartTime; |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 58 | byte[] configPacket = null; |
| 59 | private List<OspfProcess> processes = null; |
| 60 | private OspfInterfaceChannelHandler ospfChannelHandler; |
| 61 | private NioClientSocketChannelFactory peerExecFactory; |
| 62 | private ClientBootstrap peerBootstrap = null; |
sangyun-han | 53ee58a | 2017-01-05 16:34:02 +0900 | [diff] [blame] | 63 | private TpPort ospfPort = TpPort.tpPort(OspfUtil.SPORT); |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 64 | private ScheduledExecutorService connectExecutor = null; |
| 65 | private int connectRetryCounter = 0; |
| 66 | private int connectRetryTime; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 67 | private DriverService driverService; |
| 68 | private OspfAgent agent; |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * Deactivates OSPF controller. |
| 72 | */ |
sangyun-han | 53ee58a | 2017-01-05 16:34:02 +0900 | [diff] [blame] | 73 | public void ospfDeactivate() { |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 74 | peerExecFactory.shutdown(); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Updates the processes configuration. |
| 79 | * |
| 80 | * @param ospfProcesses list of OSPF process instances |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 81 | */ |
Ray Milkey | 019fba4 | 2018-01-31 14:07:47 -0800 | [diff] [blame^] | 82 | public void updateConfig(List<OspfProcess> ospfProcesses) { |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 83 | log.debug("Controller::UpdateConfig called"); |
| 84 | configPacket = new byte[OspfUtil.CONFIG_LENGTH]; |
| 85 | byte numberOfInterface = 0; // number of interfaces to configure |
| 86 | configPacket[0] = (byte) 0xFF; // its a conf packet - identifier |
| 87 | for (OspfProcess ospfProcess : ospfProcesses) { |
| 88 | log.debug("OspfProcessDetails : " + ospfProcess); |
| 89 | for (OspfArea ospfArea : ospfProcess.areas()) { |
| 90 | for (OspfInterface ospfInterface : ospfArea.ospfInterfaceList()) { |
| 91 | log.debug("OspfInterfaceDetails : " + ospfInterface); |
| 92 | numberOfInterface++; |
| 93 | configPacket[2 * numberOfInterface] = (byte) ospfInterface.interfaceIndex(); |
| 94 | configPacket[(2 * numberOfInterface) + 1] = (byte) 4; |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | configPacket[1] = numberOfInterface; |
| 99 | //First time configuration |
| 100 | if (processes == null) { |
| 101 | if (ospfProcesses.size() > 0) { |
| 102 | processes = ospfProcesses; |
| 103 | connectPeer(); |
| 104 | } |
| 105 | } else { |
| 106 | ospfChannelHandler.updateInterfaceMap(ospfProcesses); |
| 107 | //Send the config packet |
| 108 | ospfChannelHandler.sentConfigPacket(configPacket); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Initializes the netty client channel connection. |
| 114 | */ |
| 115 | private void initConnection() { |
| 116 | if (peerBootstrap != null) { |
| 117 | return; |
| 118 | } |
| 119 | peerBootstrap = createPeerBootStrap(); |
| 120 | |
| 121 | peerBootstrap.setOption("reuseAddress", true); |
| 122 | peerBootstrap.setOption("tcpNoDelay", true); |
| 123 | peerBootstrap.setOption("keepAlive", true); |
| 124 | peerBootstrap.setOption("receiveBufferSize", Controller.BUFFER_SIZE); |
| 125 | peerBootstrap.setOption("receiveBufferSizePredictorFactory", |
| 126 | new FixedReceiveBufferSizePredictorFactory( |
| 127 | Controller.BUFFER_SIZE)); |
| 128 | peerBootstrap.setOption("receiveBufferSizePredictor", |
| 129 | new AdaptiveReceiveBufferSizePredictor(64, 4096, 65536)); |
| 130 | peerBootstrap.setOption("child.keepAlive", true); |
| 131 | peerBootstrap.setOption("child.tcpNoDelay", true); |
| 132 | peerBootstrap.setOption("child.sendBufferSize", Controller.BUFFER_SIZE); |
| 133 | peerBootstrap.setOption("child.receiveBufferSize", Controller.BUFFER_SIZE); |
| 134 | peerBootstrap.setOption("child.receiveBufferSizePredictorFactory", |
| 135 | new FixedReceiveBufferSizePredictorFactory( |
| 136 | Controller.BUFFER_SIZE)); |
| 137 | peerBootstrap.setOption("child.reuseAddress", true); |
| 138 | |
| 139 | ospfChannelHandler = new OspfInterfaceChannelHandler(this, processes); |
| 140 | ChannelPipelineFactory pfact = new OspfPipelineFactory(ospfChannelHandler); |
| 141 | peerBootstrap.setPipelineFactory(pfact); |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Creates peer boot strap. |
| 146 | * |
| 147 | * @return client bootstrap instance |
| 148 | */ |
| 149 | private ClientBootstrap createPeerBootStrap() { |
| 150 | |
| 151 | if (peerWorkerThreads == 0) { |
| 152 | peerExecFactory = new NioClientSocketChannelFactory( |
sangyun-han | 53ee58a | 2017-01-05 16:34:02 +0900 | [diff] [blame] | 153 | Executors.newCachedThreadPool(groupedThreads("onos/ospf", "boss-%d")), |
| 154 | Executors.newCachedThreadPool(groupedThreads("onos/ospf", "worker-%d"))); |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 155 | return new ClientBootstrap(peerExecFactory); |
| 156 | } else { |
| 157 | peerExecFactory = new NioClientSocketChannelFactory( |
sangyun-han | 53ee58a | 2017-01-05 16:34:02 +0900 | [diff] [blame] | 158 | Executors.newCachedThreadPool(groupedThreads("onos/ospf", "boss-%d")), |
| 159 | Executors.newCachedThreadPool(groupedThreads("onos/ospf", "worker-%d")), |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 160 | peerWorkerThreads); |
| 161 | return new ClientBootstrap(peerExecFactory); |
| 162 | } |
| 163 | } |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 164 | |
| 165 | /** |
| 166 | * Gets all configured processes. |
| 167 | * |
| 168 | * @return all configured processes |
| 169 | */ |
| 170 | public List<OspfProcess> getAllConfiguredProcesses() { |
| 171 | return processes; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Adds device details. |
| 176 | * |
| 177 | * @param ospfRouter OSPF router instance |
| 178 | */ |
| 179 | public void addDeviceDetails(OspfRouter ospfRouter) { |
| 180 | agent.addConnectedRouter(ospfRouter); |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * Removes device details. |
| 185 | * |
| 186 | * @param ospfRouter OSPF router instance |
| 187 | */ |
| 188 | public void removeDeviceDetails(OspfRouter ospfRouter) { |
| 189 | agent.removeConnectedRouter(ospfRouter); |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Adds link details. |
| 194 | * |
| 195 | * @param ospfRouter OSPF router instance |
| 196 | * @param ospfLinkTed OSPF link ted instance |
| 197 | */ |
| 198 | public void addLinkDetails(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) { |
| 199 | agent.addLink(ospfRouter, ospfLinkTed); |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Removes link details. |
| 204 | * |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 205 | * @param ospfRouter OSPF router instance |
| 206 | * @param ospfLinkTed OSPF link ted instance |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 207 | */ |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 208 | public void removeLinkDetails(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) { |
| 209 | agent.deleteLink(ospfRouter, ospfLinkTed); |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | /** |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 213 | * Initializes internal data structures. |
| 214 | */ |
| 215 | public void init() { |
| 216 | this.systemStartTime = System.currentTimeMillis(); |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Starts the controller. |
| 221 | * |
| 222 | * @param ag OSPF agent instance |
| 223 | * @param driverService driver service instance |
| 224 | */ |
| 225 | public void start(OspfAgent ag, DriverService driverService) { |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 226 | log.info("Starting OSPF controller...!!!"); |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 227 | this.agent = ag; |
| 228 | this.driverService = driverService; |
| 229 | this.init(); |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Stops the Controller. |
| 234 | */ |
| 235 | public void stop() { |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 236 | log.info("Stopping OSPF controller...!!!"); |
sangyun-han | 53ee58a | 2017-01-05 16:34:02 +0900 | [diff] [blame] | 237 | ospfDeactivate(); |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 238 | processes.clear(); |
| 239 | } |
| 240 | |
| 241 | /** |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 242 | * Returns interface IP by index. |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 243 | * |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 244 | * @param interfaceIndex interface index |
| 245 | * @return interface IP by index |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 246 | */ |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 247 | private Ip4Address getInterfaceIp(int interfaceIndex) { |
| 248 | Ip4Address ipAddress = null; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 249 | try { |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 250 | NetworkInterface networkInterface = NetworkInterface.getByIndex(interfaceIndex); |
| 251 | Enumeration ipAddresses = networkInterface.getInetAddresses(); |
| 252 | while (ipAddresses.hasMoreElements()) { |
| 253 | InetAddress address = (InetAddress) ipAddresses.nextElement(); |
| 254 | if (!address.isLinkLocalAddress()) { |
| 255 | ipAddress = Ip4Address.valueOf(address.getAddress()); |
| 256 | break; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 257 | } |
| 258 | } |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 259 | } catch (Exception e) { |
| 260 | log.debug("Error while getting Interface IP by index"); |
| 261 | return OspfUtil.DEFAULTIP; |
| 262 | } |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 263 | |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 264 | return ipAddress; |
| 265 | } |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 266 | |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 267 | /** |
| 268 | * Returns interface mask by index. |
| 269 | * |
| 270 | * @param interfaceIndex interface index |
| 271 | * @return interface IP by index |
| 272 | */ |
| 273 | private String getInterfaceMask(int interfaceIndex) { |
| 274 | String subnetMask = null; |
| 275 | try { |
| 276 | Ip4Address ipAddress = getInterfaceIp(interfaceIndex); |
| 277 | NetworkInterface networkInterface = NetworkInterface.getByInetAddress( |
| 278 | InetAddress.getByName(ipAddress.toString())); |
| 279 | Enumeration ipAddresses = networkInterface.getInetAddresses(); |
| 280 | int index = 0; |
| 281 | while (ipAddresses.hasMoreElements()) { |
| 282 | InetAddress address = (InetAddress) ipAddresses.nextElement(); |
| 283 | if (!address.isLinkLocalAddress()) { |
| 284 | break; |
| 285 | } |
| 286 | index++; |
| 287 | } |
| 288 | int prfLen = networkInterface.getInterfaceAddresses().get(index).getNetworkPrefixLength(); |
| 289 | int shft = 0xffffffff << (32 - prfLen); |
| 290 | int oct1 = ((byte) ((shft & 0xff000000) >> 24)) & 0xff; |
| 291 | int oct2 = ((byte) ((shft & 0x00ff0000) >> 16)) & 0xff; |
| 292 | int oct3 = ((byte) ((shft & 0x0000ff00) >> 8)) & 0xff; |
| 293 | int oct4 = ((byte) (shft & 0x000000ff)) & 0xff; |
| 294 | subnetMask = oct1 + "." + oct2 + "." + oct3 + "." + oct4; |
| 295 | } catch (Exception e) { |
| 296 | log.debug("Error while getting Interface network mask by index"); |
| 297 | return subnetMask; |
| 298 | } |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 299 | |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 300 | return subnetMask; |
| 301 | } |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 302 | |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 303 | /** |
| 304 | * Disconnects the executor. |
| 305 | */ |
| 306 | public void disconnectExecutor() { |
| 307 | if (connectExecutor != null) { |
| 308 | connectExecutor.shutdown(); |
| 309 | connectExecutor = null; |
| 310 | } |
| 311 | } |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 312 | |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 313 | /** |
| 314 | * Connects to peer. |
| 315 | */ |
| 316 | public void connectPeer() { |
| 317 | scheduleConnectionRetry(this.connectRetryTime); |
| 318 | } |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 319 | |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 320 | /** |
| 321 | * Retry connection with exponential back-off mechanism. |
| 322 | * |
| 323 | * @param retryDelay retry delay |
| 324 | */ |
| 325 | private void scheduleConnectionRetry(long retryDelay) { |
| 326 | if (this.connectExecutor == null) { |
| 327 | this.connectExecutor = Executors.newSingleThreadScheduledExecutor(); |
| 328 | } |
| 329 | this.connectExecutor.schedule(new ConnectionRetry(), retryDelay, TimeUnit.MINUTES); |
| 330 | } |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 331 | |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 332 | /** |
sangyun-han | 53ee58a | 2017-01-05 16:34:02 +0900 | [diff] [blame] | 333 | * Implements OSPF connection and manages connection to peer with back-off mechanism in case of failure. |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 334 | */ |
| 335 | class ConnectionRetry implements Runnable { |
| 336 | @Override |
| 337 | public void run() { |
| 338 | log.debug("Connect to peer {}", OspfUtil.SHOST); |
| 339 | initConnection(); |
| 340 | ospfChannelHandler.sentConfigPacket(configPacket); |
sangyun-han | 53ee58a | 2017-01-05 16:34:02 +0900 | [diff] [blame] | 341 | InetSocketAddress connectToSocket = new InetSocketAddress(OspfUtil.SHOST, ospfPort.toInt()); |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 342 | try { |
| 343 | peerBootstrap.connect(connectToSocket).addListener(new ChannelFutureListener() { |
| 344 | @Override |
Ray Milkey | 019fba4 | 2018-01-31 14:07:47 -0800 | [diff] [blame^] | 345 | public void operationComplete(ChannelFuture future) { |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 346 | if (!future.isSuccess()) { |
| 347 | connectRetryCounter++; |
| 348 | log.error("Connection failed, ConnectRetryCounter {} remote host {}", connectRetryCounter, |
| 349 | OspfUtil.SHOST); |
| 350 | /* |
| 351 | * Reconnect to peer on failure is exponential till 4 mins, later on retry after every 4 |
| 352 | * mins. |
| 353 | */ |
| 354 | if (connectRetryTime < RETRY_INTERVAL) { |
| 355 | connectRetryTime = (connectRetryTime != 0) ? connectRetryTime * 2 : 1; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 356 | } |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 357 | scheduleConnectionRetry(connectRetryTime); |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 358 | } else { |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 359 | //Send the config packet |
| 360 | ospfChannelHandler.sentConfigPacket(configPacket); |
| 361 | connectRetryCounter++; |
| 362 | log.info("Connected to remote host {}, Connect Counter {}", OspfUtil.SHOST, |
| 363 | connectRetryCounter); |
| 364 | disconnectExecutor(); |
| 365 | |
| 366 | return; |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 367 | } |
| 368 | } |
sunishvk | f7c5655 | 2016-07-18 16:02:39 +0530 | [diff] [blame] | 369 | }); |
| 370 | } catch (Exception e) { |
| 371 | log.info("Connect peer exception : " + e.toString()); |
| 372 | disconnectExecutor(); |
Kalyankumar Asangi | 27728f2 | 2016-02-17 15:46:28 +0530 | [diff] [blame] | 373 | } |
| 374 | } |
| 375 | } |
| 376 | } |