Search in sources :

Example 71 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class Ofdpa3GroupHandler method createUnfilteredL2L3Chain.

// TODO Introduce in the future an inner class to return two treatments
/**
 * Internal implementation of createL2L3Chain for L2 unfiltered interface group.
 *
 * @param treatment that needs to be broken up to create the group chain
 * @param nextId of the next objective that needs this group chain
 * @param appId of the application that sent this next objective
 * @param useSetVlanExtension use the setVlanVid extension that has is_present bit set to 0.
 * @return GroupInfo containing the GroupDescription of the
 *         L2 Unfiltered Interface group(inner) and the GroupDescription of the (outer)
 *         L3Unicast group. May return null if there is an error in processing the chain.
 */
private GroupInfo createUnfilteredL2L3Chain(TrafficTreatment treatment, int nextId, ApplicationId appId, boolean useSetVlanExtension) {
    // for the l2 unfiltered interface group, get port info
    // for the l3 unicast group, get the src/dst mac, and vlan info
    TrafficTreatment.Builder outerTtb = DefaultTrafficTreatment.builder();
    TrafficTreatment.Builder innerTtb = DefaultTrafficTreatment.builder();
    VlanId vlanId;
    long portNum = 0;
    MacAddress srcMac;
    MacAddress dstMac;
    for (Instruction ins : treatment.allInstructions()) {
        if (ins.type() == Instruction.Type.L2MODIFICATION) {
            L2ModificationInstruction l2ins = (L2ModificationInstruction) ins;
            switch(l2ins.subtype()) {
                case ETH_DST:
                    dstMac = ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac();
                    outerTtb.setEthDst(dstMac);
                    break;
                case ETH_SRC:
                    srcMac = ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac();
                    outerTtb.setEthSrc(srcMac);
                    break;
                case VLAN_ID:
                    vlanId = ((L2ModificationInstruction.ModVlanIdInstruction) l2ins).vlanId();
                    if (useSetVlanExtension) {
                        OfdpaSetVlanVid ofdpaSetVlanVid = new OfdpaSetVlanVid(vlanId);
                        outerTtb.extension(ofdpaSetVlanVid, deviceId);
                    } else {
                        outerTtb.setVlanId(vlanId);
                    }
                    break;
                default:
                    break;
            }
        } else if (ins.type() == Instruction.Type.OUTPUT) {
            portNum = ((Instructions.OutputInstruction) ins).port().toLong();
            innerTtb.add(ins);
        } else {
            log.debug("Driver does not handle this type of TrafficTreatment" + " instruction in l2l3chain:  {} - {}", ins.type(), ins);
        }
    }
    innerTtb.extension(new OfdpaSetAllowVlanTranslation(Ofdpa3AllowVlanTranslationType.ALLOW), deviceId);
    // assemble information for ofdpa l2 unfiltered interface group
    int l2groupId = l2UnfilteredGroupId(portNum);
    // a globally unique groupkey that is different for ports in the same device,
    // but different for the same portnumber on different devices. Also different
    // for the various group-types created out of the same next objective.
    int l2gk = l2UnfilteredGroupKey(deviceId, portNum);
    final GroupKey l2groupkey = new DefaultGroupKey(Ofdpa3Pipeline.appKryo.serialize(l2gk));
    // assemble information for outer group (L3Unicast)
    GroupDescription outerGrpDesc;
    int l3unicastIndex = getNextAvailableIndex();
    int l3groupId = L3_UNICAST_TYPE | (TYPE_MASK & l3unicastIndex);
    final GroupKey l3groupkey = new DefaultGroupKey(Ofdpa3Pipeline.appKryo.serialize(l3unicastIndex));
    outerTtb.group(new GroupId(l2groupId));
    // create the l3unicast group description to wait for the
    // l2 unfiltered interface group to be processed
    GroupBucket l3unicastGroupBucket = DefaultGroupBucket.createIndirectGroupBucket(outerTtb.build());
    outerGrpDesc = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(l3unicastGroupBucket)), l3groupkey, l3groupId, appId);
    log.debug("Trying L3Unicast: device:{} gid:{} gkey:{} nextid:{}", deviceId, Integer.toHexString(l3groupId), l3groupkey, nextId);
    // store l2groupkey with the groupChainElem for the outer-group that depends on it
    GroupChainElem gce = new GroupChainElem(outerGrpDesc, 1, false, deviceId);
    updatePendingGroups(l2groupkey, gce);
    // create group description for the inner l2 unfiltered interface group
    GroupBucket l2InterfaceGroupBucket = DefaultGroupBucket.createIndirectGroupBucket(innerTtb.build());
    GroupDescription l2groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(l2InterfaceGroupBucket)), l2groupkey, l2groupId, appId);
    log.debug("Trying L2Unfiltered: device:{} gid:{} gkey:{} nextId:{}", deviceId, Integer.toHexString(l2groupId), l2groupkey, nextId);
    return new GroupInfo(l2groupDescription, outerGrpDesc);
}
Also used : OfdpaSetVlanVid(org.onosproject.driver.extensions.OfdpaSetVlanVid) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) OfdpaSetAllowVlanTranslation(org.onosproject.driver.extensions.OfdpaSetAllowVlanTranslation) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instructions(org.onosproject.net.flow.instructions.Instructions) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) MacAddress(org.onlab.packet.MacAddress) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) VlanId(org.onlab.packet.VlanId)

