本文整理汇总了Java中org.onosproject.incubator.net.virtual.DefaultVirtualPort类的典型用法代码示例。如果您正苦于以下问题:Java DefaultVirtualPort类的具体用法?Java DefaultVirtualPort怎么用?Java DefaultVirtualPort使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultVirtualPort类属于org.onosproject.incubator.net.virtual包,在下文中一共展示了DefaultVirtualPort类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import org.onosproject.incubator.net.virtual.DefaultVirtualPort; //导入依赖的package包/类
@Override
public VirtualPort decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
DeviceId dId = DeviceId.deviceId(extractMember(DEVICE_ID, json));
VirtualNetworkService vnetService = context.getService(VirtualNetworkService.class);
Set<VirtualDevice> vDevs = vnetService.getVirtualDevices(nId);
VirtualDevice vDev = vDevs.stream()
.filter(virtualDevice -> virtualDevice.id().equals(dId))
.findFirst().orElse(null);
nullIsIllegal(vDev, dId.toString() + INVALID_VIRTUAL_DEVICE);
PortNumber portNum = PortNumber.portNumber(extractMember(PORT_NUM, json));
DeviceId physDId = DeviceId.deviceId(extractMember(PHYS_DEVICE_ID, json));
PortNumber physPortNum = PortNumber.portNumber(extractMember(PHYS_PORT_NUM, json));
DefaultAnnotations annotations = DefaultAnnotations.builder().build();
Device physDevice = new DefaultDevice(null, physDId,
null, null, null, null, null, null, annotations);
Port realizedBy = new DefaultPort(physDevice, physPortNum, true);
return new DefaultVirtualPort(nId, vDev, portNum, realizedBy);
}
示例2: addPort
import org.onosproject.incubator.net.virtual.DefaultVirtualPort; //导入依赖的package包/类
@Override
public VirtualPort addPort(NetworkId networkId, DeviceId deviceId,
PortNumber portNumber, ConnectPoint realizedBy) {
checkState(networkExists(networkId), "The network has not been added.");
Set<VirtualPort> virtualPortSet = networkIdVirtualPortSetMap.get(networkId);
if (virtualPortSet == null) {
virtualPortSet = new HashSet<>();
}
VirtualDevice device = deviceIdVirtualDeviceMap.get(new VirtualDeviceId(networkId, deviceId));
checkNotNull(device, "The device has not been created for deviceId: " + deviceId);
checkState(!virtualPortExists(networkId, deviceId, portNumber),
"The requested Port Number has been added.");
VirtualPort virtualPort = new DefaultVirtualPort(networkId, device,
portNumber, realizedBy);
virtualPortSet.add(virtualPort);
networkIdVirtualPortSetMap.put(networkId, virtualPortSet);
notifyDelegate(new VirtualNetworkEvent(VirtualNetworkEvent.Type.VIRTUAL_PORT_ADDED,
networkId, device, virtualPort));
return virtualPort;
}
示例3: decode
import org.onosproject.incubator.net.virtual.DefaultVirtualPort; //导入依赖的package包/类
@Override
public VirtualPort decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
DeviceId dId = DeviceId.deviceId(extractMember(DEVICE_ID, json));
VirtualNetworkService vnetService = context.getService(VirtualNetworkService.class);
Set<VirtualDevice> vDevs = vnetService.getVirtualDevices(nId);
VirtualDevice vDev = vDevs.stream()
.filter(virtualDevice -> virtualDevice.id().equals(dId))
.findFirst().orElse(null);
nullIsIllegal(vDev, dId.toString() + INVALID_VIRTUAL_DEVICE);
PortNumber portNum = PortNumber.portNumber(extractMember(PORT_NUM, json));
DeviceId physDId = DeviceId.deviceId(extractMember(PHYS_DEVICE_ID, json));
PortNumber physPortNum = PortNumber.portNumber(extractMember(PHYS_PORT_NUM, json));
ConnectPoint realizedBy = new ConnectPoint(physDId, physPortNum);
return new DefaultVirtualPort(nId, vDev, portNum, realizedBy);
}
示例4: addPort
import org.onosproject.incubator.net.virtual.DefaultVirtualPort; //导入依赖的package包/类
@Override
public VirtualPort addPort(NetworkId networkId, DeviceId deviceId, PortNumber portNumber, Port realizedBy) {
checkState(networkExists(networkId), "The network has not been added.");
Set<VirtualPort> virtualPortSet = networkIdVirtualPortSetMap.get(networkId);
if (virtualPortSet == null) {
virtualPortSet = new HashSet<>();
}
Device device = deviceIdVirtualDeviceMap.get(deviceId);
checkNotNull(device, "The device has not been created for deviceId: " + deviceId);
VirtualPort virtualPort = new DefaultVirtualPort(networkId, device, portNumber, realizedBy);
virtualPortSet.add(virtualPort);
networkIdVirtualPortSetMap.put(networkId, virtualPortSet);
return virtualPort;
}
示例5: updatePortState
import org.onosproject.incubator.net.virtual.DefaultVirtualPort; //导入依赖的package包/类
@Override
public void updatePortState(NetworkId networkId, DeviceId deviceId,
PortNumber portNumber, boolean isEnabled) {
checkState(networkExists(networkId), "No network with NetworkId %s exists.", networkId);
VirtualDevice device = deviceIdVirtualDeviceMap.get(new VirtualDeviceId(networkId, deviceId));
checkNotNull(device, "No device %s exists in NetworkId: %s", deviceId, networkId);
Set<VirtualPort> virtualPortSet = networkIdVirtualPortSetMap.get(networkId);
checkNotNull(virtualPortSet, "No port has been created for NetworkId: %s", networkId);
Optional<VirtualPort> virtualPortOptional = virtualPortSet.stream().filter(
p -> p.element().id().equals(deviceId) &&
p.number().equals(portNumber)).findFirst();
checkState(virtualPortOptional.isPresent(), "The virtual port has not been added.");
VirtualPort oldPort = virtualPortOptional.get();
if (oldPort.isEnabled() == isEnabled) {
log.debug("No change in port state - port not updated");
return;
}
VirtualPort newPort = new DefaultVirtualPort(networkId, device, portNumber, isEnabled,
oldPort.realizedBy());
virtualPortSet.remove(oldPort);
virtualPortSet.add(newPort);
networkIdVirtualPortSetMap.put(networkId, virtualPortSet);
notifyDelegate(new VirtualNetworkEvent(VirtualNetworkEvent.Type.VIRTUAL_PORT_UPDATED,
networkId, device, newPort));
log.debug("port state changed from {} to {}", oldPort.isEnabled(), isEnabled);
}
示例6: vPort
import org.onosproject.incubator.net.virtual.DefaultVirtualPort; //导入依赖的package包/类
private VirtualPort vPort(int portNumber) {
return new DefaultVirtualPort(NetworkId.networkId(20), new DefaultDevice(PID, DID, null, MFR, HW, SW, SN, CID),
PortNumber.portNumber(portNumber), new ConnectPoint(DID, PortNumber.portNumber(900)));
}