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


Java PortNumber.fromString方法代码示例

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


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

示例1: execute

import org.onosproject.net.PortNumber; //导入方法依赖的package包/类
@Override
protected void execute() {
    resourceService = get(ResourceService.class);
    DeviceId did = DeviceId.deviceId(deviceIdStr);
    PortNumber portNum = PortNumber.fromString(portNumberStr);

    ResourceConsumer consumer = IntentId.valueOf(nIntendId);

    Resource resource = Resources.discrete(did, portNum,
            createLambda(Integer.parseInt(lambda))).resource();

    Optional<ResourceAllocation> allocate = resourceService.allocate(consumer, resource);
    if (allocate.isPresent()) {
        print("Allocated: %s", allocate.get());
    } else {
        print("Failed to allocate %s for %s", resource, consumer);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:TestAllocateResource.java

示例2: getPortNumber

import org.onosproject.net.PortNumber; //导入方法依赖的package包/类
/**
 * Extracts port number of the given json node.
 *
 * @param jsonNode json node
 * @return port number
 */
private PortNumber getPortNumber(ObjectNode jsonNode) {
    PortNumber portNumber;
    if (jsonNode.get(InstructionCodec.PORT).isLong() || jsonNode.get(InstructionCodec.PORT).isInt()) {
        portNumber = PortNumber
                .portNumber(nullIsIllegal(jsonNode.get(InstructionCodec.PORT)
                        .asLong(), InstructionCodec.PORT
                        + InstructionCodec.MISSING_MEMBER_MESSAGE));
    } else if (jsonNode.get(InstructionCodec.PORT).isTextual()) {
        portNumber = PortNumber
                .fromString(nullIsIllegal(jsonNode.get(InstructionCodec.PORT)
                        .textValue(), InstructionCodec.PORT
                        + InstructionCodec.MISSING_MEMBER_MESSAGE));
    } else {
        throw new IllegalArgumentException("Port value "
                + jsonNode.get(InstructionCodec.PORT).toString()
                + " is not supported");
    }
    return portNumber;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:DecodeInstructionCodecHelper.java

示例3: translate

import org.onosproject.net.PortNumber; //导入方法依赖的package包/类
/**
 * Translates gRPC PortDescription message to {@link PortDescription}.
 *
 * @param portDescription gRPC message
 * @return {@link PortDescription}
 */
public static PortDescription translate(org.onosproject.grpc.net.Port.PortDescription portDescription) {
    PortNumber number = PortNumber.fromString(portDescription.getPortNumber());
    boolean isEnabled = portDescription.getIsEnabled();
    Port.Type type = translate(portDescription.getType());
    long portSpeed = portDescription.getPortSpeed();
    SparseAnnotations annotations = asAnnotations(portDescription.getAnnotations());
    // TODO How to deal with more specific Port...
    return new DefaultPortDescription(number, isEnabled, type, portSpeed, annotations);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:GrpcDeviceUtils.java

示例4: translate

import org.onosproject.net.PortNumber; //导入方法依赖的package包/类
/**
 * Translates gRPC message to corresponding ONOS object.
 *
 * @param connectPoint gRPC message.
 * @return {@link ConnectPoint}
 */
private ConnectPoint translate(org.onosproject.grpc.net.Link.ConnectPoint connectPoint) {
    checkArgument(connectPoint.getElementIdCase() == ElementIdCase.DEVICE_ID,
                  "Only DeviceId supported.");
    return new ConnectPoint(deviceId(connectPoint.getDeviceId()),
                            PortNumber.fromString(connectPoint.getPortNumber()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:LinkProviderServiceServerProxy.java


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