當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultVirtualPort類代碼示例

本文整理匯總了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);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:27,代碼來源:VirtualPortCodec.java

示例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;
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:25,代碼來源:DistributedVirtualNetworkStore.java

示例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);
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:24,代碼來源:VirtualPortCodec.java

示例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;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:15,代碼來源:DistributedVirtualNetworkStore.java

示例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);
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:31,代碼來源:DistributedVirtualNetworkStore.java

示例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)));
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:5,代碼來源:ComparatorsTest.java


注:本文中的org.onosproject.incubator.net.virtual.DefaultVirtualPort類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。