Example 72 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class Ofdpa3GroupHandler method createMplsTunnelLabelGroup.

/**
 * Helper method to create a mpls tunnel label group.
 *
 * @param nextGroupId the next group in the chain
 * @param subtype the mpls tunnel label group subtype
 * @param index the index of the group
 * @param instructions the instructions to push
 * @param applicationId the application id
 * @return the group description
 */
private GroupDescription createMplsTunnelLabelGroup(int nextGroupId, OfdpaMplsGroupSubType subtype, int index, List<Instruction> instructions, ApplicationId applicationId) {
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    // We add all the instructions.
    instructions.forEach(treatment::add);
    // We point the group to the next group.
    treatment.group(new GroupId(nextGroupId));
    GroupBucket groupBucket = DefaultGroupBucket.createIndirectGroupBucket(treatment.build());
    // Finally we build the group description.
    int groupId = makeMplsLabelGroupId(subtype, index);
    GroupKey groupKey = new DefaultGroupKey(Ofdpa2Pipeline.appKryo.serialize(index));
    return new DefaultGroupDescription(deviceId, INDIRECT, new GroupBuckets(Collections.singletonList(groupBucket)), groupKey, groupId, applicationId);
}
Also used : GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupId(org.onosproject.core.GroupId)

Example 73 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class OvsOfdpaGroupHandler method createL2L3Chain.

