Search in sources :

Example 6 with Registration

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

the class BaseParserExtensionActivator method start.

@Override
public List<Registration> start(final PCEPExtensionProviderContext context) {
    final List<Registration> regs = new ArrayList<>();
    registerLabelParsers(regs, context);
    final LabelRegistry labelReg = context.getLabelHandlerRegistry();
    registerEROParsers(regs, context, labelReg);
    registerRROParsers(regs, context, labelReg);
    registerXROParsers(regs, context);
    registerTlvParsers(regs, context);
    registerObjectParsers(regs, context);
    final ObjectRegistry objReg = context.getObjectHandlerRegistry();
    final PCEPOpenMessageParser openParser = new PCEPOpenMessageParser(objReg);
    regs.add(context.registerMessageParser(PCEPOpenMessageParser.TYPE, openParser));
    regs.add(context.registerMessageSerializer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Open.class, openParser));
    final PCEPKeepAliveMessageParser kaParser = new PCEPKeepAliveMessageParser(objReg);
    regs.add(context.registerMessageParser(PCEPKeepAliveMessageParser.TYPE, kaParser));
    regs.add(context.registerMessageSerializer(Keepalive.class, kaParser));
    final PCEPRequestMessageParser reqParser = new PCEPRequestMessageParser(objReg);
    regs.add(context.registerMessageParser(PCEPRequestMessageParser.TYPE, reqParser));
    regs.add(context.registerMessageSerializer(Pcreq.class, reqParser));
    final PCEPReplyMessageParser repParser = new PCEPReplyMessageParser(objReg);
    regs.add(context.registerMessageParser(PCEPReplyMessageParser.TYPE, repParser));
    regs.add(context.registerMessageSerializer(Pcrep.class, repParser));
    final PCEPNotificationMessageParser notParser = new PCEPNotificationMessageParser(objReg);
    regs.add(context.registerMessageParser(PCEPNotificationMessageParser.TYPE, notParser));
    regs.add(context.registerMessageSerializer(Pcntf.class, notParser));
    final PCEPErrorMessageParser errParser = new PCEPErrorMessageParser(objReg);
    regs.add(context.registerMessageParser(PCEPErrorMessageParser.TYPE, errParser));
    regs.add(context.registerMessageSerializer(Pcerr.class, errParser));
    final PCEPCloseMessageParser closeParser = new PCEPCloseMessageParser(objReg);
    regs.add(context.registerMessageParser(PCEPCloseMessageParser.TYPE, closeParser));
    regs.add(context.registerMessageSerializer(Close.class, closeParser));
    final PCEPMonitoringReplyMessageParser monRepParser = new PCEPMonitoringReplyMessageParser(objReg);
    regs.add(context.registerMessageParser(PCEPMonitoringReplyMessageParser.TYPE, monRepParser));
    regs.add(context.registerMessageSerializer(Pcmonrep.class, monRepParser));
    final PCEPMonitoringRequestMessageParser monReqParser = new PCEPMonitoringRequestMessageParser(objReg);
    regs.add(context.registerMessageParser(PCEPMonitoringRequestMessageParser.TYPE, monReqParser));
    regs.add(context.registerMessageSerializer(Pcmonreq.class, monReqParser));
    final PCEPStartTLSMessageParser startTLSParser = new PCEPStartTLSMessageParser(objReg);
    regs.add(context.registerMessageParser(PCEPStartTLSMessageParser.TYPE, startTLSParser));
    regs.add(context.registerMessageSerializer(Starttls.class, startTLSParser));
    return regs;
}
Also used : ArrayList(java.util.ArrayList) PCEPMonitoringReplyMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPMonitoringReplyMessageParser) PCEPMonitoringRequestMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPMonitoringRequestMessageParser) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open) PCEPCloseMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPCloseMessageParser) Pcmonreq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcmonreq) Pcmonrep(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcmonrep) Registration(org.opendaylight.yangtools.concepts.Registration) PCEPNotificationMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPNotificationMessageParser) PCEPRequestMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPRequestMessageParser) LabelRegistry(org.opendaylight.protocol.pcep.spi.LabelRegistry) Pcerr(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcerr) Keepalive(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Keepalive) PCEPKeepAliveMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPKeepAliveMessageParser) PCEPStartTLSMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPStartTLSMessageParser) Starttls(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Starttls) PCEPReplyMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPReplyMessageParser) PCEPOpenMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPOpenMessageParser) PCEPErrorMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPErrorMessageParser) CClose(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CClose) Close(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close) Pcntf(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcntf) Pcrep(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcrep) Pcreq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcreq) ObjectRegistry(org.opendaylight.protocol.pcep.spi.ObjectRegistry)

Example 7 with Registration

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

the class AbstractBrokerServiceProxy method close.

