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


Java Port类代码示例

本文整理汇总了Java中org.onosproject.net.Port的典型用法代码示例。如果您正苦于以下问题:Java Port类的具体用法?Java Port怎么用?Java Port使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testPostVirtualPort

import org.onosproject.net.Port; //导入依赖的package包/类
/**
 * Tests adding of new virtual port using POST via JSON stream.
 */
@Test
public void testPostVirtualPort() {
    NetworkId networkId = networkId3;
    DeviceId deviceId = devId22;
    DefaultAnnotations annotations = DefaultAnnotations.builder().build();
    Device physDevice = new DefaultDevice(null, DeviceId.deviceId("dev1"),
                                          null, null, null, null, null, null, annotations);
    Port port1 = new DefaultPort(physDevice, portNumber(1), true);
    expect(mockVnetAdminService.createVirtualPort(networkId, deviceId, portNumber(22), port1))
            .andReturn(vport22);

    replay(mockVnetAdminService);

    WebTarget wt = target();
    InputStream jsonStream = VirtualNetworkWebResourceTest.class
            .getResourceAsStream("post-virtual-port.json");
    String reqLocation = "vnets/" + networkId.toString()
            + "/devices/" + deviceId.toString() + "/ports";
    Response response = wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE)
            .post(Entity.json(jsonStream));
    assertThat(response.getStatus(), is(HttpURLConnection.HTTP_CREATED));

    verify(mockVnetAdminService);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:VirtualNetworkWebResourceTest.java

示例2: portData