@Override
protected GroupInfo createL2L3Chain(TrafficTreatment treatment, int nextId, ApplicationId appId, boolean mpls, TrafficSelector meta) {
    if (createUnfiltered(treatment, meta)) {
        return createUnfilteredL2L3Chain(treatment, nextId, appId);
    }
    // for the l2interface group, get vlan and port info
    // for the outer group, get the src/dst mac, and vlan info
    TrafficTreatment.Builder outerTtb = DefaultTrafficTreatment.builder();
    TrafficTreatment.Builder innerTtb = DefaultTrafficTreatment.builder();
    VlanId vlanid = null;
    long portNum = 0;
    boolean setVlan = false, popVlan = false;
    MacAddress srcMac = MacAddress.ZERO;
    MacAddress dstMac = MacAddress.ZERO;
    for (Instruction ins : treatment.allInstructions()) {
        if (ins.type() == Instruction.Type.L2MODIFICATION) {
            L2ModificationInstruction l2ins = (L2ModificationInstruction) ins;
            switch(l2ins.subtype()) {
                case ETH_DST:
                    dstMac = ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac();
                    outerTtb.setEthDst(dstMac);
                    break;
                case ETH_SRC:
                    srcMac = ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac();
                    outerTtb.setEthSrc(srcMac);
                    break;
                case VLAN_ID:
                    vlanid = ((L2ModificationInstruction.ModVlanIdInstruction) l2ins).vlanId();
                    outerTtb.setVlanId(vlanid);
                    setVlan = true;
                    break;
                case VLAN_POP:
                    innerTtb.popVlan();
                    popVlan = true;
                    break;
                case DEC_MPLS_TTL:
                case MPLS_LABEL:
                case MPLS_POP:
                case MPLS_PUSH:
                case VLAN_PCP:
                case VLAN_PUSH:
                default:
                    break;
            }
        } else if (ins.type() == Instruction.Type.OUTPUT) {
            portNum = ((Instructions.OutputInstruction) ins).port().toLong();
            innerTtb.add(ins);
        } else {
            log.debug("Driver does not handle this type of TrafficTreatment" + " instruction in l2l3chain:  {} - {}", ins.type(), ins);
        }
    }
    if (vlanid == null && meta != null) {
        // use metadata if available
        Criterion vidCriterion = meta.getCriterion(Criterion.Type.VLAN_VID);
        if (vidCriterion != null) {
            vlanid = ((VlanIdCriterion) vidCriterion).vlanId();
        }
        // if vlan is not set, use the vlan in metadata for outerTtb
        if (vlanid != null && !setVlan) {
            outerTtb.setVlanId(vlanid);
        }
    }
    if (vlanid == null) {
        log.error("Driver cannot process an L2/L3 group chain without " + "egress vlan information for dev: {} port:{}", deviceId, portNum);
        return null;
    }
    if (!setVlan && !popVlan) {
        // untagged outgoing port
        TrafficTreatment.Builder temp = DefaultTrafficTreatment.builder();
        temp.popVlan();
        innerTtb.build().allInstructions().forEach(i -> temp.add(i));
        innerTtb = temp;
    }
    // assemble information for ofdpa l2interface group
    int l2groupId = L2_INTERFACE_TYPE | (vlanid.toShort() << 16) | (int) portNum;
    // a globally unique groupkey that is different for ports in the same device,
    // but different for the same portnumber on different devices. Also different
    // for the various group-types created out of the same next objective.
    int l2gk = l2InterfaceGroupKey(deviceId, vlanid, portNum);
    final GroupKey l2groupkey = new DefaultGroupKey(Ofdpa2Pipeline.appKryo.serialize(l2gk));
    // assemble information for outer group
    GroupDescription outerGrpDesc = null;
    if (mpls) {
        // outer group is MPLSInteface
        int mplsInterfaceIndex = getNextAvailableIndex();
        int mplsgroupId = MPLS_INTERFACE_TYPE | (SUBTYPE_MASK & mplsInterfaceIndex);
        final GroupKey mplsgroupkey = new DefaultGroupKey(Ofdpa2Pipeline.appKryo.serialize(mplsInterfaceIndex));
        outerTtb.group(new GroupId(l2groupId));
        // create the mpls-interface group description to wait for the
        // l2 interface group to be processed
        GroupBucket mplsinterfaceGroupBucket = DefaultGroupBucket.createIndirectGroupBucket(outerTtb.build());
        outerGrpDesc = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(mplsinterfaceGroupBucket)), mplsgroupkey, mplsgroupId, appId);
        log.debug("Trying MPLS-Interface: device:{} gid:{} gkey:{} nextid:{}", deviceId, Integer.toHexString(mplsgroupId), mplsgroupkey, nextId);
    } else {
        // outer group is L3Unicast
        int l3unicastIndex = getNextAvailableIndex();
        int l3groupId = L3_UNICAST_TYPE | (TYPE_MASK & l3unicastIndex);
        final GroupKey l3groupkey = new DefaultGroupKey(Ofdpa2Pipeline.appKryo.serialize(l3unicastIndex));
        outerTtb.group(new GroupId(l2groupId));
        // create the l3unicast group description to wait for the
        // l2 interface group to be processed
        GroupBucket l3unicastGroupBucket = DefaultGroupBucket.createIndirectGroupBucket(outerTtb.build());
        outerGrpDesc = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(l3unicastGroupBucket)), l3groupkey, l3groupId, appId);
        log.debug("Trying L3Unicast: device:{} gid:{} gkey:{} nextid:{}", deviceId, Integer.toHexString(l3groupId), l3groupkey, nextId);
    }
    // store l2groupkey with the groupChainElem for the outer-group that depends on it
    GroupChainElem gce = new GroupChainElem(outerGrpDesc, 1, false, deviceId);
    updatePendingGroups(l2groupkey, gce);
    // create group description for the inner l2interfacegroup
    GroupBucket l2InterfaceGroupBucket = DefaultGroupBucket.createIndirectGroupBucket(innerTtb.build());
    GroupDescription l2groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(l2InterfaceGroupBucket)), l2groupkey, l2groupId, appId);
    log.debug("Trying L2Interface: device:{} gid:{} gkey:{} nextId:{}", deviceId, Integer.toHexString(l2groupId), l2groupkey, nextId);
    return new GroupInfo(l2groupDescription, outerGrpDesc);
}
Also used : GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instructions(org.onosproject.net.flow.instructions.Instructions) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) MacAddress(org.onlab.packet.MacAddress) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) Criterion(org.onosproject.net.flow.criteria.Criterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) VlanId(org.onlab.packet.VlanId)

