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


Java VlanQuery類代碼示例

本文整理匯總了Java中org.onosproject.net.behaviour.VlanQuery的典型用法代碼示例。如果您正苦於以下問題:Java VlanQuery類的具體用法?Java VlanQuery怎麽用?Java VlanQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


VlanQuery類屬於org.onosproject.net.behaviour包,在下文中一共展示了VlanQuery類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: queryVlanIds

import org.onosproject.net.behaviour.VlanQuery; //導入依賴的package包/類
private Set<VlanId> queryVlanIds(DeviceId device, PortNumber port) {
    try {
        DriverHandler handler = driverService.createHandler(device);
        if (handler == null || !handler.hasBehaviour(VlanQuery.class)) {
            return ImmutableSet.of();
        }

        VlanQuery query = handler.behaviour(VlanQuery.class);
        if (query == null) {
            return ImmutableSet.of();
        }
        return query.queryVlanIds(port);
    } catch (ItemNotFoundException e) {
        return ImmutableSet.of();
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:17,代碼來源:ResourceDeviceListener.java

示例2: printVlans

import org.onosproject.net.behaviour.VlanQuery; //導入依賴的package包/類
private void printVlans(Port port) {
    DeviceService deviceService = get(DeviceService.class);
    DriverService driverService = get(DriverService.class);

    DeviceId deviceId = (DeviceId) port.element().id();
    Device device = deviceService.getDevice(deviceId);

    if (!device.is(VlanQuery.class)) {
        // The relevant behavior is not supported by the device.
        print(NO_SUPPORT);
        return;
    }

    DriverHandler h = driverService.createHandler(deviceId);
    VlanQuery vlanQuery = h.behaviour(VlanQuery.class);

    try {
        Set<VlanId> vlanIds = vlanQuery.queryVlanIds(port.number());

        if (vlanIds.isEmpty()) {
            print(VLAN_NOT_AVAILABLE);
        } else {
            print(AVAIL_VLANS, getRanges(vlanIds).toString());
        }
    } catch (Exception e) {
        print(FAILURE + e.getMessage());
    }
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:29,代碼來源:PortQueryVlansCommand.java


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