Search in sources :

Example 46 with Received

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());
}
Also used : Logger(org.slf4j.Logger) NotificationService(org.opendaylight.controller.sal.binding.api.NotificationService) OutOfPixieDustNotificationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotificationBuilder) Assert.assertNotNull(org.junit.Assert.assertNotNull) LoggerFactory(org.slf4j.LoggerFactory) Test(org.junit.Test) ProviderContext(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext) NotificationProviderService(org.opendaylight.controller.sal.binding.api.NotificationProviderService) ListenerRegistration(org.opendaylight.yangtools.concepts.ListenerRegistration) ArrayList(java.util.ArrayList) BindingAwareConsumer(org.opendaylight.controller.sal.binding.api.BindingAwareConsumer) OpendaylightTestNotificationListener(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OpendaylightTestNotificationListener) List(java.util.List) BindingAwareProvider(org.opendaylight.controller.sal.binding.api.BindingAwareProvider) OutOfPixieDustNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotification) NotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener) Assert.assertEquals(org.junit.Assert.assertEquals) ProviderContext(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext) BindingAwareProvider(org.opendaylight.controller.sal.binding.api.BindingAwareProvider) NotificationProviderService(org.opendaylight.controller.sal.binding.api.NotificationProviderService) NotificationService(org.opendaylight.controller.sal.binding.api.NotificationService) BindingAwareConsumer(org.opendaylight.controller.sal.binding.api.BindingAwareConsumer) Test(org.junit.Test)

Example 47 with Received

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());
        }
    }
}
Also used : AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey)

Example 48 with Received

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;
}
Also used : SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) ArrayList(java.util.ArrayList) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) EidItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)

Example 49 with Received

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;
}
Also used : MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) ArrayList(java.util.ArrayList) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)

Example 50 with Received

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);
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) LocatorRecordKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordKey)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)29 ArrayList (java.util.ArrayList)24 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)23 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)18 BigInteger (java.math.BigInteger)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)16 List (java.util.List)13 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)13 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)13 Test (org.junit.Test)12 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)12 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 UnknownHostException (java.net.UnknownHostException)10 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)10 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)9 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)9 Collections (java.util.Collections)8 Map (java.util.Map)8 VpnInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface)8