Small cleanups for vRouter app
Change-Id: Ibee46d3b95ee76dd3547e11d046c4620b3b3306d
diff --git a/apps/routing/src/main/java/org/onosproject/routing/impl/ControlPlaneRedirectManager.java b/apps/routing/src/main/java/org/onosproject/routing/impl/ControlPlaneRedirectManager.java
index a82d4ff..4430f5e 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/impl/ControlPlaneRedirectManager.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/impl/ControlPlaneRedirectManager.java
@@ -16,16 +16,8 @@
package org.onosproject.routing.impl;
-import static com.google.common.base.Preconditions.checkState;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
+import com.google.common.collect.ImmutableSortedSet;
+import com.google.common.collect.Maps;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -69,8 +61,15 @@
import org.onosproject.routing.config.RouterConfig;
import org.slf4j.Logger;
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.Maps;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkState;
+import static org.slf4j.LoggerFactory.getLogger;
/**
* Manages connectivity between peers redirecting control traffic to a routing
@@ -183,7 +182,7 @@
updateOspfForwarding(intf, true);
}
/**
- * Install or removes the basic forwarding flows for each interface
+ * Installs or removes the basic forwarding flows for each interface
* based on the flag used.
*
* @param intf the Interface on which event is received
@@ -266,9 +265,9 @@
}
/**
- * Install or removes ospf forwarding rules.
+ * Installs or removes OSPF forwarding rules.
*
- * @param intf the Interface on which event is received
+ * @param intf the interface on which event is received
* @param install true to create an add objective, false to create a remove
* objective
**/
@@ -293,7 +292,7 @@
cpNextId = modifyNextObjective(deviceId, controlPlanePort,
intf.vlan(), false, install);
}
- log.debug("ospf flows intf:{} nextid:{}", intf, cpNextId);
+ log.debug("OSPF flows intf:{} nextid:{}", intf, cpNextId);
flowObjectiveService.forward(controlPlaneConnectPoint.deviceId(),
buildForwardingObjective(toSelector, null, cpNextId, install ? ospfEnabled : install));
}
@@ -331,7 +330,7 @@
nextObjBuilder.withMeta(metabuilder.build());
nextObjBuilder.addTreatment(ttBuilder.build());
- log.debug("Submited next objective {} in device {} for port/vlan {}/{}",
+ log.debug("Submitted next objective {} in device {} for port/vlan {}/{}",
nextId, deviceId, portNumber, vlanId);
if (install) {
flowObjectiveService.next(deviceId, nextObjBuilder.add());
@@ -385,7 +384,6 @@
log.info("Device connected {}", event.subject().id());
updateDevice();
}
-
break;
case DEVICE_UPDATED:
case DEVICE_REMOVED:
diff --git a/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java b/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java
index b548492..a78e9b4 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java
@@ -60,9 +60,8 @@
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.flowobjective.NextObjective;
-import org.onosproject.net.flowobjective.Objective;
import org.onosproject.net.flowobjective.ObjectiveContext;
-import org.onosproject.net.flowobjective.ObjectiveError;
+import org.onosproject.net.flowobjective.DefaultObjectiveContext;
import org.onosproject.routing.FibEntry;
import org.onosproject.routing.FibListener;
import org.onosproject.routing.FibUpdate;
@@ -442,43 +441,15 @@
private void sendFilteringObjective(boolean install, FilteringObjective.Builder fob,
Interface intf) {
- if (install) {
- flowObjectiveService.filter(
- deviceId,
- fob.add(new ObjectiveContext() {
- @Override
- public void onSuccess(Objective objective) {
- log.info("Successfully installed interface based "
- + "filtering objectives for intf {}", intf);
- }
- @Override
- public void onError(Objective objective,
- ObjectiveError error) {
- log.error("Failed to install interface filters for intf {}: {}",
- intf, error);
- // TODO something more than just logging
- }
- }));
- } else {
- flowObjectiveService.filter(
- deviceId,
- fob.remove(new ObjectiveContext() {
- @Override
- public void onSuccess(Objective objective) {
- log.info("Successfully removed interface based "
- + "filtering objectives for intf {}", intf);
- }
+ ObjectiveContext context = new DefaultObjectiveContext(
+ (objective) -> log.info("Installed filter for interface {}", intf),
+ (objective, error) ->
+ log.error("Failed to install filter for interface {}: {}", intf, error));
- @Override
- public void onError(Objective objective,
- ObjectiveError error) {
- log.error("Failed to install interface filters for intf {}: {}",
- intf, error);
- // TODO something more than just logging
- }
- }));
- }
+ FilteringObjective filter = install ? fob.add(context) : fob.remove(context);
+
+ flowObjectiveService.filter(deviceId, filter);
}
private class InternalFibListener implements FibListener {