Java Code Examples for org.onosproject.net.group.DefaultGroupBucket#createIndirectGroupBucket()

The following examples show how to use org.onosproject.net.group.DefaultGroupBucket#createIndirectGroupBucket() . 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: OvsOfdpaPipeline.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a indirect group contains pop_vlan and punt actions.
 * <p>
 * Using group instead of immediate action to ensure that
 * the copy of packet on the data plane is not affected by the pop vlan action.
 */
private void initPopVlanPuntGroup() {
    GroupKey groupKey = popVlanPuntGroupKey();
    TrafficTreatment bucketTreatment = DefaultTrafficTreatment.builder()
            .popVlan().punt().build();
    GroupBucket bucket =
            DefaultGroupBucket.createIndirectGroupBucket(bucketTreatment);
    GroupDescription groupDesc =
            new DefaultGroupDescription(
                    deviceId,
                    GroupDescription.Type.INDIRECT,
                    new GroupBuckets(Collections.singletonList(bucket)),
                    groupKey,
                    POP_VLAN_PUNT_GROUP_ID,
                    driverId);
    groupService.addGroup(groupDesc);

    log.info("Initialized pop vlan punt group on {}", deviceId);
}
 
Example 2
Source File: Ofdpa2GroupHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an Mpls group of type swap.
 *
 * @param nextGroupId the next group in the chain
 * @param subtype the mpls swap label group subtype
 * @param index the index of the group
 * @param mplsLabel the mpls label to swap
 * @param applicationId the application id
 * @return the group description
 */
protected GroupDescription createMplsSwap(int nextGroupId,
                                          OfdpaMplsGroupSubType subtype,
                                          int index,
                                          MplsLabel mplsLabel,
                                          ApplicationId applicationId) {
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.setMpls(mplsLabel);
    // 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);
}
 
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,
                                           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: 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 5
Source File: Ofdpa3GroupHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * 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
    );
}
 
Example 6
Source File: Ofdpa3GroupHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to create a mpls l2 vpn group.
 *
 * @param nextGroupId the next group in the chain
 * @param index the index of the group
 * @param instructions the instructions to push
 * @param applicationId the application id
 * @return the group description
 */
private GroupDescription createMplsL2VpnGroup(int nextGroupId,
                                              int index,
                                              List<Instruction> instructions,
                                              ApplicationId applicationId) {
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    // We add the extensions and the instructions.
    treatment.extension(new Ofdpa3PushL2Header(), deviceId);
    treatment.pushVlan();
    instructions.forEach(treatment::add);
    treatment.extension(new Ofdpa3PushCw(), deviceId);
    // 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(OfdpaMplsGroupSubType.L2_VPN, index);
    GroupKey groupKey = new DefaultGroupKey(
            Ofdpa2Pipeline.appKryo.serialize(index)
    );
    return new DefaultGroupDescription(
            deviceId,
            INDIRECT,
            new GroupBuckets(Collections.singletonList(groupBucket)),
            groupKey,
            groupId,
            applicationId
    );
}
 
Example 7
Source File: SpringOpenTTP.java    From onos with Apache License 2.0 5 votes vote down vote up
private void addBucketToGroup(NextObjective nextObjective) {
    log.debug("addBucketToGroup in {}: for next objective id {}",
              deviceId, nextObjective.id());
    Collection<TrafficTreatment> treatments = nextObjective.next();
    TrafficTreatment treatment = treatments.iterator().next();
    final GroupKey key = new DefaultGroupKey(
            appKryo.serialize(nextObjective
                    .id()));
    Group group = groupService.getGroup(deviceId, key);
    if (group == null) {
        log.warn("Group is not found in {} for {}", deviceId, key);
        return;
    }
    GroupBucket bucket;
    if (group.type() == GroupDescription.Type.INDIRECT) {
        bucket = DefaultGroupBucket.createIndirectGroupBucket(treatment);
    } else if (group.type() == GroupDescription.Type.SELECT) {
        bucket = DefaultGroupBucket.createSelectGroupBucket(treatment);
    } else if (group.type() == GroupDescription.Type.ALL) {
        bucket = DefaultGroupBucket.createAllGroupBucket(treatment);
    } else {
        log.warn("Unsupported Group type {}", group.type());
        return;
    }
    GroupBuckets bucketsToAdd = new GroupBuckets(Collections.singletonList(bucket));
    log.debug("Adding buckets to group id {} of next objective id {} in device {}",
              group.id(), nextObjective.id(), deviceId);
    groupService.addBucketsToGroup(deviceId, key, bucketsToAdd, key, appId);
}
 
