Search in sources :

Example 1 with Registration

use of org.opendaylight.yangtools.concepts.Registration in project controller by opendaylight.

the class ModuleShardBackendResolverTest method testNotifyWhenBackendInfoIsStale.

@SuppressWarnings("unchecked")
@Test
public void testNotifyWhenBackendInfoIsStale() {
    final RegisterForShardAvailabilityChanges regMessage = shardManagerProbe.expectMsgClass(RegisterForShardAvailabilityChanges.class);
    Registration mockReg = mock(Registration.class);
    shardManagerProbe.reply(new Status.Success(mockReg));
    Consumer<Long> mockCallback = mock(Consumer.class);
    final Registration callbackReg = moduleShardBackendResolver.notifyWhenBackendInfoIsStale(mockCallback);
    regMessage.getCallback().accept(DefaultShardStrategy.DEFAULT_SHARD);
    verify(mockCallback, timeout(5000)).accept((long) 0);
    reset(mockCallback);
    callbackReg.close();
    regMessage.getCallback().accept(DefaultShardStrategy.DEFAULT_SHARD);
    Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
    verifyNoMoreInteractions(mockCallback);
}
Also used : Status(akka.actor.Status) Registration(org.opendaylight.yangtools.concepts.Registration) RegisterForShardAvailabilityChanges(org.opendaylight.controller.cluster.datastore.shardmanager.RegisterForShardAvailabilityChanges) Test(org.junit.Test)

Example 2 with Registration

use of org.opendaylight.yangtools.concepts.Registration in project bgpcep by opendaylight.

the class BGPActivator method start.

