本文整理汇总了Java中org.onosproject.net.device.DeviceEvent类的典型用法代码示例。如果您正苦于以下问题:Java DeviceEvent类的具体用法?Java DeviceEvent怎么用?Java DeviceEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeviceEvent类属于org.onosproject.net.device包,在下文中一共展示了DeviceEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testUpdatePortStatus
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Test
public final void testUpdatePortStatus() {
putDevice(DID1, SW1);
List<PortDescription> pds = Arrays.<PortDescription>asList(
new DefaultPortDescription(P1, true)
);
deviceStore.updatePorts(PID, DID1, pds);
Capture<InternalPortStatusEvent> message = new Capture<>();
Capture<MessageSubject> subject = new Capture<>();
Capture<Function<InternalPortStatusEvent, byte[]>> encoder = new Capture<>();
resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);
final DefaultPortDescription desc = new DefaultPortDescription(P1, false);
DeviceEvent event = deviceStore.updatePortStatus(PID, DID1, desc);
assertEquals(PORT_UPDATED, event.type());
assertDevice(DID1, SW1, event.subject());
assertEquals(P1, event.port().number());
assertFalse("Port is disabled", event.port().isEnabled());
verify(clusterCommunicator);
assertInternalPortStatusEvent(NID1, DID1, PID, desc, NO_ANNOTATION, message, subject, encoder);
assertTrue(message.hasCaptured());
}
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:GossipDeviceStoreTest.java
示例2: switchSuppressedByAnnotation
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
/**
* Checks that links on a reconfigured switch are properly removed.
*/
@Test
public void switchSuppressedByAnnotation() {
// add device to stub DeviceService
deviceService.putDevice(device(DID3));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
assertFalse("Device not added", provider.discoverers.isEmpty());
// update device in stub DeviceService with suppression config
deviceService.putDevice(device(DID3, DefaultAnnotations.builder()
.set(LldpLinkProvider.NO_LLDP, "true")
.build()));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_UPDATED, DID3));
// discovery on device is expected to be gone or stopped
LinkDiscovery linkDiscovery = provider.discoverers.get(DID3);
if (linkDiscovery != null) {
assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped());
}
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:LldpLinkProviderTest.java
示例3: switchSuppressByBlacklist
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Test
public void switchSuppressByBlacklist() {
// add device in stub DeviceService
deviceService.putDevice(device(DID3));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
// add deviveId to device blacklist
deviceBlacklist.add(DID3);
configListener.event(new NetworkConfigEvent(Type.CONFIG_ADDED,
DID3,
LinkDiscoveryFromDevice.class));
assertAfter(EVENT_MS, () -> {
// discovery helper for device is expected to be gone or stopped
LinkDiscovery linkDiscovery = provider.discoverers.get(DID3);
if (linkDiscovery != null) {
assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped());
}
});
}
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:LldpLinkProviderTest.java
示例4: portSuppressedByPortConfig
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
/**
* Checks that discovery on reconfigured port are properly restarted.
*/
@Test
public void portSuppressedByPortConfig() {
// add device in stub DeviceService without suppression configured
deviceService.putDevice(device(DID3));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
// suppressed port added to non-suppressed device
final long portno3 = 3L;
final Port port3 = port(DID3, portno3, true,
DefaultAnnotations.builder()
.set(LldpLinkProvider.NO_LLDP, "true")
.build());
deviceService.putPorts(DID3, port3);
deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID3, port3));
// discovery helper should be there turned on
assertFalse("Discoverer is expected to start", provider.discoverers.get(DID3).isStopped());
assertFalse("Discoverer should not contain the port there",
provider.discoverers.get(DID3).containsPort(portno3));
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:LldpLinkProviderTest.java
示例5: testAddDevice
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
/**
* Tests adding new Device to a openflow router.
*/
@Test
public void testAddDevice() {
ConnectPoint sw1eth4 = new ConnectPoint(DEVICE_ID, PortNumber.portNumber(4));
Set<InterfaceIpAddress> interfaceIpAddresses4 = Sets.newHashSet();
interfaceIpAddresses4
.add(new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24")));
Interface sw1Eth4 = new Interface(sw1eth4.deviceId().toString(), sw1eth4, interfaceIpAddresses4,
MacAddress.valueOf("00:00:00:00:00:04"), VlanId.NONE);
interfaces.add(sw1Eth4);
EasyMock.reset(flowObjectiveService);
setUpFlowObjectiveService();
deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED, dev3));
verify(flowObjectiveService);
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:ControlPlaneRedirectManagerTest.java
示例6: activate
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Activate
public void activate() {
backgroundService = newSingleThreadScheduledExecutor(
groupedThreads("onos/device", "manager-background", log));
localNodeId = clusterService.getLocalNode().id();
store.setDelegate(delegate);
eventDispatcher.addSink(DeviceEvent.class, listenerRegistry);
mastershipService.addListener(mastershipListener);
networkConfigService.addListener(networkConfigListener);
backgroundService.scheduleWithFixedDelay(() -> {
try {
mastershipCheck();
} catch (Exception e) {
log.error("Exception thrown during integrity check", e);
}
}, 1, 1, TimeUnit.MINUTES);
log.info("Started");
}
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:DeviceManager.java
示例7: updatePorts
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Override
public void updatePorts(DeviceId deviceId,
List<PortDescription> portDescriptions) {
checkNotNull(deviceId, DEVICE_ID_NULL);
checkNotNull(portDescriptions, PORT_DESC_LIST_NULL);
checkValidity();
if (!mastershipService.isLocalMaster(deviceId)) {
// Never been a master for this device
// any update will be ignored.
log.trace("Ignoring {} port updates on standby node. {}", deviceId, portDescriptions);
return;
}
portDescriptions = portDescriptions.stream()
.map(e -> consolidate(deviceId, e))
.map(this::ensureGeneric)
.collect(Collectors.toList());
List<DeviceEvent> events = store.updatePorts(this.provider().id(),
deviceId, portDescriptions);
if (events != null) {
for (DeviceEvent event : events) {
post(event);
}
}
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:DeviceManager.java
示例8: 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
示例9: testEventHostAvailableMatch
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
/**
* Tests an event for a host becoming available that matches an intent.
*
* @throws InterruptedException if the latch wait fails.
*/
@Test
public void testEventHostAvailableMatch() throws Exception {
// we will expect 2 delegate calls
delegate.latch = new CountDownLatch(2);
Device host = device("host1");
DeviceEvent deviceEvent = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, host);
reasons.add(deviceEvent);
Key key = Key.of(0x333L, APP_ID);
Collection<NetworkResource> resources = ImmutableSet.of(host.id());
tracker.addTrackedResources(key, resources);
reasons.add(deviceEvent);
TopologyEvent event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, topology, reasons);
listener.event(event);
assertThat(delegate.latch.await(WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS), is(true));
assertThat(delegate.intentIdsFromEvent, hasSize(1));
assertThat(delegate.compileAllFailedFromEvent, is(true));
assertThat(delegate.intentIdsFromEvent.get(0).toString(),
equalTo("0x333"));
}
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:ObjectiveTrackerTest.java
示例10: testEventHostUnavailableMatch
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
/**
* Tests an event for a host becoming unavailable that matches an intent.
*
* @throws InterruptedException if the latch wait fails.
*/
@Test
public void testEventHostUnavailableMatch() throws Exception {
Device host = device("host1");
DeviceEvent deviceEvent = new DeviceEvent(DeviceEvent.Type.DEVICE_REMOVED, host);
reasons.add(deviceEvent);
Key key = Key.of(0x333L, APP_ID);
Collection<NetworkResource> resources = ImmutableSet.of(host.id());
tracker.addTrackedResources(key, resources);
TopologyEvent event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, topology, reasons);
listener.event(event);
assertThat(delegate.latch.await(WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS), is(true));
assertThat(delegate.intentIdsFromEvent, hasSize(1));
assertThat(delegate.compileAllFailedFromEvent, is(false));
assertThat(delegate.intentIdsFromEvent.get(0).toString(), equalTo("0x333"));
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:ObjectiveTrackerTest.java
示例11: markOffline
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Override
public DeviceEvent markOffline(DeviceId deviceId) {
Map<ProviderId, DeviceDescriptions> providerDescs
= getOrCreateDeviceDescriptions(deviceId);
// locking device
synchronized (providerDescs) {
Device device = devices.get(deviceId);
if (device == null) {
return null;
}
boolean removed = availableDevices.remove(deviceId);
if (removed) {
// TODO: broadcast ... DOWN only?
return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device, null);
}
return null;
}
}
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:SimpleDeviceStore.java
示例12: removeDevice
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Override
public DeviceEvent removeDevice(DeviceId deviceId) {
Map<ProviderId, DeviceDescriptions> descs = getOrCreateDeviceDescriptions(deviceId);
synchronized (descs) {
Device device = devices.remove(deviceId);
// should DEVICE_REMOVED carry removed ports?
Map<PortNumber, Port> ports = devicePorts.get(deviceId);
if (ports != null) {
ports.clear();
}
availableDevices.remove(deviceId);
descs.clear();
return device == null ? null :
new DeviceEvent(DEVICE_REMOVED, device, null);
}
}
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:SimpleDeviceStore.java
示例13: testCreateOrUpdateDevice
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Test
public final void testCreateOrUpdateDevice() {
DeviceDescription description =
new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
HW, SW1, SN, CID);
DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description);
assertEquals(DEVICE_ADDED, event.type());
assertDevice(DID1, SW1, event.subject());
DeviceDescription description2 =
new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
HW, SW2, SN, CID);
DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2);
assertEquals(DEVICE_UPDATED, event2.type());
assertDevice(DID1, SW2, event2.subject());
assertNull("No change expected", deviceStore.createOrUpdateDevice(PID, DID1, description2));
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:SimpleDeviceStoreTest.java
示例14: testUpdatePortStatus
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Test
public final void testUpdatePortStatus() {
putDevice(DID1, SW1);
List<PortDescription> pds = Arrays.<PortDescription>asList(
new DefaultPortDescription(P1, true)
);
deviceStore.updatePorts(PID, DID1, pds);
DeviceEvent event = deviceStore.updatePortStatus(PID, DID1,
new DefaultPortDescription(P1, false));
assertEquals(PORT_UPDATED, event.type());
assertDevice(DID1, SW1, event.subject());
assertEquals(P1, event.port().number());
assertFalse("Port is disabled", event.port().isEnabled());
}
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:SimpleDeviceStoreTest.java
示例15: createOrUpdateDevice
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Override
public DeviceEvent createOrUpdateDevice(ProviderId providerId,
DeviceId deviceId,
DeviceDescription deviceDescription) {
NodeId master = mastershipService.getMasterFor(deviceId);
if (localNodeId.equals(master)) {
deviceDescriptions.put(new DeviceKey(providerId, deviceId), deviceDescription);
return refreshDeviceCache(providerId, deviceId);
} else {
// Only forward for ConfigProvider
// Forwarding was added as a workaround for ONOS-490
if (!providerId.scheme().equals("cfg")) {
return null;
}
DeviceInjectedEvent deviceInjectedEvent = new DeviceInjectedEvent(providerId, deviceId, deviceDescription);
return Futures.getUnchecked(
clusterCommunicator.sendAndReceive(deviceInjectedEvent,
DEVICE_INJECTED,
SERIALIZER::encode,
SERIALIZER::decode,
master));
}
}
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:ECDeviceStore.java
示例16: testMarkOffline
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Test
public final void testMarkOffline() {
putDevice(DID1, SW1);
assertTrue(deviceStore.isAvailable(DID1));
Capture<InternalDeviceEvent> message = new Capture<>();
Capture<MessageSubject> subject = new Capture<>();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>();
resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);
DeviceEvent event = deviceStore.markOffline(DID1);
assertEquals(DEVICE_AVAILABILITY_CHANGED, event.type());
assertDevice(DID1, SW1, event.subject());
assertFalse(deviceStore.isAvailable(DID1));
verify(clusterCommunicator);
// TODO: verify broadcast message
assertTrue(message.hasCaptured());
resetCommunicatorExpectingNoBroadcast(message, subject, encoder);
DeviceEvent event2 = deviceStore.markOffline(DID1);
assertNull("No change, no event", event2);
verify(clusterCommunicator);
assertFalse(message.hasCaptured());
}
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:GossipDeviceStoreTest.java
示例17: isRelevant
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Override
public boolean isRelevant(DeviceEvent event) {
if (mastershipService.getMasterFor(event.subject().id()) == null) {
return true;
}
return event.subject().annotations().value(AnnotationKeys.PROTOCOL)
.equals(SCHEME_NAME.toUpperCase()) &&
mastershipService.getMasterFor(event.subject().id()).equals(localNodeId);
}
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:NetconfDeviceProvider.java
示例18: switchAdd
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Test
public void switchAdd() {
DeviceEvent de = deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1);
deviceListener.event(de);
assertFalse("Device not added", provider.discoverers.isEmpty());
}
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:LldpLinkProviderTest.java
示例19: switchRemove
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Test
public void switchRemove() {
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_REMOVED, DID1));
final LinkDiscovery linkDiscovery = provider.discoverers.get(DID1);
if (linkDiscovery != null) {
// If LinkDiscovery helper is there after DEVICE_REMOVED,
// it should be stopped
assertTrue("Discoverer is not stopped", linkDiscovery.isStopped());
}
assertTrue("Device is not gone.", vanishedDpid(DID1));
}
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:LldpLinkProviderTest.java
示例20: portUp
import org.onosproject.net.device.DeviceEvent; //导入依赖的package包/类
@Test
public void portUp() {
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID1, port(DID1, 3, true)));
assertTrue("Port not added to discoverer",
provider.discoverers.get(DID1).containsPort(3L));
}
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:LldpLinkProviderTest.java
注:本文中的org.onosproject.net.device.DeviceEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论