Example 8
Source File: SpringOpenTTP.java    From onos with Apache License 2.0 5 votes vote down vote up
private void removeBucketFromGroup(NextObjective nextObjective) {
    log.debug("removeBucketFromGroup in {}: for next objective id {}",
              deviceId, nextObjective.id());
    NextGroup nextGroup = flowObjectiveStore.getNextGroup(nextObjective.id());
    if (nextGroup != null) {
        Collection<TrafficTreatment> treatments = nextObjective.next();
        TrafficTreatment treatment = treatments.iterator().next();
        final GroupKey key = new DefaultGroupKey(
                appKryo.serialize(nextObjective
                        .id()));
        Group group = groupService.getGroup(deviceId, key);
        if (group == null) {
            log.warn("Group is not found in {} for {}", deviceId, key);
            return;
        }
        GroupBucket bucket;
        if (group.type() == GroupDescription.Type.INDIRECT) {
            bucket = DefaultGroupBucket.createIndirectGroupBucket(treatment);
        } else if (group.type() == GroupDescription.Type.SELECT) {
            bucket = DefaultGroupBucket.createSelectGroupBucket(treatment);
        } else if (group.type() == GroupDescription.Type.ALL) {
            bucket = DefaultGroupBucket.createAllGroupBucket(treatment);
        } else {
            log.warn("Unsupported Group type {}", group.type());
            return;
        }
        GroupBuckets removeBuckets = new GroupBuckets(Collections.singletonList(bucket));
        log.debug("Removing buckets from group id {} of next objective id {} in device {}",
                  group.id(), nextObjective.id(), deviceId);
        groupService.removeBucketsFromGroup(deviceId, key, removeBuckets, key, appId);
    }
}
 
Example 9
Source File: AbstractCorsaPipeline.java    From onos with Apache License 2.0 5 votes vote down vote up
@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();
                CorsaTrafficTreatment corsaTreatment = processNextTreatment(treatment);
                final GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id()));
                if (corsaTreatment.type() == CorsaTrafficTreatmentType.GROUP) {
                    GroupBucket bucket = DefaultGroupBucket.createIndirectGroupBucket(corsaTreatment.treatment());
                    GroupBuckets buckets = new GroupBuckets(Collections.singletonList(bucket));
                    // group id == null, let group service determine group id
                    GroupDescription groupDescription = new DefaultGroupDescription(deviceId,
                                                                                    GroupDescription.Type.INDIRECT,
                                                                                    buckets,
                                                                                    key,
                                                                                    null,
                                                                                    nextObjective.appId());
                    groupService.addGroup(groupDescription);
                    pendingGroups.put(key, nextObjective);
                } else if (corsaTreatment.type() == CorsaTrafficTreatmentType.ACTIONS) {
                    pendingNext.put(nextObjective.id(), nextObjective);
                    flowObjectiveStore.putNextGroup(nextObjective.id(), new CorsaGroup(key));
                    nextObjective.context().ifPresent(context -> context.onSuccess(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());
    }

}
 
Example 10
Source File: GroupBucketEntryBuilder.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a GroupBuckets.
 *
 * @return GroupBuckets object, a list of GroupBuckets
 */
public GroupBuckets build() {
    List<GroupBucket> bucketList = Lists.newArrayList();

    for (OFBucket bucket: ofBuckets) {
        TrafficTreatment treatment = buildTreatment(bucket.getActions());
        // TODO: Use GroupBucketEntry
        GroupBucket groupBucket = null;
        switch (type) {
            case INDIRECT:
                groupBucket =
                        DefaultGroupBucket.createIndirectGroupBucket(treatment);
                break;
            case SELECT:
                groupBucket =
                        DefaultGroupBucket.createSelectGroupBucket(treatment, (short) bucket.getWeight());
                break;
            case FF:
                PortNumber port =
                        PortNumber.portNumber(bucket.getWatchPort().getPortNumber());
                GroupId groupId =
                        new GroupId(bucket.getWatchGroup().getGroupNumber());
                groupBucket =
                        DefaultGroupBucket.createFailoverGroupBucket(treatment,
                                port, groupId);
                break;
            case ALL:
                groupBucket =
                        DefaultGroupBucket.createAllGroupBucket(treatment);
                break;
            default:
                log.error("Unsupported Group type : {}", type);
        }
        if (groupBucket != null) {
            bucketList.add(groupBucket);
        }
    }
    return new GroupBuckets(bucketList);
}
 