@Override
public List<Registration> start(final BGPExtensionProviderContext context) {
    final List<Registration> regs = new ArrayList<>();
    regs.add(context.registerSubsequentAddressFamily(FlowspecSubsequentAddressFamily.class, FLOWSPEC_SAFI));
    regs.add(context.registerSubsequentAddressFamily(FlowspecL3vpnSubsequentAddressFamily.class, FLOWSPEC_L3VPN_SAFI));
    final Ipv4NextHopParserSerializer ipv4NextHopParser = new Ipv4NextHopParserSerializer();
    final Ipv6NextHopParserSerializer ipv6NextHopParser = new Ipv6NextHopParserSerializer();
    final SimpleFlowspecIpv4NlriParser fsIpv4Handler = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
    final SimpleFlowspecIpv6NlriParser fsIpv6Handler = new SimpleFlowspecIpv6NlriParser(SAFI.FLOWSPEC);
    regs.add(context.registerNlriParser(Ipv4AddressFamily.class, FlowspecSubsequentAddressFamily.class, fsIpv4Handler, ipv4NextHopParser, Ipv4NextHopCase.class));
    regs.add(context.registerNlriParser(Ipv6AddressFamily.class, FlowspecSubsequentAddressFamily.class, fsIpv6Handler, ipv6NextHopParser, Ipv6NextHopCase.class));
    regs.add(context.registerNlriSerializer(FlowspecRoutes.class, fsIpv4Handler));
    regs.add(context.registerNlriSerializer(FlowspecIpv6Routes.class, fsIpv6Handler));
    final FlowspecL3vpnIpv4NlriParser fsL3vpnIpv4Handler = new FlowspecL3vpnIpv4NlriParser(SAFI.FLOWSPEC_VPN);
    final FlowspecL3vpnIpv6NlriParser fsL3vpnIpv6Handler = new FlowspecL3vpnIpv6NlriParser(SAFI.FLOWSPEC_VPN);
    regs.add(context.registerNlriParser(Ipv4AddressFamily.class, FlowspecL3vpnSubsequentAddressFamily.class, fsL3vpnIpv4Handler, ipv4NextHopParser, Ipv4NextHopCase.class));
    regs.add(context.registerNlriParser(Ipv6AddressFamily.class, FlowspecL3vpnSubsequentAddressFamily.class, fsL3vpnIpv6Handler, ipv6NextHopParser, Ipv6NextHopCase.class));
    regs.add(context.registerNlriSerializer(FlowspecL3vpnIpv4Routes.class, fsL3vpnIpv4Handler));
    regs.add(context.registerNlriSerializer(FlowspecL3vpnIpv6Routes.class, fsL3vpnIpv6Handler));
    final RedirectAsTwoOctetEcHandler redirect2bHandler = new RedirectAsTwoOctetEcHandler();
    regs.add(context.registerExtendedCommunityParser(redirect2bHandler.getType(true), redirect2bHandler.getSubType(), redirect2bHandler));
    regs.add(context.registerExtendedCommunitySerializer(RedirectExtendedCommunityCase.class, redirect2bHandler));
    final TrafficActionEcHandler trafficActionHandler = new TrafficActionEcHandler();
    regs.add(context.registerExtendedCommunityParser(trafficActionHandler.getType(true), trafficActionHandler.getSubType(), trafficActionHandler));
    regs.add(context.registerExtendedCommunitySerializer(TrafficActionExtendedCommunityCase.class, trafficActionHandler));
    final TrafficMarkingEcHandler trafficMarkingHandler = new TrafficMarkingEcHandler();
    regs.add(context.registerExtendedCommunityParser(trafficMarkingHandler.getType(true), trafficMarkingHandler.getSubType(), trafficMarkingHandler));
    regs.add(context.registerExtendedCommunitySerializer(TrafficMarkingExtendedCommunityCase.class, trafficMarkingHandler));
    final TrafficRateEcHandler trafficRateEcHandler = new TrafficRateEcHandler();
    regs.add(context.registerExtendedCommunityParser(trafficRateEcHandler.getType(true), trafficRateEcHandler.getSubType(), trafficRateEcHandler));
    regs.add(context.registerExtendedCommunitySerializer(TrafficRateExtendedCommunityCase.class, trafficRateEcHandler));
    final RedirectIpv6EcHandler redirectIpv6EcHandler = new RedirectIpv6EcHandler();
    regs.add(context.registerExtendedCommunityParser(redirectIpv6EcHandler.getType(true), redirectIpv6EcHandler.getSubType(), redirectIpv6EcHandler));
    regs.add(context.registerExtendedCommunitySerializer(RedirectIpv6ExtendedCommunityCase.class, redirectIpv6EcHandler));
    final RedirectAsFourOctetEcHandler redirect4bHandler = new RedirectAsFourOctetEcHandler();
    regs.add(context.registerExtendedCommunityParser(redirect4bHandler.getType(true), redirect4bHandler.getSubType(), redirect4bHandler));
    regs.add(context.registerExtendedCommunitySerializer(RedirectAs4ExtendedCommunityCase.class, redirect4bHandler));
    final RedirectIpv4EcHandler redirectIpv4Handler = new RedirectIpv4EcHandler();
    regs.add(context.registerExtendedCommunityParser(redirectIpv4Handler.getType(true), redirectIpv4Handler.getSubType(), redirectIpv4Handler));
    regs.add(context.registerExtendedCommunitySerializer(RedirectIpv4ExtendedCommunityCase.class, redirectIpv4Handler));
    final RedirectIpNextHopEcHandler redirectIpNhHandler = new RedirectIpNextHopEcHandler();
    regs.add(context.registerExtendedCommunityParser(redirectIpNhHandler.getType(true), redirectIpNhHandler.getSubType(), redirectIpNhHandler));
    regs.add(context.registerExtendedCommunitySerializer(RedirectIpNhExtendedCommunityCase.class, redirectIpNhHandler));
    return regs;
}
Also used : Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily) FlowspecL3vpnIpv4Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.ipv4.routes.FlowspecL3vpnIpv4Routes) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) RedirectIpv6EcHandler(org.opendaylight.protocol.bgp.flowspec.extended.communities.RedirectIpv6EcHandler) ArrayList(java.util.ArrayList) RedirectIpv6ExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv6ExtendedCommunityCase) RedirectAsFourOctetEcHandler(org.opendaylight.protocol.bgp.flowspec.extended.communities.RedirectAsFourOctetEcHandler) TrafficRateEcHandler(org.opendaylight.protocol.bgp.flowspec.extended.communities.TrafficRateEcHandler) FlowspecL3vpnSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.FlowspecL3vpnSubsequentAddressFamily) RedirectExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectExtendedCommunityCase) RedirectIpv4ExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv4ExtendedCommunityCase) Registration(org.opendaylight.yangtools.concepts.Registration) RedirectAsTwoOctetEcHandler(org.opendaylight.protocol.bgp.flowspec.extended.communities.RedirectAsTwoOctetEcHandler) Ipv4NextHopParserSerializer(org.opendaylight.protocol.bgp.inet.codec.nexthop.Ipv4NextHopParserSerializer) Ipv6NextHopParserSerializer(org.opendaylight.protocol.bgp.inet.codec.nexthop.Ipv6NextHopParserSerializer) FlowspecRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.routes.FlowspecRoutes) FlowspecL3vpnIpv6NlriParser(org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv6.FlowspecL3vpnIpv6NlriParser) TrafficMarkingEcHandler(org.opendaylight.protocol.bgp.flowspec.extended.communities.TrafficMarkingEcHandler) RedirectIpNextHopEcHandler(org.opendaylight.protocol.bgp.flowspec.extended.communities.RedirectIpNextHopEcHandler) TrafficMarkingExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.TrafficMarkingExtendedCommunityCase) Ipv4NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCase) TrafficRateExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.TrafficRateExtendedCommunityCase) Ipv6NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv6NextHopCase) FlowspecL3vpnIpv4NlriParser(org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv4.FlowspecL3vpnIpv4NlriParser) RedirectIpv4EcHandler(org.opendaylight.protocol.bgp.flowspec.extended.communities.RedirectIpv4EcHandler) FlowspecL3vpnIpv6Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6Routes) TrafficActionExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCase) RedirectIpNhExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase) TrafficActionEcHandler(org.opendaylight.protocol.bgp.flowspec.extended.communities.TrafficActionEcHandler) FlowspecSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.FlowspecSubsequentAddressFamily) RedirectAs4ExtendedCommunityCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.bgp.rib.route.attributes.extended.communities.extended.community.RedirectAs4ExtendedCommunityCase) FlowspecIpv6Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.ipv6.routes.FlowspecIpv6Routes)

