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