<bgp-extensions>
<type xmlns:bgpspi="urn:opendaylight:params:xml:ns:yang:controller:bgp:parser:spi">bgpspi:extensions</type>
<name>global-bgp-extensions</name>
- </bgp-extensions>
+ </bgp-extensions>
+ <timer>
+ <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-timer</type>
+ <name>global-timer</name>
+ </timer>
<boss-group>
<type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-threadgroup</type>
<name>global-boss-group</name>
<groupId>org.opendaylight.controller</groupId>
<artifactId>netty-config-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netty-timer-config</artifactId>
+ </dependency>
<!--test dependencies -->
<dependency>
super(name, dependencyResolver, oldModule, oldInstance);
}
- @Override
- public void validate() {
- super.validate();
- }
-
@Override
public java.lang.AutoCloseable createInstance() {
final BGPExtensionConsumerContext bgpExtensions = getBgpExtensionsDependency();
- return new BGPDispatcherImpl(bgpExtensions.getMessageRegistry(),
+ return new BGPDispatcherImpl(bgpExtensions.getMessageRegistry(), getTimerDependency(),
getBossGroupDependency(), getWorkerGroupDependency());
}
}
}
@Override
- public void validate() {
- super.validate();
+ public void customValidation() {
JmxAttributeValidationException.checkNotNull(getExtensions(), "is not set.", this.extensionsJmxAttribute);
JmxAttributeValidationException.checkNotNull(getRibId(), "is not set.", this.ribIdJmxAttribute);
JmxAttributeValidationException.checkNotNull(getLocalAs(), "is not set.", this.localAsJmxAttribute);
}
}
+ container timer {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity netty:netty-timer;
+ }
+ }
+ }
+
container boss-group {
uses config:service-ref {
refine type {
import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleFactory;
import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleMXBean;
+import org.opendaylight.controller.config.yang.netty.timer.HashedWheelTimerModuleFactory;
+import org.opendaylight.controller.config.yang.netty.timer.HashedWheelTimerModuleMXBean;
public class BGPDispatcherImplModuleTest extends AbstractConfigTest {
private SimpleBGPExtensionProviderContextModuleFactory extensionFactory;
+ private HashedWheelTimerModuleFactory hwtFactory;
+
@Before
public void setUp() throws Exception {
this.factory = new BGPDispatcherImplModuleFactory();
this.threadgroupFactory = new NettyThreadgroupModuleFactory();
this.messageFactory = new RIBExtensionsImplModuleFactory();
this.extensionFactory = new SimpleBGPExtensionProviderContextModuleFactory();
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory, threadgroupFactory, messageFactory, extensionFactory));
+ this.hwtFactory = new HashedWheelTimerModuleFactory();
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+ this.factory, threadgroupFactory, messageFactory, extensionFactory, hwtFactory));
}
@Test
transaction.validateConfig();
CommitStatus status = transaction.commit();
assertBeanCount(1, factory.getImplementationName());
- assertStatus(status, 4, 0, 0);
+ assertStatus(status, 5, 0, 0);
}
@Test
assertBeanCount(1, factory.getImplementationName());
CommitStatus status = transaction.commit();
assertBeanCount(1, factory.getImplementationName());
- assertStatus(status, 0, 0, 4);
+ assertStatus(status, 0, 0, 5);
}
public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
- final String instanceName) throws InstanceAlreadyExistsException {
+ final String instanceName) throws InstanceAlreadyExistsException {
ObjectName nameCreated = transaction.createModule(
moduleName, instanceName);
BGPDispatcherImplModuleMXBean mxBean = transaction.newMBeanProxy(
mxBean.setBossGroup(createThreadgroupInstance(transaction, "boss-threadgroup", 10));
mxBean.setWorkerGroup(createThreadgroupInstance(transaction, "worker-threadgroup", 10));
mxBean.setBgpExtensions(createBgpExtensionsInstance(transaction, "bgp-extensions"));
+ mxBean.setTimer(createTimerInstance(transaction, ""));
return nameCreated;
}
return nameCreated;
}
+ public static ObjectName createTimerInstance(final ConfigTransactionJMXClient transaction, final String instanceName)
+ throws InstanceAlreadyExistsException {
+ ObjectName nameCreated = transaction.createModule(HashedWheelTimerModuleFactory.NAME,
+ instanceName);
+ HashedWheelTimerModuleMXBean mxBean = transaction.newMBeanProxy(
+ nameCreated, HashedWheelTimerModuleMXBean.class);
+ return nameCreated;
+
+ }
+
public static ObjectName createBgpExtensionsInstance(
final ConfigTransactionJMXClient transaction,
final String instanceName)
- throws InstanceAlreadyExistsException {
+ throws InstanceAlreadyExistsException {
ObjectName nameCreated = transaction.createModule(SimpleBGPExtensionProviderContextModuleFactory.NAME,
instanceName);
transaction.newMBeanProxy(nameCreated,
import org.opendaylight.controller.config.yang.netty.eventexecutor.GlobalEventExecutorModuleFactory;
import org.opendaylight.controller.config.yang.reconnectstrategy.TimedReconnectStrategyModuleFactory;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
transaction.validateConfig();
final CommitStatus status = transaction.commit();
assertBeanCount(1, BGPPeerModuleFactory.NAME);
- assertStatus(status, 15, 0, 0);
+ assertStatus(status, 16, 0, 0);
}
@Override
assertBeanCount(1, BGPPeerModuleFactory.NAME);
status = transaction.commit();
assertBeanCount(1, BGPPeerModuleFactory.NAME);
- assertStatus(status, 0, 0, 15);
+ assertStatus(status, 0, 0, 16);
}
@Test
mxBean.setPort(new PortNumber(10));
status = transaction.commit();
assertBeanCount(1, BGPPeerModuleFactory.NAME);
- assertStatus(status, 0, 1, 14);
+ assertStatus(status, 0, 1, 15);
}
}
import org.opendaylight.controller.config.yang.md.sal.dom.impl.HashMapDataStoreModuleMXBean;
import org.opendaylight.controller.config.yang.netty.eventexecutor.GlobalEventExecutorModuleFactory;
import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
+import org.opendaylight.controller.config.yang.netty.timer.HashedWheelTimerModuleFactory;
import org.opendaylight.controller.config.yang.reconnectstrategy.TimedReconnectStrategyModuleFactory;
import org.opendaylight.controller.config.yang.store.impl.YangParserWrapper;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
private DomBrokerImplModuleFactory domBrokerFactory;
private RuntimeMappingModuleFactory runtimeMappingFactory;
private HashMapDataStoreModuleFactory dataStroreFactory;
+ private HashedWheelTimerModuleFactory hwtFactory;
@Mock
private DataModificationTransaction mockedTransaction;
this.domBrokerFactory = new DomBrokerImplModuleFactory();
this.runtimeMappingFactory = new RuntimeMappingModuleFactory();
this.dataStroreFactory = new HashMapDataStoreModuleFactory();
+ this.hwtFactory = new HashedWheelTimerModuleFactory();
List<ModuleFactory> moduleFactories = getModuleFactories();
super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, moduleFactories
this.dispactherFactory, this.threadgroupFactory,
this.reconnectFactory, this.dataBrokerFactory, this.executorFactory, this.extensionFactory,
this.ribExtensionsFactory, this.domBrokerFactory, this.runtimeMappingFactory,
- this.dataStroreFactory);
+ this.dataStroreFactory, this.hwtFactory);
}
@Override
CommitStatus status = transaction.commit();
Thread.sleep(2000);
assertBeanCount(1, factory.getImplementationName());
- assertStatus(status, 13, 0, 0);
+ assertStatus(status, 14, 0, 0);
}
@After
public static ObjectName lookupMappingServiceInstance(final ConfigTransactionJMXClient transaction) {
- try {
- return transaction.lookupConfigBean(RuntimeMappingModuleFactory.NAME, RuntimeMappingModuleFactory.SINGLETON_NAME);
- } catch (InstanceNotFoundException e) {
- try {
- return transaction.createModule(RuntimeMappingModuleFactory.NAME, RuntimeMappingModuleFactory.SINGLETON_NAME);
- } catch (InstanceAlreadyExistsException e1) {
- throw new IllegalStateException(e1);
- }
- }
+ try {
+ return transaction.lookupConfigBean(RuntimeMappingModuleFactory.NAME, RuntimeMappingModuleFactory.SINGLETON_NAME);
+ } catch (InstanceNotFoundException e) {
+ try {
+ return transaction.createModule(RuntimeMappingModuleFactory.NAME, RuntimeMappingModuleFactory.SINGLETON_NAME);
+ } catch (InstanceAlreadyExistsException e1) {
+ throw new IllegalStateException(e1);
+ }
+ }
}
public static ObjectName createRibExtensionsInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
import io.netty.channel.EventLoopGroup;
import io.netty.channel.socket.SocketChannel;
-import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.Promise;
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import com.google.common.base.Preconditions;
+
/**
* Implementation of BGPDispatcher.
*/
public final class BGPDispatcherImpl extends AbstractDispatcher<BGPSessionImpl, BGPSessionListener> implements BGPDispatcher, AutoCloseable {
- private final Timer timer = new HashedWheelTimer();
-
private final BGPHandlerFactory hf;
+ private final Timer timer;
- public BGPDispatcherImpl(final MessageRegistry messageRegistry, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
+ public BGPDispatcherImpl(final MessageRegistry messageRegistry, final Timer timer, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
super(bossGroup, workerGroup);
+ this.timer = Preconditions.checkNotNull(timer);
this.hf = new BGPHandlerFactory(messageRegistry);
}
package org.opendaylight.protocol.bgp.testtool;
import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.util.HashedWheelTimer;
import io.netty.util.concurrent.GlobalEventExecutor;
import java.net.InetAddress;
private static final int RECONNECT_MILLIS = 5000;
private Main() throws Exception {
- this.dispatcher = new BGPDispatcherImpl(ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getMessageRegistry(), new NioEventLoopGroup(), new NioEventLoopGroup());
+ this.dispatcher = new BGPDispatcherImpl(ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getMessageRegistry(),
+ new HashedWheelTimer(), new NioEventLoopGroup(), new NioEventLoopGroup());
}
public static void main(final String[] args) throws Exception {
<artifactId>netty-config-api</artifactId>
<version>${controller.config.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netty-timer-config</artifactId>
+ <version>${controller.config.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-api</artifactId>