Jonathan Hart

Fix registering config listener in SingleSwitchFibInstaller

Change-Id: I559d89063236c81fa63530aa5db61f4b68006287
...@@ -122,8 +122,6 @@ public class SingleSwitchFibInstaller { ...@@ -122,8 +122,6 @@ public class SingleSwitchFibInstaller {
122 label = "Install a /32 route to each next hop") 122 label = "Install a /32 route to each next hop")
123 private boolean routeToNextHop = false; 123 private boolean routeToNextHop = false;
124 124
125 - private InternalDeviceListener deviceListener;
126 -
127 // Device id of data-plane switch - should be learned from config 125 // Device id of data-plane switch - should be learned from config
128 private DeviceId deviceId; 126 private DeviceId deviceId;
129 127
...@@ -143,9 +141,10 @@ public class SingleSwitchFibInstaller { ...@@ -143,9 +141,10 @@ public class SingleSwitchFibInstaller {
143 // Mapping from next hop IP to next hop object containing group info 141 // Mapping from next hop IP to next hop object containing group info
144 private final Map<IpAddress, Integer> nextHops = Maps.newHashMap(); 142 private final Map<IpAddress, Integer> nextHops = Maps.newHashMap();
145 143
146 - //interface object for event 144 + private final InternalDeviceListener deviceListener = new InternalDeviceListener();
147 - private InternalInterfaceListener internalInterfaceList = new InternalInterfaceListener(); 145 + private final InternalInterfaceListener internalInterfaceList = new InternalInterfaceListener();
148 - private InternalRouteListener routeListener = new InternalRouteListener(); 146 + private final InternalRouteListener routeListener = new InternalRouteListener();
147 + private final InternalNetworkConfigListener configListener = new InternalNetworkConfigListener();
149 148
150 private ConfigFactory<ApplicationId, McastConfig> mcastConfigFactory = 149 private ConfigFactory<ApplicationId, McastConfig> mcastConfigFactory =
151 new ConfigFactory<ApplicationId, McastConfig>(SubjectFactories.APP_SUBJECT_FACTORY, 150 new ConfigFactory<ApplicationId, McastConfig>(SubjectFactories.APP_SUBJECT_FACTORY,
...@@ -166,9 +165,8 @@ public class SingleSwitchFibInstaller { ...@@ -166,9 +165,8 @@ public class SingleSwitchFibInstaller {
166 165
167 networkConfigRegistry.registerConfigFactory(mcastConfigFactory); 166 networkConfigRegistry.registerConfigFactory(mcastConfigFactory);
168 167
169 - deviceListener = new InternalDeviceListener(); 168 + networkConfigService.addListener(configListener);
170 deviceService.addListener(deviceListener); 169 deviceService.addListener(deviceListener);
171 -
172 interfaceService.addListener(internalInterfaceList); 170 interfaceService.addListener(internalInterfaceList);
173 171
174 updateConfig(); 172 updateConfig();
...@@ -181,6 +179,7 @@ public class SingleSwitchFibInstaller { ...@@ -181,6 +179,7 @@ public class SingleSwitchFibInstaller {
181 routeService.removeListener(routeListener); 179 routeService.removeListener(routeListener);
182 deviceService.removeListener(deviceListener); 180 deviceService.removeListener(deviceListener);
183 interfaceService.removeListener(internalInterfaceList); 181 interfaceService.removeListener(internalInterfaceList);
182 + networkConfigService.removeListener(configListener);
184 183
185 //processIntfFilters(false, configService.getInterfaces()); //TODO necessary? 184 //processIntfFilters(false, configService.getInterfaces()); //TODO necessary?
186 185
...@@ -532,7 +531,7 @@ public class SingleSwitchFibInstaller { ...@@ -532,7 +531,7 @@ public class SingleSwitchFibInstaller {
532 private class InternalNetworkConfigListener implements NetworkConfigListener { 531 private class InternalNetworkConfigListener implements NetworkConfigListener {
533 @Override 532 @Override
534 public void event(NetworkConfigEvent event) { 533 public void event(NetworkConfigEvent event) {
535 - if (event.subject().equals(RoutingService.ROUTER_CONFIG_CLASS)) { 534 + if (event.configClass().equals(RoutingService.ROUTER_CONFIG_CLASS)) {
536 switch (event.type()) { 535 switch (event.type()) {
537 case CONFIG_ADDED: 536 case CONFIG_ADDED:
538 case CONFIG_UPDATED: 537 case CONFIG_UPDATED:
......
...@@ -40,6 +40,7 @@ import org.onosproject.incubator.net.routing.RouteServiceAdapter; ...@@ -40,6 +40,7 @@ import org.onosproject.incubator.net.routing.RouteServiceAdapter;
40 import org.onosproject.net.ConnectPoint; 40 import org.onosproject.net.ConnectPoint;
41 import org.onosproject.net.DeviceId; 41 import org.onosproject.net.DeviceId;
42 import org.onosproject.net.PortNumber; 42 import org.onosproject.net.PortNumber;
43 +import org.onosproject.net.config.NetworkConfigListener;
43 import org.onosproject.net.config.NetworkConfigRegistry; 44 import org.onosproject.net.config.NetworkConfigRegistry;
44 import org.onosproject.net.config.NetworkConfigService; 45 import org.onosproject.net.config.NetworkConfigService;
45 import org.onosproject.net.device.DeviceListener; 46 import org.onosproject.net.device.DeviceListener;
...@@ -130,6 +131,8 @@ public class SingleSwitchFibInstallerTest { ...@@ -130,6 +131,8 @@ public class SingleSwitchFibInstallerTest {
130 interfaceService = createMock(InterfaceService.class); 131 interfaceService = createMock(InterfaceService.class);
131 132
132 networkConfigService = createMock(NetworkConfigService.class); 133 networkConfigService = createMock(NetworkConfigService.class);
134 + networkConfigService.addListener(anyObject(NetworkConfigListener.class));
135 + expectLastCall().anyTimes();
133 networkConfigRegistry = createMock(NetworkConfigRegistry.class); 136 networkConfigRegistry = createMock(NetworkConfigRegistry.class);
134 flowObjectiveService = createMock(FlowObjectiveService.class); 137 flowObjectiveService = createMock(FlowObjectiveService.class);
135 deviceService = new TestDeviceService(); 138 deviceService = new TestDeviceService();
......