Jonathan Hart

[Falcon] More flexible component choice for routing apps

Change-Id: I0b01f633332fa7f099d4b3ffe58d86141f3a040b
......@@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.incubator.component.ComponentService;
import org.onosproject.incubator.net.intf.InterfaceService;
import org.onosproject.net.DeviceId;
import org.onosproject.net.config.NetworkConfigService;
......@@ -36,6 +37,8 @@ import org.onosproject.routing.config.RoutingConfigurationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
......@@ -72,6 +75,9 @@ public class BgpRouter {
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentService componentService;
private ApplicationId appId;
// Device id of control-plane switch (OVS) connected to BGP Speaker - should be
......@@ -85,10 +91,19 @@ public class BgpRouter {
private DeviceListener deviceListener;
private IcmpHandler icmpHandler;
private static List<String> components = new ArrayList<>();
static {
components.add("org.onosproject.routing.bgp.BgpSessionManager");
components.add("org.onosproject.routing.impl.Router");
components.add("org.onosproject.routing.impl.SingleSwitchFibInstaller");
}
@Activate
protected void activate() {
appId = coreService.registerApplication(BGP_ROUTER_APP);
components.forEach(name -> componentService.activate(appId, name));
ApplicationId routerAppId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
BgpConfig bgpConfig =
networkConfigService.getConfig(routerAppId, RoutingService.CONFIG_CLASS);
......@@ -123,6 +138,8 @@ public class BgpRouter {
@Deactivate
protected void deactivate() {
components.forEach(name -> componentService.deactivate(appId, name));
connectivityManager.stop();
icmpHandler.stop();
deviceService.removeListener(deviceListener);
......
......@@ -55,7 +55,7 @@ import static org.onlab.util.Tools.groupedThreads;
/**
* BGP Session Manager class.
*/
@Component(immediate = true)
@Component(immediate = true, enabled = false)
@Service
public class BgpSessionManager implements BgpInfoService, BgpService {
private static final Logger log =
......
......@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.bgprouter;
package org.onosproject.routing.impl;
import java.util.Objects;
......
......@@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.bgprouter;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
package org.onosproject.routing.impl;
import com.google.common.base.MoreObjects;
import org.onlab.packet.IpAddress;
import com.google.common.base.MoreObjects;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Identifier for a next hop group.
......
......@@ -72,7 +72,7 @@ import static org.onosproject.routing.RouteEntry.createBinaryString;
* (RIB). After route updates have been processed and next hops have been
* resolved, FIB updates are sent to any listening FIB components.
*/
@Component(immediate = true)
@Component(immediate = true, enabled = false)
@Service
public class Router implements RoutingService {
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.onosproject.bgprouter;
package org.onosproject.routing.impl;
import com.google.common.collect.ConcurrentHashMultiset;
import com.google.common.collect.HashMultimap;
......@@ -70,8 +70,8 @@ import java.util.Set;
/**
* Programs routes to a single OpenFlow switch.
*/
@Component(immediate = true)
public class SingleSwitchRouter {
@Component(immediate = true, enabled = false)
public class SingleSwitchFibInstaller {
private final Logger log = LoggerFactory.getLogger(getClass());
......@@ -129,7 +129,7 @@ public class SingleSwitchRouter {
getDeviceConfiguration(bgpConfig);
appId = coreService.getAppId(BgpRouter.BGP_ROUTER_APP);
appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
deviceListener = new InnerDeviceListener();
deviceService.addListener(deviceListener);
......@@ -376,8 +376,8 @@ public class SingleSwitchRouter {
@Override
public void update(Collection<FibUpdate> updates,
Collection<FibUpdate> withdraws) {
SingleSwitchRouter.this.deleteFibEntry(withdraws);
SingleSwitchRouter.this.updateFibEntry(updates);
SingleSwitchFibInstaller.this.deleteFibEntry(withdraws);
SingleSwitchFibInstaller.this.updateFibEntry(updates);
}
}
......
......@@ -23,6 +23,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onosproject.app.ApplicationService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.incubator.component.ComponentService;
import org.onosproject.incubator.net.intf.InterfaceService;
import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.routing.IntentSynchronizationAdminService;
......@@ -30,6 +31,9 @@ import org.onosproject.routing.IntentSynchronizationService;
import org.onosproject.routing.RoutingService;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.List;
import static org.slf4j.LoggerFactory.getLogger;
/**
......@@ -59,12 +63,24 @@ public class SdnIp {
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected IntentSynchronizationAdminService intentSynchronizerAdmin;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentService componentService;
private PeerConnectivityManager peerConnectivity;
private ApplicationId appId;
private static List<String> components = new ArrayList<>();
static {
components.add("org.onosproject.routing.bgp.BgpSessionManager");
components.add("org.onosproject.routing.impl.Router");
components.add(org.onosproject.sdnip.SdnIpFib.class.getName());
}
@Activate
protected void activate() {
components.forEach(name -> componentService.activate(appId, name));
appId = coreService.registerApplication(SDN_IP_APP);
peerConnectivity = new PeerConnectivityManager(appId,
......@@ -83,6 +99,8 @@ public class SdnIp {
@Deactivate
protected void deactivate() {
components.forEach(name -> componentService.deactivate(appId, name));
peerConnectivity.stop();
log.info("SDN-IP Stopped");
......
......@@ -58,7 +58,7 @@ import static com.google.common.base.Preconditions.checkArgument;
/**
* FIB component of SDN-IP.
*/
@Component(immediate = true)
@Component(immediate = true, enabled = false)
public class SdnIpFib {
private Logger log = LoggerFactory.getLogger(getClass());
......