Example 11
Source File: OFAgentVirtualGroupBucketEntryBuilder.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a GroupBuckets.
 *
 * @return GroupBuckets object, a list of GroupBuckets
 */
public GroupBuckets build() {
    List<GroupBucket> bucketList = Lists.newArrayList();

    for (OFBucket bucket: ofBuckets) {
        TrafficTreatment treatment = buildTreatment(bucket.getActions());
        // TODO: Use GroupBucketEntry
        GroupBucket groupBucket = null;
        switch (type) {
            case INDIRECT:
                groupBucket =
                        DefaultGroupBucket.createIndirectGroupBucket(treatment);
                break;
            case SELECT:
                groupBucket =
                        DefaultGroupBucket.createSelectGroupBucket(treatment, (short) bucket.getWeight());
                break;
            case FF:
                PortNumber port =
                        PortNumber.portNumber(bucket.getWatchPort().getPortNumber());
                GroupId groupId =
                        new GroupId(bucket.getWatchGroup().getGroupNumber());
                groupBucket =
                        DefaultGroupBucket.createFailoverGroupBucket(treatment,
                                port, groupId);
                break;
            case ALL:
                groupBucket =
                        DefaultGroupBucket.createAllGroupBucket(treatment);
                break;
            default:
                log.error("Unsupported Group type : {}", type);
        }
        if (groupBucket != null) {
            bucketList.add(groupBucket);
        }
    }
    return new GroupBuckets(bucketList);
}
 
Example 12
Source File: GroupCodecTest.java    From onos with Apache License 2.0 5 votes vote down vote up
@Test
public void codecEncodeTest() {
    GroupBucket bucket1 = DefaultGroupBucket.createAllGroupBucket(DefaultTrafficTreatment.emptyTreatment());
    GroupBucket bucket2 = DefaultGroupBucket.createAllGroupBucket(DefaultTrafficTreatment.emptyTreatment());
    GroupBucket bucket3 = DefaultGroupBucket.createIndirectGroupBucket(DefaultTrafficTreatment.emptyTreatment());
    GroupBuckets allBuckets = new GroupBuckets(ImmutableList.of(bucket1, bucket2));
    GroupBuckets indirectBuckets = new GroupBuckets(ImmutableList.of(bucket3));

    DefaultGroup group = new DefaultGroup(
            new GroupId(1),
            NetTestTools.did("d1"),
            ALL,
            allBuckets);
    DefaultGroup group1 = new DefaultGroup(
            new GroupId(2),
            NetTestTools.did("d2"),
            INDIRECT,
            indirectBuckets);

    MockCodecContext context = new MockCodecContext();
    GroupCodec codec = new GroupCodec();
    ObjectNode groupJson = codec.encode(group, context);

    ObjectNode groupJsonIndirect = codec.encode(group1, context);

    assertThat(groupJson, matchesGroup(group));
    assertThat(groupJsonIndirect, matchesGroup(group1));
}
 
