use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class NullFlowRuleProvider method executeBatch.
@Override
public void executeBatch(FlowRuleBatchOperation batch) {
// TODO: consider checking mastership
Set<FlowEntry> entries = flowTable.getOrDefault(batch.deviceId(), Sets.newConcurrentHashSet());
for (FlowRuleBatchEntry fbe : batch.getOperations()) {
switch(fbe.operator()) {
case ADD:
entries.add(new DefaultFlowEntry(fbe.target()));
break;
case REMOVE:
entries.remove(new DefaultFlowEntry(fbe.target()));
break;
case MODIFY:
FlowEntry entry = new DefaultFlowEntry(fbe.target());
entries.remove(entry);
entries.add(entry);
break;
default:
log.error("Unknown flow operation: {}", fbe);
}
}
flowTable.put(batch.deviceId(), entries);
CompletedBatchOperation op = new CompletedBatchOperation(true, Collections.emptySet(), batch.deviceId());
providerService.batchOperationCompleted(batch.id(), op);
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class VirtualNetworkFlowRuleManagerTest method flowRemoved.
@Test
public void flowRemoved() {
FlowRule f1 = addFlowRule(1);
FlowRule f2 = addFlowRule(2);
StoredFlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
providerService1.pushFlowMetrics(VDID1, ImmutableList.of(fe1, fe2));
vnetFlowRuleService1.removeFlowRules(f1);
// FIXME modification of "stored" flow entry outside of store
fe1.setState(FlowEntry.FlowEntryState.REMOVED);
providerService1.flowRemoved(fe1);
validateEvents(listener1, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, RULE_ADDED, RULE_REMOVE_REQUESTED, RULE_REMOVED);
providerService1.flowRemoved(fe1);
validateEvents(listener1);
FlowRule f3 = flowRule(3, 3);
FlowEntry fe3 = new DefaultFlowEntry(f3);
vnetFlowRuleService1.applyFlowRules(f3);
providerService1.pushFlowMetrics(VDID1, Collections.singletonList(fe3));
validateEvents(listener1, RULE_ADD_REQUESTED, RULE_ADDED, RULE_UPDATED);
providerService1.flowRemoved(fe3);
validateEvents(listener1);
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class VirtualNetworkFlowRuleManagerTest method extraneousFlow.
@Test
public void extraneousFlow() {
FlowRule f1 = flowRule(1, 1);
FlowRule f2 = flowRule(2, 2);
FlowRule f3 = flowRule(3, 3);
vnetFlowRuleService1.applyFlowRules(f1, f2);
FlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
FlowEntry fe3 = new DefaultFlowEntry(f3);
providerService1.pushFlowMetrics(VDID1, Lists.newArrayList(fe1, fe2, fe3));
validateEvents(listener1, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, RULE_ADDED);
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class VirtualNetworkFlowRuleManagerTest 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);
FlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
vnetFlowRuleService1.applyFlowRules(f1, f2, f3);
vnetFlowRuleService1.removeFlowRules(f3);
providerService1.pushFlowMetrics(VDID1, Lists.newArrayList(fe1, fe2));
validateEvents(listener1, 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 VirtualNetworkFlowRuleManagerTest method removeFlowRules.
@Test
public void removeFlowRules() {
FlowRule f1 = addFlowRule(1);
FlowRule f2 = addFlowRule(2);
FlowRule f3 = addFlowRule(3);
assertEquals("3 rules should exist", 3, flowCount(vnetFlowRuleService1));
FlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
FlowEntry fe3 = new DefaultFlowEntry(f3);
providerService1.pushFlowMetrics(VDID1, ImmutableList.of(fe1, fe2, fe3));
validateEvents(listener1, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, RULE_ADDED, RULE_ADDED);
vnetFlowRuleService1.removeFlowRules(f1, f2);
// removing from north, so no events generated
validateEvents(listener1, RULE_REMOVE_REQUESTED, RULE_REMOVE_REQUESTED);
assertEquals("3 rule should exist", 3, flowCount(vnetFlowRuleService1));
assertTrue("Entries should be pending remove.", validateState(ImmutableMap.of(f1, FlowEntry.FlowEntryState.PENDING_REMOVE, f2, FlowEntry.FlowEntryState.PENDING_REMOVE, f3, FlowEntry.FlowEntryState.ADDED)));
vnetFlowRuleService1.removeFlowRules(f1);
assertEquals("3 rule should still exist", 3, flowCount(vnetFlowRuleService1));
}
Aggregations