Example 74 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class OvsOfdpaGroupHandler method createUnfilteredL2L3Chain.

/**
 * Internal implementation of createL2L3Chain to handle double-tagged vlan.
 * L3UG Group carries dummyVlanId and output port information in its groupId,
 * and does not set vlan.
 * L2UG Group only has OUTPUT instruction.
 *
 * @param treatment that needs to be broken up to create the group chain
 * @param nextId of the next objective that needs this group chain
 * @param appId of the application that sent this next objective
 * @return GroupInfo containing the GroupDescription of the
 *         L2 Unfiltered Interface group(inner) and the GroupDescription of the (outer)
 *         L3Unicast group. May return null if there is an error in processing the chain.
 */
private GroupInfo createUnfilteredL2L3Chain(TrafficTreatment treatment, int nextId, ApplicationId appId) {
    // for the l2 unfiltered interface group, get port info
    // for the l3 unicast group, get the src/dst mac, and vlan info
    TrafficTreatment.Builder outerTtb = DefaultTrafficTreatment.builder();
    TrafficTreatment.Builder innerTtb = DefaultTrafficTreatment.builder();
    VlanId vlanId = VlanId.NONE;
    long portNum = 0;
    MacAddress srcMac;
    MacAddress dstMac;
    for (Instruction ins : treatment.allInstructions()) {
        if (ins.type() == Instruction.Type.L2MODIFICATION) {
            L2ModificationInstruction l2ins = (L2ModificationInstruction) ins;
            switch(l2ins.subtype()) {
                case ETH_DST:
                    dstMac = ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac();
                    outerTtb.setEthDst(dstMac);
                    break;
                case ETH_SRC:
                    srcMac = ((L2ModificationInstruction.ModEtherInstruction) l2ins).mac();
                    outerTtb.setEthSrc(srcMac);
                    break;
                case VLAN_ID:
                    vlanId = ((L2ModificationInstruction.ModVlanIdInstruction) l2ins).vlanId();
                    break;
                default:
                    break;
            }
        } else if (ins.type() == Instruction.Type.OUTPUT) {
            portNum = ((Instructions.OutputInstruction) ins).port().toLong();
            innerTtb.add(ins);
        } else {
            log.debug("Driver does not handle this type of TrafficTreatment" + " instruction in l2l3chain:  {} - {}", ins.type(), ins);
        }
    }
    // assemble information for ofdpa l2 unfiltered interface group
    int l2groupId = l2UnfilteredGroupId(portNum);
    // a globally unique groupkey that is different for ports in the same device,
    // but different for the same portnumber on different devices. Also different
    // for the various group-types created out of the same next objective.
    int l2gk = l2UnfilteredGroupKey(deviceId, portNum);
    final GroupKey l2groupkey = new DefaultGroupKey(Ofdpa2Pipeline.appKryo.serialize(l2gk));
    // assemble information for outer group (L3Unicast)
    GroupDescription outerGrpDesc;
    int l3groupId = doubleVlanL3UnicastGroupId(vlanId, portNum);
    final GroupKey l3groupkey = new DefaultGroupKey(Ofdpa3Pipeline.appKryo.serialize(doubleVlanL3UnicastGroupKey(deviceId, vlanId, portNum)));
    outerTtb.group(new GroupId(l2groupId));
    // create the l3unicast group description to wait for the
    // l2 unfiltered interface group to be processed
    GroupBucket l3unicastGroupBucket = DefaultGroupBucket.createIndirectGroupBucket(outerTtb.build());
    outerGrpDesc = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(l3unicastGroupBucket)), l3groupkey, l3groupId, appId);
    log.debug("Trying L3Unicast: device:{} gid:{} gkey:{} nextid:{}", deviceId, Integer.toHexString(l3groupId), l3groupkey, nextId);
    // store l2groupkey with the groupChainElem for the outer-group that depends on it
    OfdpaGroupHandlerUtility.GroupChainElem gce = new OfdpaGroupHandlerUtility.GroupChainElem(outerGrpDesc, 1, false, deviceId);
    updatePendingGroups(l2groupkey, gce);
    // create group description for the inner l2 unfiltered interface group
    GroupBucket l2InterfaceGroupBucket = DefaultGroupBucket.createIndirectGroupBucket(innerTtb.build());
    GroupDescription l2groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(l2InterfaceGroupBucket)), l2groupkey, l2groupId, appId);
    log.debug("Trying L2Unfiltered: device:{} gid:{} gkey:{} nextId:{}", deviceId, Integer.toHexString(l2groupId), l2groupkey, nextId);
    return new OfdpaGroupHandlerUtility.GroupInfo(l2groupDescription, outerGrpDesc);
}
Also used : GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instructions(org.onosproject.net.flow.instructions.Instructions) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) MacAddress(org.onlab.packet.MacAddress) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) OfdpaGroupHandlerUtility(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) VlanId(org.onlab.packet.VlanId)

