Brian O'Connor

refactoring OpticalPathIntent

Change-Id: Ic6ab6237237b2a5019851182b2869110bc5b1b73
...@@ -6,46 +6,45 @@ import org.onlab.onos.ApplicationId; ...@@ -6,46 +6,45 @@ import org.onlab.onos.ApplicationId;
6 import org.onlab.onos.net.ConnectPoint; 6 import org.onlab.onos.net.ConnectPoint;
7 import org.onlab.onos.net.Link; 7 import org.onlab.onos.net.Link;
8 import org.onlab.onos.net.Path; 8 import org.onlab.onos.net.Path;
9 -import org.onlab.onos.net.flow.TrafficSelector;
10 -import org.onlab.onos.net.flow.TrafficTreatment;
11 9
12 import com.google.common.base.MoreObjects; 10 import com.google.common.base.MoreObjects;
13 11
14 -public class OpticalPathIntent extends OpticalConnectivityIntent { 12 +public class OpticalPathIntent extends ConnectivityIntent {
13 +
14 + private final ConnectPoint src;
15 + private final ConnectPoint dst;
15 private final Path path; 16 private final Path path;
16 - // private final TrafficSelector opticalMatch; 17 +
17 - // private final TrafficTreatment opticalAction;
18 18
19 public OpticalPathIntent(ApplicationId appId, 19 public OpticalPathIntent(ApplicationId appId,
20 ConnectPoint src, 20 ConnectPoint src,
21 ConnectPoint dst, 21 ConnectPoint dst,
22 - TrafficSelector match,
23 - TrafficTreatment action,
24 Path path) { 22 Path path) {
25 - super(appId, src, dst); 23 + super(id(OpticalPathIntent.class, src, dst),
26 - // this.opticalMatch = match; 24 + appId, resources(path.links()), null, null);
27 - // this.opticalAction = action; 25 + this.src = src;
26 + this.dst = dst;
28 this.path = path; 27 this.path = path;
29 } 28 }
30 29
31 protected OpticalPathIntent() { 30 protected OpticalPathIntent() {
32 - // this.opticalMatch = null; 31 + this.src = null;
33 - // this.opticalAction = null; 32 + this.dst = null;
34 this.path = null; 33 this.path = null;
35 } 34 }
36 35
37 - public Path path() { 36 + public ConnectPoint src() {
38 - return path; 37 + return src;
39 } 38 }
40 -/* 39 +
41 - public TrafficSelector selector() { 40 + public ConnectPoint dst() {
42 - // return opticalMatch; 41 + return dst;
43 } 42 }
44 43
45 - public TrafficTreatment treatment() { 44 + public Path path() {
46 - // return opticalAction; 45 + return path;
47 } 46 }
48 -*/ 47 +
49 @Override 48 @Override
50 public boolean isInstallable() { 49 public boolean isInstallable() {
51 return true; 50 return true;
...@@ -55,10 +54,8 @@ public class OpticalPathIntent extends OpticalConnectivityIntent { ...@@ -55,10 +54,8 @@ public class OpticalPathIntent extends OpticalConnectivityIntent {
55 public String toString() { 54 public String toString() {
56 return MoreObjects.toStringHelper(getClass()) 55 return MoreObjects.toStringHelper(getClass())
57 .add("id", id()) 56 .add("id", id())
58 - //.add("match", opticalMatch) 57 + .add("ingressPort", src)
59 - //.add("action", opticalAction) 58 + .add("egressPort", dst)
60 - .add("ingressPort", this.getSrcConnectPoint())
61 - .add("egressPort", this.getDst())
62 .add("path", path) 59 .add("path", path)
63 .toString(); 60 .toString();
64 } 61 }
......
...@@ -14,16 +14,11 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -14,16 +14,11 @@ import org.apache.felix.scr.annotations.Reference;
14 import org.apache.felix.scr.annotations.ReferenceCardinality; 14 import org.apache.felix.scr.annotations.ReferenceCardinality;
15 import org.onlab.onos.CoreService; 15 import org.onlab.onos.CoreService;
16 import org.onlab.onos.net.ConnectPoint; 16 import org.onlab.onos.net.ConnectPoint;
17 -
18 import org.onlab.onos.net.Link; 17 import org.onlab.onos.net.Link;
19 import org.onlab.onos.net.Path; 18 import org.onlab.onos.net.Path;
20 -import org.onlab.onos.net.flow.TrafficSelector;
21 -import org.onlab.onos.net.flow.TrafficTreatment;
22 -
23 import org.onlab.onos.net.intent.Intent; 19 import org.onlab.onos.net.intent.Intent;
24 import org.onlab.onos.net.intent.IntentCompiler; 20 import org.onlab.onos.net.intent.IntentCompiler;
25 import org.onlab.onos.net.intent.IntentExtensionService; 21 import org.onlab.onos.net.intent.IntentExtensionService;
26 -
27 import org.onlab.onos.net.intent.OpticalConnectivityIntent; 22 import org.onlab.onos.net.intent.OpticalConnectivityIntent;
28 import org.onlab.onos.net.intent.OpticalPathIntent; 23 import org.onlab.onos.net.intent.OpticalPathIntent;
29 import org.onlab.onos.net.provider.ProviderId; 24 import org.onlab.onos.net.provider.ProviderId;
...@@ -32,7 +27,6 @@ import org.onlab.onos.net.topology.LinkWeight; ...@@ -32,7 +27,6 @@ import org.onlab.onos.net.topology.LinkWeight;
32 import org.onlab.onos.net.topology.PathService; 27 import org.onlab.onos.net.topology.PathService;
33 import org.onlab.onos.net.topology.Topology; 28 import org.onlab.onos.net.topology.Topology;
34 import org.onlab.onos.net.topology.TopologyEdge; 29 import org.onlab.onos.net.topology.TopologyEdge;
35 -
36 import org.onlab.onos.net.topology.TopologyService; 30 import org.onlab.onos.net.topology.TopologyService;
37 import org.slf4j.Logger; 31 import org.slf4j.Logger;
38 32
...@@ -88,15 +82,10 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical ...@@ -88,15 +82,10 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical
88 links.addAll(path.links()); 82 links.addAll(path.links());
89 //links.add(DefaultEdgeLink.createEdgeLink(intent.getDst(), false)); 83 //links.add(DefaultEdgeLink.createEdgeLink(intent.getDst(), false));
90 84
91 - TrafficSelector opticalSelector = null;
92 - TrafficTreatment opticalTreatment = null;
93 -
94 // create a new opticalPathIntent 85 // create a new opticalPathIntent
95 Intent newIntent = new OpticalPathIntent(intent.appId(), 86 Intent newIntent = new OpticalPathIntent(intent.appId(),
96 path.src(), 87 path.src(),
97 path.dst(), 88 path.dst(),
98 - opticalSelector,
99 - opticalTreatment,
100 path); 89 path);
101 90
102 retList.add(newIntent); 91 retList.add(newIntent);
......
...@@ -3,7 +3,6 @@ package org.onlab.onos.net.intent.impl; ...@@ -3,7 +3,6 @@ package org.onlab.onos.net.intent.impl;
3 import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder; 3 import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
4 import static org.slf4j.LoggerFactory.getLogger; 4 import static org.slf4j.LoggerFactory.getLogger;
5 5
6 -
7 import java.util.List; 6 import java.util.List;
8 7
9 import org.apache.felix.scr.annotations.Activate; 8 import org.apache.felix.scr.annotations.Activate;
...@@ -20,11 +19,11 @@ import org.onlab.onos.net.flow.DefaultTrafficSelector; ...@@ -20,11 +19,11 @@ import org.onlab.onos.net.flow.DefaultTrafficSelector;
20 import org.onlab.onos.net.flow.DefaultTrafficTreatment; 19 import org.onlab.onos.net.flow.DefaultTrafficTreatment;
21 import org.onlab.onos.net.flow.FlowRule; 20 import org.onlab.onos.net.flow.FlowRule;
22 import org.onlab.onos.net.flow.FlowRuleBatchEntry; 21 import org.onlab.onos.net.flow.FlowRuleBatchEntry;
22 +import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
23 import org.onlab.onos.net.flow.FlowRuleBatchOperation; 23 import org.onlab.onos.net.flow.FlowRuleBatchOperation;
24 import org.onlab.onos.net.flow.FlowRuleService; 24 import org.onlab.onos.net.flow.FlowRuleService;
25 import org.onlab.onos.net.flow.TrafficSelector; 25 import org.onlab.onos.net.flow.TrafficSelector;
26 import org.onlab.onos.net.flow.TrafficTreatment; 26 import org.onlab.onos.net.flow.TrafficTreatment;
27 -import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
28 import org.onlab.onos.net.intent.IntentExtensionService; 27 import org.onlab.onos.net.intent.IntentExtensionService;
29 import org.onlab.onos.net.intent.IntentInstaller; 28 import org.onlab.onos.net.intent.IntentInstaller;
30 import org.onlab.onos.net.intent.OpticalPathIntent; 29 import org.onlab.onos.net.intent.OpticalPathIntent;
...@@ -86,12 +85,12 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn ...@@ -86,12 +85,12 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
86 LinkResourceAllocations allocations = assignWavelength(intent); 85 LinkResourceAllocations allocations = assignWavelength(intent);
87 86
88 TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder(); 87 TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
89 - selectorBuilder.matchInport(intent.getSrcConnectPoint().port()); 88 + selectorBuilder.matchInport(intent.src().port());
90 89
91 TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder(); 90 TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
92 91
93 List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); 92 List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
94 - ConnectPoint prev = intent.getSrcConnectPoint(); 93 + ConnectPoint prev = intent.src();
95 94
96 //TODO throw exception if the lambda was not assigned successfully 95 //TODO throw exception if the lambda was not assigned successfully
97 for (Link link : intent.path().links()) { 96 for (Link link : intent.path().links()) {
...@@ -127,8 +126,8 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn ...@@ -127,8 +126,8 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
127 126
128 // build the last T port rule 127 // build the last T port rule
129 TrafficTreatment treatmentLast = builder() 128 TrafficTreatment treatmentLast = builder()
130 - .setOutput(intent.getDst().port()).build(); 129 + .setOutput(intent.dst().port()).build();
131 - FlowRule rule = new DefaultFlowRule(intent.getDst().deviceId(), 130 + FlowRule rule = new DefaultFlowRule(intent.dst().deviceId(),
132 selectorBuilder.build(), 131 selectorBuilder.build(),
133 treatmentLast, 132 treatmentLast,
134 100, 133 100,
...@@ -190,12 +189,12 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn ...@@ -190,12 +189,12 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
190 LinkResourceAllocations allocations = resourceService.getAllocations(intent.id()); 189 LinkResourceAllocations allocations = resourceService.getAllocations(intent.id());
191 190
192 TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder(); 191 TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
193 - selectorBuilder.matchInport(intent.getSrcConnectPoint().port()); 192 + selectorBuilder.matchInport(intent.src().port());
194 193
195 TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder(); 194 TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
196 195
197 List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); 196 List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
198 - ConnectPoint prev = intent.getSrcConnectPoint(); 197 + ConnectPoint prev = intent.src();
199 198
200 //TODO throw exception if the lambda was not retrieved successfully 199 //TODO throw exception if the lambda was not retrieved successfully
201 for (Link link : intent.path().links()) { 200 for (Link link : intent.path().links()) {
...@@ -231,8 +230,8 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn ...@@ -231,8 +230,8 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
231 230
232 // build the last T port rule 231 // build the last T port rule
233 TrafficTreatment treatmentLast = builder() 232 TrafficTreatment treatmentLast = builder()
234 - .setOutput(intent.getDst().port()).build(); 233 + .setOutput(intent.dst().port()).build();
235 - FlowRule rule = new DefaultFlowRule(intent.getDst().deviceId(), 234 + FlowRule rule = new DefaultFlowRule(intent.dst().deviceId(),
236 selectorBuilder.build(), 235 selectorBuilder.build(),
237 treatmentLast, 236 treatmentLast,
238 100, 237 100,
......