alshabib

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

Showing 1000 changed files with 530 additions and 3439 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

...@@ -3,7 +3,7 @@ package org.onlab.onos.cli; ...@@ -3,7 +3,7 @@ package org.onlab.onos.cli;
3 import org.apache.karaf.shell.commands.Argument; 3 import org.apache.karaf.shell.commands.Argument;
4 import org.apache.karaf.shell.commands.Command; 4 import org.apache.karaf.shell.commands.Command;
5 import org.apache.karaf.shell.console.OsgiCommandSupport; 5 import org.apache.karaf.shell.console.OsgiCommandSupport;
6 -import org.onlab.onos.net.GreetService; 6 +import org.onlab.onos.GreetService;
7 7
8 /** 8 /**
9 * Simple command example to demonstrate use of Karaf shell extensions; shows 9 * Simple command example to demonstrate use of Karaf shell extensions; shows
......
...@@ -2,7 +2,7 @@ package org.onlab.onos.cli; ...@@ -2,7 +2,7 @@ package org.onlab.onos.cli;
2 2
3 import org.apache.karaf.shell.console.Completer; 3 import org.apache.karaf.shell.console.Completer;
4 import org.apache.karaf.shell.console.completer.StringsCompleter; 4 import org.apache.karaf.shell.console.completer.StringsCompleter;
5 -import org.onlab.onos.net.GreetService; 5 +import org.onlab.onos.GreetService;
6 6
7 import java.util.Iterator; 7 import java.util.Iterator;
8 import java.util.List; 8 import java.util.List;
......
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
23 description="ONOS services and model API"> 23 description="ONOS services and model API">
24 <feature>scr</feature> 24 <feature>scr</feature>
25 <feature>onos-thirdparty-base</feature> 25 <feature>onos-thirdparty-base</feature>
26 - <bundle>mvn:org.onlab.onos/onos-utils-osgi/1.0.0-SNAPSHOT</bundle> 26 + <bundle>mvn:org.onlab.onos/onlab-misc/1.0.0-SNAPSHOT</bundle>
27 - <bundle>mvn:org.onlab.onos/onos-utils-rest/1.0.0-SNAPSHOT</bundle> 27 + <bundle>mvn:org.onlab.onos/onlab-osgi/1.0.0-SNAPSHOT</bundle>
28 + <bundle>mvn:org.onlab.onos/onlab-rest/1.0.0-SNAPSHOT</bundle>
28 29
29 <bundle>mvn:org.onlab.onos/onos-api/1.0.0-SNAPSHOT</bundle> 30 <bundle>mvn:org.onlab.onos/onos-api/1.0.0-SNAPSHOT</bundle>
30 </feature> 31 </feature>
......
1 -package org.onlab.onos.net; 1 +package org.onlab.onos;
2 2
3 /** 3 /**
4 * Example of a simple service that provides greetings and it 4 * Example of a simple service that provides greetings and it
......
1 package org.onlab.onos.event; 1 package org.onlab.onos.event;
2 2
3 /** 3 /**
4 - * Base abstraction of an event. 4 + * Base event implementation.
5 */ 5 */
6 public class AbstractEvent<T extends Enum, S extends Object> implements Event<T, S> { 6 public class AbstractEvent<T extends Enum, S extends Object> implements Event<T, S> {
7 7
......
1 package org.onlab.onos.event; 1 package org.onlab.onos.event;
2 2
3 import org.slf4j.Logger; 3 import org.slf4j.Logger;
4 -import org.slf4j.LoggerFactory;
5 4
6 import java.util.Set; 5 import java.util.Set;
7 import java.util.concurrent.CopyOnWriteArraySet; 6 import java.util.concurrent.CopyOnWriteArraySet;
8 7
9 import static com.google.common.base.Preconditions.checkArgument; 8 import static com.google.common.base.Preconditions.checkArgument;
10 import static com.google.common.base.Preconditions.checkNotNull; 9 import static com.google.common.base.Preconditions.checkNotNull;
10 +import static org.slf4j.LoggerFactory.getLogger;
11 11
12 /** 12 /**
13 - * Base implementation of a manager capable of tracking listeners and 13 + * Base implementation of an event sink and a registry capable of tracking
14 - * dispatching events to them. 14 + * listeners and dispatching events to them as part of event sink processing.
15 */ 15 */
16 -public class AbstractListenerManager<E extends Event, L extends EventListener<E>> 16 +public class AbstractListenerRegistry<E extends Event, L extends EventListener<E>>
17 implements EventSink<E> { 17 implements EventSink<E> {
18 18
19 - protected Logger log = LoggerFactory.getLogger(AbstractListenerManager.class); 19 + private final Logger log = getLogger(getClass());
20 20
21 private final Set<L> listeners = new CopyOnWriteArraySet<>(); 21 private final Set<L> listeners = new CopyOnWriteArraySet<>();
22 22
......
...@@ -10,12 +10,12 @@ import static com.google.common.base.Preconditions.checkArgument; ...@@ -10,12 +10,12 @@ import static com.google.common.base.Preconditions.checkArgument;
10 import static com.google.common.base.Preconditions.checkNotNull; 10 import static com.google.common.base.Preconditions.checkNotNull;
11 11
12 /** 12 /**
13 - * Base implementation of event sink broker. 13 + * Base implementation of event sink registry.
14 */ 14 */
15 -public class DefaultEventSinkBroker implements EventSinkBroker { 15 +public class DefaultEventSinkRegistry implements EventSinkRegistry {
16 16
17 - private final Map<Class<? extends Event>, EventSink<? extends Event>> sinks = 17 + private final Map<Class<? extends Event>, EventSink<? extends Event>>
18 - new ConcurrentHashMap<>(); 18 + sinks = new ConcurrentHashMap<>();
19 19
20 @Override 20 @Override
21 public <E extends Event> void addSink(Class<E> eventClass, EventSink<E> sink) { 21 public <E extends Event> void addSink(Class<E> eventClass, EventSink<E> sink) {
......
1 package org.onlab.onos.event; 1 package org.onlab.onos.event;
2 2
3 /** 3 /**
4 - * Abstraction of an event. 4 + * Abstraction of an of a time-stamped event pertaining to an arbitrary subject.
5 */ 5 */
6 public interface Event<T extends Enum, S extends Object> { 6 public interface Event<T extends Enum, S extends Object> {
7 7
......
1 +package org.onlab.onos.event;
2 +
3 +/**
4 + * Abstraction of an entity capable of accepting events to be posted and
5 + * then dispatching them to the appropriate event sink.
6 + */
7 +public interface EventDeliveryService extends EventDispatcher, EventSinkRegistry {
8 +}
...@@ -6,13 +6,13 @@ package org.onlab.onos.event; ...@@ -6,13 +6,13 @@ package org.onlab.onos.event;
6 * Similarly, whether the events are accepted and dispatched synchronously 6 * Similarly, whether the events are accepted and dispatched synchronously
7 * or asynchronously is unspecified as well. 7 * or asynchronously is unspecified as well.
8 */ 8 */
9 -public interface EventDispatcher<E extends Event> { 9 +public interface EventDispatcher {
10 10
11 /** 11 /**
12 * Posts the specified event for dispatching. 12 * Posts the specified event for dispatching.
13 * 13 *
14 * @param event event to be posted 14 * @param event event to be posted
15 */ 15 */
16 - void post(E event); 16 + void post(Event event);
17 17
18 } 18 }
......
...@@ -3,10 +3,10 @@ package org.onlab.onos.event; ...@@ -3,10 +3,10 @@ package org.onlab.onos.event;
3 import java.util.Set; 3 import java.util.Set;
4 4
5 /** 5 /**
6 - * Abstraction of an event sink broker capable of tracking sinks based on 6 + * Abstraction of an event sink registry capable of tracking sinks based on
7 * their event class. 7 * their event class.
8 */ 8 */
9 -public interface EventSinkBroker { 9 +public interface EventSinkRegistry {
10 10
11 /** 11 /**
12 * Adds the specified sink for the given event class. 12 * Adds the specified sink for the given event class.
......
1 package org.onlab.onos.net.device; 1 package org.onlab.onos.net.device;
2 2
3 -import org.onlab.onos.net.provider.ProviderBroker; 3 +import org.onlab.onos.net.provider.ProviderRegistry;
4 4
5 /** 5 /**
6 - * Abstraction of a device provider brokerage. 6 + * Abstraction of a device provider registry.
7 */ 7 */
8 -public interface DeviceProviderBroker 8 +public interface DeviceProviderRegistry
9 - extends ProviderBroker<DeviceProvider, DeviceProviderService> { 9 + extends ProviderRegistry<DeviceProvider, DeviceProviderService> {
10 } 10 }
......
...@@ -35,16 +35,16 @@ public interface DeviceProviderService extends ProviderService<DeviceProvider> { ...@@ -35,16 +35,16 @@ public interface DeviceProviderService extends ProviderService<DeviceProvider> {
35 * <p/> 35 * <p/>
36 * 36 *
37 * @param deviceId identity of the device 37 * @param deviceId identity of the device
38 - * @param ports list of device ports 38 + * @param portDescriptions list of device ports
39 */ 39 */
40 - void updatePorts(DeviceId deviceId, List<PortDescription> ports); 40 + void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions);
41 41
42 /** 42 /**
43 * Used to notify the core about port status change of a single port. 43 * Used to notify the core about port status change of a single port.
44 * 44 *
45 * @param deviceId identity of the device 45 * @param deviceId identity of the device
46 - * @param port description of the port that changed 46 + * @param portDescription description of the port that changed
47 */ 47 */
48 - void portStatusChanged(DeviceId deviceId, PortDescription port); 48 + void portStatusChanged(DeviceId deviceId, PortDescription portDescription);
49 49
50 } 50 }
......
1 package org.onlab.onos.net.flow; 1 package org.onlab.onos.net.flow;
2 2
3 -import org.onlab.onos.net.provider.ProviderBroker; 3 +import org.onlab.onos.net.provider.ProviderRegistry;
4 4
5 /** 5 /**
6 - * Abstraction for a flow rule provider brokerage. 6 + * Abstraction for a flow rule provider registry.
7 */ 7 */
8 -public interface FlowRuleProviderBroker 8 +public interface FlowRuleProviderRegistry
9 - extends ProviderBroker<FlowRuleProvider, FlowRuleProviderService> { 9 + extends ProviderRegistry<FlowRuleProvider, FlowRuleProviderService> {
10 } 10 }
......
1 package org.onlab.onos.net.host; 1 package org.onlab.onos.net.host;
2 2
3 -import org.onlab.onos.net.provider.ProviderBroker; 3 +import org.onlab.onos.net.provider.ProviderRegistry;
4 4
5 /** 5 /**
6 - * Abstraction of a host provider brokerage. 6 + * Abstraction of a host provider registry.
7 */ 7 */
8 -public interface HostProviderBroker 8 +public interface HostProviderRegistry
9 - extends ProviderBroker<HostProvider, HostProviderService> { 9 + extends ProviderRegistry<HostProvider, HostProviderService> {
10 } 10 }
......
1 package org.onlab.onos.net.link; 1 package org.onlab.onos.net.link;
2 2
3 -import org.onlab.onos.net.provider.ProviderBroker; 3 +import org.onlab.onos.net.provider.ProviderRegistry;
4 4
5 /** 5 /**
6 - * Abstraction of an infrastructure link provider brokerage. 6 + * Abstraction of an infrastructure link provider registry.
7 */ 7 */
8 -public interface LinkProviderBroker 8 +public interface LinkProviderRegistry
9 - extends ProviderBroker<LinkProvider, LinkProviderService> { 9 + extends ProviderRegistry<LinkProvider, LinkProviderService> {
10 } 10 }
......
1 package org.onlab.onos.net.provider; 1 package org.onlab.onos.net.provider;
2 2
3 +import com.google.common.collect.ImmutableSet;
4 +
3 import java.util.HashMap; 5 import java.util.HashMap;
4 import java.util.Map; 6 import java.util.Map;
7 +import java.util.Set;
5 8
6 -import static com.google.common.base.Preconditions.checkArgument;
7 import static com.google.common.base.Preconditions.checkNotNull; 9 import static com.google.common.base.Preconditions.checkNotNull;
10 +import static com.google.common.base.Preconditions.checkState;
8 11
9 /** 12 /**
10 - * Base implementation of provider broker. 13 + * Base implementation of provider registry.
11 * 14 *
12 * @param <P> type of the information provider 15 * @param <P> type of the information provider
13 * @param <S> type of the provider service 16 * @param <S> type of the provider service
14 */ 17 */
15 -public abstract class AbstractProviderBroker<P extends Provider, S extends ProviderService<P>> 18 +public abstract class AbstractProviderRegistry<P extends Provider, S extends ProviderService<P>>
16 - implements ProviderBroker<P, S> { 19 + implements ProviderRegistry<P, S> {
17 20
18 private final Map<ProviderId, S> services = new HashMap<>(); 21 private final Map<ProviderId, S> services = new HashMap<>();
19 22
...@@ -28,7 +31,7 @@ public abstract class AbstractProviderBroker<P extends Provider, S extends Provi ...@@ -28,7 +31,7 @@ public abstract class AbstractProviderBroker<P extends Provider, S extends Provi
28 @Override 31 @Override
29 public synchronized S register(P provider) { 32 public synchronized S register(P provider) {
30 checkNotNull(provider, "Provider cannot be null"); 33 checkNotNull(provider, "Provider cannot be null");
31 - checkArgument(!services.containsKey(provider), "Provider %s already registered", provider.id()); 34 + checkState(!services.containsKey(provider.id()), "Provider %s already registered", provider.id());
32 S service = createProviderService(provider); 35 S service = createProviderService(provider);
33 services.put(provider.id(), service); 36 services.put(provider.id(), service);
34 return service; 37 return service;
...@@ -37,10 +40,16 @@ public abstract class AbstractProviderBroker<P extends Provider, S extends Provi ...@@ -37,10 +40,16 @@ public abstract class AbstractProviderBroker<P extends Provider, S extends Provi
37 @Override 40 @Override
38 public synchronized void unregister(P provider) { 41 public synchronized void unregister(P provider) {
39 checkNotNull(provider, "Provider cannot be null"); 42 checkNotNull(provider, "Provider cannot be null");
40 - S service = services.get(provider); 43 + S service = services.get(provider.id());
41 if (service != null && service instanceof AbstractProviderService) { 44 if (service != null && service instanceof AbstractProviderService) {
42 ((AbstractProviderService) service).invalidate(); 45 ((AbstractProviderService) service).invalidate();
43 - services.remove(provider); 46 + services.remove(provider.id());
44 } 47 }
45 } 48 }
49 +
50 + @Override
51 + public synchronized Set<ProviderId> getProviders() {
52 + return ImmutableSet.copyOf(services.keySet());
53 + }
54 +
46 } 55 }
......
1 package org.onlab.onos.net.provider; 1 package org.onlab.onos.net.provider;
2 2
3 +import java.util.Set;
4 +
3 /** 5 /**
4 - * Broker used for registering/unregistering information providers with the core. 6 + * Registry for tracking information providers with the core.
5 * 7 *
6 * @param <P> type of the information provider 8 * @param <P> type of the information provider
7 * @param <S> type of the provider service 9 * @param <S> type of the provider service
8 */ 10 */
9 -public interface ProviderBroker<P extends Provider, S extends ProviderService<P>> { 11 +public interface ProviderRegistry<P extends Provider, S extends ProviderService<P>> {
10 12
11 /** 13 /**
12 * Registers the supplied provider with the core. 14 * Registers the supplied provider with the core.
...@@ -29,4 +31,11 @@ public interface ProviderBroker<P extends Provider, S extends ProviderService<P> ...@@ -29,4 +31,11 @@ public interface ProviderBroker<P extends Provider, S extends ProviderService<P>
29 */ 31 */
30 void unregister(P provider); 32 void unregister(P provider);
31 33
34 + /**
35 + * Returns a set of currently registered provider identities.
36 + *
37 + * @return set of provider identifiers
38 + */
39 + Set<ProviderId> getProviders();
40 +
32 } 41 }
......
1 package org.onlab.onos.net.topology; 1 package org.onlab.onos.net.topology;
2 2
3 -import org.onlab.onos.net.provider.ProviderBroker; 3 +import org.onlab.onos.net.provider.ProviderRegistry;
4 4
5 /** 5 /**
6 - * Abstraction of a network topology provider brokerage. 6 + * Abstraction of a network topology provider registry.
7 */ 7 */
8 -public interface TopologyProviderBroker extends 8 +public interface TopologyProviderRegistry extends
9 - ProviderBroker<TopologyProvider, TopologyProviderService> { 9 + ProviderRegistry<TopologyProvider, TopologyProviderService> {
10 } 10 }
......
1 +<body>
2 +ONOS Core API definitions.
3 +</body>
...\ No newline at end of file ...\ No newline at end of file
...@@ -8,13 +8,13 @@ import static org.junit.Assert.assertTrue; ...@@ -8,13 +8,13 @@ import static org.junit.Assert.assertTrue;
8 /** 8 /**
9 * Tests of the base listener manager. 9 * Tests of the base listener manager.
10 */ 10 */
11 -public class AbstractListenerManagerTest { 11 +public class AbstractListenerRegistryTest {
12 12
13 @Test 13 @Test
14 public void basics() { 14 public void basics() {
15 TestListener listener = new TestListener(); 15 TestListener listener = new TestListener();
16 TestListener secondListener = new TestListener(); 16 TestListener secondListener = new TestListener();
17 - TestListenerManager manager = new TestListenerManager(); 17 + TestListenerRegistry manager = new TestListenerRegistry();
18 manager.addListener(listener); 18 manager.addListener(listener);
19 manager.addListener(secondListener); 19 manager.addListener(secondListener);
20 20
...@@ -35,7 +35,7 @@ public class AbstractListenerManagerTest { ...@@ -35,7 +35,7 @@ public class AbstractListenerManagerTest {
35 public void badListener() { 35 public void badListener() {
36 TestListener listener = new BrokenListener(); 36 TestListener listener = new BrokenListener();
37 TestListener secondListener = new TestListener(); 37 TestListener secondListener = new TestListener();
38 - TestListenerManager manager = new TestListenerManager(); 38 + TestListenerRegistry manager = new TestListenerRegistry();
39 manager.addListener(listener); 39 manager.addListener(listener);
40 manager.addListener(secondListener); 40 manager.addListener(secondListener);
41 41
......
...@@ -6,11 +6,11 @@ import org.junit.Test; ...@@ -6,11 +6,11 @@ import org.junit.Test;
6 import static org.junit.Assert.*; 6 import static org.junit.Assert.*;
7 7
8 /** 8 /**
9 - * Tests of the default event sink broker. 9 + * Tests of the default event sink registry.
10 */ 10 */
11 -public class DefaultEventSinkBrokerTest { 11 +public class DefaultEventSinkRegistryTest {
12 12
13 - private DefaultEventSinkBroker broker; 13 + private DefaultEventSinkRegistry registry;
14 14
15 private static class FooEvent extends TestEvent { 15 private static class FooEvent extends TestEvent {
16 public FooEvent(String subject) { super(Type.FOO, subject); } 16 public FooEvent(String subject) { super(Type.FOO, subject); }
...@@ -30,23 +30,23 @@ public class DefaultEventSinkBrokerTest { ...@@ -30,23 +30,23 @@ public class DefaultEventSinkBrokerTest {
30 30
31 @Before 31 @Before
32 public void setUp() { 32 public void setUp() {
33 - broker = new DefaultEventSinkBroker(); 33 + registry = new DefaultEventSinkRegistry();
34 } 34 }
35 35
36 @Test 36 @Test
37 public void basics() { 37 public void basics() {
38 FooSink fooSink = new FooSink(); 38 FooSink fooSink = new FooSink();
39 BarSink barSink = new BarSink(); 39 BarSink barSink = new BarSink();
40 - broker.addSink(FooEvent.class, fooSink); 40 + registry.addSink(FooEvent.class, fooSink);
41 - broker.addSink(BarEvent.class, barSink); 41 + registry.addSink(BarEvent.class, barSink);
42 42
43 - assertEquals("incorrect sink count", 2, broker.getSinks().size()); 43 + assertEquals("incorrect sink count", 2, registry.getSinks().size());
44 - assertEquals("incorrect sink", fooSink, broker.getSink(FooEvent.class)); 44 + assertEquals("incorrect sink", fooSink, registry.getSink(FooEvent.class));
45 - assertEquals("incorrect sink", barSink, broker.getSink(BarEvent.class)); 45 + assertEquals("incorrect sink", barSink, registry.getSink(BarEvent.class));
46 46
47 - broker.removeSink(FooEvent.class); 47 + registry.removeSink(FooEvent.class);
48 - assertNull("incorrect sink", broker.getSink(FooEvent.class)); 48 + assertNull("incorrect sink", registry.getSink(FooEvent.class));
49 - assertEquals("incorrect sink", barSink, broker.getSink(BarEvent.class)); 49 + assertEquals("incorrect sink", barSink, registry.getSink(BarEvent.class));
50 50
51 } 51 }
52 } 52 }
......
...@@ -6,8 +6,8 @@ import java.util.List; ...@@ -6,8 +6,8 @@ import java.util.List;
6 /** 6 /**
7 * Test event listener manager fixture. 7 * Test event listener manager fixture.
8 */ 8 */
9 -public class TestListenerManager 9 +public class TestListenerRegistry
10 - extends AbstractListenerManager<TestEvent, TestListener> { 10 + extends AbstractListenerRegistry<TestEvent, TestListener> {
11 11
12 public final List<Throwable> errors = new ArrayList<>(); 12 public final List<Throwable> errors = new ArrayList<>();
13 13
......
1 +package org.onlab.onos.net.provider;
2 +
3 +import org.junit.Test;
4 +
5 +import static org.hamcrest.MatcherAssert.assertThat;
6 +import static org.junit.Assert.assertEquals;
7 +
8 +/**
9 + * Test of the base provider registry.
10 + */
11 +public class AbstractProviderRegistryTest {
12 +
13 + private class TestProviderService extends AbstractProviderService<TestProvider> {
14 + protected TestProviderService(TestProvider provider) {
15 + super(provider);
16 + }
17 + }
18 +
19 + private class TestProviderRegistry extends AbstractProviderRegistry<TestProvider, TestProviderService> {
20 + @Override
21 + protected TestProviderService createProviderService(TestProvider provider) {
22 + return new TestProviderService(provider);
23 + }
24 + }
25 +
26 + @Test
27 + public void basics() {
28 + TestProviderRegistry registry = new TestProviderRegistry();
29 + assertEquals("incorrect provider count", 0, registry.getProviders().size());
30 +
31 + ProviderId fooId = new ProviderId("foo");
32 + TestProvider pFoo = new TestProvider(fooId);
33 + TestProviderService psFoo = registry.register(pFoo);
34 + assertEquals("incorrect provider count", 1, registry.getProviders().size());
35 + assertThat("provider not found", registry.getProviders().contains(fooId));
36 + assertEquals("incorrect provider", psFoo.provider(), pFoo);
37 +
38 + ProviderId barId = new ProviderId("bar");
39 + TestProvider pBar = new TestProvider(barId);
40 + TestProviderService psBar = registry.register(pBar);
41 + assertEquals("incorrect provider count", 2, registry.getProviders().size());
42 + assertThat("provider not found", registry.getProviders().contains(barId));
43 + assertEquals("incorrect provider", psBar.provider(), pBar);
44 +
45 + psFoo.checkValidity();
46 + registry.unregister(pFoo);
47 + psBar.checkValidity();
48 + assertEquals("incorrect provider count", 1, registry.getProviders().size());
49 + assertThat("provider not found", registry.getProviders().contains(barId));
50 + }
51 +
52 + @Test(expected = IllegalStateException.class)
53 + public void duplicateRegistration() {
54 + TestProviderRegistry registry = new TestProviderRegistry();
55 + TestProvider pFoo = new TestProvider(new ProviderId("foo"));
56 + registry.register(pFoo);
57 + registry.register(pFoo);
58 + }
59 +
60 + @Test
61 + public void voidUnregistration() {
62 + TestProviderRegistry registry = new TestProviderRegistry();
63 + registry.unregister(new TestProvider(new ProviderId("foo")));
64 + }
65 +
66 + @Test(expected = IllegalStateException.class)
67 + public void unregistration() {
68 + TestProviderRegistry registry = new TestProviderRegistry();
69 + TestProvider pFoo = new TestProvider(new ProviderId("foo"));
70 + TestProviderService psFoo = registry.register(pFoo);
71 + registry.unregister(pFoo);
72 + psFoo.checkValidity();
73 + }
74 +}
1 +package org.onlab.onos.event.impl;
2 +
3 +import org.apache.felix.scr.annotations.Activate;
4 +import org.apache.felix.scr.annotations.Component;
5 +import org.apache.felix.scr.annotations.Deactivate;
6 +import org.apache.felix.scr.annotations.Service;
7 +import org.onlab.onos.event.AbstractEvent;
8 +import org.onlab.onos.event.DefaultEventSinkRegistry;
9 +import org.onlab.onos.event.Event;
10 +import org.onlab.onos.event.EventDeliveryService;
11 +import org.onlab.onos.event.EventSink;
12 +import org.slf4j.Logger;
13 +
14 +import java.util.concurrent.BlockingQueue;
15 +import java.util.concurrent.ExecutorService;
16 +import java.util.concurrent.LinkedBlockingQueue;
17 +
18 +import static java.util.concurrent.Executors.newSingleThreadExecutor;
19 +import static org.onlab.util.Tools.namedThreads;
20 +import static org.slf4j.LoggerFactory.getLogger;
21 +
22 +/**
23 + * Simple implementation of an event dispatching service.
24 + */
25 +@Component(immediate = true)
26 +@Service
27 +public class SimpleEventDispatcher extends DefaultEventSinkRegistry
28 + implements EventDeliveryService {
29 +
30 + private final Logger log = getLogger(getClass());
31 +
32 + private final ExecutorService executor =
33 + newSingleThreadExecutor(namedThreads("event-dispatch-%d"));
34 +
35 + @SuppressWarnings("unchecked")
36 + private static final Event KILL_PILL = new AbstractEvent(null, 0) {
37 + };
38 +
39 + private final BlockingQueue<Event> events = new LinkedBlockingQueue<>();
40 +
41 + private volatile boolean stopped = false;
42 +
43 + @Override
44 + public void post(Event event) {
45 + events.add(event);
46 + }
47 +
48 + @Activate
49 + public void activate() {
50 + stopped = false;
51 + executor.execute(new DispatchLoop());
52 + log.info("Started");
53 + }
54 +
55 + @Deactivate
56 + public void deactivate() {
57 + stopped = true;
58 + post(KILL_PILL);
59 + log.info("Stopped");
60 + }
61 +
62 + // Auxiliary event dispatching loop that feeds off the events queue.
63 + private class DispatchLoop implements Runnable {
64 + @Override
65 + @SuppressWarnings("unchecked")
66 + public void run() {
67 + log.info("Dispatch loop initiated");
68 + while (!stopped) {
69 + try {
70 + // Fetch the next event and if it is the kill-pill, bail
71 + Event event = events.take();
72 + if (event == KILL_PILL) {
73 + break;
74 + }
75 +
76 + // Locate the sink for the event class and use it to
77 + // process the event
78 + EventSink sink = getSink(event.getClass());
79 + if (sink != null) {
80 + sink.process(event);
81 + } else {
82 + log.warn("No sink registered for event class {}",
83 + event.getClass());
84 + }
85 + } catch (Throwable e) {
86 + log.warn("Error encountered while dispatching event:", e);
87 + }
88 + }
89 + log.info("Dispatch loop terminated");
90 + }
91 + }
92 +
93 +}
1 -package org.onlab.onos.net.trivial.impl; 1 +package org.onlab.onos.impl;
2 2
3 import com.google.common.collect.ImmutableSet; 3 import com.google.common.collect.ImmutableSet;
4 import org.apache.felix.scr.annotations.Activate; 4 import org.apache.felix.scr.annotations.Activate;
5 import org.apache.felix.scr.annotations.Component; 5 import org.apache.felix.scr.annotations.Component;
6 import org.apache.felix.scr.annotations.Deactivate; 6 import org.apache.felix.scr.annotations.Deactivate;
7 import org.apache.felix.scr.annotations.Service; 7 import org.apache.felix.scr.annotations.Service;
8 -import org.onlab.onos.net.GreetService; 8 +import org.onlab.onos.GreetService;
9 import org.slf4j.Logger; 9 import org.slf4j.Logger;
10 -import org.slf4j.LoggerFactory;
11 10
12 import java.util.HashSet; 11 import java.util.HashSet;
13 import java.util.Set; 12 import java.util.Set;
14 13
15 import static com.google.common.base.Preconditions.checkNotNull; 14 import static com.google.common.base.Preconditions.checkNotNull;
15 +import static org.slf4j.LoggerFactory.getLogger;
16 16
17 /** 17 /**
18 * Trivial implementation of the seed service to demonstrate component and 18 * Trivial implementation of the seed service to demonstrate component and
...@@ -22,7 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -22,7 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
22 @Service 22 @Service
23 public class GreetManager implements GreetService { 23 public class GreetManager implements GreetService {
24 24
25 - private final Logger log = LoggerFactory.getLogger(getClass()); 25 + private final Logger log = getLogger(getClass());
26 26
27 private final Set<String> names = new HashSet<>(); 27 private final Set<String> names = new HashSet<>();
28 28
......
1 -package org.onlab.onos.net.trivial.impl; 1 +package org.onlab.onos.impl;
2 2
3 import org.apache.felix.scr.annotations.Activate; 3 import org.apache.felix.scr.annotations.Activate;
4 import org.apache.felix.scr.annotations.Component; 4 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.onlab.onos.net.GreetService; 8 +import org.onlab.onos.GreetService;
9 import org.slf4j.Logger; 9 import org.slf4j.Logger;
10 -import org.slf4j.LoggerFactory; 10 +
11 +import static org.slf4j.LoggerFactory.getLogger;
11 12
12 /** 13 /**
13 * Example of a component that does not provide any service, but consumes one. 14 * Example of a component that does not provide any service, but consumes one.
...@@ -15,7 +16,7 @@ import org.slf4j.LoggerFactory; ...@@ -15,7 +16,7 @@ import org.slf4j.LoggerFactory;
15 @Component(immediate = true) 16 @Component(immediate = true)
16 public class SomeOtherComponent { 17 public class SomeOtherComponent {
17 18
18 - private final Logger log = LoggerFactory.getLogger(SomeOtherComponent.class); 19 + private final Logger log = getLogger(getClass());
19 20
20 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 21 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
21 protected GreetService service; 22 protected GreetService service;
......
1 +package org.onlab.onos.net.trivial.impl;
2 +
3 +import org.onlab.onos.net.Device;
4 +import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.Port;
6 +import org.onlab.onos.net.PortNumber;
7 +import org.onlab.onos.net.device.DeviceDescription;
8 +import org.onlab.onos.net.device.DeviceEvent;
9 +import org.onlab.onos.net.device.PortDescription;
10 +
11 +import java.util.ArrayList;
12 +import java.util.List;
13 +import java.util.Map;
14 +import java.util.concurrent.ConcurrentHashMap;
15 +
16 +/**
17 + * Manages inventory of infrastructure devices.
18 + */
19 +public class DeviceStore {
20 +
21 + private final Map<DeviceId, Device> devices = new ConcurrentHashMap<>();
22 +
23 + /**
24 + * Creates a new infrastructure device, or updates an existing one using
25 + * the supplied device description.
26 + *
27 + * @param deviceId device identifier
28 + * @param deviceDescription device description
29 + * @return ready to send event describing what occurred; null if no change
30 + */
31 + public DeviceEvent createOrUpdateDevice(DeviceId deviceId,
32 + DeviceDescription deviceDescription) {
33 + return null;
34 + }
35 +
36 + /**
37 + * Removes the specified infrastructure device.
38 + *
39 + * @param deviceId device identifier
40 + * @return ready to send event describing what occurred; null if no change
41 + */
42 + public DeviceEvent removeDevice(DeviceId deviceId) {
43 + return null;
44 + }
45 +
46 + /**
47 + * Updates the ports of the specified infrastructure device using the given
48 + * list of port descriptions. The list is assumed to be comprehensive.
49 + *
50 + * @param deviceId device identifier
51 + * @param portDescriptions list of port descriptions
52 + * @return ready to send events describing what occurred; empty list if no change
53 + */
54 + public List<DeviceEvent> updatePorts(DeviceId deviceId,
55 + List<PortDescription> portDescriptions) {
56 + return new ArrayList<>();
57 + }
58 +
59 + /**
60 + * Updates the port status of the specified infrastructure device using the
61 + * given port description.
62 + *
63 + * @param deviceId device identifier
64 + * @param portDescription port description
65 + * @return ready to send event describing what occurred; null if no change
66 + */
67 + public DeviceEvent updatePortStatus(DeviceId deviceId,
68 + PortDescription portDescription) {
69 + return null;
70 + }
71 +
72 + /**
73 + * Returns the device with the specified identifier.
74 + *
75 + * @param deviceId device identifier
76 + * @return device
77 + */
78 + public Device getDevice(DeviceId deviceId) {
79 + return null;
80 + }
81 +
82 + /**
83 + * Returns the list of ports that belong to the specified device.
84 + *
85 + * @param deviceId device identifier
86 + * @return list of device ports
87 + */
88 + public List<Port> getPorts(DeviceId deviceId) {
89 + return null;
90 + }
91 +
92 + /**
93 + * Returns the specified device port.
94 + *
95 + * @param deviceId device identifier
96 + * @param portNumber port number
97 + * @return device port
98 + */
99 + public Port getPort(DeviceId deviceId, PortNumber portNumber) {
100 + return null;
101 + }
102 +}
...@@ -3,63 +3,113 @@ package org.onlab.onos.net.trivial.impl; ...@@ -3,63 +3,113 @@ package org.onlab.onos.net.trivial.impl;
3 import org.apache.felix.scr.annotations.Activate; 3 import org.apache.felix.scr.annotations.Activate;
4 import org.apache.felix.scr.annotations.Component; 4 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;
7 +import org.apache.felix.scr.annotations.ReferenceCardinality;
6 import org.apache.felix.scr.annotations.Service; 8 import org.apache.felix.scr.annotations.Service;
9 +import org.onlab.onos.event.AbstractListenerRegistry;
10 +import org.onlab.onos.event.EventDeliveryService;
11 +import org.onlab.onos.net.Device;
7 import org.onlab.onos.net.DeviceId; 12 import org.onlab.onos.net.DeviceId;
8 import org.onlab.onos.net.MastershipRole; 13 import org.onlab.onos.net.MastershipRole;
14 +import org.onlab.onos.net.Port;
15 +import org.onlab.onos.net.PortNumber;
9 import org.onlab.onos.net.device.DeviceDescription; 16 import org.onlab.onos.net.device.DeviceDescription;
17 +import org.onlab.onos.net.device.DeviceEvent;
18 +import org.onlab.onos.net.device.DeviceListener;
10 import org.onlab.onos.net.device.DeviceProvider; 19 import org.onlab.onos.net.device.DeviceProvider;
11 -import org.onlab.onos.net.device.DeviceProviderBroker; 20 +import org.onlab.onos.net.device.DeviceProviderRegistry;
12 import org.onlab.onos.net.device.DeviceProviderService; 21 import org.onlab.onos.net.device.DeviceProviderService;
22 +import org.onlab.onos.net.device.DeviceService;
13 import org.onlab.onos.net.device.PortDescription; 23 import org.onlab.onos.net.device.PortDescription;
14 -import org.onlab.onos.net.provider.AbstractProviderBroker; 24 +import org.onlab.onos.net.provider.AbstractProviderRegistry;
15 import org.onlab.onos.net.provider.AbstractProviderService; 25 import org.onlab.onos.net.provider.AbstractProviderService;
16 import org.slf4j.Logger; 26 import org.slf4j.Logger;
17 -import org.slf4j.LoggerFactory;
18 27
19 import java.util.List; 28 import java.util.List;
20 29
30 +import static com.google.common.base.Preconditions.checkNotNull;
31 +import static org.slf4j.LoggerFactory.getLogger;
32 +
21 /** 33 /**
22 * Provides basic implementation of the device SB &amp; NB APIs. 34 * Provides basic implementation of the device SB &amp; NB APIs.
23 */ 35 */
24 @Component(immediate = true) 36 @Component(immediate = true)
25 @Service 37 @Service
26 -public class SimpleDeviceManager implements DeviceProviderBroker { 38 +public class SimpleDeviceManager
39 + extends AbstractProviderRegistry<DeviceProvider, DeviceProviderService>
40 + implements DeviceService, DeviceProviderRegistry {
41 +
42 + public static final String DEVICE_ID_NULL = "Device ID cannot be null";
43 + public static final String PORT_NUMBER_NULL = "Port number cannot be null";
44 + public static final String DEVICE_DESCRIPTION_NULL = "Device description cannot be null";
45 + public static final String PORT_DESCRIPTION_NULL = "Port description cannot be null";
46 +
47 + private final Logger log = getLogger(getClass());
48 +
49 + private final AbstractListenerRegistry<DeviceEvent, DeviceListener>
50 + listenerRegistry = new AbstractListenerRegistry<>();
27 51
28 - private Logger log = LoggerFactory.getLogger(SimpleDeviceManager.class); 52 + private final DeviceStore store = new DeviceStore();
29 53
30 - private final DeviceProviderBroker broker = new InternalBroker(); 54 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
55 + private EventDeliveryService eventDispatcher;
31 56
32 @Activate 57 @Activate
33 public void activate() { 58 public void activate() {
59 + eventDispatcher.addSink(DeviceEvent.class, listenerRegistry);
34 log.info("Started"); 60 log.info("Started");
35 } 61 }
36 62
37 @Deactivate 63 @Deactivate
38 public void deactivate() { 64 public void deactivate() {
65 + eventDispatcher.removeSink(DeviceEvent.class);
39 log.info("Stopped"); 66 log.info("Stopped");
40 } 67 }
41 68
42 @Override 69 @Override
43 - public DeviceProviderService register(DeviceProvider provider) { 70 + public MastershipRole getRole(DeviceId deviceId) {
44 - log.info("Registering provider {}", provider.id()); 71 + checkNotNull(deviceId, DEVICE_ID_NULL);
45 - return broker.register(provider); 72 + return null;
73 + }
74 +
75 + @Override
76 + public Iterable<Device> getDevices() {
77 + return null;
46 } 78 }
47 79
48 @Override 80 @Override
49 - public void unregister(DeviceProvider provider) { 81 + public Device getDevice(DeviceId deviceId) {
50 - log.info("Unregistering provider {}", provider.id()); 82 + checkNotNull(deviceId, DEVICE_ID_NULL);
51 - broker.unregister(provider); 83 + return store.getDevice(deviceId);
84 + }
85 +
86 + @Override
87 + public List<Port> getPorts(DeviceId deviceId) {
88 + checkNotNull(deviceId, DEVICE_ID_NULL);
89 + return store.getPorts(deviceId);
90 + }
91 +
92 + @Override
93 + public Port getPort(DeviceId deviceId, PortNumber portNumber) {
94 + checkNotNull(deviceId, DEVICE_ID_NULL);
95 + checkNotNull(portNumber, PORT_NUMBER_NULL);
96 + return store.getPort(deviceId, portNumber);
97 + }
98 +
99 + @Override
100 + public void addListener(DeviceListener listener) {
101 + listenerRegistry.addListener(listener);
102 + }
103 +
104 + @Override
105 + public void removeListener(DeviceListener listener) {
106 + listenerRegistry.removeListener(listener);
52 } 107 }
53 108
54 - // Internal delegate for tracking various providers and issuing them a
55 - // personalized provider service.
56 - private class InternalBroker extends AbstractProviderBroker<DeviceProvider, DeviceProviderService>
57 - implements DeviceProviderBroker {
58 @Override 109 @Override
59 protected DeviceProviderService createProviderService(DeviceProvider provider) { 110 protected DeviceProviderService createProviderService(DeviceProvider provider) {
60 return new InternalDeviceProviderService(provider); 111 return new InternalDeviceProviderService(provider);
61 } 112 }
62 - }
63 113
64 // Personalized device provider service issued to the supplied provider. 114 // Personalized device provider service issued to the supplied provider.
65 private class InternalDeviceProviderService extends AbstractProviderService<DeviceProvider> 115 private class InternalDeviceProviderService extends AbstractProviderService<DeviceProvider>
...@@ -71,26 +121,49 @@ public class SimpleDeviceManager implements DeviceProviderBroker { ...@@ -71,26 +121,49 @@ public class SimpleDeviceManager implements DeviceProviderBroker {
71 121
72 @Override 122 @Override
73 public MastershipRole deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) { 123 public MastershipRole deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) {
124 + checkNotNull(deviceId, DEVICE_ID_NULL);
125 + checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL);
74 log.info("Device {} connected: {}", deviceId, deviceDescription); 126 log.info("Device {} connected: {}", deviceId, deviceDescription);
127 + DeviceEvent event = store.createOrUpdateDevice(deviceId, deviceDescription);
128 + post(event);
75 return MastershipRole.MASTER; 129 return MastershipRole.MASTER;
76 } 130 }
77 131
78 @Override 132 @Override
79 public void deviceDisconnected(DeviceId deviceId) { 133 public void deviceDisconnected(DeviceId deviceId) {
134 + checkNotNull(deviceId, DEVICE_ID_NULL);
80 log.info("Device {} disconnected", deviceId); 135 log.info("Device {} disconnected", deviceId);
81 - 136 + DeviceEvent event = store.removeDevice(deviceId);
137 + post(event);
82 } 138 }
83 139
84 @Override 140 @Override
85 - public void updatePorts(DeviceId deviceId, List<PortDescription> ports) { 141 + public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) {
142 + checkNotNull(deviceId, DEVICE_ID_NULL);
143 + checkNotNull(portDescriptions, "Port descriptions list cannot be null");
86 // FIXME: fix the interface to accept DeviceId separately 144 // FIXME: fix the interface to accept DeviceId separately
87 - log.info("Device {} ports updated: {}", ports); 145 + log.info("Device {} ports updated: {}", portDescriptions);
88 - 146 + List<DeviceEvent> events = store.updatePorts(deviceId, portDescriptions);
147 + for (DeviceEvent event : events) {
148 + post(event);
149 + }
89 } 150 }
90 151
91 @Override 152 @Override
92 - public void portStatusChanged(DeviceId deviceId, PortDescription port) { 153 + public void portStatusChanged(DeviceId deviceId, PortDescription portDescription) {
93 - log.info("Device {} port status changed: {}", deviceId, port); 154 + checkNotNull(deviceId, DEVICE_ID_NULL);
155 + checkNotNull(portDescription, PORT_DESCRIPTION_NULL);
156 + log.info("Device {} port status changed: {}", deviceId, portDescription);
157 + DeviceEvent event = store.updatePortStatus(deviceId, portDescription);
158 + post(event);
159 + }
160 + }
161 +
162 + // Posts the specified event to a local event dispatcher
163 + private void post(DeviceEvent event) {
164 + if (event != null && eventDispatcher != null) {
165 + eventDispatcher.post(event);
94 } 166 }
95 } 167 }
168 +
96 } 169 }
......
...@@ -3,58 +3,57 @@ package org.onlab.onos.net.trivial.impl; ...@@ -3,58 +3,57 @@ package org.onlab.onos.net.trivial.impl;
3 import org.apache.felix.scr.annotations.Activate; 3 import org.apache.felix.scr.annotations.Activate;
4 import org.apache.felix.scr.annotations.Component; 4 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;
7 +import org.apache.felix.scr.annotations.ReferenceCardinality;
6 import org.apache.felix.scr.annotations.Service; 8 import org.apache.felix.scr.annotations.Service;
9 +import org.onlab.onos.event.AbstractListenerRegistry;
10 +import org.onlab.onos.event.EventDeliveryService;
7 import org.onlab.onos.net.host.HostDescription; 11 import org.onlab.onos.net.host.HostDescription;
12 +import org.onlab.onos.net.host.HostEvent;
13 +import org.onlab.onos.net.host.HostListener;
8 import org.onlab.onos.net.host.HostProvider; 14 import org.onlab.onos.net.host.HostProvider;
9 -import org.onlab.onos.net.host.HostProviderBroker; 15 +import org.onlab.onos.net.host.HostProviderRegistry;
10 import org.onlab.onos.net.host.HostProviderService; 16 import org.onlab.onos.net.host.HostProviderService;
11 -import org.onlab.onos.net.provider.AbstractProviderBroker; 17 +import org.onlab.onos.net.provider.AbstractProviderRegistry;
12 import org.onlab.onos.net.provider.AbstractProviderService; 18 import org.onlab.onos.net.provider.AbstractProviderService;
13 import org.slf4j.Logger; 19 import org.slf4j.Logger;
14 -import org.slf4j.LoggerFactory; 20 +
21 +import static org.slf4j.LoggerFactory.getLogger;
15 22
16 /** 23 /**
17 * Provides basic implementation of the host SB &amp; NB APIs. 24 * Provides basic implementation of the host SB &amp; NB APIs.
18 */ 25 */
19 @Component(immediate = true) 26 @Component(immediate = true)
20 @Service 27 @Service
21 -public class SimpleHostManager implements HostProviderBroker { 28 +public class SimpleHostManager
29 + extends AbstractProviderRegistry<HostProvider, HostProviderService>
30 + implements HostProviderRegistry {
31 +
32 + private final Logger log = getLogger(getClass());
33 +
34 + private final AbstractListenerRegistry<HostEvent, HostListener>
35 + listenerRegistry = new AbstractListenerRegistry<>();
22 36
23 - private Logger log = LoggerFactory.getLogger(SimpleHostManager.class); 37 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
38 + private EventDeliveryService eventDispatcher;
24 39
25 - private final HostProviderBroker broker = new InternalBroker();
26 40
27 @Activate 41 @Activate
28 public void activate() { 42 public void activate() {
43 + eventDispatcher.addSink(HostEvent.class, listenerRegistry);
29 log.info("Started"); 44 log.info("Started");
30 } 45 }
31 46
32 @Deactivate 47 @Deactivate
33 public void deactivate() { 48 public void deactivate() {
49 + eventDispatcher.removeSink(HostEvent.class);
34 log.info("Stopped"); 50 log.info("Stopped");
35 } 51 }
36 52
37 @Override 53 @Override
38 - public HostProviderService register(HostProvider provider) {
39 - log.info("Registering provider {}", provider.id());
40 - return broker.register(provider);
41 - }
42 -
43 - @Override
44 - public void unregister(HostProvider provider) {
45 - log.info("Unregistering provider {}", provider.id());
46 - broker.unregister(provider);
47 - }
48 -
49 - // Internal delegate for tracking various providers and issuing them a
50 - // personalized provider service.
51 - private class InternalBroker extends AbstractProviderBroker<HostProvider, HostProviderService>
52 - implements HostProviderBroker {
53 - @Override
54 protected HostProviderService createProviderService(HostProvider provider) { 54 protected HostProviderService createProviderService(HostProvider provider) {
55 return new InternalHostProviderService(provider); 55 return new InternalHostProviderService(provider);
56 } 56 }
57 - }
58 57
59 // Personalized host provider service issued to the supplied provider. 58 // Personalized host provider service issued to the supplied provider.
60 private class InternalHostProviderService extends AbstractProviderService<HostProvider> 59 private class InternalHostProviderService extends AbstractProviderService<HostProvider>
......
...@@ -3,58 +3,56 @@ package org.onlab.onos.net.trivial.impl; ...@@ -3,58 +3,56 @@ package org.onlab.onos.net.trivial.impl;
3 import org.apache.felix.scr.annotations.Activate; 3 import org.apache.felix.scr.annotations.Activate;
4 import org.apache.felix.scr.annotations.Component; 4 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;
7 +import org.apache.felix.scr.annotations.ReferenceCardinality;
6 import org.apache.felix.scr.annotations.Service; 8 import org.apache.felix.scr.annotations.Service;
9 +import org.onlab.onos.event.AbstractListenerRegistry;
10 +import org.onlab.onos.event.EventDeliveryService;
7 import org.onlab.onos.net.link.LinkDescription; 11 import org.onlab.onos.net.link.LinkDescription;
12 +import org.onlab.onos.net.link.LinkEvent;
13 +import org.onlab.onos.net.link.LinkListener;
8 import org.onlab.onos.net.link.LinkProvider; 14 import org.onlab.onos.net.link.LinkProvider;
9 -import org.onlab.onos.net.link.LinkProviderBroker; 15 +import org.onlab.onos.net.link.LinkProviderRegistry;
10 import org.onlab.onos.net.link.LinkProviderService; 16 import org.onlab.onos.net.link.LinkProviderService;
11 -import org.onlab.onos.net.provider.AbstractProviderBroker; 17 +import org.onlab.onos.net.provider.AbstractProviderRegistry;
12 import org.onlab.onos.net.provider.AbstractProviderService; 18 import org.onlab.onos.net.provider.AbstractProviderService;
13 import org.slf4j.Logger; 19 import org.slf4j.Logger;
14 -import org.slf4j.LoggerFactory; 20 +
21 +import static org.slf4j.LoggerFactory.getLogger;
15 22
16 /** 23 /**
17 * Provides basic implementation of the link SB &amp; NB APIs. 24 * Provides basic implementation of the link SB &amp; NB APIs.
18 */ 25 */
19 @Component(immediate = true) 26 @Component(immediate = true)
20 @Service 27 @Service
21 -public class SimpleLinkManager implements LinkProviderBroker { 28 +public class SimpleLinkManager
29 + extends AbstractProviderRegistry<LinkProvider, LinkProviderService>
30 + implements LinkProviderRegistry {
31 +
32 + private final Logger log = getLogger(getClass());
22 33
23 - private Logger log = LoggerFactory.getLogger(SimpleLinkManager.class); 34 + private final AbstractListenerRegistry<LinkEvent, LinkListener>
35 + listenerRegistry = new AbstractListenerRegistry<>();
24 36
25 - private final LinkProviderBroker broker = new InternalBroker(); 37 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
38 + private EventDeliveryService eventDispatcher;
26 39
27 @Activate 40 @Activate
28 public void activate() { 41 public void activate() {
42 + eventDispatcher.addSink(LinkEvent.class, listenerRegistry);
29 log.info("Started"); 43 log.info("Started");
30 } 44 }
31 45
32 @Deactivate 46 @Deactivate
33 public void deactivate() { 47 public void deactivate() {
48 + eventDispatcher.removeSink(LinkEvent.class);
34 log.info("Stopped"); 49 log.info("Stopped");
35 } 50 }
36 51
37 @Override 52 @Override
38 - public LinkProviderService register(LinkProvider provider) {
39 - log.info("Registering provider {}", provider.id());
40 - return broker.register(provider);
41 - }
42 -
43 - @Override
44 - public void unregister(LinkProvider provider) {
45 - log.info("Unregistering provider {}", provider.id());
46 - broker.unregister(provider);
47 - }
48 -
49 - // Internal delegate for tracking various providers and issuing them a
50 - // personalized provider service.
51 - private class InternalBroker extends AbstractProviderBroker<LinkProvider, LinkProviderService>
52 - implements LinkProviderBroker {
53 - @Override
54 protected LinkProviderService createProviderService(LinkProvider provider) { 53 protected LinkProviderService createProviderService(LinkProvider provider) {
55 return new InternalLinkProviderService(provider); 54 return new InternalLinkProviderService(provider);
56 } 55 }
57 - }
58 56
59 // Personalized link provider service issued to the supplied provider. 57 // Personalized link provider service issued to the supplied provider.
60 private class InternalLinkProviderService extends AbstractProviderService<LinkProvider> 58 private class InternalLinkProviderService extends AbstractProviderService<LinkProvider>
......
1 +<body>
2 +ONOS local event dispatching mechanism.
3 +</body>
...\ No newline at end of file ...\ No newline at end of file
1 +<body>
2 +ONOS Core infrastructure implementations.
3 +</body>
...\ No newline at end of file ...\ No newline at end of file
1 -package org.onlab.onos.net.trivial.impl; 1 +package org.onlab.onos.impl;
2 2
3 import org.junit.Test; 3 import org.junit.Test;
4 -import org.onlab.onos.net.GreetService; 4 +import org.onlab.onos.GreetService;
5 5
6 import java.util.Iterator; 6 import java.util.Iterator;
7 7
......
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
26 <groupId>com.google.guava</groupId> 26 <groupId>com.google.guava</groupId>
27 <artifactId>guava</artifactId> 27 <artifactId>guava</artifactId>
28 </dependency> 28 </dependency>
29 +
30 + <dependency>
31 + <groupId>org.onlab.onos</groupId>
32 + <artifactId>onlab-misc</artifactId>
33 + </dependency>
29 </dependencies> 34 </dependencies>
30 35
31 <build> 36 <build>
......
1 -# See: http://rolf-engelhard.de/2011/04/using-the-same-suppression-filter-for-checkstyle-in-eclipse-and-maven/
2 -config_loc=conf/checkstyle
This diff is collapsed. Click to expand it.
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
3 -
4 -<suppressions>
5 - <!--
6 - Note: Exclusion definition exists in multiple places.
7 - - In file ${findbugs.excludeFilterFile} defined at top of pom.xml
8 - - In file conf/checkstyle/onos_suppressions.xml (this file)
9 - - maven-pmd-plugin configuration in pom.xml
10 - (under build and reporting)
11 - -->
12 -
13 - <suppress files=".*" checks="FinalParametersCheck"/>
14 - <suppress files=".*" checks="MagicNumbersCheck"/>
15 - <suppress files=".*" checks="DesignForExtensionCheck"/>
16 - <suppress files=".*" checks="TodoCommentCheck"/>
17 - <suppress files=".*" checks="AvoidInlineConditionalsCheck"/>
18 - <suppress files=".*" checks="OperatorWrapCheck"/>
19 -</suppressions>
20 -
1 -<FindBugsFilter>
2 - <!--
3 - Note: Exclusion definition exists in multiple places.
4 - - In file ${findbugs.excludeFilterFile} defined at top of pom.xml (this file)
5 - - In file conf/checkstyle/onos_suppressions.xml
6 - - maven-pmd-plugin configuration in pom.xml
7 - (under build and reporting)
8 - -->
9 - <Match>
10 - <Class name="~net\.onrc\.onos\.core\.datastore\.serializers\..*" />
11 - </Match>
12 - <Match>
13 - <Class name="~.*edu\.stanford\..*"/>
14 - </Match>
15 - <Match>
16 - <Class name="~.org\.projectfloodlight\..*"/>
17 - </Match>
18 -</FindBugsFilter>
This diff is collapsed. Click to expand it.
1 -package net.onrc.onos.of.ctl;
2 -
3 -import org.projectfloodlight.openflow.protocol.OFVersion;
4 -
5 -import org.onlab.onos.of.controller.impl.registry.IControllerRegistry;
6 -
7 -/**
8 - * Interface to passed to controller class in order to allow
9 - * it to spawn the appropriate type of switch and furthermore
10 - * specify a registry object (ie. ZooKeeper).
11 - *
12 - */
13 -public interface IOFSwitchManager {
14 -
15 - /**
16 - * Given a description string for a switch spawn the
17 - * concrete representation of that switch.
18 - *
19 - * @param mfr manufacturer description
20 - * @param hwDesc hardware description
21 - * @param swDesc software description
22 - * @param ofv openflow version
23 - * @return A switch of type IOFSwitch.
24 - */
25 - public IOFSwitch getSwitchImpl(String mfr, String hwDesc, String swDesc, OFVersion ofv);
26 -
27 - /**
28 - * Returns the mastership registry used during controller-switch role election.
29 - * @return the registry
30 - */
31 - public IControllerRegistry getRegistry();
32 -
33 -}
1 -package net.onrc.onos.of.ctl;
2 -
3 -import org.projectfloodlight.openflow.protocol.OFControllerRole;
4 -
5 -/**
6 - * The role of the controller as it pertains to a particular switch.
7 - * Note that this definition of the role enum is different from the
8 - * OF1.3 definition. It is maintained here to be backward compatible to
9 - * earlier versions of the controller code. This enum is translated
10 - * to the OF1.3 enum, before role messages are sent to the switch.
11 - * See sendRoleRequestMessage method in OFSwitchImpl
12 - */
13 -public enum Role {
14 - EQUAL(OFControllerRole.ROLE_EQUAL),
15 - MASTER(OFControllerRole.ROLE_MASTER),
16 - SLAVE(OFControllerRole.ROLE_SLAVE);
17 -
18 - private Role(OFControllerRole nxRole) {
19 - nxRole.ordinal();
20 - }
21 - /*
22 - private static Map<Integer,Role> nxRoleToEnum
23 - = new HashMap<Integer,Role>();
24 - static {
25 - for(Role r: Role.values())
26 - nxRoleToEnum.put(r.toNxRole(), r);
27 - }
28 - public int toNxRole() {
29 - return nxRole;
30 - }
31 - // Return the enum representing the given nxRole or null if no
32 - // such role exists
33 - public static Role fromNxRole(int nxRole) {
34 - return nxRoleToEnum.get(nxRole);
35 - }*/
36 -}
1 -/**
2 - * Copyright 2012, Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.annotations;
19 -
20 -import java.lang.annotation.ElementType;
21 -import java.lang.annotation.Target;
22 -
23 -/**
24 - * Annotation used to set the category for log messages for a class.
25 - *
26 - */
27 -@Target({ ElementType.TYPE, ElementType.METHOD })
28 -public @interface LogMessageCategory {
29 -
30 - /**
31 - * The category for the log messages for this class.
32 - *
33 - * @return
34 - */
35 - String value() default "Core";
36 -}
1 -/**
2 - * Copyright 2012, Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.annotations;
19 -
20 -import java.lang.annotation.ElementType;
21 -import java.lang.annotation.Target;
22 -
23 -/**
24 - * Annotation used to document log messages. This can be used to generate
25 - * documentation on syslog output.
26 - *
27 - */
28 -@Target({ ElementType.TYPE, ElementType.METHOD })
29 -public @interface LogMessageDoc {
30 - public static final String NO_ACTION = "No action is required.";
31 - public static final String UNKNOWN_ERROR = "An unknown error occured";
32 - public static final String GENERIC_ACTION =
33 - "Examine the returned error or exception and take " +
34 - "appropriate action.";
35 - public static final String CHECK_SWITCH =
36 - "Check the health of the indicated switch. " +
37 - "Test and troubleshoot IP connectivity.";
38 - public static final String CHECK_CONTROLLER =
39 - "Verify controller system health, CPU usage, and memory. " +
40 - "Rebooting the controller node may help if the controller " +
41 - "node is in a distressed state.";
42 - public static final String REPORT_CONTROLLER_BUG =
43 - "This is likely a defect in the controller. Please report this " +
44 - "issue. Restarting the controller or switch may help to " +
45 - "alleviate.";
46 - public static final String REPORT_SWITCH_BUG =
47 - "This is likely a defect in the switch. Please report this " +
48 - "issue. Restarting the controller or switch may help to " +
49 - "alleviate.";
50 -
51 - /**
52 - * The log level for the log message.
53 - *
54 - * @return the log level as a tring
55 - */
56 - String level() default "INFO";
57 -
58 - /**
59 - * The message that will be printed.
60 - *
61 - * @return the message
62 - */
63 - String message() default UNKNOWN_ERROR;
64 -
65 - /**
66 - * An explanation of the meaning of the log message.
67 - *
68 - * @return the explanation
69 - */
70 - String explanation() default UNKNOWN_ERROR;
71 -
72 - /**
73 - * The recommendated action associated with the log message.
74 - *
75 - * @return the recommendation
76 - */
77 - String recommendation() default NO_ACTION;
78 -}
1 -/**
2 - * Copyright 2012, Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.annotations;
19 -
20 -import java.lang.annotation.ElementType;
21 -import java.lang.annotation.Target;
22 -
23 -/**
24 - * Annotation used to document log messages. This can be used to generate
25 - * documentation on syslog output. This version allows multiple log messages
26 - * to be documentated on an interface.
27 - *
28 - */
29 -@Target({ ElementType.TYPE, ElementType.METHOD })
30 -public @interface LogMessageDocs {
31 - /**
32 - * A list of {@link LogMessageDoc} elements.
33 - *
34 - * @return the list of log message doc
35 - */
36 - LogMessageDoc[] value();
37 -}
1 -package org.onlab.onos.of.controller.impl.debugcounter;
2 -
3 -public interface IDebugCounter {
4 - /**
5 - * Increments the counter by 1 thread-locally, and immediately flushes to
6 - * the global counter storage. This method should be used for counters that
7 - * are updated outside the OF message processing pipeline.
8 - */
9 - void updateCounterWithFlush();
10 -
11 - /**
12 - * Increments the counter by 1 thread-locally. Flushing to the global
13 - * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
14 - * resulting in higher performance. This method should be used for counters
15 - * updated in the OF message processing pipeline.
16 - */
17 - void updateCounterNoFlush();
18 -
19 - /**
20 - * Increments the counter thread-locally by the 'incr' specified, and immediately
21 - * flushes to the global counter storage. This method should be used for counters
22 - * that are updated outside the OF message processing pipeline.
23 - */
24 - void updateCounterWithFlush(int incr);
25 -
26 - /**
27 - * Increments the counter thread-locally by the 'incr' specified. Flushing to the global
28 - * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
29 - * resulting in higher performance. This method should be used for counters
30 - * updated in the OF message processing pipeline.
31 - */
32 - void updateCounterNoFlush(int incr);
33 -
34 - /**
35 - * Retrieve the value of the counter from the global counter store.
36 - */
37 - long getCounterValue();
38 -}
1 -package org.onlab.onos.of.controller.impl.debugcounter;
2 -
3 -import java.util.Collections;
4 -import java.util.List;
5 -
6 -import org.onlab.onos.of.controller.impl.debugcounter.DebugCounter.DebugCounterInfo;
7 -
8 -public class NullDebugCounter implements IDebugCounterService {
9 -
10 - @Override
11 - public void flushCounters() {
12 -
13 - }
14 -
15 - @Override
16 - public void resetAllCounters() {
17 -
18 - }
19 -
20 - @Override
21 - public void resetAllModuleCounters(String moduleName) {
22 -
23 - }
24 -
25 -
26 - @Override
27 - public void resetCounterHierarchy(String moduleName, String counterHierarchy) {
28 -
29 - }
30 -
31 - @Override
32 - public void enableCtrOnDemand(String moduleName, String counterHierarchy) {
33 -
34 - }
35 -
36 - @Override
37 - public void disableCtrOnDemand(String moduleName, String counterHierarchy) {
38 -
39 - }
40 -
41 - @Override
42 - public List<DebugCounterInfo> getCounterHierarchy(String moduleName,
43 - String counterHierarchy) {
44 - return Collections.emptyList();
45 - }
46 -
47 - @Override
48 - public List<DebugCounterInfo> getAllCounterValues() {
49 - return Collections.emptyList();
50 - }
51 -
52 - @Override
53 - public List<DebugCounterInfo> getModuleCounterValues(String moduleName) {
54 - return Collections.emptyList();
55 - }
56 -
57 - @Override
58 - public boolean containsModuleCounterHierarchy(String moduleName,
59 - String counterHierarchy) {
60 - return false;
61 - }
62 -
63 - @Override
64 - public boolean containsModuleName(String moduleName) {
65 - return false;
66 - }
67 -
68 - @Override
69 - public
70 - IDebugCounter
71 - registerCounter(String moduleName, String counterHierarchy,
72 - String counterDescription,
73 - CounterType counterType, String... metaData)
74 - throws MaxCountersRegistered {
75 - return new NullCounterImpl();
76 - }
77 -
78 - @Override
79 - public List<String> getModuleList() {
80 - return Collections.emptyList();
81 - }
82 -
83 - @Override
84 - public List<String> getModuleCounterList(String moduleName) {
85 - return Collections.emptyList();
86 - }
87 -
88 - public static class NullCounterImpl implements IDebugCounter {
89 -
90 - @Override
91 - public void updateCounterWithFlush() {
92 -
93 - }
94 -
95 - @Override
96 - public void updateCounterNoFlush() {
97 -
98 - }
99 -
100 - @Override
101 - public void updateCounterWithFlush(int incr) {
102 - }
103 -
104 - @Override
105 - public void updateCounterNoFlush(int incr) {
106 -
107 - }
108 -
109 - @Override
110 - public long getCounterValue() {
111 - return -1;
112 - }
113 -
114 - }
115 -
116 -}
1 -/**
2 - * Copyright 2011, Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.internal;
19 -
20 -/**
21 - * Exception is thrown when the handshake fails to complete.
22 - * before a specified time
23 - *
24 - */
25 -public class HandshakeTimeoutException extends Exception {
26 -
27 - private static final long serialVersionUID = 6859880268940337312L;
28 -
29 -}
1 -/**
2 -* Copyright 2011, Big Switch Networks, Inc.
3 -* Originally created by David Erickson, Stanford University
4 -*
5 -* Licensed under the Apache License, Version 2.0 (the "License"); you may
6 -* not use this file except in compliance with the License. You may obtain
7 -* a copy of the License at
8 -*
9 -* http://www.apache.org/licenses/LICENSE-2.0
10 -*
11 -* Unless required by applicable law or agreed to in writing, software
12 -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 -* License for the specific language governing permissions and limitations
15 -* under the License.
16 -**/
17 -
18 -package org.onlab.onos.of.controller.impl.internal;
19 -
20 -import java.util.concurrent.TimeUnit;
21 -
22 -import org.jboss.netty.channel.ChannelHandlerContext;
23 -import org.jboss.netty.channel.ChannelStateEvent;
24 -import org.jboss.netty.channel.Channels;
25 -import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
26 -import org.jboss.netty.util.Timeout;
27 -import org.jboss.netty.util.Timer;
28 -import org.jboss.netty.util.TimerTask;
29 -
30 -/**
31 - * Trigger a timeout if a switch fails to complete handshake soon enough.
32 - */
33 -public class HandshakeTimeoutHandler
34 - extends SimpleChannelUpstreamHandler {
35 - static final HandshakeTimeoutException EXCEPTION =
36 - new HandshakeTimeoutException();
37 -
38 - final OFChannelHandler channelHandler;
39 - final Timer timer;
40 - final long timeoutNanos;
41 - volatile Timeout timeout;
42 -
43 - public HandshakeTimeoutHandler(OFChannelHandler channelHandler,
44 - Timer timer,
45 - long timeoutSeconds) {
46 - super();
47 - this.channelHandler = channelHandler;
48 - this.timer = timer;
49 - this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);
50 -
51 - }
52 -
53 - @Override
54 - public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
55 - throws Exception {
56 - if (timeoutNanos > 0) {
57 - timeout = timer.newTimeout(new HandshakeTimeoutTask(ctx),
58 - timeoutNanos, TimeUnit.NANOSECONDS);
59 - }
60 - ctx.sendUpstream(e);
61 - }
62 -
63 - @Override
64 - public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
65 - throws Exception {
66 - if (timeout != null) {
67 - timeout.cancel();
68 - timeout = null;
69 - }
70 - }
71 -
72 - private final class HandshakeTimeoutTask implements TimerTask {
73 -
74 - private final ChannelHandlerContext ctx;
75 -
76 - HandshakeTimeoutTask(ChannelHandlerContext ctx) {
77 - this.ctx = ctx;
78 - }
79 -
80 - @Override
81 - public void run(Timeout t) throws Exception {
82 - if (t.isCancelled()) {
83 - return;
84 - }
85 -
86 - if (!ctx.getChannel().isOpen()) {
87 - return;
88 - }
89 - if (!channelHandler.isHandshakeComplete()) {
90 - Channels.fireExceptionCaught(ctx, EXCEPTION);
91 - }
92 - }
93 - }
94 -}
1 -/**
2 - * Copyright 2011, Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.internal;
19 -
20 -
21 -import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.jboss.netty.channel.Channel;
23 -import org.jboss.netty.channel.ChannelHandlerContext;
24 -import org.jboss.netty.handler.codec.frame.FrameDecoder;
25 -import org.projectfloodlight.openflow.protocol.OFFactories;
26 -import org.projectfloodlight.openflow.protocol.OFMessage;
27 -import org.projectfloodlight.openflow.protocol.OFMessageReader;
28 -
29 -/**
30 - * Decode an openflow message from a Channel, for use in a netty pipeline.
31 - */
32 -public class OFMessageDecoder extends FrameDecoder {
33 -
34 - @Override
35 - protected Object decode(ChannelHandlerContext ctx, Channel channel,
36 - ChannelBuffer buffer) throws Exception {
37 - if (!channel.isConnected()) {
38 - // In testing, I see decode being called AFTER decode last.
39 - // This check avoids that from reading corrupted frames
40 - return null;
41 - }
42 -
43 - // Note that a single call to decode results in reading a single
44 - // OFMessage from the channel buffer, which is passed on to, and processed
45 - // by, the controller (in OFChannelHandler).
46 - // This is different from earlier behavior (with the original openflowj),
47 - // where we parsed all the messages in the buffer, before passing on
48 - // a list of the parsed messages to the controller.
49 - // The performance *may or may not* not be as good as before.
50 - OFMessageReader<OFMessage> reader = OFFactories.getGenericReader();
51 - OFMessage message = reader.readFrom(buffer);
52 -
53 - return message;
54 - }
55 -
56 -}
1 -/**
2 - * Copyright 2011, Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.internal;
19 -
20 -import java.util.List;
21 -
22 -import org.jboss.netty.buffer.ChannelBuffer;
23 -import org.jboss.netty.buffer.ChannelBuffers;
24 -import org.jboss.netty.channel.Channel;
25 -import org.jboss.netty.channel.ChannelHandlerContext;
26 -import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
27 -import org.projectfloodlight.openflow.protocol.OFMessage;
28 -
29 -
30 -/**
31 - * Encode an openflow message for output into a ChannelBuffer, for use in a
32 - * netty pipeline.
33 - */
34 -public class OFMessageEncoder extends OneToOneEncoder {
35 -
36 - @Override
37 - protected Object encode(ChannelHandlerContext ctx, Channel channel,
38 - Object msg) throws Exception {
39 - if (!(msg instanceof List)) {
40 - return msg;
41 - }
42 -
43 - @SuppressWarnings("unchecked")
44 - List<OFMessage> msglist = (List<OFMessage>) msg;
45 - /* XXX S can't get length of OFMessage in loxigen's openflowj??
46 - int size = 0;
47 - for (OFMessage ofm : msglist) {
48 - size += ofm.getLengthU();
49 - }*/
50 -
51 - ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
52 -
53 - for (OFMessage ofm : msglist) {
54 - ofm.writeTo(buf);
55 - }
56 - return buf;
57 - }
58 -
59 -}
1 -/**
2 -* Copyright 2011, Big Switch Networks, Inc.
3 -* Originally created by David Erickson, Stanford University
4 -*
5 -* Licensed under the Apache License, Version 2.0 (the "License"); you may
6 -* not use this file except in compliance with the License. You may obtain
7 -* a copy of the License at
8 -*
9 -* http://www.apache.org/licenses/LICENSE-2.0
10 -*
11 -* Unless required by applicable law or agreed to in writing, software
12 -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 -* License for the specific language governing permissions and limitations
15 -* under the License.
16 -**/
17 -
18 -package org.onlab.onos.of.controller.impl.internal;
19 -
20 -import java.util.concurrent.ThreadPoolExecutor;
21 -
22 -import org.jboss.netty.channel.ChannelPipeline;
23 -import org.jboss.netty.channel.ChannelPipelineFactory;
24 -import org.jboss.netty.channel.Channels;
25 -import org.jboss.netty.handler.execution.ExecutionHandler;
26 -import org.jboss.netty.handler.timeout.IdleStateHandler;
27 -import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
28 -import org.jboss.netty.util.ExternalResourceReleasable;
29 -import org.jboss.netty.util.HashedWheelTimer;
30 -import org.jboss.netty.util.Timer;
31 -
32 -/**
33 - * Creates a ChannelPipeline for a server-side openflow channel.
34 - */
35 -public class OpenflowPipelineFactory
36 - implements ChannelPipelineFactory, ExternalResourceReleasable {
37 -
38 - protected Controller controller;
39 - protected ThreadPoolExecutor pipelineExecutor;
40 - protected Timer timer;
41 - protected IdleStateHandler idleHandler;
42 - protected ReadTimeoutHandler readTimeoutHandler;
43 -
44 - public OpenflowPipelineFactory(Controller controller,
45 - ThreadPoolExecutor pipelineExecutor) {
46 - super();
47 - this.controller = controller;
48 - this.pipelineExecutor = pipelineExecutor;
49 - this.timer = new HashedWheelTimer();
50 - this.idleHandler = new IdleStateHandler(timer, 20, 25, 0);
51 - this.readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
52 - }
53 -
54 - @Override
55 - public ChannelPipeline getPipeline() throws Exception {
56 - OFChannelHandler handler = new OFChannelHandler(controller);
57 -
58 - ChannelPipeline pipeline = Channels.pipeline();
59 - pipeline.addLast("ofmessagedecoder", new OFMessageDecoder());
60 - pipeline.addLast("ofmessageencoder", new OFMessageEncoder());
61 - pipeline.addLast("idle", idleHandler);
62 - pipeline.addLast("timeout", readTimeoutHandler);
63 - // XXX S ONOS: was 15 increased it to fix Issue #296
64 - pipeline.addLast("handshaketimeout",
65 - new HandshakeTimeoutHandler(handler, timer, 60));
66 - if (pipelineExecutor != null) {
67 - pipeline.addLast("pipelineExecutor",
68 - new ExecutionHandler(pipelineExecutor));
69 - }
70 - pipeline.addLast("handler", handler);
71 - return pipeline;
72 - }
73 -
74 - @Override
75 - public void releaseExternalResources() {
76 - timer.stop();
77 - }
78 -}
1 -package org.onlab.onos.of.controller.impl.internal;
2 -
3 -/**
4 - * Thrown when IOFSwitch.startDriverHandshake() is called more than once.
5 - *
6 - */
7 -public class SwitchDriverSubHandshakeAlreadyStarted extends
8 - SwitchDriverSubHandshakeException {
9 - private static final long serialVersionUID = -5491845708752443501L;
10 -
11 - public SwitchDriverSubHandshakeAlreadyStarted() {
12 - super();
13 - }
14 -}
1 -package org.onlab.onos.of.controller.impl.internal;
2 -
3 -import org.projectfloodlight.openflow.protocol.OFMessage;
4 -
5 -
6 -/**
7 - * Indicates that a message was passed to a switch driver's subhandshake
8 - * handling code but the driver has already completed the sub-handshake.
9 - *
10 - */
11 -public class SwitchDriverSubHandshakeCompleted
12 - extends SwitchDriverSubHandshakeException {
13 - private static final long serialVersionUID = -8817822245846375995L;
14 -
15 - public SwitchDriverSubHandshakeCompleted(OFMessage m) {
16 - super("Sub-Handshake is already complete but received message "
17 - + m.getType());
18 - }
19 -}
1 -package org.onlab.onos.of.controller.impl.internal;
2 -
3 -/**
4 - * Base class for exception thrown by switch driver sub-handshake processing.
5 - *
6 - */
7 -public class SwitchDriverSubHandshakeException extends RuntimeException {
8 - private static final long serialVersionUID = -6257836781419604438L;
9 -
10 - protected SwitchDriverSubHandshakeException() {
11 - super();
12 - }
13 -
14 - protected SwitchDriverSubHandshakeException(String arg0, Throwable arg1) {
15 - super(arg0, arg1);
16 - }
17 -
18 - protected SwitchDriverSubHandshakeException(String arg0) {
19 - super(arg0);
20 - }
21 -
22 - protected SwitchDriverSubHandshakeException(Throwable arg0) {
23 - super(arg0);
24 - }
25 -
26 -}
1 -package org.onlab.onos.of.controller.impl.internal;
2 -
3 -/**
4 - * Thrown when a switch driver's sub-handshake has not been started but an
5 - * operation requiring the sub-handshake has been attempted.
6 - *
7 - */
8 -public class SwitchDriverSubHandshakeNotStarted extends
9 - SwitchDriverSubHandshakeException {
10 - private static final long serialVersionUID = -5491845708752443501L;
11 -
12 - public SwitchDriverSubHandshakeNotStarted() {
13 - super();
14 - }
15 -}
1 -package org.onlab.onos.of.controller.impl.internal;
2 -
3 -/**
4 - * Thrown when a switch driver's sub-handshake state-machine receives an
5 - * unexpected OFMessage and/or is in an invald state.
6 - *
7 - */
8 -public class SwitchDriverSubHandshakeStateException extends
9 - SwitchDriverSubHandshakeException {
10 - private static final long serialVersionUID = -8249926069195147051L;
11 -
12 - public SwitchDriverSubHandshakeStateException(String msg) {
13 - super(msg);
14 - }
15 -}
1 -/**
2 - * Copyright 2011, Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.internal;
19 -
20 -/**
21 - * This exception indicates an error or unexpected message during
22 - * message handling. E.g., if an OFMessage is received that is illegal or
23 - * unexpected given the current handshake state.
24 - *
25 - * We don't allow wrapping other exception in a switch state exception. We
26 - * only log the SwitchStateExceptions message so the causing exceptions
27 - * stack trace is generally not available.
28 - *
29 - */
30 -public class SwitchStateException extends Exception {
31 -
32 - private static final long serialVersionUID = 9153954512470002631L;
33 -
34 - public SwitchStateException() {
35 - super();
36 - }
37 -
38 - public SwitchStateException(String arg0, Throwable arg1) {
39 - super(arg0, arg1);
40 - }
41 -
42 - public SwitchStateException(String arg0) {
43 - super(arg0);
44 - }
45 -
46 - public SwitchStateException(Throwable arg0) {
47 - super(arg0);
48 - }
49 -
50 -}
1 -package org.onlab.onos.of.controller.impl.registry;
2 -
3 -
4 -
5 -public class ControllerRegistryEntry implements Comparable<ControllerRegistryEntry> {
6 - //
7 - // TODO: Refactor the implementation and decide whether controllerId
8 - // is needed. If "yes", we might need to consider it inside the
9 - // compareTo(), equals() and hashCode() implementations.
10 - //
11 - private final String controllerId;
12 - private final int sequenceNumber;
13 -
14 - public ControllerRegistryEntry(String controllerId, int sequenceNumber) {
15 - this.controllerId = controllerId;
16 - this.sequenceNumber = sequenceNumber;
17 - }
18 -
19 - public String getControllerId() {
20 - return controllerId;
21 - }
22 -
23 - /**
24 - * Compares this object with the specified object for order.
25 - * NOTE: the test is based on ControllerRegistryEntry sequence numbers,
26 - * and doesn't include the controllerId.
27 - *
28 - * @param o the object to be compared.
29 - * @return a negative integer, zero, or a positive integer as this object
30 - * is less than, equal to, or greater than the specified object.
31 - */
32 - @Override
33 - public int compareTo(ControllerRegistryEntry o) {
34 - return this.sequenceNumber - o.sequenceNumber;
35 - }
36 -
37 - /**
38 - * Test whether some other object is "equal to" this one.
39 - * NOTE: the test is based on ControllerRegistryEntry sequence numbers,
40 - * and doesn't include the controllerId.
41 - *
42 - * @param obj the reference object with which to compare.
43 - * @return true if this object is the same as the obj argument; false
44 - * otherwise.
45 - */
46 - @Override
47 - public boolean equals(Object obj) {
48 - if (obj instanceof ControllerRegistryEntry) {
49 - ControllerRegistryEntry other = (ControllerRegistryEntry) obj;
50 - return this.sequenceNumber == other.sequenceNumber;
51 - }
52 - return false;
53 - }
54 -
55 - /**
56 - * Get the hash code for the object.
57 - * NOTE: the computation is based on ControllerRegistryEntry sequence
58 - * numbers, and doesn't include the controller ID.
59 - *
60 - * @return a hash code value for this object.
61 - */
62 - @Override
63 - public int hashCode() {
64 - return Integer.valueOf(this.sequenceNumber).hashCode();
65 - }
66 -}
1 -package org.onlab.onos.of.controller.impl.registry;
2 -
3 -import java.util.Collection;
4 -import java.util.List;
5 -import java.util.Map;
6 -
7 -import org.onlab.onos.of.controller.impl.util.InstanceId;
8 -
9 -/**
10 - * A registry service that allows ONOS to register controllers and switches in a
11 - * way that is global to the entire ONOS cluster. The registry is the arbiter
12 - * for allowing controllers to control switches.
13 - * <p/>
14 - * The OVS/OF1.{2,3} fault tolerance model is a switch connects to multiple
15 - * controllers, and the controllers send role requests to tell the switch their
16 - * role in controlling the switch.
17 - * <p/>
18 - * The ONOS fault tolerance model allows only a single controller to have
19 - * control of a switch (MASTER role) at once. Controllers therefore need a
20 - * mechanism that enables them to decide who should control a each switch. The
21 - * registry service provides this mechanism.
22 - */
23 -public interface IControllerRegistry {
24 -
25 - /**
26 - * Callback interface for control change events.
27 - */
28 - public interface ControlChangeCallback {
29 - /**
30 - * Called whenever the control changes from the point of view of the
31 - * registry. The callee can check whether they have control or not using
32 - * the hasControl parameter.
33 - *
34 - * @param dpid The switch that control has changed for
35 - * @param hasControl Whether the listener now has control or not
36 - */
37 - void controlChanged(long dpid, boolean hasControl);
38 - }
39 -
40 - /**
41 - * Request for control of a switch. This method does not block. When control
42 - * for a switch changes, the controlChanged method on the callback object
43 - * will be called. This happens any time the control changes while the
44 - * request is still active (until releaseControl is called)
45 - *
46 - * @param dpid Switch to request control for
47 - * @param cb Callback that will be used to notify caller of control changes
48 - * @throws RegistryException Errors contacting the registry service
49 - */
50 - public void requestControl(long dpid, ControlChangeCallback cb)
51 - throws RegistryException;
52 -
53 - /**
54 - * Stop trying to take control of a switch. This removes the entry for this
55 - * controller requesting this switch in the registry. If the controller had
56 - * control when this is called, another controller will now gain control of
57 - * the switch. This call doesn't block.
58 - *
59 - * @param dpid Switch to release control of
60 - */
61 - public void releaseControl(long dpid);
62 -
63 - /**
64 - * Check whether the controller has control of the switch This call doesn't
65 - * block.
66 - *
67 - * @param dpid Switch to check control of
68 - * @return true if controller has control of the switch.
69 - */
70 - public boolean hasControl(long dpid);
71 -
72 - /**
73 - * Check whether this instance is the leader for the cluster. This call
74 - * doesn't block.
75 - *
76 - * @return true if the instance is the leader for the cluster, otherwise
77 - * false.
78 - */
79 - public boolean isClusterLeader();
80 -
81 - /**
82 - * Gets the unique ID used to identify this ONOS instance in the cluster.
83 - *
84 - * @return Instance ID.
85 - */
86 - public InstanceId getOnosInstanceId();
87 -
88 - /**
89 - * Register a controller to the ONOS cluster. Must be called before the
90 - * registry can be used to take control of any switches.
91 - *
92 - * @param controllerId A unique string ID identifying this controller in the
93 - * cluster
94 - * @throws RegistryException for errors connecting to registry service,
95 - * controllerId already registered
96 - */
97 - public void registerController(String controllerId)
98 - throws RegistryException;
99 -
100 - /**
101 - * Get all controllers in the cluster.
102 - *
103 - * @return Collection of controller IDs
104 - * @throws RegistryException on error
105 - */
106 - public Collection<String> getAllControllers() throws RegistryException;
107 -
108 - /**
109 - * Get all switches in the cluster, along with which controller is in
110 - * control of them (if any) and any other controllers that have requested
111 - * control.
112 - *
113 - * @return Map of all switches.
114 - */
115 - public Map<String, List<ControllerRegistryEntry>> getAllSwitches();
116 -
117 - /**
118 - * Get the controller that has control of a given switch.
119 - *
120 - * @param dpid Switch to find controller for
121 - * @return controller ID
122 - * @throws RegistryException Errors contacting registry service
123 - */
124 - public String getControllerForSwitch(long dpid) throws RegistryException;
125 -
126 - /**
127 - * Get all switches controlled by a given controller.
128 - *
129 - * @param controllerId ID of the controller
130 - * @return Collection of dpids
131 - */
132 - public Collection<Long> getSwitchesControlledByController(String controllerId);
133 -
134 - /**
135 - * Get a unique Id Block.
136 - *
137 - * @return Id Block.
138 - */
139 - public IdBlock allocateUniqueIdBlock();
140 -
141 - /**
142 - * Get next unique id and retrieve a new range of ids if needed.
143 - *
144 - * @param range range to use for the identifier
145 - * @return Id Block.
146 - */
147 - public IdBlock allocateUniqueIdBlock(long range);
148 -
149 - /**
150 - * Get a globally unique ID.
151 - *
152 - * @return a globally unique ID.
153 - */
154 - public long getNextUniqueId();
155 -}
1 -package org.onlab.onos.of.controller.impl.registry;
2 -
3 -public class IdBlock {
4 - private final long start;
5 - private final long end;
6 - private final long size;
7 -
8 - public IdBlock(long start, long end, long size) {
9 - this.start = start;
10 - this.end = end;
11 - this.size = size;
12 - }
13 -
14 - public long getStart() {
15 - return start;
16 - }
17 -
18 - public long getEnd() {
19 - return end;
20 - }
21 -
22 - public long getSize() {
23 - return size;
24 - }
25 -
26 - @Override
27 - public String toString() {
28 - return "IdBlock [start=" + start + ", end=" + end + ", size=" + size
29 - + "]";
30 - }
31 -}
32 -
1 -package org.onlab.onos.of.controller.impl.registry;
2 -
3 -public class RegistryException extends Exception {
4 -
5 - private static final long serialVersionUID = -8276300722010217913L;
6 -
7 - public RegistryException(String message) {
8 - super(message);
9 - }
10 -
11 - public RegistryException(String message, Throwable cause) {
12 - super(message, cause);
13 - }
14 -
15 -}
1 -package org.onlab.onos.of.controller.impl.util;
2 -
3 -import org.projectfloodlight.openflow.util.HexString;
4 -
5 -/**
6 - * The class representing a network switch DPID.
7 - * This class is immutable.
8 - */
9 -public final class Dpid {
10 - private static final long UNKNOWN = 0;
11 - private final long value;
12 -
13 - /**
14 - * Default constructor.
15 - */
16 - public Dpid() {
17 - this.value = Dpid.UNKNOWN;
18 - }
19 -
20 - /**
21 - * Constructor from a long value.
22 - *
23 - * @param value the value to use.
24 - */
25 - public Dpid(long value) {
26 - this.value = value;
27 - }
28 -
29 - /**
30 - * Constructor from a string.
31 - *
32 - * @param value the value to use.
33 - */
34 - public Dpid(String value) {
35 - this.value = HexString.toLong(value);
36 - }
37 -
38 - /**
39 - * Get the value of the DPID.
40 - *
41 - * @return the value of the DPID.
42 - */
43 - public long value() {
44 - return value;
45 - }
46 -
47 - /**
48 - * Convert the DPID value to a ':' separated hexadecimal string.
49 - *
50 - * @return the DPID value as a ':' separated hexadecimal string.
51 - */
52 - @Override
53 - public String toString() {
54 - return HexString.toHexString(this.value);
55 - }
56 -
57 - @Override
58 - public boolean equals(Object other) {
59 - if (!(other instanceof Dpid)) {
60 - return false;
61 - }
62 -
63 - Dpid otherDpid = (Dpid) other;
64 -
65 - return value == otherDpid.value;
66 - }
67 -
68 - @Override
69 - public int hashCode() {
70 - int hash = 17;
71 - hash += 31 * hash + (int) (value ^ value >>> 32);
72 - return hash;
73 - }
74 -}
1 -package org.onlab.onos.of.controller.impl.util;
2 -
3 -import java.io.IOException;
4 -import java.util.Collection;
5 -import java.util.Date;
6 -import java.util.List;
7 -import java.util.Map;
8 -import java.util.Set;
9 -import java.util.concurrent.Future;
10 -
11 -import org.jboss.netty.channel.Channel;
12 -import org.projectfloodlight.openflow.protocol.OFActionType;
13 -import org.projectfloodlight.openflow.protocol.OFCapabilities;
14 -import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
15 -import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
16 -import org.projectfloodlight.openflow.protocol.OFMessage;
17 -import org.projectfloodlight.openflow.protocol.OFPortDesc;
18 -import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
19 -import org.projectfloodlight.openflow.protocol.OFPortStatus;
20 -import org.projectfloodlight.openflow.protocol.OFStatsReply;
21 -import org.projectfloodlight.openflow.protocol.OFStatsRequest;
22 -import org.projectfloodlight.openflow.protocol.OFVersion;
23 -import org.projectfloodlight.openflow.types.DatapathId;
24 -import org.projectfloodlight.openflow.types.U64;
25 -import org.slf4j.Logger;
26 -import org.slf4j.LoggerFactory;
27 -
28 -import net.onrc.onos.of.ctl.IOFSwitch;
29 -import net.onrc.onos.of.ctl.Role;
30 -import org.onlab.onos.of.controller.impl.debugcounter.IDebugCounterService;
31 -import org.onlab.onos.of.controller.impl.debugcounter.IDebugCounterService.CounterException;
32 -
33 -public class DummySwitchForTesting implements IOFSwitch {
34 -
35 - protected static final Logger log = LoggerFactory.getLogger(DummySwitchForTesting.class);
36 -
37 - private Channel channel;
38 - private boolean connected = false;
39 - private OFVersion ofv = OFVersion.OF_10;
40 -
41 - private Collection<OFPortDesc> ports;
42 -
43 - private DatapathId datapathId;
44 -
45 - private Set<OFCapabilities> capabilities;
46 -
47 - private int buffers;
48 -
49 - private byte tables;
50 -
51 - private String stringId;
52 -
53 - private Role role;
54 -
55 - @Override
56 - public void disconnectSwitch() {
57 - this.channel.close();
58 - }
59 -
60 - @Override
61 - public void write(OFMessage m) throws IOException {
62 - this.channel.write(m);
63 -
64 - }
65 -
66 - @Override
67 - public void write(List<OFMessage> msglist) throws IOException {
68 - for (OFMessage m : msglist) {
69 - this.channel.write(m);
70 - }
71 -
72 - }
73 -
74 - @Override
75 - public Date getConnectedSince() {
76 - // TODO Auto-generated method stub
77 - return null;
78 - }
79 -
80 - @Override
81 - public int getNextTransactionId() {
82 - return 0;
83 - }
84 -
85 - @Override
86 - public boolean isConnected() {
87 - return this.connected;
88 - }
89 -
90 - @Override
91 - public void setConnected(boolean connected) {
92 - this.connected = connected;
93 -
94 - }
95 -
96 - @Override
97 - public void flush() {
98 - // TODO Auto-generated method stub
99 -
100 - }
101 -
102 - @Override
103 - public void setChannel(Channel channel) {
104 - this.channel = channel;
105 -
106 - }
107 -
108 - @Override
109 - public long getId() {
110 - if (this.stringId == null) {
111 - throw new RuntimeException("Features reply has not yet been set");
112 - }
113 - return this.datapathId.getLong();
114 - }
115 -
116 - @Override
117 - public String getStringId() {
118 - // TODO Auto-generated method stub
119 - return "DummySwitch";
120 - }
121 -
122 - @Override
123 - public int getNumBuffers() {
124 - // TODO Auto-generated method stub
125 - return 0;
126 - }
127 -
128 - @Override
129 - public Set<OFCapabilities> getCapabilities() {
130 - // TODO Auto-generated method stub
131 - return null;
132 - }
133 -
134 - @Override
135 - public byte getNumTables() {
136 - // TODO Auto-generated method stub
137 - return 0;
138 - }
139 -
140 - @Override
141 - public OFDescStatsReply getSwitchDescription() {
142 - // TODO Auto-generated method stub
143 - return null;
144 - }
145 -
146 - @Override
147 - public void cancelFeaturesReply(int transactionId) {
148 - // TODO Auto-generated method stub
149 -
150 - }
151 -
152 - @Override
153 - public Set<OFActionType> getActions() {
154 - // TODO Auto-generated method stub
155 - return null;
156 - }
157 -
158 - @Override
159 - public void setOFVersion(OFVersion version) {
160 - // TODO Auto-generated method stub
161 -
162 - }
163 -
164 - @Override
165 - public OFVersion getOFVersion() {
166 - return this.ofv;
167 - }
168 -
169 - @Override
170 - public Collection<OFPortDesc> getEnabledPorts() {
171 - // TODO Auto-generated method stub
172 - return null;
173 - }
174 -
175 - @Override
176 - public Collection<Integer> getEnabledPortNumbers() {
177 - // TODO Auto-generated method stub
178 - return null;
179 - }
180 -
181 - @Override
182 - public OFPortDesc getPort(int portNumber) {
183 - // TODO Auto-generated method stub
184 - return null;
185 - }
186 -
187 - @Override
188 - public OFPortDesc getPort(String portName) {
189 - // TODO Auto-generated method stub
190 - return null;
191 - }
192 -
193 - @Override
194 - public OrderedCollection<PortChangeEvent> processOFPortStatus(
195 - OFPortStatus ps) {
196 - // TODO Auto-generated method stub
197 - return null;
198 - }
199 -
200 - @Override
201 - public Collection<OFPortDesc> getPorts() {
202 - return ports;
203 - }
204 -
205 - @Override
206 - public boolean portEnabled(int portName) {
207 - // TODO Auto-generated method stub
208 - return false;
209 - }
210 -
211 - @Override
212 - public OrderedCollection<PortChangeEvent> setPorts(
213 - Collection<OFPortDesc> p) {
214 - this.ports = p;
215 - return null;
216 - }
217 -
218 - @Override
219 - public Map<Object, Object> getAttributes() {
220 - return null;
221 - }
222 -
223 - @Override
224 - public boolean hasAttribute(String name) {
225 - // TODO Auto-generated method stub
226 - return false;
227 - }
228 -
229 - @Override
230 - public Object getAttribute(String name) {
231 - return Boolean.FALSE;
232 - }
233 -
234 - @Override
235 - public void setAttribute(String name, Object value) {
236 - // TODO Auto-generated method stub
237 -
238 - }
239 -
240 - @Override
241 - public Object removeAttribute(String name) {
242 - // TODO Auto-generated method stub
243 - return null;
244 - }
245 -
246 - @Override
247 - public void deliverStatisticsReply(OFMessage reply) {
248 - // TODO Auto-generated method stub
249 -
250 - }
251 -
252 - @Override
253 - public void cancelStatisticsReply(int transactionId) {
254 - // TODO Auto-generated method stub
255 -
256 - }
257 -
258 - @Override
259 - public void cancelAllStatisticsReplies() {
260 - // TODO Auto-generated method stub
261 -
262 - }
263 -
264 - @Override
265 - public Future<List<OFStatsReply>> getStatistics(OFStatsRequest<?> request)
266 - throws IOException {
267 - // TODO Auto-generated method stub
268 - return null;
269 - }
270 -
271 - @Override
272 - public void clearAllFlowMods() {
273 - // TODO Auto-generated method stub
274 -
275 - }
276 -
277 - @Override
278 - public Role getRole() {
279 - return this.role;
280 - }
281 -
282 - @Override
283 - public void setRole(Role role) {
284 - this.role = role;
285 - }
286 -
287 - @Override
288 - public U64 getNextGenerationId() {
289 - // TODO Auto-generated method stub
290 - return null;
291 - }
292 -
293 - @Override
294 - public void setDebugCounterService(IDebugCounterService debugCounter)
295 - throws CounterException {
296 - // TODO Auto-generated method stub
297 -
298 - }
299 -
300 - @Override
301 - public void startDriverHandshake() throws IOException {
302 - // TODO Auto-generated method stub
303 -
304 - }
305 -
306 - @Override
307 - public boolean isDriverHandshakeComplete() {
308 - return true;
309 - }
310 -
311 - @Override
312 - public void processDriverHandshakeMessage(OFMessage m) {
313 -
314 - }
315 -
316 - @Override
317 - public void setTableFull(boolean isFull) {
318 - // TODO Auto-generated method stub
319 -
320 - }
321 -
322 - @Override
323 - public void setFeaturesReply(OFFeaturesReply featuresReply) {
324 - if (featuresReply == null) {
325 - log.error("Error setting featuresReply for switch: {}", getStringId());
326 - return;
327 - }
328 - this.datapathId = featuresReply.getDatapathId();
329 - this.capabilities = featuresReply.getCapabilities();
330 - this.buffers = (int) featuresReply.getNBuffers();
331 - this.tables = (byte) featuresReply.getNTables();
332 - this.stringId = this.datapathId.toString();
333 -
334 - }
335 -
336 - @Override
337 - public void setPortDescReply(OFPortDescStatsReply portDescReply) {
338 - // TODO Auto-generated method stub
339 -
340 - }
341 -
342 - @Override
343 - public void handleMessage(OFMessage m) {
344 - log.info("Got packet {} but I am dumb so I don't know what to do.", m);
345 - }
346 -
347 - @Override
348 - public boolean portEnabled(String portName) {
349 - // TODO Auto-generated method stub
350 - return false;
351 - }
352 -
353 - @Override
354 - public OrderedCollection<PortChangeEvent> comparePorts(
355 - Collection<OFPortDesc> p) {
356 - // TODO Auto-generated method stub
357 - return null;
358 - }
359 -
360 -}
1 -package org.onlab.onos.of.controller.impl.util;
2 -
3 -import java.util.EnumSet;
4 -import java.util.Set;
5 -
6 -/**
7 - * A utility class to convert between integer based bitmaps for (OpenFlow)
8 - * flags and Enum and EnumSet based representations.
9 - *
10 - * The enum used to represent individual flags needs to implement the
11 - * BitmapableEnum interface.
12 - *
13 - * Example:
14 - * {@code
15 - * int bitmap = 0x11; // OFPPC_PORT_DOWN | OFPPC_NO_STP
16 - * EnumSet<OFPortConfig> s = toEnumSet(OFPortConfig.class, bitmap);
17 - * // s will contain OFPPC_PORT_DOWN and OFPPC_NO_STP
18 - * }
19 - *
20 - * {@code
21 - * EnumSet<OFPortConfig> s = EnumSet.of(OFPPC_NO_STP, OFPPC_PORT_DOWN);
22 - * int bitmap = toBitmap(s); // returns 0x11
23 - * }
24 - *
25 - */
26 -public final class EnumBitmaps {
27 -
28 -
29 - private EnumBitmaps() { }
30 -
31 - /**
32 - * Enums used to represent individual flags needs to implement this
33 - * interface.
34 - */
35 - public interface BitmapableEnum {
36 - /** Return the value in the bitmap that the enum constant represents.
37 - * The returned value must have only a single bit set. E.g.,1 << 3
38 - */
39 - int getValue();
40 - }
41 -
42 -
43 - /**
44 - * Convert an integer bitmap to an EnumSet.
45 - *
46 - * See class description for example
47 - * @param type The Enum class to use. Must implement BitmapableEnum
48 - * @param bitmap The integer bitmap
49 - * @return A newly allocated EnumSet representing the bits set in the
50 - * bitmap
51 - * @throws NullPointerException if type is null
52 - * @throws IllegalArgumentException if any enum constant from type has
53 - * more than one bit set.
54 - * @throws IllegalArgumentException if the bitmap has any bits set not
55 - * represented by an enum constant.
56 - */
57 - public static <E extends Enum<E> & BitmapableEnum>
58 - EnumSet<E> toEnumSet(Class<E> type, int bitmap) {
59 - if (type == null) {
60 - throw new NullPointerException("Given enum type must not be null");
61 - }
62 - EnumSet<E> s = EnumSet.noneOf(type);
63 - // allSetBitmap will eventually have all valid bits for the given
64 - // type set.
65 - int allSetBitmap = 0;
66 - for (E element: type.getEnumConstants()) {
67 - if (Integer.bitCount(element.getValue()) != 1) {
68 - String msg = String.format("The %s (%x) constant of the " +
69 - "enum %s is supposed to represent a bitmap entry but " +
70 - "has more than one bit set.",
71 - element.toString(), element.getValue(), type.getName());
72 - throw new IllegalArgumentException(msg);
73 - }
74 - allSetBitmap |= element.getValue();
75 - if ((bitmap & element.getValue()) != 0) {
76 - s.add(element);
77 - }
78 - }
79 - if (((~allSetBitmap) & bitmap) != 0) {
80 - // check if only valid flags are set in the given bitmap
81 - String msg = String.format("The bitmap %x for enum %s has " +
82 - "bits set that are presented by any enum constant",
83 - bitmap, type.getName());
84 - throw new IllegalArgumentException(msg);
85 - }
86 - return s;
87 - }
88 -
89 - /**
90 - * Return the bitmap mask with all possible bits set. E.g., If a bitmap
91 - * has the individual flags 0x1, 0x2, and 0x8 (note the missing 0x4) then
92 - * the mask will be 0xb (1011 binary)
93 - *
94 - * @param type The Enum class to use. Must implement BitmapableEnum
95 - * @throws NullPointerException if type is null
96 - * @throws IllegalArgumentException if any enum constant from type has
97 - * more than one bit set
98 - * @return an integer with all possible bits for the given bitmap enum
99 - * type set.
100 - */
101 - public static <E extends Enum<E> & BitmapableEnum>
102 - int getMask(Class<E> type) {
103 - if (type == null) {
104 - throw new NullPointerException("Given enum type must not be null");
105 - }
106 - // allSetBitmap will eventually have all valid bits for the given
107 - // type set.
108 - int allSetBitmap = 0;
109 - for (E element: type.getEnumConstants()) {
110 - if (Integer.bitCount(element.getValue()) != 1) {
111 - String msg = String.format("The %s (%x) constant of the " +
112 - "enum %s is supposed to represent a bitmap entry but " +
113 - "has more than one bit set.",
114 - element.toString(), element.getValue(), type.getName());
115 - throw new IllegalArgumentException(msg);
116 - }
117 - allSetBitmap |= element.getValue();
118 - }
119 - return allSetBitmap;
120 - }
121 -
122 - /**
123 - * Convert the given EnumSet to the integer bitmap representation.
124 - * @param set The EnumSet to convert. The enum must implement
125 - * BitmapableEnum
126 - * @return the integer bitmap
127 - * @throws IllegalArgumentException if an enum constant from the set (!) has
128 - * more than one bit set
129 - * @throws NullPointerException if the set is null
130 - */
131 - public static <E extends Enum<E> & BitmapableEnum>
132 - int toBitmap(Set<E> set) {
133 - if (set == null) {
134 - throw new NullPointerException("Given set must not be null");
135 - }
136 - int bitmap = 0;
137 - for (E element: set) {
138 - if (Integer.bitCount(element.getValue()) != 1) {
139 - String msg = String.format("The %s (%x) constant in the set " +
140 - "is supposed to represent a bitmap entry but " +
141 - "has more than one bit set.",
142 - element.toString(), element.getValue());
143 - throw new IllegalArgumentException(msg);
144 - }
145 - bitmap |= element.getValue();
146 - }
147 - return bitmap;
148 - }
149 -}
1 -/**
2 - * Copyright 2012, Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.util;
19 -
20 -import java.util.Iterator;
21 -import java.util.NoSuchElementException;
22 -
23 -/**
24 - * An iterator that will filter values from an iterator and return only
25 - * those values that match the predicate.
26 - */
27 -public abstract class FilterIterator<T> implements Iterator<T> {
28 - protected Iterator<T> subIterator;
29 - protected T next;
30 -
31 - /**
32 - * Construct a filter iterator from the given sub iterator.
33 - *
34 - * @param subIterator the sub iterator over which we'll filter
35 - */
36 - public FilterIterator(Iterator<T> subIterator) {
37 - super();
38 - this.subIterator = subIterator;
39 - }
40 -
41 - /**
42 - * Check whether the given value should be returned by the
43 - * filter.
44 - *
45 - * @param value the value to check
46 - * @return true if the value should be included
47 - */
48 - protected abstract boolean matches(T value);
49 -
50 - // ***********
51 - // Iterator<T>
52 - // ***********
53 -
54 - @Override
55 - public boolean hasNext() {
56 - if (next != null) {
57 - return true;
58 - }
59 -
60 - while (subIterator.hasNext()) {
61 - next = subIterator.next();
62 - if (matches(next)) {
63 - return true;
64 - }
65 - }
66 - next = null;
67 - return false;
68 - }
69 -
70 - @Override
71 - public T next() {
72 - if (hasNext()) {
73 - T cur = next;
74 - next = null;
75 - return cur;
76 - }
77 - throw new NoSuchElementException();
78 - }
79 -
80 - @Override
81 - public void remove() {
82 - throw new UnsupportedOperationException();
83 - }
84 -
85 -}
1 -package org.onlab.onos.of.controller.impl.util;
2 -
3 -import static com.google.common.base.Preconditions.checkNotNull;
4 -import static com.google.common.base.Preconditions.checkArgument;
5 -
6 -/**
7 - * The class representing an ONOS Instance ID.
8 - *
9 - * This class is immutable.
10 - */
11 -public final class InstanceId {
12 - private final String id;
13 -
14 - /**
15 - * Constructor from a string value.
16 - *
17 - * @param id the value to use.
18 - */
19 - public InstanceId(String id) {
20 - this.id = checkNotNull(id);
21 - checkArgument(!id.isEmpty(), "Empty ONOS Instance ID");
22 - }
23 -
24 - @Override
25 - public int hashCode() {
26 - return id.hashCode();
27 - }
28 -
29 - @Override
30 - public boolean equals(Object obj) {
31 - if (obj == this) {
32 - return true;
33 - }
34 -
35 - if (!(obj instanceof InstanceId)) {
36 - return false;
37 - }
38 -
39 - InstanceId that = (InstanceId) obj;
40 - return this.id.equals(that.id);
41 - }
42 -
43 - @Override
44 - public String toString() {
45 - return id;
46 - }
47 -}
1 -/**
2 - * Copyright 2012 Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.util;
19 -
20 -import java.util.Iterator;
21 -import java.util.NoSuchElementException;
22 -
23 -/**
24 - * Iterator over all values in an iterator of iterators.
25 - *
26 - * @param <T> the type of elements returned by this iterator
27 - */
28 -public class IterableIterator<T> implements Iterator<T> {
29 - Iterator<? extends Iterable<T>> subIterator;
30 - Iterator<T> current = null;
31 -
32 - public IterableIterator(Iterator<? extends Iterable<T>> subIterator) {
33 - super();
34 - this.subIterator = subIterator;
35 - }
36 -
37 - @Override
38 - public boolean hasNext() {
39 - if (current == null) {
40 - if (subIterator.hasNext()) {
41 - current = subIterator.next().iterator();
42 - } else {
43 - return false;
44 - }
45 - }
46 - while (!current.hasNext() && subIterator.hasNext()) {
47 - current = subIterator.next().iterator();
48 - }
49 -
50 - return current.hasNext();
51 - }
52 -
53 - @Override
54 - public T next() {
55 - if (hasNext()) {
56 - return current.next();
57 - }
58 - throw new NoSuchElementException();
59 - }
60 -
61 - @Override
62 - public void remove() {
63 - if (hasNext()) {
64 - current.remove();
65 - }
66 - throw new NoSuchElementException();
67 - }
68 -}
1 -/**
2 - * Copyright 2011, Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.util;
19 -
20 -import java.util.LinkedHashMap;
21 -import java.util.Map;
22 -
23 -public class LRUHashMap<K, V> extends LinkedHashMap<K, V> {
24 -
25 - private static final long serialVersionUID = 1L;
26 -
27 - private final int capacity;
28 -
29 - public LRUHashMap(int capacity) {
30 - super(capacity + 1, 0.75f, true);
31 - this.capacity = capacity;
32 - }
33 -
34 - protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
35 - return size() > capacity;
36 - }
37 -
38 -}
1 -package org.onlab.onos.of.controller.impl.util;
2 -
3 -import java.util.Collection;
4 -import java.util.LinkedHashSet;
5 -
6 -import com.google.common.collect.ForwardingCollection;
7 -
8 -/**
9 - * A simple wrapper / forwarder that forwards all calls to a LinkedHashSet.
10 - * This wrappers sole reason for existence is to implement the
11 - * OrderedCollection marker interface.
12 - *
13 - */
14 -public class LinkedHashSetWrapper<E>
15 - extends ForwardingCollection<E> implements OrderedCollection<E> {
16 - private final Collection<E> delegate;
17 -
18 - public LinkedHashSetWrapper() {
19 - super();
20 - this.delegate = new LinkedHashSet<E>();
21 - }
22 -
23 - public LinkedHashSetWrapper(Collection<? extends E> c) {
24 - super();
25 - this.delegate = new LinkedHashSet<E>(c);
26 - }
27 -
28 - @Override
29 - protected Collection<E> delegate() {
30 - return this.delegate;
31 - }
32 -}
1 -/**
2 - * Copyright 2012 Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.util;
19 -
20 -import java.util.Iterator;
21 -import java.util.NoSuchElementException;
22 -
23 -/**
24 - * Iterator over all values in an iterator of iterators.
25 - *
26 - * @param <T> the type of elements returned by this iterator
27 - */
28 -public class MultiIterator<T> implements Iterator<T> {
29 - Iterator<Iterator<T>> subIterator;
30 - Iterator<T> current = null;
31 -
32 - public MultiIterator(Iterator<Iterator<T>> subIterator) {
33 - super();
34 - this.subIterator = subIterator;
35 - }
36 -
37 - @Override
38 - public boolean hasNext() {
39 - if (current == null) {
40 - if (subIterator.hasNext()) {
41 - current = subIterator.next();
42 - } else {
43 - return false;
44 - }
45 - }
46 - while (!current.hasNext() && subIterator.hasNext()) {
47 - current = subIterator.next();
48 - }
49 -
50 - return current.hasNext();
51 - }
52 -
53 - @Override
54 - public T next() {
55 - if (hasNext()) {
56 - return current.next();
57 - }
58 - throw new NoSuchElementException();
59 - }
60 -
61 - @Override
62 - public void remove() {
63 - if (hasNext()) {
64 - current.remove();
65 - }
66 - throw new NoSuchElementException();
67 - }
68 -}
1 -package org.onlab.onos.of.controller.impl.util;
2 -
3 -import java.util.Collection;
4 -
5 -/**
6 - * A marker interface indicating that this Collection defines a particular
7 - * iteration order. The details about the iteration order are specified by
8 - * the concrete implementation.
9 - *
10 - * @param <E>
11 - */
12 -public interface OrderedCollection<E> extends Collection<E> {
13 -
14 -}
1 -/**
2 - * Copyright 2011, Big Switch Networks, Inc.
3 - * Originally created by David Erickson, Stanford University
4 - *
5 - * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 - * not use this file except in compliance with the License. You may obtain
7 - * a copy of the License at
8 - *
9 - * http://www.apache.org/licenses/LICENSE-2.0
10 - *
11 - * Unless required by applicable law or agreed to in writing, software
12 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 - * License for the specific language governing permissions and limitations
15 - * under the License.
16 - **/
17 -
18 -package org.onlab.onos.of.controller.impl.internal;
19 -
20 -import junit.framework.TestCase;
21 -import net.onrc.onos.of.ctl.IOFSwitch;
22 -
23 -import org.easymock.EasyMock;
24 -import org.junit.After;
25 -import org.junit.Before;
26 -import org.junit.Test;
27 -
28 -
29 -public class ControllerTest extends TestCase {
30 -
31 - private Controller controller;
32 - private IOFSwitch sw;
33 - private OFChannelHandler h;
34 -
35 - @Override
36 - @Before
37 - public void setUp() throws Exception {
38 - super.setUp();
39 - sw = EasyMock.createMock(IOFSwitch.class);
40 - h = EasyMock.createMock(OFChannelHandler.class);
41 - controller = new Controller();
42 - ControllerRunThread t = new ControllerRunThread();
43 - t.start();
44 - /*
45 - * Making sure the thread is properly started before making calls
46 - * to controller class.
47 - */
48 - Thread.sleep(200);
49 - }
50 -
51 - /**
52 - * Starts the base mocks used in these tests.
53 - */
54 - private void startMocks() {
55 - EasyMock.replay(sw, h);
56 - }
57 -
58 - /**
59 - * Reset the mocks to a known state.
60 - * Automatically called after tests.
61 - */
62 - @After
63 - private void resetMocks() {
64 - EasyMock.reset(sw);
65 - }
66 -
67 - /**
68 - * Fetches the controller instance.
69 - * @return the controller
70 - */
71 - public Controller getController() {
72 - return controller;
73 - }
74 -
75 - /**
76 - * Run the controller's main loop so that updates are processed.
77 - */
78 - protected class ControllerRunThread extends Thread {
79 - @Override
80 - public void run() {
81 - controller.openFlowPort = 0; // Don't listen
82 - controller.activate();
83 - }
84 - }
85 -
86 - /**
87 - * Verify that we are able to add a switch that just connected.
88 - * If it already exists then this should fail
89 - *
90 - * @throws Exception error
91 - */
92 - @Test
93 - public void testAddConnectedSwitches() throws Exception {
94 - startMocks();
95 - assertTrue(controller.addConnectedSwitch(0, h));
96 - assertFalse(controller.addConnectedSwitch(0, h));
97 - }
98 -
99 - /**
100 - * Add active master but cannot re-add active master.
101 - * @throws Exception an error occurred.
102 - */
103 - @Test
104 - public void testAddActivatedMasterSwitch() throws Exception {
105 - startMocks();
106 - controller.addConnectedSwitch(0, h);
107 - assertTrue(controller.addActivatedMasterSwitch(0, sw));
108 - assertFalse(controller.addActivatedMasterSwitch(0, sw));
109 - }
110 -
111 - /**
112 - * Tests that an activated switch can be added but cannot be re-added.
113 - *
114 - * @throws Exception an error occurred
115 - */
116 - @Test
117 - public void testAddActivatedEqualSwitch() throws Exception {
118 - startMocks();
119 - controller.addConnectedSwitch(0, h);
120 - assertTrue(controller.addActivatedEqualSwitch(0, sw));
121 - assertFalse(controller.addActivatedEqualSwitch(0, sw));
122 - }
123 -
124 - /**
125 - * Move an equal switch to master.
126 - * @throws Exception an error occurred
127 - */
128 - @Test
129 - public void testTranstitionToMaster() throws Exception {
130 - startMocks();
131 - controller.addConnectedSwitch(0, h);
132 - controller.addActivatedEqualSwitch(0, sw);
133 - controller.transitionToMasterSwitch(0);
134 - assertNotNull(controller.getMasterSwitch(0));
135 - }
136 -
137 - /**
138 - * Transition a master switch to equal state.
139 - * @throws Exception an error occurred
140 - */
141 - @Test
142 - public void testTranstitionToEqual() throws Exception {
143 - startMocks();
144 - controller.addConnectedSwitch(0, h);
145 - controller.addActivatedMasterSwitch(0, sw);
146 - controller.transitionToEqualSwitch(0);
147 - assertNotNull(controller.getEqualSwitch(0));
148 - }
149 -
150 - /**
151 - * Remove the switch from the controller instance.
152 - * @throws Exception an error occurred
153 - */
154 - @Test
155 - public void testRemoveSwitch() throws Exception {
156 - sw.cancelAllStatisticsReplies();
157 - EasyMock.expectLastCall().once();
158 - sw.setConnected(false);
159 - EasyMock.expectLastCall().once();
160 - startMocks();
161 - controller.addConnectedSwitch(0, h);
162 - controller.addActivatedMasterSwitch(0, sw);
163 - controller.removeConnectedSwitch(0);
164 - assertNull(controller.getSwitch(0));
165 - EasyMock.verify(sw, h);
166 - }
167 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template const.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -
27 -public enum OFActionType {
28 - OUTPUT,
29 - SET_VLAN_VID,
30 - SET_VLAN_PCP,
31 - STRIP_VLAN,
32 - SET_DL_SRC,
33 - SET_DL_DST,
34 - SET_NW_SRC,
35 - SET_NW_DST,
36 - SET_NW_TOS,
37 - SET_TP_SRC,
38 - SET_TP_DST,
39 - ENQUEUE,
40 - EXPERIMENTER,
41 - SET_NW_ECN,
42 - COPY_TTL_OUT,
43 - COPY_TTL_IN,
44 - SET_MPLS_LABEL,
45 - SET_MPLS_TC,
46 - SET_MPLS_TTL,
47 - DEC_MPLS_TTL,
48 - PUSH_VLAN,
49 - POP_VLAN,
50 - PUSH_MPLS,
51 - POP_MPLS,
52 - SET_QUEUE,
53 - GROUP,
54 - SET_NW_TTL,
55 - DEC_NW_TTL,
56 - SET_FIELD,
57 - PUSH_PBB,
58 - POP_PBB;
59 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import java.util.Set;
27 -import org.jboss.netty.buffer.ChannelBuffer;
28 -
29 -public interface OFAggregateStatsReply extends OFObject, OFStatsReply {
30 - OFVersion getVersion();
31 - OFType getType();
32 - long getXid();
33 - OFStatsType getStatsType();
34 - Set<OFStatsReplyFlags> getFlags();
35 - U64 getPacketCount();
36 - U64 getByteCount();
37 - long getFlowCount();
38 -
39 - void writeTo(ChannelBuffer channelBuffer);
40 -
41 - Builder createBuilder();
42 - public interface Builder extends OFStatsReply.Builder {
43 - OFAggregateStatsReply build();
44 - OFVersion getVersion();
45 - OFType getType();
46 - long getXid();
47 - Builder setXid(long xid);
48 - OFStatsType getStatsType();
49 - Set<OFStatsReplyFlags> getFlags();
50 - Builder setFlags(Set<OFStatsReplyFlags> flags);
51 - U64 getPacketCount();
52 - Builder setPacketCount(U64 packetCount);
53 - U64 getByteCount();
54 - Builder setByteCount(U64 byteCount);
55 - long getFlowCount();
56 - Builder setFlowCount(long flowCount);
57 - }
58 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import java.util.Set;
27 -import org.jboss.netty.buffer.ChannelBuffer;
28 -
29 -public interface OFAggregateStatsRequest extends OFObject, OFStatsRequest<OFAggregateStatsReply>, OFRequest<OFAggregateStatsReply> {
30 - OFVersion getVersion();
31 - OFType getType();
32 - long getXid();
33 - OFStatsType getStatsType();
34 - Set<OFStatsRequestFlags> getFlags();
35 - TableId getTableId();
36 - OFPort getOutPort();
37 - OFGroup getOutGroup() throws UnsupportedOperationException;
38 - U64 getCookie() throws UnsupportedOperationException;
39 - U64 getCookieMask() throws UnsupportedOperationException;
40 - Match getMatch();
41 -
42 - void writeTo(ChannelBuffer channelBuffer);
43 -
44 - Builder createBuilder();
45 - public interface Builder extends OFStatsRequest.Builder<OFAggregateStatsReply> {
46 - OFAggregateStatsRequest build();
47 - OFVersion getVersion();
48 - OFType getType();
49 - long getXid();
50 - Builder setXid(long xid);
51 - OFStatsType getStatsType();
52 - Set<OFStatsRequestFlags> getFlags();
53 - Builder setFlags(Set<OFStatsRequestFlags> flags);
54 - TableId getTableId();
55 - Builder setTableId(TableId tableId);
56 - OFPort getOutPort();
57 - Builder setOutPort(OFPort outPort);
58 - OFGroup getOutGroup() throws UnsupportedOperationException;
59 - Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException;
60 - U64 getCookie() throws UnsupportedOperationException;
61 - Builder setCookie(U64 cookie) throws UnsupportedOperationException;
62 - U64 getCookieMask() throws UnsupportedOperationException;
63 - Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException;
64 - Match getMatch();
65 - Builder setMatch(Match match);
66 - }
67 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import org.jboss.netty.buffer.ChannelBuffer;
27 -
28 -public interface OFAsyncGetReply extends OFObject, OFMessage {
29 - OFVersion getVersion();
30 - OFType getType();
31 - long getXid();
32 - long getPacketInMaskEqualMaster();
33 - long getPacketInMaskSlave();
34 - long getPortStatusMaskEqualMaster();
35 - long getPortStatusMaskSlave();
36 - long getFlowRemovedMaskEqualMaster();
37 - long getFlowRemovedMaskSlave();
38 -
39 - void writeTo(ChannelBuffer channelBuffer);
40 -
41 - Builder createBuilder();
42 - public interface Builder extends OFMessage.Builder {
43 - OFAsyncGetReply build();
44 - OFVersion getVersion();
45 - OFType getType();
46 - long getXid();
47 - Builder setXid(long xid);
48 - long getPacketInMaskEqualMaster();
49 - Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster);
50 - long getPacketInMaskSlave();
51 - Builder setPacketInMaskSlave(long packetInMaskSlave);
52 - long getPortStatusMaskEqualMaster();
53 - Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster);
54 - long getPortStatusMaskSlave();
55 - Builder setPortStatusMaskSlave(long portStatusMaskSlave);
56 - long getFlowRemovedMaskEqualMaster();
57 - Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster);
58 - long getFlowRemovedMaskSlave();
59 - Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave);
60 - }
61 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import org.jboss.netty.buffer.ChannelBuffer;
27 -
28 -public interface OFAsyncGetRequest extends OFObject, OFMessage, OFRequest<OFAsyncGetReply> {
29 - OFVersion getVersion();
30 - OFType getType();
31 - long getXid();
32 - long getPacketInMaskEqualMaster();
33 - long getPacketInMaskSlave();
34 - long getPortStatusMaskEqualMaster();
35 - long getPortStatusMaskSlave();
36 - long getFlowRemovedMaskEqualMaster();
37 - long getFlowRemovedMaskSlave();
38 -
39 - void writeTo(ChannelBuffer channelBuffer);
40 -
41 - Builder createBuilder();
42 - public interface Builder extends OFMessage.Builder {
43 - OFAsyncGetRequest build();
44 - OFVersion getVersion();
45 - OFType getType();
46 - long getXid();
47 - Builder setXid(long xid);
48 - long getPacketInMaskEqualMaster();
49 - Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster);
50 - long getPacketInMaskSlave();
51 - Builder setPacketInMaskSlave(long packetInMaskSlave);
52 - long getPortStatusMaskEqualMaster();
53 - Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster);
54 - long getPortStatusMaskSlave();
55 - Builder setPortStatusMaskSlave(long portStatusMaskSlave);
56 - long getFlowRemovedMaskEqualMaster();
57 - Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster);
58 - long getFlowRemovedMaskSlave();
59 - Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave);
60 - }
61 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import java.util.Set;
27 -import org.jboss.netty.buffer.ChannelBuffer;
28 -
29 -public interface OFAsyncSet extends OFObject, OFMessage {
30 - OFVersion getVersion();
31 - OFType getType();
32 - long getXid();
33 - long getPacketInMaskEqualMaster();
34 - long getPacketInMaskSlave();
35 - long getPortStatusMaskEqualMaster();
36 - long getPortStatusMaskSlave();
37 - long getFlowRemovedMaskEqualMaster();
38 - long getFlowRemovedMaskSlave();
39 -
40 - void writeTo(ChannelBuffer channelBuffer);
41 -
42 - Builder createBuilder();
43 - public interface Builder extends OFMessage.Builder {
44 - OFAsyncSet build();
45 - OFVersion getVersion();
46 - OFType getType();
47 - long getXid();
48 - Builder setXid(long xid);
49 - long getPacketInMaskEqualMaster();
50 - Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster);
51 - long getPacketInMaskSlave();
52 - Builder setPacketInMaskSlave(long packetInMaskSlave);
53 - long getPortStatusMaskEqualMaster();
54 - Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster);
55 - long getPortStatusMaskSlave();
56 - Builder setPortStatusMaskSlave(long portStatusMaskSlave);
57 - long getFlowRemovedMaskEqualMaster();
58 - Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster);
59 - long getFlowRemovedMaskSlave();
60 - Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave);
61 - }
62 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template const.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -
27 -public enum OFBadActionCode {
28 - BAD_TYPE,
29 - BAD_LEN,
30 - BAD_EXPERIMENTER,
31 - BAD_EXPERIMENTER_TYPE,
32 - BAD_OUT_PORT,
33 - BAD_ARGUMENT,
34 - EPERM,
35 - TOO_MANY,
36 - BAD_QUEUE,
37 - BAD_OUT_GROUP,
38 - MATCH_INCONSISTENT,
39 - UNSUPPORTED_ORDER,
40 - BAD_TAG,
41 - BAD_SET_TYPE,
42 - BAD_SET_LEN,
43 - BAD_SET_ARGUMENT;
44 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template const.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -
27 -public enum OFBadInstructionCode {
28 - UNKNOWN_INST,
29 - UNSUP_INST,
30 - BAD_TABLE_ID,
31 - UNSUP_METADATA,
32 - UNSUP_METADATA_MASK,
33 - UNSUP_EXP_INST,
34 - BAD_EXPERIMENTER,
35 - BAD_EXPERIMENTER_TYPE,
36 - BAD_LEN,
37 - EPERM;
38 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template const.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -
27 -public enum OFBadMatchCode {
28 - BAD_TYPE,
29 - BAD_LEN,
30 - BAD_TAG,
31 - BAD_DL_ADDR_MASK,
32 - BAD_NW_ADDR_MASK,
33 - BAD_WILDCARDS,
34 - BAD_FIELD,
35 - BAD_VALUE,
36 - BAD_MASK,
37 - BAD_PREREQ,
38 - DUP_FIELD,
39 - EPERM;
40 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template const.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -
27 -public enum OFBadRequestCode {
28 - BAD_VERSION,
29 - BAD_TYPE,
30 - BAD_STAT,
31 - BAD_EXPERIMENTER,
32 - BAD_SUBTYPE,
33 - EPERM,
34 - BAD_LEN,
35 - BUFFER_EMPTY,
36 - BUFFER_UNKNOWN,
37 - BAD_TABLE_ID,
38 - BAD_EXPERIMENTER_TYPE,
39 - IS_SLAVE,
40 - BAD_PORT,
41 - BAD_PACKET,
42 - MULTIPART_BUFFER_OVERFLOW;
43 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import org.jboss.netty.buffer.ChannelBuffer;
27 -
28 -public interface OFBarrierReply extends OFObject, OFMessage {
29 - OFVersion getVersion();
30 - OFType getType();
31 - long getXid();
32 -
33 - void writeTo(ChannelBuffer channelBuffer);
34 -
35 - Builder createBuilder();
36 - public interface Builder extends OFMessage.Builder {
37 - OFBarrierReply build();
38 - OFVersion getVersion();
39 - OFType getType();
40 - long getXid();
41 - Builder setXid(long xid);
42 - }
43 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import org.jboss.netty.buffer.ChannelBuffer;
27 -
28 -public interface OFBarrierRequest extends OFObject, OFMessage, OFRequest<OFBarrierReply> {
29 - OFVersion getVersion();
30 - OFType getType();
31 - long getXid();
32 -
33 - void writeTo(ChannelBuffer channelBuffer);
34 -
35 - Builder createBuilder();
36 - public interface Builder extends OFMessage.Builder {
37 - OFBarrierRequest build();
38 - OFVersion getVersion();
39 - OFType getType();
40 - long getXid();
41 - Builder setXid(long xid);
42 - }
43 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import org.jboss.netty.buffer.ChannelBuffer;
27 -
28 -public interface OFBsnArpIdle extends OFObject, OFBsnHeader {
29 - OFVersion getVersion();
30 - OFType getType();
31 - long getXid();
32 - long getExperimenter();
33 - long getSubtype();
34 - int getVlanVid();
35 - IPv4Address getIpv4Addr();
36 -
37 - void writeTo(ChannelBuffer channelBuffer);
38 -
39 - Builder createBuilder();
40 - public interface Builder extends OFBsnHeader.Builder {
41 - OFBsnArpIdle build();
42 - OFVersion getVersion();
43 - OFType getType();
44 - long getXid();
45 - Builder setXid(long xid);
46 - long getExperimenter();
47 - long getSubtype();
48 - int getVlanVid();
49 - Builder setVlanVid(int vlanVid);
50 - IPv4Address getIpv4Addr();
51 - Builder setIpv4Addr(IPv4Address ipv4Addr);
52 - }
53 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import org.jboss.netty.buffer.ChannelBuffer;
27 -
28 -public interface OFBsnBwClearDataReply extends OFObject, OFBsnHeader {
29 - OFVersion getVersion();
30 - OFType getType();
31 - long getXid();
32 - long getExperimenter();
33 - long getSubtype();
34 - long getStatus();
35 -
36 - void writeTo(ChannelBuffer channelBuffer);
37 -
38 - Builder createBuilder();
39 - public interface Builder extends OFBsnHeader.Builder {
40 - OFBsnBwClearDataReply build();
41 - OFVersion getVersion();
42 - OFType getType();
43 - long getXid();
44 - Builder setXid(long xid);
45 - long getExperimenter();
46 - long getSubtype();
47 - long getStatus();
48 - Builder setStatus(long status);
49 - }
50 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import org.jboss.netty.buffer.ChannelBuffer;
27 -
28 -public interface OFBsnBwClearDataRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnBwClearDataReply> {
29 - OFVersion getVersion();
30 - OFType getType();
31 - long getXid();
32 - long getExperimenter();
33 - long getSubtype();
34 -
35 - void writeTo(ChannelBuffer channelBuffer);
36 -
37 - Builder createBuilder();
38 - public interface Builder extends OFBsnHeader.Builder {
39 - OFBsnBwClearDataRequest build();
40 - OFVersion getVersion();
41 - OFType getType();
42 - long getXid();
43 - Builder setXid(long xid);
44 - long getExperimenter();
45 - long getSubtype();
46 - }
47 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import org.jboss.netty.buffer.ChannelBuffer;
27 -
28 -public interface OFBsnBwEnableGetReply extends OFObject, OFBsnHeader {
29 - OFVersion getVersion();
30 - OFType getType();
31 - long getXid();
32 - long getExperimenter();
33 - long getSubtype();
34 - long getEnabled();
35 -
36 - void writeTo(ChannelBuffer channelBuffer);
37 -
38 - Builder createBuilder();
39 - public interface Builder extends OFBsnHeader.Builder {
40 - OFBsnBwEnableGetReply build();
41 - OFVersion getVersion();
42 - OFType getType();
43 - long getXid();
44 - Builder setXid(long xid);
45 - long getExperimenter();
46 - long getSubtype();
47 - long getEnabled();
48 - Builder setEnabled(long enabled);
49 - }
50 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import org.jboss.netty.buffer.ChannelBuffer;
27 -
28 -public interface OFBsnBwEnableGetRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnBwEnableGetReply> {
29 - OFVersion getVersion();
30 - OFType getType();
31 - long getXid();
32 - long getExperimenter();
33 - long getSubtype();
34 -
35 - void writeTo(ChannelBuffer channelBuffer);
36 -
37 - Builder createBuilder();
38 - public interface Builder extends OFBsnHeader.Builder {
39 - OFBsnBwEnableGetRequest build();
40 - OFVersion getVersion();
41 - OFType getType();
42 - long getXid();
43 - Builder setXid(long xid);
44 - long getExperimenter();
45 - long getSubtype();
46 - }
47 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import java.util.Set;
27 -import org.jboss.netty.buffer.ChannelBuffer;
28 -
29 -public interface OFBsnBwEnableSetReply extends OFObject, OFBsnHeader {
30 - OFVersion getVersion();
31 - OFType getType();
32 - long getXid();
33 - long getExperimenter();
34 - long getSubtype();
35 - long getEnable();
36 - long getStatus();
37 -
38 - void writeTo(ChannelBuffer channelBuffer);
39 -
40 - Builder createBuilder();
41 - public interface Builder extends OFBsnHeader.Builder {
42 - OFBsnBwEnableSetReply build();
43 - OFVersion getVersion();
44 - OFType getType();
45 - long getXid();
46 - Builder setXid(long xid);
47 - long getExperimenter();
48 - long getSubtype();
49 - long getEnable();
50 - Builder setEnable(long enable);
51 - long getStatus();
52 - Builder setStatus(long status);
53 - }
54 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import java.util.Set;
27 -import org.jboss.netty.buffer.ChannelBuffer;
28 -
29 -public interface OFBsnBwEnableSetRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnBwEnableSetReply> {
30 - OFVersion getVersion();
31 - OFType getType();
32 - long getXid();
33 - long getExperimenter();
34 - long getSubtype();
35 - long getEnable();
36 -
37 - void writeTo(ChannelBuffer channelBuffer);
38 -
39 - Builder createBuilder();
40 - public interface Builder extends OFBsnHeader.Builder {
41 - OFBsnBwEnableSetRequest build();
42 - OFVersion getVersion();
43 - OFType getType();
44 - long getXid();
45 - Builder setXid(long xid);
46 - long getExperimenter();
47 - long getSubtype();
48 - long getEnable();
49 - Builder setEnable(long enable);
50 - }
51 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template of_interface.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -import org.jboss.netty.buffer.ChannelBuffer;
27 -
28 -public interface OFBsnControllerConnection extends OFObject {
29 - OFBsnControllerConnectionState getState();
30 - OFAuxId getAuxiliaryId();
31 - OFControllerRole getRole();
32 - String getUri();
33 - OFVersion getVersion();
34 -
35 - void writeTo(ChannelBuffer channelBuffer);
36 -
37 - Builder createBuilder();
38 - public interface Builder {
39 - OFBsnControllerConnection build();
40 - OFBsnControllerConnectionState getState();
41 - Builder setState(OFBsnControllerConnectionState state);
42 - OFAuxId getAuxiliaryId();
43 - Builder setAuxiliaryId(OFAuxId auxiliaryId);
44 - OFControllerRole getRole();
45 - Builder setRole(OFControllerRole role);
46 - String getUri();
47 - Builder setUri(String uri);
48 - OFVersion getVersion();
49 - }
50 -}
1 -// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 -// Copyright (c) 2011, 2012 Open Networking Foundation
3 -// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 -// This library was generated by the LoxiGen Compiler.
5 -// See the file LICENSE.txt which should have been included in the source distribution
6 -
7 -// Automatically generated by LOXI from template const.java
8 -// Do not modify
9 -
10 -package org.projectfloodlight.openflow.protocol;
11 -
12 -import org.projectfloodlight.openflow.protocol.*;
13 -import org.projectfloodlight.openflow.protocol.action.*;
14 -import org.projectfloodlight.openflow.protocol.actionid.*;
15 -import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 -import org.projectfloodlight.openflow.protocol.errormsg.*;
17 -import org.projectfloodlight.openflow.protocol.meterband.*;
18 -import org.projectfloodlight.openflow.protocol.instruction.*;
19 -import org.projectfloodlight.openflow.protocol.instructionid.*;
20 -import org.projectfloodlight.openflow.protocol.match.*;
21 -import org.projectfloodlight.openflow.protocol.oxm.*;
22 -import org.projectfloodlight.openflow.protocol.queueprop.*;
23 -import org.projectfloodlight.openflow.types.*;
24 -import org.projectfloodlight.openflow.util.*;
25 -import org.projectfloodlight.openflow.exceptions.*;
26 -
27 -public enum OFBsnControllerConnectionState {
28 - BSN_CONTROLLER_CONNECTION_STATE_DISCONNECTED,
29 - BSN_CONTROLLER_CONNECTION_STATE_CONNECTED;
30 -}