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


Java DeviceEvent.Type方法代码示例

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


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

示例1: processDeviceEvent

import org.onosproject.net.device.DeviceEvent; //导入方法依赖的package包/类
private void processDeviceEvent(DeviceEvent event) {
    //FIXME handle the case where a device is suspended, this may or may not come up
    DeviceEvent.Type type = event.type();
    DeviceId id = event.subject().id();

    if (type == DEVICE_ADDED ||
            type == DEVICE_AVAILABILITY_CHANGED && deviceService.isAvailable(id)) {
        // When device is added or becomes available, add all its ports
        deviceService.getPorts(event.subject().id())
                .forEach(p -> addEdgePort(new ConnectPoint(id, p.number())));
    } else if (type == DEVICE_REMOVED ||
            type == DEVICE_AVAILABILITY_CHANGED && !deviceService.isAvailable(id)) {
        // When device is removed or becomes unavailable, remove all its ports
        deviceService.getPorts(event.subject().id())
                .forEach(p -> removeEdgePort(new ConnectPoint(id, p.number())));
        connectionPoints.remove(id);

    } else if (type == DeviceEvent.Type.PORT_ADDED ||
            type == PORT_UPDATED && event.port().isEnabled()) {
        addEdgePort(new ConnectPoint(id, event.port().number()));
    } else if (type == DeviceEvent.Type.PORT_REMOVED ||
            type == PORT_UPDATED && !event.port().isEnabled()) {
        removeEdgePort(new ConnectPoint(id, event.port().number()));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:EdgeManager.java

示例2: refreshDeviceCache

import org.onosproject.net.device.DeviceEvent; //导入方法依赖的package包/类
private DeviceEvent refreshDeviceCache(ProviderId providerId, DeviceId deviceId) {
    AtomicReference<DeviceEvent.Type> eventType = new AtomicReference<>();
    Device device = devices.compute(deviceId, (k, existingDevice) -> {
        Device newDevice = composeDevice(deviceId);
        if (existingDevice == null) {
            eventType.set(DEVICE_ADDED);
        } else {
            // We allow only certain attributes to trigger update
            boolean propertiesChanged =
                    !Objects.equals(existingDevice.hwVersion(), newDevice.hwVersion()) ||
                            !Objects.equals(existingDevice.swVersion(), newDevice.swVersion()) ||
                            !Objects.equals(existingDevice.providerId(), newDevice.providerId());
            boolean annotationsChanged =
                    !AnnotationsUtil.isEqual(existingDevice.annotations(), newDevice.annotations());

            // Primary providers can respond to all changes, but ancillary ones
            // should respond only to annotation changes.
            if ((providerId.isAncillary() && annotationsChanged) ||
                    (!providerId.isAncillary() && (propertiesChanged || annotationsChanged))) {
                boolean replaced = devices.replace(deviceId, existingDevice, newDevice);
                verify(replaced, "Replacing devices cache failed. PID:%s [expected:%s, found:%s, new=%s]",
                        providerId, existingDevice, devices.get(deviceId), newDevice);
                eventType.set(DEVICE_UPDATED);
            }
        }
        return newDevice;
    });
    if (eventType.get() != null && !providerId.isAncillary()) {
        markOnline(deviceId);
    }
    return eventType.get() != null ? new DeviceEvent(eventType.get(), device) : null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:ECDeviceStore.java

示例3: portEvent

import org.onosproject.net.device.DeviceEvent; //导入方法依赖的package包/类
@SuppressWarnings(value = {"unused"})
private DeviceEvent portEvent(DeviceEvent.Type type, DeviceId did, PortNumber port) {
    return new DeviceEvent(type, deviceService.getDevice(did),
                           deviceService.getPort(did, port));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:6,代码来源:LldpLinkProviderTest.java

示例4: deviceEvent

import org.onosproject.net.device.DeviceEvent; //导入方法依赖的package包/类
private DeviceEvent deviceEvent(DeviceEvent.Type type, DeviceId did) {
    return new DeviceEvent(type, deviceService.getDevice(did));

}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:LldpLinkProviderTest.java


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