Brian O'Connor

Adding mac to intentperf selector and making Distributed flow store smaller

Change-Id: Id057ec6337519617dab8a5e352feb2922b40897d
...@@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Activate; ...@@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Activate;
22 import org.apache.felix.scr.annotations.Component; 22 import org.apache.felix.scr.annotations.Component;
23 import org.apache.felix.scr.annotations.Deactivate; 23 import org.apache.felix.scr.annotations.Deactivate;
24 import org.apache.felix.scr.annotations.Reference; 24 import org.apache.felix.scr.annotations.Reference;
25 +import org.onlab.packet.MacAddress;
25 import org.onlab.util.Counter; 26 import org.onlab.util.Counter;
26 import org.onosproject.cluster.ClusterService; 27 import org.onosproject.cluster.ClusterService;
27 import org.onosproject.core.ApplicationId; 28 import org.onosproject.core.ApplicationId;
...@@ -200,7 +201,8 @@ public class IntentPerfInstaller { ...@@ -200,7 +201,8 @@ public class IntentPerfInstaller {
200 } 201 }
201 202
202 //FIXME we currently ignore the path length and always use the same device 203 //FIXME we currently ignore the path length and always use the same device
203 - TrafficSelector selector = DefaultTrafficSelector.builder().build(); 204 + TrafficSelector selector = DefaultTrafficSelector.builder()
205 + .matchEthDst(MacAddress.valueOf(count)).build();
204 TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); 206 TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
205 ConnectPoint ingress = new ConnectPoint(ingressDevice.id(), PortNumber.portNumber(1)); 207 ConnectPoint ingress = new ConnectPoint(ingressDevice.id(), PortNumber.portNumber(1));
206 ConnectPoint egress = new ConnectPoint(ingressDevice.id(), PortNumber.portNumber(2)); 208 ConnectPoint egress = new ConnectPoint(ingressDevice.id(), PortNumber.portNumber(2));
......
...@@ -19,7 +19,7 @@ import com.google.common.collect.ImmutableList; ...@@ -19,7 +19,7 @@ import com.google.common.collect.ImmutableList;
19 import com.google.common.collect.Iterables; 19 import com.google.common.collect.Iterables;
20 import com.google.common.collect.Maps; 20 import com.google.common.collect.Maps;
21 import com.google.common.collect.Sets; 21 import com.google.common.collect.Sets;
22 - 22 +import org.apache.commons.lang.math.RandomUtils;
23 import org.apache.felix.scr.annotations.Activate; 23 import org.apache.felix.scr.annotations.Activate;
24 import org.apache.felix.scr.annotations.Component; 24 import org.apache.felix.scr.annotations.Component;
25 import org.apache.felix.scr.annotations.Deactivate; 25 import org.apache.felix.scr.annotations.Deactivate;
...@@ -53,7 +53,6 @@ import org.onosproject.net.flow.FlowRuleStore; ...@@ -53,7 +53,6 @@ import org.onosproject.net.flow.FlowRuleStore;
53 import org.onosproject.net.flow.FlowRuleStoreDelegate; 53 import org.onosproject.net.flow.FlowRuleStoreDelegate;
54 import org.onosproject.net.flow.StoredFlowEntry; 54 import org.onosproject.net.flow.StoredFlowEntry;
55 import org.onosproject.store.AbstractStore; 55 import org.onosproject.store.AbstractStore;
56 -import org.onosproject.store.Timestamp;
57 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 56 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
58 import org.onosproject.store.cluster.messaging.ClusterMessage; 57 import org.onosproject.store.cluster.messaging.ClusterMessage;
59 import org.onosproject.store.cluster.messaging.ClusterMessageHandler; 58 import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
...@@ -625,15 +624,8 @@ public class DistributedFlowRuleStore ...@@ -625,15 +624,8 @@ public class DistributedFlowRuleStore
625 .register(MastershipBasedTimestamp.class); 624 .register(MastershipBasedTimestamp.class);
626 625
627 private final ClockService<FlowId, StoredFlowEntry> clockService = 626 private final ClockService<FlowId, StoredFlowEntry> clockService =
628 - new ClockService<FlowId, StoredFlowEntry>() { 627 + (flowId, flowEntry) ->
629 - @Override 628 + (flowEntry == null) ? null : deviceClockService.getTimestamp(flowEntry.deviceId());
630 - public Timestamp getTimestamp(FlowId flowId, StoredFlowEntry flowEntry) {
631 - if (flowEntry == null) {
632 - return null;
633 - }
634 - return deviceClockService.getTimestamp(flowEntry.deviceId());
635 - }
636 - };
637 629
638 private final EventuallyConsistentMap<FlowId, StoredFlowEntry> backupMap = 630 private final EventuallyConsistentMap<FlowId, StoredFlowEntry> backupMap =
639 new EventuallyConsistentMapImpl<>("flow-backup", 631 new EventuallyConsistentMapImpl<>("flow-backup",
...@@ -653,8 +645,8 @@ public class DistributedFlowRuleStore ...@@ -653,8 +645,8 @@ public class DistributedFlowRuleStore
653 if (nodes.isEmpty()) { 645 if (nodes.isEmpty()) {
654 return ImmutableList.of(); 646 return ImmutableList.of();
655 } else { 647 } else {
656 - Collections.shuffle(nodes); 648 + // get a random peer
657 - return ImmutableList.of(nodes.get(0)); 649 + return ImmutableList.of(nodes.get(RandomUtils.nextInt(nodes.size())));
658 } 650 }
659 } 651 }
660 652
......