Example 3 with Registration

use of org.opendaylight.yangtools.concepts.Registration in project bgpcep by opendaylight.

the class BgpTestActivator method start.

@Override
public List<? extends Registration> start(final BGPExtensionProviderContext context) {
    initMock();
    final List<Registration> regs = new ArrayList<>();
    regs.add(context.registerAttributeParser(TYPE, this.attrParser));
    regs.add(context.registerAttributeSerializer(DataObject.class, this.attrSerializer));
    regs.add(context.registerParameterParser(TYPE, this.paramParser));
    regs.add(context.registerParameterSerializer(BgpParameters.class, this.paramSerializer));
    regs.add(context.registerCapabilityParser(TYPE, this.capaParser));
    regs.add(context.registerCapabilitySerializer(CParameters.class, this.capaSerializer));
    regs.add(context.registerBgpPrefixSidTlvParser(TYPE, this.sidTlvParser));
    regs.add(context.registerBgpPrefixSidTlvSerializer(BgpPrefixSidTlv.class, this.sidTlvSerializer));
    regs.add(context.registerMessageParser(TYPE, this.msgParser));
    regs.add(context.registerMessageSerializer(Notification.class, this.msgSerializer));
    regs.add(context.registerAddressFamily(Ipv4AddressFamily.class, 1));
    regs.add(context.registerAddressFamily(Ipv6AddressFamily.class, 2));
    regs.add(context.registerSubsequentAddressFamily(UnicastSubsequentAddressFamily.class, 1));
    this.nextHopParserSerializer = new NextHopParserSerializer() {

        @Override
        public CNextHop parseNextHop(final ByteBuf buffer) throws BGPParsingException {
            return new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4AddressNoZone("127.0.0.1")).build()).build();
        }

        @Override
        public void serializeNextHop(final CNextHop cnextHop, final ByteBuf byteAggregator) {
            final byte[] mpReachBytes = { 0x7f, 0x00, 0x00, 0x01 };
            byteAggregator.writeBytes(mpReachBytes);
        }
    };
    regs.add(context.registerNlriParser(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, this.nlriParser, this.nextHopParserSerializer, Ipv4NextHopCase.class));
    regs.add(context.registerNlriParser(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class, this.nlriParser, this.nextHopParserSerializer, Ipv6NextHopCase.class));
    regs.add(context.registerNlriSerializer(DataObject.class, this.nlriSerializer));
    regs.add(context.registerExtendedCommunityParser(0, 0, this.exParser));
    regs.add(context.registerExtendedCommunitySerializer(RouteTargetIpv4Case.class, this.exSerializer));
    return regs;
}
Also used : Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily) RouteTargetIpv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.RouteTargetIpv4Case) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) ArrayList(java.util.ArrayList) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters) BGPParsingException(org.opendaylight.protocol.bgp.parser.BGPParsingException) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters) ByteBuf(io.netty.buffer.ByteBuf) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.CNextHop) Ipv4NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCase) Notification(org.opendaylight.yangtools.yang.binding.Notification) Ipv6NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv6NextHopCase) Ipv4NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) BgpPrefixSidTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv) Ipv4NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder) Registration(org.opendaylight.yangtools.concepts.Registration) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily) NextHopParserSerializer(org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)

