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;
}
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;
}
}
}
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");
}
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;
}
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();
}
};
}
Aggregations