use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications in project openflowplugin by opendaylight.
the class Activator method onSessionInitialized.
/**
* Invoked when consumer is registered to the MD-SAL.
*/
@Override
public void onSessionInitialized(ConsumerContext session) {
LOG.info("inSessionInitialized() passing");
/**
* We create instance of our LearningSwitchManager
* and set all required dependencies,
*
* which are
* Data Broker (data storage service) - for configuring flows and reading stored switch state
* PacketProcessingService - for sending out packets
* NotificationService - for receiving notifications such as packet in.
*/
learningSwitch = new LearningSwitchManagerMultiImpl();
learningSwitch.setDataBroker(session.getSALService(DataBroker.class));
learningSwitch.setPacketProcessingService(session.getRpcService(PacketProcessingService.class));
learningSwitch.setNotificationService(session.getSALService(NotificationService.class));
learningSwitch.start();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications in project openflowplugin by opendaylight.
the class ConnectionAdapterImplTest method testConsume.
/**
* Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications.
*/
@Test
public void testConsume() {
DataObject message = new EchoRequestMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
message = new ErrorMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message);
message = new ExperimenterMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message);
message = new FlowRemovedMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message);
message = new HelloMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onHelloMessage((HelloMessage) message);
message = new MultipartReplyMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message);
message = new PacketInMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message);
message = new PortStatusMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message);
message = new SwitchIdleEventBuilder().build();
adapter.consume(message);
verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message);
message = new DisconnectEventBuilder().build();
adapter.consume(message);
verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message);
message = new EchoRequestMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications in project netvirt by opendaylight.
the class Ipv6ServiceInterfaceEventListener method remove.
@Override
public void remove(InstanceIdentifier<Interface> key, Interface del) {
LOG.debug("Port removed {}, {}", key, del);
if (!L2vlan.class.equals(del.getType())) {
return;
}
// In ipv6service, we are only interested in the notification for NeutronPort, so we skip other notifications
List<String> ofportIds = del.getLowerLayerIf();
if (ofportIds == null || ofportIds.isEmpty() || !isNeutronPort(del.getName())) {
return;
}
if (!ipv6ServiceEosHandler.isClusterOwner()) {
LOG.trace("Not a cluster Owner, skipping further IPv6 processing on this node.");
return;
}
Uuid portId = new Uuid(del.getName());
VirtualPort port = ifMgr.obtainV6Interface(portId);
if (port == null) {
LOG.info("Port {} does not include IPv6Address, skipping.", portId);
return;
}
String jobKey = Ipv6ServiceUtils.buildIpv6MonitorJobKey(portId.getValue());
jobCoordinator.enqueueJob(jobKey, () -> {
if (port.getServiceBindingStatus()) {
// Unbind Service
ipv6ServiceUtils.unbindIpv6Service(portId.getValue());
port.setServiceBindingStatus(false);
VirtualNetwork vnet = ifMgr.getNetwork(port.getNetworkID());
if (null != vnet) {
Uint64 dpId = port.getDpId();
vnet.updateDpnPortInfo(dpId, port.getOfPort(), portId, Ipv6ServiceConstants.DEL_ENTRY);
}
}
VirtualPort routerPort = ifMgr.getRouterV6InterfaceForNetwork(port.getNetworkID());
ifMgr.handleInterfaceStateEvent(port, ipv6ServiceUtils.getDpIdFromInterfaceState(del), routerPort, del.getIfIndex(), Ipv6ServiceConstants.DEL_FLOW);
return Collections.emptyList();
}, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications in project controller by opendaylight.
the class NotificationIT method notificationTest.
/**
* test of delivering of notification
* @throws Exception
*/
@Test
public void notificationTest() throws Exception {
LOG.info("The registration of the Provider 1.");
AbstractTestProvider provider1 = new AbstractTestProvider() {
@Override
public void onSessionInitiated(ProviderContext session) {
notifyProviderService = session.getSALService(NotificationProviderService.class);
}
};
// registerProvider method calls onSessionInitiated method above
broker.registerProvider(provider1);
assertNotNull(notifyProviderService);
LOG.info("The registration of the Consumer 1. It retrieves Notification Service " + "from MD-SAL and registers OpendaylightTestNotificationListener as notification listener");
BindingAwareConsumer consumer1 = session -> {
NotificationService notificationService = session.getSALService(NotificationService.class);
assertNotNull(notificationService);
listener1Reg = notificationService.registerNotificationListener(listener1);
};
// registerConsumer method calls onSessionInitialized method above
broker.registerConsumer(consumer1);
assertNotNull(listener1Reg);
LOG.info("The notification of type FlowAdded with cookie ID 0 is created. The " + "delay 100ms to make sure that the notification was delivered to " + "listener.");
notifyProviderService.publish(noDustNotification("rainy day", 42));
Thread.sleep(100);
/**
* Check that one notification was delivered and has correct cookie.
*/
assertEquals(1, listener1.notificationBag.size());
assertEquals("rainy day", listener1.notificationBag.get(0).getReason());
assertEquals(42, listener1.notificationBag.get(0).getDaysTillNewDust().intValue());
LOG.info("The registration of the Consumer 2. SalFlowListener is registered " + "registered as notification listener.");
BindingAwareProvider provider = session -> listener2Reg = session.getSALService(NotificationProviderService.class).registerNotificationListener(listener2);
// registerConsumer method calls onSessionInitialized method above
broker.registerProvider(provider);
LOG.info("3 notifications are published");
notifyProviderService.publish(noDustNotification("rainy day", 5));
notifyProviderService.publish(noDustNotification("rainy day", 10));
notifyProviderService.publish(noDustNotification("tax collector", 2));
/**
* The delay 100ms to make sure that the notifications were delivered to
* listeners.
*/
Thread.sleep(100);
/**
* Check that 3 notification was delivered to both listeners (first one
* received 4 in total, second 3 in total).
*/
assertEquals(4, listener1.notificationBag.size());
assertEquals(3, listener2.notificationBag.size());
/**
* The second listener is closed (unregistered)
*/
listener2Reg.close();
LOG.info("The notification 5 is published");
notifyProviderService.publish(noDustNotification("entomologist hunt", 10));
/**
* The delay 100ms to make sure that the notification was delivered to
* listener.
*/
Thread.sleep(100);
/**
* Check that first consumer received 5 notifications in total, second
* consumer received only three. Last notification was never received by
* second consumer because its listener was unregistered.
*/
assertEquals(5, listener1.notificationBag.size());
assertEquals(3, listener2.notificationBag.size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications in project lispflowmapping by opendaylight.
the class MappingDataListener method onDataTreeChanged.
@Override
public void onDataTreeChanged(Collection<DataTreeModification<Mapping>> changes) {
for (DataTreeModification<Mapping> change : changes) {
final DataObjectModification<Mapping> mod = change.getRootNode();
if (ModificationType.DELETE == mod.getModificationType()) {
// Process deleted mappings
final Mapping mapping = mod.getDataBefore();
// before being persisted, except for cluster slaves
if (mapping.getOrigin() == MappingOrigin.Southbound && mapSystem.isMaster()) {
continue;
}
LOG.trace("Received deleted data");
LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
LOG.trace("Value: {}", mapping);
final Mapping convertedMapping = convertToBinaryIfNecessary(mapping);
mapSystem.removeMapping(convertedMapping.getOrigin(), convertedMapping.getMappingRecord().getEid());
} else if (ModificationType.SUBTREE_MODIFIED == mod.getModificationType() || ModificationType.WRITE == mod.getModificationType()) {
final Mapping mapping = mod.getDataAfter();
// SB notifications
if (mapping.getOrigin() == MappingOrigin.Southbound && mapSystem.isMaster()) {
continue;
}
final Mapping convertedMapping = convertToBinaryIfNecessary(mapping);
Eid convertedEid = convertedMapping.getMappingRecord().getEid();
if (ModificationType.SUBTREE_MODIFIED == mod.getModificationType()) {
LOG.trace("Received update data");
LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
LOG.trace("Value: {}", mapping);
mapSystem.updateMapping(convertedMapping.getOrigin(), convertedEid, new MappingData(convertedMapping.getMappingRecord()));
} else {
LOG.trace("Received write data");
LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
LOG.trace("Value: {}", mapping);
mapSystem.addMapping(convertedMapping.getOrigin(), convertedEid, new MappingData(convertedMapping.getMappingRecord()));
}
} else {
LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
}
}
}
Aggregations