Search in sources :

Example 1 with StoredFlowEntry

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;
}
Also used : StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) FlowRuleEvent(org.onosproject.net.flow.FlowRuleEvent)

Example 2 with StoredFlowEntry

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);
    }
}
Also used : FlowId(org.onosproject.net.flow.FlowId) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DeviceId(org.onosproject.net.DeviceId)

Example 3 with StoredFlowEntry

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}");
    }
}
Also used : FlowEntryWithLoad(org.onosproject.net.statistic.FlowEntryWithLoad) SummaryFlowEntryWithLoad(org.onosproject.net.statistic.SummaryFlowEntryWithLoad) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry)

Example 4 with StoredFlowEntry

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

Example 5 with StoredFlowEntry

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);
    }
}
Also used : FlowId(org.onosproject.net.flow.FlowId) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DeviceId(org.onosproject.net.DeviceId)

Aggregations

StoredFlowEntry (org.onosproject.net.flow.StoredFlowEntry)18 DefaultFlowEntry (org.onosproject.net.flow.DefaultFlowEntry)9 FlowEntry (org.onosproject.net.flow.FlowEntry)5 FlowRuleEvent (org.onosproject.net.flow.FlowRuleEvent)5 Test (org.junit.Test)4 DeviceId (org.onosproject.net.DeviceId)4 FlowId (org.onosproject.net.flow.FlowId)4 FlowRule (org.onosproject.net.flow.FlowRule)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)3 Maps (com.google.common.collect.Maps)2 Map (java.util.Map)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 ApplicationId (org.onosproject.core.ApplicationId)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 LogicalTimestamp (org.onosproject.store.LogicalTimestamp)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 ArrayList (java.util.ArrayList)1