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


Java Port.isEnabled方法代码示例

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


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

示例1: updatePort

import org.onosproject.net.Port; //导入方法依赖的package包/类
/**
 * Updates discovery helper state of the specified port.
 *
 * Adds a port to the discovery helper if up and discovery is enabled,
 * or calls {@link #removePort(Port)} otherwise.
 */
private void updatePort(LinkDiscovery discoverer, Port port) {
    if (port == null) {
        return;
    }
    if (port.number().isLogical()) {
        // silently ignore logical ports
        return;
    }

    if (rules.isSuppressed(port) || isBlacklisted(port)) {
        log.trace("LinkDiscovery from {} disabled by configuration", port);
        removePort(port);
        return;
    }

    // check if enabled and turn off discovery?
    if (!port.isEnabled()) {
        removePort(port);
        return;
    }

    discoverer.addPort(port);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:LldpLinkProvider.java

示例2: processLink

import org.onosproject.net.Port; //导入方法依赖的package包/类
private void processLink(Link link) {
    DeviceId srcId = link.src().deviceId();
    DeviceId dstId = link.dst().deviceId();
    Port srcPort = deviceService.getPort(srcId, link.src().port());
    Port dstPort = deviceService.getPort(dstId, link.dst().port());

    if (srcPort == null || dstPort == null) {
        return; //FIXME remove this in favor of below TODO
    }

    boolean active = deviceService.isAvailable(srcId) &&
            deviceService.isAvailable(dstId) &&
            // TODO: should update be queued if src or dstPort is null?
            //srcPort != null && dstPort != null &&
            srcPort.isEnabled() && dstPort.isEnabled();

    LinkDescription desc = new DefaultLinkDescription(link.src(), link.dst(), OPTICAL);
    if (active) {
        providerService.linkDetected(desc);
    } else {
        providerService.linkVanished(desc);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:OpticalLinkProvider.java

示例3: updatePort

import org.onosproject.net.Port; //导入方法依赖的package包/类
private DeviceEvent updatePort(Device device, Port oldPort,
                               Port newPort,
                               Map<PortNumber, Port> ports) {
    if (oldPort.isEnabled() != newPort.isEnabled() ||
            oldPort.type() != newPort.type() ||
            oldPort.portSpeed() != newPort.portSpeed() ||
            !AnnotationsUtil.isEqual(oldPort.annotations(), newPort.annotations())) {
        ports.put(oldPort.number(), newPort);
        return new DeviceEvent(PORT_UPDATED, device, newPort);
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:SimpleDeviceStore.java

示例4: run

import org.onosproject.net.Port; //导入方法依赖的package包/类
@Override
public void run() {
    Device device = event.subject();
    Port port = event.port();
    if (device == null) {
        log.error("Device is null.");
        return;
    }
    log.trace("{} {} {}", event.type(), event.subject(), event);
    final DeviceId deviceId = device.id();
    switch (event.type()) {
        case DEVICE_ADDED:
        case DEVICE_UPDATED:
            updateDevice(device).ifPresent(ld -> updatePorts(ld, deviceId));
            break;
        case PORT_ADDED:
        case PORT_UPDATED:
            if (port.isEnabled()) {
                updateDevice(device).ifPresent(ld -> updatePort(ld, port));
            } else {
                log.debug("Port down {}", port);
                removePort(port);
                providerService.linksVanished(new ConnectPoint(port.element().id(),
                                                               port.number()));
            }
            break;
        case PORT_REMOVED:
            log.debug("Port removed {}", port);
            removePort(port);
            providerService.linksVanished(new ConnectPoint(port.element().id(),
                                                           port.number()));
            break;
        case DEVICE_REMOVED:
        case DEVICE_SUSPENDED:
            log.debug("Device removed {}", deviceId);
            removeDevice(deviceId);
            providerService.linksVanished(deviceId);
            break;
        case DEVICE_AVAILABILITY_CHANGED:
            if (deviceService.isAvailable(deviceId)) {
                log.debug("Device up {}", deviceId);
                updateDevice(device).ifPresent(ld -> updatePorts(ld, deviceId));
            } else {
                log.debug("Device down {}", deviceId);
                removeDevice(deviceId);
                providerService.linksVanished(deviceId);
            }
            break;
        case PORT_STATS_UPDATED:
            break;
        default:
            log.debug("Unknown event {}", event);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:55,代码来源:LldpLinkProvider.java

示例5: isIncluded

import org.onosproject.net.Port; //导入方法依赖的package包/类
private boolean isIncluded(Port port) {
    return enabled && port.isEnabled() || disabled && !port.isEnabled() ||
            !enabled && !disabled;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:DevicePortsListCommand.java

示例6: populateRouterMacVlanFilters

import org.onosproject.net.Port; //导入方法依赖的package包/类
/**
 * Creates a filtering objective to permit all untagged packets with a
 * dstMac corresponding to the router's MAC address. For those pipelines
 * that need to internally assign vlans to untagged packets, this method
 * provides per-subnet vlan-ids as metadata.
 * <p>
 * Note that the vlan assignment is only done by the master-instance for a switch.
 * However we send the filtering objective from slave-instances as well, so
 * that drivers can obtain other information (like Router MAC and IP).
 *
 * @param deviceId  the switch dpid for the router
 * @return true if operation succeeds
 */
public boolean populateRouterMacVlanFilters(DeviceId deviceId) {
    log.debug("Installing per-port filtering objective for untagged "
            + "packets in device {}", deviceId);

    MacAddress deviceMac;
    try {
        deviceMac = config.getDeviceMac(deviceId);
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting populateRouterMacVlanFilters.");
        return false;
    }

    List<Port> devPorts = srManager.deviceService.getPorts(deviceId);
    if (devPorts != null && devPorts.size() == 0) {
        log.warn("Device {} ports not available. Unable to add MacVlan filters",
                 deviceId);
        return false;
    }
    int disabledPorts = 0, suppressedPorts = 0, filteredPorts = 0;
    for (Port port : devPorts) {
        ConnectPoint connectPoint = new ConnectPoint(deviceId, port.number());
        // TODO: Handles dynamic port events when we are ready for dynamic config
        SegmentRoutingAppConfig appConfig = srManager.cfgService
                .getConfig(srManager.appId, SegmentRoutingAppConfig.class);
        if (!port.isEnabled()) {
            disabledPorts++;
            continue;
        }
        if (appConfig != null && appConfig.suppressSubnet().contains(connectPoint)) {
            suppressedPorts++;
            continue;
        }
        Ip4Prefix portSubnet = config.getPortSubnet(deviceId, port.number());
        VlanId assignedVlan = (portSubnet == null)
                ? VlanId.vlanId(SegmentRoutingManager.ASSIGNED_VLAN_NO_SUBNET)
                : srManager.getSubnetAssignedVlanId(deviceId, portSubnet);

        FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
        fob.withKey(Criteria.matchInPort(port.number()))
            .addCondition(Criteria.matchEthDst(deviceMac))
            .addCondition(Criteria.matchVlanId(VlanId.NONE))
            .withPriority(SegmentRoutingService.DEFAULT_PRIORITY);
        // vlan assignment is valid only if this instance is master
        if (srManager.mastershipService.isLocalMaster(deviceId)) {
            TrafficTreatment tt = DefaultTrafficTreatment.builder()
                    .pushVlan().setVlanId(assignedVlan).build();
            fob.withMeta(tt);
        }
        fob.permit().fromApp(srManager.appId);
        log.debug("Sending filtering objective for dev/port:{}/{}", deviceId, port);
        filteredPorts++;
        ObjectiveContext context = new DefaultObjectiveContext(
            (objective) -> log.debug("Filter for {} populated", connectPoint),
            (objective, error) ->
            log.warn("Failed to populate filter for {}: {}", connectPoint, error));
        srManager.flowObjectiveService.filter(deviceId, fob.add(context));
    }
    log.info("Filtering on dev:{}, disabledPorts:{}, suppressedPorts:{}, filteredPorts:{}",
              deviceId, disabledPorts, suppressedPorts, filteredPorts);
    // XXX With this check, there is a chance that not all the ports that
    // should be filtered actually get filtered as long as one of them does.
    // Note there is no PORT_UPDATED event that makes the port go from disabled
    // to enabled state, because the ports comes enabled from the switch.
    // Check ONOS core, where the port becoming available and being declared
    // enabled is possibly not atomic.
    return (filteredPorts > 0) ? true : false;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:81,代码来源:RoutingRulePopulator.java

示例7: descriptionOf

import org.onosproject.net.Port; //导入方法依赖的package包/类
/**
 * Returns a description built from an existing port.
 *
 * @param port the device port
 * @return a PortDescription based on the port
 */
public static PortDescription descriptionOf(Port port) {
    checkNotNull(port, "Must supply non-null Port");
    final boolean isUp = port.isEnabled();
    return descriptionOfPort(port, isUp);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:OpticalPortOperator.java


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