Jonathan Hart

Fix registering config listener in SingleSwitchFibInstaller

Change-Id: I559d89063236c81fa63530aa5db61f4b68006287
...@@ -127,8 +127,6 @@ public class SingleSwitchFibInstaller { ...@@ -127,8 +127,6 @@ public class SingleSwitchFibInstaller {
127 label = "Install a /32 route to each next hop") 127 label = "Install a /32 route to each next hop")
128 private boolean routeToNextHop = false; 128 private boolean routeToNextHop = false;
129 129
130 - private InternalDeviceListener deviceListener;
131 -
132 // Device id of data-plane switch - should be learned from config 130 // Device id of data-plane switch - should be learned from config
133 private DeviceId deviceId; 131 private DeviceId deviceId;
134 132
...@@ -149,9 +147,10 @@ public class SingleSwitchFibInstaller { ...@@ -149,9 +147,10 @@ public class SingleSwitchFibInstaller {
149 // Mapping from next hop IP to next hop object containing group info 147 // Mapping from next hop IP to next hop object containing group info
150 private final Map<IpAddress, Integer> nextHops = Maps.newHashMap(); 148 private final Map<IpAddress, Integer> nextHops = Maps.newHashMap();
151 149
152 - //interface object for event 150 + private final InternalDeviceListener deviceListener = new InternalDeviceListener();
153 - private InternalInterfaceListener internalInterfaceList = new InternalInterfaceListener(); 151 + private final InternalInterfaceListener internalInterfaceList = new InternalInterfaceListener();
154 - private InternalRouteListener routeListener = new InternalRouteListener(); 152 + private final InternalRouteListener routeListener = new InternalRouteListener();
153 + private final InternalNetworkConfigListener configListener = new InternalNetworkConfigListener();
155 154
156 private ConfigFactory<ApplicationId, McastConfig> mcastConfigFactory = 155 private ConfigFactory<ApplicationId, McastConfig> mcastConfigFactory =
157 new ConfigFactory<ApplicationId, McastConfig>(SubjectFactories.APP_SUBJECT_FACTORY, 156 new ConfigFactory<ApplicationId, McastConfig>(SubjectFactories.APP_SUBJECT_FACTORY,
...@@ -173,9 +172,8 @@ public class SingleSwitchFibInstaller { ...@@ -173,9 +172,8 @@ public class SingleSwitchFibInstaller {
173 172
174 networkConfigRegistry.registerConfigFactory(mcastConfigFactory); 173 networkConfigRegistry.registerConfigFactory(mcastConfigFactory);
175 174
176 - deviceListener = new InternalDeviceListener(); 175 + networkConfigService.addListener(configListener);
177 deviceService.addListener(deviceListener); 176 deviceService.addListener(deviceListener);
178 -
179 interfaceService.addListener(internalInterfaceList); 177 interfaceService.addListener(internalInterfaceList);
180 178
181 updateConfig(); 179 updateConfig();
...@@ -192,6 +190,7 @@ public class SingleSwitchFibInstaller { ...@@ -192,6 +190,7 @@ public class SingleSwitchFibInstaller {
192 routeService.removeListener(routeListener); 190 routeService.removeListener(routeListener);
193 deviceService.removeListener(deviceListener); 191 deviceService.removeListener(deviceListener);
194 interfaceService.removeListener(internalInterfaceList); 192 interfaceService.removeListener(internalInterfaceList);
193 + networkConfigService.removeListener(configListener);
195 194
196 //processIntfFilters(false, configService.getInterfaces()); //TODO necessary? 195 //processIntfFilters(false, configService.getInterfaces()); //TODO necessary?
197 196
...@@ -557,7 +556,7 @@ public class SingleSwitchFibInstaller { ...@@ -557,7 +556,7 @@ public class SingleSwitchFibInstaller {
557 private class InternalNetworkConfigListener implements NetworkConfigListener { 556 private class InternalNetworkConfigListener implements NetworkConfigListener {
558 @Override 557 @Override
559 public void event(NetworkConfigEvent event) { 558 public void event(NetworkConfigEvent event) {
560 - if (event.subject().equals(RoutingService.ROUTER_CONFIG_CLASS)) { 559 + if (event.configClass().equals(RoutingService.ROUTER_CONFIG_CLASS)) {
561 switch (event.type()) { 560 switch (event.type()) {
562 case CONFIG_ADDED: 561 case CONFIG_ADDED:
563 case CONFIG_UPDATED: 562 case CONFIG_UPDATED:
......
...@@ -41,6 +41,7 @@ import org.onosproject.incubator.net.routing.RouteServiceAdapter; ...@@ -41,6 +41,7 @@ import org.onosproject.incubator.net.routing.RouteServiceAdapter;
41 import org.onosproject.net.ConnectPoint; 41 import org.onosproject.net.ConnectPoint;
42 import org.onosproject.net.DeviceId; 42 import org.onosproject.net.DeviceId;
43 import org.onosproject.net.PortNumber; 43 import org.onosproject.net.PortNumber;
44 +import org.onosproject.net.config.NetworkConfigListener;
44 import org.onosproject.net.config.NetworkConfigRegistry; 45 import org.onosproject.net.config.NetworkConfigRegistry;
45 import org.onosproject.net.config.NetworkConfigService; 46 import org.onosproject.net.config.NetworkConfigService;
46 import org.onosproject.net.device.DeviceListener; 47 import org.onosproject.net.device.DeviceListener;
...@@ -131,6 +132,8 @@ public class SingleSwitchFibInstallerTest { ...@@ -131,6 +132,8 @@ public class SingleSwitchFibInstallerTest {
131 interfaceService = createMock(InterfaceService.class); 132 interfaceService = createMock(InterfaceService.class);
132 133
133 networkConfigService = createMock(NetworkConfigService.class); 134 networkConfigService = createMock(NetworkConfigService.class);
135 + networkConfigService.addListener(anyObject(NetworkConfigListener.class));
136 + expectLastCall().anyTimes();
134 networkConfigRegistry = createMock(NetworkConfigRegistry.class); 137 networkConfigRegistry = createMock(NetworkConfigRegistry.class);
135 flowObjectiveService = createMock(FlowObjectiveService.class); 138 flowObjectiveService = createMock(FlowObjectiveService.class);
136 applicationService = createNiceMock(ApplicationService.class); 139 applicationService = createNiceMock(ApplicationService.class);
......