import org.onosproject.net.Port; //导入依赖的package包/类
private ObjectNode portData(Port p, DeviceId id) {
    ObjectNode port = objectNode();
    LinkService ls = get(LinkService.class);
    String name = p.annotations().value(AnnotationKeys.PORT_NAME);

    port.put(ID, capitalizeFully(p.number().toString()));
    port.put(TYPE, capitalizeFully(p.type().toString()));
    port.put(SPEED, p.portSpeed());
    port.put(ENABLED, p.isEnabled());
    port.put(NAME, name != null ? name : "");

    Set<Link> links = ls.getEgressLinks(new ConnectPoint(id, p.number()));
    if (!links.isEmpty()) {
        StringBuilder egressLinks = new StringBuilder();
        for (Link l : links) {
            ConnectPoint dest = l.dst();
            egressLinks.append(dest.elementId()).append("/")
                    .append(dest.port()).append(" ");
        }
        port.put(LINK_DEST, egressLinks.toString());
    }

    return port;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:DeviceViewMessageHandler.java

示例3: otuPortDescription

import org.onosproject.net.Port; //导入依赖的package包/类
/**
 * Creates OTU port description based on the supplied information.
 *
 * @param number        port number
 * @param isEnabled     port enabled state
 * @param signalType    OTU client signal type
 * @param annotations   key/value annotations map
 */
public static PortDescription otuPortDescription(PortNumber number,
                                                 boolean isEnabled,
                                                 OtuSignalType signalType,
                                                 SparseAnnotations annotations) {
    Builder builder = DefaultAnnotations.builder();
    builder.putAll(annotations);

    builder.set(SIGNAL_TYPE, signalType.toString());

    long portSpeed = 0; // TODO specify appropriate value?
    return new DefaultPortDescription(number,
                                      isEnabled,
                                      Port.Type.OTU,
                                      portSpeed,
                                      builder.build());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:OtuPortHelper.java

示例4: queryOchTributarySlots

import org.onosproject.net.Port; //导入依赖的package包/类
private Set<TributarySlot> queryOchTributarySlots(Port ochPort) {
    OduSignalType signalType = null;
    if (ochPort instanceof org.onosproject.net.OchPort) {
        // remove once deprecation of old OchPort model is done
        signalType = ((org.onosproject.net.OchPort) ochPort).signalType();
    }
    if (ochPort instanceof OchPort) {
        signalType = ((OchPort) ochPort).signalType();
    }

    if (signalType == null) {
        log.warn("{} was not an OchPort", ochPort);
        return Collections.emptySet();
    }

    switch (signalType) {
        case ODU2:
            return ENTIRE_ODU2_TRIBUTARY_SLOTS;
        case ODU4:
            return ENTIRE_ODU4_TRIBUTARY_SLOTS;
        default:
            log.error("Unsupported signal type {} for {}", signalType, ochPort);
            return Collections.emptySet();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:DefaultTributarySlotQuery.java

示例5: decode

import org.onosproject.net.Port; //导入依赖的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

示例6: mapPort

import org.onosproject.net.Port; //导入依赖的package包/类
@Override
protected Optional<OchPort> mapPort(Port port) {
    if (port instanceof OchPort) {
        return Optional.of((OchPort) port);
    } else if (port instanceof org.onosproject.net.OchPort) {
        // TODO remove after deprecation of old OchPort is complete

        // translate to new OchPort
        org.onosproject.net.OchPort old = (org.onosproject.net.OchPort) port;
        return Optional.of(new DefaultOchPort(old,
                                              old.signalType(),
                                              old.isTunable(),
                                              old.lambda()));
    }

    return OchPortHelper.asOchPort(port);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:OchPortMapper.java

示例7: ochPortDescription

import org.onosproject.net.Port; //导入依赖的package包/类
/**
 * Creates OCh port DefaultPortDescription based on the supplied information.
 *
 * @param number      port number
 * @param isEnabled   port enabled state
 * @param signalType  ODU signal type
 * @param isTunable   tunable wavelength capability
 * @param lambda      OCh signal
 * @param annotationsIn key/value annotations map
 * @return OCh port DefaultPortDescription with OCh annotations
 */
public static PortDescription ochPortDescription(PortNumber number,
                                                 boolean isEnabled,
                                                 OduSignalType signalType,
                                                 boolean isTunable,
                                                 OchSignal lambda,
                                                 SparseAnnotations annotationsIn) {

    Builder builder = DefaultAnnotations.builder();
    builder.putAll(annotationsIn);

    builder.set(TUNABLE, String.valueOf(isTunable));
    builder.set(LAMBDA, OchSignalCodec.encode(lambda).toString());
    builder.set(SIGNAL_TYPE, signalType.toString());

    DefaultAnnotations annotations = builder.build();
    long portSpeed = 0; // FIXME assign appropriate value
    return new DefaultPortDescription(number, isEnabled, Port.Type.OCH, portSpeed, annotations);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:OchPortHelper.java

示例8: buildPortDescriptions

import org.onosproject.net.Port; //导入依赖的package包/类
private List<PortDescription> buildPortDescriptions(PcepDpid dpid,
                                                    Port port,
                                                    PortType portType) {

    List<PortDescription> portList;

    if (portMap.containsKey(dpid.value())) {
        portList = portMap.get(dpid.value());
    } else {
        portList = new ArrayList<>();
    }
    if (port != null && portType != null) {
        portList.add(buildPortDescription(port, portType));
    }

    portMap.put(dpid.value(), portList);
    return portList;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:PcepTopologyProvider.java

示例9: testEquality

import org.onosproject.net.Port; //导入依赖的package包/类
@Test
public void testEquality() {
    DefaultVirtualDevice device1 =
            new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue1));
    DefaultVirtualDevice device2 =
            new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue2));

    Port portA = new DefaultPort(device1, PortNumber.portNumber(1), true);
    Port portB = new DefaultPort(device1, PortNumber.portNumber(2), true);
    Port portC = new DefaultPort(device2, PortNumber.portNumber(2), true);

    DefaultVirtualPort port1 =
            new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(1), portA);
    DefaultVirtualPort port2 =
            new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(1), portA);
    DefaultVirtualPort port3 =
            new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(2), portB);
    DefaultVirtualPort port4 =
            new DefaultVirtualPort(NetworkId.networkId(1), device2, PortNumber.portNumber(2), portC);


    new EqualsTester().addEqualityGroup(port1, port2).addEqualityGroup(port3)
            .addEqualityGroup(port4).testEquals();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:DefaultVirtualPortTest.java

示例10: asOtuPort

import org.onosproject.net.Port; //导入依赖的package包/类
public static Optional<OtuPort> asOtuPort(Port port) {
    if (port instanceof OtuPort) {
        return Optional.of((OtuPort) port);
    }

    try {
        Annotations an = port.annotations();

        OtuSignalType signalType = Enum.valueOf(OtuSignalType.class,
                                                an.value(SIGNAL_TYPE));


        // Note: OTU specific annotations is not filtered-out here.
        //       DefaultOtuPort should filter them, if necessary.
        return Optional.of(new DefaultOtuPort(port, signalType));

    } catch (NullPointerException | IllegalArgumentException e) {

        log.warn("{} was not well-formed Otu port.", port, e);
        return Optional.empty();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:OtuPortHelper.java

示例11: mapPort

import org.onosproject.net.Port; //导入依赖的package包/类
@Override
protected Optional<OmsPort> mapPort(Port port) {
    if (port instanceof OmsPort) {
        return Optional.of((OmsPort) port);
    } else if (port instanceof org.onosproject.net.OmsPort) {
        // TODO remove after deprecation of old OmsPort is complete

        // translate to new OmsPort
        org.onosproject.net.OmsPort old = (org.onosproject.net.OmsPort) port;
        return Optional.of(new DefaultOmsPort(old,
                                              old.minFrequency(),
                                              old.maxFrequency(),
                                              old.grid()));
    }

    return OmsPortHelper.asOmsPort(port);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:OmsPortMapper.java

示例12: execute

import org.onosproject.net.Port; //导入依赖的package包/类
@Override
protected void execute() {
    DeviceService deviceService = get(DeviceService.class);
    DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
    Device dev = deviceService.getDevice(DeviceId.deviceId(uri));
    if (dev == null) {
        print(" %s", "Device does not exist");
        return;
    }
    PortNumber pnum = PortNumber.portNumber(portNumber);
    Port p = deviceService.getPort(dev.id(), pnum);
    if (p == null) {
        print(" %s", "Port does not exist");
        return;
    }
    if (portState.equals("enable")) {
        deviceAdminService.changePortState(dev.id(), pnum, true);
    } else if (portState.equals("disable")) {
        deviceAdminService.changePortState(dev.id(), pnum, false);
    } else {
        print(" %s", "State must be enable or disable");
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:DevicePortStateCommand.java

示例13: jsonPorts

import org.onosproject.net.Port; //导入依赖的package包/类
/**
 * Produces JSON array containing ports of the specified device.
 *
 * @param service device service
 * @param mapper  object mapper
 * @param device  infrastructure devices
 * @return JSON array
 */
public JsonNode jsonPorts(DeviceService service, ObjectMapper mapper, Device device) {
    ObjectNode result = mapper.createObjectNode();
    ArrayNode ports = mapper.createArrayNode();
    for (Port port : service.getPorts(device.id())) {
        if (isIncluded(port)) {
            ports.add(mapper.createObjectNode()
                              .put("port", portName(port.number()))
                              .put("isEnabled", port.isEnabled())
                              .put("type", port.type().toString().toLowerCase())
                              .put("portSpeed", port.portSpeed())
                              .set("annotations", annotations(mapper, port.annotations())));
        }
    }
    result.set("device", jsonForEntity(device, Device.class));
    result.set("ports", ports);
    return result;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:DevicePortsListCommand.java

示例14: createConnectPoint

import org.onosproject.net.Port; //导入依赖的package包/类
private ConnectPoint createConnectPoint(String devicePortString) {
    String[] splitted = devicePortString.split("/");

    checkArgument(splitted.length == 2,
            "Connect point must be in \"deviceUri/portNumber\" format");

    DeviceId deviceId = DeviceId.deviceId(splitted[0]);
    DeviceService deviceService = get(DeviceService.class);

    List<Port> ports = deviceService.getPorts(deviceId);

    for (Port port : ports) {
        if (splitted[1].equals(port.number().name())) {
            return new ConnectPoint(deviceId, port.number());
        }
    }

    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:AddOpticalIntentCommand.java

示例15: hasEnoughBandwidth

import org.onosproject.net.Port; //导入依赖的package包/类
private boolean hasEnoughBandwidth(ConnectPoint cp) {
    if (cp.elementId() instanceof DeviceId) {
        Device device =  deviceService.getDevice(cp.deviceId());
        Device.Type type = device.type();

        if (isTransportLayer(type)) {
            // Check if the port has enough capacity
            Port port = deviceService.getPort(cp.deviceId(), cp.port());
            if (port instanceof OduCltPort || port instanceof OchPort) {
                // Port with capacity
                return bandwidth.bps() < port.portSpeed() * 1000000.0;
            } else {
                // Port without valid capacity (OMS port, etc.)
                return true;
            }
        } else {
            // Check if enough amount of bandwidth resource remains
            ContinuousResource resource = Resources.continuous(cp.deviceId(), cp.port(), Bandwidth.class)
                    .resource(bandwidth.bps());
            return resourceService.isAvailable(resource);
        }
    }
    return false;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:OpticalPathProvisioner.java


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