Praseed Balakrishnan

Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next

Showing 138 changed files with 2400 additions and 234 deletions
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5 + <modelVersion>4.0.0</modelVersion>
6 +
7 + <parent>
8 + <groupId>org.onlab.onos</groupId>
9 + <artifactId>onos-app-metrics</artifactId>
10 + <version>1.0.0-SNAPSHOT</version>
11 + <relativePath>../pom.xml</relativePath>
12 + </parent>
13 +
14 + <artifactId>onos-app-metrics-intent</artifactId>
15 + <packaging>bundle</packaging>
16 +
17 + <description>ONOS intent metrics application</description>
18 +
19 + <dependencies>
20 + <dependency>
21 + <groupId>org.onlab.onos</groupId>
22 + <artifactId>onos-cli</artifactId>
23 + <version>${project.version}</version>
24 + </dependency>
25 +
26 + <dependency>
27 + <groupId>org.apache.karaf.shell</groupId>
28 + <artifactId>org.apache.karaf.shell.console</artifactId>
29 + </dependency>
30 + </dependencies>
31 +
32 +</project>
1 +package org.onlab.onos.metrics.intent;
2 +
3 +import java.util.List;
4 +
5 +import com.codahale.metrics.Gauge;
6 +import com.codahale.metrics.Meter;
7 +import org.onlab.onos.net.intent.IntentEvent;
8 +
9 +/**
10 + * Service interface exported by IntentMetrics.
11 + */
12 +public interface IntentMetricsService {
13 + /**
14 + * Gets the last saved intent events.
15 + *
16 + * @return the last saved intent events.
17 + */
18 + public List<IntentEvent> getEvents();
19 +
20 + /**
21 + * Gets the Metrics' Gauge for the intent SUBMITTED event timestamp
22 + * (ms from the epoch).
23 + *
24 + * @return the Metrics' Gauge for the intent SUBMITTED event timestamp
25 + * (ms from the epoch)
26 + */
27 + public Gauge<Long> intentSubmittedTimestampEpochMsGauge();
28 +
29 + /**
30 + * Gets the Metrics' Gauge for the intent INSTALLED event timestamp
31 + * (ms from the epoch).
32 + *
33 + * @return the Metrics' Gauge for the intent INSTALLED event timestamp
34 + * (ms from the epoch)
35 + */
36 + public Gauge<Long> intentInstalledTimestampEpochMsGauge();
37 +
38 + /**
39 + * Gets the Metrics' Gauge for the intent WITHDRAW_REQUESTED event
40 + * timestamp (ms from the epoch).
41 + *
42 + * TODO: This intent event is not implemented yet.
43 + *
44 + * @return the Metrics' Gauge for the intent WITHDRAW_REQUESTED event
45 + * timestamp (ms from the epoch)
46 + */
47 + public Gauge<Long> intentWithdrawRequestedTimestampEpochMsGauge();
48 +
49 + /**
50 + * Gets the Metrics' Gauge for the intent WITHDRAWN event timestamp
51 + * (ms from the epoch).
52 + *
53 + * @return the Metrics' Gauge for the intent WITHDRAWN event timestamp
54 + * (ms from the epoch)
55 + */
56 + public Gauge<Long> intentWithdrawnTimestampEpochMsGauge();
57 +
58 + /**
59 + * Gets the Metrics' Meter for the submitted intents event rate.
60 + *
61 + * @return the Metrics' Meter for the submitted intents event rate
62 + */
63 + public Meter intentSubmittedRateMeter();
64 +
65 + /**
66 + * Gets the Metrics' Meter for the installed intents event rate.
67 + *
68 + * @return the Metrics' Meter for the installed intent event rate
69 + */
70 + public Meter intentInstalledRateMeter();
71 +
72 + /**
73 + * Gets the Metrics' Meter for the withdraw requested intents event rate.
74 + *
75 + * @return the Metrics' Meter for the withdraw requested intents event rate
76 + */
77 + public Meter intentWithdrawRequestedRateMeter();
78 +
79 + /**
80 + * Gets the Metrics' Meter for the withdraw completed intents event rate.
81 + *
82 + * @return the Metrics' Meter for the withdraw completed intents event rate
83 + */
84 + public Meter intentWithdrawnRateMeter();
85 +}
1 +package org.onlab.onos.metrics.intent.cli;
2 +
3 +import java.util.List;
4 +
5 +import com.fasterxml.jackson.databind.JsonNode;
6 +import com.fasterxml.jackson.databind.ObjectMapper;
7 +import com.fasterxml.jackson.databind.node.ArrayNode;
8 +import com.fasterxml.jackson.databind.node.ObjectNode;
9 +import org.apache.karaf.shell.commands.Command;
10 +import org.onlab.onos.cli.AbstractShellCommand;
11 +import org.onlab.onos.metrics.intent.IntentMetricsService;
12 +import org.onlab.onos.net.intent.IntentEvent;
13 +
14 +/**
15 + * Command to show the list of last intent events.
16 + */
17 +@Command(scope = "onos", name = "intents-events",
18 + description = "Lists the last intent events")
19 +public class IntentEventsListCommand extends AbstractShellCommand {
20 +
21 + private static final String FORMAT_EVENT = "Event=%s";
22 +
23 + @Override
24 + protected void execute() {
25 + IntentMetricsService service = get(IntentMetricsService.class);
26 +
27 + if (outputJson()) {
28 + print("%s", json(service.getEvents()));
29 + } else {
30 + for (IntentEvent event : service.getEvents()) {
31 + print(FORMAT_EVENT, event);
32 + print(""); // Extra empty line for clarity
33 + }
34 + }
35 + }
36 +
37 + /**
38 + * Produces a JSON array of intent events.
39 + *
40 + * @param intentEvents the intent events with the data
41 + * @return JSON array with the intent events
42 + */
43 + private JsonNode json(List<IntentEvent> intentEvents) {
44 + ObjectMapper mapper = new ObjectMapper();
45 + ArrayNode result = mapper.createArrayNode();
46 +
47 + for (IntentEvent event : intentEvents) {
48 + result.add(json(mapper, event));
49 + }
50 + return result;
51 + }
52 +
53 + /**
54 + * Produces JSON object for a intent event.
55 + *
56 + * @param mapper the JSON object mapper to use
57 + * @param intentEvent the intent event with the data
58 + * @return JSON object for the intent event
59 + */
60 + private ObjectNode json(ObjectMapper mapper, IntentEvent intentEvent) {
61 + ObjectNode result = mapper.createObjectNode();
62 +
63 + result.put("time", intentEvent.time())
64 + .put("type", intentEvent.type().toString())
65 + .put("event", intentEvent.toString());
66 + return result;
67 + }
68 +}
1 +package org.onlab.onos.metrics.intent.cli;
2 +
3 +import java.io.IOException;
4 +import java.util.concurrent.TimeUnit;
5 +
6 +import com.codahale.metrics.Gauge;
7 +import com.codahale.metrics.Meter;
8 +import com.codahale.metrics.json.MetricsModule;
9 +import com.fasterxml.jackson.core.JsonProcessingException;
10 +import com.fasterxml.jackson.databind.JsonNode;
11 +import com.fasterxml.jackson.databind.ObjectMapper;
12 +import com.fasterxml.jackson.databind.node.ObjectNode;
13 +import org.apache.karaf.shell.commands.Command;
14 +import org.onlab.onos.cli.AbstractShellCommand;
15 +import org.onlab.onos.metrics.intent.IntentMetricsService;
16 +
17 +/**
18 + * Command to show the intent events metrics.
19 + */
20 +@Command(scope = "onos", name = "intents-events-metrics",
21 + description = "Lists intent events metrics")
22 +public class IntentEventsMetricsCommand extends AbstractShellCommand {
23 +
24 + private static final String FORMAT_GAUGE =
25 + "Intent %s Event Timestamp (ms from epoch)=%d";
26 + private static final String FORMAT_METER =
27 + "Intent %s Events count=%d rate(events/sec) mean=%f m1=%f m5=%f m15=%f";
28 +
29 + @Override
30 + protected void execute() {
31 + IntentMetricsService service = get(IntentMetricsService.class);
32 + Gauge<Long> gauge;
33 + Meter meter;
34 +
35 + if (outputJson()) {
36 + ObjectMapper mapper = new ObjectMapper()
37 + .registerModule(new MetricsModule(TimeUnit.SECONDS,
38 + TimeUnit.MILLISECONDS,
39 + false));
40 + ObjectNode result = mapper.createObjectNode();
41 + //
42 + gauge = service.intentSubmittedTimestampEpochMsGauge();
43 + result.put("intentSubmittedTimestamp", json(mapper, gauge));
44 + gauge = service.intentInstalledTimestampEpochMsGauge();
45 + result.put("intentInstalledTimestamp", json(mapper, gauge));
46 + gauge = service.intentWithdrawRequestedTimestampEpochMsGauge();
47 + result.put("intentWithdrawRequestedTimestamp",
48 + json(mapper, gauge));
49 + gauge = service.intentWithdrawnTimestampEpochMsGauge();
50 + result.put("intentWithdrawnTimestamp", json(mapper, gauge));
51 + //
52 + meter = service.intentSubmittedRateMeter();
53 + result.put("intentSubmittedRate", json(mapper, meter));
54 + meter = service.intentInstalledRateMeter();
55 + result.put("intentInstalledRate", json(mapper, meter));
56 + meter = service.intentWithdrawRequestedRateMeter();
57 + result.put("intentWithdrawRequestedRate", json(mapper, meter));
58 + meter = service.intentWithdrawnRateMeter();
59 + result.put("intentWithdrawnRate", json(mapper, meter));
60 + //
61 + print("%s", result);
62 + } else {
63 + gauge = service.intentSubmittedTimestampEpochMsGauge();
64 + printGauge("Submitted", gauge);
65 + gauge = service.intentInstalledTimestampEpochMsGauge();
66 + printGauge("Installed", gauge);
67 + gauge = service.intentWithdrawRequestedTimestampEpochMsGauge();
68 + printGauge("Withdraw Requested", gauge);
69 + gauge = service.intentWithdrawnTimestampEpochMsGauge();
70 + printGauge("Withdrawn", gauge);
71 + //
72 + meter = service.intentSubmittedRateMeter();
73 + printMeter("Submitted", meter);
74 + meter = service.intentInstalledRateMeter();
75 + printMeter("Installed", meter);
76 + meter = service.intentWithdrawRequestedRateMeter();
77 + printMeter("Withdraw Requested", meter);
78 + meter = service.intentWithdrawnRateMeter();
79 + printMeter("Withdrawn", meter);
80 + }
81 + }
82 +
83 + /**
84 + * Produces JSON node for an Object.
85 + *
86 + * @param mapper the JSON object mapper to use
87 + * @param object the Object with the data
88 + * @return JSON node for the Object
89 + */
90 + private JsonNode json(ObjectMapper mapper, Object object) {
91 + //
92 + // NOTE: The API for custom serializers is incomplete,
93 + // hence we have to parse the JSON string to create JsonNode.
94 + //
95 + try {
96 + final String objectJson = mapper.writeValueAsString(object);
97 + JsonNode objectNode = mapper.readTree(objectJson);
98 + return objectNode;
99 + } catch (JsonProcessingException e) {
100 + log.error("Error writing value as JSON string", e);
101 + } catch (IOException e) {
102 + log.error("Error writing value as JSON string", e);
103 + }
104 + return null;
105 + }
106 +
107 + /**
108 + * Prints a Gauge.
109 + *
110 + * @param operationStr the string with the intent operation to print
111 + * @param gauge the Gauge to print
112 + */
113 + private void printGauge(String operationStr, Gauge<Long> gauge) {
114 + print(FORMAT_GAUGE, operationStr, gauge.getValue());
115 + }
116 +
117 + /**
118 + * Prints a Meter.
119 + *
120 + * @param operationStr the string with the intent operation to print
121 + * @param meter the Meter to print
122 + */
123 + private void printMeter(String operationStr, Meter meter) {
124 + TimeUnit rateUnit = TimeUnit.SECONDS;
125 + double rateFactor = rateUnit.toSeconds(1);
126 + print(FORMAT_METER, operationStr, meter.getCount(),
127 + meter.getMeanRate() * rateFactor,
128 + meter.getOneMinuteRate() * rateFactor,
129 + meter.getFiveMinuteRate() * rateFactor,
130 + meter.getFifteenMinuteRate() * rateFactor);
131 + }
132 +}
1 +/**
2 + * ONOS Intent Metrics Application that collects intent-related metrics.
3 + */
4 +package org.onlab.onos.metrics.intent;
1 +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
2 +
3 + <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
4 + <command>
5 + <action class="org.onlab.onos.metrics.intent.cli.IntentEventsListCommand"/>
6 + </command>
7 + <command>
8 + <action class="org.onlab.onos.metrics.intent.cli.IntentEventsMetricsCommand"/>
9 + </command>
10 + </command-bundle>
11 +
12 +</blueprint>
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 <description>ONOS metrics applications</description> 17 <description>ONOS metrics applications</description>
18 18
19 <modules> 19 <modules>
20 + <module>intent</module>
20 <module>topology</module> 21 <module>topology</module>
21 </modules> 22 </modules>
22 23
......
...@@ -18,6 +18,15 @@ import org.onlab.metrics.MetricsComponent; ...@@ -18,6 +18,15 @@ import org.onlab.metrics.MetricsComponent;
18 import org.onlab.metrics.MetricsFeature; 18 import org.onlab.metrics.MetricsFeature;
19 import org.onlab.metrics.MetricsService; 19 import org.onlab.metrics.MetricsService;
20 import org.onlab.onos.event.Event; 20 import org.onlab.onos.event.Event;
21 +import org.onlab.onos.net.device.DeviceEvent;
22 +import org.onlab.onos.net.device.DeviceListener;
23 +import org.onlab.onos.net.device.DeviceService;
24 +import org.onlab.onos.net.host.HostEvent;
25 +import org.onlab.onos.net.host.HostListener;
26 +import org.onlab.onos.net.host.HostService;
27 +import org.onlab.onos.net.link.LinkEvent;
28 +import org.onlab.onos.net.link.LinkListener;
29 +import org.onlab.onos.net.link.LinkService;
21 import org.onlab.onos.net.topology.TopologyEvent; 30 import org.onlab.onos.net.topology.TopologyEvent;
22 import org.onlab.onos.net.topology.TopologyListener; 31 import org.onlab.onos.net.topology.TopologyListener;
23 import org.onlab.onos.net.topology.TopologyService; 32 import org.onlab.onos.net.topology.TopologyService;
...@@ -28,14 +37,26 @@ import org.slf4j.Logger; ...@@ -28,14 +37,26 @@ import org.slf4j.Logger;
28 */ 37 */
29 @Component(immediate = true) 38 @Component(immediate = true)
30 @Service 39 @Service
31 -public class TopologyMetrics implements TopologyMetricsService, 40 +public class TopologyMetrics implements TopologyMetricsService {
32 - TopologyListener {
33 private static final Logger log = getLogger(TopologyMetrics.class); 41 private static final Logger log = getLogger(TopologyMetrics.class);
34 42
35 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 43 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
44 + protected DeviceService deviceService;
45 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
46 + protected HostService hostService;
47 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 + protected LinkService linkService;
49 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
36 protected TopologyService topologyService; 50 protected TopologyService topologyService;
37 - private LinkedList<TopologyEvent> lastEvents = new LinkedList<>(); 51 +
38 - private static final int LAST_EVENTS_MAX_N = 10; 52 + private LinkedList<Event> lastEvents = new LinkedList<>();
53 + private static final int LAST_EVENTS_MAX_N = 100;
54 +
55 + private final DeviceListener deviceListener = new InnerDeviceListener();
56 + private final HostListener hostListener = new InnerHostListener();
57 + private final LinkListener linkListener = new InnerLinkListener();
58 + private final TopologyListener topologyListener =
59 + new InnerTopologyListener();
39 60
40 // 61 //
41 // Metrics 62 // Metrics
...@@ -61,22 +82,33 @@ public class TopologyMetrics implements TopologyMetricsService, ...@@ -61,22 +82,33 @@ public class TopologyMetrics implements TopologyMetricsService,
61 protected void activate() { 82 protected void activate() {
62 clear(); 83 clear();
63 registerMetrics(); 84 registerMetrics();
64 - topologyService.addListener(this); 85 +
86 + // Register for all topology-related events
87 + deviceService.addListener(deviceListener);
88 + hostService.addListener(hostListener);
89 + linkService.addListener(linkListener);
90 + topologyService.addListener(topologyListener);
91 +
65 log.info("ONOS Topology Metrics started."); 92 log.info("ONOS Topology Metrics started.");
66 } 93 }
67 94
68 @Deactivate 95 @Deactivate
69 public void deactivate() { 96 public void deactivate() {
70 - topologyService.removeListener(this); 97 + // De-register from all topology-related events
98 + deviceService.removeListener(deviceListener);
99 + hostService.removeListener(hostListener);
100 + linkService.removeListener(linkListener);
101 + topologyService.removeListener(topologyListener);
102 +
71 removeMetrics(); 103 removeMetrics();
72 clear(); 104 clear();
73 log.info("ONOS Topology Metrics stopped."); 105 log.info("ONOS Topology Metrics stopped.");
74 } 106 }
75 107
76 @Override 108 @Override
77 - public List<TopologyEvent> getEvents() { 109 + public List<Event> getEvents() {
78 synchronized (lastEvents) { 110 synchronized (lastEvents) {
79 - return ImmutableList.<TopologyEvent>copyOf(lastEvents); 111 + return ImmutableList.<Event>copyOf(lastEvents);
80 } 112 }
81 } 113 }
82 114
...@@ -90,27 +122,22 @@ public class TopologyMetrics implements TopologyMetricsService, ...@@ -90,27 +122,22 @@ public class TopologyMetrics implements TopologyMetricsService,
90 return eventRateMeter; 122 return eventRateMeter;
91 } 123 }
92 124
93 - @Override 125 + /**
94 - public void event(TopologyEvent event) { 126 + * Records an event.
95 - lastEventTimestampEpochMs = System.currentTimeMillis(); 127 + *
96 - // 128 + * @param event the event to record
97 - // NOTE: If we want to count each "reason" as a separate event, 129 + * @param updateEventRateMeter if true, update the Event Rate Meter
98 - // then we should use 'event.reason().size()' instead of '1' to 130 + */
99 - // mark the meter below. 131 + private void recordEvent(Event event, boolean updateEventRateMeter) {
100 - //
101 - eventRateMeter.mark(1);
102 -
103 - log.debug("Topology Event: time = {} type = {} subject = {}",
104 - event.time(), event.type(), event.subject());
105 - for (Event reason : event.reasons()) {
106 - log.debug("Topology Event Reason: time = {} type = {} subject = {}",
107 - reason.time(), reason.type(), reason.subject());
108 - }
109 -
110 - //
111 - // Keep only the last N events, where N = LAST_EVENTS_MAX_N
112 - //
113 synchronized (lastEvents) { 132 synchronized (lastEvents) {
133 + lastEventTimestampEpochMs = System.currentTimeMillis();
134 + if (updateEventRateMeter) {
135 + eventRateMeter.mark(1);
136 + }
137 +
138 + //
139 + // Keep only the last N events, where N = LAST_EVENTS_MAX_N
140 + //
114 while (lastEvents.size() >= LAST_EVENTS_MAX_N) { 141 while (lastEvents.size() >= LAST_EVENTS_MAX_N) {
115 lastEvents.remove(); 142 lastEvents.remove();
116 } 143 }
...@@ -119,11 +146,67 @@ public class TopologyMetrics implements TopologyMetricsService, ...@@ -119,11 +146,67 @@ public class TopologyMetrics implements TopologyMetricsService,
119 } 146 }
120 147
121 /** 148 /**
149 + * Inner Device Event Listener class.
150 + */
151 + private class InnerDeviceListener implements DeviceListener {
152 + @Override
153 + public void event(DeviceEvent event) {
154 + recordEvent(event, true);
155 + log.debug("Device Event: time = {} type = {} event = {}",
156 + event.time(), event.type(), event);
157 + }
158 + }
159 +
160 + /**
161 + * Inner Host Event Listener class.
162 + */
163 + private class InnerHostListener implements HostListener {
164 + @Override
165 + public void event(HostEvent event) {
166 + recordEvent(event, true);
167 + log.debug("Host Event: time = {} type = {} event = {}",
168 + event.time(), event.type(), event);
169 + }
170 + }
171 +
172 + /**
173 + * Inner Link Event Listener class.
174 + */
175 + private class InnerLinkListener implements LinkListener {
176 + @Override
177 + public void event(LinkEvent event) {
178 + recordEvent(event, true);
179 + log.debug("Link Event: time = {} type = {} event = {}",
180 + event.time(), event.type(), event);
181 + }
182 + }
183 +
184 + /**
185 + * Inner Topology Event Listener class.
186 + */
187 + private class InnerTopologyListener implements TopologyListener {
188 + @Override
189 + public void event(TopologyEvent event) {
190 + //
191 + // NOTE: Don't update the eventRateMeter, because the real
192 + // events are already captured/counted.
193 + //
194 + recordEvent(event, false);
195 + log.debug("Topology Event: time = {} type = {} event = {}",
196 + event.time(), event.type(), event);
197 + for (Event reason : event.reasons()) {
198 + log.debug("Topology Event Reason: time = {} type = {} event = {}",
199 + reason.time(), reason.type(), reason);
200 + }
201 + }
202 + }
203 +
204 + /**
122 * Clears the internal state. 205 * Clears the internal state.
123 */ 206 */
124 private void clear() { 207 private void clear() {
125 - lastEventTimestampEpochMs = 0;
126 synchronized (lastEvents) { 208 synchronized (lastEvents) {
209 + lastEventTimestampEpochMs = 0;
127 lastEvents.clear(); 210 lastEvents.clear();
128 } 211 }
129 } 212 }
......
...@@ -4,7 +4,7 @@ import java.util.List; ...@@ -4,7 +4,7 @@ import java.util.List;
4 4
5 import com.codahale.metrics.Gauge; 5 import com.codahale.metrics.Gauge;
6 import com.codahale.metrics.Meter; 6 import com.codahale.metrics.Meter;
7 -import org.onlab.onos.net.topology.TopologyEvent; 7 +import org.onlab.onos.event.Event;
8 8
9 /** 9 /**
10 * Service interface exported by TopologyMetrics. 10 * Service interface exported by TopologyMetrics.
...@@ -15,7 +15,7 @@ public interface TopologyMetricsService { ...@@ -15,7 +15,7 @@ public interface TopologyMetricsService {
15 * 15 *
16 * @return the last saved topology events. 16 * @return the last saved topology events.
17 */ 17 */
18 - public List<TopologyEvent> getEvents(); 18 + public List<Event> getEvents();
19 19
20 /** 20 /**
21 * Gets the Metrics' Gauge for the last topology event timestamp 21 * Gets the Metrics' Gauge for the last topology event timestamp
......
...@@ -19,10 +19,8 @@ import org.onlab.onos.net.topology.TopologyEvent; ...@@ -19,10 +19,8 @@ import org.onlab.onos.net.topology.TopologyEvent;
19 description = "Lists the last topology events") 19 description = "Lists the last topology events")
20 public class TopologyEventsListCommand extends AbstractShellCommand { 20 public class TopologyEventsListCommand extends AbstractShellCommand {
21 21
22 - private static final String FORMAT_EVENT = 22 + private static final String FORMAT_EVENT = "Event=%s";
23 - "Topology Event time=%d type=%s subject=%s"; 23 + private static final String FORMAT_REASON = " Reason=%s";
24 - private static final String FORMAT_REASON =
25 - " Reason time=%d type=%s subject=%s";
26 24
27 @Override 25 @Override
28 protected void execute() { 26 protected void execute() {
...@@ -31,12 +29,13 @@ public class TopologyEventsListCommand extends AbstractShellCommand { ...@@ -31,12 +29,13 @@ public class TopologyEventsListCommand extends AbstractShellCommand {
31 if (outputJson()) { 29 if (outputJson()) {
32 print("%s", json(service.getEvents())); 30 print("%s", json(service.getEvents()));
33 } else { 31 } else {
34 - for (TopologyEvent event : service.getEvents()) { 32 + for (Event event : service.getEvents()) {
35 - print(FORMAT_EVENT, event.time(), event.type(), 33 + print(FORMAT_EVENT, event);
36 - event.subject()); 34 + if (event instanceof TopologyEvent) {
37 - for (Event reason : event.reasons()) { 35 + TopologyEvent topologyEvent = (TopologyEvent) event;
38 - print(FORMAT_REASON, reason.time(), reason.type(), 36 + for (Event reason : topologyEvent.reasons()) {
39 - reason.subject()); 37 + print(FORMAT_REASON, reason);
38 + }
40 } 39 }
41 print(""); // Extra empty line for clarity 40 print(""); // Extra empty line for clarity
42 } 41 }
...@@ -46,14 +45,14 @@ public class TopologyEventsListCommand extends AbstractShellCommand { ...@@ -46,14 +45,14 @@ public class TopologyEventsListCommand extends AbstractShellCommand {
46 /** 45 /**
47 * Produces a JSON array of topology events. 46 * Produces a JSON array of topology events.
48 * 47 *
49 - * @param topologyEvents the topology events with the data 48 + * @param events the topology events with the data
50 * @return JSON array with the topology events 49 * @return JSON array with the topology events
51 */ 50 */
52 - private JsonNode json(List<TopologyEvent> topologyEvents) { 51 + private JsonNode json(List<Event> events) {
53 ObjectMapper mapper = new ObjectMapper(); 52 ObjectMapper mapper = new ObjectMapper();
54 ArrayNode result = mapper.createArrayNode(); 53 ArrayNode result = mapper.createArrayNode();
55 54
56 - for (TopologyEvent event : topologyEvents) { 55 + for (Event event : events) {
57 result.add(json(mapper, event)); 56 result.add(json(mapper, event));
58 } 57 }
59 return result; 58 return result;
...@@ -66,32 +65,23 @@ public class TopologyEventsListCommand extends AbstractShellCommand { ...@@ -66,32 +65,23 @@ public class TopologyEventsListCommand extends AbstractShellCommand {
66 * @param topologyEvent the topology event with the data 65 * @param topologyEvent the topology event with the data
67 * @return JSON object for the topology event 66 * @return JSON object for the topology event
68 */ 67 */
69 - private ObjectNode json(ObjectMapper mapper, TopologyEvent topologyEvent) {
70 - ObjectNode result = mapper.createObjectNode();
71 - ArrayNode reasons = mapper.createArrayNode();
72 -
73 - for (Event reason : topologyEvent.reasons()) {
74 - reasons.add(json(mapper, reason));
75 - }
76 - result.put("time", topologyEvent.time())
77 - .put("type", topologyEvent.type().toString())
78 - .put("subject", topologyEvent.subject().toString())
79 - .put("reasons", reasons);
80 - return result;
81 - }
82 -
83 - /**
84 - * Produces JSON object for a generic event.
85 - *
86 - * @param event the generic event with the data
87 - * @return JSON object for the generic event
88 - */
89 private ObjectNode json(ObjectMapper mapper, Event event) { 68 private ObjectNode json(ObjectMapper mapper, Event event) {
90 ObjectNode result = mapper.createObjectNode(); 69 ObjectNode result = mapper.createObjectNode();
91 70
92 result.put("time", event.time()) 71 result.put("time", event.time())
93 .put("type", event.type().toString()) 72 .put("type", event.type().toString())
94 - .put("subject", event.subject().toString()); 73 + .put("event", event.toString());
74 +
75 + // Add the reasons if a TopologyEvent
76 + if (event instanceof TopologyEvent) {
77 + TopologyEvent topologyEvent = (TopologyEvent) event;
78 + ArrayNode reasons = mapper.createArrayNode();
79 + for (Event reason : topologyEvent.reasons()) {
80 + reasons.add(json(mapper, reason));
81 + }
82 + result.put("reasons", reasons);
83 + }
84 +
95 return result; 85 return result;
96 } 86 }
97 } 87 }
......
...@@ -285,7 +285,7 @@ public class OpticalConfigProvider extends AbstractProvider implements DevicePro ...@@ -285,7 +285,7 @@ public class OpticalConfigProvider extends AbstractProvider implements DevicePro
285 DefaultLinkDescription linkDescription = 285 DefaultLinkDescription linkDescription =
286 new DefaultLinkDescription(srcPoint, 286 new DefaultLinkDescription(srcPoint,
287 snkPoint, 287 snkPoint,
288 - Link.Type.DIRECT, 288 + Link.Type.OPTICAL,
289 extendedAttributes); 289 extendedAttributes);
290 290
291 linkProviderService.linkDetected(linkDescription); 291 linkProviderService.linkDetected(linkDescription);
...@@ -316,7 +316,7 @@ public class OpticalConfigProvider extends AbstractProvider implements DevicePro ...@@ -316,7 +316,7 @@ public class OpticalConfigProvider extends AbstractProvider implements DevicePro
316 DefaultLinkDescription linkDescription = 316 DefaultLinkDescription linkDescription =
317 new DefaultLinkDescription(srcPoint, 317 new DefaultLinkDescription(srcPoint,
318 snkPoint, 318 snkPoint,
319 - Link.Type.DIRECT, 319 + Link.Type.OPTICAL,
320 extendedAttributes); 320 extendedAttributes);
321 321
322 linkProviderService.linkDetected(linkDescription); 322 linkProviderService.linkDetected(linkDescription);
......
1 { 1 {
2 - "opticalSwitches": [ 2 + "opticalSwitches": [
3 { 3 {
4 "allowed": true, 4 "allowed": true,
5 "latitude": 37.6, 5 "latitude": 37.6,
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
12 "type": "Roadm" 12 "type": "Roadm"
13 }, 13 },
14 14
15 - { 15 + {
16 "allowed": true, 16 "allowed": true,
17 "latitude": 37.3, 17 "latitude": 37.3,
18 "longitude": 121.9, 18 "longitude": 121.9,
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
22 "numRegen": 0 22 "numRegen": 0
23 }, 23 },
24 "type": "Roadm" 24 "type": "Roadm"
25 - }, 25 + },
26 26
27 - { 27 + {
28 "allowed": true, 28 "allowed": true,
29 "latitude": 33.9, 29 "latitude": 33.9,
30 "longitude": 118.4, 30 "longitude": 118.4,
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
34 "numRegen": 2 34 "numRegen": 2
35 }, 35 },
36 "type": "Roadm" 36 "type": "Roadm"
37 - } 37 + }
38 ], 38 ],
39 39
40 - "opticalLinks": [ 40 + "opticalLinks": [
41 { 41 {
42 "allowed": true, 42 "allowed": true,
43 "nodeDpid1": "00:00:ff:ff:ff:ff:ff:01", 43 "nodeDpid1": "00:00:ff:ff:ff:ff:ff:01",
...@@ -51,10 +51,38 @@ ...@@ -51,10 +51,38 @@
51 "port2": 30 51 "port2": 30
52 }, 52 },
53 "type": "wdmLink" 53 "type": "wdmLink"
54 - }, 54 + },
55 - 55 + {
56 - { 56 + "allowed": true,
57 - "allowed": true, 57 + "nodeDpid1": "00:00:ff:ff:ff:ff:ff:03",
58 + "nodeDpid2": "00:00:ff:ff:ff:ff:ff:01",
59 + "params": {
60 + "distKms": 1000,
61 + "nodeName1": "ROADM3",
62 + "nodeName2": "ROADM1",
63 + "numWaves": 80,
64 + "port1": 30,
65 + "port2": 10
66 + },
67 + "type": "wdmLink"
68 + },
69 +
70 + {
71 + "allowed": true,
72 + "nodeDpid1": "00:00:ff:ff:ff:ff:ff:02",
73 + "nodeDpid2": "00:00:ff:ff:ff:ff:ff:03",
74 + "params": {
75 + "distKms": 2000,
76 + "nodeName1": "ROADM2",
77 + "nodeName2": "ROADM3",
78 + "numWaves": 80,
79 + "port1": 20,
80 + "port2": 31
81 + },
82 + "type": "wdmLink"
83 + },
84 + {
85 + "allowed": true,
58 "nodeDpid1": "00:00:ff:ff:ff:ff:ff:03", 86 "nodeDpid1": "00:00:ff:ff:ff:ff:ff:03",
59 "nodeDpid2": "00:00:ff:ff:ff:ff:ff:02", 87 "nodeDpid2": "00:00:ff:ff:ff:ff:ff:02",
60 "params": { 88 "params": {
...@@ -66,10 +94,9 @@ ...@@ -66,10 +94,9 @@
66 "port2": 21 94 "port2": 21
67 }, 95 },
68 "type": "wdmLink" 96 "type": "wdmLink"
69 - }, 97 + },
70 98
71 - 99 + {
72 - {
73 "allowed": true, 100 "allowed": true,
74 "nodeDpid1": "00:00:ff:ff:ff:ff:00:01", 101 "nodeDpid1": "00:00:ff:ff:ff:ff:00:01",
75 "nodeDpid2": "00:00:ff:ff:ff:ff:ff:01", 102 "nodeDpid2": "00:00:ff:ff:ff:ff:ff:01",
...@@ -82,8 +109,21 @@ ...@@ -82,8 +109,21 @@
82 }, 109 },
83 "type": "pktOptLink" 110 "type": "pktOptLink"
84 }, 111 },
112 + {
113 + "allowed": true,
114 + "nodeDpid1": "00:00:ff:ff:ff:ff:ff:01",
115 + "nodeDpid2": "00:00:ff:ff:ff:ff:00:01",
116 + "params": {
117 + "nodeName1": "ROADM1",
118 + "nodeName2": "ROUTER1",
119 + "bandWidth": 100000,
120 + "port1": 11,
121 + "port2": 10
122 + },
123 + "type": "pktOptLink"
124 + },
85 125
86 - { 126 + {
87 "allowed": true, 127 "allowed": true,
88 "nodeDpid1": "00:00:ff:ff:ff:ff:00:02", 128 "nodeDpid1": "00:00:ff:ff:ff:ff:00:02",
89 "nodeDpid2": "00:00:ff:ff:ff:ff:ff:02", 129 "nodeDpid2": "00:00:ff:ff:ff:ff:ff:02",
...@@ -95,7 +135,20 @@ ...@@ -95,7 +135,20 @@
95 "port2": 11 135 "port2": 11
96 }, 136 },
97 "type": "pktOptLink" 137 "type": "pktOptLink"
98 - } 138 + },
139 + {
140 + "allowed": true,
141 + "nodeDpid1": "00:00:ff:ff:ff:ff:ff:02",
142 + "nodeDpid2": "00:00:ff:ff:ff:ff:00:02",
143 + "params": {
144 + "nodeName1": "ROADM2",
145 + "nodeName2": "ROUTER2",
146 + "bandWidth": 100000,
147 + "port1": 21,
148 + "port2": 10
149 + },
150 + "type": "pktOptLink"
151 + }
99 152
100 ] 153 ]
101 } 154 }
......
...@@ -4,19 +4,17 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -4,19 +4,17 @@ import static com.google.common.base.Preconditions.checkNotNull;
4 4
5 import java.util.Set; 5 import java.util.Set;
6 6
7 -import org.apache.commons.lang.NotImplementedException;
8 import org.onlab.onos.net.ConnectPoint; 7 import org.onlab.onos.net.ConnectPoint;
9 import org.onlab.onos.net.host.HostService; 8 import org.onlab.onos.net.host.HostService;
10 import org.onlab.onos.net.host.PortAddresses; 9 import org.onlab.onos.net.host.PortAddresses;
11 import org.onlab.onos.sdnip.config.Interface; 10 import org.onlab.onos.sdnip.config.Interface;
12 import org.onlab.packet.IpAddress; 11 import org.onlab.packet.IpAddress;
12 +import org.onlab.packet.IpPrefix;
13 13
14 import com.google.common.collect.Sets; 14 import com.google.common.collect.Sets;
15 15
16 -
17 -
18 /** 16 /**
19 - * Provides IntefaceService using PortAddresses data from the HostService. 17 + * Provides InterfaceService using PortAddresses data from the HostService.
20 */ 18 */
21 public class HostToInterfaceAdaptor implements InterfaceService { 19 public class HostToInterfaceAdaptor implements InterfaceService {
22 20
...@@ -52,8 +50,17 @@ public class HostToInterfaceAdaptor implements InterfaceService { ...@@ -52,8 +50,17 @@ public class HostToInterfaceAdaptor implements InterfaceService {
52 50
53 @Override 51 @Override
54 public Interface getMatchingInterface(IpAddress ipAddress) { 52 public Interface getMatchingInterface(IpAddress ipAddress) {
55 - // TODO implement 53 + checkNotNull(ipAddress);
56 - throw new NotImplementedException("getMatchingInteface is not yet implemented"); 54 +
55 + for (PortAddresses portAddresses : hostService.getAddressBindings()) {
56 + for (IpPrefix p : portAddresses.ips()) {
57 + if (p.contains(ipAddress)) {
58 + return new Interface(portAddresses);
59 + }
60 + }
61 + }
62 +
63 + return null;
57 } 64 }
58 65
59 } 66 }
......
1 package org.onlab.onos.sdnip; 1 package org.onlab.onos.sdnip;
2 2
3 -import com.google.common.base.Objects; 3 +import java.util.Collection;
4 -import com.google.common.collect.HashMultimap; 4 +import java.util.HashMap;
5 -import com.google.common.collect.Multimaps; 5 +import java.util.HashSet;
6 -import com.google.common.collect.SetMultimap; 6 +import java.util.Iterator;
7 -import com.google.common.util.concurrent.ThreadFactoryBuilder; 7 +import java.util.LinkedList;
8 -import com.googlecode.concurrenttrees.common.KeyValuePair; 8 +import java.util.List;
9 -import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory; 9 +import java.util.Map;
10 -import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree; 10 +import java.util.Set;
11 -import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; 11 +import java.util.concurrent.BlockingQueue;
12 +import java.util.concurrent.ConcurrentHashMap;
13 +import java.util.concurrent.ExecutorService;
14 +import java.util.concurrent.Executors;
15 +import java.util.concurrent.LinkedBlockingQueue;
16 +import java.util.concurrent.Semaphore;
17 +
12 import org.apache.commons.lang3.tuple.Pair; 18 import org.apache.commons.lang3.tuple.Pair;
13 import org.onlab.onos.ApplicationId; 19 import org.onlab.onos.ApplicationId;
14 import org.onlab.onos.net.ConnectPoint; 20 import org.onlab.onos.net.ConnectPoint;
...@@ -36,20 +42,15 @@ import org.onlab.packet.MacAddress; ...@@ -36,20 +42,15 @@ import org.onlab.packet.MacAddress;
36 import org.slf4j.Logger; 42 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory; 43 import org.slf4j.LoggerFactory;
38 44
39 -import java.util.Collection; 45 +import com.google.common.base.Objects;
40 -import java.util.HashMap; 46 +import com.google.common.collect.HashMultimap;
41 -import java.util.HashSet; 47 +import com.google.common.collect.Multimaps;
42 -import java.util.Iterator; 48 +import com.google.common.collect.SetMultimap;
43 -import java.util.LinkedList; 49 +import com.google.common.util.concurrent.ThreadFactoryBuilder;
44 -import java.util.List; 50 +import com.googlecode.concurrenttrees.common.KeyValuePair;
45 -import java.util.Map; 51 +import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory;
46 -import java.util.Set; 52 +import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree;
47 -import java.util.concurrent.BlockingQueue; 53 +import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree;
48 -import java.util.concurrent.ConcurrentHashMap;
49 -import java.util.concurrent.ExecutorService;
50 -import java.util.concurrent.Executors;
51 -import java.util.concurrent.LinkedBlockingQueue;
52 -import java.util.concurrent.Semaphore;
53 54
54 /** 55 /**
55 * This class processes BGP route update, translates each update into a intent 56 * This class processes BGP route update, translates each update into a intent
...@@ -744,6 +745,21 @@ public class Router implements RouteListener { ...@@ -744,6 +745,21 @@ public class Router implements RouteListener {
744 } 745 }
745 746
746 /** 747 /**
748 + * Gets the pushed route intents.
749 + *
750 + * @return the pushed route intents
751 + */
752 + public Collection<MultiPointToSinglePointIntent> getPushedRouteIntents() {
753 + List<MultiPointToSinglePointIntent> pushedIntents = new LinkedList<>();
754 +
755 + for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry :
756 + pushedRouteIntents.entrySet()) {
757 + pushedIntents.add(entry.getValue());
758 + }
759 + return pushedIntents;
760 + }
761 +
762 + /**
747 * Listener for host events. 763 * Listener for host events.
748 */ 764 */
749 class InternalHostListener implements HostListener { 765 class InternalHostListener implements HostListener {
......
...@@ -64,6 +64,7 @@ public class SdnIp implements SdnIpService { ...@@ -64,6 +64,7 @@ public class SdnIp implements SdnIpService {
64 bgpSessionManager.startUp(2000); // TODO 64 bgpSessionManager.startUp(2000); // TODO
65 65
66 // TODO need to disable link discovery on external ports 66 // TODO need to disable link discovery on external ports
67 +
67 } 68 }
68 69
69 @Deactivate 70 @Deactivate
......
1 +package org.onlab.onos.sdnip;
2 +
3 +import static org.easymock.EasyMock.createMock;
4 +import static org.easymock.EasyMock.expect;
5 +import static org.easymock.EasyMock.replay;
6 +import static org.easymock.EasyMock.reset;
7 +import static org.junit.Assert.assertEquals;
8 +import static org.junit.Assert.assertNull;
9 +import static org.junit.Assert.assertTrue;
10 +
11 +import java.util.Map;
12 +import java.util.Set;
13 +
14 +import org.junit.Before;
15 +import org.junit.Test;
16 +import org.onlab.onos.net.ConnectPoint;
17 +import org.onlab.onos.net.DeviceId;
18 +import org.onlab.onos.net.PortNumber;
19 +import org.onlab.onos.net.host.HostService;
20 +import org.onlab.onos.net.host.PortAddresses;
21 +import org.onlab.onos.sdnip.config.Interface;
22 +import org.onlab.packet.IpAddress;
23 +import org.onlab.packet.IpPrefix;
24 +import org.onlab.packet.MacAddress;
25 +
26 +import com.google.common.collect.Maps;
27 +import com.google.common.collect.Sets;
28 +
29 +/**
30 + * Unit tests for the HostToInterfaceAdaptor class.
31 + */
32 +public class HostToInterfaceAdaptorTest {
33 +
34 + private HostService hostService;
35 + private HostToInterfaceAdaptor adaptor;
36 +
37 + private Set<PortAddresses> portAddresses;
38 + private Map<ConnectPoint, Interface> interfaces;
39 +
40 + private static final ConnectPoint CP1 = new ConnectPoint(
41 + DeviceId.deviceId("of:1"), PortNumber.portNumber(1));
42 + private static final ConnectPoint CP2 = new ConnectPoint(
43 + DeviceId.deviceId("of:1"), PortNumber.portNumber(2));
44 + private static final ConnectPoint CP3 = new ConnectPoint(
45 + DeviceId.deviceId("of:2"), PortNumber.portNumber(1));
46 +
47 + private static final ConnectPoint NON_EXISTENT_CP = new ConnectPoint(
48 + DeviceId.deviceId("doesnotexist"), PortNumber.portNumber(1));
49 +
50 + private static final PortAddresses DEFAULT_PA = new PortAddresses(
51 + NON_EXISTENT_CP, null, null);
52 +
53 +
54 + @Before
55 + public void setUp() throws Exception {
56 + hostService = createMock(HostService.class);
57 +
58 + portAddresses = Sets.newHashSet();
59 + interfaces = Maps.newHashMap();
60 +
61 + createPortAddressesAndInterface(CP1,
62 + Sets.newHashSet(IpPrefix.valueOf("192.168.1.1/24")),
63 + MacAddress.valueOf("00:00:00:00:00:01"));
64 +
65 + // Two addresses in the same subnet
66 + createPortAddressesAndInterface(CP2,
67 + Sets.newHashSet(IpPrefix.valueOf("192.168.2.1/24"),
68 + IpPrefix.valueOf("192.168.2.2/24")),
69 + MacAddress.valueOf("00:00:00:00:00:02"));
70 +
71 + // Two addresses in different subnets
72 + createPortAddressesAndInterface(CP3,
73 + Sets.newHashSet(IpPrefix.valueOf("192.168.3.1/24"),
74 + IpPrefix.valueOf("192.168.4.1/24")),
75 + MacAddress.valueOf("00:00:00:00:00:03"));
76 +
77 + expect(hostService.getAddressBindings()).andReturn(portAddresses).anyTimes();
78 +
79 + replay(hostService);
80 +
81 + adaptor = new HostToInterfaceAdaptor(hostService);
82 + }
83 +
84 + /**
85 + * Creates both a PortAddresses and an Interface for the given inputs and
86 + * places them in the correct global data stores.
87 + *
88 + * @param cp the connect point
89 + * @param ips the set of IP addresses
90 + * @param mac the MAC address
91 + */
92 + private void createPortAddressesAndInterface(
93 + ConnectPoint cp, Set<IpPrefix> ips, MacAddress mac) {
94 + PortAddresses pa = new PortAddresses(cp, ips, mac);
95 + portAddresses.add(pa);
96 + expect(hostService.getAddressBindingsForPort(cp)).andReturn(pa).anyTimes();
97 +
98 + Interface intf = new Interface(cp, ips, mac);
99 + interfaces.put(cp, intf);
100 + }
101 +
102 + /**
103 + * Tests {@link HostToInterfaceAdaptor#getInterfaces()}.
104 + * Verifies that the set of interfaces returned matches what is expected
105 + * based on the input PortAddresses data.
106 + */
107 + @Test
108 + public void testGetInterfaces() {
109 + Set<Interface> adaptorIntfs = adaptor.getInterfaces();
110 +
111 + assertEquals(3, adaptorIntfs.size());
112 + assertTrue(adaptorIntfs.contains(this.interfaces.get(CP1)));
113 + assertTrue(adaptorIntfs.contains(this.interfaces.get(CP2)));
114 + assertTrue(adaptorIntfs.contains(this.interfaces.get(CP3)));
115 + }
116 +
117 + /**
118 + * Tests {@link HostToInterfaceAdaptor#getInterface(ConnectPoint)}.
119 + * Verifies that the correct interface is returned for a given connect
120 + * point.
121 + */
122 + @Test
123 + public void testGetInterface() {
124 + assertEquals(this.interfaces.get(CP1), adaptor.getInterface(CP1));
125 + assertEquals(this.interfaces.get(CP2), adaptor.getInterface(CP2));
126 + assertEquals(this.interfaces.get(CP3), adaptor.getInterface(CP3));
127 +
128 + // Try and get an interface for a connect point with no addresses
129 + reset(hostService);
130 + expect(hostService.getAddressBindingsForPort(NON_EXISTENT_CP))
131 + .andReturn(DEFAULT_PA).anyTimes();
132 + replay(hostService);
133 +
134 + assertNull(adaptor.getInterface(NON_EXISTENT_CP));
135 + }
136 +
137 + /**
138 + * Tests {@link HostToInterfaceAdaptor#getInterface(ConnectPoint)} in the
139 + * case that the input connect point is null.
140 + * Verifies that a NullPointerException is thrown.
141 + */
142 + @Test(expected = NullPointerException.class)
143 + public void testGetInterfaceNull() {
144 + adaptor.getInterface(null);
145 + }
146 +
147 + /**
148 + * Tests {@link HostToInterfaceAdaptor#getMatchingInterface(IpAddress)}.
149 + * Verifies that the correct interface is returned based on the given IP
150 + * address.
151 + */
152 + @Test
153 + public void testGetMatchingInterface() {
154 + assertEquals(this.interfaces.get(CP1),
155 + adaptor.getMatchingInterface(IpAddress.valueOf("192.168.1.100")));
156 + assertEquals(this.interfaces.get(CP2),
157 + adaptor.getMatchingInterface(IpAddress.valueOf("192.168.2.100")));
158 + assertEquals(this.interfaces.get(CP3),
159 + adaptor.getMatchingInterface(IpAddress.valueOf("192.168.3.100")));
160 + assertEquals(this.interfaces.get(CP3),
161 + adaptor.getMatchingInterface(IpAddress.valueOf("192.168.4.100")));
162 +
163 + // Try and match an address we don't have subnet configured for
164 + assertNull(adaptor.getMatchingInterface(IpAddress.valueOf("1.1.1.1")));
165 + }
166 +
167 + /**
168 + * Tests {@link HostToInterfaceAdaptor#getMatchingInterface(IpAddress)} in the
169 + * case that the input IP address is null.
170 + * Verifies that a NullPointerException is thrown.
171 + */
172 + @Test(expected = NullPointerException.class)
173 + public void testGetMatchingInterfaceNull() {
174 + adaptor.getMatchingInterface(null);
175 + }
176 +
177 +}
This diff is collapsed. Click to expand it.
...@@ -18,10 +18,13 @@ ...@@ -18,10 +18,13 @@
18 */ 18 */
19 package org.onlab.onos.cli; 19 package org.onlab.onos.cli;
20 20
21 +import com.fasterxml.jackson.databind.ObjectMapper;
22 +import com.fasterxml.jackson.databind.node.ObjectNode;
21 import org.apache.karaf.shell.commands.Option; 23 import org.apache.karaf.shell.commands.Option;
22 import org.apache.karaf.shell.console.OsgiCommandSupport; 24 import org.apache.karaf.shell.console.OsgiCommandSupport;
23 import org.onlab.onos.ApplicationId; 25 import org.onlab.onos.ApplicationId;
24 import org.onlab.onos.CoreService; 26 import org.onlab.onos.CoreService;
27 +import org.onlab.onos.net.Annotations;
25 import org.onlab.osgi.DefaultServiceDirectory; 28 import org.onlab.osgi.DefaultServiceDirectory;
26 import org.onlab.osgi.ServiceNotFoundException; 29 import org.onlab.osgi.ServiceNotFoundException;
27 30
...@@ -76,6 +79,34 @@ public abstract class AbstractShellCommand extends OsgiCommandSupport { ...@@ -76,6 +79,34 @@ public abstract class AbstractShellCommand extends OsgiCommandSupport {
76 } 79 }
77 80
78 /** 81 /**
82 + * Produces a string image of the specified key/value annotations.
83 + *
84 + * @param annotations key/value annotations
85 + * @return string image with ", k1=v1, k2=v2, ..." pairs
86 + */
87 + public static String annotations(Annotations annotations) {
88 + StringBuilder sb = new StringBuilder();
89 + for (String key : annotations.keys()) {
90 + sb.append(", ").append(key).append('=').append(annotations.value(key));
91 + }
92 + return sb.toString();
93 + }
94 +
95 + /**
96 + * Produces a JSON object from the specified key/value annotations.
97 + *
98 + * @param annotations key/value annotations
99 + * @return JSON object
100 + */
101 + public static ObjectNode annotations(ObjectMapper mapper, Annotations annotations) {
102 + ObjectNode result = mapper.createObjectNode();
103 + for (String key : annotations.keys()) {
104 + result.put(key, annotations.value(key));
105 + }
106 + return result;
107 + }
108 +
109 + /**
79 * Executes this command. 110 * Executes this command.
80 */ 111 */
81 protected abstract void execute(); 112 protected abstract void execute();
......
...@@ -43,7 +43,7 @@ import static org.onlab.onos.net.DeviceId.deviceId; ...@@ -43,7 +43,7 @@ import static org.onlab.onos.net.DeviceId.deviceId;
43 description = "Lists all ports or all ports of a device") 43 description = "Lists all ports or all ports of a device")
44 public class DevicePortsListCommand extends DevicesListCommand { 44 public class DevicePortsListCommand extends DevicesListCommand {
45 45
46 - private static final String FMT = " port=%s, state=%s"; 46 + private static final String FMT = " port=%s, state=%s%s";
47 47
48 @Option(name = "-e", aliases = "--enabled", description = "Show only enabled ports", 48 @Option(name = "-e", aliases = "--enabled", description = "Show only enabled ports",
49 required = false, multiValued = false) 49 required = false, multiValued = false)
...@@ -112,7 +112,8 @@ public class DevicePortsListCommand extends DevicesListCommand { ...@@ -112,7 +112,8 @@ public class DevicePortsListCommand extends DevicesListCommand {
112 if (isIncluded(port)) { 112 if (isIncluded(port)) {
113 ports.add(mapper.createObjectNode() 113 ports.add(mapper.createObjectNode()
114 .put("port", port.number().toString()) 114 .put("port", port.number().toString())
115 - .put("isEnabled", port.isEnabled())); 115 + .put("isEnabled", port.isEnabled())
116 + .set("annotations", annotations(mapper, port.annotations())));
116 } 117 }
117 } 118 }
118 return result.put("device", device.id().toString()).set("ports", ports); 119 return result.put("device", device.id().toString()).set("ports", ports);
...@@ -131,7 +132,8 @@ public class DevicePortsListCommand extends DevicesListCommand { ...@@ -131,7 +132,8 @@ public class DevicePortsListCommand extends DevicesListCommand {
131 Collections.sort(ports, Comparators.PORT_COMPARATOR); 132 Collections.sort(ports, Comparators.PORT_COMPARATOR);
132 for (Port port : ports) { 133 for (Port port : ports) {
133 if (isIncluded(port)) { 134 if (isIncluded(port)) {
134 - print(FMT, port.number(), port.isEnabled() ? "enabled" : "disabled"); 135 + print(FMT, port.number(), port.isEnabled() ? "enabled" : "disabled",
136 + annotations(port.annotations()));
135 } 137 }
136 } 138 }
137 } 139 }
......
...@@ -41,7 +41,7 @@ import static com.google.common.collect.Lists.newArrayList; ...@@ -41,7 +41,7 @@ import static com.google.common.collect.Lists.newArrayList;
41 public class DevicesListCommand extends AbstractShellCommand { 41 public class DevicesListCommand extends AbstractShellCommand {
42 42
43 private static final String FMT = 43 private static final String FMT =
44 - "id=%s, available=%s, role=%s, type=%s, mfr=%s, hw=%s, sw=%s, serial=%s"; 44 + "id=%s, available=%s, role=%s, type=%s, mfr=%s, hw=%s, sw=%s, serial=%s%s";
45 45
46 @Override 46 @Override
47 protected void execute() { 47 protected void execute() {
...@@ -89,7 +89,8 @@ public class DevicesListCommand extends AbstractShellCommand { ...@@ -89,7 +89,8 @@ public class DevicesListCommand extends AbstractShellCommand {
89 .put("mfr", device.manufacturer()) 89 .put("mfr", device.manufacturer())
90 .put("hw", device.hwVersion()) 90 .put("hw", device.hwVersion())
91 .put("sw", device.swVersion()) 91 .put("sw", device.swVersion())
92 - .put("serial", device.serialNumber()); 92 + .put("serial", device.serialNumber())
93 + .set("annotations", annotations(mapper, device.annotations()));
93 } 94 }
94 return result; 95 return result;
95 } 96 }
...@@ -117,7 +118,7 @@ public class DevicesListCommand extends AbstractShellCommand { ...@@ -117,7 +118,7 @@ public class DevicesListCommand extends AbstractShellCommand {
117 print(FMT, device.id(), service.isAvailable(device.id()), 118 print(FMT, device.id(), service.isAvailable(device.id()),
118 service.getRole(device.id()), device.type(), 119 service.getRole(device.id()), device.type(),
119 device.manufacturer(), device.hwVersion(), device.swVersion(), 120 device.manufacturer(), device.hwVersion(), device.swVersion(),
120 - device.serialNumber()); 121 + device.serialNumber(), annotations(device.annotations()));
121 } 122 }
122 } 123 }
123 124
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +package org.onlab.onos.cli.net;
20 +
21 +import org.apache.karaf.shell.commands.Argument;
22 +import org.apache.karaf.shell.commands.Command;
23 +import org.onlab.onos.cli.AbstractShellCommand;
24 +import org.onlab.onos.net.ConnectPoint;
25 +import org.onlab.onos.net.DeviceId;
26 +import org.onlab.onos.net.PortNumber;
27 +
28 +import org.onlab.onos.net.statistic.Load;
29 +import org.onlab.onos.net.statistic.StatisticService;
30 +
31 +
32 +import static org.onlab.onos.net.DeviceId.deviceId;
33 +import static org.onlab.onos.net.PortNumber.portNumber;
34 +
35 +/**
36 + * Fetches statistics.
37 + */
38 +@Command(scope = "onos", name = "get-stats",
39 + description = "Fetches stats for a connection point")
40 +public class GetStatistics extends AbstractShellCommand {
41 +
42 + @Argument(index = 0, name = "connectPoint",
43 + description = "Device/Port Description",
44 + required = true, multiValued = false)
45 + String connectPoint = null;
46 +
47 +
48 + @Override
49 + protected void execute() {
50 + StatisticService service = get(StatisticService.class);
51 +
52 + DeviceId ingressDeviceId = deviceId(getDeviceId(connectPoint));
53 + PortNumber ingressPortNumber = portNumber(getPortNumber(connectPoint));
54 + ConnectPoint cp = new ConnectPoint(ingressDeviceId, ingressPortNumber);
55 +
56 + Load load = service.load(cp);
57 +
58 + print("Load on %s -> %s", cp, load);
59 + }
60 +
61 + /**
62 + * Extracts the port number portion of the ConnectPoint.
63 + *
64 + * @param deviceString string representing the device/port
65 + * @return port number as a string, empty string if the port is not found
66 + */
67 + private String getPortNumber(String deviceString) {
68 + int slash = deviceString.indexOf('/');
69 + if (slash <= 0) {
70 + return "";
71 + }
72 + return deviceString.substring(slash + 1, deviceString.length());
73 + }
74 +
75 + /**
76 + * Extracts the device ID portion of the ConnectPoint.
77 + *
78 + * @param deviceString string representing the device/port
79 + * @return device ID string
80 + */
81 + private String getDeviceId(String deviceString) {
82 + int slash = deviceString.indexOf('/');
83 + if (slash <= 0) {
84 + return "";
85 + }
86 + return deviceString.substring(0, slash);
87 + }
88 +}
...@@ -42,7 +42,7 @@ import static com.google.common.collect.Lists.newArrayList; ...@@ -42,7 +42,7 @@ import static com.google.common.collect.Lists.newArrayList;
42 public class HostsListCommand extends AbstractShellCommand { 42 public class HostsListCommand extends AbstractShellCommand {
43 43
44 private static final String FMT = 44 private static final String FMT =
45 - "id=%s, mac=%s, location=%s/%s, vlan=%s, ip(s)=%s"; 45 + "id=%s, mac=%s, location=%s/%s, vlan=%s, ip(s)=%s%s";
46 46
47 @Override 47 @Override
48 protected void execute() { 48 protected void execute() {
...@@ -80,6 +80,7 @@ public class HostsListCommand extends AbstractShellCommand { ...@@ -80,6 +80,7 @@ public class HostsListCommand extends AbstractShellCommand {
80 .put("vlan", host.vlan().toString()); 80 .put("vlan", host.vlan().toString());
81 result.set("location", loc); 81 result.set("location", loc);
82 result.set("ips", ips); 82 result.set("ips", ips);
83 + result.set("annotations", annotations(mapper, host.annotations()));
83 return result; 84 return result;
84 } 85 }
85 86
...@@ -105,7 +106,8 @@ public class HostsListCommand extends AbstractShellCommand { ...@@ -105,7 +106,8 @@ public class HostsListCommand extends AbstractShellCommand {
105 print(FMT, host.id(), host.mac(), 106 print(FMT, host.id(), host.mac(),
106 host.location().deviceId(), 107 host.location().deviceId(),
107 host.location().port(), 108 host.location().port(),
108 - host.vlan(), host.ipAddresses()); 109 + host.vlan(), host.ipAddresses(),
110 + annotations(host.annotations()));
109 } 111 }
110 } 112 }
111 } 113 }
......
...@@ -38,7 +38,7 @@ import static org.onlab.onos.net.DeviceId.deviceId; ...@@ -38,7 +38,7 @@ import static org.onlab.onos.net.DeviceId.deviceId;
38 description = "Lists all infrastructure links") 38 description = "Lists all infrastructure links")
39 public class LinksListCommand extends AbstractShellCommand { 39 public class LinksListCommand extends AbstractShellCommand {
40 40
41 - private static final String FMT = "src=%s/%s, dst=%s/%s, type=%s"; 41 + private static final String FMT = "src=%s/%s, dst=%s/%s, type=%s%s";
42 private static final String COMPACT = "%s/%s-%s/%s"; 42 private static final String COMPACT = "%s/%s-%s/%s";
43 43
44 @Argument(index = 0, name = "uri", description = "Device ID", 44 @Argument(index = 0, name = "uri", description = "Device ID",
...@@ -85,6 +85,7 @@ public class LinksListCommand extends AbstractShellCommand { ...@@ -85,6 +85,7 @@ public class LinksListCommand extends AbstractShellCommand {
85 ObjectNode result = mapper.createObjectNode(); 85 ObjectNode result = mapper.createObjectNode();
86 result.set("src", json(mapper, link.src())); 86 result.set("src", json(mapper, link.src()));
87 result.set("dst", json(mapper, link.dst())); 87 result.set("dst", json(mapper, link.dst()));
88 + result.set("annotations", annotations(mapper, link.annotations()));
88 return result; 89 return result;
89 } 90 }
90 91
...@@ -109,7 +110,8 @@ public class LinksListCommand extends AbstractShellCommand { ...@@ -109,7 +110,8 @@ public class LinksListCommand extends AbstractShellCommand {
109 */ 110 */
110 public static String linkString(Link link) { 111 public static String linkString(Link link) {
111 return String.format(FMT, link.src().deviceId(), link.src().port(), 112 return String.format(FMT, link.src().deviceId(), link.src().port(),
112 - link.dst().deviceId(), link.dst().port(), link.type()); 113 + link.dst().deviceId(), link.dst().port(), link.type(),
114 + annotations(link.annotations()));
113 } 115 }
114 116
115 /** 117 /**
......
...@@ -20,8 +20,10 @@ package org.onlab.onos.cli.net; ...@@ -20,8 +20,10 @@ package org.onlab.onos.cli.net;
20 20
21 import com.fasterxml.jackson.databind.ObjectMapper; 21 import com.fasterxml.jackson.databind.ObjectMapper;
22 import org.apache.karaf.shell.commands.Command; 22 import org.apache.karaf.shell.commands.Command;
23 +import org.apache.karaf.shell.commands.Option;
23 import org.onlab.onos.cli.AbstractShellCommand; 24 import org.onlab.onos.cli.AbstractShellCommand;
24 import org.onlab.onos.net.topology.Topology; 25 import org.onlab.onos.net.topology.Topology;
26 +import org.onlab.onos.net.topology.TopologyProvider;
25 import org.onlab.onos.net.topology.TopologyService; 27 import org.onlab.onos.net.topology.TopologyService;
26 28
27 /** 29 /**
...@@ -35,6 +37,10 @@ public class TopologyCommand extends AbstractShellCommand { ...@@ -35,6 +37,10 @@ public class TopologyCommand extends AbstractShellCommand {
35 private static final String FMT = 37 private static final String FMT =
36 "time=%s, devices=%d, links=%d, clusters=%d, paths=%d"; 38 "time=%s, devices=%d, links=%d, clusters=%d, paths=%d";
37 39
40 + @Option(name = "-r", aliases = "--recompute", description = "Trigger topology re-computation",
41 + required = false, multiValued = false)
42 + private boolean recompute = false;
43 +
38 protected TopologyService service; 44 protected TopologyService service;
39 protected Topology topology; 45 protected Topology topology;
40 46
...@@ -49,7 +55,10 @@ public class TopologyCommand extends AbstractShellCommand { ...@@ -49,7 +55,10 @@ public class TopologyCommand extends AbstractShellCommand {
49 @Override 55 @Override
50 protected void execute() { 56 protected void execute() {
51 init(); 57 init();
52 - if (outputJson()) { 58 + if (recompute) {
59 + get(TopologyProvider.class).triggerRecompute();
60 +
61 + } else if (outputJson()) {
53 print("%s", new ObjectMapper().createObjectNode() 62 print("%s", new ObjectMapper().createObjectNode()
54 .put("time", topology.time()) 63 .put("time", topology.time())
55 .put("deviceCount", topology.deviceCount()) 64 .put("deviceCount", topology.deviceCount())
......
...@@ -119,6 +119,12 @@ ...@@ -119,6 +119,12 @@
119 </optional-completers> 119 </optional-completers>
120 </command> 120 </command>
121 <command> 121 <command>
122 + <action class="org.onlab.onos.cli.net.GetStatistics"/>
123 + <completers>
124 + <ref component-id="connectPointCompleter"/>
125 + </completers>
126 + </command>
127 + <command>
122 <action class="org.onlab.onos.cli.net.AddMultiPointToSinglePointIntentCommand"/> 128 <action class="org.onlab.onos.cli.net.AddMultiPointToSinglePointIntentCommand"/>
123 <completers> 129 <completers>
124 <ref component-id="connectPointCompleter"/> 130 <ref component-id="connectPointCompleter"/>
......
1 package org.onlab.onos.mastership; 1 package org.onlab.onos.mastership;
2 2
3 -import org.onlab.onos.cluster.NodeId;
4 import org.onlab.onos.cluster.RoleInfo; 3 import org.onlab.onos.cluster.RoleInfo;
5 import org.onlab.onos.event.AbstractEvent; 4 import org.onlab.onos.event.AbstractEvent;
6 import org.onlab.onos.net.DeviceId; 5 import org.onlab.onos.net.DeviceId;
...@@ -56,19 +55,6 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI ...@@ -56,19 +55,6 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
56 } 55 }
57 56
58 /** 57 /**
59 - * Returns the NodeID of the node associated with the event.
60 - * For MASTER_CHANGED this is the newly elected master, and for
61 - * BACKUPS_CHANGED, this is the node that was newly added, removed, or
62 - * whose position was changed in the list.
63 - *
64 - * @return node ID as a subject
65 - */
66 - //XXX to-be removed - or keep for convenience?
67 - public NodeId node() {
68 - return roleInfo.master();
69 - }
70 -
71 - /**
72 * Returns the current role state for the subject. 58 * Returns the current role state for the subject.
73 * 59 *
74 * @return RoleInfo associated with Device ID subject 60 * @return RoleInfo associated with Device ID subject
......
...@@ -25,7 +25,18 @@ public interface Link extends Annotated, Provided, NetworkResource { ...@@ -25,7 +25,18 @@ public interface Link extends Annotated, Provided, NetworkResource {
25 /** 25 /**
26 * Signifies that this link is an edge, i.e. host link. 26 * Signifies that this link is an edge, i.e. host link.
27 */ 27 */
28 - EDGE 28 + EDGE,
29 +
30 + /**
31 + * Signifies that this link represents a logical link backed by
32 + * some form of a tunnel.
33 + */
34 + TUNNEL,
35 +
36 + /**
37 + * Signifies that this link is realized by optical connection.
38 + */
39 + OPTICAL
29 } 40 }
30 41
31 /** 42 /**
...@@ -49,6 +60,4 @@ public interface Link extends Annotated, Provided, NetworkResource { ...@@ -49,6 +60,4 @@ public interface Link extends Annotated, Provided, NetworkResource {
49 */ 60 */
50 Type type(); 61 Type type();
51 62
52 - // LinkInfo info(); // Additional link information / decorations
53 -
54 } 63 }
......
...@@ -4,6 +4,8 @@ import org.onlab.onos.event.AbstractEvent; ...@@ -4,6 +4,8 @@ import org.onlab.onos.event.AbstractEvent;
4 import org.onlab.onos.net.Device; 4 import org.onlab.onos.net.Device;
5 import org.onlab.onos.net.Port; 5 import org.onlab.onos.net.Port;
6 6
7 +import static com.google.common.base.MoreObjects.toStringHelper;
8 +
7 /** 9 /**
8 * Describes infrastructure device event. 10 * Describes infrastructure device event.
9 */ 11 */
...@@ -109,4 +111,12 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> { ...@@ -109,4 +111,12 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
109 return port; 111 return port;
110 } 112 }
111 113
114 + @Override
115 + public String toString() {
116 + if (port == null) {
117 + return super.toString();
118 + }
119 + return toStringHelper(this).add("time", time()).add("type", type())
120 + .add("subject", subject()).add("port", port).toString();
121 + }
112 } 122 }
......
1 -package org.onlab.onos.net.intent; 1 +/*
2 -//TODO is this the right package? 2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +package org.onlab.onos.net.flow;
3 20
4 import static com.google.common.base.Preconditions.checkNotNull; 21 import static com.google.common.base.Preconditions.checkNotNull;
5 22
......
1 -package org.onlab.onos.net.intent; 1 +/*
2 -//TODO is this the right package? 2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +package org.onlab.onos.net.flow;
3 20
4 import java.util.Objects; 21 import java.util.Objects;
5 22
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import java.util.List; 21 import java.util.List;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +package org.onlab.onos.net.flow;
20 +
21 +/**
22 + * An interface of the class which is assigned to BatchOperation.
23 + */
24 +public interface BatchOperationTarget {
25 +
26 +}
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import java.util.List; 21 import java.util.List;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import static com.google.common.base.MoreObjects.toStringHelper; 21 import static com.google.common.base.MoreObjects.toStringHelper;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import static com.google.common.base.MoreObjects.toStringHelper; 21 import static com.google.common.base.MoreObjects.toStringHelper;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import java.util.HashMap; 21 import java.util.HashMap;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import java.util.LinkedList; 21 import java.util.LinkedList;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 21
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import com.google.common.base.Objects; 21 import com.google.common.base.Objects;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import org.onlab.onos.net.DeviceId; 21 import org.onlab.onos.net.DeviceId;
4 -import org.onlab.onos.net.intent.BatchOperationTarget;
5 22
6 /** 23 /**
7 * Represents a generalized match &amp; action pair to be applied to 24 * Represents a generalized match &amp; action pair to be applied to
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation; 21 import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
4 -import org.onlab.onos.net.intent.BatchOperationEntry;
5 22
6 23
7 public class FlowRuleBatchEntry 24 public class FlowRuleBatchEntry
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import java.util.Collection; 21 import java.util.Collection;
4 22
5 -import org.onlab.onos.net.intent.BatchOperation;
6 -
7 public class FlowRuleBatchOperation 23 public class FlowRuleBatchOperation
8 extends BatchOperation<FlowRuleBatchEntry> { 24 extends BatchOperation<FlowRuleBatchEntry> {
9 25
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import org.onlab.onos.event.AbstractEvent; 21 import org.onlab.onos.event.AbstractEvent;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import org.onlab.onos.event.EventListener; 21 import org.onlab.onos.event.EventListener;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import java.util.concurrent.Future; 21 import java.util.concurrent.Future;
4 22
5 import org.onlab.onos.ApplicationId; 23 import org.onlab.onos.ApplicationId;
6 -import org.onlab.onos.net.intent.BatchOperation;
7 import org.onlab.onos.net.provider.Provider; 24 import org.onlab.onos.net.provider.Provider;
8 25
9 /** 26 /**
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import org.onlab.onos.net.provider.ProviderRegistry; 21 import org.onlab.onos.net.provider.ProviderRegistry;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import org.onlab.onos.net.DeviceId; 21 import org.onlab.onos.net.DeviceId;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import java.util.concurrent.Future; 21 import java.util.concurrent.Future;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import org.onlab.onos.ApplicationId; 21 import org.onlab.onos.ApplicationId;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import org.onlab.onos.store.StoreDelegate; 21 import org.onlab.onos.store.StoreDelegate;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 21
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import java.util.Set; 21 import java.util.Set;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import java.util.List; 21 import java.util.List;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow; 19 package org.onlab.onos.net.flow;
2 20
3 import org.onlab.onos.net.PortNumber; 21 import org.onlab.onos.net.PortNumber;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow.criteria; 19 package org.onlab.onos.net.flow.criteria;
2 20
3 import static com.google.common.base.MoreObjects.toStringHelper; 21 import static com.google.common.base.MoreObjects.toStringHelper;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow.criteria; 19 package org.onlab.onos.net.flow.criteria;
2 20
3 21
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +
1 /** 20 /**
2 * Traffic selection criteria model. 21 * Traffic selection criteria model.
3 */ 22 */
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow.instructions; 19 package org.onlab.onos.net.flow.instructions;
2 20
3 /** 21 /**
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow.instructions; 19 package org.onlab.onos.net.flow.instructions;
2 20
3 import static com.google.common.base.MoreObjects.toStringHelper; 21 import static com.google.common.base.MoreObjects.toStringHelper;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow.instructions; 19 package org.onlab.onos.net.flow.instructions;
2 20
3 import static com.google.common.base.MoreObjects.toStringHelper; 21 import static com.google.common.base.MoreObjects.toStringHelper;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.flow.instructions; 19 package org.onlab.onos.net.flow.instructions;
2 20
3 import static com.google.common.base.MoreObjects.toStringHelper; 21 import static com.google.common.base.MoreObjects.toStringHelper;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +
1 /** 20 /**
2 * Traffic treatment model. 21 * Traffic treatment model.
3 */ 22 */
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +
1 /** 20 /**
2 * Flow rule model &amp; related services API definitions. 21 * Flow rule model &amp; related services API definitions.
3 */ 22 */
......
1 -package org.onlab.onos.net.intent;
2 -//TODO is this the right package?
3 -
4 -/**
5 - * An interface of the class which is assigned to BatchOperation.
6 - */
7 -public interface BatchOperationTarget {
8 -
9 -}
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import com.google.common.collect.ImmutableSet; 21 import com.google.common.collect.ImmutableSet;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import com.google.common.base.MoreObjects; 21 import com.google.common.base.MoreObjects;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import org.onlab.onos.ApplicationId; 21 import org.onlab.onos.ApplicationId;
4 import org.onlab.onos.net.NetworkResource; 22 import org.onlab.onos.net.NetworkResource;
23 +import org.onlab.onos.net.flow.BatchOperationTarget;
5 24
6 import java.util.Collection; 25 import java.util.Collection;
7 import java.util.Objects; 26 import java.util.Objects;
......
1 -package org.onlab.onos.net.intent;
2 -
3 -/**
4 - * A list of intent operations.
5 - */
6 -public class IntentBatchOperation extends
7 - BatchOperation<BatchOperationEntry<IntentBatchOperation.Operator, ?>> {
8 - /**
9 - * The intent operators.
10 - */
11 - public enum Operator {
12 - ADD,
13 - REMOVE,
14 - }
15 -
16 - /**
17 - * Adds an add-intent operation.
18 - *
19 - * @param intent the intent to be added
20 - * @return the IntentBatchOperation object if succeeded, null otherwise
21 - */
22 - public IntentBatchOperation addAddIntentOperation(Intent intent) {
23 - return (null == super.addOperation(
24 - new BatchOperationEntry<Operator, Intent>(Operator.ADD, intent)))
25 - ? null : this;
26 - }
27 -
28 - /**
29 - * Adds a remove-intent operation.
30 - *
31 - * @param id the ID of intent to be removed
32 - * @return the IntentBatchOperation object if succeeded, null otherwise
33 - */
34 - public IntentBatchOperation addRemoveIntentOperation(IntentId id) {
35 - return (null == super.addOperation(
36 - new BatchOperationEntry<Operator, IntentId>(Operator.REMOVE, id)))
37 - ? null : this;
38 - }
39 -}
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import java.util.List; 21 import java.util.List;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import org.onlab.onos.event.AbstractEvent; 21 import org.onlab.onos.event.AbstractEvent;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 /** 21 /**
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import java.util.Map; 21 import java.util.Map;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
21 +import org.onlab.onos.net.flow.BatchOperationTarget;
22 +
3 /** 23 /**
4 * Intent identifier suitable as an external key. 24 * Intent identifier suitable as an external key.
5 * <p/> 25 * <p/>
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import java.util.List; 21 import java.util.List;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import org.onlab.onos.event.EventListener; 21 import org.onlab.onos.event.EventListener;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +package org.onlab.onos.net.intent;
20 +
21 +/**
22 + * Abstraction of an intent-related operation, e.g. add, remove, replace.
23 + */
24 +public class IntentOperation {
25 +
26 + private final Type type;
27 + private final IntentId intentId;
28 + private final Intent intent;
29 +
30 + /**
31 + * Operation type.
32 + */
33 + enum Type {
34 + /**
35 + * Indicates that an intent should be added.
36 + */
37 + SUBMIT,
38 +
39 + /**
40 + * Indicates that an intent should be removed.
41 + */
42 + WITHDRAW,
43 +
44 + /**
45 + * Indicates that an intent should be replaced with another.
46 + */
47 + REPLACE
48 + }
49 +
50 + /**
51 + * Creates an intent operation.
52 + *
53 + * @param type operation type
54 + * @param intentId identifier of the intent subject to the operation
55 + * @param intent intent subject
56 + */
57 + IntentOperation(Type type, IntentId intentId, Intent intent) {
58 + this.type = type;
59 + this.intentId = intentId;
60 + this.intent = intent;
61 + }
62 +
63 + /**
64 + * Returns the type of the operation.
65 + *
66 + * @return operation type
67 + */
68 + public Type type() {
69 + return type;
70 + }
71 +
72 + /**
73 + * Returns the identifier of the intent to which this operation applies.
74 + *
75 + * @return intent identifier
76 + */
77 + public IntentId intentId() {
78 + return intentId;
79 + }
80 +
81 + /**
82 + * Returns the intent to which this operation applied. For remove,
83 + * this can be null.
84 + *
85 + * @return intent that is the subject of the operation; null for remove
86 + */
87 + public Intent intent() {
88 + return intent;
89 + }
90 +
91 +}
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
21 +import com.google.common.collect.ImmutableList;
22 +
23 +import java.util.List;
24 +
25 +import static com.google.common.base.Preconditions.checkNotNull;
26 +import static org.onlab.onos.net.intent.IntentOperation.Type.REPLACE;
27 +import static org.onlab.onos.net.intent.IntentOperation.Type.SUBMIT;
28 +import static org.onlab.onos.net.intent.IntentOperation.Type.WITHDRAW;
29 +
3 /** 30 /**
4 - * Abstraction of a batch of intent submit/withdraw operations. 31 + * Batch of intent submit/withdraw/replace operations.
5 */ 32 */
6 -public interface IntentOperations { 33 +public final class IntentOperations {
34 +
35 + private final List<IntentOperation> operations;
36 +
37 + /**
38 + * Creates a batch of intent operations using the supplied list.
39 + *
40 + * @param operations list of intent operations
41 + */
42 + private IntentOperations(List<IntentOperation> operations) {
43 + this.operations = operations;
44 + }
45 +
46 + /**
47 + * List of operations that need to be executed as a unit.
48 + *
49 + * @return list of intent operations
50 + */
51 + public List<IntentOperation> operations() {
52 + return operations;
53 + }
54 +
55 + /**
56 + * Returns a builder for intent operation batches.
57 + *
58 + * @return intent operations builder
59 + */
60 + public static Builder builder() {
61 + return new Builder();
62 + }
63 +
64 + /**
65 + * Builder for batches of intent operations.
66 + */
67 + public static final class Builder {
68 +
69 + private final ImmutableList.Builder<IntentOperation> builder = ImmutableList.builder();
70 +
71 + // Public construction is forbidden.
72 + private Builder() {
73 + }
74 +
75 + /**
76 + * Adds an intent submit operation.
77 + *
78 + * @param intent intent to be submitted
79 + * @return self
80 + */
81 + public Builder addSubmitOperation(Intent intent) {
82 + checkNotNull(intent, "Intent cannot be null");
83 + builder.add(new IntentOperation(SUBMIT, intent.id(), intent));
84 + return this;
85 + }
86 +
87 + /**
88 + * Adds an intent submit operation.
89 + *
90 + * @param oldIntentId intent to be replaced
91 + * @param newIntent replacement intent
92 + * @return self
93 + */
94 + public Builder addReplaceOperation(IntentId oldIntentId, Intent newIntent) {
95 + checkNotNull(oldIntentId, "Intent ID cannot be null");
96 + checkNotNull(newIntent, "Intent cannot be null");
97 + builder.add(new IntentOperation(REPLACE, oldIntentId, newIntent));
98 + return this;
99 + }
100 +
101 + /**
102 + * Adds an intent submit operation.
103 + *
104 + * @param intentId identifier of the intent to be withdrawn
105 + * @return self
106 + */
107 + public Builder addWithdrawOperation(IntentId intentId) {
108 + checkNotNull(intentId, "Intent ID cannot be null");
109 + builder.add(new IntentOperation(WITHDRAW, intentId, null));
110 + return this;
111 + }
7 112
8 - // TODO: elaborate once the revised BatchOperation scheme is in place 113 + /**
114 + * Builds a batch of intent operations.
115 + *
116 + * @return immutable batch of intent operations
117 + */
118 + public IntentOperations build() {
119 + return new IntentOperations(builder.build());
120 + }
9 121
122 + }
10 } 123 }
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 21
4 import java.util.List; 22 import java.util.List;
23 +import java.util.concurrent.Future;
5 24
6 /** 25 /**
7 * Service for application submitting or withdrawing their intents. 26 * Service for application submitting or withdrawing their intents.
...@@ -28,6 +47,14 @@ public interface IntentService { ...@@ -28,6 +47,14 @@ public interface IntentService {
28 void withdraw(Intent intent); 47 void withdraw(Intent intent);
29 48
30 /** 49 /**
50 + * Replaces the specified intent with a new one.
51 + *
52 + * @param oldIntentId identifier of the old intent being replaced
53 + * @param newIntent new intent replacing the old one
54 + */
55 + void replace(IntentId oldIntentId, Intent newIntent);
56 +
57 + /**
31 * Submits a batch of submit &amp; withdraw operations. Such a batch is 58 * Submits a batch of submit &amp; withdraw operations. Such a batch is
32 * assumed to be processed together. 59 * assumed to be processed together.
33 * <p/> 60 * <p/>
...@@ -36,7 +63,7 @@ public interface IntentService { ...@@ -36,7 +63,7 @@ public interface IntentService {
36 * 63 *
37 * @param operations batch of intent operations 64 * @param operations batch of intent operations
38 */ 65 */
39 - void execute(IntentOperations operations); 66 + Future<IntentOperations> execute(IntentOperations operations);
40 67
41 /** 68 /**
42 * Returns an iterable of intents currently in the system. 69 * Returns an iterable of intents currently in the system.
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 /** 21 /**
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import org.onlab.onos.store.Store; 21 import org.onlab.onos.store.Store;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import org.onlab.onos.store.StoreDelegate; 21 import org.onlab.onos.store.StoreDelegate;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import com.google.common.base.MoreObjects; 21 import com.google.common.base.MoreObjects;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import com.google.common.base.MoreObjects; 21 import com.google.common.base.MoreObjects;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import com.google.common.base.MoreObjects; 21 import com.google.common.base.MoreObjects;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import com.google.common.base.MoreObjects; 21 import com.google.common.base.MoreObjects;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.net.intent; 19 package org.onlab.onos.net.intent;
2 20
3 import com.google.common.base.MoreObjects; 21 import com.google.common.base.MoreObjects;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +
1 /** 20 /**
2 * Set of abstractions for conveying high-level intents for treatment of 21 * Set of abstractions for conveying high-level intents for treatment of
3 * selected network traffic by allowing applications to express the 22 * selected network traffic by allowing applications to express the
......
1 +package org.onlab.onos.net.statistic;
2 +
3 +import com.google.common.base.MoreObjects;
4 +import org.onlab.onos.net.flow.FlowRuleProvider;
5 +
6 +/**
7 + * Implementation of a load.
8 + */
9 +public class DefaultLoad implements Load {
10 +
11 + private final boolean isValid;
12 + private final long current;
13 + private final long previous;
14 + private final long time;
15 +
16 + /**
17 + * Creates an invalid load.
18 + */
19 + public DefaultLoad() {
20 + this.isValid = false;
21 + this.time = System.currentTimeMillis();
22 + this.current = -1;
23 + this.previous = -1;
24 + }
25 +
26 + /**
27 + * Creates a load value from the parameters.
28 + * @param current the current value
29 + * @param previous the previous value
30 + */
31 + public DefaultLoad(long current, long previous) {
32 + this.current = current;
33 + this.previous = previous;
34 + this.time = System.currentTimeMillis();
35 + this.isValid = true;
36 + }
37 +
38 + @Override
39 + public long rate() {
40 + return (current - previous) / FlowRuleProvider.POLL_INTERVAL;
41 + }
42 +
43 + @Override
44 + public long latest() {
45 + return current;
46 + }
47 +
48 + @Override
49 + public boolean isValid() {
50 + return isValid;
51 + }
52 +
53 + @Override
54 + public long time() {
55 + return time;
56 + }
57 +
58 + @Override
59 + public String toString() {
60 + return MoreObjects.toStringHelper("Load").add("rate", rate())
61 + .add("latest", latest()).toString();
62 +
63 + }
64 +}
...@@ -6,15 +6,27 @@ package org.onlab.onos.net.statistic; ...@@ -6,15 +6,27 @@ package org.onlab.onos.net.statistic;
6 public interface Load { 6 public interface Load {
7 7
8 /** 8 /**
9 - * Obtain the current observed rate on a link. 9 + * Obtain the current observed rate (in bytes/s) on a link.
10 * @return long value 10 * @return long value
11 */ 11 */
12 long rate(); 12 long rate();
13 13
14 /** 14 /**
15 - * Obtain the latest counter viewed on that link. 15 + * Obtain the latest bytes counter viewed on that link.
16 * @return long value 16 * @return long value
17 */ 17 */
18 long latest(); 18 long latest();
19 19
20 + /**
21 + * Indicates whether this load was built on valid values.
22 + * @return boolean
23 + */
24 + boolean isValid();
25 +
26 + /**
27 + * Returns when this value was seen.
28 + * @return epoch time
29 + */
30 + long time();
31 +
20 } 32 }
......
...@@ -7,4 +7,9 @@ import org.onlab.onos.net.provider.Provider; ...@@ -7,4 +7,9 @@ import org.onlab.onos.net.provider.Provider;
7 */ 7 */
8 public interface TopologyProvider extends Provider { 8 public interface TopologyProvider extends Provider {
9 9
10 + /**
11 + * Triggers topology recomputation.
12 + */
13 + void triggerRecompute();
14 +
10 } 15 }
......
1 package org.onlab.onos.store.cluster.messaging; 1 package org.onlab.onos.store.cluster.messaging;
2 2
3 +import java.util.concurrent.Future;
3 import java.util.concurrent.TimeUnit; 4 import java.util.concurrent.TimeUnit;
4 import java.util.concurrent.TimeoutException; 5 import java.util.concurrent.TimeoutException;
5 6
6 import org.onlab.onos.cluster.NodeId; 7 import org.onlab.onos.cluster.NodeId;
7 8
8 -public interface ClusterMessageResponse { 9 +public interface ClusterMessageResponse extends Future<byte[]> {
10 +
9 public NodeId sender(); 11 public NodeId sender();
10 - public byte[] get(long timeout, TimeUnit timeunit) throws TimeoutException; 12 +
11 - public byte[] get(long timeout) throws InterruptedException; 13 + // TODO InterruptedException, ExecutionException removed from original
14 + // Future declaration. Revisit if we ever need those.
15 + @Override
16 + public byte[] get(long timeout, TimeUnit unit) throws TimeoutException;
17 +
12 } 18 }
......
...@@ -9,6 +9,7 @@ import java.util.Map; ...@@ -9,6 +9,7 @@ import java.util.Map;
9 import java.util.Set; 9 import java.util.Set;
10 import java.util.concurrent.ExecutorService; 10 import java.util.concurrent.ExecutorService;
11 import java.util.concurrent.Executors; 11 import java.util.concurrent.Executors;
12 +import java.util.concurrent.Future;
12 13
13 /** 14 /**
14 * Fake implementation of the intent service to assist in developing tests of 15 * Fake implementation of the intent service to assist in developing tests of
...@@ -171,11 +172,17 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -171,11 +172,17 @@ public class FakeIntentManager implements TestableIntentService {
171 } 172 }
172 173
173 @Override 174 @Override
174 - public void execute(IntentOperations operations) { 175 + public void replace(IntentId oldIntentId, Intent newIntent) {
175 // TODO: implement later 176 // TODO: implement later
176 } 177 }
177 178
178 @Override 179 @Override
180 + public Future<IntentOperations> execute(IntentOperations operations) {
181 + // TODO: implement later
182 + return null;
183 + }
184 +
185 + @Override
179 public Set<Intent> getIntents() { 186 public Set<Intent> getIntents() {
180 return Collections.unmodifiableSet(new HashSet<>(intents.values())); 187 return Collections.unmodifiableSet(new HashSet<>(intents.values()));
181 } 188 }
......
...@@ -227,10 +227,14 @@ implements MastershipService, MastershipAdminService { ...@@ -227,10 +227,14 @@ implements MastershipService, MastershipAdminService {
227 if (clusterService.getNodes().size() > (clusterSize.intValue() / 2)) { 227 if (clusterService.getNodes().size() > (clusterSize.intValue() / 2)) {
228 return true; 228 return true;
229 } 229 }
230 - //else { 230 +// else {
231 //FIXME: break tie for equal-sized clusters, by number of 231 //FIXME: break tie for equal-sized clusters, by number of
232 // connected switches, then masters, then nodeId hash 232 // connected switches, then masters, then nodeId hash
233 - // } 233 + // problem is, how do we get at channel info cleanly here?
234 + // Also, what's the time hit for a distributed store look-up
235 + // versus channel re-negotiation? bet on the latter being worse.
236 +
237 +// }
234 return false; 238 return false;
235 } 239 }
236 240
......
...@@ -108,6 +108,9 @@ public class FlowRuleManager ...@@ -108,6 +108,9 @@ public class FlowRuleManager
108 if (local) { 108 if (local) {
109 // TODO: aggregate all local rules and push down once? 109 // TODO: aggregate all local rules and push down once?
110 applyFlowRulesToProviders(f); 110 applyFlowRulesToProviders(f);
111 + eventDispatcher.post(
112 + new FlowRuleEvent(FlowRuleEvent.Type.RULE_ADD_REQUESTED, f));
113 +
111 } 114 }
112 } 115 }
113 } 116 }
...@@ -136,6 +139,8 @@ public class FlowRuleManager ...@@ -136,6 +139,8 @@ public class FlowRuleManager
136 if (local) { 139 if (local) {
137 // TODO: aggregate all local rules and push down once? 140 // TODO: aggregate all local rules and push down once?
138 removeFlowRulesFromProviders(f); 141 removeFlowRulesFromProviders(f);
142 + eventDispatcher.post(
143 + new FlowRuleEvent(FlowRuleEvent.Type.RULE_REMOVE_REQUESTED, f));
139 } 144 }
140 } 145 }
141 } 146 }
......
...@@ -126,7 +126,13 @@ public class IntentManager ...@@ -126,7 +126,13 @@ public class IntentManager
126 126
127 // FIXME: implement this method 127 // FIXME: implement this method
128 @Override 128 @Override
129 - public void execute(IntentOperations operations) { 129 + public void replace(IntentId oldIntentId, Intent newIntent) {
130 + throw new UnsupportedOperationException("execute() is not implemented yet");
131 + }
132 +
133 + // FIXME: implement this method
134 + @Override
135 + public Future<IntentOperations> execute(IntentOperations operations) {
130 throw new UnsupportedOperationException("execute() is not implemented yet"); 136 throw new UnsupportedOperationException("execute() is not implemented yet");
131 } 137 }
132 138
......
...@@ -208,7 +208,7 @@ public class LinkManager ...@@ -208,7 +208,7 @@ public class LinkManager
208 LinkEvent event = store.createOrUpdateLink(provider().id(), 208 LinkEvent event = store.createOrUpdateLink(provider().id(),
209 linkDescription); 209 linkDescription);
210 if (event != null) { 210 if (event != null) {
211 - log.debug("Link {} detected", linkDescription); 211 + log.info("Link {} detected", linkDescription);
212 post(event); 212 post(event);
213 } 213 }
214 } 214 }
......
...@@ -68,7 +68,9 @@ implements PacketService, PacketProviderRegistry { ...@@ -68,7 +68,9 @@ implements PacketService, PacketProviderRegistry {
68 checkNotNull(packet, "Packet cannot be null"); 68 checkNotNull(packet, "Packet cannot be null");
69 final Device device = deviceService.getDevice(packet.sendThrough()); 69 final Device device = deviceService.getDevice(packet.sendThrough());
70 final PacketProvider packetProvider = getProvider(device.providerId()); 70 final PacketProvider packetProvider = getProvider(device.providerId());
71 - packetProvider.emit(packet); 71 + if (packetProvider != null) {
72 + packetProvider.emit(packet);
73 + }
72 } 74 }
73 75
74 @Override 76 @Override
......
...@@ -10,14 +10,17 @@ import org.onlab.onos.net.ConnectPoint; ...@@ -10,14 +10,17 @@ import org.onlab.onos.net.ConnectPoint;
10 import org.onlab.onos.net.Link; 10 import org.onlab.onos.net.Link;
11 import org.onlab.onos.net.Path; 11 import org.onlab.onos.net.Path;
12 12
13 +import org.onlab.onos.net.flow.FlowEntry;
13 import org.onlab.onos.net.flow.FlowRule; 14 import org.onlab.onos.net.flow.FlowRule;
14 import org.onlab.onos.net.flow.FlowRuleEvent; 15 import org.onlab.onos.net.flow.FlowRuleEvent;
15 import org.onlab.onos.net.flow.FlowRuleListener; 16 import org.onlab.onos.net.flow.FlowRuleListener;
16 import org.onlab.onos.net.flow.FlowRuleService; 17 import org.onlab.onos.net.flow.FlowRuleService;
18 +import org.onlab.onos.net.statistic.DefaultLoad;
17 import org.onlab.onos.net.statistic.Load; 19 import org.onlab.onos.net.statistic.Load;
18 import org.onlab.onos.net.statistic.StatisticService; 20 import org.onlab.onos.net.statistic.StatisticService;
19 import org.onlab.onos.net.statistic.StatisticStore; 21 import org.onlab.onos.net.statistic.StatisticStore;
20 import org.slf4j.Logger; 22 import org.slf4j.Logger;
23 +import java.util.Set;
21 24
22 import static org.slf4j.LoggerFactory.getLogger; 25 import static org.slf4j.LoggerFactory.getLogger;
23 26
...@@ -54,27 +57,91 @@ public class StatisticManager implements StatisticService { ...@@ -54,27 +57,91 @@ public class StatisticManager implements StatisticService {
54 57
55 @Override 58 @Override
56 public Load load(Link link) { 59 public Load load(Link link) {
57 - return null; 60 + return load(link.src());
58 } 61 }
59 62
60 @Override 63 @Override
61 public Load load(ConnectPoint connectPoint) { 64 public Load load(ConnectPoint connectPoint) {
62 - return null; 65 + return loadInternal(connectPoint);
63 } 66 }
64 67
65 @Override 68 @Override
66 public Link max(Path path) { 69 public Link max(Path path) {
67 - return null; 70 + if (path.links().isEmpty()) {
71 + return null;
72 + }
73 + Load maxLoad = new DefaultLoad();
74 + Link maxLink = null;
75 + for (Link link : path.links()) {
76 + Load load = loadInternal(link.src());
77 + if (load.rate() > maxLoad.rate()) {
78 + maxLoad = load;
79 + maxLink = link;
80 + }
81 + }
82 + return maxLink;
68 } 83 }
69 84
70 @Override 85 @Override
71 public Link min(Path path) { 86 public Link min(Path path) {
72 - return null; 87 + if (path.links().isEmpty()) {
88 + return null;
89 + }
90 + Load minLoad = new DefaultLoad();
91 + Link minLink = null;
92 + for (Link link : path.links()) {
93 + Load load = loadInternal(link.src());
94 + if (load.rate() < minLoad.rate()) {
95 + minLoad = load;
96 + minLink = link;
97 + }
98 + }
99 + return minLink;
73 } 100 }
74 101
75 @Override 102 @Override
76 public FlowRule highestHitter(ConnectPoint connectPoint) { 103 public FlowRule highestHitter(ConnectPoint connectPoint) {
77 - return null; 104 + Set<FlowEntry> hitters = statisticStore.getCurrentStatistic(connectPoint);
105 + if (hitters.isEmpty()) {
106 + return null;
107 + }
108 +
109 + FlowEntry max = hitters.iterator().next();
110 + for (FlowEntry entry : hitters) {
111 + if (entry.bytes() > max.bytes()) {
112 + max = entry;
113 + }
114 + }
115 + return max;
116 + }
117 +
118 + private Load loadInternal(ConnectPoint connectPoint) {
119 + Set<FlowEntry> current;
120 + Set<FlowEntry> previous;
121 + synchronized (statisticStore) {
122 + current = statisticStore.getCurrentStatistic(connectPoint);
123 + previous = statisticStore.getPreviousStatistic(connectPoint);
124 + }
125 + if (current == null || previous == null) {
126 + return new DefaultLoad();
127 + }
128 + long currentAggregate = aggregate(current);
129 + long previousAggregate = aggregate(previous);
130 +
131 + return new DefaultLoad(currentAggregate, previousAggregate);
132 + }
133 +
134 + /**
135 + * Aggregates a set of values.
136 + * @param values the values to aggregate
137 + * @return a long value
138 + */
139 + private long aggregate(Set<FlowEntry> values) {
140 + long sum = 0;
141 + for (FlowEntry f : values) {
142 + sum += f.bytes();
143 + }
144 + return sum;
78 } 145 }
79 146
80 /** 147 /**
...@@ -84,22 +151,29 @@ public class StatisticManager implements StatisticService { ...@@ -84,22 +151,29 @@ public class StatisticManager implements StatisticService {
84 151
85 @Override 152 @Override
86 public void event(FlowRuleEvent event) { 153 public void event(FlowRuleEvent event) {
87 -// FlowRule rule = event.subject(); 154 + FlowRule rule = event.subject();
88 -// switch (event.type()) { 155 + switch (event.type()) {
89 -// case RULE_ADDED: 156 + case RULE_ADDED:
90 -// case RULE_UPDATED: 157 + case RULE_UPDATED:
91 -// if (rule instanceof FlowEntry) { 158 + if (rule instanceof FlowEntry) {
92 -// statisticStore.addOrUpdateStatistic((FlowEntry) rule); 159 + statisticStore.addOrUpdateStatistic((FlowEntry) rule);
93 -// } 160 + } else {
94 -// break; 161 + log.warn("IT AIN'T A FLOWENTRY");
95 -// case RULE_ADD_REQUESTED: 162 + }
96 -// statisticStore.prepareForStatistics(rule); 163 + break;
97 -// break; 164 + case RULE_ADD_REQUESTED:
98 -// case RULE_REMOVE_REQUESTED: 165 + log.info("Preparing for stats");
99 -// case RULE_REMOVED: 166 + statisticStore.prepareForStatistics(rule);
100 -// statisticStore.removeFromStatistics(rule); 167 + break;
101 -// break; 168 + case RULE_REMOVE_REQUESTED:
102 -// } 169 + log.info("Removing stats");
170 + statisticStore.removeFromStatistics(rule);
171 + break;
172 + case RULE_REMOVED:
173 + break;
174 + default:
175 + log.warn("Unknown flow rule event {}", event);
176 + }
103 } 177 }
104 } 178 }
105 179
......
...@@ -5,6 +5,7 @@ import org.apache.felix.scr.annotations.Component; ...@@ -5,6 +5,7 @@ import org.apache.felix.scr.annotations.Component;
5 import org.apache.felix.scr.annotations.Deactivate; 5 import org.apache.felix.scr.annotations.Deactivate;
6 import org.apache.felix.scr.annotations.Reference; 6 import org.apache.felix.scr.annotations.Reference;
7 import org.apache.felix.scr.annotations.ReferenceCardinality; 7 import org.apache.felix.scr.annotations.ReferenceCardinality;
8 +import org.apache.felix.scr.annotations.Service;
8 import org.onlab.onos.event.AbstractEventAccumulator; 9 import org.onlab.onos.event.AbstractEventAccumulator;
9 import org.onlab.onos.event.Event; 10 import org.onlab.onos.event.Event;
10 import org.onlab.onos.event.EventAccumulator; 11 import org.onlab.onos.event.EventAccumulator;
...@@ -39,6 +40,7 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -39,6 +40,7 @@ import static org.slf4j.LoggerFactory.getLogger;
39 * new topology snapshots. 40 * new topology snapshots.
40 */ 41 */
41 @Component(immediate = true) 42 @Component(immediate = true)
43 +@Service
42 public class DefaultTopologyProvider extends AbstractProvider 44 public class DefaultTopologyProvider extends AbstractProvider
43 implements TopologyProvider { 45 implements TopologyProvider {
44 46
...@@ -89,7 +91,7 @@ public class DefaultTopologyProvider extends AbstractProvider ...@@ -89,7 +91,7 @@ public class DefaultTopologyProvider extends AbstractProvider
89 linkService.addListener(linkListener); 91 linkService.addListener(linkListener);
90 92
91 isStarted = true; 93 isStarted = true;
92 - triggerTopologyBuild(Collections.<Event>emptyList()); 94 + triggerRecompute();
93 log.info("Started"); 95 log.info("Started");
94 } 96 }
95 97
...@@ -108,6 +110,11 @@ public class DefaultTopologyProvider extends AbstractProvider ...@@ -108,6 +110,11 @@ public class DefaultTopologyProvider extends AbstractProvider
108 log.info("Stopped"); 110 log.info("Stopped");
109 } 111 }
110 112
113 + @Override
114 + public void triggerRecompute() {
115 + triggerTopologyBuild(Collections.<Event>emptyList());
116 + }
117 +
111 /** 118 /**
112 * Triggers assembly of topology data citing the specified events as the 119 * Triggers assembly of topology data citing the specified events as the
113 * reason. 120 * reason.
...@@ -177,7 +184,11 @@ public class DefaultTopologyProvider extends AbstractProvider ...@@ -177,7 +184,11 @@ public class DefaultTopologyProvider extends AbstractProvider
177 184
178 @Override 185 @Override
179 public void run() { 186 public void run() {
180 - buildTopology(reasons); 187 + try {
188 + buildTopology(reasons);
189 + } catch (Exception e) {
190 + log.warn("Unable to compute topology due to: {}", e.getMessage());
191 + }
181 } 192 }
182 } 193 }
183 194
......
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.