Java Code Examples for org.onosproject.net.group.GroupDescription#Type

The following examples show how to use org.onosproject.net.group.GroupDescription#Type . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenFlowGroupProvider.java    From onos with Apache License 2.0 6 votes vote down vote up
private GroupDescription.Type getGroupType(OFGroupType type) {
    switch (type) {
        case ALL:
            return GroupDescription.Type.ALL;
        case INDIRECT:
            return GroupDescription.Type.INDIRECT;
        case SELECT:
            return GroupDescription.Type.SELECT;
        case FF:
            return GroupDescription.Type.FAILOVER;
        default:
            log.error("Unsupported OF group type : {}", type);
            break;
    }
    return null;
}
 
Example 2
Source File: GroupModBuilder.java    From onos with Apache License 2.0 6 votes vote down vote up
private OFGroupType getOFGroupType(GroupDescription.Type groupType) {
    switch (groupType) {
        case INDIRECT:
            return OFGroupType.INDIRECT;
        case SELECT:
            return OFGroupType.SELECT;
        case FAILOVER:
            return OFGroupType.FF;
        case ALL:
            return OFGroupType.ALL;
        default:
            log.error("Unsupported group type : {}", groupType);
            break;
    }
    return null;
}
 
Example 3
Source File: RulePopulatorUtil.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the group bucket with given traffic treatment and group type.
 *
 * @param treatment     traffic treatment
 * @param type          group type
 * @param weight        weight (only for select type)
 * @return group bucket
 */
public static GroupBucket buildGroupBucket(TrafficTreatment treatment,
                                           GroupDescription.Type type, short weight) {
    switch (type) {
        case ALL:
            return DefaultGroupBucket.createAllGroupBucket(treatment);
        case SELECT:
            if (weight == -1) {
                return DefaultGroupBucket.createSelectGroupBucket(treatment);
            } else {
                return DefaultGroupBucket.createSelectGroupBucket(treatment, weight);
            }
        case INDIRECT:
            return DefaultGroupBucket.createIndirectGroupBucket(treatment);
        default:
            return null;
    }
}
 
Example 4
Source File: DefaultOFSwitch.java    From onos with Apache License 2.0 6 votes vote down vote up
private GroupDescription.Type getGroupType(OFGroupType type) {
    switch (type) {
        case ALL:
            return GroupDescription.Type.ALL;
        case INDIRECT:
            return GroupDescription.Type.INDIRECT;
        case SELECT:
            return GroupDescription.Type.SELECT;
        case FF:
            return GroupDescription.Type.FAILOVER;
        default:
            log.error("Unsupported OF group type : {}", type);
            break;
    }
    return null;
}
 
Example 5
Source File: OfdpaGroupHandlerUtility.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Generates a list of group buckets from given list of group information
 * and group bucket type.
 *
 * @param groupInfos a list of group information
 * @param bucketType group bucket type
 * @return list of group bucket generate from group information
 */
static List<GroupBucket> generateNextGroupBuckets(List<GroupInfo> groupInfos,
                                                   GroupDescription.Type bucketType) {
    List<GroupBucket> newBuckets = Lists.newArrayList();

    groupInfos.forEach(groupInfo -> {
        GroupDescription groupDesc = groupInfo.nextGroupDesc();
        TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
        treatmentBuilder.group(new GroupId(groupDesc.givenGroupId()));
        GroupBucket newBucket = null;
        switch (bucketType) {
            case ALL:
                newBucket =
                        DefaultGroupBucket.createAllGroupBucket(treatmentBuilder.build());
                break;
            case INDIRECT:
                newBucket =
                        DefaultGroupBucket.createIndirectGroupBucket(treatmentBuilder.build());
                break;
            case SELECT:
                newBucket =
                        DefaultGroupBucket.createSelectGroupBucket(treatmentBuilder.build());
                break;
            case FAILOVER:
                // TODO: support failover bucket type
            default:
                log.warn("Unknown bucket type: {}", bucketType);
                break;
        }

        if (newBucket != null) {
            newBuckets.add(newBucket);
        }

    });

    return ImmutableList.copyOf(newBuckets);
}
 
