Showing
4 changed files
with
12 additions
and
39 deletions
1 | package org.onlab.onos.net; | 1 | package org.onlab.onos.net; |
2 | 2 | ||
3 | -import java.util.Set; | ||
4 | - | ||
5 | /** | 3 | /** |
6 | * Abstraction of a network port. | 4 | * Abstraction of a network port. |
7 | */ | 5 | */ |
8 | public interface Port { | 6 | public interface Port { |
9 | 7 | ||
10 | /** | 8 | /** |
11 | - * Port state. | ||
12 | - */ | ||
13 | - enum State { | ||
14 | - UP, DOWN, BLOCKED, UNKNOWN | ||
15 | - } | ||
16 | - | ||
17 | - /** | ||
18 | * Returns the port number. | 9 | * Returns the port number. |
19 | * | 10 | * |
20 | * @return port number | 11 | * @return port number |
... | @@ -22,13 +13,6 @@ public interface Port { | ... | @@ -22,13 +13,6 @@ public interface Port { |
22 | PortNumber number(); | 13 | PortNumber number(); |
23 | 14 | ||
24 | /** | 15 | /** |
25 | - * Returns the port state(s). | ||
26 | - * | ||
27 | - * @return port state set | ||
28 | - */ | ||
29 | - Set<State> state(); | ||
30 | - | ||
31 | - /** | ||
32 | * Indicates whether or not the port is currently up and active. | 16 | * Indicates whether or not the port is currently up and active. |
33 | * | 17 | * |
34 | * @return true if the port is operational | 18 | * @return true if the port is operational |
... | @@ -36,13 +20,6 @@ public interface Port { | ... | @@ -36,13 +20,6 @@ public interface Port { |
36 | boolean isEnabled(); | 20 | boolean isEnabled(); |
37 | 21 | ||
38 | /** | 22 | /** |
39 | - * Indicates whether or not the port is administratively blocked. | ||
40 | - * | ||
41 | - * @return true if the port is blocked | ||
42 | - */ | ||
43 | - boolean isBlocked(); | ||
44 | - | ||
45 | - /** | ||
46 | * Returns the identifier of the network element to which this port belongs. | 23 | * Returns the identifier of the network element to which this port belongs. |
47 | * | 24 | * |
48 | * @return parent network element | 25 | * @return parent network element | ... | ... |
1 | package org.onlab.onos.net.device; | 1 | package org.onlab.onos.net.device; |
2 | 2 | ||
3 | -import com.google.common.collect.ImmutableSet; | ||
4 | -import org.onlab.onos.net.Port; | ||
5 | import org.onlab.onos.net.PortNumber; | 3 | import org.onlab.onos.net.PortNumber; |
6 | 4 | ||
7 | -import java.util.Set; | ||
8 | - | ||
9 | /** | 5 | /** |
10 | * Default implementation of immutable port description. | 6 | * Default implementation of immutable port description. |
11 | */ | 7 | */ |
12 | public class DefaultPortDescription implements PortDescription { | 8 | public class DefaultPortDescription implements PortDescription { |
13 | 9 | ||
14 | private final PortNumber number; | 10 | private final PortNumber number; |
15 | - private final Set<Port.State> state; | 11 | + private final boolean isEnabled; |
16 | 12 | ||
17 | - public DefaultPortDescription(PortNumber number, Set<Port.State> state) { | 13 | + public DefaultPortDescription(PortNumber number, boolean isEnabled) { |
18 | this.number = number; | 14 | this.number = number; |
19 | - this.state = ImmutableSet.copyOf(state); | 15 | + this.isEnabled = isEnabled; |
20 | } | 16 | } |
21 | 17 | ||
22 | @Override | 18 | @Override |
... | @@ -25,8 +21,8 @@ public class DefaultPortDescription implements PortDescription { | ... | @@ -25,8 +21,8 @@ public class DefaultPortDescription implements PortDescription { |
25 | } | 21 | } |
26 | 22 | ||
27 | @Override | 23 | @Override |
28 | - public Set<Port.State> portState() { | 24 | + public boolean isEnabled() { |
29 | - return state; | 25 | + return isEnabled; |
30 | } | 26 | } |
31 | 27 | ||
32 | } | 28 | } | ... | ... |
1 | package org.onlab.onos.net.device; | 1 | package org.onlab.onos.net.device; |
2 | 2 | ||
3 | -import org.onlab.onos.net.Port; | ||
4 | import org.onlab.onos.net.PortNumber; | 3 | import org.onlab.onos.net.PortNumber; |
5 | 4 | ||
6 | -import java.util.Set; | ||
7 | - | ||
8 | /** | 5 | /** |
9 | * Information about a port. | 6 | * Information about a port. |
10 | */ | 7 | */ |
... | @@ -20,10 +17,10 @@ public interface PortDescription { | ... | @@ -20,10 +17,10 @@ public interface PortDescription { |
20 | PortNumber portNumber(); | 17 | PortNumber portNumber(); |
21 | 18 | ||
22 | /** | 19 | /** |
23 | - * Returns the port state set. | 20 | + * Indicates whether or not the port is up and active. |
24 | * | 21 | * |
25 | - * @return set of port states | 22 | + * @return true if the port is active and has carrier signal |
26 | */ | 23 | */ |
27 | - Set<Port.State> portState(); | 24 | + boolean isEnabled(); |
28 | 25 | ||
29 | } | 26 | } | ... | ... |
providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
... | @@ -44,6 +44,8 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -44,6 +44,8 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
44 | 44 | ||
45 | private DeviceProviderService providerService; | 45 | private DeviceProviderService providerService; |
46 | 46 | ||
47 | + private OpenFlowSwitchListener listener = new InternalDeviceProvider(); | ||
48 | + | ||
47 | /** | 49 | /** |
48 | * Creates an OpenFlow device provider. | 50 | * Creates an OpenFlow device provider. |
49 | */ | 51 | */ |
... | @@ -54,13 +56,14 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -54,13 +56,14 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
54 | @Activate | 56 | @Activate |
55 | public void activate() { | 57 | public void activate() { |
56 | providerService = providerRegistry.register(this); | 58 | providerService = providerRegistry.register(this); |
57 | - controller.addListener(new InternalDeviceProvider()); | 59 | + controller.addListener(listener); |
58 | log.info("Started"); | 60 | log.info("Started"); |
59 | } | 61 | } |
60 | 62 | ||
61 | @Deactivate | 63 | @Deactivate |
62 | public void deactivate() { | 64 | public void deactivate() { |
63 | providerRegistry.unregister(this); | 65 | providerRegistry.unregister(this); |
66 | + controller.removeListener(listener); | ||
64 | providerService = null; | 67 | providerService = null; |
65 | log.info("Stopped"); | 68 | log.info("Stopped"); |
66 | } | 69 | } | ... | ... |
-
Please register or login to post a comment