aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/sdnip/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps/sdnip/src/main')
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java85
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java10
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java20
3 files changed, 49 insertions, 66 deletions
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
index f2d5b5e2..a3cd6875 100644
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
+++ b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
@@ -15,24 +15,25 @@
*/
package org.onosproject.sdnip;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.IntentState;
-import org.onosproject.net.intent.Key;
-import org.onosproject.routing.IntentSynchronizationService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static java.util.concurrent.Executors.newSingleThreadExecutor;
+import static org.onlab.util.Tools.groupedThreads;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
-import static java.util.concurrent.Executors.newSingleThreadExecutor;
-import static org.onlab.util.Tools.groupedThreads;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.IntentService;
+import org.onosproject.net.intent.IntentState;
+import org.onosproject.net.intent.Key;
+import org.onosproject.routing.IntentSynchronizationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Synchronizes intents between the in-memory intent store and the
@@ -97,55 +98,30 @@ public class IntentSynchronizer implements IntentSynchronizationService {
synchronized (this) {
// Stop the thread(s)
intentsSynchronizerExecutor.shutdownNow();
+ log.info("Intents Synchronizer Executor shutdown completed");
- //
- // Withdraw all app related intents
- //
- if (!isElectedLeader) {
- return; // Nothing to do: not the leader anymore
- }
+ }
+ }
- //
- // NOTE: We don't withdraw the intents during shutdown, because
- // it creates flux in the data plane during switchover.
- //
-
- /*
- //
- // Build a batch operation to withdraw all intents from this
- // application.
- //
- log.debug("Intent Synchronizer shutdown: " +
- "withdrawing all intents...");
- IntentOperations.Builder builder = IntentOperations.builder(appId);
- for (Intent intent : intentService.getIntents()) {
- // Skip the intents from other applications
- if (!intent.appId().equals(appId)) {
- continue;
- }
+ /**
+ * Withdraws all intents.
+ */
+ public void removeIntents() {
+ if (!isElectedLeader) {
+ // only leader will withdraw intents
+ return;
+ }
- // Skip the intents that are already withdrawn
- IntentState intentState =
- intentService.getIntentState(intent.id());
- if ((intentState == null) ||
- intentState.equals(IntentState.WITHDRAWING) ||
- intentState.equals(IntentState.WITHDRAWN)) {
- continue;
- }
+ log.debug("Intent Synchronizer shutdown: withdrawing all intents...");
- log.trace("Intent Synchronizer withdrawing intent: {}",
- intent);
- builder.addWithdrawOperation(intent.id());
- }
- IntentOperations intentOperations = builder.build();
- intentService.execute(intentOperations);
- leaderChanged(false);
-
- peerIntents.clear();
- routeIntents.clear();
- log.debug("Intent Synchronizer shutdown completed");
- */
+ for (Entry<Key, Intent> entry : intents.entrySet()) {
+ intentService.withdraw(entry.getValue());
+ log.debug("Intent Synchronizer withdrawing intent: {}",
+ entry.getValue());
}
+
+ intents.clear();
+ log.info("Tried to clean all intents");
}
@Override
@@ -261,5 +237,4 @@ public class IntentSynchronizer implements IntentSynchronizationService {
}
log.debug("Intent synchronization completed");
}
-
}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
index a27baaf9..fb008aad 100644
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
+++ b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
@@ -340,15 +340,15 @@ public class PeerConnectivityManager {
private TrafficSelector buildSelector(byte ipProto, IpAddress srcIp,
IpAddress dstIp, Short srcTcpPort,
Short dstTcpPort) {
- TrafficSelector.Builder builder = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4)
- .matchIPProtocol(ipProto);
+ TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchIPProtocol(ipProto);
if (dstIp.isIp4()) {
- builder.matchIPSrc(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET_MASK_LENGTH))
+ builder.matchEthType(Ethernet.TYPE_IPV4)
+ .matchIPSrc(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET_MASK_LENGTH))
.matchIPDst(IpPrefix.valueOf(dstIp, IpPrefix.MAX_INET_MASK_LENGTH));
} else {
- builder.matchIPv6Src(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET6_MASK_LENGTH))
+ builder.matchEthType(Ethernet.TYPE_IPV6)
+ .matchIPv6Src(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET6_MASK_LENGTH))
.matchIPv6Dst(IpPrefix.valueOf(dstIp, IpPrefix.MAX_INET6_MASK_LENGTH));
}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
index 1b3eda9d..ace888d1 100644
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
+++ b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
@@ -15,12 +15,17 @@
*/
package org.onosproject.sdnip;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Objects;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
+import org.onosproject.app.ApplicationService;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.ControllerNode;
import org.onosproject.cluster.LeadershipEvent;
@@ -28,8 +33,8 @@ import org.onosproject.cluster.LeadershipEventListener;
import org.onosproject.cluster.LeadershipService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.incubator.net.intf.InterfaceService;
+import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.IntentService;
import org.onosproject.routing.IntentSynchronizationService;
@@ -38,10 +43,6 @@ import org.onosproject.routing.SdnIpService;
import org.onosproject.routing.config.RoutingConfigurationService;
import org.slf4j.Logger;
-import java.util.Objects;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
/**
* Component for the SDN-IP peering application.
*/
@@ -59,6 +60,9 @@ public class SdnIp implements SdnIpService {
protected IntentService intentService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ApplicationService applicationService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected HostService hostService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -84,7 +88,7 @@ public class SdnIp implements SdnIpService {
private SdnIpFib fib;
private LeadershipEventListener leadershipEventListener =
- new InnerLeadershipEventListener();
+ new InnerLeadershipEventListener();
private ApplicationId appId;
private ControllerNode localControllerNode;
@@ -113,6 +117,10 @@ public class SdnIp implements SdnIpService {
leadershipService.addListener(leadershipEventListener);
leadershipService.runForLeadership(appId.name());
+
+ applicationService.registerDeactivateHook(appId,
+ intentSynchronizer::removeIntents);
+
}
@Deactivate