Example 75 with GroupBuckets

use of org.onosproject.net.group.GroupBuckets in project onos by opennetworkinglab.

the class SimpleGroupStoreTest method testGroupOperationFailure.

@Test
public void testGroupOperationFailure() {
    simpleGroupStore.deviceInitialAuditCompleted(D1, true);
    ApplicationId appId = new DefaultApplicationId(2, "org.groupstore.test");
    GroupKey key = new DefaultGroupKey("group1".getBytes());
    PortNumber[] ports = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
    List<PortNumber> outPorts = new ArrayList<>();
    outPorts.add(ports[0]);
    outPorts.add(ports[1]);
    List<GroupBucket> buckets = new ArrayList<>();
    for (PortNumber portNumber : outPorts) {
        TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
        tBuilder.setOutput(portNumber).setEthDst(MacAddress.valueOf("00:00:00:00:00:02")).setEthSrc(MacAddress.valueOf("00:00:00:00:00:01")).pushMpls().setMpls(MplsLabel.mplsLabel(106));
        buckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
    }
    GroupBuckets groupBuckets = new GroupBuckets(buckets);
    GroupDescription groupDesc = new DefaultGroupDescription(D1, Group.Type.SELECT, groupBuckets, key, null, appId);
    InternalGroupStoreDelegate checkStoreGroupDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_ADD_REQUESTED);
    simpleGroupStore.setDelegate(checkStoreGroupDelegate);
    // Testing storeGroup operation
    simpleGroupStore.storeGroupDescription(groupDesc);
    simpleGroupStore.unsetDelegate(checkStoreGroupDelegate);
    // Testing Group add operation failure
    Group createdGroup = simpleGroupStore.getGroup(D1, key);
    checkStoreGroupDelegate.verifyGroupId(createdGroup.id());
    GroupOperation groupAddOp = GroupOperation.createAddGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
    InternalGroupStoreDelegate checkGroupAddFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_ADD_FAILED);
    simpleGroupStore.setDelegate(checkGroupAddFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupAddOp);
    // Testing Group modify operation failure
    simpleGroupStore.unsetDelegate(checkGroupAddFailureDelegate);
    GroupOperation groupModOp = GroupOperation.createModifyGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
    InternalGroupStoreDelegate checkGroupModFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_UPDATE_FAILED);
    simpleGroupStore.setDelegate(checkGroupModFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupModOp);
    // Testing Group modify operation failure
    simpleGroupStore.unsetDelegate(checkGroupModFailureDelegate);
    GroupOperation groupDelOp = GroupOperation.createDeleteGroupOperation(createdGroup.id(), createdGroup.type());
    InternalGroupStoreDelegate checkGroupDelFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_REMOVE_FAILED);
    simpleGroupStore.setDelegate(checkGroupDelFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupDelOp);
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) ArrayList(java.util.ArrayList) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) PortNumber(org.onosproject.net.PortNumber) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupOperation(org.onosproject.net.group.GroupOperation) Test(org.junit.Test)

Aggregations

GroupBuckets (org.onosproject.net.group.GroupBuckets)90 GroupBucket (org.onosproject.net.group.GroupBucket)82 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)69 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)63 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)58 GroupKey (org.onosproject.net.group.GroupKey)58 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)57 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)56 GroupDescription (org.onosproject.net.group.GroupDescription)53 Group (org.onosproject.net.group.Group)35 ArrayList (java.util.ArrayList)31 GroupId (org.onosproject.core.GroupId)28 PortNumber (org.onosproject.net.PortNumber)27 DefaultGroup (org.onosproject.net.group.DefaultGroup)22 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)17 ArrayDeque (java.util.ArrayDeque)15 Deque (java.util.Deque)15 TrafficSelector (org.onosproject.net.flow.TrafficSelector)15 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)14 NextObjective (org.onosproject.net.flowobjective.NextObjective)13