tom

Sketching SB & NB API.

Modified onos-of-api pom to subsume openflowj loxi-generated stuff.
Showing 32 changed files with 387 additions and 24 deletions
...@@ -7,4 +7,5 @@ ...@@ -7,4 +7,5 @@
7 .javacp* 7 .javacp*
8 target 8 target
9 *.iml 9 *.iml
10 +dependency-reduced-pom.xml
10 .idea 11 .idea
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
6 <feature name="onos-thirdparty-base" version="1.0.0" 6 <feature name="onos-thirdparty-base" version="1.0.0"
7 description="ONOS 3rd party dependencies"> 7 description="ONOS 3rd party dependencies">
8 <bundle>mvn:com.google.guava/guava/17.0</bundle> 8 <bundle>mvn:com.google.guava/guava/17.0</bundle>
9 - <bundle>mvn:io.netty/netty/3.9.2.Final</bundle>
10 </feature> 9 </feature>
11 10
12 <feature name="onos-thirdparty-web" version="1.0.0" 11 <feature name="onos-thirdparty-web" version="1.0.0"
...@@ -55,7 +54,6 @@ ...@@ -55,7 +54,6 @@
55 description="ONOS OpenFlow API, Controller &amp; Providers"> 54 description="ONOS OpenFlow API, Controller &amp; Providers">
56 <feature>onos-core</feature> 55 <feature>onos-core</feature>
57 <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> 56 <bundle>mvn:io.netty/netty/3.9.2.Final</bundle>
58 - <bundle>mvn:com.google.guava/guava/15.0</bundle>
59 57
60 <bundle>mvn:org.onlab.onos/openflow-api/1.0.0-SNAPSHOT</bundle> 58 <bundle>mvn:org.onlab.onos/openflow-api/1.0.0-SNAPSHOT</bundle>
61 <bundle>mvn:org.onlab.onos/openflow-ctl/1.0.0-SNAPSHOT</bundle> 59 <bundle>mvn:org.onlab.onos/openflow-ctl/1.0.0-SNAPSHOT</bundle>
......
1 +package org.onlab.onos.event;
2 +
3 +/**
4 + * Base abstraction of an event.
5 + */
6 +public class AbstractEvent<T extends Enum, S extends Object> implements Event<T, S> {
7 +
8 + private final long time;
9 + private final T type;
10 + private S subject;
11 +
12 + /**
13 + * Creates an event of a given type and for the specified subject and the
14 + * current time.
15 + *
16 + * @param type event type
17 + * @param subject event subject
18 + */
19 + protected AbstractEvent(T type, S subject) {
20 + this(type, subject, System.currentTimeMillis());
21 + }
22 +
23 + /**
24 + * Creates an event of a given type and for the specified subject and time.
25 + *
26 + * @param type event type
27 + * @param subject event subject
28 + * @param time occurrence time
29 + */
30 + protected AbstractEvent(T type, S subject, long time) {
31 + this.type = type;
32 + this.subject = subject;
33 + this.time = time;
34 + }
35 +
36 + @Override
37 + public long time() {
38 + return time;
39 + }
40 +
41 + @Override
42 + public T type() {
43 + return type;
44 + }
45 +
46 + @Override
47 + public S subject() {
48 + return subject;
49 + }
50 +
51 +}
1 +package org.onlab.onos.event;
2 +
3 +/**
4 + * Abstraction of an event.
5 + */
6 +public interface Event<T extends Enum, S extends Object> {
7 +
8 + /**
9 + * Returns the timestamp of when the event occurred, given in milliseconds
10 + * since the start of epoch.
11 + *
12 + * @return timestamp in milliseconds
13 + */
14 + long time();
15 +
16 + /**
17 + * Returns the type of the event.
18 + *
19 + * @return event type
20 + */
21 + T type();
22 +
23 + /**
24 + * Returns the subject of the event.
25 + *
26 + * @return subject to which this event pertains
27 + */
28 + S subject();
29 +
30 +}
1 +package org.onlab.onos.event;
2 +
3 +/**
4 + * Entity capable of receiving events.
5 + */
6 +public interface EventListener<E extends Event> {
7 +
8 + /**
9 + * Reacts to the specified event.
10 + *
11 + * @param event event to be processed
12 + */
13 + void event(E event);
14 +
15 +}
1 +package org.onlab.onos.net;
2 +
3 +/**
4 + * Representation of an network infrastructure device.
5 + */
6 +public class Device {
7 +
8 + // type, e.g. switch, router, firewall, ips, controller
9 +
10 + // id (uri within)
11 +
12 + // ports
13 +
14 +}
1 +package org.onlab.onos.net;
2 +
3 +/**
4 + * Abstraction of an end-station host on the network, essentially a NIC.
5 + */
6 +public class Host {
7 +
8 + // MAC, IP(s), optional VLAN ID
9 +
10 + // Location (current, recent locations?
11 +
12 +}
1 +package org.onlab.onos.net;
2 +
3 +/**
4 + * Representation of a relationship role of a controller instance to a device
5 + * or a region of network environment.
6 + */
7 +public enum MastershipRole {
8 +
9 + /**
10 + * Represents a relationship where the controller instance is the master
11 + * to a device or a region of network environment.
12 + */
13 + MASTER,
14 +
15 + /**
16 + * Represents a relationship where the controller instance is the standby,
17 + * i.e. potential master to a device or a region of network environment.
18 + */
19 + STANDBY,
20 +
21 + /**
22 + * Represents that the controller instance is not eligible to be the master
23 + * to a device or a region of network environment.
24 + */
25 + NONE
26 +
27 +}
1 +package org.onlab.onos.net.device;
2 +
3 +import org.onlab.onos.event.AbstractEvent;
4 +import org.onlab.onos.net.Device;
5 +
6 +/**
7 + * Describes infrastructure device event.
8 + */
9 +public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
10 +
11 + /**
12 + * Type of device events.
13 + */
14 + public enum Type {
15 + /** Signifies that a new device has been detected. */
16 + DEVICE_ADDED,
17 +
18 + /** Signifies that a device has been removed. */
19 + DEVICE_REMOVED,
20 +
21 + /** Signifies that a device has been administratively suspended. */
22 + DEVICE_SUSPENDED,
23 +
24 + /** Signifies that a device has come online or has gone offline. */
25 + DEVICE_AVAILABILITY_CHANGED,
26 +
27 + /**
28 + * Signifies that the current controller instance relationship has
29 + * changed with respect to a device.
30 + */
31 + DEVICE_MASTERSHIP_CHANGED
32 + }
33 +
34 + /**
35 + * Creates an event of a given type and for the specified subject and the
36 + * current time.
37 + *
38 + * @param type event type
39 + * @param subject event subject
40 + */
41 + public DeviceEvent(Type type, Device subject) {
42 + super(type, subject);
43 + }
44 +
45 + /**
46 + * Creates an event of a given type and for the specified subject and time.
47 + *
48 + * @param type event type
49 + * @param subject event subject
50 + * @param time occurrence time
51 + */
52 + public DeviceEvent(Type type, Device subject, long time) {
53 + super(type, subject, time);
54 + }
55 +
56 +}
1 +package org.onlab.onos.net.device;
2 +
3 +/**
4 + * Entity capable of receiving device related events.
5 + */
6 +public interface DeviceListener {
7 +}
1 package org.onlab.onos.net.device; 1 package org.onlab.onos.net.device;
2 2
3 -import org.onlab.onos.net.Provider; 3 +import org.onlab.onos.net.Device;
4 +import org.onlab.onos.net.MastershipRole;
5 +import org.onlab.onos.provider.Provider;
4 6
5 /** 7 /**
6 * Abstraction of a device information provider. 8 * Abstraction of a device information provider.
7 */ 9 */
8 public interface DeviceProvider extends Provider { 10 public interface DeviceProvider extends Provider {
11 +
12 + // TODO: consider how dirty the triggerProbe gets; if it costs too much, let's drop it
13 +
14 + /**
15 + * Triggers an asynchronous probe of the specified device, intended to
16 + * determine whether the host is present or not. An indirect result of this
17 + * should be invocation of
18 + * {@link org.onlab.onos.net.device.DeviceProviderService#deviceConnected(DeviceDescription)} )} or
19 + * {@link org.onlab.onos.net.device.DeviceProviderService#deviceDisconnected(DeviceDescription)}
20 + * at some later point in time.
21 + *
22 + * @param device device to be probed
23 + */
24 + void triggerProbe(Device device);
25 +
26 + /**
27 + * Notifies the provider of a mastership role change for the specified
28 + * device as decided by the core.
29 + *
30 + * @param device affected device
31 + * @param newRole newly determined mastership role
32 + */
33 + void roleChanged(Device device, MastershipRole newRole);
34 +
9 } 35 }
......
1 package org.onlab.onos.net.device; 1 package org.onlab.onos.net.device;
2 2
3 -import org.onlab.onos.net.ProviderBroker; 3 +import org.onlab.onos.provider.ProviderBroker;
4 4
5 /** 5 /**
6 * Abstraction of a device provider brokerage. 6 * Abstraction of a device provider brokerage.
......
1 package org.onlab.onos.net.device; 1 package org.onlab.onos.net.device;
2 2
3 -import org.onlab.onos.net.ProviderService; 3 +import org.onlab.onos.net.MastershipRole;
4 +import org.onlab.onos.provider.ProviderService;
4 5
5 import java.util.List; 6 import java.util.List;
6 7
...@@ -16,8 +17,9 @@ public interface DeviceProviderService extends ProviderService { ...@@ -16,8 +17,9 @@ public interface DeviceProviderService extends ProviderService {
16 * Signals the core that a device has connected or has been detected somehow. 17 * Signals the core that a device has connected or has been detected somehow.
17 * 18 *
18 * @param deviceDescription information about network device 19 * @param deviceDescription information about network device
20 + * @return mastership role chosen by the provider service
19 */ 21 */
20 - void deviceConnected(DeviceDescription deviceDescription); 22 + MastershipRole deviceConnected(DeviceDescription deviceDescription);
21 23
22 /** 24 /**
23 * Signals the core that a device has disconnected or is no longer reachable. 25 * Signals the core that a device has disconnected or is no longer reachable.
......
1 +package org.onlab.onos.net.device;
2 +
3 +import org.onlab.onos.net.Device;
4 +import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.MastershipRole;
6 +
7 +/**
8 + * Service for interacting with the inventory of infrastructure devices.
9 + */
10 +public interface DeviceService {
11 +
12 + /**
13 + * Returns the current mastership role for the specified device.
14 + *
15 + * @param deviceId device identifier
16 + * @return designated mastership role
17 + */
18 + MastershipRole getRole(DeviceId deviceId);
19 +
20 + /**
21 + * Returns an iterable collection of the currently known infrastructure
22 + * devices.
23 + *
24 + * @return collection of devices
25 + */
26 + Iterable<Device> getDevices();
27 +
28 + /**
29 + * Returns the device with the specified identifier.
30 + *
31 + * @param deviceId device identifier
32 + * @return device or null if one with the given identifier is not known
33 + */
34 + Device getDevice(DeviceId deviceId);
35 +
36 +
37 +// List<Port> getPorts(DeviceId deviceId);
38 +
39 + /**
40 + * Adds the specified device listener.
41 + *
42 + * @param listener device listener
43 + */
44 + void addListener(DeviceListener listener);
45 +
46 + /**
47 + * Removes the specified device listener.
48 + *
49 + * @param listener device listener
50 + */
51 + void removeListener(DeviceListener listener);
52 +}
1 package org.onlab.onos.net.flow; 1 package org.onlab.onos.net.flow;
2 2
3 -import org.onlab.onos.net.Provider; 3 +import org.onlab.onos.provider.Provider;
4 4
5 /** 5 /**
6 * Abstraction of a flow rule provider. 6 * Abstraction of a flow rule provider.
7 */ 7 */
8 public interface FlowRuleProvider extends Provider { 8 public interface FlowRuleProvider extends Provider {
9 +
10 + // TODO: pushFlowRule
11 +
9 } 12 }
......
1 package org.onlab.onos.net.flow; 1 package org.onlab.onos.net.flow;
2 2
3 -import org.onlab.onos.net.ProviderBroker; 3 +import org.onlab.onos.provider.ProviderBroker;
4 4
5 /** 5 /**
6 * Abstraction for a flow rule provider brokerage. 6 * Abstraction for a flow rule provider brokerage.
......
1 package org.onlab.onos.net.flow; 1 package org.onlab.onos.net.flow;
2 2
3 -import org.onlab.onos.net.ProviderService; 3 +import org.onlab.onos.provider.ProviderService;
4 4
5 /** 5 /**
6 * Service through which flowrule providers can inject flowrule information into 6 * Service through which flowrule providers can inject flowrule information into
......
1 package org.onlab.onos.net.host; 1 package org.onlab.onos.net.host;
2 2
3 -import org.onlab.onos.net.Provider; 3 +import org.onlab.onos.net.Host;
4 +import org.onlab.onos.provider.Provider;
4 5
5 /** 6 /**
6 * Provider of information about hosts and their location on the network. 7 * Provider of information about hosts and their location on the network.
7 */ 8 */
8 public interface HostProvider extends Provider { 9 public interface HostProvider extends Provider {
10 +
11 + // TODO: consider how dirty the triggerProbe gets; if it costs too much, let's drop it
12 +
13 + /**
14 + * Triggers an asynchronous probe of the specified host, intended to
15 + * determine whether the host is present or not. An indirect result of this
16 + * should be invocation of {@link org.onlab.onos.net.host.HostProviderService#hostDetected(HostDescription)} or
17 + * {@link org.onlab.onos.net.host.HostProviderService#hostNotDetected(HostDescription)}
18 + * at some later point in time.
19 + *
20 + * @param host host to probe
21 + */
22 + void triggerProbe(Host host);
23 +
9 } 24 }
......
1 package org.onlab.onos.net.host; 1 package org.onlab.onos.net.host;
2 2
3 -import org.onlab.onos.net.ProviderBroker; 3 +import org.onlab.onos.provider.ProviderBroker;
4 4
5 /** 5 /**
6 * Abstraction of a host provider brokerage. 6 * Abstraction of a host provider brokerage.
......
1 package org.onlab.onos.net.host; 1 package org.onlab.onos.net.host;
2 2
3 -import org.onlab.onos.net.ProviderService; 3 +import org.onlab.onos.provider.ProviderService;
4 4
5 /** 5 /**
6 * Means of conveying host information to the core. 6 * Means of conveying host information to the core.
7 */ 7 */
8 public interface HostProviderService extends ProviderService { 8 public interface HostProviderService extends ProviderService {
9 9
10 + /**
11 + * Notifies the core when a host has been detected on a network along with
12 + * information that identifies the hoot location.
13 + *
14 + * @param hostDescription description of host and its location
15 + */
10 void hostDetected(HostDescription hostDescription); 16 void hostDetected(HostDescription hostDescription);
11 17
18 + /**
19 + * Notifies the core when a host is no longer detected on a network.
20 + *
21 + * @param hostDescription description of host
22 + */
23 + void hostNotDetected(HostDescription hostDescription);
24 +
12 } 25 }
......
1 package org.onlab.onos.net.link; 1 package org.onlab.onos.net.link;
2 2
3 -import org.onlab.onos.net.Provider; 3 +import org.onlab.onos.provider.Provider;
4 4
5 /** 5 /**
6 * Abstraction of an entity providing information about infrastructure links 6 * Abstraction of an entity providing information about infrastructure links
......
1 package org.onlab.onos.net.link; 1 package org.onlab.onos.net.link;
2 2
3 -import org.onlab.onos.net.ProviderBroker; 3 +import org.onlab.onos.provider.ProviderBroker;
4 4
5 /** 5 /**
6 * Abstraction of an infrastructure link provider brokerage. 6 * Abstraction of an infrastructure link provider brokerage.
......
1 package org.onlab.onos.net.link; 1 package org.onlab.onos.net.link;
2 2
3 -import org.onlab.onos.net.ProviderService; 3 +import org.onlab.onos.provider.ProviderService;
4 4
5 /** 5 /**
6 * Means for injecting link information into the core. 6 * Means for injecting link information into the core.
......
1 package org.onlab.onos.net.topology; 1 package org.onlab.onos.net.topology;
2 2
3 -import org.onlab.onos.net.Provider; 3 +import org.onlab.onos.provider.Provider;
4 4
5 /** 5 /**
6 * Means for injecting topology information into the core. 6 * Means for injecting topology information into the core.
......
1 package org.onlab.onos.net.topology; 1 package org.onlab.onos.net.topology;
2 2
3 -import org.onlab.onos.net.ProviderBroker; 3 +import org.onlab.onos.provider.ProviderBroker;
4 4
5 /** 5 /**
6 * Abstraction of a network topology provider brokerage. 6 * Abstraction of a network topology provider brokerage.
......
1 package org.onlab.onos.net.topology; 1 package org.onlab.onos.net.topology;
2 2
3 -import org.onlab.onos.net.ProviderService; 3 +import org.onlab.onos.provider.ProviderService;
4 4
5 /** 5 /**
6 * Means for injecting topology information into the core. 6 * Means for injecting topology information into the core.
......
1 -package org.onlab.onos.net; 1 +package org.onlab.onos.provider;
2 2
3 /** 3 /**
4 * Abstraction of a provider of information about network environment. 4 * Abstraction of a provider of information about network environment.
......
1 -package org.onlab.onos.net; 1 +package org.onlab.onos.provider;
2 2
3 /** 3 /**
4 * Broker used for registering/unregistering information providers with the core. 4 * Broker used for registering/unregistering information providers with the core.
......
1 -package org.onlab.onos.net; 1 +package org.onlab.onos.provider;
2 2
3 /** 3 /**
4 * Notion of provider identity. 4 * Notion of provider identity.
......
1 -package org.onlab.onos.net; 1 +package org.onlab.onos.provider;
2 2
3 /** 3 /**
4 * Abstraction of a service through which providers can inject information 4 * Abstraction of a service through which providers can inject information
......
...@@ -16,4 +16,42 @@ ...@@ -16,4 +16,42 @@
16 16
17 <description>ONOS OpenFlow controller subsystem API</description> 17 <description>ONOS OpenFlow controller subsystem API</description>
18 18
19 + <dependencies>
20 + <dependency>
21 + <groupId>org.projectfloodlight</groupId>
22 + <artifactId>openflowj</artifactId>
23 + <version>0.3.8-SNAPSHOT</version>
24 + </dependency>
25 + </dependencies>
26 +
27 + <build>
28 + <plugins>
29 + <plugin>
30 + <groupId>org.apache.maven.plugins</groupId>
31 + <artifactId>maven-shade-plugin</artifactId>
32 + <version>2.3</version>
33 + <configuration>
34 + <artifactSet>
35 + <excludes>
36 + <exclude>io.netty:netty</exclude>
37 + <exclude>com.google.guava:guava</exclude>
38 + <exclude>org.slf4j:slfj-api</exclude>
39 + <exclude>ch.qos.logback:logback-core</exclude>
40 + <exclude>ch.qos.logback:logback-classic</exclude>
41 + <exclude>com.google.code.findbugs:annotations</exclude>
42 + </excludes>
43 + </artifactSet>
44 + </configuration>
45 + <executions>
46 + <execution>
47 + <phase>package</phase>
48 + <goals>
49 + <goal>shade</goal>
50 + </goals>
51 + </execution>
52 + </executions>
53 + </plugin>
54 + </plugins>
55 + </build>
56 +
19 </project> 57 </project>
......
...@@ -193,9 +193,7 @@ ...@@ -193,9 +193,7 @@
193 </configuration> 193 </configuration>
194 </plugin> 194 </plugin>
195 195
196 -
197 <!-- TODO: add jacoco plugin for unit test coverage; for explicit invocation only --> 196 <!-- TODO: add jacoco plugin for unit test coverage; for explicit invocation only -->
198 -
199 <!-- TODO: add findbugs plugin for static code analysis; for explicit invocation only --> 197 <!-- TODO: add findbugs plugin for static code analysis; for explicit invocation only -->
200 <!-- TODO: add sonarqube plugin for code analysis; for explicit invocation only --> 198 <!-- TODO: add sonarqube plugin for code analysis; for explicit invocation only -->
201 199
...@@ -205,6 +203,11 @@ ...@@ -205,6 +203,11 @@
205 <plugins> 203 <plugins>
206 <plugin> 204 <plugin>
207 <groupId>org.apache.maven.plugins</groupId> 205 <groupId>org.apache.maven.plugins</groupId>
206 + <artifactId>maven-jar-plugin</artifactId>
207 + </plugin>
208 +
209 + <plugin>
210 + <groupId>org.apache.maven.plugins</groupId>
208 <artifactId>maven-checkstyle-plugin</artifactId> 211 <artifactId>maven-checkstyle-plugin</artifactId>
209 <version>2.12.1</version> 212 <version>2.12.1</version>
210 <dependencies> 213 <dependencies>
......