File tree Expand file tree Collapse file tree 2 files changed +38
-15
lines changed
lldpcommon/src/main/java/org/onosproject/provider/lldpcommon
lldp/src/main/java/org/onosproject/provider/lldp/impl Expand file tree Collapse file tree 2 files changed +38
-15
lines changed Original file line number Diff line number Diff line change @@ -741,14 +741,24 @@ public void run() {
741741 if (isStale (e .getValue ())) {
742742 if (useStaleLinkAge ) {
743743 providerService .linkVanished (new DefaultLinkDescription (e .getKey ().src (),
744-
745744 e .getKey ().dst (),
746745 DIRECT ));
747746 return true ;
748747 }
749- log .warn ("VanishStaleLinkAge feature is disabled, " +
750- "not bringing down link src {} dst {} with expired StaleLinkAge" ,
751- e .getKey ().src (), e .getKey ().dst ());
748+ // if one of the device is not available - let's prune the link
749+ if (!deviceService .isAvailable (e .getKey ().src ().deviceId ()) ||
750+ !deviceService .isAvailable (e .getKey ().dst ().deviceId ())) {
751+ return true ;
752+ }
753+ // if one of the ports is not enable - let's prune the link
754+ Port srcPort = deviceService .getPort (e .getKey ().src ());
755+ Port dstPort = deviceService .getPort (e .getKey ().dst ());
756+ if (!srcPort .isEnabled () || !dstPort .isEnabled ()) {
757+ return true ;
758+ }
759+ log .trace ("VanishStaleLinkAge feature is disabled, " +
760+ "not bringing down link src {} dst {} with expired StaleLinkAge" ,
761+ e .getKey ().src (), e .getKey ().dst ());
752762 }
753763 return false ;
754764 }).clear ();
Original file line number Diff line number Diff line change @@ -370,17 +370,30 @@ private boolean notMy(String mac) {
370370 */
371371 @ Override
372372 public void run (Timeout t ) {
373- if (isStopped ()) {
374- return ;
375- }
376-
377- if (context .mastershipService ().isLocalMaster (deviceId )) {
378- log .trace ("Sending probes from {}" , deviceId );
379- ImmutableMap .copyOf (portMap ).forEach (this ::sendProbes );
380- }
381-
382- if (!isStopped ()) {
383- timeout = t .timer ().newTimeout (this , context .probeRate (), MILLISECONDS );
373+ try {
374+ // Check first if it has been stopped
375+ if (isStopped ()) {
376+ return ;
377+ }
378+ // Verify if we are still the master
379+ if (context .mastershipService ().isLocalMaster (deviceId )) {
380+ log .trace ("Sending probes from {}" , deviceId );
381+ ImmutableMap .copyOf (portMap ).forEach (this ::sendProbes );
382+ }
383+ } catch (Exception e ) {
384+ // Catch all exceptions to avoid timer task being cancelled
385+ if (!isStopped ()) {
386+ // Error condition
387+ log .error ("Exception thrown during link discovery process" , e );
388+ } else {
389+ // Provider is shutting down, the error can be ignored
390+ log .trace ("Shutting down, ignoring error" , e );
391+ }
392+ } finally {
393+ // if it has not been stopped - re-schedule itself
394+ if (!isStopped ()) {
395+ timeout = t .timer ().newTimeout (this , context .probeRate (), MILLISECONDS );
396+ }
384397 }
385398 }
386399
You can’t perform that action at this time.
0 commit comments