@After
public void closeAllModules() throws Exception {
- // FIXME: re-activate once test succeed
- // super.destroyAllConfigBeans();
+ super.destroyAllConfigBeans();
}
public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
import static org.junit.Assert.fail;
import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
import org.junit.Before;
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.pcep.stateful02.cfg.AbstractStateful02PCEPSessionProposalFactoryModuleFactory;
import org.opendaylight.controller.config.yang.pcep.stateful02.cfg.Stateful02PCEPSessionProposalFactoryModuleFactory;
import org.opendaylight.controller.config.yang.pcep.stateful02.cfg.Stateful02PCEPSessionProposalFactoryModuleMXBean;
public class PCEPSessionProposalFactoryImplModuleTest extends AbstractConfigTest {
- private final String instanceName = "pcep-proposal";
-
- private Stateful02PCEPSessionProposalFactoryModuleFactory factory;
-
- @Before
- public void setUp() throws Exception {
- this.factory = new Stateful02PCEPSessionProposalFactoryModuleFactory();
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory));
- }
-
- @Test
- public void testValidationExceptionDeadTimerValueNotSet() throws InstanceAlreadyExistsException {
- try {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, null, 100, true, true, true);
- transaction.validateConfig();
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("DeadTimerValue value is not set"));
- }
- }
-
- @Test
- public void testValidationExceptionKeepAliveTimerNotSet() throws InstanceAlreadyExistsException {
- try {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, null, true, true, true);
- transaction.validateConfig();
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("KeepAliveTimerValue value is not set"));
- }
- }
-
- @Test
- public void testValidationExceptionStatefulNotSet() throws InstanceAlreadyExistsException {
- try {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, 100, null, false, false);
- transaction.validateConfig();
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("Stateful value is not set"));
- }
- }
-
- @Test
- public void testValidationExceptionActiveNotSet() throws InstanceAlreadyExistsException {
- try {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, 100, true, null, true);
- transaction.validateConfig();
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("Active value is not set"));
- }
- }
-
- @Test
- public void testValidationExceptionInstantiatedNotSet() throws InstanceAlreadyExistsException {
- try {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, 100, true, true, null);
- transaction.validateConfig();
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("Initiated value is not set"));
- }
- }
-
- @Test
- public void testValidationExceptionKeepAliveTimerMinValue() throws InstanceAlreadyExistsException {
- try {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, -10, true, true, true);
- transaction.validateConfig();
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("minimum value is 1."));
- }
- }
-
- @Test
- public void testStatefulAfterCommitted() throws InstanceAlreadyExistsException, InstanceNotFoundException, ValidationException, ConflictingVersionException {
- ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, 100, false, true, true);
- transaction.validateConfig();
- transaction.commit();
- transaction = this.configRegistryClient.createTransaction();
- final Stateful02PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMBeanProxy(
- transaction.lookupConfigBean(AbstractStateful02PCEPSessionProposalFactoryModuleFactory.NAME, this.instanceName),
- Stateful02PCEPSessionProposalFactoryModuleMXBean.class);
- assertTrue(mxBean.getStateful());
- }
-
- @Test
- public void testCreateBean() throws Exception {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 0, 0, true, true, true);
- transaction.validateConfig();
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, this.factory.getImplementationName());
- assertStatus(status, 1, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
- ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, 100, true, true, true);
- transaction.commit();
- transaction = this.configRegistryClient.createTransaction();
- assertBeanCount(1, this.factory.getImplementationName());
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, this.factory.getImplementationName());
- assertStatus(status, 0, 0, 1);
- }
-
- @Test
- public void testReconfigure() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException,
- InstanceNotFoundException {
- ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, 100, true, true, true);
- transaction.commit();
- transaction = this.configRegistryClient.createTransaction();
- assertBeanCount(1, this.factory.getImplementationName());
- final Stateful02PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMBeanProxy(
- transaction.lookupConfigBean(AbstractStateful02PCEPSessionProposalFactoryModuleFactory.NAME, this.instanceName),
- Stateful02PCEPSessionProposalFactoryModuleMXBean.class);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, this.factory.getImplementationName());
- assertStatus(status, 0, 0, 1);
- }
-
- public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
- final String instanceName, final Integer deadTimer, final Integer keepAlive, final Boolean stateful, final Boolean active,
- final Boolean instant) throws InstanceAlreadyExistsException {
- final ObjectName nameCreated = transaction.createModule(moduleName, instanceName);
- final Stateful02PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
- Stateful02PCEPSessionProposalFactoryModuleMXBean.class);
- mxBean.setActive(active);
- mxBean.setDeadTimerValue(deadTimer);
- mxBean.setInitiated(instant);
- mxBean.setKeepAliveTimerValue(keepAlive);
- mxBean.setStateful(stateful);
- return nameCreated;
- }
+ private static final String INSTANCE_NAME = "pcep-stateful02-session-proposal-factroy-impl";
+ private static final String FACTROY_NAME = Stateful02PCEPSessionProposalFactoryModuleFactory.NAME;
+
+ @Before
+ public void setUp() throws Exception {
+ Stateful02PCEPSessionProposalFactoryModuleFactory factory = new Stateful02PCEPSessionProposalFactoryModuleFactory();
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+ }
+
+ @Test
+ public void testValidationExceptionDeadTimerValueNotSet() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createStateful02SessionInstance(null, 100, true, true, true, 0);
+ fail();
+ } catch (final ValidationException e) {
+ assertTrue(e.getMessage().contains("DeadTimerValue value is not set"));
+ }
+ }
+
+ @Test
+ public void testValidationExceptionKeepAliveTimerNotSet() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createStateful02SessionInstance(400, null, true, true, true, 0);
+ fail();
+ } catch (final ValidationException e) {
+ assertTrue(e.getMessage().contains("KeepAliveTimerValue value is not set"));
+ }
+ }
+
+ @Test
+ public void testValidationExceptionStatefulNotSet() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createStateful02SessionInstance(400, 100, null, false, false, 0);
+ fail();
+ } catch (final ValidationException e) {
+ assertTrue(e.getMessage().contains("Stateful value is not set"));
+ }
+ }
+
+ @Test
+ public void testValidationExceptionActiveNotSet() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createStateful02SessionInstance(400, 100, true, null, true, 0);
+ fail();
+ } catch (final ValidationException e) {
+ assertTrue(e.getMessage().contains("Active value is not set"));
+ }
+ }
+
+ @Test
+ public void testValidationExceptionInstantiatedNotSet() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createStateful02SessionInstance(400, 100, true, true, null, 0);
+ fail();
+ } catch (final ValidationException e) {
+ assertTrue(e.getMessage().contains("Initiated value is not set"));
+ }
+ }
+
+ @Test
+ public void testValidationExceptionTimeoutNotSet() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createStateful02SessionInstance(400, 100, true, true, true, null);
+ fail();
+ } catch (final ValidationException e) {
+ assertTrue(e.getMessage().contains("Timeout value is not set"));
+ }
+ }
+
+ @Test
+ public void testValidationExceptionKeepAliveTimerMinValue() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createStateful02SessionInstance(400, -10, true, true, true, 0);
+ fail();
+ } catch (final ValidationException e) {
+ assertTrue(e.getMessage().contains("minimum value is 1."));
+ }
+ }
+
+ @Test
+ public void testStatefulAfterCommitted() throws Exception {
+ createStateful02SessionInstance(400, 100, false, true, true, 0);
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ final Stateful02PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMBeanProxy(
+ transaction.lookupConfigBean(FACTROY_NAME, INSTANCE_NAME),
+ Stateful02PCEPSessionProposalFactoryModuleMXBean.class);
+ assertTrue(mxBean.getStateful());
+ }
+
+ @Test
+ public void testCreateBean() throws Exception {
+ final CommitStatus status = createStateful02SessionInstance(0, 0, true, true, true, 0);
+ assertBeanCount(1, FACTROY_NAME);
+ assertStatus(status, 1, 0, 0);
+ }
+
+ @Test
+ public void testReusingOldInstance() throws Exception {
+ createStateful02SessionInstance(400, 100, true, true, true, 0);
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTROY_NAME);
+ final CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTROY_NAME);
+ assertStatus(status, 0, 0, 1);
+ }
+
+ @Test
+ public void testReconfigure() throws Exception {
+ createStateful02SessionInstance(400, 100, true, true, true, 0);
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTROY_NAME);
+ transaction.newMBeanProxy(transaction.lookupConfigBean(FACTROY_NAME, INSTANCE_NAME),
+ Stateful02PCEPSessionProposalFactoryModuleMXBean.class);
+ final CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTROY_NAME);
+ assertStatus(status, 0, 0, 1);
+ }
+
+ private CommitStatus createStateful02SessionInstance(final Integer deadTimer, final Integer keepAlive,
+ final Boolean isStateful, final Boolean isActive, final Boolean isInstant, final Integer timeout)
+ throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ createStateful02SessionInstance(transaction, deadTimer, keepAlive, isStateful, isActive, isInstant, timeout);
+ return transaction.commit();
+ }
+
+ public static ObjectName createStateful02SessionInstance(final ConfigTransactionJMXClient transaction,
+ final Integer deadTimer, final Integer keepAlive, final Boolean stateful, final Boolean active,
+ final Boolean instant, final Integer timeout) throws InstanceAlreadyExistsException {
+ final ObjectName nameCreated = transaction.createModule(FACTROY_NAME, INSTANCE_NAME);
+ final Stateful02PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+ Stateful02PCEPSessionProposalFactoryModuleMXBean.class);
+ mxBean.setActive(active);
+ mxBean.setDeadTimerValue(deadTimer);
+ mxBean.setInitiated(instant);
+ mxBean.setKeepAliveTimerValue(keepAlive);
+ mxBean.setStateful(stateful);
+ mxBean.setTimeout(timeout);
+ return nameCreated;
+ }
}
import static org.junit.Assert.fail;
import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
import org.junit.Before;
public class PCEPDispatcherImplModuleTest extends AbstractConfigTest {
- private final String instanceName = "pcep-dispatcher";
-
- private PCEPDispatcherImplModuleFactory factory;
-
- private PCEPSessionProposalFactoryImplModuleFactory sessionFactory;
-
- private NettyThreadgroupModuleFactory threadgroupFactory;
-
- private SimplePCEPExtensionProviderContextModuleFactory extensionsFactory;
-
- private HashedWheelTimerModuleFactory timerFactory;
-
- @Before
- public void setUp() throws Exception {
- this.factory = new PCEPDispatcherImplModuleFactory();
- this.sessionFactory = new PCEPSessionProposalFactoryImplModuleFactory();
- this.threadgroupFactory = new NettyThreadgroupModuleFactory();
- this.extensionsFactory = new SimplePCEPExtensionProviderContextModuleFactory();
- this.timerFactory = new HashedWheelTimerModuleFactory();
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
- factory, sessionFactory, threadgroupFactory, extensionsFactory,
- timerFactory));
- }
-
- @Test
- public void testValidationExceptionMaxUnknownMessagesNotSet()
- throws InstanceAlreadyExistsException {
- try {
- ConfigTransactionJMXClient transaction = configRegistryClient
- .createTransaction();
- createInstance(transaction, this.factory.getImplementationName(),
- instanceName, null,
- this.sessionFactory.getImplementationName(),
- this.threadgroupFactory.getImplementationName(),
- this.extensionsFactory.getImplementationName(),
- this.timerFactory.getImplementationName());
- transaction.validateConfig();
- fail();
- } catch (ValidationException e) {
- assertTrue(e.getMessage().contains(
- "MaxUnknownMessages value is not set"));
- }
- }
-
- @Test
- public void testValidationExceptionMaxUnknownMessagesMinValue()
- throws InstanceAlreadyExistsException {
- try {
- ConfigTransactionJMXClient transaction = configRegistryClient
- .createTransaction();
- createInstance(transaction, this.factory.getImplementationName(),
- instanceName, 0,
- this.sessionFactory.getImplementationName(),
- this.threadgroupFactory.getImplementationName(),
- this.extensionsFactory.getImplementationName(),
- this.timerFactory.getImplementationName());
- transaction.validateConfig();
- fail();
- } catch (ValidationException e) {
- assertTrue(e.getMessage().contains("must be greater than 0"));
- }
- }
-
- @Test
- public void testCreateBean() throws Exception {
- ConfigTransactionJMXClient transaction = configRegistryClient
- .createTransaction();
- createInstance(transaction, this.factory.getImplementationName(),
- instanceName, 5, this.sessionFactory.getImplementationName(),
- this.threadgroupFactory.getImplementationName(),
- this.extensionsFactory.getImplementationName(),
- this.timerFactory.getImplementationName());
- transaction.validateConfig();
- CommitStatus status = transaction.commit();
- assertBeanCount(1, factory.getImplementationName());
- assertStatus(status, 6, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws InstanceAlreadyExistsException,
- ConflictingVersionException, ValidationException {
- ConfigTransactionJMXClient transaction = configRegistryClient
- .createTransaction();
- createInstance(transaction, this.factory.getImplementationName(),
- instanceName, 5, this.sessionFactory.getImplementationName(),
- this.threadgroupFactory.getImplementationName(),
- this.extensionsFactory.getImplementationName(),
- this.timerFactory.getImplementationName());
- transaction.commit();
- transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, factory.getImplementationName());
- CommitStatus status = transaction.commit();
- assertBeanCount(1, factory.getImplementationName());
- assertStatus(status, 0, 0, 6);
- }
-
- @Test
- public void testReconfigure() throws InstanceAlreadyExistsException,
- ConflictingVersionException, ValidationException,
- InstanceNotFoundException {
- ConfigTransactionJMXClient transaction = configRegistryClient
- .createTransaction();
- createInstance(transaction, this.factory.getImplementationName(),
- instanceName, 5, this.sessionFactory.getImplementationName(),
- this.threadgroupFactory.getImplementationName(),
- this.extensionsFactory.getImplementationName(),
- this.timerFactory.getImplementationName());
- transaction.commit();
- transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, factory.getImplementationName());
- PCEPDispatcherImplModuleMXBean mxBean = transaction.newMBeanProxy(
- transaction.lookupConfigBean(
- this.factory.getImplementationName(), instanceName),
- PCEPDispatcherImplModuleMXBean.class);
- mxBean.setMaxUnknownMessages(10);
- CommitStatus status = transaction.commit();
- assertBeanCount(1, factory.getImplementationName());
- assertStatus(status, 0, 1, 5);
- }
-
- public static ObjectName createInstance(
- final ConfigTransactionJMXClient transaction,
- final String moduleName, final String instanceName,
- final Integer maxUnknownMessages,
- final String sessionFactoryImplName,
- final String threadGroupFactoryImplName,
- final String extensionsImplName, final String timerFactoryImplName)
- throws InstanceAlreadyExistsException {
- ObjectName nameCreated = transaction.createModule(moduleName,
- instanceName);
- PCEPDispatcherImplModuleMXBean mxBean = transaction.newMBeanProxy(
- nameCreated, PCEPDispatcherImplModuleMXBean.class);
- mxBean.setPcepSessionProposalFactory(PCEPSessionProposalFactoryImplModuleTest
- .createInstance(transaction, sessionFactoryImplName,
- "pcep-proposal", 0, 0));
- mxBean.setMaxUnknownMessages(maxUnknownMessages);
- mxBean.setBossGroup(createThreadGroupInstance(transaction,
- threadGroupFactoryImplName, "boss-group", 10));
- mxBean.setWorkerGroup(createThreadGroupInstance(transaction,
- threadGroupFactoryImplName, "worker-group", 10));
- mxBean.setPcepExtensions(createExtensionsInstance(transaction,
- extensionsImplName, "extensions"));
- mxBean.setTimer(createTimerInstance(transaction, timerFactoryImplName,
- "timmer1"));
- return nameCreated;
- }
-
- public static ObjectName createExtensionsInstance(
- final ConfigTransactionJMXClient transaction,
- final String moduleName, final String instanceName)
- throws InstanceAlreadyExistsException {
- ObjectName nameCreated = transaction.createModule(moduleName,
- instanceName);
- transaction.newMBeanProxy(nameCreated,
- SimplePCEPExtensionProviderContextModuleMXBean.class);
-
- return nameCreated;
- }
-
- public static ObjectName createThreadGroupInstance(
- final ConfigTransactionJMXClient transaction,
- final String moduleName, final String instanceName,
- final Integer threadCount) throws InstanceAlreadyExistsException {
- ObjectName nameCreated = transaction.createModule(moduleName,
- instanceName);
- NettyThreadgroupModuleMXBean mxBean = transaction.newMBeanProxy(
- nameCreated, NettyThreadgroupModuleMXBean.class);
- mxBean.setThreadCount(threadCount);
- return nameCreated;
- }
-
- public static ObjectName createTimerInstance(
- final ConfigTransactionJMXClient transaction,
- final String moduleName, final String instanceName)
- throws InstanceAlreadyExistsException {
- ObjectName nameCreated = transaction.createModule(moduleName,
- instanceName);
- transaction.newMBeanProxy(nameCreated,
- HashedWheelTimerModuleMXBean.class);
- return nameCreated;
- }
+ private static final String INSTANCE_NAME = "pcep-dispatcher-impl";
+ private static final String FACTORY_NAME = PCEPDispatcherImplModuleFactory.NAME;
+
+ private static final String TIMER_INSTANCE_NAME = "hashed-wheel-timer";
+ private static final String TIMER_FACTORY_NAME = HashedWheelTimerModuleFactory.NAME;
+
+ private static final String THREADGROUP_FACTORY_NAME = NettyThreadgroupModuleFactory.NAME;
+ private static final String BOSS_TG_INSTANCE_NAME = "boss-group";
+ private static final String WORKER_TG_INSTANCE_NAME = "worker-group";
+
+ private static final String EXTENSION_INSTANCE_NAME = "pcep-extension-privider";
+ private static final String EXTENSION_FACTORYNAME = SimplePCEPExtensionProviderContextModuleFactory.NAME;
+
+ @Before
+ public void setUp() throws Exception {
+ final PCEPDispatcherImplModuleFactory factory = new PCEPDispatcherImplModuleFactory();
+ final PCEPSessionProposalFactoryImplModuleFactory sessionFactory = new PCEPSessionProposalFactoryImplModuleFactory();
+ final NettyThreadgroupModuleFactory threadgroupFactory = new NettyThreadgroupModuleFactory();
+ final SimplePCEPExtensionProviderContextModuleFactory extensionsFactory = new SimplePCEPExtensionProviderContextModuleFactory();
+ final HashedWheelTimerModuleFactory timerFactory = new HashedWheelTimerModuleFactory();
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory, sessionFactory,
+ threadgroupFactory, extensionsFactory, timerFactory));
+ }
+
+ @Test
+ public void testValidationExceptionMaxUnknownMessagesNotSet() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createDispatcherInstance(null);
+ fail();
+ } catch (ValidationException e) {
+ assertTrue(e.getMessage().contains("MaxUnknownMessages value is not set"));
+ }
+ }
+
+ @Test
+ public void testValidationExceptionMaxUnknownMessagesMinValue() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createDispatcherInstance(0);
+ fail();
+ } catch (ValidationException e) {
+ assertTrue(e.getMessage().contains("must be greater than 0"));
+ }
+ }
+
+ @Test
+ public void testCreateBean() throws Exception {
+ final CommitStatus status = createDispatcherInstance(5);
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 6, 0, 0);
+ }
+
+ @Test
+ public void testReusingOldInstance() throws Exception {
+ createDispatcherInstance(5);
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTORY_NAME);
+ final CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 0, 0, 6);
+ }
+
+ @Test
+ public void testReconfigure() throws Exception {
+ createDispatcherInstance(5);
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTORY_NAME);
+ final PCEPDispatcherImplModuleMXBean mxBean = transaction.newMBeanProxy(
+ transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), PCEPDispatcherImplModuleMXBean.class);
+ mxBean.setMaxUnknownMessages(10);
+ final CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 0, 1, 5);
+ }
+
+ private CommitStatus createDispatcherInstance(final Integer maxUnknownMessages)
+ throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ createDispatcherInstance(transaction, maxUnknownMessages);
+ return transaction.commit();
+ }
+
+ private static ObjectName createDispatcherInstance(final ConfigTransactionJMXClient transaction,
+ final Integer maxUnknownMessages) throws InstanceAlreadyExistsException {
+ final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
+ final PCEPDispatcherImplModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+ PCEPDispatcherImplModuleMXBean.class);
+ mxBean.setPcepSessionProposalFactory(PCEPSessionProposalFactoryImplModuleTest.createSessionInstance(
+ transaction, 0, 0));
+ mxBean.setMaxUnknownMessages(maxUnknownMessages);
+ mxBean.setBossGroup(createThreadGroupInstance(transaction, 10, BOSS_TG_INSTANCE_NAME));
+ mxBean.setWorkerGroup(createThreadGroupInstance(transaction, 10, WORKER_TG_INSTANCE_NAME));
+ mxBean.setPcepExtensions(createExtensionsInstance(transaction));
+ mxBean.setTimer(createTimerInstance(transaction));
+ return nameCreated;
+ }
+
+ private static ObjectName createExtensionsInstance(final ConfigTransactionJMXClient transaction)
+ throws InstanceAlreadyExistsException {
+ final ObjectName nameCreated = transaction.createModule(EXTENSION_FACTORYNAME, EXTENSION_INSTANCE_NAME);
+ transaction.newMBeanProxy(nameCreated, SimplePCEPExtensionProviderContextModuleMXBean.class);
+
+ return nameCreated;
+ }
+
+ private static ObjectName createThreadGroupInstance(final ConfigTransactionJMXClient transaction,
+ final Integer threadCount, final String instanceName) throws InstanceAlreadyExistsException {
+ final ObjectName nameCreated = transaction.createModule(THREADGROUP_FACTORY_NAME, instanceName);
+ final NettyThreadgroupModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+ NettyThreadgroupModuleMXBean.class);
+ mxBean.setThreadCount(threadCount);
+ return nameCreated;
+ }
+
+ private static ObjectName createTimerInstance(final ConfigTransactionJMXClient transaction)
+ throws InstanceAlreadyExistsException {
+ final ObjectName nameCreated = transaction.createModule(TIMER_FACTORY_NAME, TIMER_INSTANCE_NAME);
+ transaction.newMBeanProxy(nameCreated, HashedWheelTimerModuleMXBean.class);
+ return nameCreated;
+ }
}
import static org.junit.Assert.fail;
import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
import org.junit.Before;
public class PCEPSessionProposalFactoryImplModuleTest extends AbstractConfigTest {
- private final String instanceName = "pcep-proposal";
+ private static final String INSTANCE_NAME = "pcep-session-proposal-factory-impl";
+ private static final String FACTORY_NAME = PCEPSessionProposalFactoryImplModuleFactory.NAME;
- private PCEPSessionProposalFactoryImplModuleFactory factory;
+ @Before
+ public void setUp() throws Exception {
+ final PCEPSessionProposalFactoryImplModuleFactory factory = new PCEPSessionProposalFactoryImplModuleFactory();
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
+ }
- @Before
- public void setUp() throws Exception {
- this.factory = new PCEPSessionProposalFactoryImplModuleFactory();
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.factory));
- }
+ @Test
+ public void testValidationExceptionDeadTimerValueNotSet() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createSessionInstance(null, 100);
+ fail();
+ } catch (final ValidationException e) {
+ assertTrue(e.getMessage().contains("DeadTimerValue value is not set"));
+ }
+ }
- @Test
- public void testValidationExceptionDeadTimerValueNotSet() throws InstanceAlreadyExistsException {
- try {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, null, 100);
- transaction.validateConfig();
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("DeadTimerValue value is not set"));
- }
- }
+ @Test
+ public void testValidationExceptionKeepAliveTimerNotSet() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createSessionInstance(400, null);
+ fail();
+ } catch (final ValidationException e) {
+ assertTrue(e.getMessage().contains("KeepAliveTimerValue value is not set"));
+ }
+ }
- @Test
- public void testValidationExceptionKeepAliveTimerNotSet() throws InstanceAlreadyExistsException {
- try {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, null);
- transaction.validateConfig();
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("KeepAliveTimerValue value is not set"));
- }
- }
+ @Test
+ public void testValidationExceptionKeepAliveTimerMinValue() throws InstanceAlreadyExistsException,
+ ConflictingVersionException {
+ try {
+ createSessionInstance(400, -10);
+ fail();
+ } catch (final ValidationException e) {
+ assertTrue(e.getMessage().contains("minimum value is 1."));
+ }
+ }
- @Test
- public void testValidationExceptionKeepAliveTimerMinValue() throws InstanceAlreadyExistsException {
- try {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, -10);
- transaction.validateConfig();
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("minimum value is 1."));
- }
- }
+ @Test
+ public void testCreateBean() throws Exception {
+ final CommitStatus status = createSessionInstance(0, 0);
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 1, 0, 0);
+ }
- @Test
- public void testCreateBean() throws Exception {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 0, 0);
- transaction.validateConfig();
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, this.factory.getImplementationName());
- assertStatus(status, 1, 0, 0);
- }
+ @Test
+ public void testReusingOldInstance() throws Exception {
+ createSessionInstance(400, 100);
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTORY_NAME);
+ final CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 0, 0, 1);
+ }
- @Test
- public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
- ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, 100);
- transaction.commit();
- transaction = this.configRegistryClient.createTransaction();
- assertBeanCount(1, this.factory.getImplementationName());
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, this.factory.getImplementationName());
- assertStatus(status, 0, 0, 1);
- }
+ @Test
+ public void testReconfigure() throws Exception {
+ createSessionInstance(400, 100);
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTORY_NAME);
+ transaction.newMBeanProxy(transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
+ PCEPSessionProposalFactoryImplModuleMXBean.class);
+ final CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 0, 0, 1);
+ }
- @Test
- public void testReconfigure() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException,
- InstanceNotFoundException {
- ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createInstance(transaction, this.factory.getImplementationName(), this.instanceName, 400, 100);
- transaction.commit();
- transaction = this.configRegistryClient.createTransaction();
- assertBeanCount(1, this.factory.getImplementationName());
- final PCEPSessionProposalFactoryImplModuleMXBean mxBean = transaction.newMBeanProxy(
- transaction.lookupConfigBean(AbstractPCEPSessionProposalFactoryImplModuleFactory.NAME, this.instanceName),
- PCEPSessionProposalFactoryImplModuleMXBean.class);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, this.factory.getImplementationName());
- assertStatus(status, 0, 0, 1);
- }
+ private CommitStatus createSessionInstance(final Integer deadTimer, final Integer keepAlive)
+ throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ createSessionInstance(transaction, deadTimer, keepAlive);
+ return transaction.commit();
+ }
- public static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String moduleName,
- final String instanceName, final Integer deadTimer, final Integer keepAlive) throws InstanceAlreadyExistsException {
- final ObjectName nameCreated = transaction.createModule(moduleName, instanceName);
- final PCEPSessionProposalFactoryImplModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
- PCEPSessionProposalFactoryImplModuleMXBean.class);
- mxBean.setDeadTimerValue(deadTimer);
- mxBean.setKeepAliveTimerValue(keepAlive);
- return nameCreated;
- }
+ public static ObjectName createSessionInstance(final ConfigTransactionJMXClient transaction,
+ final Integer deadTimer, final Integer keepAlive) throws InstanceAlreadyExistsException {
+ final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
+ final PCEPSessionProposalFactoryImplModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated,
+ PCEPSessionProposalFactoryImplModuleMXBean.class);
+ mxBean.setDeadTimerValue(deadTimer);
+ mxBean.setKeepAliveTimerValue(keepAlive);
+ return nameCreated;
+ }
}
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.JdkFutureAdapters;
private final Map<SRPID, PCEPRequest> waitingRequests = new HashMap<>();
private final Map<SRPID, PCEPRequest> sendingRequests = new HashMap<>();
+ private final Map<String, ReportedLsp> lspData = new HashMap<>();
private final Map<PLSPID, String> lsps = new HashMap<>();
private InstanceIdentifier<Node> topologyNode;
private InstanceIdentifier<Node1> topologyAugment;
private Node1Builder topologyAugmentBuilder;
private TopologyNodeState nodeState;
private boolean ownsTopology = false;
- private boolean synced = false;
+ private boolean synced = false, dirty;
private PCEPSession session;
protected AbstractTopologySessionListener(final ServerSessionManager serverSessionManager) {
public final synchronized void onMessage(final PCEPSession session, final Message message) {
final DataModificationTransaction trans = this.serverSessionManager.beginTransaction();
+ dirty = false;
+
if (onMessage(trans, message)) {
LOG.info("Unhandled message {} on session {}", message, session);
return;
}
+ if (dirty) {
+ LOG.debug("Internal state changed, forcing sync");
+ this.pccBuilder.setReportedLsp(Lists.newArrayList(lspData.values()));
+ this.topologyAugmentBuilder.setPathComputationClient(this.pccBuilder.build());
+ final Node1 ta = this.topologyAugmentBuilder.build();
+
+ //trans.removeOperationalData(this.topologyAugment);
+ trans.putOperationalData(this.topologyAugment, ta);
+ LOG.debug("Peer data {} set to {}", this.topologyAugment, ta);
+ dirty = false;
+ } else {
+ LOG.debug("State has not changed, skipping sync");
+ }
+
Futures.addCallback(JdkFutureAdapters.listenInPoolThread(trans.commit()), new FutureCallback<RpcResult<TransactionStatus>>() {
@Override
public void onSuccess(final RpcResult<TransactionStatus> result) {
rlb.setMetadata(this.nodeState.getLspMetadata(name));
}
- LOG.debug("Updating LSP to MD-SAL {}", rlb.build());
- trans.putOperationalData(lspIdentifier(name).build(), rlb.build());
+ LOG.debug("LSP {} forcing update to MD-SAL", name);
+ dirty = true;
+ lspData .put(name, rlb.build());
}
protected final synchronized void stateSynchronizationAchieved(final DataModificationTransaction trans) {
// Update synchronization flag
this.synced = true;
- this.topologyAugmentBuilder.setPathComputationClient(this.pccBuilder.setStateSync(PccSyncState.Synchronized).build());
- final Node1 ta = this.topologyAugmentBuilder.build();
- trans.putOperationalData(this.topologyAugment, ta);
- LOG.debug("Peer data {} set to {}", this.topologyAugment, ta);
+ this.pccBuilder.setStateSync(PccSyncState.Synchronized).build();
+ this.dirty = true;
// The node has completed synchronization, cleanup metadata no longer reported back
this.nodeState.cleanupExcept(this.lsps.values());
protected final synchronized void removeLsp(final DataModificationTransaction trans, final PLSPID id) {
final String name = this.lsps.remove(id);
- if (name != null) {
- trans.removeOperationalData(lspIdentifier(name).build());
- }
-
+ dirty = true;
LOG.debug("LSP {} removed", name);
+ lspData.remove(name);
}
abstract protected void onSessionUp(PCEPSession session, PathComputationClientBuilder pccBuilder);
final ReportedLspBuilder rlb = new ReportedLspBuilder();
rlb.addAugmentation(ReportedLsp1.class, new ReportedLsp1Builder().setLsp(r.getLsp()).build());
+ if (r.getPath() != null) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder();
+ pb.fieldsFrom(r.getPath());
+ rlb.setPath(pb.build());
+ }
boolean solicited = false;
if (id.getValue() != 0) {
rb.setLsp(new LspBuilder().setPlspId(ra.getLsp().getPlspId()).setDelegate(Boolean.TRUE).setOperational(input.getArguments().getAugmentation(Arguments2.class).isOperational()).build());
final PathBuilder pb = new PathBuilder();
rb.setPath(pb.setEro(input.getArguments().getEro()).build());
-
+ pb.fieldsFrom(input.getArguments());
+ rb.setPath(pb.build());
final PcupdMessageBuilder ub = new PcupdMessageBuilder(MESSAGE_HEADER);
ub.setUpdates(ImmutableList.of(rb.build()));
return sendMessage(new PcupdBuilder().setPcupdMessage(ub.build()).build(), rep.getName(), input.getArguments().getMetadata());
final ReportedLspBuilder rlb = new ReportedLspBuilder();
rlb.addAugmentation(ReportedLsp1.class, new ReportedLsp1Builder(r).build());
+ if (r.getPath() != null) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder();
+ pb.fieldsFrom(r.getPath());
+ rlb.setPath(pb.build());
+ }
boolean solicited = false;
final Srp srp = r.getSrp();
rb.setSrp(new SrpBuilder().setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE).build());
rb.setLsp(new LspBuilder().setAdministrative(input.getArguments().isAdministrative()).setDelegate(Boolean.TRUE).setPlspId(
new PlspId(0L)).setTlvs(
- new TlvsBuilder().setSymbolicPathName(
- new SymbolicPathNameBuilder().setPathName(new SymbolicPathName(input.getName().getBytes(Charsets.UTF_8))).build()).build()).build());
+ new TlvsBuilder().setSymbolicPathName(
+ new SymbolicPathNameBuilder().setPathName(new SymbolicPathName(input.getName().getBytes(Charsets.UTF_8))).build()).build()).build());
final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
ib.setRequests(ImmutableList.of(rb.build()));
rb.setLsp(new LspBuilder().setPlspId(ra.getLsp().getPlspId()).setDelegate(Boolean.TRUE).build());
final PathBuilder pb = new PathBuilder();
rb.setPath(pb.setEro(input.getArguments().getEro()).build());
-
+ pb.fieldsFrom(input.getArguments());
+ rb.setPath(pb.build());
final PcupdMessageBuilder ub = new PcupdMessageBuilder(MESSAGE_HEADER);
ub.setUpdates(ImmutableList.of(rb.build()));
return sendMessage(new PcupdBuilder().setPcupdMessage(ub.build()).build(), rb.getSrp().getOperationId(),