use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received 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.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project lispflowmapping by opendaylight.
the class AuthenticationKeyDataListener method onDataTreeChanged.
@Override
public synchronized void onDataTreeChanged(Collection<DataTreeModification<AuthenticationKey>> changes) {
for (DataTreeModification<AuthenticationKey> change : changes) {
final DataObjectModification<AuthenticationKey> mod = change.getRootNode();
if (ModificationType.DELETE == mod.getModificationType()) {
final AuthenticationKey authKey = mod.getDataBefore();
LOG.trace("Received deleted data");
LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
LOG.trace("Value: {}", authKey);
final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
akdb.removeAuthenticationKey(convertedAuthKey.getEid());
updatedEntries.put(convertedAuthKey.getEid(), System.currentTimeMillis());
} else if (ModificationType.WRITE == mod.getModificationType() || ModificationType.SUBTREE_MODIFIED == mod.getModificationType()) {
if (ModificationType.WRITE == mod.getModificationType()) {
LOG.trace("Received created data");
} else {
LOG.trace("Received updated data");
}
// Process newly created or updated authentication keys
final AuthenticationKey authKey = mod.getDataAfter();
LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
LOG.trace("Value: {}", authKey);
final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
akdb.addAuthenticationKey(convertedAuthKey.getEid(), convertedAuthKey.getMappingAuthkey());
updatedEntries.put(convertedAuthKey.getEid(), System.currentTimeMillis());
} else {
LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method getDefaultMapRequestBuilder.
/*
* PACKETS CREATION METHODS
*
* In general we return "Builders" so that the caller can customize the fields, but that means it also needs to
* call .build() on the received objects.
*/
/* Map-Request */
/**
* Create a default MapRequestBuilder object.
*
* @param eid the requested EID
* @return the MapRequestBuilder object
*/
static MapRequestBuilder getDefaultMapRequestBuilder(Eid eid) {
MapRequestBuilder mrBuilder = new MapRequestBuilder().setAuthoritative(false).setEidItem(new ArrayList<>()).setItrRloc(new ArrayList<>()).setMapDataPresent(true).setNonce((long) 4).setPitr(false).setProbe(false).setSmr(false).setSmrInvoked(false).setSourceEid(new SourceEidBuilder().setEid(DEFAULT_IPV4_EID).build()).setItrRloc(getDefaultItrRlocList(DEFAULT_IPV4_ITR_RLOC));
mrBuilder.getEidItem().add(new EidItemBuilder().setEid(eid).build());
return mrBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method getDefaultMappingRecordBuilder.
/**
* Create a default MappingRecordBuilder object.
*
* @param eid EID for the mapping record, if null, a default will be added
* @param rlocs RLOCs for the mapping record, if null, no locator record will be added
* @return the MappingRecordBuilder object
*/
static MappingRecordBuilder getDefaultMappingRecordBuilder(Eid eid, List<Rloc> rlocs) {
if (eid == null) {
eid = DEFAULT_IPV4_EID_PREFIX;
LOG.warn("getDefaultMappingRecordBuilder(): null EID received, using the default {}", DEFAULT_IPV4_EID_STRING);
}
MappingRecordBuilder mrb = new MappingRecordBuilder().setEid(eid).setAction(MappingRecord.Action.NoAction).setAuthoritative(false).setLocatorRecord(new ArrayList<>()).setMapVersion((short) 0).setRecordTtl(60).setSiteId(DEFAULT_SITE_ID).setXtrId(DEFAULT_XTR_ID).setTimestamp(System.currentTimeMillis());
// We want to allow for empty locator records, so we only add one if rloc is not null
if (rlocs != null) {
for (Rloc rloc : rlocs) {
mrb.getLocatorRecord().add(getDefaultLocatorBuilder(rloc).build());
}
}
return mrb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method getDefaultLocatorBuilder.
/**
* Create a default LocatorRecordBuilder object.
*
* @param rloc RLOC for the mapping record, if null, a default will be added
* @return the LocatorRecordBuilder object
*/
static LocatorRecordBuilder getDefaultLocatorBuilder(Rloc rloc) {
if (rloc == null) {
rloc = DEFAULT_IPV4_RLOC;
LOG.warn("getDefaultLocatorBuilder(): null RLOC received, using the default {}", DEFAULT_IPV4_RLOC_STRING);
}
return new LocatorRecordBuilder().setLocalLocator(true).setMulticastPriority((short) 255).setMulticastWeight((short) 0).setPriority((short) 1).setRlocProbed(false).setRouted(true).setWeight((short) 1).setKey(new LocatorRecordKey(LispAddressStringifier.getString(rloc))).setRloc(rloc);
}
Aggregations