@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public void close() {
    if (delegate != null) {
        delegate = null;
        RuntimeException potentialException = new RuntimeException("Uncaught exceptions occured during unregistration");
        boolean hasSuppressed = false;
        for (Registration registration : registrations) {
            try {
                registration.close();
            } catch (Exception e) {
                potentialException.addSuppressed(e);
                hasSuppressed = true;
            }
        }
        if (hasSuppressed) {
            throw potentialException;
        }
    }
}
Also used : Registration(org.opendaylight.yangtools.concepts.Registration)

Example 8 with Registration

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

the class ShardManagerTest method testRegisterForShardLeaderChanges.

@SuppressWarnings("unchecked")
@Test
public void testRegisterForShardLeaderChanges() {
    LOG.info("testRegisterForShardLeaderChanges starting");
    final String memberId1 = "member-1-shard-default-" + shardMrgIDSuffix;
    final String memberId2 = "member-2-shard-default-" + shardMrgIDSuffix;
    final TestKit kit = new TestKit(getSystem());
    final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor());
    shardManager.tell(new UpdateSchemaContext(TEST_SCHEMA_CONTEXT), kit.getRef());
    shardManager.tell(new ActorInitialized(), mockShardActor);
    final Consumer<String> mockCallback = mock(Consumer.class);
    shardManager.tell(new RegisterForShardAvailabilityChanges(mockCallback), kit.getRef());
    final Success reply = kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
    final Registration reg = (Registration) reply.status();
    final DataTree mockDataTree = mock(DataTree.class);
    shardManager.tell(new ShardLeaderStateChanged(memberId1, memberId1, mockDataTree, DataStoreVersions.CURRENT_VERSION), mockShardActor);
    verify(mockCallback, timeout(5000)).accept("default");
    reset(mockCallback);
    shardManager.tell(new ShardLeaderStateChanged(memberId1, memberId1, mockDataTree, DataStoreVersions.CURRENT_VERSION), mockShardActor);
    Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
    verifyNoMoreInteractions(mockCallback);
    shardManager.tell(new ShardLeaderStateChanged(memberId1, null, mockDataTree, DataStoreVersions.CURRENT_VERSION), mockShardActor);
    verify(mockCallback, timeout(5000)).accept("default");
    reset(mockCallback);
    shardManager.tell(new ShardLeaderStateChanged(memberId1, memberId2, mockDataTree, DataStoreVersions.CURRENT_VERSION), mockShardActor);
    verify(mockCallback, timeout(5000)).accept("default");
    reset(mockCallback);
    reg.close();
    shardManager.tell(new ShardLeaderStateChanged(memberId1, memberId1, mockDataTree, DataStoreVersions.CURRENT_VERSION), mockShardActor);
    Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
    verifyNoMoreInteractions(mockCallback);
    LOG.info("testRegisterForShardLeaderChanges ending");
}
Also used : UpdateSchemaContext(org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext) DataTree(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree) ShardLeaderStateChanged(org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged) ActorRef(akka.actor.ActorRef) TestActorRef(akka.testkit.TestActorRef) Registration(org.opendaylight.yangtools.concepts.Registration) ActorInitialized(org.opendaylight.controller.cluster.datastore.messages.ActorInitialized) AddressFromURIString(akka.actor.AddressFromURIString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TestKit(akka.testkit.javadsl.TestKit) Success(akka.actor.Status.Success) Test(org.junit.Test) AbstractClusterRefActorTest(org.opendaylight.controller.cluster.datastore.AbstractClusterRefActorTest)

Example 9 with Registration

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

the class RSVPActivator method start.

@Override
public List<Registration> start(final RSVPExtensionProviderContext context) {
    final List<Registration> regs = new ArrayList<>();
    registerLabelParsers(regs, context);
    final LabelRegistry labelReg = context.getLabelHandlerRegistry();
    registerRROParsers(regs, context, labelReg);
    registerXROParsers(regs, context);
    registerEROParsers(regs, context, labelReg);
    registerRsvpTEParsers(context);
    return regs;
}
Also used : LabelRegistry(org.opendaylight.protocol.rsvp.parser.spi.LabelRegistry) Registration(org.opendaylight.yangtools.concepts.Registration) ArrayList(java.util.ArrayList)

Example 10 with Registration

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

the class SimpleAttributeRegistry method registerAttributeSerializer.

synchronized Registration registerAttributeSerializer(final Class<? extends DataObject> paramClass, final AttributeSerializer serializer) {
    final Registration reg = this.handlers.registerSerializer(paramClass, serializer);
    this.serializers.put(reg, serializer);
    return new AbstractRegistration() {

        @Override
        protected void removeRegistration() {
            synchronized (SimpleAttributeRegistry.this) {
                SimpleAttributeRegistry.this.serializers.remove(reg);
                SimpleAttributeRegistry.this.roSerializers.set(SimpleAttributeRegistry.this.serializers.values());
            }
            reg.close();
        }
    };
}
Also used : AbstractRegistration(org.opendaylight.yangtools.concepts.AbstractRegistration) Registration(org.opendaylight.yangtools.concepts.Registration) AbstractRegistration(org.opendaylight.yangtools.concepts.AbstractRegistration)

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