tom

Simplified port state.

package org.onlab.onos.net;
import java.util.Set;
/**
* Abstraction of a network port.
*/
public interface Port {
/**
* Port state.
*/
enum State {
UP, DOWN, BLOCKED, UNKNOWN
}
/**
* Returns the port number.
*
* @return port number
......@@ -22,13 +13,6 @@ public interface Port {
PortNumber number();
/**
* Returns the port state(s).
*
* @return port state set
*/
Set<State> state();
/**
* Indicates whether or not the port is currently up and active.
*
* @return true if the port is operational
......@@ -36,13 +20,6 @@ public interface Port {
boolean isEnabled();
/**
* Indicates whether or not the port is administratively blocked.
*
* @return true if the port is blocked
*/
boolean isBlocked();
/**
* Returns the identifier of the network element to which this port belongs.
*
* @return parent network element
......
package org.onlab.onos.net.device;
import com.google.common.collect.ImmutableSet;
import org.onlab.onos.net.Port;
import org.onlab.onos.net.PortNumber;
import java.util.Set;
/**
* Default implementation of immutable port description.
*/
public class DefaultPortDescription implements PortDescription {
private final PortNumber number;
private final Set<Port.State> state;
private final boolean isEnabled;
public DefaultPortDescription(PortNumber number, Set<Port.State> state) {
public DefaultPortDescription(PortNumber number, boolean isEnabled) {
this.number = number;
this.state = ImmutableSet.copyOf(state);
this.isEnabled = isEnabled;
}
@Override
......@@ -25,8 +21,8 @@ public class DefaultPortDescription implements PortDescription {
}
@Override
public Set<Port.State> portState() {
return state;
public boolean isEnabled() {
return isEnabled;
}
}
......
package org.onlab.onos.net.device;
import org.onlab.onos.net.Port;
import org.onlab.onos.net.PortNumber;
import java.util.Set;
/**
* Information about a port.
*/
......@@ -20,10 +17,10 @@ public interface PortDescription {
PortNumber portNumber();
/**
* Returns the port state set.
* Indicates whether or not the port is up and active.
*
* @return set of port states
* @return true if the port is active and has carrier signal
*/
Set<Port.State> portState();
boolean isEnabled();
}
......
......@@ -44,6 +44,8 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
private DeviceProviderService providerService;
private OpenFlowSwitchListener listener = new InternalDeviceProvider();
/**
* Creates an OpenFlow device provider.
*/
......@@ -54,13 +56,14 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
@Activate
public void activate() {
providerService = providerRegistry.register(this);
controller.addListener(new InternalDeviceProvider());
controller.addListener(listener);
log.info("Started");
}
@Deactivate
public void deactivate() {
providerRegistry.unregister(this);
controller.removeListener(listener);
providerService = null;
log.info("Stopped");
}
......