mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-17 02:11:38 +02:00
Including nodeId in DefaultPacketRequest so that we do not prematurely withdraw intercepts when a node is shutdown
Change-Id: If6ae0be8f53a4a158af37e6cc4938309a5e9991b
This commit is contained in:
parent
5f326879bd
commit
6f8b702324
@ -16,6 +16,8 @@
|
||||
package org.onosproject.net.packet;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
|
||||
import org.onosproject.cluster.NodeId;
|
||||
import org.onosproject.core.ApplicationId;
|
||||
import org.onosproject.net.flow.TrafficSelector;
|
||||
|
||||
@ -28,6 +30,7 @@ public final class DefaultPacketRequest implements PacketRequest {
|
||||
private final TrafficSelector selector;
|
||||
private final PacketPriority priority;
|
||||
private final ApplicationId appId;
|
||||
private final NodeId nodeId;
|
||||
|
||||
/**
|
||||
* Creates a new packet request.
|
||||
@ -35,29 +38,40 @@ public final class DefaultPacketRequest implements PacketRequest {
|
||||
* @param selector traffic selector
|
||||
* @param priority intercept priority
|
||||
* @param appId application id
|
||||
* @param nodeId identifier of node where request originated
|
||||
*/
|
||||
public DefaultPacketRequest(TrafficSelector selector, PacketPriority priority,
|
||||
ApplicationId appId) {
|
||||
ApplicationId appId,
|
||||
NodeId nodeId) {
|
||||
this.selector = selector;
|
||||
this.priority = priority;
|
||||
this.appId = appId;
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrafficSelector selector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPriority priority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationId appId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeId nodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(selector, priority, appId);
|
||||
return Objects.hash(selector, priority, appId, nodeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,7 +85,8 @@ public final class DefaultPacketRequest implements PacketRequest {
|
||||
final DefaultPacketRequest other = (DefaultPacketRequest) obj;
|
||||
return Objects.equals(this.selector, other.selector)
|
||||
&& Objects.equals(this.priority, other.priority)
|
||||
&& Objects.equals(this.appId, other.appId);
|
||||
&& Objects.equals(this.appId, other.appId)
|
||||
&& Objects.equals(this.nodeId, other.nodeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,6 +94,7 @@ public final class DefaultPacketRequest implements PacketRequest {
|
||||
return MoreObjects.toStringHelper(this.getClass())
|
||||
.add("selector", selector)
|
||||
.add("priority", priority)
|
||||
.add("appId", appId).toString();
|
||||
.add("appId", appId)
|
||||
.add("nodeId", nodeId).toString();
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.onosproject.net.packet;
|
||||
|
||||
import org.onosproject.cluster.NodeId;
|
||||
import org.onosproject.core.ApplicationId;
|
||||
import org.onosproject.net.flow.TrafficSelector;
|
||||
|
||||
@ -44,4 +45,10 @@ public interface PacketRequest {
|
||||
*/
|
||||
ApplicationId appId();
|
||||
|
||||
/**
|
||||
* Obtain the node id.
|
||||
*
|
||||
* @return an node id
|
||||
*/
|
||||
NodeId nodeId();
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ package org.onosproject.net;
|
||||
import org.onlab.junit.TestUtils;
|
||||
import org.onlab.packet.ChassisId;
|
||||
import org.onosproject.TestApplicationId;
|
||||
import org.onosproject.cluster.NodeId;
|
||||
import org.onosproject.core.ApplicationId;
|
||||
import org.onosproject.event.EventDeliveryService;
|
||||
import org.onosproject.net.provider.ProviderId;
|
||||
@ -44,6 +45,7 @@ public final class NetTestTools {
|
||||
|
||||
public static final ProviderId PID = new ProviderId("of", "foo");
|
||||
public static final ApplicationId APP_ID = new TestApplicationId("foo");
|
||||
public static final NodeId NODE_ID = new NodeId("node1");
|
||||
|
||||
// Short-hand for producing a device id from a string
|
||||
public static DeviceId did(String id) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
package org.onosproject.net.packet;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.onosproject.cluster.NodeId;
|
||||
import org.onosproject.core.DefaultApplicationId;
|
||||
import org.onosproject.net.NetTestTools;
|
||||
import org.onosproject.net.flow.DefaultTrafficSelector;
|
||||
@ -40,23 +41,28 @@ public class DefaultPacketRequestTest {
|
||||
private final DefaultPacketRequest packetRequest1 =
|
||||
new DefaultPacketRequest(DefaultTrafficSelector.emptySelector(),
|
||||
PacketPriority.CONTROL,
|
||||
NetTestTools.APP_ID);
|
||||
NetTestTools.APP_ID,
|
||||
NetTestTools.NODE_ID);
|
||||
private final DefaultPacketRequest sameAsacketRequest1 =
|
||||
new DefaultPacketRequest(DefaultTrafficSelector.emptySelector(),
|
||||
PacketPriority.CONTROL,
|
||||
NetTestTools.APP_ID);
|
||||
NetTestTools.APP_ID,
|
||||
NetTestTools.NODE_ID);
|
||||
private final DefaultPacketRequest packetRequest2 =
|
||||
new DefaultPacketRequest(selector,
|
||||
PacketPriority.CONTROL,
|
||||
NetTestTools.APP_ID);
|
||||
NetTestTools.APP_ID,
|
||||
NetTestTools.NODE_ID);
|
||||
private final DefaultPacketRequest packetRequest3 =
|
||||
new DefaultPacketRequest(DefaultTrafficSelector.emptySelector(),
|
||||
PacketPriority.REACTIVE,
|
||||
NetTestTools.APP_ID);
|
||||
NetTestTools.APP_ID,
|
||||
NetTestTools.NODE_ID);
|
||||
private final DefaultPacketRequest packetRequest4 =
|
||||
new DefaultPacketRequest(DefaultTrafficSelector.emptySelector(),
|
||||
PacketPriority.CONTROL,
|
||||
new DefaultApplicationId(1, "foo"));
|
||||
new DefaultApplicationId(1, "foo"),
|
||||
new NodeId("node1"));
|
||||
|
||||
/**
|
||||
* Tests the operation of the equals(), toAstring() and hashCode() methods.
|
||||
|
@ -17,12 +17,15 @@ package org.onosproject.net.packet.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
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.cluster.ClusterService;
|
||||
import org.onosproject.cluster.NodeId;
|
||||
import org.onosproject.core.ApplicationId;
|
||||
import org.onosproject.core.CoreService;
|
||||
import org.onosproject.net.Device;
|
||||
@ -86,6 +89,9 @@ public class PacketManager
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
private CoreService coreService;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
private ClusterService clusterService;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
private DeviceService deviceService;
|
||||
|
||||
@ -105,11 +111,13 @@ public class PacketManager
|
||||
private final List<ProcessorEntry> processors = Lists.newCopyOnWriteArrayList();
|
||||
|
||||
private ApplicationId appId;
|
||||
private NodeId localNodeId;
|
||||
|
||||
@Activate
|
||||
public void activate() {
|
||||
eventHandlingExecutor = Executors.newSingleThreadExecutor(
|
||||
groupedThreads("onos/net/packet", "event-handler"));
|
||||
localNodeId = clusterService.getLocalNode().id();
|
||||
appId = coreService.getAppId(CoreService.CORE_APP_NAME);
|
||||
store.setDelegate(delegate);
|
||||
deviceService.addListener(deviceListener);
|
||||
@ -167,7 +175,7 @@ public class PacketManager
|
||||
checkNotNull(selector, "Selector cannot be null");
|
||||
checkNotNull(appId, "Application ID cannot be null");
|
||||
|
||||
PacketRequest request = new DefaultPacketRequest(selector, priority, appId);
|
||||
PacketRequest request = new DefaultPacketRequest(selector, priority, appId, localNodeId);
|
||||
store.requestPackets(request);
|
||||
}
|
||||
|
||||
@ -178,7 +186,7 @@ public class PacketManager
|
||||
checkNotNull(selector, "Selector cannot be null");
|
||||
checkNotNull(appId, "Application ID cannot be null");
|
||||
|
||||
PacketRequest request = new DefaultPacketRequest(selector, priority, appId);
|
||||
PacketRequest request = new DefaultPacketRequest(selector, priority, appId, localNodeId);
|
||||
store.cancelPackets(request);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user