• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java GroupDescription类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.onosproject.net.group.GroupDescription的典型用法代码示例。如果您正苦于以下问题:Java GroupDescription类的具体用法?Java GroupDescription怎么用?Java GroupDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

GroupDescription类属于org.onosproject.net.group包,在下文中一共展示了GroupDescription类的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getGroupType

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
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;
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:17,
代码来源:OpenFlowGroupProvider.java

示例2: getOFGroupType

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
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;
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:17,
代码来源:GroupModBuilder.java

示例3: codecEncodeTest

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
@Test
public void codecEncodeTest() {
    GroupBucket bucket1 = DefaultGroupBucket
            .createSelectGroupBucket(DefaultTrafficTreatment.emptyTreatment());
    GroupBucket bucket2 = DefaultGroupBucket
            .createIndirectGroupBucket(DefaultTrafficTreatment.emptyTreatment());
    GroupBuckets buckets = new GroupBuckets(ImmutableList.of(bucket1, bucket2));


    DefaultGroup group = new DefaultGroup(
            new DefaultGroupId(1),
            NetTestTools.did("d1"),
            GroupDescription.Type.INDIRECT,
            buckets);

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

    assertThat(groupJson, matchesGroup(group));
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:22,
代码来源:GroupCodecTest.java

示例4: storeGroupDescription

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Stores a new group entry using the information from group description.
 *
 * @param groupDesc group description to be used to create group entry
 */
@Override
public void storeGroupDescription(GroupDescription groupDesc) {
    // Check if a group is existing with the same key
    if (getGroup(groupDesc.deviceId(), groupDesc.appCookie()) != null) {
        return;
    }

    if (deviceAuditStatus.get(groupDesc.deviceId()) == null) {
        // Device group audit has not completed yet
        // Add this group description to pending group key table
        // Create a group entry object with Dummy Group ID
        StoredGroupEntry group = new DefaultGroup(dummyGroupId, groupDesc);
        group.setState(GroupState.WAITING_AUDIT_COMPLETE);
        ConcurrentMap<GroupKey, StoredGroupEntry> pendingKeyTable =
                getPendingGroupKeyTable(groupDesc.deviceId());
        pendingKeyTable.put(groupDesc.appCookie(), group);
        return;
    }

    storeGroupDescriptionInternal(groupDesc);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:27,
代码来源:SimpleGroupStore.java

示例5: getProviderGroup

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
private GroupId getProviderGroup(ServiceNetwork provider, DeviceId deviceId) {
    GroupKey groupKey = getGroupKey(provider.id());
    Group group = groupService.getGroup(deviceId, groupKey);
    GroupId groupId = getGroupId(provider.id(), deviceId);

    if (group != null) {
        return groupId;
    }

    GroupBuckets buckets = getProviderGroupBuckets(
            deviceId, provider.segmentId().id(), getInstances(provider.id()));
    GroupDescription groupDescription = new DefaultGroupDescription(
            deviceId,
            GroupDescription.Type.SELECT,
            buckets,
            groupKey,
            groupId.id(),
            appId);

    groupService.addGroup(groupDescription);
    return groupId;
}
 

开发者ID:opencord,
项目名称:vtn,
代码行数:23,
代码来源:DependencyHandler.java

示例6: getGroupType

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
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;
}
 

开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:17,
代码来源:OpenFlowGroupProvider.java

示例7: buildGroupMod

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Builds the GroupMod OF message.
 *
 * @return GroupMod OF message
 */
public OFGroupMod buildGroupMod() {
    List<OFBucket> ofBuckets = new ArrayList<OFBucket>();
    for (GroupBucket bucket: buckets.buckets()) {
        List<OFAction> actions = buildActions(bucket.treatment());

        OFBucket.Builder bucketBuilder = factory.buildBucket();
        bucketBuilder.setActions(actions);
        if (type == GroupDescription.Type.SELECT) {
            bucketBuilder.setWeight(1);
        }
        bucketBuilder.setWatchGroup(OFGroup.ANY);
        bucketBuilder.setWatchPort(OFPort.ANY);
        OFBucket ofBucket = bucketBuilder.build();
        ofBuckets.add(ofBucket);
    }

    OFGroupMod groupMsg = factory.buildGroupModify()
            .setGroup(OFGroup.of(groupId.id()))
            .setBuckets(ofBuckets)
            .setGroupType(getOFGroupType(type))
            .setXid(xid)
            .build();

    return groupMsg;
}
 

开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:31,
代码来源:GroupModBuilder.java

示例8: storeGroupDescriptionInternal

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
private void storeGroupDescriptionInternal(GroupDescription groupDesc) {
    // Check if a group is existing with the same key
    if (getGroup(groupDesc.deviceId(), groupDesc.appCookie()) != null) {
        return;
    }

    // Get a new group identifier
    GroupId id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId()));
    // Create a group entry object
    StoredGroupEntry group = new DefaultGroup(id, groupDesc);
    // Insert the newly created group entry into concurrent key and id maps
    ConcurrentMap<GroupKey, StoredGroupEntry> keyTable =
            getGroupKeyTable(groupDesc.deviceId());
    keyTable.put(groupDesc.appCookie(), group);
    ConcurrentMap<GroupId, StoredGroupEntry> idTable =
            getGroupIdTable(groupDesc.deviceId());
    idTable.put(id, group);
    notifyDelegate(new GroupEvent(GroupEvent.Type.GROUP_ADD_REQUESTED,
                                  group));
}
 

