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 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 FlowStatisticManager method toFlowEntryWithLoad.
private List<TypedFlowEntryWithLoad> toFlowEntryWithLoad(List<FlowEntryWithLoad> loadList) {
// convert FlowEntryWithLoad list to TypedFlowEntryWithLoad list
List<TypedFlowEntryWithLoad> tfelList = new ArrayList<>();
loadList.forEach(fel -> {
StoredFlowEntry sfe = fel.storedFlowEntry();
TypedStoredFlowEntry.FlowLiveType liveType = toTypedStoredFlowEntryLiveType(sfe.liveType());
TypedStoredFlowEntry tfe = new DefaultTypedFlowEntry(sfe, liveType);
TypedFlowEntryWithLoad tfel = new TypedFlowEntryWithLoad(fel.connectPoint(), tfe, fel.load());
tfelList.add(tfel);
});
return tfelList;
}
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);
}
}
use of org.onosproject.net.flow.StoredFlowEntry in project onos by opennetworkinglab.
the class SimpleFlowRuleStore method removeFlowRule.
@Override
public FlowRuleEvent removeFlowRule(FlowEntry rule) {
// This is where one could mark a rule as removed and still keep it in the store.
final DeviceId did = rule.deviceId();
List<StoredFlowEntry> entries = getFlowEntries(did, rule.id());
synchronized (entries) {
if (entries.remove(rule)) {
return new FlowRuleEvent(RULE_REMOVED, rule);
}
}
return null;
}
Aggregations