Search in sources :

Example 16 with DefaultGroupDescription

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

the class DistributedGroupStoreTest method testPushGroupMetrics.

/**
 * Tests pushing group metrics.
 */
@Test
public void testPushGroupMetrics() {
    groupStore.deviceInitialAuditCompleted(deviceId1, true);
    groupStore.deviceInitialAuditCompleted(deviceId2, true);
    GroupDescription groupDescription3 = new DefaultGroupDescription(deviceId1, ALL, allGroupBuckets, new DefaultGroupKey("aaa".getBytes()), null, APP_ID);
    groupStore.storeGroupDescription(groupDescription1);
    groupStore.storeGroupDescription(groupDescription2);
    groupStore.storeGroupDescription(groupDescription3);
    Group group1 = groupStore.getGroup(deviceId1, groupId1);
    assertThat(group1, instanceOf(DefaultGroup.class));
    DefaultGroup defaultGroup1 = (DefaultGroup) group1;
    defaultGroup1.setPackets(55L);
    defaultGroup1.setBytes(66L);
    groupStore.pushGroupMetrics(deviceId1, ImmutableList.of(group1));
    // Make sure the group was updated.
    Group requeryGroup1 = groupStore.getGroup(deviceId1, groupId1);
    assertThat(requeryGroup1.packets(), is(55L));
    assertThat(requeryGroup1.bytes(), is(66L));
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroup(org.onosproject.net.group.DefaultGroup) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) Test(org.junit.Test)

Example 17 with DefaultGroupDescription

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

the class OpenstackVtapManager method createGroupTable.

private void createGroupTable(DeviceId deviceId, int groupId, List<Integer> tableIds, List<PortNumber> ports) {
    List<GroupBucket> buckets = Lists.newArrayList();
    if (tableIds != null) {
        tableIds.forEach(tableId -> {
            TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().extension(buildResubmitExtension(deviceId, tableId), deviceId);
            GroupBucket bucket = DefaultGroupBucket.createAllGroupBucket(treatment.build());
            buckets.add(bucket);
        });
    }
    if (ports != null) {
        ports.forEach(port -> {
            TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setOutput(port);
            GroupBucket bucket = DefaultGroupBucket.createAllGroupBucket(treatment.build());
            buckets.add(bucket);
        });
    }
    GroupDescription groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.ALL, new GroupBuckets(buckets), getGroupKey(groupId), groupId, appId);
    groupService.addGroup(groupDescription);
}
Also used : GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) 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)

Example 18 with DefaultGroupDescription

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

the class SpringOpenTTP method addGroup.

private void addGroup(NextObjective nextObjective) {
    log.debug("addGroup with type{} for nextObjective id {}", nextObjective.type(), nextObjective.id());
    List<GroupBucket> buckets;
    switch(nextObjective.type()) {
        case SIMPLE:
            Collection<TrafficTreatment> treatments = nextObjective.next();
            if (treatments.size() == 1) {
                // Spring Open TTP converts simple nextObjective to flow-actions
                // in a dummy group
                TrafficTreatment treatment = nextObjective.next().iterator().next();
                log.debug("Converting SIMPLE group for next objective id {} " + "to {} flow-actions in device:{}", nextObjective.id(), treatment.allInstructions().size(), deviceId);
                flowObjectiveStore.putNextGroup(nextObjective.id(), new SpringOpenGroup(null, treatment));
            }
            break;
        case HASHED:
            // we convert MPLS ECMP groups to flow-actions for a single
            // bucket(output port).
            boolean mplsEcmp = false;
            if (nextObjective.meta() != null) {
                for (Criterion c : nextObjective.meta().criteria()) {
                    if (c.type() == Type.MPLS_LABEL) {
                        mplsEcmp = true;
                    }
                }
            }
            if (mplsEcmp) {
                // covert to flow-actions in a dummy group by choosing the first bucket
                log.debug("Converting HASHED group for next objective id {} " + "to flow-actions in device:{}", nextObjective.id(), deviceId);
                TrafficTreatment treatment = nextObjective.next().iterator().next();
                flowObjectiveStore.putNextGroup(nextObjective.id(), new SpringOpenGroup(null, treatment));
            } else {
                // process as ECMP group
                buckets = nextObjective.next().stream().map(DefaultGroupBucket::createSelectGroupBucket).collect(Collectors.toList());
                if (!buckets.isEmpty()) {
                    final GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id()));
                    GroupDescription groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.SELECT, new GroupBuckets(buckets), key, null, nextObjective.appId());
                    log.debug("Creating HASHED group for next objective id {}" + " in dev:{}", nextObjective.id(), deviceId);
                    pendingGroups.put(key, nextObjective);
                    groupService.addGroup(groupDescription);
                    verifyPendingGroupLater();
                }
            }
            break;
        case BROADCAST:
            buckets = nextObjective.next().stream().map(DefaultGroupBucket::createAllGroupBucket).collect(Collectors.toList());
            if (!buckets.isEmpty()) {
                final GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id()));
                GroupDescription groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.ALL, new GroupBuckets(buckets), key, null, nextObjective.appId());
                log.debug("Creating BROADCAST group for next objective id {} " + "in device {}", nextObjective.id(), deviceId);
                pendingGroups.put(key, nextObjective);
                groupService.addGroup(groupDescription);
                verifyPendingGroupLater();
            }
            break;
        case FAILOVER:
            log.debug("FAILOVER next objectives not supported");
            fail(nextObjective, ObjectiveError.UNSUPPORTED);
            log.warn("Unsupported next objective type {}", nextObjective.type());
            break;
        default:
            fail(nextObjective, ObjectiveError.UNKNOWN);
            log.warn("Unknown next objective type {}", nextObjective.type());
    }
}
Also used : GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) MplsBosCriterion(org.onosproject.net.flow.criteria.MplsBosCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) 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)