Example 6
Source File: GroupModBuilder.java    From onos with Apache License 2.0 5 votes vote down vote up
private GroupModBuilder(GroupBuckets buckets, GroupId groupId,
                         GroupDescription.Type type, OFFactory factory,
                         Optional<Long> xid) {
    this.buckets = buckets;
    this.groupId = groupId;
    this.type = type;
    this.factory = factory;
    this.xid = xid.orElse((long) 0);
}
 
Example 7
Source File: GroupModBuilder.java    From onos with Apache License 2.0 5 votes vote down vote up
private GroupModBuilder(GroupBuckets buckets, GroupId groupId,
                         GroupDescription.Type type, OFFactory factory,
                         Optional<Long> xid, Optional<DriverService> driverService) {
    this.buckets = buckets;
    this.groupId = groupId;
    this.type = type;
    this.factory = factory;
    this.xid = xid.orElse((long) 0);
    this.driverService = driverService;
}
 
Example 8
Source File: GroupModBuilderTest.java    From onos with Apache License 2.0 5 votes vote down vote up
private GroupDescription.Type getGroupType(OFGroupType type) {
    switch (type) {
        case ALL:
            return GroupDescription.Type.ALL;
        case INDIRECT:
            return GroupDescription.Type.INDIRECT;
        case SELECT:
            return GroupDescription.Type.SELECT;
        case FF:
            return GroupDescription.Type.FAILOVER;
        default:
            break;
    }
    return null;
}
 
Example 9
Source File: OpenstackGroupRuleManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void setRule(ApplicationId appId, DeviceId deviceId, int groupId,
                    GroupDescription.Type type, List<GroupBucket> buckets,
                    boolean install) {
    if (install) {
        GroupDescription groupDesc = new DefaultGroupDescription(deviceId,
                type, new GroupBuckets(buckets), getGroupKey(groupId), groupId, appId);
        groupService.addGroup(groupDesc);
        log.info("Adding group rule {}", groupId);
    } else {
        groupService.removeGroup(deviceId, getGroupKey(groupId), appId);
        log.info("Removing group rule {}", groupId);
    }
}
 
Example 10
Source File: GroupModBuilder.java    From onos with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a builder for GroupMod.
 *
 * @param buckets GroupBuckets object
 * @param groupId Group Id to create
 * @param type Group type
 * @param factory OFFactory object
 * @param xid transaction ID
 * @return GroupModBuilder object
 */
public static GroupModBuilder builder(GroupBuckets buckets, GroupId groupId,
                                      GroupDescription.Type type, OFFactory factory,
                                      Optional<Long> xid) {

    return new GroupModBuilder(buckets, groupId, type, factory, xid);
}
 
Example 11
Source File: GroupModBuilder.java    From onos with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a builder for GroupMod.
 *
 * @param buckets GroupBuckets object
 * @param groupId Group Id to create
 * @param type Group type
 * @param factory OFFactory object
 * @param xid transaction ID
 * @param driverService driver Service
 * @return GroupModBuilder object
 */
public static GroupModBuilder builder(GroupBuckets buckets, GroupId groupId,
                                      GroupDescription.Type type, OFFactory factory,
                                      Optional<Long> xid, Optional<DriverService> driverService) {

    return new GroupModBuilder(buckets, groupId, type, factory, xid, driverService);
}
 
Example 12
Source File: OpenstackGroupRuleService.java    From onos with Apache License 2.0 2 votes vote down vote up
/**
 * Configures the group table rule.
 *
 * @param appId         application ID
 * @param deviceId      device ID
 * @param groupId       group ID
 * @param type          group type
 * @param buckets       a list of group buckets
 * @param install       true for rule addition, false for rule removal
 */
void setRule(ApplicationId appId, DeviceId deviceId, int groupId,
             GroupDescription.Type type, List<GroupBucket> buckets, boolean install);