当前位置: 首页>>代码示例>>Java>>正文


Java VlanId.toShort方法代码示例

本文整理汇总了Java中org.onlab.packet.VlanId.toShort方法的典型用法代码示例。如果您正苦于以下问题:Java VlanId.toShort方法的具体用法?Java VlanId.toShort怎么用?Java VlanId.toShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.onlab.packet.VlanId的用法示例。


在下文中一共展示了VlanId.toShort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: provisionFabric

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
private void provisionFabric(VlanId vlanId, ConnectPoint point, ConnectPoint fromPoint) {

        long vlan = vlanId.toShort();

        JsonObject node = new JsonObject();
        node.add("vlan", vlan);
        if (vlan == 201) {
            node.add("iptv", true);
        } else {
            node.add("iptv", false);
        }
        JsonArray array = new JsonArray();
        JsonObject cp1 = new JsonObject();
        JsonObject cp2 = new JsonObject();
        cp1.add("device", point.deviceId().toString());
        cp1.add("port", point.port().toLong());
        cp2.add("device", fromPoint.deviceId().toString());
        cp2.add("port", fromPoint.port().toLong());
        array.add(cp1);
        array.add(cp2);
        node.add("ports", array);


        String baseUrl = "http://" + FABRIC_CONTROLLER_ADDRESS + ":"
                + Integer.toString(FABRIC_SERVER_PORT);
        Client client = ClientBuilder.newClient();
        WebTarget wt = client.target(baseUrl + FABRIC_BASE_URI);
        Invocation.Builder builder = wt.request(JSON_UTF_8.toString());

        builder.post(Entity.json(node.toString()));
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:OnosXosIntegrationManager.java

示例2: createL2FloodGroup

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
private void createL2FloodGroup(NextObjective nextObj, VlanId vlanId, List<GroupInfo> groupInfos) {
    // assemble info for l2 flood group
    // since there can be only one flood group for a vlan, its index is always the same - 0
    Integer l2floodgroupId = L2_FLOOD_TYPE | (vlanId.toShort() << 16);
    int l2floodgk = getNextAvailableIndex();
    final GroupKey l2floodgroupkey = new DefaultGroupKey(Ofdpa2Pipeline.appKryo.serialize(l2floodgk));

    // collection of group buckets pointing to all the l2 interface groups
    List<GroupBucket> l2floodBuckets = Lists.newArrayList();
    groupInfos.forEach(groupInfo -> {
        GroupDescription l2intGrpDesc = groupInfo.nextGroupDesc;
        TrafficTreatment.Builder ttb = DefaultTrafficTreatment.builder();
        ttb.group(new DefaultGroupId(l2intGrpDesc.givenGroupId()));
        GroupBucket abucket = DefaultGroupBucket.createAllGroupBucket(ttb.build());
        l2floodBuckets.add(abucket);
    });
    // create the l2flood group-description to wait for all the
    // l2interface groups to be processed
    GroupDescription l2floodGroupDescription =
            new DefaultGroupDescription(
                    deviceId,
                    GroupDescription.Type.ALL,
                    new GroupBuckets(l2floodBuckets),
                    l2floodgroupkey,
                    l2floodgroupId,
                    nextObj.appId());
    log.debug("Trying L2-Flood: device:{} gid:{} gkey:{} nextid:{}",
            deviceId, Integer.toHexString(l2floodgroupId),
            l2floodgroupkey, nextObj.id());

    // Put all dependency information into allGroupKeys
    List<Deque<GroupKey>> allGroupKeys = Lists.newArrayList();
    groupInfos.forEach(groupInfo -> {
        Deque<GroupKey> gkeyChain = new ArrayDeque<>();
        // In this case we should have L2 interface group only
        gkeyChain.addFirst(groupInfo.nextGroupDesc.appCookie());
        gkeyChain.addFirst(l2floodgroupkey);
        allGroupKeys.add(gkeyChain);
    });

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

    GroupChainElem gce = new GroupChainElem(l2floodGroupDescription,
            groupInfos.size(), false);
    groupInfos.forEach(groupInfo -> {
        // Point this group to the next group
        updatePendingGroups(groupInfo.nextGroupDesc.appCookie(), gce);
        // Start installing the inner-most group
        groupService.addGroup(groupInfo.innerMostGroupDesc);
    });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:54,代码来源:Ofdpa2GroupHandler.java

示例3: createL3MulticastGroup

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
private void createL3MulticastGroup(NextObjective nextObj, VlanId vlanId, List<GroupInfo> groupInfos) {
    List<GroupBucket> l3McastBuckets = new ArrayList<>();
    groupInfos.forEach(groupInfo -> {
        // Points to L3 interface group if there is one.
        // Otherwise points to L2 interface group directly.
        GroupDescription nextGroupDesc = (groupInfo.nextGroupDesc != null) ?
                groupInfo.nextGroupDesc : groupInfo.innerMostGroupDesc;
        TrafficTreatment.Builder ttb = DefaultTrafficTreatment.builder();
        ttb.group(new DefaultGroupId(nextGroupDesc.givenGroupId()));
        GroupBucket abucket = DefaultGroupBucket.createAllGroupBucket(ttb.build());
        l3McastBuckets.add(abucket);
    });

    int l3MulticastIndex = getNextAvailableIndex();
    int l3MulticastGroupId = L3_MULTICAST_TYPE | vlanId.toShort() << 16 | (TYPE_VLAN_MASK & l3MulticastIndex);
    final GroupKey l3MulticastGroupKey = new DefaultGroupKey(Ofdpa2Pipeline.appKryo.serialize(l3MulticastIndex));

    GroupDescription l3MulticastGroupDesc = new DefaultGroupDescription(deviceId,
            GroupDescription.Type.ALL,
            new GroupBuckets(l3McastBuckets),
            l3MulticastGroupKey,
            l3MulticastGroupId,
            nextObj.appId());

    // Put all dependency information into allGroupKeys
    List<Deque<GroupKey>> allGroupKeys = Lists.newArrayList();
    groupInfos.forEach(groupInfo -> {
        Deque<GroupKey> gkeyChain = new ArrayDeque<>();
        gkeyChain.addFirst(groupInfo.innerMostGroupDesc.appCookie());
        // Add L3 interface group to the chain if there is one.
        if (!groupInfo.nextGroupDesc.equals(groupInfo.innerMostGroupDesc)) {
            gkeyChain.addFirst(groupInfo.nextGroupDesc.appCookie());
        }
        gkeyChain.addFirst(l3MulticastGroupKey);
        allGroupKeys.add(gkeyChain);
    });

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

    GroupChainElem outerGce = new GroupChainElem(l3MulticastGroupDesc,
            groupInfos.size(), false);
    groupInfos.forEach(groupInfo -> {
        // Point this group (L3 multicast) to the next group
        updatePendingGroups(groupInfo.nextGroupDesc.appCookie(), outerGce);

        // Point next group to inner-most group, if any
        if (!groupInfo.nextGroupDesc.equals(groupInfo.innerMostGroupDesc)) {
            GroupChainElem innerGce = new GroupChainElem(groupInfo.nextGroupDesc,
                    1, false);
            updatePendingGroups(groupInfo.innerMostGroupDesc.appCookie(), innerGce);
        }

        // Start installing the inner-most group
        groupService.addGroup(groupInfo.innerMostGroupDesc);
    });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:59,代码来源:Ofdpa2GroupHandler.java

示例4: encode

import org.onlab.packet.VlanId; //导入方法依赖的package包/类
@Override
public int encode(VlanId resource) {
    return resource.toShort();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:VlanIdCodec.java


注:本文中的org.onlab.packet.VlanId.toShort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。