Example 19 with DefaultGroupDescription

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

the class CentecV350Pipeline method next.

@Override
public void next(NextObjective nextObjective) {
    switch(nextObjective.type()) {
        case SIMPLE:
            Collection<TrafficTreatment> treatments = nextObjective.next();
            if (treatments.size() == 1) {
                TrafficTreatment treatment = treatments.iterator().next();
                // Since we do not support strip_vlan in PORT_VLAN table, we use mod_vlan
                // to modify the packet to desired vlan.
                // Note: if we use push_vlan here, the switch will add a second VLAN tag to the outgoing
                // packet, which is not what we want.
                TrafficTreatment.Builder treatmentWithoutPushVlan = DefaultTrafficTreatment.builder();
                VlanId modVlanId;
                for (Instruction ins : treatment.allInstructions()) {
                    if (ins.type() == Instruction.Type.L2MODIFICATION) {
                        L2ModificationInstruction l2ins = (L2ModificationInstruction) ins;
                        switch(l2ins.subtype()) {
                            case ETH_DST:
                                treatmentWithoutPushVlan.setEthDst(((L2ModificationInstruction.ModEtherInstruction) l2ins).mac());
                                break;
                            case ETH_SRC:
                                treatmentWithoutPushVlan.setEthSrc(((L2ModificationInstruction.ModEtherInstruction) l2ins).mac());
                                break;
                            case VLAN_ID:
                                modVlanId = ((L2ModificationInstruction.ModVlanIdInstruction) l2ins).vlanId();
                                treatmentWithoutPushVlan.setVlanId(modVlanId);
                                break;
                            default:
                                break;
                        }
                    } else if (ins.type() == Instruction.Type.OUTPUT) {
                        // long portNum = ((Instructions.OutputInstruction) ins).port().toLong();
                        treatmentWithoutPushVlan.add(ins);
                    } else {
                        // Ignore the vlan_pcp action since it's does matter much.
                        log.warn("Driver does not handle this type of TrafficTreatment" + " instruction in nextObjectives:  {}", ins.type());
                    }
                }
                GroupBucket bucket = DefaultGroupBucket.createIndirectGroupBucket(treatmentWithoutPushVlan.build());
                final GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id()));
                GroupDescription groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(bucket)), key, // let group service determine group id
                null, nextObjective.appId());
                groupService.addGroup(groupDescription);
                pendingGroups.put(key, nextObjective);
            }
            break;
        case HASHED:
        case BROADCAST:
        case FAILOVER:
            fail(nextObjective, ObjectiveError.UNSUPPORTED);
            log.warn("Unsupported next objective type {}", nextObjective.type());
            break;
        default:
            fail(nextObjective, ObjectiveError.UNKNOWN);
            log.warn("Unknown next objective type {}", nextObjective.type());
    }
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) 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) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) VlanId(org.onlab.packet.VlanId)

Example 20 with DefaultGroupDescription

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

the class SimpleVirtualGroupStore method deviceInitialAuditCompleted.

@Override
public void deviceInitialAuditCompleted(NetworkId networkId, DeviceId deviceId, boolean completed) {
    deviceAuditStatus.computeIfAbsent(networkId, k -> new HashMap<>());
    HashMap<DeviceId, Boolean> deviceAuditStatusByNetwork = deviceAuditStatus.get(networkId);
    synchronized (deviceAuditStatusByNetwork) {
        if (completed) {
            log.debug("deviceInitialAuditCompleted: AUDIT " + "completed for device {}", deviceId);
            deviceAuditStatusByNetwork.put(deviceId, true);
            // Execute all pending group requests
            ConcurrentMap<GroupKey, StoredGroupEntry> pendingGroupRequests = getPendingGroupKeyTable(networkId, deviceId);
            for (Group group : pendingGroupRequests.values()) {
                GroupDescription tmp = new DefaultGroupDescription(group.deviceId(), group.type(), group.buckets(), group.appCookie(), group.givenGroupId(), group.appId());
                storeGroupDescriptionInternal(networkId, tmp);
            }
            getPendingGroupKeyTable(networkId, deviceId).clear();
        } else {
            if (deviceAuditStatusByNetwork.get(deviceId)) {
                log.debug("deviceInitialAuditCompleted: Clearing AUDIT " + "status for device {}", deviceId);
                deviceAuditStatusByNetwork.put(deviceId, false);
            }
        }
    }
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) DeviceId(org.onosproject.net.DeviceId) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry)

Aggregations

DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)67 GroupBuckets (org.onosproject.net.group.GroupBuckets)61 GroupBucket (org.onosproject.net.group.GroupBucket)56 GroupDescription (org.onosproject.net.group.GroupDescription)54 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)47 GroupKey (org.onosproject.net.group.GroupKey)45 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)42 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)40 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)39 GroupId (org.onosproject.core.GroupId)21 Group (org.onosproject.net.group.Group)21 ArrayList (java.util.ArrayList)18 OfdpaGroupHandlerUtility.l2MulticastGroupKey (org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey)15 PortNumber (org.onosproject.net.PortNumber)14 PiGroupKey (org.onosproject.net.pi.runtime.PiGroupKey)14 ArrayDeque (java.util.ArrayDeque)13 Deque (java.util.Deque)13 TrafficSelector (org.onosproject.net.flow.TrafficSelector)13 DefaultGroup (org.onosproject.net.group.DefaultGroup)13 VlanId (org.onlab.packet.VlanId)10