开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:21,
代码来源:SimpleGroupStore.java

示例9: initPopVlanPuntGroup

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * 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);
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:25,
代码来源:CpqdOfdpa2Pipeline.java

示例10: checkFailoverGroups

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Builds a list of failover Groups whose primary live bucket failed over
 * (i.e. bucket in use has changed).
 *
 * @param dpid    DPID of switch whose port's status changed
 * @param status  new status of port
 * @return        list of groups whose primary live bucket failed over
 */
private List<Group> checkFailoverGroups(Dpid dpid, OFPortStatus status) {
    List<Group> groupList = new ArrayList<>();
    OFPortDesc desc = status.getDesc();
    PortNumber portNumber = PortNumber.portNumber(desc.getPortNo().getPortNumber());
    DeviceId id = DeviceId.deviceId(Dpid.uri(dpid));
    if (desc.isEnabled()) {
        return groupList;
    }
    Iterator<Group> iterator = groupService.getGroups(id).iterator();
    while (iterator.hasNext()) {
        Group group = iterator.next();
        if (group.type() == GroupDescription.Type.FAILOVER &&
                checkFailoverGroup(group, id, portNumber)) {
            groupList.add(group);
        }
    }
return groupList;
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:27,
代码来源:OpenFlowGroupProvider.java

示例11: storeGroupDescription

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
@Override
public void storeGroupDescription(NetworkId networkId, GroupDescription groupDesc) {
    // Check if a group is existing with the same key
    if (getGroup(networkId, groupDesc.deviceId(), groupDesc.appCookie()) != null) {
        return;
    }

    if (deviceAuditStatus.get(networkId) == null ||
            deviceAuditStatus.get(networkId).get(groupDesc.deviceId()) == null) {
        // Device group audit has not completed yet
        // Add this group description to pending group key table
        // Create a group entry object with Dummy Group ID
        StoredGroupEntry group = new DefaultGroup(dummyGroupId, groupDesc);
        group.setState(Group.GroupState.WAITING_AUDIT_COMPLETE);
        ConcurrentMap<GroupKey, StoredGroupEntry> pendingKeyTable =
                getPendingGroupKeyTable(networkId, groupDesc.deviceId());
        pendingKeyTable.put(groupDesc.appCookie(), group);
        return;
    }

    storeGroupDescriptionInternal(networkId, groupDesc);
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:23,
代码来源:SimpleVirtualGroupStore.java

示例12: testFwdBridging

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Creates only one rule for ingress_port_vlan table if there is no condition
 * of destination mac address.
 * The packet will be handled by bridging table by default.
 */
@Test
public void testFwdBridging() {
    FilteringObjective filteringObjective = buildFilteringObjective(null);
    PipelinerTranslationResult result = pipeliner.pipelinerFilter.filter(filteringObjective);
    List<FlowRule> flowRulesInstalled = (List<FlowRule>) result.flowRules();
    List<GroupDescription> groupsInstalled = (List<GroupDescription>) result.groups();

    assertTrue(groupsInstalled.isEmpty());

    // in port vlan flow rule
    FlowRule actualFlowRule = flowRulesInstalled.get(0);
    FlowRule flowRuleExpected = buildExpectedVlanInPortRule(PORT_1,
                                                            VlanId.NONE,
                                                            VLAN_100,
                                                            FabricConstants.TBL_INGRESS_PORT_VLAN_ID);
    assertTrue(flowRuleExpected.exactMatch(actualFlowRule));

    // No rules in forwarding classifier, will do default action: set fwd type to bridging
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:25,
代码来源:FabricFilteringPipelinerTest.java

示例13: addOrUpdateGatewayGroup

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
private void addOrUpdateGatewayGroup(OpenstackNode osNode,
                                     Set<OpenstackNode> gatewayNodes,
                                     NetworkMode mode) {
    GroupBuckets buckets = gatewayGroupBuckets(osNode, gatewayNodes, mode);
    if (groupService.getGroup(osNode.intgBridge(), osNode.gatewayGroupKey(mode)) == null) {
        GroupDescription groupDescription = new DefaultGroupDescription(
                osNode.intgBridge(),
                GroupDescription.Type.SELECT,
                buckets,
                osNode.gatewayGroupKey(mode),
                osNode.gatewayGroupId(mode).id(),
                appId);
        groupService.addGroup(groupDescription);
        log.debug("Created gateway group for {}", osNode.hostname());
    } else {
        groupService.setBucketsForGroup(
                osNode.intgBridge(),
                osNode.gatewayGroupKey(mode),
                buckets,
                osNode.gatewayGroupKey(mode),
                appId);
        log.debug("Updated gateway group for {}", osNode.hostname());
    }
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:25,
代码来源:DefaultOpenstackNodeHandler.java

示例14: createFailoverTreatmentGroup

点赞 3

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Creates a new failover group with the initial ports of the links
 * from the primary and backup path.
 *
 * @param links         links from the primary path
 * @param backupLinks   links from the backup path
 * @param intent        intent from which this call originates
 */
private void createFailoverTreatmentGroup(List<Link> links,
                                          List<Link> backupLinks,
                                          PointToPointIntent intent) {

    List<GroupBucket> buckets = new ArrayList<>();

    TrafficTreatment.Builder tBuilderIn = DefaultTrafficTreatment.builder();
    ConnectPoint src = links.get(0).src();
    tBuilderIn.setOutput(src.port());

    TrafficTreatment.Builder tBuilderIn2 = DefaultTrafficTreatment.builder();
    ConnectPoint src2 = backupLinks.get(0).src();
    tBuilderIn2.setOutput(src2.port());

    buckets.add(DefaultGroupBucket.createFailoverGroupBucket(tBuilderIn.build(), src.port(), null));
    buckets.add(DefaultGroupBucket.createFailoverGroupBucket(tBuilderIn2.build(), src2.port(), null));

    GroupBuckets groupBuckets = new GroupBuckets(buckets);

    GroupDescription groupDesc = new DefaultGroupDescription(src.deviceId(), Group.Type.FAILOVER,
                                     groupBuckets, makeGroupKey(intent.id()), null, intent.appId());
    log.trace("adding failover group {}", groupDesc);
    groupService.addGroup(groupDesc);
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:33,
代码来源:PointToPointIntentCompiler.java

示例15: createGroup

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Create new group rule. Creates and installs a new group rule for the
 * specified device.
 *
 * @param deviceId device identifier
 * @param stream   group rule JSON
 * @return status of the request - CREATED if the JSON is correct,
 * BAD_REQUEST if the JSON is invalid
 * @onos.rsModel GroupsPost
 */
@POST
@Path("{deviceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createGroup(@PathParam("deviceId") String deviceId,
                            InputStream stream) {
    try {

        ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
        JsonNode specifiedDeviceId = jsonTree.get("deviceId");

        if (specifiedDeviceId != null &&
                !specifiedDeviceId.asText().equals(deviceId)) {
            throw new IllegalArgumentException(DEVICE_INVALID);
        }
        jsonTree.put("deviceId", deviceId);
        Group group = codec(Group.class).decode(jsonTree, this);
        GroupDescription description = new DefaultGroupDescription(
                group.deviceId(), group.type(), group.buckets(),
                group.appCookie(), group.id().id(), group.appId());
        groupService.addGroup(description);
        UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
                .path("groups")
                .path(deviceId)
                .path(Long.toString(group.id().id()));
        return Response
                .created(locationBuilder.build())
                .build();
    } catch (IOException ex) {
        throw new IllegalArgumentException(ex);
    }
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:43,
代码来源:GroupsWebResource.java

示例16: addBucketToGroup

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
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);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:30,
代码来源:SpringOpenTTP.java

示例17: removeBucketFromGroup

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
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);
    }
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:33,
代码来源:SpringOpenTTP.java

示例18: createL2InterfaceGroup

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Creates a simple L2 Interface Group.
 *
 * @param nextObj the next Objective
 */
private void createL2InterfaceGroup(NextObjective nextObj) {
    VlanId assignedVlan = Ofdpa2Pipeline.readVlanFromSelector(nextObj.meta());
    if (assignedVlan == null) {
        log.warn("VLAN ID required by simple next obj is missing. Abort.");
        Ofdpa2Pipeline.fail(nextObj, ObjectiveError.BADPARAMS);
        return;
    }

    List<GroupInfo> groupInfos = prepareL2InterfaceGroup(nextObj, assignedVlan);

    // There is only one L2 interface group in this case
    GroupDescription l2InterfaceGroupDesc = groupInfos.get(0).innerMostGroupDesc;

    // Put all dependency information into allGroupKeys
    List<Deque<GroupKey>> allGroupKeys = Lists.newArrayList();
    Deque<GroupKey> gkeyChain = new ArrayDeque<>();
    gkeyChain.addFirst(l2InterfaceGroupDesc.appCookie());
    allGroupKeys.add(gkeyChain);

    // Point the next objective to this group
    OfdpaNextGroup ofdpaGrp = new OfdpaNextGroup(allGroupKeys, nextObj);
    updatePendingNextObjective(l2InterfaceGroupDesc.appCookie(), ofdpaGrp);

    // Start installing the inner-most group
    groupService.addGroup(l2InterfaceGroupDesc);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:32,
代码来源:Ofdpa2GroupHandler.java

示例19: next

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
@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();
                treatment = processNextTreatment(treatment);
                GroupBucket bucket =
                        DefaultGroupBucket.createIndirectGroupBucket(treatment);
                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());
    }

}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:36,
代码来源:AbstractCorsaPipeline.java

示例20: GroupModBuilder

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
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);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:10,
代码来源:GroupModBuilder.java

