use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class FlowRuleManagerTest method flowMissingRemove.
/*
* Tests whether a rule that was marked for removal but no flowRemoved was received
* is indeed removed at the next stats update.
*/
@Test
public void flowMissingRemove() {
FlowRule f1 = flowRule(1, 1);
FlowRule f2 = flowRule(2, 2);
FlowRule f3 = flowRule(3, 3);
// FlowRule updatedF1 = flowRule(f1, FlowRuleState.ADDED);
// FlowRule updatedF2 = flowRule(f2, FlowRuleState.ADDED);
FlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
mgr.applyFlowRules(f1, f2, f3);
mgr.removeFlowRules(f3);
providerService.pushFlowMetrics(DID, Lists.newArrayList(fe1, fe2));
validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_REMOVE_REQUESTED, RULE_ADDED, RULE_ADDED, RULE_REMOVED);
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class FlowRuleManagerTest method getFlowEntry.
@Test
public void getFlowEntry() {
assertTrue("store should be empty", Sets.newHashSet(service.getFlowEntries(DID)).isEmpty());
FlowRule f1 = addFlowRule(1);
FlowRule f2 = addFlowRule(2);
FlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
assertEquals("2 rules should exist", 2, flowCount());
FlowEntry actual1 = service.getFlowEntry(f1);
FlowEntry actual2 = service.getFlowEntry(f2);
assertEquals(fe1, actual1);
assertEquals(fe2, actual2);
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class FlowRuleManagerTest method getFlowEntries.
@Test
public void getFlowEntries() {
assertTrue("store should be empty", Sets.newHashSet(service.getFlowEntries(DID)).isEmpty());
FlowRule f1 = addFlowRule(1);
FlowRule f2 = addFlowRule(2);
FlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
assertEquals("2 rules should exist", 2, flowCount());
providerService.pushFlowMetrics(DID, ImmutableList.of(fe1, fe2));
validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, RULE_ADDED);
addFlowRule(1);
System.err.println("events :" + listener.events);
assertEquals("should still be 2 rules", 2, flowCount());
providerService.pushFlowMetrics(DID, ImmutableList.of(fe1));
validateEvents(RULE_UPDATED, RULE_UPDATED);
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class FlowStatisticManager method typedFlowEntryLoadByInstInternal.
private List<FlowEntryWithLoad> typedFlowEntryLoadByInstInternal(ConnectPoint cp, Map<FlowRule, FlowEntry> currentMap, Map<FlowRule, FlowEntry> previousMap, boolean isAllInstType, Instruction.Type instType) {
List<FlowEntryWithLoad> fel = new ArrayList<>();
currentMap.values().forEach(fe -> {
if (isAllInstType || fe.treatment().allInstructions().stream().filter(i -> i.type() == instType).findAny().isPresent()) {
long currentBytes = fe.bytes();
long previousBytes = previousMap.getOrDefault(fe, new DefaultFlowEntry(fe)).bytes();
long liveTypePollInterval = getLiveTypePollInterval(fe.liveType());
Load fLoad = new DefaultLoad(currentBytes, previousBytes, liveTypePollInterval);
fel.add(new FlowEntryWithLoad(cp, fe, fLoad));
}
});
return fel;
}
use of org.onosproject.net.flow.DefaultFlowEntry 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