use of org.onosproject.net.flow.StoredFlowEntry in project onos by opennetworkinglab.
the class SimpleVirtualFlowRuleStore method addOrUpdateFlowRule.
@Override
public FlowRuleEvent addOrUpdateFlowRule(NetworkId networkId, FlowEntry rule) {
// check if this new rule is an update to an existing entry
List<StoredFlowEntry> entries = getFlowEntries(networkId, rule.deviceId(), rule.id());
synchronized (entries) {
for (StoredFlowEntry stored : entries) {
if (stored.equals(rule)) {
synchronized (stored) {
// FIXME modification of "stored" flow entry outside of flow table
stored.setBytes(rule.bytes());
stored.setLife(rule.life());
stored.setPackets(rule.packets());
if (stored.state() == FlowEntry.FlowEntryState.PENDING_ADD) {
stored.setState(FlowEntry.FlowEntryState.ADDED);
// TODO: Do we need to change `rule` state?
return new FlowRuleEvent(FlowRuleEvent.Type.RULE_ADDED, rule);
}
return new FlowRuleEvent(FlowRuleEvent.Type.RULE_UPDATED, rule);
}
}
}
}
// should not reach here
// storeFlowRule was expected to be called
log.error("FlowRule was not found in store {} to update", rule);
return null;
}
use of org.onosproject.net.flow.StoredFlowEntry in project onos by opennetworkinglab.
the class SimpleVirtualFlowRuleStore method storeFlowRuleInternal.
private void storeFlowRuleInternal(NetworkId networkId, FlowRule rule) {
StoredFlowEntry f = new DefaultFlowEntry(rule);
final DeviceId did = f.deviceId();
final FlowId fid = f.id();
List<StoredFlowEntry> existing = getFlowEntries(networkId, did, fid);
synchronized (existing) {
for (StoredFlowEntry fe : existing) {
if (fe.equals(rule)) {
// was already there? ignore
return;
}
}
// new flow rule added
existing.add(f);
}
}
use of org.onosproject.net.flow.StoredFlowEntry in project onos by opennetworkinglab.
the class GetFlowStatisticsCommand method printPortFlowsLoad.
private void printPortFlowsLoad(ConnectPoint cp, List<FlowEntryWithLoad> typedFlowLoad) {
print(" deviceId/Port=%s/%s, %s flows", cp.elementId(), cp.port(), typedFlowLoad.size());
for (FlowEntryWithLoad fel : typedFlowLoad) {
StoredFlowEntry sfe = fel.storedFlowEntry();
print(" flowId=%s, state=%s, liveType=%s, life=%s -> %s", Long.toHexString(sfe.id().value()), sfe.state(), sfe.liveType(), sfe.life(), fel.load().isValid() ? fel.load() : "Load{rate=0, NOT VALID}");
}
}
use of org.onosproject.net.flow.StoredFlowEntry in project onos by opennetworkinglab.
the class FlowEntryWithLoadTest method testConstructionCpFeLoad.
@Test
public void testConstructionCpFeLoad() {
ConnectPoint cp = NetTestTools.connectPoint("id1", 1);
StoredFlowEntry fe = new MockFlowEntry(FlowEntry.FlowLiveType.IMMEDIATE);
Load load = new DefaultLoad();
FlowEntryWithLoad underTest = new FlowEntryWithLoad(cp, fe, load);
assertThat(underTest.connectPoint(), is(cp));
assertThat(underTest.load(), is(load));
assertThat(underTest.storedFlowEntry(), is(fe));
}
use of org.onosproject.net.flow.StoredFlowEntry in project onos by opennetworkinglab.
the class SimpleFlowRuleStore method storeFlowRuleInternal.
private void storeFlowRuleInternal(FlowRule rule) {
StoredFlowEntry f = new DefaultFlowEntry(rule);
final DeviceId did = f.deviceId();
final FlowId fid = f.id();
List<StoredFlowEntry> existing = getFlowEntries(did, fid);
synchronized (existing) {
for (StoredFlowEntry fe : existing) {
if (fe.equals(rule)) {
// was already there? ignore
return;
}
}
// new flow rule added
existing.add(f);
}
}
Aggregations