Example 4 with Registration

use of org.opendaylight.yangtools.concepts.Registration in project bgpcep by opendaylight.

the class StrictBGPPeerRegistryTest method testClosePeerSessionOneListener.

@Test
public void testClosePeerSessionOneListener() throws BGPDocumentedException {
    final PeerRegistrySessionListener sessionListener1 = getMockSessionListener();
    final Registration registration1 = this.peerRegistry.registerPeerSessionListener(sessionListener1);
    final PeerRegistrySessionListener sessionListener2 = getMockSessionListener();
    this.peerRegistry.registerPeerSessionListener(sessionListener2);
    this.peerRegistry.addPeer(REMOTE_IP, this.peer1, this.mockPreferences);
    this.peerRegistry.getPeer(REMOTE_IP, FROM, TO, this.classicOpen);
    this.peerRegistry.removePeerSession(REMOTE_IP);
    registration1.close();
    this.peerRegistry.getPeer(REMOTE_IP, FROM, TO, this.classicOpen);
    this.peerRegistry.removePeerSession(REMOTE_IP);
    verify(sessionListener1, times(1)).onSessionCreated(REMOTE_IP);
    verify(sessionListener2, times(2)).onSessionCreated(REMOTE_IP);
    verify(sessionListener1, times(1)).onSessionRemoved(REMOTE_IP);
    verify(sessionListener2, times(2)).onSessionRemoved(REMOTE_IP);
}
Also used : Registration(org.opendaylight.yangtools.concepts.Registration) PeerRegistrySessionListener(org.opendaylight.protocol.bgp.rib.impl.spi.PeerRegistrySessionListener) Test(org.junit.Test)

Example 5 with Registration

use of org.opendaylight.yangtools.concepts.Registration in project bgpcep by opendaylight.

the class BGPStateCollectorTest method getRibStatsTest.

@Test
public void getRibStatsTest() {
    assertEquals(List.of(), collector.getRibStats());
    assertEquals(List.of(), collector.getPeerStats());
    doReturn(mock(BGPPeerState.class)).when(bgpPeerStateProvider).getPeerState();
    doReturn(mock(BGPRibState.class)).when(bgpribStateProvider).getRIBState();
    try (Registration ribStateReg = collector.register(bgpribStateProvider)) {
        try (Registration peerStateReg = collector.register(bgpPeerStateProvider)) {
            assertEquals(1, collector.getRibStats().size());
            assertEquals(1, collector.getPeerStats().size());
        }
    }
    assertEquals(List.of(), collector.getRibStats());
    assertEquals(List.of(), collector.getPeerStats());
}
Also used : Registration(org.opendaylight.yangtools.concepts.Registration) BGPPeerState(org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerState) BGPRibState(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState) Test(org.junit.Test)

Aggregations

Registration (org.opendaylight.yangtools.concepts.Registration)17 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)6 Ipv4NextHopCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCase)4 Ipv6NextHopCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv6NextHopCase)4 TlvRegistry (org.opendaylight.protocol.pcep.spi.TlvRegistry)3 VendorInformationTlvRegistry (org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry)3 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open)3 Ipv4NextHopParserSerializer (org.opendaylight.protocol.bgp.inet.codec.nexthop.Ipv4NextHopParserSerializer)2 Ipv6NextHopParserSerializer (org.opendaylight.protocol.bgp.inet.codec.nexthop.Ipv6NextHopParserSerializer)2 NextHopParserSerializer (org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)2 ObjectRegistry (org.opendaylight.protocol.pcep.spi.ObjectRegistry)2 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily)2 Ipv6AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily)2 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp)2 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful)2 ActorRef (akka.actor.ActorRef)1 AddressFromURIString (akka.actor.AddressFromURIString)1 Status (akka.actor.Status)1 Success (akka.actor.Status.Success)1