Example 13
Source File: Ofdpa2GroupHandler.java    From onos with Apache License 2.0 4 votes vote down vote up
private GroupInfo prepareL3UnicastGroup(NextObjective nextObj, NextGroup next) {

       ImmutableList.Builder<GroupInfo> groupInfoBuilder = ImmutableList.builder();
       TrafficTreatment treatment = nextObj.next().iterator().next();

       VlanId assignedVlan = readVlanFromSelector(nextObj.meta());
       if (assignedVlan == null) {
            log.warn("VLAN ID required by next obj is missing. Abort.");
            return null;
       }

       List<GroupInfo> l2GroupInfos = prepareL2InterfaceGroup(nextObj, assignedVlan);
       GroupDescription l2InterfaceGroupDesc = l2GroupInfos.get(0).innerMostGroupDesc();
       GroupKey l2groupkey = l2InterfaceGroupDesc.appCookie();

       TrafficTreatment.Builder outerTtb = DefaultTrafficTreatment.builder();
       VlanId vlanid = null;
       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();
                            outerTtb.setVlanId(vlanid);
                        break;
                    default:
                        break;
                }
            } else {
                log.debug("Driver does not handle this type of TrafficTreatment"
                        + " instruction in l2l3chain:  {} - {}", ins.type(), ins);
            }
       }

       GroupId l2groupId = new GroupId(l2InterfaceGroupDesc.givenGroupId());
       outerTtb.group(l2groupId);

       // we need the top level group's key to point the flow to it
       List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
       GroupKey l3groupkey = gkeys.get(0).peekFirst();
       GroupId grpId = groupService.getGroup(deviceId, l3groupkey).id();
       int l3groupId = grpId.id();

       // create the l3unicast group description to wait for the
       // l2 interface group to be processed
       GroupBucket l3UnicastGroupBucket =  DefaultGroupBucket.createIndirectGroupBucket(outerTtb.build());

       GroupDescription l3UnicastGroupDescription = new DefaultGroupDescription(deviceId,
                                                        GroupDescription.Type.INDIRECT,
                                                        new GroupBuckets(Collections.singletonList(
                                                        l3UnicastGroupBucket)), l3groupkey,
                                                        l3groupId, nextObj.appId());

      // store l2groupkey with the groupChainElem for the outer-group that depends on it
      GroupChainElem gce = new GroupChainElem(l3UnicastGroupDescription, 1, false, deviceId);
      updatePendingGroups(l2groupkey, gce);

      log.debug("Trying L3-Interface: device:{} gid:{} gkey:{} nextid:{}",
                        deviceId, Integer.toHexString(l3groupId), l3groupkey, nextObj.id());

      groupInfoBuilder.add(new GroupInfo(l2InterfaceGroupDesc,
                    l3UnicastGroupDescription));

      return groupInfoBuilder.build().iterator().next();
    }
 
Example 14
Source File: CentecV350Pipeline.java    From onos with Apache License 2.0 4 votes vote down vote up
@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,
                        null, // let group service determine group id
                        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());
    }

}
 
Example 15
Source File: GroupBucketCodec.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public GroupBucket decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    // build traffic treatment
    ObjectNode treatmentJson = get(json, TREATMENT);
    TrafficTreatment trafficTreatment = null;
    if (treatmentJson != null) {
        JsonCodec<TrafficTreatment> treatmentCodec =
                context.codec(TrafficTreatment.class);
        trafficTreatment = treatmentCodec.decode(treatmentJson, context);
    }

    // parse group type
    String type = nullIsIllegal(json.get(TYPE), TYPE + MISSING_MEMBER_MESSAGE).asText();
    GroupBucket groupBucket = null;

    switch (type) {
        case "SELECT":
            // parse weight
            int weightInt = nullIsIllegal(json.get(WEIGHT), WEIGHT + MISSING_MEMBER_MESSAGE).asInt();

            groupBucket =
                    DefaultGroupBucket.createSelectGroupBucket(trafficTreatment, (short) weightInt);
            break;
        case "INDIRECT":
            groupBucket =
                    DefaultGroupBucket.createIndirectGroupBucket(trafficTreatment);
            break;
        case "ALL":
            groupBucket =
                    DefaultGroupBucket.createAllGroupBucket(trafficTreatment);
            break;
        case "FAILOVER":
            // parse watchPort
            PortNumber watchPort = PortNumber.portNumber(nullIsIllegal(json.get(WATCH_PORT),
                    WATCH_PORT + MISSING_MEMBER_MESSAGE).asText());

            // parse watchGroup
            int groupIdInt = nullIsIllegal(json.get(WATCH_GROUP),
                    WATCH_GROUP + MISSING_MEMBER_MESSAGE).asInt();
            GroupId watchGroup = new GroupId((short) groupIdInt);

            groupBucket =
                    DefaultGroupBucket.createFailoverGroupBucket(trafficTreatment, watchPort, watchGroup);
            break;
        default:
            DefaultGroupBucket.createAllGroupBucket(trafficTreatment);
    }

    return groupBucket;
}