[Falcon] More flexible component choice for routing apps
Change-Id: I0b01f633332fa7f099d4b3ffe58d86141f3a040b
Showing
8 changed files
with
51 additions
and
15 deletions
| ... | @@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Reference; |
| 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 23 | import org.onosproject.core.ApplicationId; | 23 | import org.onosproject.core.ApplicationId; |
| 24 | import org.onosproject.core.CoreService; | 24 | import org.onosproject.core.CoreService; |
| 25 | +import org.onosproject.incubator.component.ComponentService; | ||
| 25 | import org.onosproject.incubator.net.intf.InterfaceService; | 26 | import org.onosproject.incubator.net.intf.InterfaceService; |
| 26 | import org.onosproject.net.DeviceId; | 27 | import org.onosproject.net.DeviceId; |
| 27 | import org.onosproject.net.config.NetworkConfigService; | 28 | import org.onosproject.net.config.NetworkConfigService; |
| ... | @@ -36,6 +37,8 @@ import org.onosproject.routing.config.RoutingConfigurationService; | ... | @@ -36,6 +37,8 @@ import org.onosproject.routing.config.RoutingConfigurationService; |
| 36 | import org.slf4j.Logger; | 37 | import org.slf4j.Logger; |
| 37 | import org.slf4j.LoggerFactory; | 38 | import org.slf4j.LoggerFactory; |
| 38 | 39 | ||
| 40 | +import java.util.ArrayList; | ||
| 41 | +import java.util.List; | ||
| 39 | import java.util.Optional; | 42 | import java.util.Optional; |
| 40 | 43 | ||
| 41 | /** | 44 | /** |
| ... | @@ -72,6 +75,9 @@ public class BgpRouter { | ... | @@ -72,6 +75,9 @@ public class BgpRouter { |
| 72 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 75 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 73 | protected DeviceService deviceService; | 76 | protected DeviceService deviceService; |
| 74 | 77 | ||
| 78 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 79 | + protected ComponentService componentService; | ||
| 80 | + | ||
| 75 | private ApplicationId appId; | 81 | private ApplicationId appId; |
| 76 | 82 | ||
| 77 | // Device id of control-plane switch (OVS) connected to BGP Speaker - should be | 83 | // Device id of control-plane switch (OVS) connected to BGP Speaker - should be |
| ... | @@ -85,10 +91,19 @@ public class BgpRouter { | ... | @@ -85,10 +91,19 @@ public class BgpRouter { |
| 85 | private DeviceListener deviceListener; | 91 | private DeviceListener deviceListener; |
| 86 | private IcmpHandler icmpHandler; | 92 | private IcmpHandler icmpHandler; |
| 87 | 93 | ||
| 94 | + private static List<String> components = new ArrayList<>(); | ||
| 95 | + static { | ||
| 96 | + components.add("org.onosproject.routing.bgp.BgpSessionManager"); | ||
| 97 | + components.add("org.onosproject.routing.impl.Router"); | ||
| 98 | + components.add("org.onosproject.routing.impl.SingleSwitchFibInstaller"); | ||
| 99 | + } | ||
| 100 | + | ||
| 88 | @Activate | 101 | @Activate |
| 89 | protected void activate() { | 102 | protected void activate() { |
| 90 | appId = coreService.registerApplication(BGP_ROUTER_APP); | 103 | appId = coreService.registerApplication(BGP_ROUTER_APP); |
| 91 | 104 | ||
| 105 | + components.forEach(name -> componentService.activate(appId, name)); | ||
| 106 | + | ||
| 92 | ApplicationId routerAppId = coreService.getAppId(RoutingService.ROUTER_APP_ID); | 107 | ApplicationId routerAppId = coreService.getAppId(RoutingService.ROUTER_APP_ID); |
| 93 | BgpConfig bgpConfig = | 108 | BgpConfig bgpConfig = |
| 94 | networkConfigService.getConfig(routerAppId, RoutingService.CONFIG_CLASS); | 109 | networkConfigService.getConfig(routerAppId, RoutingService.CONFIG_CLASS); |
| ... | @@ -123,6 +138,8 @@ public class BgpRouter { | ... | @@ -123,6 +138,8 @@ public class BgpRouter { |
| 123 | 138 | ||
| 124 | @Deactivate | 139 | @Deactivate |
| 125 | protected void deactivate() { | 140 | protected void deactivate() { |
| 141 | + components.forEach(name -> componentService.deactivate(appId, name)); | ||
| 142 | + | ||
| 126 | connectivityManager.stop(); | 143 | connectivityManager.stop(); |
| 127 | icmpHandler.stop(); | 144 | icmpHandler.stop(); |
| 128 | deviceService.removeListener(deviceListener); | 145 | deviceService.removeListener(deviceListener); | ... | ... |
| ... | @@ -55,7 +55,7 @@ import static org.onlab.util.Tools.groupedThreads; | ... | @@ -55,7 +55,7 @@ import static org.onlab.util.Tools.groupedThreads; |
| 55 | /** | 55 | /** |
| 56 | * BGP Session Manager class. | 56 | * BGP Session Manager class. |
| 57 | */ | 57 | */ |
| 58 | -@Component(immediate = true) | 58 | +@Component(immediate = true, enabled = false) |
| 59 | @Service | 59 | @Service |
| 60 | public class BgpSessionManager implements BgpInfoService, BgpService { | 60 | public class BgpSessionManager implements BgpInfoService, BgpService { |
| 61 | private static final Logger log = | 61 | private static final Logger log = | ... | ... |
| ... | @@ -13,7 +13,8 @@ | ... | @@ -13,7 +13,8 @@ |
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package org.onosproject.bgprouter; | 16 | + |
| 17 | +package org.onosproject.routing.impl; | ||
| 17 | 18 | ||
| 18 | import java.util.Objects; | 19 | import java.util.Objects; |
| 19 | 20 | ... | ... |
| ... | @@ -13,15 +13,15 @@ | ... | @@ -13,15 +13,15 @@ |
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package org.onosproject.bgprouter; | ||
| 17 | 16 | ||
| 18 | -import static com.google.common.base.Preconditions.checkNotNull; | 17 | +package org.onosproject.routing.impl; |
| 19 | - | ||
| 20 | -import java.util.Objects; | ||
| 21 | 18 | ||
| 19 | +import com.google.common.base.MoreObjects; | ||
| 22 | import org.onlab.packet.IpAddress; | 20 | import org.onlab.packet.IpAddress; |
| 23 | 21 | ||
| 24 | -import com.google.common.base.MoreObjects; | 22 | +import java.util.Objects; |
| 23 | + | ||
| 24 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 25 | 25 | ||
| 26 | /** | 26 | /** |
| 27 | * Identifier for a next hop group. | 27 | * Identifier for a next hop group. | ... | ... |
| ... | @@ -72,7 +72,7 @@ import static org.onosproject.routing.RouteEntry.createBinaryString; | ... | @@ -72,7 +72,7 @@ import static org.onosproject.routing.RouteEntry.createBinaryString; |
| 72 | * (RIB). After route updates have been processed and next hops have been | 72 | * (RIB). After route updates have been processed and next hops have been |
| 73 | * resolved, FIB updates are sent to any listening FIB components. | 73 | * resolved, FIB updates are sent to any listening FIB components. |
| 74 | */ | 74 | */ |
| 75 | -@Component(immediate = true) | 75 | +@Component(immediate = true, enabled = false) |
| 76 | @Service | 76 | @Service |
| 77 | public class Router implements RoutingService { | 77 | public class Router implements RoutingService { |
| 78 | 78 | ... | ... |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.bgprouter; | 17 | +package org.onosproject.routing.impl; |
| 18 | 18 | ||
| 19 | import com.google.common.collect.ConcurrentHashMultiset; | 19 | import com.google.common.collect.ConcurrentHashMultiset; |
| 20 | import com.google.common.collect.HashMultimap; | 20 | import com.google.common.collect.HashMultimap; |
| ... | @@ -70,8 +70,8 @@ import java.util.Set; | ... | @@ -70,8 +70,8 @@ import java.util.Set; |
| 70 | /** | 70 | /** |
| 71 | * Programs routes to a single OpenFlow switch. | 71 | * Programs routes to a single OpenFlow switch. |
| 72 | */ | 72 | */ |
| 73 | -@Component(immediate = true) | 73 | +@Component(immediate = true, enabled = false) |
| 74 | -public class SingleSwitchRouter { | 74 | +public class SingleSwitchFibInstaller { |
| 75 | 75 | ||
| 76 | private final Logger log = LoggerFactory.getLogger(getClass()); | 76 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 77 | 77 | ||
| ... | @@ -129,7 +129,7 @@ public class SingleSwitchRouter { | ... | @@ -129,7 +129,7 @@ public class SingleSwitchRouter { |
| 129 | 129 | ||
| 130 | getDeviceConfiguration(bgpConfig); | 130 | getDeviceConfiguration(bgpConfig); |
| 131 | 131 | ||
| 132 | - appId = coreService.getAppId(BgpRouter.BGP_ROUTER_APP); | 132 | + appId = coreService.getAppId(RoutingService.ROUTER_APP_ID); |
| 133 | 133 | ||
| 134 | deviceListener = new InnerDeviceListener(); | 134 | deviceListener = new InnerDeviceListener(); |
| 135 | deviceService.addListener(deviceListener); | 135 | deviceService.addListener(deviceListener); |
| ... | @@ -376,8 +376,8 @@ public class SingleSwitchRouter { | ... | @@ -376,8 +376,8 @@ public class SingleSwitchRouter { |
| 376 | @Override | 376 | @Override |
| 377 | public void update(Collection<FibUpdate> updates, | 377 | public void update(Collection<FibUpdate> updates, |
| 378 | Collection<FibUpdate> withdraws) { | 378 | Collection<FibUpdate> withdraws) { |
| 379 | - SingleSwitchRouter.this.deleteFibEntry(withdraws); | 379 | + SingleSwitchFibInstaller.this.deleteFibEntry(withdraws); |
| 380 | - SingleSwitchRouter.this.updateFibEntry(updates); | 380 | + SingleSwitchFibInstaller.this.updateFibEntry(updates); |
| 381 | } | 381 | } |
| 382 | } | 382 | } |
| 383 | 383 | ... | ... |
| ... | @@ -23,6 +23,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; | ... | @@ -23,6 +23,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 23 | import org.onosproject.app.ApplicationService; | 23 | import org.onosproject.app.ApplicationService; |
| 24 | import org.onosproject.core.ApplicationId; | 24 | import org.onosproject.core.ApplicationId; |
| 25 | import org.onosproject.core.CoreService; | 25 | import org.onosproject.core.CoreService; |
| 26 | +import org.onosproject.incubator.component.ComponentService; | ||
| 26 | import org.onosproject.incubator.net.intf.InterfaceService; | 27 | import org.onosproject.incubator.net.intf.InterfaceService; |
| 27 | import org.onosproject.net.config.NetworkConfigService; | 28 | import org.onosproject.net.config.NetworkConfigService; |
| 28 | import org.onosproject.routing.IntentSynchronizationAdminService; | 29 | import org.onosproject.routing.IntentSynchronizationAdminService; |
| ... | @@ -30,6 +31,9 @@ import org.onosproject.routing.IntentSynchronizationService; | ... | @@ -30,6 +31,9 @@ import org.onosproject.routing.IntentSynchronizationService; |
| 30 | import org.onosproject.routing.RoutingService; | 31 | import org.onosproject.routing.RoutingService; |
| 31 | import org.slf4j.Logger; | 32 | import org.slf4j.Logger; |
| 32 | 33 | ||
| 34 | +import java.util.ArrayList; | ||
| 35 | +import java.util.List; | ||
| 36 | + | ||
| 33 | import static org.slf4j.LoggerFactory.getLogger; | 37 | import static org.slf4j.LoggerFactory.getLogger; |
| 34 | 38 | ||
| 35 | /** | 39 | /** |
| ... | @@ -59,12 +63,24 @@ public class SdnIp { | ... | @@ -59,12 +63,24 @@ public class SdnIp { |
| 59 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 63 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 60 | protected IntentSynchronizationAdminService intentSynchronizerAdmin; | 64 | protected IntentSynchronizationAdminService intentSynchronizerAdmin; |
| 61 | 65 | ||
| 66 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 67 | + protected ComponentService componentService; | ||
| 68 | + | ||
| 62 | private PeerConnectivityManager peerConnectivity; | 69 | private PeerConnectivityManager peerConnectivity; |
| 63 | 70 | ||
| 64 | private ApplicationId appId; | 71 | private ApplicationId appId; |
| 65 | 72 | ||
| 73 | + private static List<String> components = new ArrayList<>(); | ||
| 74 | + static { | ||
| 75 | + components.add("org.onosproject.routing.bgp.BgpSessionManager"); | ||
| 76 | + components.add("org.onosproject.routing.impl.Router"); | ||
| 77 | + components.add(org.onosproject.sdnip.SdnIpFib.class.getName()); | ||
| 78 | + } | ||
| 79 | + | ||
| 66 | @Activate | 80 | @Activate |
| 67 | protected void activate() { | 81 | protected void activate() { |
| 82 | + components.forEach(name -> componentService.activate(appId, name)); | ||
| 83 | + | ||
| 68 | appId = coreService.registerApplication(SDN_IP_APP); | 84 | appId = coreService.registerApplication(SDN_IP_APP); |
| 69 | 85 | ||
| 70 | peerConnectivity = new PeerConnectivityManager(appId, | 86 | peerConnectivity = new PeerConnectivityManager(appId, |
| ... | @@ -83,6 +99,8 @@ public class SdnIp { | ... | @@ -83,6 +99,8 @@ public class SdnIp { |
| 83 | 99 | ||
| 84 | @Deactivate | 100 | @Deactivate |
| 85 | protected void deactivate() { | 101 | protected void deactivate() { |
| 102 | + components.forEach(name -> componentService.deactivate(appId, name)); | ||
| 103 | + | ||
| 86 | peerConnectivity.stop(); | 104 | peerConnectivity.stop(); |
| 87 | 105 | ||
| 88 | log.info("SDN-IP Stopped"); | 106 | log.info("SDN-IP Stopped"); | ... | ... |
| ... | @@ -58,7 +58,7 @@ import static com.google.common.base.Preconditions.checkArgument; | ... | @@ -58,7 +58,7 @@ import static com.google.common.base.Preconditions.checkArgument; |
| 58 | /** | 58 | /** |
| 59 | * FIB component of SDN-IP. | 59 | * FIB component of SDN-IP. |
| 60 | */ | 60 | */ |
| 61 | -@Component(immediate = true) | 61 | +@Component(immediate = true, enabled = false) |
| 62 | public class SdnIpFib { | 62 | public class SdnIpFib { |
| 63 | private Logger log = LoggerFactory.getLogger(getClass()); | 63 | private Logger log = LoggerFactory.getLogger(getClass()); |
| 64 | 64 | ... | ... |
-
Please register or login to post a comment