building flowrules
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowEntry.java b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowEntry.java
deleted file mode 100644
index 295517b..0000000
--- a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowEntry.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.onlab.onos.net.flow;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import org.onlab.onos.net.DeviceId;
-
-public class DefaultFlowEntry extends DefaultFlowRule implements FlowEntry {
-
- private final int priority;
- private final long created;
- private final FlowId id;
-
- public DefaultFlowEntry(DefaultFlowEntry entry) {
- super(entry.deviceId(), entry.selector(), entry.treatment());
- this.priority = entry.priority;
- this.created = entry.created;
- this.id = entry.id;
- }
-
- public DefaultFlowEntry(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority) {
- super(deviceId, selector, treatment);
- this.priority = priority;
- this.created = System.currentTimeMillis();
- this.id = FlowId.valueOf(this.hashCode());
- }
-
- @Override
- public FlowId id() {
- return null;
- }
-
- @Override
- public int priority() {
- return priority;
- }
-
- @Override
- public long lifeMillis() {
- return (created - System.currentTimeMillis());
- }
-
- @Override
- public long idleMillis() {
- return 0;
- }
-
- @Override
- public long packets() {
- return 0;
- }
-
- @Override
- public long bytes() {
- return 0;
- }
-
- @Override
- /*
- * currently uses the parts that definitely have a defined hashcode...
- *
- * (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- final int prime = 31;
- int result = prime * this.deviceId().hashCode();
- result = prime * result + this.priority;
- result = prime * result + this.selector().hashCode();
- result = prime * result + this.treatment().hashCode();
- return result;
- }
-
- @Override
- /*
- * The priority and statistics can change on a given treatment and selector
- *
- * (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj instanceof DefaultFlowEntry) {
- DefaultFlowEntry that = (DefaultFlowEntry) obj;
- if (!this.deviceId().equals(that.deviceId())) {
- return false;
- }
- if (!(this.priority == that.priority)) {
- return false;
- }
- return super.equals(obj);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("id", id)
- .add("deviceId", deviceId())
- .add("priority", priority)
- .add("selector", selector())
- .add("treatment", treatment())
- .toString();
- }
-
-}
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
index d20e79e..564416c 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
@@ -1,24 +1,57 @@
package org.onlab.onos.net.flow;
+import static com.google.common.base.MoreObjects.toStringHelper;
+
import org.onlab.onos.net.DeviceId;
public class DefaultFlowRule implements FlowRule {
+ private final DeviceId deviceId;
+ private final int priority;
private final TrafficSelector selector;
private final TrafficTreatment treatment;
- private final DeviceId deviceId;
+ private final FlowId id;
+ private final long created;
+ private long life;
+ private long idle;
+ private long packets;
+ private long bytes;
+
public DefaultFlowRule(DeviceId deviceId,
- TrafficSelector selector, TrafficTreatment treatment) {
- this.treatment = treatment;
- this.selector = selector;
+ TrafficSelector selector, TrafficTreatment treatment, int priority) {
this.deviceId = deviceId;
+ this.priority = priority;
+ this.selector = selector;
+ this.treatment = treatment;
+ this.life = 0;
+ this.idle = 0;
+ this.packets = 0;
+ this.bytes = 0;
+ this.id = FlowId.valueOf(this.hashCode());
+ this.created = System.currentTimeMillis();
+ }
+
+ // TODO: Decide whether to take the flowId from the underlying flowentry.
+ public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
+ TrafficTreatment treatment, int priority,
+ long life, long idle, long packets, long bytes) {
+ this(deviceId, selector, treatment, priority);
+ this.life = life;
+ this.idle = idle;
+ this.packets = packets;
+ this.bytes = bytes;
+ }
+
+
+ @Override
+ public FlowId id() {
+ return id;
}
@Override
public int priority() {
- // is this supposed to be 0?
- return 0;
+ return priority;
}
@Override
@@ -37,6 +70,32 @@
}
@Override
+ public long lifeMillis() {
+ return life;
+ }
+
+ @Override
+ public long idleMillis() {
+ return idle;
+ }
+
+ @Override
+ public long packets() {
+ return packets;
+ }
+
+ @Override
+ public long bytes() {
+ return bytes;
+ }
+
+ @Override
+ /*
+ * The priority and statistics can change on a given treatment and selector
+ *
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
public int hashCode() {
final int prime = 31;
int result = prime * this.deviceId().hashCode();
@@ -69,5 +128,16 @@
return false;
}
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("id", id)
+ .add("deviceId", deviceId)
+ .add("priority", priority)
+ .add("selector", selector)
+ .add("treatment", treatment)
+ .add("created", created)
+ .toString();
+ }
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/FlowEntry.java b/core/api/src/main/java/org/onlab/onos/net/flow/FlowEntry.java
deleted file mode 100644
index 7fee1c1..0000000
--- a/core/api/src/main/java/org/onlab/onos/net/flow/FlowEntry.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.onlab.onos.net.flow;
-
-/**
- * Represents a flow rule and its associated accumulated metrics.
- */
-public interface FlowEntry extends FlowRule {
-
- /**
- * Returns the ID of this flow.
- *
- * @return the flow ID
- */
- FlowId id();
-
- /**
- * Returns the number of milliseconds this flow rule has been applied.
- *
- * @return number of millis
- */
- long lifeMillis();
-
- /**
- * Returns the number of milliseconds this flow rule has been idle.
- *
- * @return number of millis
- */
- long idleMillis();
-
- /**
- * Returns the number of packets this flow rule has matched.
- *
- * @return number of packets
- */
- long packets();
-
- /**
- * Returns the number of bytes this flow rule has matched.
- *
- * @return number of bytes
- */
- long bytes();
-
-}
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
index 5f44630..f2bc1a0 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
@@ -9,6 +9,12 @@
public interface FlowRule {
//TODO: build cookie value
+ /**
+ * Returns the ID of this flow.
+ *
+ * @return the flow ID
+ */
+ FlowId id();
/**
* Returns the flow rule priority given in natural order; higher numbers
@@ -40,4 +46,32 @@
*/
TrafficTreatment treatment();
+ /**
+ * Returns the number of milliseconds this flow rule has been applied.
+ *
+ * @return number of millis
+ */
+ long lifeMillis();
+
+ /**
+ * Returns the number of milliseconds this flow rule has been idle.
+ *
+ * @return number of millis
+ */
+ long idleMillis();
+
+ /**
+ * Returns the number of packets this flow rule has matched.
+ *
+ * @return number of packets
+ */
+ long packets();
+
+ /**
+ * Returns the number of bytes this flow rule has matched.
+ *
+ * @return number of bytes
+ */
+ long bytes();
+
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProvider.java b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProvider.java
index 184479b..0277695 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProvider.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProvider.java
@@ -25,5 +25,4 @@
*/
void removeFlowRule(FlowRule... flowRules);
-
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleService.java b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleService.java
index ba75ae9..d2b9432 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleService.java
@@ -21,7 +21,7 @@
* @param deviceId device identifier
* @return collection of flow rules
*/
- Iterable<FlowEntry> getFlowEntries(DeviceId deviceId);
+ Iterable<FlowRule> getFlowEntries(DeviceId deviceId);
// TODO: add createFlowRule factory method and execute operations method
@@ -34,7 +34,7 @@
* throws SomeKindOfException that indicates which ones were applied and
* which ones failed
*/
- List<FlowEntry> applyFlowRules(FlowRule... flowRules);
+ List<FlowRule> applyFlowRules(FlowRule... flowRules);
/**
* Removes the specified flow rules from their respective devices. If the
diff --git a/core/api/src/main/java/org/onlab/onos/net/provider/AbstractProviderRegistry.java b/core/api/src/main/java/org/onlab/onos/net/provider/AbstractProviderRegistry.java
index f8cdb6b..6cf91a6 100644
--- a/core/api/src/main/java/org/onlab/onos/net/provider/AbstractProviderRegistry.java
+++ b/core/api/src/main/java/org/onlab/onos/net/provider/AbstractProviderRegistry.java
@@ -1,6 +1,7 @@
package org.onlab.onos.net.provider;
import com.google.common.collect.ImmutableSet;
+import org.onlab.onos.net.DeviceId;
import java.util.HashMap;
import java.util.Map;
@@ -20,6 +21,7 @@
private final Map<ProviderId, P> providers = new HashMap<>();
private final Map<ProviderId, S> services = new HashMap<>();
+ private final Map<String, P> providersByScheme = new HashMap<>();
/**
* Creates a new provider service bound to the specified provider.
@@ -65,4 +67,14 @@
return providers.get(providerId);
}
+ /**
+ * Returns the provider for the specified device ID based on URI scheme.
+ *
+ * @param deviceId device identifier
+ * @return provider bound to the URI scheme
+ */
+ protected synchronized P getProvider(DeviceId deviceId) {
+ return providersByScheme.get(deviceId.uri().getScheme());
+ }
+
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/provider/ProviderId.java b/core/api/src/main/java/org/onlab/onos/net/provider/ProviderId.java
index a945354..e9af0eb 100644
--- a/core/api/src/main/java/org/onlab/onos/net/provider/ProviderId.java
+++ b/core/api/src/main/java/org/onlab/onos/net/provider/ProviderId.java
@@ -9,6 +9,7 @@
*/
public class ProviderId {
+ private final String scheme;
private final String id;
/**
@@ -16,15 +17,26 @@
* The providers are expected to follow the reverse DNS convention, e.g.
* {@code org.onlab.onos.provider.of.device}
*
- * @param id string identifier
+ * @param scheme device URI scheme to which this provider is bound, e.g. "of", "snmp"
+ * @param id string identifier
*/
- public ProviderId(String id) {
+ public ProviderId(String scheme, String id) {
+ this.scheme = scheme;
this.id = id;
}
+ /**
+ * Returns the device URI scheme to which this provider is bound.
+ *
+ * @return device URI scheme
+ */
+ public String scheme() {
+ return scheme;
+ }
+
@Override
public int hashCode() {
- return Objects.hash(id);
+ return Objects.hash(scheme, id);
}
@Override
@@ -36,12 +48,13 @@
return false;
}
final ProviderId other = (ProviderId) obj;
- return Objects.equals(this.id, other.id);
+ return Objects.equals(this.scheme, other.scheme) &&
+ Objects.equals(this.id, other.id);
}
@Override
public String toString() {
- return toStringHelper(this).add("id", id).toString();
+ return toStringHelper(this).add("scheme", scheme).add("id", id).toString();
}
}
diff --git a/core/api/src/test/java/org/onlab/onos/net/DefaultDeviceTest.java b/core/api/src/test/java/org/onlab/onos/net/DefaultDeviceTest.java
index c37a15c..ea1c8fd 100644
--- a/core/api/src/test/java/org/onlab/onos/net/DefaultDeviceTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/DefaultDeviceTest.java
@@ -13,7 +13,7 @@
*/
public class DefaultDeviceTest {
- private static final ProviderId PID = new ProviderId("foo");
+ private static final ProviderId PID = new ProviderId("of", "foo");
private static final DeviceId DID1 = deviceId("of:foo");
private static final DeviceId DID2 = deviceId("of:bar");
private static final String MFR = "whitebox";
diff --git a/core/api/src/test/java/org/onlab/onos/net/DefaultEdgeLinkTest.java b/core/api/src/test/java/org/onlab/onos/net/DefaultEdgeLinkTest.java
index a19f969..b3891f1 100644
--- a/core/api/src/test/java/org/onlab/onos/net/DefaultEdgeLinkTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/DefaultEdgeLinkTest.java
@@ -15,7 +15,7 @@
*/
public class DefaultEdgeLinkTest {
- private static final ProviderId PID = new ProviderId("foo");
+ private static final ProviderId PID = new ProviderId("of", "foo");
private static final DeviceId DID1 = deviceId("of:foo");
private static final HostId HID1 = hostId("nic:foobar");
private static final HostId HID2 = hostId("nic:barfoo");
diff --git a/core/api/src/test/java/org/onlab/onos/net/DefaultLinkTest.java b/core/api/src/test/java/org/onlab/onos/net/DefaultLinkTest.java
index ec8511e..a62c822 100644
--- a/core/api/src/test/java/org/onlab/onos/net/DefaultLinkTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/DefaultLinkTest.java
@@ -15,7 +15,7 @@
*/
public class DefaultLinkTest {
- private static final ProviderId PID = new ProviderId("foo");
+ private static final ProviderId PID = new ProviderId("of", "foo");
private static final DeviceId DID1 = deviceId("of:foo");
private static final DeviceId DID2 = deviceId("of:bar");
private static final PortNumber P1 = portNumber(1);
diff --git a/core/api/src/test/java/org/onlab/onos/net/DefaultPortTest.java b/core/api/src/test/java/org/onlab/onos/net/DefaultPortTest.java
index e9d3da6..1069fd1 100644
--- a/core/api/src/test/java/org/onlab/onos/net/DefaultPortTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/DefaultPortTest.java
@@ -14,7 +14,7 @@
*/
public class DefaultPortTest {
- private static final ProviderId PID = new ProviderId("foo");
+ private static final ProviderId PID = new ProviderId("of", "foo");
private static final DeviceId DID1 = deviceId("of:foo");
private static final DeviceId DID2 = deviceId("of:bar");
private static final PortNumber P1 = portNumber(1);
diff --git a/core/api/src/test/java/org/onlab/onos/net/TestDeviceParams.java b/core/api/src/test/java/org/onlab/onos/net/TestDeviceParams.java
index afaf23e..7471a2d 100644
--- a/core/api/src/test/java/org/onlab/onos/net/TestDeviceParams.java
+++ b/core/api/src/test/java/org/onlab/onos/net/TestDeviceParams.java
@@ -17,7 +17,7 @@
*/
public abstract class TestDeviceParams {
- protected static final ProviderId PID = new ProviderId("foo");
+ protected static final ProviderId PID = new ProviderId("of", "foo");
protected static final DeviceId DID1 = deviceId("of:foo");
protected static final DeviceId DID2 = deviceId("of:bar");
protected static final MacAddress MAC1 = MacAddress.valueOf("00:11:00:00:00:01");
diff --git a/core/api/src/test/java/org/onlab/onos/net/device/DeviceEventTest.java b/core/api/src/test/java/org/onlab/onos/net/device/DeviceEventTest.java
index 7175308..df19365 100644
--- a/core/api/src/test/java/org/onlab/onos/net/device/DeviceEventTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/device/DeviceEventTest.java
@@ -18,7 +18,7 @@
public class DeviceEventTest extends AbstractEventTest {
private Device createDevice() {
- return new DefaultDevice(new ProviderId("foo"), deviceId("of:foo"),
+ return new DefaultDevice(new ProviderId("of", "foo"), deviceId("of:foo"),
Device.Type.SWITCH, "box", "hw", "sw", "sn");
}
diff --git a/core/api/src/test/java/org/onlab/onos/net/host/HostEventTest.java b/core/api/src/test/java/org/onlab/onos/net/host/HostEventTest.java
index a0d6848..561b041 100644
--- a/core/api/src/test/java/org/onlab/onos/net/host/HostEventTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/host/HostEventTest.java
@@ -34,7 +34,7 @@
HostId hid = HostId.hostId(mac, vlan);
return new DefaultHost(
- new ProviderId("foo"), hid, mac, vlan, loc, ipset);
+ new ProviderId("of", "foo"), hid, mac, vlan, loc, ipset);
}
@Override
diff --git a/core/api/src/test/java/org/onlab/onos/net/link/LinkEventTest.java b/core/api/src/test/java/org/onlab/onos/net/link/LinkEventTest.java
index dae9f85..aa95a42 100644
--- a/core/api/src/test/java/org/onlab/onos/net/link/LinkEventTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/link/LinkEventTest.java
@@ -16,7 +16,7 @@
public class LinkEventTest extends AbstractEventTest {
private Link createLink() {
- return new DefaultLink(new ProviderId("foo"),
+ return new DefaultLink(new ProviderId("of", "foo"),
new ConnectPoint(deviceId("of:foo"), portNumber(1)),
new ConnectPoint(deviceId("of:bar"), portNumber(2)),
Link.Type.INDIRECT);
diff --git a/core/api/src/test/java/org/onlab/onos/net/provider/AbstractProviderRegistryTest.java b/core/api/src/test/java/org/onlab/onos/net/provider/AbstractProviderRegistryTest.java
index abbe5be..37bee71 100644
--- a/core/api/src/test/java/org/onlab/onos/net/provider/AbstractProviderRegistryTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/provider/AbstractProviderRegistryTest.java
@@ -28,14 +28,14 @@
TestProviderRegistry registry = new TestProviderRegistry();
assertEquals("incorrect provider count", 0, registry.getProviders().size());
- ProviderId fooId = new ProviderId("foo");
+ ProviderId fooId = new ProviderId("of", "foo");
TestProvider pFoo = new TestProvider(fooId);
TestProviderService psFoo = registry.register(pFoo);
assertEquals("incorrect provider count", 1, registry.getProviders().size());
assertThat("provider not found", registry.getProviders().contains(fooId));
assertEquals("incorrect provider", psFoo.provider(), pFoo);
- ProviderId barId = new ProviderId("bar");
+ ProviderId barId = new ProviderId("of", "bar");
TestProvider pBar = new TestProvider(barId);
TestProviderService psBar = registry.register(pBar);
assertEquals("incorrect provider count", 2, registry.getProviders().size());
@@ -52,7 +52,7 @@
@Test(expected = IllegalStateException.class)
public void duplicateRegistration() {
TestProviderRegistry registry = new TestProviderRegistry();
- TestProvider pFoo = new TestProvider(new ProviderId("foo"));
+ TestProvider pFoo = new TestProvider(new ProviderId("of", "foo"));
registry.register(pFoo);
registry.register(pFoo);
}
@@ -60,13 +60,13 @@
@Test
public void voidUnregistration() {
TestProviderRegistry registry = new TestProviderRegistry();
- registry.unregister(new TestProvider(new ProviderId("foo")));
+ registry.unregister(new TestProvider(new ProviderId("of", "foo")));
}
@Test(expected = IllegalStateException.class)
public void unregistration() {
TestProviderRegistry registry = new TestProviderRegistry();
- TestProvider pFoo = new TestProvider(new ProviderId("foo"));
+ TestProvider pFoo = new TestProvider(new ProviderId("of", "foo"));
TestProviderService psFoo = registry.register(pFoo);
registry.unregister(pFoo);
psFoo.checkValidity();
diff --git a/core/api/src/test/java/org/onlab/onos/net/provider/AbstractProviderTest.java b/core/api/src/test/java/org/onlab/onos/net/provider/AbstractProviderTest.java
index 745aebc..c2e5cfc 100644
--- a/core/api/src/test/java/org/onlab/onos/net/provider/AbstractProviderTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/provider/AbstractProviderTest.java
@@ -11,7 +11,7 @@
@Test
public void basics() {
- ProviderId id = new ProviderId("foo.bar");
+ ProviderId id = new ProviderId("of", "foo.bar");
TestProvider provider = new TestProvider(id);
assertEquals("incorrect id", id, provider.id());
}
diff --git a/core/api/src/test/java/org/onlab/onos/net/provider/ProviderIdTest.java b/core/api/src/test/java/org/onlab/onos/net/provider/ProviderIdTest.java
index 1c05507..1501eb9 100644
--- a/core/api/src/test/java/org/onlab/onos/net/provider/ProviderIdTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/provider/ProviderIdTest.java
@@ -11,8 +11,9 @@
@Test
public void basics() {
new EqualsTester()
- .addEqualityGroup(new ProviderId("foo"), new ProviderId("foo"))
- .addEqualityGroup(new ProviderId("bar"))
+ .addEqualityGroup(new ProviderId("of", "foo"), new ProviderId("of", "foo"))
+ .addEqualityGroup(new ProviderId("snmp", "foo"), new ProviderId("snmp", "foo"))
+ .addEqualityGroup(new ProviderId("of", "bar"))
.testEquals();
}
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManager.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManager.java
index b7c5b15..7003271 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManager.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManager.java
@@ -17,7 +17,6 @@
import org.onlab.onos.net.Device;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.DeviceService;
-import org.onlab.onos.net.flow.FlowEntry;
import org.onlab.onos.net.flow.FlowRule;
import org.onlab.onos.net.flow.FlowRuleEvent;
import org.onlab.onos.net.flow.FlowRuleListener;
@@ -62,13 +61,13 @@
}
@Override
- public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) {
+ public Iterable<FlowRule> getFlowEntries(DeviceId deviceId) {
return store.getFlowEntries(deviceId);
}
@Override
- public List<FlowEntry> applyFlowRules(FlowRule... flowRules) {
- List<FlowEntry> entries = new ArrayList<FlowEntry>();
+ public List<FlowRule> applyFlowRules(FlowRule... flowRules) {
+ List<FlowRule> entries = new ArrayList<FlowRule>();
for (int i = 0; i < flowRules.length; i++) {
FlowRule f = flowRules[i];
@@ -159,7 +158,7 @@
}
@Override
- public void pushFlowMetrics(Iterable<FlowEntry> flowEntries) {
+ public void pushFlowMetrics(Iterable<FlowRule> flowEntries) {
// TODO Auto-generated method stub
}
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleStore.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleStore.java
index 4f23ff4..dd8dce8 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleStore.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleStore.java
@@ -1,8 +1,7 @@
package org.onlab.onos.net.trivial.flow.impl;
import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.net.flow.DefaultFlowEntry;
-import org.onlab.onos.net.flow.FlowEntry;
+import org.onlab.onos.net.flow.DefaultFlowRule;
import org.onlab.onos.net.flow.FlowRule;
import org.onlab.onos.net.flow.FlowRuleEvent;
@@ -18,7 +17,7 @@
public class SimpleFlowRuleStore {
// store entries as a pile of rules, no info about device tables
- private final Multimap<DeviceId, FlowEntry> flowEntries = HashMultimap.create();
+ private final Multimap<DeviceId, FlowRule> flowEntries = HashMultimap.create();
/**
* Returns the flow entries associated with a device.
@@ -26,19 +25,19 @@
* @param deviceId the device ID
* @return the flow entries
*/
- Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) {
+ Iterable<FlowRule> getFlowEntries(DeviceId deviceId) {
return ImmutableSet.copyOf(flowEntries.get(deviceId));
}
/**
- * Stores a new flow rule, and generates a FlowEntry for it.
+ * Stores a new flow rule, and generates a FlowRule for it.
*
* @param rule the flow rule to add
* @return a flow entry
*/
- FlowEntry storeFlowRule(FlowRule rule) {
+ FlowRule storeFlowRule(FlowRule rule) {
DeviceId did = rule.deviceId();
- FlowEntry entry = new DefaultFlowEntry(did,
+ FlowRule entry = new DefaultFlowRule(did,
rule.selector(), rule.treatment(), rule.priority());
flowEntries.put(did, entry);
return entry;
@@ -53,20 +52,14 @@
FlowRuleEvent addOrUpdateFlowRule(FlowRule rule) {
DeviceId did = rule.deviceId();
- FlowEntry entry = new DefaultFlowEntry(
- did,
- rule.selector(),
- rule.treatment(),
- rule.priority());
-
// check if this new rule is an update to an existing entry
- for (FlowEntry fe : flowEntries.get(did)) {
- if (entry.equals(fe)) {
- // TODO update the stats on this flowEntry?
+ for (FlowRule fe : flowEntries.get(did)) {
+ if (rule.equals(fe)) {
+ // TODO update the stats on this FlowRule?
return null;
}
}
- flowEntries.put(did, entry);
+ flowEntries.put(did, rule);
return new FlowRuleEvent(RULE_ADDED, rule);
}
@@ -77,10 +70,8 @@
*/
FlowRuleEvent removeFlowRule(FlowRule rule) {
- FlowEntry rem = new DefaultFlowEntry(rule.deviceId(),
- rule.selector(), rule.treatment(), rule.priority());
synchronized (this) {
- if (flowEntries.remove(rem.deviceId(), rem)) {
+ if (flowEntries.remove(rule.deviceId(), rule)) {
return new FlowRuleEvent(RULE_REMOVED, rule);
} else {
return null;
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopology.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopology.java
index 7213497..efbe6af 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopology.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopology.java
@@ -45,7 +45,7 @@
private static final TarjanGraphSearch<TopologyVertex, TopologyEdge> TARJAN =
new TarjanGraphSearch<>();
- private static final ProviderId PID = new ProviderId("org.onlab.onos.net");
+ private static final ProviderId PID = new ProviderId("core", "org.onlab.onos.net");
private final long time;
private final TopologyGraph graph;
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopologyProvider.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopologyProvider.java
index b6efba9..6e6a917 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopologyProvider.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopologyProvider.java
@@ -74,7 +74,7 @@
* Creates a provider with the supplier identifier.
*/
public DefaultTopologyProvider() {
- super(new ProviderId("org.onlab.onos.provider.topology"));
+ super(new ProviderId("core", "org.onlab.onos.provider.topology"));
}
@Activate
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimplePathManager.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimplePathManager.java
index f495057..5fe7793 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimplePathManager.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimplePathManager.java
@@ -45,7 +45,7 @@
private static final String ELEMENT_ID_NULL = "Element ID cannot be null";
- private static final ProviderId PID = new ProviderId("org.onlab.onos.core");
+ private static final ProviderId PID = new ProviderId("core", "org.onlab.onos.core");
private static final PortNumber P0 = PortNumber.portNumber(0);
private static final EdgeLink NOT_HOST = new NotHost();
diff --git a/core/trivial/src/test/java/org/onlab/onos/net/trivial/device/impl/SimpleDeviceManagerTest.java b/core/trivial/src/test/java/org/onlab/onos/net/trivial/device/impl/SimpleDeviceManagerTest.java
index 4c1aff4..4d531d3 100644
--- a/core/trivial/src/test/java/org/onlab/onos/net/trivial/device/impl/SimpleDeviceManagerTest.java
+++ b/core/trivial/src/test/java/org/onlab/onos/net/trivial/device/impl/SimpleDeviceManagerTest.java
@@ -38,7 +38,7 @@
*/
public class SimpleDeviceManagerTest {
- private static final ProviderId PID = new ProviderId("foo");
+ private static final ProviderId PID = new ProviderId("of", "foo");
private static final DeviceId DID1 = deviceId("of:foo");
private static final DeviceId DID2 = deviceId("of:bar");
private static final String MFR = "whitebox";
diff --git a/core/trivial/src/test/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManagerTest.java b/core/trivial/src/test/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManagerTest.java
index bb0a496..0bee5b3 100644
--- a/core/trivial/src/test/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManagerTest.java
+++ b/core/trivial/src/test/java/org/onlab/onos/net/trivial/flow/impl/SimpleFlowRuleManagerTest.java
@@ -4,6 +4,8 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_ADDED;
+import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_REMOVED;
import java.util.ArrayList;
import java.util.List;
@@ -21,9 +23,7 @@
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.device.DeviceListener;
import org.onlab.onos.net.device.DeviceService;
-import org.onlab.onos.net.flow.DefaultFlowEntry;
import org.onlab.onos.net.flow.DefaultFlowRule;
-import org.onlab.onos.net.flow.FlowEntry;
import org.onlab.onos.net.flow.FlowRule;
import org.onlab.onos.net.flow.FlowRuleEvent;
import org.onlab.onos.net.flow.FlowRuleListener;
@@ -41,14 +41,12 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import static org.onlab.onos.net.flow.FlowRuleEvent.Type.*;
-
/**
* Test codifying the flow rule service & flow rule provider service contracts.
*/
public class SimpleFlowRuleManagerTest {
- private static final ProviderId PID = new ProviderId("foo");
+ private static final ProviderId PID = new ProviderId("of", "foo");
private static final DeviceId DID = DeviceId.deviceId("of:001");
private static final Device DEV = new DefaultDevice(
PID, DID, Type.SWITCH, "", "", "", "");
@@ -81,7 +79,7 @@
public void tearDown() {
registry.unregister(provider);
assertFalse("provider should not be registered",
- registry.getProviders().contains(provider.id()));
+ registry.getProviders().contains(provider.id()));
service.removeListener(listener);
mgr.deactivate();
mgr.eventDispatcher = null;
@@ -91,7 +89,7 @@
private FlowRule flowRule(int tsval, int trval) {
TestSelector ts = new TestSelector(tsval);
TestTreatment tr = new TestTreatment(trval);
- return new DefaultFlowRule(DID, ts, tr);
+ return new DefaultFlowRule(DID, ts, tr, 0);
}
private void addFlowRule(int hval) {
@@ -142,14 +140,14 @@
FlowRule r3 = flowRule(1, 3);
//current FlowRules always return 0. FlowEntries inherit the value
- FlowEntry e1 = new DefaultFlowEntry(DID, ts, r1.treatment(), 0);
- FlowEntry e2 = new DefaultFlowEntry(DID, ts, r2.treatment(), 0);
- FlowEntry e3 = new DefaultFlowEntry(DID, ts, r3.treatment(), 0);
- List<FlowEntry> fel = Lists.newArrayList(e1, e2, e3);
+ FlowRule e1 = new DefaultFlowRule(DID, ts, r1.treatment(), 0);
+ FlowRule e2 = new DefaultFlowRule(DID, ts, r2.treatment(), 0);
+ FlowRule e3 = new DefaultFlowRule(DID, ts, r3.treatment(), 0);
+ List<FlowRule> fel = Lists.newArrayList(e1, e2, e3);
assertTrue("store should be empty",
Sets.newHashSet(service.getFlowEntries(DID)).isEmpty());
- List<FlowEntry> ret = mgr.applyFlowRules(r1, r2, r3);
+ List<FlowRule> ret = mgr.applyFlowRules(r1, r2, r3);
assertEquals("3 rules should exist", 3, flowCount());
assertTrue("3 entries should result", fel.containsAll(ret));
}
@@ -255,17 +253,12 @@
public void removeFlowRule(FlowRule... flowRules) {
}
- @Override
- public Iterable<FlowEntry> getFlowMetrics(DeviceId deviceId) {
- return null;
- }
-
}
private class TestSelector implements TrafficSelector {
//for controlling hashcode uniqueness;
- private int testval;
+ private final int testval;
public TestSelector(int val) {
testval = val;
@@ -293,7 +286,7 @@
private class TestTreatment implements TrafficTreatment {
//for controlling hashcode uniqueness;
- private int testval;
+ private final int testval;
public TestTreatment(int val) {
testval = val;
diff --git a/core/trivial/src/test/java/org/onlab/onos/net/trivial/host/impl/SimpleHostManagerTest.java b/core/trivial/src/test/java/org/onlab/onos/net/trivial/host/impl/SimpleHostManagerTest.java
index b1b825e..67c14b0 100644
--- a/core/trivial/src/test/java/org/onlab/onos/net/trivial/host/impl/SimpleHostManagerTest.java
+++ b/core/trivial/src/test/java/org/onlab/onos/net/trivial/host/impl/SimpleHostManagerTest.java
@@ -42,7 +42,7 @@
*/
public class SimpleHostManagerTest {
- private static final ProviderId PID = new ProviderId("foo");
+ private static final ProviderId PID = new ProviderId("of", "foo");
private static final VlanId VLAN1 = VlanId.vlanId((short) 1);
private static final VlanId VLAN2 = VlanId.vlanId((short) 2);
diff --git a/core/trivial/src/test/java/org/onlab/onos/net/trivial/link/impl/SimpleLinkManagerTest.java b/core/trivial/src/test/java/org/onlab/onos/net/trivial/link/impl/SimpleLinkManagerTest.java
index 3702b0a..93610b5 100644
--- a/core/trivial/src/test/java/org/onlab/onos/net/trivial/link/impl/SimpleLinkManagerTest.java
+++ b/core/trivial/src/test/java/org/onlab/onos/net/trivial/link/impl/SimpleLinkManagerTest.java
@@ -40,7 +40,7 @@
*/
public class SimpleLinkManagerTest {
- private static final ProviderId PID = new ProviderId("foo");
+ private static final ProviderId PID = new ProviderId("of", "foo");
private static final DeviceId DID1 = deviceId("of:foo");
private static final DeviceId DID2 = deviceId("of:bar");
private static final DeviceId DID3 = deviceId("of:goo");
diff --git a/core/trivial/src/test/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopologyTest.java b/core/trivial/src/test/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopologyTest.java
index 2520602..1fe33f6 100644
--- a/core/trivial/src/test/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopologyTest.java
+++ b/core/trivial/src/test/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopologyTest.java
@@ -29,7 +29,7 @@
*/
public class DefaultTopologyTest {
- public static final ProviderId PID = new ProviderId("foo.bar");
+ public static final ProviderId PID = new ProviderId("of", "foo.bar");
public static final DeviceId D1 = deviceId("of:1");
public static final DeviceId D2 = deviceId("of:2");
diff --git a/core/trivial/src/test/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyManagerTest.java b/core/trivial/src/test/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyManagerTest.java
index 1480cec..b0b1eed 100644
--- a/core/trivial/src/test/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyManagerTest.java
+++ b/core/trivial/src/test/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyManagerTest.java
@@ -43,7 +43,7 @@
*/
public class SimpleTopologyManagerTest {
- private static final ProviderId PID = new ProviderId("foo");
+ private static final ProviderId PID = new ProviderId("of", "foo");
private SimpleTopologyManager mgr;