*/
package org.opendaylight.controller.config.yang.bgp.rib.impl;
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
+import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext;
import org.opendaylight.protocol.bgp.rib.impl.BGPDispatcherImpl;
/**
-*
-*/
+ *
+ */
public final class BGPDispatcherImplModule
- extends
- org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPDispatcherImplModule {
+extends
+org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPDispatcherImplModule {
public BGPDispatcherImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ final org.opendaylight.controller.config.api.ModuleIdentifier name,
+ final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(name, dependencyResolver);
}
public BGPDispatcherImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- BGPDispatcherImplModule oldModule,
- java.lang.AutoCloseable oldInstance) {
+ final org.opendaylight.controller.config.api.ModuleIdentifier name,
+ final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ final BGPDispatcherImplModule oldModule,
+ final java.lang.AutoCloseable oldInstance) {
super(name, dependencyResolver, oldModule, oldInstance);
}
@Override
public java.lang.AutoCloseable createInstance() {
- final BGPMessageFactory messageFactoryDependency = getMessageFactoryDependency();
- return new BGPDispatcherImpl(messageFactoryDependency,
+ final BGPExtensionConsumerContext bgpExtensions = getBgpExtensionsDependency();
+ return new BGPDispatcherImpl(bgpExtensions.getMessageRegistry(),
getBossGroupDependency(), getWorkerGroupDependency());
}
}
+++ /dev/null
-/**
- * Generated file
-
- * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-message-factory-impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 13:02:31 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.bgp.rib.impl;
-
-import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
-import org.opendaylight.protocol.bgp.parser.BGPParsingException;
-import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- *
- */
-public final class BGPMessageFactoryImplModule
-extends
-org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPMessageFactoryImplModule {
-
- public BGPMessageFactoryImplModule(
- final org.opendaylight.controller.config.api.ModuleIdentifier name,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(name, dependencyResolver);
- }
-
- public BGPMessageFactoryImplModule(
- final org.opendaylight.controller.config.api.ModuleIdentifier name,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- final BGPMessageFactoryImplModule oldModule,
- final java.lang.AutoCloseable oldInstance) {
- super(name, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public void validate() {
- super.validate();
- // Add custom validation for module attributes here.
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- try {
- return new BGPMessageFactoryCloseable(new BGPMessageFactoryImpl(
- getBgpExtensionsDependency().getMessageRegistry()));
- } catch (Exception e) {
- throw new RuntimeException("Failed to create consumer context.", e);
- }
- }
-
- private static class BGPMessageFactoryCloseable implements
- BGPMessageFactory, AutoCloseable {
- private final BGPMessageFactoryImpl inner;
-
- public BGPMessageFactoryCloseable(
- final BGPMessageFactoryImpl bgpMessageFactory) {
- this.inner = bgpMessageFactory;
- }
-
- @Override
- public void close() throws Exception {
- // NOOP
- }
-
- @Override
- public Notification parse(final byte[] bytes) throws BGPParsingException, BGPDocumentedException {
- return inner.parse(bytes);
- }
-
- @Override
- public byte[] put(final Notification bgpMessage) {
- return inner.put(bgpMessage);
- }
- }
-}
+++ /dev/null
-/**
- * Generated file
-
- * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-message-factory-impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 13:02:31 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.bgp.rib.impl;
-
-/**
-*
-*/
-public class BGPMessageFactoryImplModuleFactory
- extends
- org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPMessageFactoryImplModuleFactory {
-
-}
}
}
- identity bgp-message-factory {
- description
- "Service representing a BGP proposal.";
-
- base "config:service-type";
- config:java-class "org.opendaylight.protocol.bgp.parser.BGPMessageFactory";
- }
-
- identity bgp-message-factory-impl {
- base config:module-type;
- config:provided-service bgp-message-factory;
- config:java-name-prefix BGPMessageFactoryImpl;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case bgp-message-factory-impl {
- when "/config:modules/config:module/config:type = 'bgp-message-factory-impl'";
-
- container bgp-extensions {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity bgpspi:consumer-extensions;
- }
- }
- }
- }
- }
-
identity bgp-rib-extensions-impl {
base config:module-type;
config:provided-service ribspi:extensions;
case bgp-dispatcher-impl {
when "/config:modules/config:module/config:type = 'bgp-dispatcher-impl'";
- container message-factory {
+ container bgp-extensions {
uses config:service-ref {
refine type {
mandatory true;
- config:required-identity bgp-message-factory;
+ config:required-identity bgpspi:consumer-extensions;
}
}
}
private final String instanceName = "bgp-message-fct";
private BGPDispatcherImplModuleFactory factory;
-
+
private NettyThreadgroupModuleFactory threadgroupFactory;
-
- private BGPMessageFactoryImplModuleFactory messageFactory;
-
+
+ private RIBExtensionsImplModuleFactory messageFactory;
+
@Before
public void setUp() throws Exception {
this.factory = new BGPDispatcherImplModuleFactory();
this.threadgroupFactory = new NettyThreadgroupModuleFactory();
- this.messageFactory = new BGPMessageFactoryImplModuleFactory();
+ this.messageFactory = new RIBExtensionsImplModuleFactory();
super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory, threadgroupFactory, messageFactory));
}
-
+
@Test
public void testCreateBean() throws Exception {
ConfigTransactionJMXClient transaction = configRegistryClient
assertBeanCount(1, factory.getImplementationName());
assertStatus(status, 4, 0, 0);
}
-
+
@Test
public void testReusingOldInstance() throws InstanceAlreadyExistsException,
- ConflictingVersionException, ValidationException {
+ ConflictingVersionException, ValidationException {
ConfigTransactionJMXClient transaction = configRegistryClient
.createTransaction();
createInstance(transaction, this.factory.getImplementationName(), instanceName, this.threadgroupFactory.getImplementationName(), this.messageFactory.getImplementationName());
assertBeanCount(1, factory.getImplementationName());
assertStatus(status, 0, 0, 4);
}
-
+
public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
final String instanceName, final String threadgropuModuleName, final String messageFactoryModuleName) throws InstanceAlreadyExistsException {
ObjectName nameCreated = transaction.createModule(
mxBean.setBossGroup(createThreadgroupInstance(transaction, threadgropuModuleName, "boss-threadgroup", 10));
mxBean.setWorkerGroup(createThreadgroupInstance(transaction, threadgropuModuleName, "worker-threadgroup", 10));
//mxBean.setMessageFactory(BGPMessageFactoryImplModuleTest.createInstance(transaction, messageFactoryModuleName, "bgp-msg-fct"));
- return nameCreated;
+ return nameCreated;
}
-
+
public static ObjectName createThreadgroupInstance(
final ConfigTransactionJMXClient transaction,
final String moduleName, final String instanceName,
public class BGPImplModuleTest extends AbstractConfigTest {
private final String instanceName = "bgp-impl1";
-
+
private BGPImplModuleFactory factory;
-
+
private BGPSessionProposalImplModuleFactory sessionFacotry;
-
+
private BGPDispatcherImplModuleFactory dispactherFactory;
-
+
private NettyThreadgroupModuleFactory threadgropFactory;
-
- private BGPMessageFactoryImplModuleFactory messageFactory;
-
+
+ private RIBExtensionsImplModuleFactory messageFactory;
+
@Before
public void setUp() throws Exception {
this.factory = new BGPImplModuleFactory();
this.dispactherFactory = new BGPDispatcherImplModuleFactory();
this.sessionFacotry = new BGPSessionProposalImplModuleFactory();
this.threadgropFactory = new NettyThreadgroupModuleFactory();
- this.messageFactory = new BGPMessageFactoryImplModuleFactory();
+ this.messageFactory = new RIBExtensionsImplModuleFactory();
super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory, this.dispactherFactory, this.sessionFacotry, this.messageFactory, this.threadgropFactory));
}
-
+
@Test
public void testValidationExceptionPortNotSet()
throws InstanceAlreadyExistsException {
assertTrue(e.getMessage().contains("Port value is not set."));
}
}
-
+
@Test
public void testValidationExceptionPortOutOfRange()
throws InstanceAlreadyExistsException {
assertTrue(e.getMessage().contains("is out of range (0-65535)."));
}
}
-
+
@Test
public void testValidationExceptionHostNotSet()
throws InstanceAlreadyExistsException {
assertTrue(e.getMessage().contains("Host value is not set."));
}
}
-
+
@Test
public void testCreateBean() throws Exception {
ConfigTransactionJMXClient transaction = configRegistryClient
assertBeanCount(1, factory.getImplementationName());
assertStatus(status, 6, 0, 0);
}
-
+
@Test
public void testReusingOldInstance() throws InstanceAlreadyExistsException,
- ConflictingVersionException, ValidationException {
+ ConflictingVersionException, ValidationException {
ConfigTransactionJMXClient transaction = configRegistryClient
.createTransaction();
createInstance(transaction, this.factory.getImplementationName(), instanceName, "localhost", 1, sessionFacotry.getImplementationName(), dispactherFactory.getImplementationName(), threadgropFactory.getImplementationName(), messageFactory.getImplementationName());
@Test
public void testReconfigure() throws InstanceAlreadyExistsException,
- ConflictingVersionException, ValidationException,
- InstanceNotFoundException {
+ ConflictingVersionException, ValidationException,
+ InstanceNotFoundException {
ConfigTransactionJMXClient transaction = configRegistryClient
.createTransaction();
createInstance(transaction, this.factory.getImplementationName(), instanceName, "localhost", 1, sessionFacotry.getImplementationName(), dispactherFactory.getImplementationName(), threadgropFactory.getImplementationName(), messageFactory.getImplementationName());
assertBeanCount(1, factory.getImplementationName());
assertStatus(status, 0, 1, 5);
}
-
+
public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
final String instanceName, final String host, final Integer port, final String sessionModuleName, final String dispatcherModuleName, final String threadgroupModuleName, final String messageFactoryModuleName) throws InstanceAlreadyExistsException {
ObjectName nameCreated = transaction.createModule(
mxBean.setBgpDispatcher(BGPDispatcherImplModuleTest.createInstance(transaction, dispatcherModuleName, "bgp-dispatcher1", threadgroupModuleName, messageFactoryModuleName));
return nameCreated;
}
-
+
}
+++ /dev/null
-package org.opendaylight.controller.config.yang.bgp.rib.impl;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleMXBean;
-
-@Ignore
-public class BGPMessageFactoryImplModuleTest extends AbstractConfigTest {
-
- private final String instanceName = "bgp-message-fct";
-
- private BGPMessageFactoryImplModuleFactory factory;
-
- private SimpleBGPExtensionProviderContextModuleFactory bgpEPCFactory;
-
- @Before
- public void setUp() throws Exception {
- this.factory = new BGPMessageFactoryImplModuleFactory();
- this.bgpEPCFactory = new SimpleBGPExtensionProviderContextModuleFactory();
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory, this.bgpEPCFactory));
- }
-
- @Test
- public void testCreateBean() throws Exception {
- ConfigTransactionJMXClient transaction = configRegistryClient
- .createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), instanceName, this.bgpEPCFactory.getImplementationName());
- transaction.validateConfig();
- CommitStatus status = transaction.commit();
- assertBeanCount(1, factory.getImplementationName());
- assertStatus(status, 1, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws InstanceAlreadyExistsException,
- ConflictingVersionException, ValidationException {
- ConfigTransactionJMXClient transaction = configRegistryClient
- .createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), instanceName, this.bgpEPCFactory.getImplementationName());
- transaction.commit();
- transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, factory.getImplementationName());
- CommitStatus status = transaction.commit();
- assertBeanCount(1, factory.getImplementationName());
- assertStatus(status, 0, 0, 1);
- }
-
- public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
- final String instanceName, final String extensionsModuleName) throws InstanceAlreadyExistsException {
- ObjectName nameCreated = transaction.createModule(
- moduleName, instanceName);
- BGPMessageFactoryImplModuleMXBean mxBean = transaction.newMBeanProxy(
- nameCreated, BGPMessageFactoryImplModuleMXBean.class);
- //mxBean.setBgpExtensions(createBgpExtensionsInstance(transaction, extensionsModuleName, "bgp-extension"));
- return nameCreated;
- }
-
- public static ObjectName createBgpExtensionsInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
- final String instanceName) throws InstanceAlreadyExistsException {
- ObjectName nameCreated = transaction.createModule(
- moduleName, instanceName);
- transaction.newMBeanProxy(
- nameCreated, SimpleBGPExtensionProviderContextModuleMXBean.class);
- return nameCreated;
- }
-
-}
@Ignore
public class RIBImplModuleTest extends AbstractConfigTest {
-
+
private final String instanceName = "bgp-rib-impl";
private RIBImplModuleFactory factory;
-
+
private BindingBrokerImplSingletonModuleFactory brokerFactory;
-
+
private TimedReconnectStrategyModuleFactory reconnectFactory;
-
+
private BGPImplModuleFactory bgpFactory;
-
+
private BGPSessionProposalImplModuleFactory sessionFacotry;
-
+
private BGPDispatcherImplModuleFactory dispactherFactory;
-
+
private NettyThreadgroupModuleFactory threadgropFactory;
-
- private BGPMessageFactoryImplModuleFactory messageFactory;
-
+
+ private RIBExtensionsImplModuleFactory messageFactory;
+
private GlobalEventExecutorModuleFactory executorFactory;
-
+
@Before
public void setUp() throws Exception {
this.factory = new RIBImplModuleFactory();
this.dispactherFactory = new BGPDispatcherImplModuleFactory();
this.sessionFacotry = new BGPSessionProposalImplModuleFactory();
this.threadgropFactory = new NettyThreadgroupModuleFactory();
- this.messageFactory = new BGPMessageFactoryImplModuleFactory();
+ this.messageFactory = new RIBExtensionsImplModuleFactory();
this.reconnectFactory = new TimedReconnectStrategyModuleFactory();
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory,
- this.dispactherFactory, this.sessionFacotry, this.messageFactory,
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory,
+ this.dispactherFactory, this.sessionFacotry, this.messageFactory,
this.threadgropFactory, this.bgpFactory, this.reconnectFactory, this.brokerFactory, this.executorFactory));
Mockito.doReturn(mockedServiceRegistration).when(mockedContext).registerService(
- Matchers.any(String.class), Mockito.any(Closeable.class),
- Mockito.any(Dictionary.class));
+ Matchers.any(String.class), Mockito.any(Closeable.class),
+ Mockito.any(Dictionary.class));
Mockito.doReturn(mockedServiceRegistration).when(mockedContext).registerService(
- Matchers.any(Class.class), Mockito.any(Closeable.class),
- Mockito.any(Dictionary.class));
+ Matchers.any(Class.class), Mockito.any(Closeable.class),
+ Mockito.any(Dictionary.class));
Filter mockedFilter = Mockito.mock(Filter.class);
Mockito.doReturn(mockedFilter).when(mockedContext).createFilter(Mockito.anyString());
-
+
Mockito.doNothing().when(mockedContext).addServiceListener(Mockito.any(ServiceListener.class), Mockito.anyString());
-
+
Mockito.doReturn(new ServiceReference[]{}).when(mockedContext).getServiceReferences(Matchers.anyString(), Matchers.anyString());
-
+
ServiceReference<?> mockedserviceReference = Mockito.mock(ServiceReference.class);
Mockito.doReturn(new String()).when(mockedserviceReference).toString();
Mockito.doReturn(mockedserviceReference).when(mockedContext).getServiceReference(Matchers.any(Class.class));
-
+
DataProviderService mockedService = Mockito.mock(DataProviderService.class);
Mockito.doReturn(mockedService).when(mockedContext).getService(Matchers.any(ServiceReference.class));
}
-
+
@Test
public void testCreateBean() throws Exception {
ConfigTransactionJMXClient transaction = configRegistryClient
assertBeanCount(1, factory.getImplementationName());
assertStatus(status, 6, 0, 0);
}
-
+
public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
final String instanceName, final ObjectName bindingDataModule, final String reconnectModueName, final String executorModuleName, final String bgpModuleName,
final String sessionModuleName, final String dispatcherModuleName, final String threadgroupModuleName, final String messageFactoryModuleName) throws InstanceAlreadyExistsException, MalformedObjectNameException {
mxBean.setBgp(BGPImplModuleTest.createInstance(transaction, bgpModuleName, "bgp-impl1", "localhost", 1, sessionModuleName, dispatcherModuleName, threadgroupModuleName, messageFactoryModuleName));
return nameCreated;
}
-
+
public static ObjectName createBindingBrokerInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
final String instanceName) throws InstanceAlreadyExistsException {
ObjectName nameCreated = transaction.createModule(
import java.util.List;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
final class BGPByteToMessageDecoder extends ByteToMessageDecoder {
private final static Logger LOG = LoggerFactory.getLogger(BGPByteToMessageDecoder.class);
- private final BGPMessageFactory factory;
+ private final MessageRegistry registry;
- public BGPByteToMessageDecoder(final BGPMessageFactory factory) {
- this.factory = Preconditions.checkNotNull(factory);
+ public BGPByteToMessageDecoder(final MessageRegistry registry) {
+ this.registry = Preconditions.checkNotNull(registry);
}
@Override
LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
final byte[] bytes = new byte[in.readableBytes()];
in.readBytes(bytes);
- out.add(this.factory.parse(bytes));
+ out.add(this.registry.parseMessage(bytes));
} catch (BGPParsingException | BGPDocumentedException e) {
LOG.debug("Failed to decode protocol message", e);
this.exceptionCaught(ctx, e);
import java.net.InetSocketAddress;
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
import org.opendaylight.protocol.framework.AbstractDispatcher;
private final BGPHandlerFactory hf;
- public BGPDispatcherImpl(final BGPMessageFactory parser, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
+ public BGPDispatcherImpl(final MessageRegistry messageRegistry, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
super(bossGroup, workerGroup);
- this.hf = new BGPHandlerFactory(parser);
+ this.hf = new BGPHandlerFactory(messageRegistry);
}
@Override
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelOutboundHandler;
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import com.google.common.base.Preconditions;
*/
public class BGPHandlerFactory {
private final ChannelOutboundHandler encoder;
- private final BGPMessageFactory msgFactory;
+ private final MessageRegistry registry;
- public BGPHandlerFactory(final BGPMessageFactory msgFactory) {
- this.msgFactory = Preconditions.checkNotNull(msgFactory);
- this.encoder = new BGPMessageToByteEncoder(msgFactory);
+ public BGPHandlerFactory(final MessageRegistry registry) {
+ this.registry = Preconditions.checkNotNull(registry);
+ this.encoder = new BGPMessageToByteEncoder(registry);
}
public ChannelHandler[] getEncoders() {
public ChannelHandler[] getDecoders() {
return new ChannelHandler[] {
new BGPMessageHeaderDecoder(),
- new BGPByteToMessageDecoder(this.msgFactory),
+ new BGPByteToMessageDecoder(this.registry),
};
}
}
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Sharable
final class BGPMessageToByteEncoder extends MessageToByteEncoder<Notification> {
private final static Logger LOG = LoggerFactory.getLogger(BGPMessageToByteEncoder.class);
- private final BGPMessageFactory factory;
+ private final MessageRegistry registry;
- BGPMessageToByteEncoder(final BGPMessageFactory factory) {
- this.factory = Preconditions.checkNotNull(factory);
+ BGPMessageToByteEncoder(final MessageRegistry registry) {
+ this.registry = Preconditions.checkNotNull(registry);
}
@Override
protected void encode(final ChannelHandlerContext ctx, final Notification msg, final ByteBuf out) throws Exception {
LOG.debug("Sent to encode : {}", msg);
- out.writeBytes(this.factory.put(msg));
+ out.writeBytes(this.registry.serializeMessage(msg));
}
}
import java.net.InetSocketAddress;
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
-import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.rib.impl.BGPDispatcherImpl;
import org.opendaylight.protocol.bgp.rib.impl.BGPSessionProposalImpl;
private static final int RECONNECT_MILLIS = 5000;
private Main() throws Exception {
- this.dispatcher = new BGPDispatcherImpl(new BGPMessageFactoryImpl(ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getMessageRegistry()), new NioEventLoopGroup(), new NioEventLoopGroup());
+ this.dispatcher = new BGPDispatcherImpl(ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getMessageRegistry(), new NioEventLoopGroup(), new NioEventLoopGroup());
}
public static void main(final String[] args) throws Exception {
import java.net.InetSocketAddress;
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
-import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.rib.impl.BGPHandlerFactory;
import org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl;
final SessionNegotiatorFactory<Notification, BGPSessionImpl, BGPSessionListener> snf = new BGPSessionNegotiatorFactory(new HashedWheelTimer(), prefs);
final BGPSpeakerMock<Notification, BGPSessionImpl, BGPSessionListener> mock = new BGPSpeakerMock<>(snf,
- new BGPHandlerFactory(new BGPMessageFactoryImpl(ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getMessageRegistry())),
+ new BGPHandlerFactory(ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getMessageRegistry()),
new DefaultPromise<BGPSessionImpl>(GlobalEventExecutor.INSTANCE));
mock.createServer(new InetSocketAddress("127.0.0.2", 12345), f);