示例21: buildGroupAdd

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Builds the GroupAdd OF message.
 *
 * @return GroupAdd OF message
 */
public OFGroupAdd buildGroupAdd() {

    List<OFBucket> ofBuckets = new ArrayList<OFBucket>();
    for (GroupBucket bucket: buckets.buckets()) {
        List<OFAction> actions = buildActions(bucket.treatment());

        OFBucket.Builder bucketBuilder = factory.buildBucket();
        bucketBuilder.setActions(actions);
        if (type == GroupDescription.Type.SELECT) {
            bucketBuilder.setWeight(1);
        }

        if (type == GroupDescription.Type.FAILOVER && bucket.watchPort() != null) {
            bucketBuilder.setWatchPort(OFPort.of((int) bucket.watchPort().toLong()));
        } else {
            bucketBuilder.setWatchPort(OFPort.ANY);
        }
        if (type == GroupDescription.Type.FAILOVER &&  bucket.watchGroup() != null) {
            bucketBuilder.setWatchGroup(OFGroup.of(bucket.watchGroup().id()));
        } else {
            bucketBuilder.setWatchGroup(OFGroup.ANY);
        }
        OFBucket ofBucket = bucketBuilder.build();
        ofBuckets.add(ofBucket);
    }

    OFGroupAdd groupMsg = factory.buildGroupAdd()
            .setGroup(OFGroup.of(groupId.id()))
            .setBuckets(ofBuckets)
            .setGroupType(getOFGroupType(type))
            .setXid(xid)
            .build();

    return groupMsg;
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:41,
代码来源:GroupModBuilder.java

示例22: buildGroupMod

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Builds the GroupMod OF message.
 *
 * @return GroupMod OF message
 */
public OFGroupMod buildGroupMod() {
    List<OFBucket> ofBuckets = new ArrayList<OFBucket>();
    for (GroupBucket bucket: buckets.buckets()) {
        List<OFAction> actions = buildActions(bucket.treatment());

        OFBucket.Builder bucketBuilder = factory.buildBucket();
        bucketBuilder.setActions(actions);
        if (type == GroupDescription.Type.SELECT) {
            bucketBuilder.setWeight(1);
        }
        if (type == GroupDescription.Type.FAILOVER && bucket.watchPort() != null) {
            bucketBuilder.setWatchPort(OFPort.of((int) bucket.watchPort().toLong()));
        } else {
            bucketBuilder.setWatchPort(OFPort.ANY);
        }
        if (type == GroupDescription.Type.FAILOVER &&  bucket.watchGroup() != null) {
            bucketBuilder.setWatchGroup(OFGroup.of(bucket.watchGroup().id()));
        } else {
            bucketBuilder.setWatchGroup(OFGroup.ANY);
        }

        OFBucket ofBucket = bucketBuilder.build();
        ofBuckets.add(ofBucket);
    }

    OFGroupMod groupMsg = factory.buildGroupModify()
            .setGroup(OFGroup.of(groupId.id()))
            .setBuckets(ofBuckets)
            .setGroupType(getOFGroupType(type))
            .setXid(xid)
            .build();

    return groupMsg;
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:40,
代码来源:GroupModBuilder.java

示例23: addGroup

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
@Test
public void addGroup() {

    GroupId groupId = new DefaultGroupId(1);

    List<GroupBucket> bucketList = Lists.newArrayList();
    TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
    builder.setOutput(PortNumber.portNumber(1));
    GroupBucket bucket =
            DefaultGroupBucket.createSelectGroupBucket(builder.build());
    bucketList.add(bucket);
    GroupBuckets buckets = new GroupBuckets(bucketList);

    List<GroupOperation> operationList = Lists.newArrayList();
    GroupOperation operation = GroupOperation.createAddGroupOperation(groupId,
            GroupDescription.Type.SELECT, buckets);
    operationList.add(operation);
    GroupOperations operations = new GroupOperations(operationList);

    provider.performGroupOperation(deviceId, operations);

    final Dpid dpid = Dpid.dpid(deviceId.uri());
    TestOpenFlowSwitch sw = (TestOpenFlowSwitch) controller.getSwitch(dpid);
    assertNotNull("Switch should not be nul", sw);
    assertNotNull("OFGroupMsg should not be null", sw.msg);

}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:28,
代码来源:OpenFlowGroupProviderTest.java

示例24: groupModFailure

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
@Test
public void groupModFailure() {
    TestOpenFlowGroupProviderService testProviderService =
            (TestOpenFlowGroupProviderService) providerService;

    GroupId groupId = new DefaultGroupId(1);
    List<GroupBucket> bucketList = Lists.newArrayList();
    TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
    builder.setOutput(PortNumber.portNumber(1));
    GroupBucket bucket =
            DefaultGroupBucket.createSelectGroupBucket(builder.build());
    bucketList.add(bucket);
    GroupBuckets buckets = new GroupBuckets(bucketList);
    List<GroupOperation> operationList = Lists.newArrayList();
    GroupOperation operation = GroupOperation.createAddGroupOperation(groupId,
            GroupDescription.Type.SELECT, buckets);
    operationList.add(operation);
    GroupOperations operations = new GroupOperations(operationList);

    provider.performGroupOperation(deviceId, operations);

    OFGroupModFailedErrorMsg.Builder errorBuilder =
            OFFactories.getFactory(OFVersion.OF_13).errorMsgs().buildGroupModFailedErrorMsg();
    OFGroupMod.Builder groupBuilder = OFFactories.getFactory(OFVersion.OF_13).buildGroupModify();
    groupBuilder.setGroupType(OFGroupType.ALL);
    groupBuilder.setGroup(OFGroup.of(1));
    errorBuilder.setCode(OFGroupModFailedCode.GROUP_EXISTS);
    errorBuilder.setXid(provider.getXidAndAdd(0) - 1);

    controller.processPacket(dpid1, errorBuilder.build());

    assertNotNull("Operation failed should not be null",
            testProviderService.failedOperation);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:35,
代码来源:OpenFlowGroupProviderTest.java

示例25: deviceInitialAuditCompleted

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
@Override
public void deviceInitialAuditCompleted(DeviceId deviceId,
                                        boolean completed) {
    synchronized (deviceAuditStatus) {
        if (completed) {
            log.debug("deviceInitialAuditCompleted: AUDIT "
                    + "completed for device {}", deviceId);
            deviceAuditStatus.put(deviceId, true);
            // Execute all pending group requests
            ConcurrentMap<GroupKey, StoredGroupEntry> pendingGroupRequests =
                    getPendingGroupKeyTable(deviceId);
            for (Group group:pendingGroupRequests.values()) {
                GroupDescription tmp = new DefaultGroupDescription(
                                                                   group.deviceId(),
                                                                   group.type(),
                                                                   group.buckets(),
                                                                   group.appCookie(),
                                                                   group.givenGroupId(),
                                                                   group.appId());
                storeGroupDescriptionInternal(tmp);
            }
            getPendingGroupKeyTable(deviceId).clear();
        } else {
            if (deviceAuditStatus.get(deviceId)) {
                log.debug("deviceInitialAuditCompleted: Clearing AUDIT "
                        + "status for device {}", deviceId);
                deviceAuditStatus.put(deviceId, false);
            }
        }
    }
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:32,
代码来源:SimpleGroupStore.java

示例26: deviceInitialAuditCompleted

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
@Override
public void deviceInitialAuditCompleted(DeviceId deviceId,
                                        boolean completed) {
    synchronized (deviceAuditStatus) {
        if (completed) {
            log.debug("AUDIT completed for device {}",
                      deviceId);
            deviceAuditStatus.put(deviceId, true);
            // Execute all pending group requests
            List<StoredGroupEntry> pendingGroupRequests =
                    getPendingGroupKeyTable().values()
                            .stream()
                            .filter(g -> g.deviceId().equals(deviceId))
                            .collect(Collectors.toList());
            log.debug("processing pending group add requests for device {} and number of pending requests {}",
                      deviceId,
                      pendingGroupRequests.size());
            for (Group group : pendingGroupRequests) {
                GroupDescription tmp = new DefaultGroupDescription(
                        group.deviceId(),
                        group.type(),
                        group.buckets(),
                        group.appCookie(),
                        group.givenGroupId(),
                        group.appId());
                storeGroupDescriptionInternal(tmp);
                getPendingGroupKeyTable().
                        remove(new GroupStoreKeyMapKey(deviceId, group.appCookie()));
            }
        } else {
            Boolean audited = deviceAuditStatus.get(deviceId);
            if (audited != null && audited) {
                log.debug("Clearing AUDIT status for device {}", deviceId);
                deviceAuditStatus.put(deviceId, false);
            }
        }
    }
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:39,
代码来源:DistributedGroupStore.java

示例27: GroupStoreMessage

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
private GroupStoreMessage(Type type,
                         DeviceId deviceId,
                         GroupKey appCookie,
                         GroupDescription groupDesc,
                         UpdateType updateType,
                         GroupBuckets updateBuckets,
                         GroupKey newAppCookie) {
    this.type = type;
    this.deviceId = deviceId;
    this.appCookie = appCookie;
    this.groupDesc = groupDesc;
    this.updateType = updateType;
    this.updateBuckets = updateBuckets;
    this.newAppCookie = newAppCookie;
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:16,
代码来源:GroupStoreMessage.java

示例28: createGroupAddRequestMsg

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Creates a group store message for group ADD request.
 *
 * @param deviceId device identifier in which group to be added
 * @param desc group creation parameters
 * @return constructed group store message
 */
public static GroupStoreMessage createGroupAddRequestMsg(DeviceId deviceId,
                                                         GroupDescription desc) {
    return new GroupStoreMessage(Type.ADD,
                          deviceId,
                          null,
                          desc,
                          null,
                          null,
                          null);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:18,
代码来源:GroupStoreMessage.java

示例29: testPushGroupMetrics

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Tests pushing group metrics.
 */
@Test
public void testPushGroupMetrics() {
    groupStore.deviceInitialAuditCompleted(deviceId1, true);
    groupStore.deviceInitialAuditCompleted(deviceId2, true);

    GroupDescription groupDescription3 = new DefaultGroupDescription(
            deviceId1,
            GroupDescription.Type.SELECT,
            buckets,
            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));

}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:35,
代码来源:DistributedGroupStoreTest.java

示例30: buildGroupAdd

点赞 2

import org.onosproject.net.group.GroupDescription; //导入依赖的package包/类
/**
 * Builds the GroupAdd OF message.
 *
 * @return GroupAdd OF message
 */
public OFGroupAdd buildGroupAdd() {

    List<OFBucket> ofBuckets = new ArrayList<OFBucket>();
    for (GroupBucket bucket: buckets.buckets()) {
        List<OFAction> actions = buildActions(bucket.treatment());

        OFBucket.Builder bucketBuilder = factory.buildBucket();
        bucketBuilder.setActions(actions);
        if (type == GroupDescription.Type.SELECT) {
            bucketBuilder.setWeight(1);
        }
        bucketBuilder.setWatchGroup(OFGroup.ANY);
        bucketBuilder.setWatchPort(OFPort.ANY);
        OFBucket ofBucket = bucketBuilder.build();
        ofBuckets.add(ofBucket);
    }

    OFGroupAdd groupMsg = factory.buildGroupAdd()
            .setGroup(OFGroup.of(groupId.id()))
            .setBuckets(ofBuckets)
            .setGroupType(getOFGroupType(type))
            .setXid(xid)
            .build();

    return groupMsg;
}
 

开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:32,
代码来源:GroupModBuilder.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)