Software Defined Networking
1753857 Members
7356 Online
108809 Solutions
New Discussion юеВ

Device And Link Removal (Thread Control)

 
SOLVED
Go to solution
phpHavok
Advisor

Device And Link Removal (Thread Control)

When a device is removed from my topology, I want to iterate all its existing links and do something with the neighboring devices on the other end of the links. The problem is that device notifications and link removal run in separate threads. That is, my callback method that detects a device has been removed can or cannot iterate the removed device's links depending on whether or not the links have already been removed. Can I programatically control this? Is there some object I can syncrhonize on to guarantee that I will be able to read links before they are removed in one of these device removal notifications?

2 REPLIES 2
ShaunWackerly
HPE Pro
Solution

Re: Device And Link Removal (Thread Control)

I don't think there's a way to get the threads which run device removal and link removal to synchronize with eachother, but I think there are a few options to accomplish your goal. In both options I can think of, you'd need to register a LinkListener with the LinkService:

  1. Cache a copy of the links that are created, each time your LInkListener receives a LINK_ADDED event. When you receive a DeviceListener notification that a device has been removed (or gone offline), then consult your cache to find the links that were active at the time the device was removed.
  2. When your LinkListener receives a LINK_REMOVED event, check to see if the device still exists or is still online. This will let you infer when a device is removed or goes offline (respectively). At the point you infer this information, you'll still have the link that was removed, so you'll know the neighboring device.

In either case, remember that a link can either be DIRECT_LINK or MULTIHOP_LINK. If you are looking for physical adjacencies, then you'd only want to take action on DIRECT_LINK. If you're looking for logical OF adjacencies, then you'd take action on either link type.

I am an HPE Employee
phpHavok
Advisor

Re: Device And Link Removal (Thread Control)

This seems viable. Thank you!