Search in sources :

Example 36 with DefaultFlowEntry

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);
}
Also used : DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) FlowRuleBatchEntry(org.onosproject.net.flow.oldbatch.FlowRuleBatchEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) FlowEntry(org.onosproject.net.flow.FlowEntry) CompletedBatchOperation(org.onosproject.net.flow.CompletedBatchOperation)

Example 37 with DefaultFlowEntry

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);
}
Also used : StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) FlowEntry(org.onosproject.net.flow.FlowEntry) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Test(org.junit.Test)

Example 38 with DefaultFlowEntry

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);
}
Also used : DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) FlowEntry(org.onosproject.net.flow.FlowEntry) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Test(org.junit.Test)

Example 39 with DefaultFlowEntry

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);
}
Also used : DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) FlowEntry(org.onosproject.net.flow.FlowEntry) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Test(org.junit.Test)

Example 40 with DefaultFlowEntry

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));
}
Also used : DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) FlowEntry(org.onosproject.net.flow.FlowEntry) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Test(org.junit.Test)

Aggregations

DefaultFlowEntry (org.onosproject.net.flow.DefaultFlowEntry)44 FlowEntry (org.onosproject.net.flow.FlowEntry)38 FlowRule (org.onosproject.net.flow.FlowRule)31 StoredFlowEntry (org.onosproject.net.flow.StoredFlowEntry)22 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)21 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)8 DeviceId (org.onosproject.net.DeviceId)7 Collectors (java.util.stream.Collectors)6 Map (java.util.Map)4 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)4 DeviceConnectionCache (org.onosproject.drivers.odtn.impl.DeviceConnectionCache)4 PortNumber (org.onosproject.net.PortNumber)4 DeviceService (org.onosproject.net.device.DeviceService)4 FlowId (org.onosproject.net.flow.FlowId)4 Logger (org.slf4j.Logger)4 ImmutableList (com.google.common.collect.ImmutableList)3 IOException (java.io.IOException)3 Objects (java.util.Objects)3 Set (java.util.Set)3