本文整理汇总了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);
}
}
示例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;
}
示例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);
}
示例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()));
}