Search in sources :

Example 1 with VirtualFlowEntry

use of org.onosproject.incubator.net.virtual.store.impl.primitives.VirtualFlowEntry in project onos by opennetworkinglab.

the class DistributedVirtualFlowRuleStore method removeFlowRule.

@Override
public FlowRuleEvent removeFlowRule(NetworkId networkId, FlowEntry rule) {
    final DeviceId deviceId = rule.deviceId();
    MastershipService mastershipService = vnaService.get(networkId, MastershipService.class);
    NodeId master = mastershipService.getMasterFor(deviceId);
    if (Objects.equals(local, master)) {
        // bypass and handle it locally
        return removeFlowRuleInternal(new VirtualFlowEntry(networkId, rule));
    }
    if (master == null) {
        log.warn("Failed to removeFlowRule: No master for {}", deviceId);
        // TODO: revisit if this should be null (="no-op") or Exception
        return null;
    }
    log.trace("Forwarding removeFlowRule to {}, which is the master for device {}", master, deviceId);
    return Futures.getUnchecked(clusterCommunicator.sendAndReceive(new VirtualFlowEntry(networkId, rule), REMOVE_FLOW_ENTRY, serializer::encode, serializer::decode, master));
}
Also used : VirtualDeviceId(org.onosproject.incubator.net.virtual.store.impl.primitives.VirtualDeviceId) DeviceId(org.onosproject.net.DeviceId) VirtualFlowEntry(org.onosproject.incubator.net.virtual.store.impl.primitives.VirtualFlowEntry) NodeId(org.onosproject.cluster.NodeId) MastershipService(org.onosproject.mastership.MastershipService)

Example 2 with VirtualFlowEntry

use of org.onosproject.incubator.net.virtual.store.impl.primitives.VirtualFlowEntry in project onos by opennetworkinglab.

the class DistributedVirtualFlowRuleStore method removeFlowRuleInternal.

private FlowRuleEvent removeFlowRuleInternal(VirtualFlowEntry rule) {
    final DeviceId deviceId = rule.flowEntry().deviceId();
    // This is where one could mark a rule as removed and still keep it in the store.
    final FlowEntry removed = flowTable.remove(rule.networkId(), deviceId, rule.flowEntry());
    // rule may be partial rule that is missing treatment, we should use rule from store instead
    return removed != null ? new FlowRuleEvent(RULE_REMOVED, removed) : null;
}
Also used : FlowRuleEvent(org.onosproject.net.flow.FlowRuleEvent) VirtualDeviceId(org.onosproject.incubator.net.virtual.store.impl.primitives.VirtualDeviceId) DeviceId(org.onosproject.net.DeviceId) FlowEntry(org.onosproject.net.flow.FlowEntry) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) VirtualFlowEntry(org.onosproject.incubator.net.virtual.store.impl.primitives.VirtualFlowEntry)

Aggregations

VirtualDeviceId (org.onosproject.incubator.net.virtual.store.impl.primitives.VirtualDeviceId)2 VirtualFlowEntry (org.onosproject.incubator.net.virtual.store.impl.primitives.VirtualFlowEntry)2 DeviceId (org.onosproject.net.DeviceId)2 NodeId (org.onosproject.cluster.NodeId)1 MastershipService (org.onosproject.mastership.MastershipService)1 DefaultFlowEntry (org.onosproject.net.flow.DefaultFlowEntry)1 FlowEntry (org.onosproject.net.flow.FlowEntry)1 FlowRuleEvent (org.onosproject.net.flow.FlowRuleEvent)1 StoredFlowEntry (org.onosproject.net.flow.StoredFlowEntry)1