BUG-6973: Wire Programming with BP 02/53402/4
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 1 Mar 2017 11:24:05 +0000 (12:24 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 11 Apr 2017 13:28:46 +0000 (13:28 +0000)
-Wire Programming with BP
-Preserve backwards compatibility

Change-Id: I750fdb86a6c22d3b1a90e7466466ab7c5426d729
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
12 files changed:
pcep/topology-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/topology/provider/PCEPTopologyProviderModuleTest.java [deleted file]
pcep/topology-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/topology/provider/Stateful07TopologySessionListenerModuleTest.java [deleted file]
pcep/tunnel-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/tunnel/provider/PCEPTunnelTopologyProviderModuleTest.java [deleted file]
programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/InstructionDeployedImpl.java [new file with mode: 0644]
programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/IntructionDeployer.java [new file with mode: 0644]
programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/ProgrammingServiceImpl.java
programming/impl/src/main/java/org/opendaylight/controller/config/yang/programming/impl/InstructionSchedulerImplModule.java
programming/impl/src/main/java/org/opendaylight/controller/config/yang/programming/impl/InstructionSchedulerImplModuleFactory.java
programming/impl/src/main/resources/org/opendaylight/blueprint/programming.xml [new file with mode: 0644]
programming/impl/src/test/java/org/opendaylight/bgpcep/programming/impl/ProgrammingServiceImplTest.java
programming/impl/src/test/java/org/opendaylight/controller/config/yang/programming/impl/AbstractInstructionSchedulerTest.java [deleted file]
programming/impl/src/test/java/org/opendaylight/controller/config/yang/programming/impl/InstructionSchedulerImplModuleTest.java [deleted file]

diff --git a/pcep/topology-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/topology/provider/PCEPTopologyProviderModuleTest.java b/pcep/topology-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/topology/provider/PCEPTopologyProviderModuleTest.java
deleted file mode 100644 (file)
index c18ccfa..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.pcep.topology.provider;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import io.netty.channel.nio.NioEventLoopGroup;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleMXBean;
-import org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerTest;
-import org.opendaylight.protocol.pcep.PCEPDispatcher;
-import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
-import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
-import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
-import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
-import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
-import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
-
-public class PCEPTopologyProviderModuleTest extends AbstractInstructionSchedulerTest {
-
-    private static final String FACTORY_NAME = PCEPTopologyProviderModuleFactory.NAME;
-    private static final String INSTANCE_NAME = "pcep-topology-provider-instance";
-    private static final String STATEFUL07_TOPOLOGY_INSTANCE_NAME = "pcep-topology-stateful07-instance";
-
-    private static final String LISTEN_ADDRESS = "0.0.0.0";
-    private static final PortNumber LISTEN_PORT = new PortNumber(4189);
-    private static final TopologyId TOPOLOGY_ID = new TopologyId("pcep-topology");
-
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-
-        SimplePCEPExtensionProviderContext extContext = new SimplePCEPExtensionProviderContext();
-        setupMockService(PCEPExtensionProviderContext.class, extContext);
-        BasePCEPSessionProposalFactory proposalFactory = new BasePCEPSessionProposalFactory(120, 30,
-                Arrays.asList(new PCEPStatefulCapability(true, true, true, true, true, true, true)));
-        setupMockService(PCEPSessionProposalFactory.class, proposalFactory);
-        NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup();
-        setupMockService(PCEPDispatcher.class, new PCEPDispatcherImpl(extContext.getMessageHandlerRegistry(),
-                new DefaultPCEPSessionNegotiatorFactory(proposalFactory, 5), eventLoopGroup, eventLoopGroup));
-    }
-
-    @Test
-    public void testValidationExceptionListenAddressNotSet() throws Exception {
-        try {
-            createInstance(null, LISTEN_PORT, TOPOLOGY_ID, false);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("ListenAddress is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionListenPortNotSet() throws Exception {
-        try {
-            createInstance(LISTEN_ADDRESS, null, TOPOLOGY_ID, false);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("ListenPort is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionTopologyIdNotSet() throws Exception {
-        try {
-            createInstance(LISTEN_ADDRESS, LISTEN_PORT, null, false);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("TopologyId is not set"));
-        }
-    }
-
-    @Test
-    public void testCreateBean() throws Exception {
-        final CommitStatus status = createInstance(false);
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 13, 0, 0);
-    }
-
-    @Test
-    public void testReusingOldInstance() throws Exception {
-        createInstance(false);
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        assertBeanCount(1, FACTORY_NAME);
-        final CommitStatus status = transaction.commit();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 0, 13);
-    }
-
-    @Test
-    public void testReconfigure() throws Exception {
-        createInstance(false);
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        assertBeanCount(1, FACTORY_NAME);
-        final PCEPTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(
-                transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), PCEPTopologyProviderModuleMXBean.class);
-        mxBean.setTopologyId(new TopologyId("new-pcep-topology"));
-        final CommitStatus status = transaction.commit();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 1, 12);
-    }
-
-    private CommitStatus createInstance(final String listenAddress, final PortNumber listenPort,
-                                        final TopologyId topologyId, final boolean addMD5)
-            throws Exception {
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        createPCEPTopologyProviderModuleInstance(transaction, listenAddress, listenPort, topologyId, addMD5);
-        return transaction.commit();
-    }
-
-    private CommitStatus createInstance(final boolean addMD5) throws Exception {
-        return createInstance(LISTEN_ADDRESS, getRandomPortNumber(), TOPOLOGY_ID, addMD5);
-    }
-
-    public static ObjectName createPCEPTopologyProviderModuleInstance(final ConfigTransactionJMXClient transaction,
-            final ObjectName dataBrokerON, final ObjectName bindingBrokerON, final ObjectName schedulerON) throws Exception {
-        final ObjectName objectName = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
-        final PCEPTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(objectName, PCEPTopologyProviderModuleMXBean.class);
-        mxBean.setDataProvider(dataBrokerON);
-        mxBean.setDispatcher(createDispatcherInstance(transaction));
-
-        mxBean.setListenAddress(new IpAddress(LISTEN_ADDRESS.toCharArray()));
-        mxBean.setListenPort(getRandomPortNumber());
-        mxBean.setRpcRegistry(bindingBrokerON);
-        mxBean.setScheduler(schedulerON);
-        mxBean.setStatefulPlugin(transaction.createModule(Stateful07TopologySessionListenerModuleFactory.NAME,
-                STATEFUL07_TOPOLOGY_INSTANCE_NAME));
-        mxBean.setTopologyId(TOPOLOGY_ID);
-        return objectName;
-    }
-
-    public static ObjectName createDispatcherInstance(final ConfigTransactionJMXClient transaction)
-            throws Exception {
-        final ObjectName nameCreated = transaction.createModule(PCEPDispatcherImplModuleFactory.NAME, "pcep-dispatcher-impl");
-        transaction.newMXBeanProxy(nameCreated, PCEPDispatcherImplModuleMXBean.class);
-        return nameCreated;
-    }
-
-    private ObjectName createPCEPTopologyProviderModuleInstance(final ConfigTransactionJMXClient transaction, final String listenAddress,
-            final PortNumber listenPort, final TopologyId topologyId, final boolean addMD5) throws Exception {
-        final ObjectName objectName = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
-        final ObjectName notificationBrokerON = createNotificationBrokerInstance(transaction);
-        final ObjectName asyncDataBrokerON = createAsyncDataBrokerInstance(transaction);
-        final ObjectName bindingBrokerON = createBindingBrokerImpl(transaction, createCompatibleDataBrokerInstance(transaction), notificationBrokerON);
-
-        final PCEPTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(objectName, PCEPTopologyProviderModuleMXBean.class);
-        mxBean.setDataProvider(asyncDataBrokerON);
-        mxBean.setDispatcher(createDispatcherInstance(transaction));
-
-        if (addMD5) {
-            // create 1 client
-            final Client client = new Client();
-            client.setPassword(Rfc2385Key.getDefaultInstance("foo"));
-            client.setAddress(new IpAddress("127.0.0.1".toCharArray()));
-            mxBean.setClient(Arrays.asList(client));
-        }
-
-        mxBean.setListenAddress(listenAddress == null ? null : new IpAddress(listenAddress.toCharArray()));
-        mxBean.setListenPort(listenPort);
-        mxBean.setRpcRegistry(bindingBrokerON);
-        mxBean.setScheduler(createInstructionSchedulerModuleInstance(transaction, asyncDataBrokerON, bindingBrokerON,
-                notificationBrokerON));
-        mxBean.setStatefulPlugin(transaction.createModule(Stateful07TopologySessionListenerModuleFactory.NAME,
-                STATEFUL07_TOPOLOGY_INSTANCE_NAME));
-        mxBean.setTopologyId(topologyId);
-        return objectName;
-    }
-
-    @Override
-    public List<ModuleFactory> getModuleFactories() {
-        final List<ModuleFactory> moduleFactories = super.getModuleFactories();
-        moduleFactories.add(new PCEPTopologyProviderModuleFactory());
-        moduleFactories.add(new PCEPDispatcherImplModuleFactory());
-        moduleFactories.add(new NettyThreadgroupModuleFactory());
-        moduleFactories.add(new Stateful07TopologySessionListenerModuleFactory());
-        return moduleFactories;
-    }
-
-    private static PortNumber getRandomPortNumber() {
-        final Random random = new Random();
-        return new PortNumber(random.nextInt(65000 - 30000 + 1) + 30000);
-    }
-
-    @Override
-    public List<String> getYangModelsPaths() {
-        final List<String> paths = super.getYangModelsPaths();
-        paths.add("/META-INF/yang/network-topology@2013-10-21.yang");
-        paths.add("/META-INF/yang/network-topology-pcep.yang");
-        paths.add("/META-INF/yang/network-topology-pcep-programming.yang");
-        paths.add("/META-INF/yang/network-topology-programming.yang");
-        paths.add("/META-INF/yang/odl-network-topology.yang");
-        paths.add("/META-INF/yang/yang-ext.yang");
-        paths.add("/META-INF/yang/pcep-types.yang");
-        paths.add("/META-INF/yang/rsvp.yang");
-        paths.add("/META-INF/yang/iana.yang");
-        paths.add("/META-INF/yang/network-concepts.yang");
-        paths.add("/META-INF/yang/ieee754.yang");
-        return paths;
-    }
-}
diff --git a/pcep/topology-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/topology/provider/Stateful07TopologySessionListenerModuleTest.java b/pcep/topology-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/topology/provider/Stateful07TopologySessionListenerModuleTest.java
deleted file mode 100644 (file)
index 26c6600..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.pcep.topology.provider;
-
-import org.junit.Before;
-import org.junit.Test;
-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;
-
-public class Stateful07TopologySessionListenerModuleTest extends AbstractConfigTest {
-
-    private static final String FACTORY_NAME = Stateful07TopologySessionListenerModuleFactory.NAME;
-    private static final String INSTANCE_NAME = "pcep-topology-stateful07-instance";
-
-    @Before
-    public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new Stateful07TopologySessionListenerModuleFactory()));
-    }
-
-    @Test
-    public void testCreateBean() throws Exception {
-        CommitStatus status = createInstance();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 1, 0, 0);
-    }
-
-    @Test
-    public void testReusingOldInstance() throws Exception {
-        createInstance();
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        assertBeanCount(1, FACTORY_NAME);
-        CommitStatus status = transaction.commit();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 0, 1);
-    }
-
-    private CommitStatus createInstance() throws Exception {
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
-        return transaction.commit();
-    }
-
-}
diff --git a/pcep/tunnel-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/tunnel/provider/PCEPTunnelTopologyProviderModuleTest.java b/pcep/tunnel-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/tunnel/provider/PCEPTunnelTopologyProviderModuleTest.java
deleted file mode 100644 (file)
index b316753..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.pcep.tunnel.provider;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import io.netty.channel.nio.NioEventLoopGroup;
-import java.util.Arrays;
-import java.util.List;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleMXBean;
-import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleTest;
-import org.opendaylight.controller.config.yang.pcep.topology.provider.Stateful07TopologySessionListenerModuleFactory;
-import org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerTest;
-import org.opendaylight.protocol.pcep.PCEPDispatcher;
-import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
-import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
-import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
-import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
-import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
-import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
-
-public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSchedulerTest {
-
-    private static final String FACTORY_NAME = PCEPTunnelTopologyProviderModuleFactory.NAME;
-    private static final String INSTANCE_NAME = "pcep-tunnel-topology-provider-instance";
-
-    private static final TopologyId TOPOLOGY_ID = new TopologyId("pcep-topology");
-
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-
-        SimplePCEPExtensionProviderContext extContext = new SimplePCEPExtensionProviderContext();
-        setupMockService(PCEPExtensionProviderContext.class, extContext);
-        BasePCEPSessionProposalFactory proposalFactory = new BasePCEPSessionProposalFactory(120, 30,
-                Arrays.asList(new PCEPStatefulCapability(true, true, true, true, true, true, true)));
-        setupMockService(PCEPSessionProposalFactory.class, proposalFactory);
-        NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup();
-        setupMockService(PCEPDispatcher.class, new PCEPDispatcherImpl(extContext.getMessageHandlerRegistry(),
-                new DefaultPCEPSessionNegotiatorFactory(proposalFactory, 5), eventLoopGroup, eventLoopGroup));
-    }
-
-    @Test
-    public void testValidationExceptionTopologyIdNotSet() throws Exception {
-        try {
-            createInstance(null);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("TopologyId is not set"));
-        }
-    }
-
-    @Test
-    public void testCreateBean() throws Exception {
-        final CommitStatus status = createInstance();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 14, 0, 0);
-    }
-
-    @Test
-    public void testReusingOldInstance() throws Exception {
-        createInstance();
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        assertBeanCount(1, FACTORY_NAME);
-        final CommitStatus status = transaction.commit();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 0, 14);
-    }
-
-    @Test
-    public void testReconfigure() throws Exception {
-        createInstance();
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        assertBeanCount(1, FACTORY_NAME);
-        final PCEPTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(
-                transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), PCEPTopologyProviderModuleMXBean.class);
-        mxBean.setTopologyId(new TopologyId("new-pcep-topology"));
-        final CommitStatus status = transaction.commit();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 1, 13);
-    }
-
-    private CommitStatus createInstance(final TopologyId topologyId) throws Exception {
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        createPCEPTopologyProviderModuleInstance(transaction, topologyId);
-        return transaction.commit();
-    }
-
-    private CommitStatus createInstance() throws Exception {
-        return createInstance(TOPOLOGY_ID);
-    }
-
-    private ObjectName createPCEPTopologyProviderModuleInstance(final ConfigTransactionJMXClient transaction, final TopologyId topologyId)
-            throws Exception {
-        final ObjectName objectName = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
-        final ObjectName asyncDataBrokerON = createAsyncDataBrokerInstance(transaction);
-        final ObjectName dataBrokerON = createCompatibleDataBrokerInstance(transaction);
-        final ObjectName notificationBrokerON = createNotificationBrokerInstance(transaction);
-        final ObjectName bindingBrokerON = createBindingBrokerImpl(transaction, dataBrokerON, notificationBrokerON);
-        final ObjectName schedulerON = createInstructionSchedulerModuleInstance(transaction, asyncDataBrokerON, bindingBrokerON,
-                notificationBrokerON);
-        final ObjectName sourceTopology = PCEPTopologyProviderModuleTest.createPCEPTopologyProviderModuleInstance(transaction,
-                asyncDataBrokerON, bindingBrokerON, schedulerON);
-
-        final PCEPTunnelTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(objectName,
-                PCEPTunnelTopologyProviderModuleMXBean.class);
-        mxBean.setDataProvider(asyncDataBrokerON);
-        mxBean.setRpcRegistry(bindingBrokerON);
-        mxBean.setScheduler(schedulerON);
-        mxBean.setTopologyId(topologyId);
-        mxBean.setSourceTopology(sourceTopology);
-        return objectName;
-    }
-
-    @Override
-    public List<ModuleFactory> getModuleFactories() {
-        final List<ModuleFactory> moduleFactories = super.getModuleFactories();
-        moduleFactories.add(new PCEPTunnelTopologyProviderModuleFactory());
-        moduleFactories.add(new PCEPTopologyProviderModuleFactory());
-        moduleFactories.add(new PCEPDispatcherImplModuleFactory());
-        moduleFactories.add(new NettyThreadgroupModuleFactory());
-        moduleFactories.add(new Stateful07TopologySessionListenerModuleFactory());
-        return moduleFactories;
-    }
-
-    @Override
-    public List<String> getYangModelsPaths() {
-        final List<String> paths = super.getYangModelsPaths();
-        paths.add("/META-INF/yang/network-topology@2013-10-21.yang");
-        paths.add("/META-INF/yang/network-topology-pcep.yang");
-        paths.add("/META-INF/yang/network-topology-pcep-programming.yang");
-        paths.add("/META-INF/yang/network-topology-programming.yang");
-        paths.add("/META-INF/yang/topology-tunnel.yang");
-        paths.add("/META-INF/yang/topology-tunnel-pcep.yang");
-        paths.add("/META-INF/yang/topology-tunnel-pcep-programming.yang");
-        paths.add("/META-INF/yang/topology-tunnel-p2p.yang");
-        paths.add("/META-INF/yang/topology-tunnel-programming.yang");
-        paths.add("/META-INF/yang/odl-network-topology.yang");
-        paths.add("/META-INF/yang/yang-ext.yang");
-        paths.add("/META-INF/yang/pcep-types.yang");
-        paths.add("/META-INF/yang/rsvp.yang");
-        paths.add("/META-INF/yang/iana.yang");
-        paths.add("/META-INF/yang/network-concepts.yang");
-        paths.add("/META-INF/yang/ieee754.yang");
-        return paths;
-    }
-}
diff --git a/programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/InstructionDeployedImpl.java b/programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/InstructionDeployedImpl.java
new file mode 100644 (file)
index 0000000..2ca496d
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.bgpcep.programming.impl;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import io.netty.util.Timer;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionsQueueKey;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class InstructionDeployedImpl implements IntructionDeployer, AutoCloseable {
+    private static final Logger LOG = LoggerFactory.getLogger(InstructionDeployedImpl.class);
+
+    private final RpcProviderRegistry rpcProviderRegistry;
+    private final ListeningExecutorService exec = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
+    private final DataBroker dataProvider;
+    private final NotificationProviderService notifs;
+    private final Timer timer;
+    private final BundleContext bundleContext;
+    @GuardedBy("this")
+    private final Map<String, ProgrammingServiceImpl> programmingServices = new HashMap<>();
+
+    public InstructionDeployedImpl(final DataBroker dataProvider, final RpcProviderRegistry rpcProviderRegistry,
+        final NotificationProviderService notifs, final Timer timer, final BundleContext bundleContext) {
+        this.dataProvider = Preconditions.checkNotNull(dataProvider);
+        this.notifs = Preconditions.checkNotNull(notifs);
+        this.timer = Preconditions.checkNotNull(timer);
+        this.rpcProviderRegistry = Preconditions.checkNotNull(rpcProviderRegistry);
+        this.bundleContext = Preconditions.checkNotNull(bundleContext);
+    }
+
+    @Override
+    public synchronized void createInstruction(final String instructionId) {
+        if (this.programmingServices.containsKey(instructionId)) {
+            LOG.warn("Instruction Scheduler {} already exist. New instance won't be created", instructionId);
+            return;
+        }
+        LOG.debug("Creating Instruction Scheduler {}.", instructionId);
+
+        final ProgrammingServiceImpl programmingInst =
+            new ProgrammingServiceImpl(this.dataProvider, this.notifs, this.exec, this.rpcProviderRegistry,
+                this.timer, new InstructionsQueueKey(instructionId));
+        this.programmingServices.put(instructionId, programmingInst);
+        final Dictionary<String, String> properties = new Hashtable<>();
+        properties.put(InstructionScheduler.class.getName(), instructionId);
+        final ServiceRegistration<?> serviceRegistration = this.bundleContext
+            .registerService(InstructionScheduler.class.getName(), programmingInst, properties);
+        programmingInst.setServiceRegistration(serviceRegistration);
+    }
+
+    @Override
+    public synchronized void removeInstruction(final String instructionId) {
+        final ProgrammingServiceImpl service = this.programmingServices.remove(instructionId);
+        if (service != null) {
+            LOG.debug("Closing Instruction Scheduler {}.", instructionId);
+            service.close();
+        }
+    }
+
+    @Override
+    public synchronized void close() throws Exception {
+        this.exec.shutdown();
+        this.programmingServices.values().forEach(ProgrammingServiceImpl::close);
+    }
+}
diff --git a/programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/IntructionDeployer.java b/programming/impl/src/main/java/org/opendaylight/bgpcep/programming/impl/IntructionDeployer.java
new file mode 100644 (file)
index 0000000..3c8515e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.bgpcep.programming.impl;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Instruction Scheduler Deployer
+ */
+public interface IntructionDeployer {
+    /**
+     * Creates Instruction Scheduler
+     * @param instructionId Instruction Scheduler Id
+     */
+    void createInstruction(@Nonnull String instructionId);
+
+    /**
+     * Remove Instruction Scheduler
+     * @param instructionId Instruction Scheduler Id
+     */
+    void removeInstruction(@Nonnull String instructionId);
+}
index 079086d09ec73867cac554c51c9a38647e20f343..c87466dfde9822de0d82992e5dd15203e31e9b92 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.bgpcep.programming.impl;
 
 import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -15,7 +16,6 @@ import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.SettableFuture;
 import io.netty.util.Timeout;
 import io.netty.util.Timer;
-import io.netty.util.TimerTask;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -23,7 +23,6 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Callable;
 import java.util.concurrent.TimeUnit;
 import org.opendaylight.bgpcep.programming.NanotimeUtil;
 import org.opendaylight.bgpcep.programming.spi.ExecutionResult;
@@ -34,7 +33,10 @@ import org.opendaylight.bgpcep.programming.spi.SuccessfulRpcResult;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CancelInstructionInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CancelInstructionOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CancelInstructionOutputBuilder;
@@ -61,6 +63,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programm
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -73,6 +76,8 @@ public final class ProgrammingServiceImpl implements AutoCloseable, InstructionS
     private final ListeningExecutorService executor;
     private final DataBroker dataProvider;
     private final Timer timer;
+    private final RpcRegistration<ProgrammingService> reg;
+    private ServiceRegistration<?> serviceRegistration;
 
     private final class InstructionPusher implements QueueInstruction {
         private final InstructionBuilder builder = new InstructionBuilder();
@@ -94,7 +99,17 @@ public final class ProgrammingServiceImpl implements AutoCloseable, InstructionS
                         ProgrammingServiceImpl.this.qid.child(
                                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.queue.Instruction.class,
                                 new InstructionKey(this.builder.getId())), this.builder.build());
-                t.submit();
+                Futures.addCallback(t.submit(), new FutureCallback<Void>() {
+                    @Override
+                    public void onSuccess(final Void result) {
+                        LOG.debug("Instruction Queue {} updated", ProgrammingServiceImpl.this.qid);
+                    }
+
+                    @Override
+                    public void onFailure(final Throwable t) {
+                        LOG.error("Failed to update Instruction Queue {}", ProgrammingServiceImpl.this.qid, t);
+                    }
+                });;
             }
 
             ProgrammingServiceImpl.this.notifs.publish(new InstructionStatusChangedBuilder().setId(this.builder.getId()).setStatus(status).setDetails(details).build());
@@ -106,43 +121,54 @@ public final class ProgrammingServiceImpl implements AutoCloseable, InstructionS
             t.delete(LogicalDatastoreType.OPERATIONAL, ProgrammingServiceImpl.this.qid.child(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.queue.Instruction.class,
                     new InstructionKey(this.builder.getId())));
-            t.submit();
+            Futures.addCallback(t.submit(), new FutureCallback<Void>() {
+                @Override
+                public void onSuccess(final Void result) {
+                    LOG.debug("Instruction Queue {} removed", ProgrammingServiceImpl.this.qid);
+                }
+
+                @Override
+                public void onFailure(final Throwable t) {
+                    LOG.error("Failed to remove Instruction Queue {}", ProgrammingServiceImpl.this.qid, t);
+                }
+            });
         }
     }
 
     public ProgrammingServiceImpl(final DataBroker dataProvider, final NotificationProviderService notifs,
-            final ListeningExecutorService executor, final Timer timer, final InstructionsQueueKey instructionsQueueKey) {
+        final ListeningExecutorService executor, final RpcProviderRegistry rpcProviderRegistry,
+        final Timer timer, final InstructionsQueueKey instructionsQueueKey) {
         this.dataProvider = Preconditions.checkNotNull(dataProvider);
         this.notifs = Preconditions.checkNotNull(notifs);
         this.executor = Preconditions.checkNotNull(executor);
         this.timer = Preconditions.checkNotNull(timer);
         this.qid = KeyedInstanceIdentifier.builder(InstructionsQueue.class, instructionsQueueKey).build();
+        this.reg = rpcProviderRegistry.addRpcImplementation(ProgrammingService.class, this);
 
-        final WriteTransaction t = dataProvider.newWriteOnlyTransaction();
-        t.put(LogicalDatastoreType.OPERATIONAL, this.qid,
-                new InstructionsQueueBuilder().setKey(instructionsQueueKey).setInstruction(
-                        Collections.<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.queue.Instruction> emptyList()).build());
-        t.submit();
-    }
+        final WriteTransaction t = this.dataProvider.newWriteOnlyTransaction();
+        t.put(LogicalDatastoreType.OPERATIONAL, this.qid, new InstructionsQueueBuilder()
+            .setKey(instructionsQueueKey).setInstruction(Collections.emptyList()).build());
+        Futures.addCallback(t.submit(), new FutureCallback<Void>() {
+            @Override
+            public void onSuccess(final Void result) {
+                LOG.debug("Instruction Queue {} added", ProgrammingServiceImpl.this.qid);
+            }
 
-    @Override
-    public ListenableFuture<RpcResult<CancelInstructionOutput>> cancelInstruction(final CancelInstructionInput input) {
-        return this.executor.submit(new Callable<RpcResult<CancelInstructionOutput>>() {
             @Override
-            public RpcResult<CancelInstructionOutput> call() {
-                return realCancelInstruction(input);
+            public void onFailure(final Throwable t) {
+                LOG.error("Failed to add Instruction Queue {}", ProgrammingServiceImpl.this.qid, t);
             }
         });
     }
 
+    @Override
+    public ListenableFuture<RpcResult<CancelInstructionOutput>> cancelInstruction(final CancelInstructionInput input) {
+        return this.executor.submit(() -> realCancelInstruction(input));
+    }
+
     @Override
     public ListenableFuture<RpcResult<CleanInstructionsOutput>> cleanInstructions(final CleanInstructionsInput input) {
-        return this.executor.submit(new Callable<RpcResult<CleanInstructionsOutput>>() {
-            @Override
-            public RpcResult<CleanInstructionsOutput> call() {
-                return realCleanInstructions(input);
-            }
-        });
+        return this.executor.submit(() -> realCleanInstructions(input));
     }
 
     private synchronized RpcResult<CancelInstructionOutput> realCancelInstruction(final CancelInstructionInput input) {
@@ -276,12 +302,7 @@ public final class ProgrammingServiceImpl implements AutoCloseable, InstructionS
          */
 
         // Schedule a timeout for the instruction
-        final Timeout t = this.timer.newTimeout(new TimerTask() {
-            @Override
-            public void run(final Timeout timeout) {
-                timeoutInstruction(input.getId());
-            }
-        }, left.longValue(), TimeUnit.NANOSECONDS);
+        final Timeout t = this.timer.newTimeout(timeout -> timeoutInstruction(input.getId()), left.longValue(), TimeUnit.NANOSECONDS);
 
         // Put it into the instruction list
         final SettableFuture<Instruction> ret = SettableFuture.create();
@@ -299,12 +320,7 @@ public final class ProgrammingServiceImpl implements AutoCloseable, InstructionS
          * This task should be ingress-weighed, so we reinsert it into the
          * same execution service.
          */
-        this.executor.submit(new Runnable() {
-            @Override
-            public void run() {
-                tryScheduleInstruction(i);
-            }
-        });
+        this.executor.submit(() -> tryScheduleInstruction(i));
 
         return ret;
     }
@@ -347,16 +363,32 @@ public final class ProgrammingServiceImpl implements AutoCloseable, InstructionS
 
     @Override
     public synchronized void close() {
-        try {
-            for (final InstructionImpl i : this.insns.values()) {
-                i.tryCancel(null);
+        this.reg.close();
+        for (final InstructionImpl i : this.insns.values()) {
+            i.tryCancel(null);
+        }
+        // Workaround for BUG-2283
+        final WriteTransaction t = this.dataProvider.newWriteOnlyTransaction();
+        t.delete(LogicalDatastoreType.OPERATIONAL, this.qid);
+        final CheckedFuture<Void, TransactionCommitFailedException> future = t.submit();
+        Futures.addCallback(future, new FutureCallback<Void>() {
+            @Override
+            public void onSuccess(final Void result) {
+                LOG.debug("Instruction Queue {} removed", ProgrammingServiceImpl.this.qid);
+            }
+
+            @Override
+            public void onFailure(final Throwable t) {
+                LOG.error("Failed to shutdown Instruction Queue {}", ProgrammingServiceImpl.this.qid, t);
             }
-            // Workaround for BUG-2283
-            final WriteTransaction t = this.dataProvider.newWriteOnlyTransaction();
-            t.delete(LogicalDatastoreType.OPERATIONAL, this.qid);
-            t.submit().checkedGet();
-        } catch (final Exception e) {
-            LOG.error("Failed to shutdown Instruction Queue", e);
+        });
+        if (this.serviceRegistration != null) {
+            this.serviceRegistration.unregister();
+            this.serviceRegistration = null;
         }
     }
+
+    void setServiceRegistration(final ServiceRegistration<?> serviceRegistration) {
+        this.serviceRegistration = serviceRegistration;
+    }
 }
index 7560a41fad59a440ff163e28f3c64bc63967f682..7d6eeba21e71d990610b6de0fab03698aab6c684 100644 (file)
  */
 package org.opendaylight.controller.config.yang.programming.impl;
 
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.Executors;
-import org.opendaylight.bgpcep.programming.impl.ProgrammingServiceImpl;
-import org.opendaylight.bgpcep.programming.spi.Instruction;
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import java.lang.reflect.Method;
+import org.opendaylight.bgpcep.programming.impl.IntructionDeployer;
 import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
-import org.opendaylight.bgpcep.programming.spi.SchedulerException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionsQueueKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.ProgrammingService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.osgi.framework.BundleContext;
 
 /**
- *
+ * @deprecated Replaced by blueprint wiring
  */
 public final class InstructionSchedulerImplModule extends
-        org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerImplModule {
+    org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerImplModule {
+
+    private BundleContext bundleContext;
 
     public InstructionSchedulerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
     public InstructionSchedulerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-            final InstructionSchedulerImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
+        final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+        final InstructionSchedulerImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
@@ -53,33 +50,38 @@ public final class InstructionSchedulerImplModule extends
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        final ListeningExecutorService exec = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
+        final WaitingServiceTracker<IntructionDeployer> intructionDeployerTracker =
+            WaitingServiceTracker.create(IntructionDeployer.class, this.bundleContext);
+        final IntructionDeployer intructionDeployer = intructionDeployerTracker
+            .waitForService(WaitingServiceTracker.FIVE_MINUTES);
 
-        final ProgrammingServiceImpl inst = new ProgrammingServiceImpl(getDataProviderDependency(), getNotificationServiceDependency(), exec, getTimerDependency(),
-                new InstructionsQueueKey(getInstructionQueueId() != null ? getInstructionQueueId() : getIdentifier().getInstanceName()));
+        final String instructionId = getInstructionQueueId() != null ? getInstructionQueueId() :
+            getIdentifier().getInstanceName();
+        intructionDeployer.createInstruction(instructionId);
+        final WaitingServiceTracker<InstructionScheduler> instructionSchedulerTracker = WaitingServiceTracker
+            .create(InstructionScheduler.class,
+            this.bundleContext, "(" + InstructionScheduler.class.getName() + "=" + instructionId + ")");
+        final InstructionScheduler instructionScheduler = instructionSchedulerTracker
+            .waitForService(WaitingServiceTracker.FIVE_MINUTES);
 
-        final RpcRegistration<ProgrammingService> reg = getRpcRegistryDependency().addRpcImplementation(ProgrammingService.class, inst);
-
-        final class ProgrammingServiceImplCloseable implements InstructionScheduler, AutoCloseable {
+        return Reflection.newProxy(ProgrammingServiceImplCloseable.class, new AbstractInvocationHandler() {
             @Override
-            public void close() {
-                try {
-                    reg.close();
-                } finally {
-                    try {
-                        inst.close();
-                    } finally {
-                        exec.shutdown();
-                    }
+            protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) throws Throwable {
+                if (method.getName().equals("close")) {
+                    intructionDeployer.removeInstruction(instructionId);
+                    intructionDeployerTracker.close();
+                    return null;
+                } else {
+                    return method.invoke(instructionScheduler, args);
                 }
             }
+        });
+    }
 
-            @Override
-            public ListenableFuture<Instruction> scheduleInstruction(final SubmitInstructionInput input) throws SchedulerException {
-                return inst.scheduleInstruction(input);
-            }
-        }
+    void setBundleContext(final BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
 
-        return new ProgrammingServiceImplCloseable();
+    private interface ProgrammingServiceImplCloseable extends InstructionScheduler, AutoCloseable {
     }
 }
index be30f81b739ca6640bb0b624916166960cc98f10..51ad6a7c11649a064b21d86fb1270cf735a67439 100644 (file)
  */
 package org.opendaylight.controller.config.yang.programming.impl;
 
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
 /**
-*
-*/
+ * @deprecated Replaced by blueprint wiring
+ */
 public class InstructionSchedulerImplModuleFactory extends
         org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerImplModuleFactory {
 
+    @Override
+    public Module createModule(final String instanceName, final DependencyResolver dependencyResolver,
+        final BundleContext bundleContext) {
+        final InstructionSchedulerImplModule module = (InstructionSchedulerImplModule)
+            super.createModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+    @Override
+    public Module createModule(final String instanceName, final DependencyResolver dependencyResolver,
+        final DynamicMBeanWithInstance old, final BundleContext bundleContext) throws Exception {
+        final InstructionSchedulerImplModule module = (InstructionSchedulerImplModule)
+            super.createModule(instanceName, dependencyResolver, old, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
 }
diff --git a/programming/impl/src/main/resources/org/opendaylight/blueprint/programming.xml b/programming/impl/src/main/resources/org/opendaylight/blueprint/programming.xml
new file mode 100644 (file)
index 0000000..e883f18
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+      Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+
+    <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+               odl:type="default"/>
+    <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+    <reference id="notificationService"
+               interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService" />
+    <reference id="timer" interface="io.netty.util.Timer" odl:type="global-timer"/>
+
+    <bean id="IntructionDeployerImpl" class="org.opendaylight.bgpcep.programming.impl.InstructionDeployedImpl"
+          destroy-method="close">
+        <argument ref="dataBroker"/>
+        <argument ref="rpcRegistry"/>
+        <argument ref="notificationService"/>
+        <argument ref="timer"/>
+        <argument ref="blueprintBundleContext"/>
+    </bean>
+
+    <service ref="IntructionDeployerImpl" interface="org.opendaylight.bgpcep.programming.impl.IntructionDeployer"/>
+</blueprint>
\ No newline at end of file
index f93067d9d8e21b6eabb8651c7e696f62e68434bf..69571f370f9017aa874f956c6f286e971129b446 100644 (file)
@@ -9,29 +9,35 @@ package org.opendaylight.bgpcep.programming.impl;
 
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
-import static org.opendaylight.protocol.util.CheckUtil.checkPresent;
-import static org.opendaylight.protocol.util.CheckUtil.checkNull;
 
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.ListenableFuture;
 import io.netty.util.HashedWheelTimer;
 import io.netty.util.Timer;
-import java.io.IOException;
 import java.math.BigInteger;
 import java.util.List;
 import java.util.Optional;
+import java.util.concurrent.ExecutionException;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
 import org.opendaylight.bgpcep.programming.NanotimeUtil;
 import org.opendaylight.bgpcep.programming.spi.Instruction;
 import org.opendaylight.bgpcep.programming.spi.SchedulerException;
 import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CancelInstructionInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CancelInstructionInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CleanInstructionsInput;
@@ -42,39 +48,45 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programm
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionsQueue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionsQueueKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.Nanotime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.ProgrammingService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.queue.InstructionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.Details;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.DetailsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.programming.rev131030.PcepUpdateTunnelInput;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 
 public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
 
     private static final int INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS = 3;
-    private static final String INSTRUCTIONS_QUEUE_KEY = "test-instraction-queue";
-
+    private static final InstructionsQueueKey INSTRUCTIONS_QUEUE_KEY = new InstructionsQueueKey("test-instraction-queue");
+    private final Timer timer = new HashedWheelTimer();
     private MockedExecutorWrapper mockedExecutorWrapper;
     private MockedNotificationServiceWrapper mockedNotificationServiceWrapper;
     private ProgrammingServiceImpl testedProgrammingService;
-    private final Timer timer = new HashedWheelTimer();
+    @Mock
+    private RpcProviderRegistry rpcRegistry;
+    @Mock
+    private RoutedRpcRegistration<ProgrammingService> registration;
 
     @Before
-    public void setUp() throws IOException, YangSyntaxErrorException {
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        doReturn(this.registration).when(this.rpcRegistry).addRpcImplementation(Mockito.any(),
+            Mockito.any(ProgrammingService.class));
+        doNothing().when(this.registration).close();
         this.mockedExecutorWrapper = new MockedExecutorWrapper();
         this.mockedNotificationServiceWrapper = new MockedNotificationServiceWrapper();
 
         this.testedProgrammingService = new ProgrammingServiceImpl(getDataBroker(),
             this.mockedNotificationServiceWrapper.getMockedNotificationService(),
-            this.mockedExecutorWrapper.getMockedExecutor(), this.timer,
-            new InstructionsQueueKey(INSTRUCTIONS_QUEUE_KEY));
+            this.mockedExecutorWrapper.getMockedExecutor(), this.rpcRegistry, this.timer, INSTRUCTIONS_QUEUE_KEY);
     }
 
     @After
     public void tearDown() throws Exception {
+        this.testedProgrammingService.close();
     }
 
     @Test
@@ -82,22 +94,20 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
         final SubmitInstructionInput mockedSubmit = getMockedSubmitInstructionInput("mockedSubmit");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit);
 
-        checkPresent(getDataBroker(), buildInstructionIID(mockedSubmit.getId()));
+        assertTrue(assertInstructionExists(mockedSubmit.getId()));
 
         // assert Schedule to executor
         this.mockedExecutorWrapper.assertSubmittedTasksSize(1);
 
         // assert Notification
         this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(0, mockedSubmit.getId(),
-            InstructionStatus.Scheduled);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(0, mockedSubmit.getId(), InstructionStatus.Scheduled);
     }
 
     @Test
     public void testScheduleDependingInstruction() throws Exception {
         this.testedProgrammingService.scheduleInstruction(getMockedSubmitInstructionInput("mockedSubmit1"));
-        final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2",
-            "mockedSubmit1");
+        final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
 
         this.mockedExecutorWrapper.assertSubmittedTasksSize(2);
@@ -109,8 +119,7 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
     @Test
     public void testScheduleDependingInstructionToFail() throws Exception {
         try {
-            this.testedProgrammingService.scheduleInstruction(getMockedSubmitInstructionInput("mockedSubmit",
-                "dep1"));
+            this.testedProgrammingService.scheduleInstruction(getMockedSubmitInstructionInput("mockedSubmit", "dep1"));
         } catch (final SchedulerException e) {
             assertThat(e.getMessage(), containsString("Unknown dependency ID"));
             this.mockedNotificationServiceWrapper.assertNotificationsCount(0);
@@ -123,61 +132,54 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
     public void testCancelInstruction() throws Exception {
         final SubmitInstructionInput mockedSubmit = getMockedSubmitInstructionInput("mockedSubmit");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit);
-        checkPresent(getDataBroker(), buildInstructionIID(mockedSubmit.getId()));
+
+        assertTrue(assertInstructionExists(mockedSubmit.getId()));
 
         final CancelInstructionInput mockedCancel = getCancelInstruction("mockedSubmit");
         this.testedProgrammingService.cancelInstruction(mockedCancel);
 
-        checkPresent(getDataBroker(), buildInstructionIID(mockedSubmit.getId()));
+        assertTrue(assertInstructionExists(mockedSubmit.getId()));
+
         this.mockedExecutorWrapper.assertSubmittedTasksSize(2);
 
         this.mockedNotificationServiceWrapper.assertNotificationsCount(2);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit.getId(),
-            InstructionStatus.Cancelled);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit.getId(), InstructionStatus.Cancelled);
     }
 
     @Test
     public void testCancelDependantInstruction() throws Exception {
         final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
-        final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2",
-            "mockedSubmit1");
+        final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
-        final SubmitInstructionInput mockedSubmit3 = getMockedSubmitInstructionInput("mockedSubmit3",
-            "mockedSubmit1", "mockedSubmit2");
+        final SubmitInstructionInput mockedSubmit3 = getMockedSubmitInstructionInput("mockedSubmit3", "mockedSubmit1", "mockedSubmit2");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit3);
 
         this.testedProgrammingService.cancelInstruction(getCancelInstruction("mockedSubmit1"));
 
         this.mockedNotificationServiceWrapper.assertNotificationsCount(1 /*First Scheduled*/+ 3 /*First and all dependencies cancelled*/);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(0, mockedSubmit1.getId(),
-            InstructionStatus.Scheduled);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
-            InstructionStatus.Cancelled);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit2.getId(),
-            InstructionStatus.Cancelled);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit3.getId(),
-            InstructionStatus.Cancelled);
-
-        checkPresent(getDataBroker(), buildInstructionIID(mockedSubmit1.getId()));
-        checkPresent(getDataBroker(), buildInstructionIID(mockedSubmit2.getId()));
-        checkPresent(getDataBroker(), buildInstructionIID(mockedSubmit3.getId()));
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(0, mockedSubmit1.getId(), InstructionStatus.Scheduled);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(), InstructionStatus.Cancelled);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit2.getId(), InstructionStatus.Cancelled);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit3.getId(), InstructionStatus.Cancelled);
+
+        assertTrue(assertInstructionExists(mockedSubmit1.getId()));
+        assertTrue(assertInstructionExists(mockedSubmit2.getId()));
+        assertTrue(assertInstructionExists(mockedSubmit3.getId()));
     }
 
     @Test
     public void testCleanInstructions() throws Exception {
         final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
-        final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2",
-            "mockedSubmit1");
+        final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
 
         final CleanInstructionsInputBuilder cleanInstructionsInputBuilder = new CleanInstructionsInputBuilder();
         final CleanInstructionsInput cleanInstructionsInput = cleanInstructionsInputBuilder.setId(
                 Lists.newArrayList(mockedSubmit1.getId(), mockedSubmit2.getId())).build();
 
-        ListenableFuture<RpcResult<CleanInstructionsOutput>> cleanedInstructionOutput = this.testedProgrammingService
-            .cleanInstructions(cleanInstructionsInput);
+        ListenableFuture<RpcResult<CleanInstructionsOutput>> cleanedInstructionOutput = this.testedProgrammingService.cleanInstructions(cleanInstructionsInput);
 
         assertCleanInstructionOutput(cleanedInstructionOutput, 2);
 
@@ -186,13 +188,12 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
         cleanedInstructionOutput = this.testedProgrammingService.cleanInstructions(cleanInstructionsInput);
         assertCleanInstructionOutput(cleanedInstructionOutput, 0);
 
-        checkNull(getDataBroker(), buildInstructionIID(mockedSubmit1.getId()));
-        checkNull(getDataBroker(), buildInstructionIID(mockedSubmit2.getId()));
+        assertFalse(assertInstructionExists(mockedSubmit1.getId()));
+        assertFalse(assertInstructionExists(mockedSubmit2.getId()));
     }
 
-    private void assertCleanInstructionOutput(final ListenableFuture<RpcResult<CleanInstructionsOutput>>
-        cleanedInstructionOutput, final int unflushedCount) throws InterruptedException,
-        java.util.concurrent.ExecutionException {
+    private void assertCleanInstructionOutput(final ListenableFuture<RpcResult<CleanInstructionsOutput>> cleanedInstructionOutput,
+            final int unflushedCount) throws InterruptedException, java.util.concurrent.ExecutionException {
         if (unflushedCount == 0) {
             final List<InstructionId> unflushed = cleanedInstructionOutput.get().getResult().getUnflushed();
             assertTrue(unflushed == null || unflushed.isEmpty());
@@ -206,20 +207,17 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
     public void testCloseProgrammingService() throws Exception {
         final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
-        final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2",
-            "mockedSubmit1");
+        final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
 
         this.testedProgrammingService.close();
 
-        this.mockedNotificationServiceWrapper
-            .assertNotificationsCount(1/* First scheduled */+ 2/* Both cancelled at close */);
+        this.mockedNotificationServiceWrapper.assertNotificationsCount(1/* First scheduled */+ 2/* Both cancelled at close */);
     }
 
     @Test(timeout = 30 * 1000)
     public void testTimeoutWhileScheduledTransaction() throws Exception {
-        final BigInteger deadlineOffset = BigInteger.valueOf(1000L * 1000 * 1000 *
-            INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS /* seconds */);
+        final BigInteger deadlineOffset = BigInteger.valueOf(1000L * 1000 * 1000 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS /* seconds */);
         final Nanotime current = NanotimeUtil.currentTime();
         final Nanotime deadlineNano = new Nanotime(current.getValue().add(deadlineOffset));
 
@@ -231,15 +229,15 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
 
         future.get();
 
+        Thread.sleep(2 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS * 1000);
+
         this.mockedNotificationServiceWrapper.assertNotificationsCount(2);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
-            InstructionStatus.Cancelled);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(), InstructionStatus.Cancelled);
     }
 
     @Test(timeout = 30 * 1000)
     public void testTimeoutWhileSuccessfulTransaction() throws Exception {
-        final BigInteger deadlineOffset = BigInteger.valueOf(1000L * 1000 * 1000 *
-            INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS /* seconds */);
+        final BigInteger deadlineOffset = BigInteger.valueOf(1000L * 1000 * 1000 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS /* seconds */);
         final Nanotime current = NanotimeUtil.currentTime();
         final Nanotime deadlineNano = new Nanotime(current.getValue().add(deadlineOffset));
 
@@ -253,18 +251,17 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
         i.checkedExecutionStart();
         i.executionCompleted(InstructionStatus.Successful, getDetails());
 
+        Thread.sleep(2 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS * 1000);
+
         this.mockedNotificationServiceWrapper.assertNotificationsCount(3);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
-            InstructionStatus.Executing);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(),
-            InstructionStatus.Successful);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(), InstructionStatus.Executing);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(), InstructionStatus.Successful);
         // Timeout in success should not do anything
     }
 
     @Test(timeout = 30 * 1000)
     public void testTimeoutWhileExecutingWithDependenciesTransaction() throws Exception {
-        final BigInteger deadlineOffset = BigInteger.valueOf(1000L * 1000 * 1000 *
-            INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS /* seconds */);
+        final BigInteger deadlineOffset = BigInteger.valueOf(1000L * 1000 * 1000 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS /* seconds */);
         final Nanotime current = NanotimeUtil.currentTime();
         final Nanotime deadlineNano = new Nanotime(current.getValue().add(deadlineOffset));
 
@@ -272,8 +269,7 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
         final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1", deadline);
         final ListenableFuture<Instruction> future = this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
 
-        final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2",
-            "mockedSubmit1");
+        final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
         this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
 
         this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
@@ -281,13 +277,12 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
         final Instruction i = future.get();
         i.checkedExecutionStart();
 
+        Thread.sleep(2 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS * 1000);
+
         this.mockedNotificationServiceWrapper.assertNotificationsCount(4);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
-            InstructionStatus.Executing);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(),
-            InstructionStatus.Unknown);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(),
-            InstructionStatus.Cancelled);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(), InstructionStatus.Executing);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(), InstructionStatus.Unknown);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(), InstructionStatus.Cancelled);
     }
 
     // TODO test deadline with state Queued
@@ -307,22 +302,17 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
         i.executionCompleted(InstructionStatus.Successful, getDetails());
 
         this.mockedNotificationServiceWrapper.assertNotificationsCount(4);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
-            InstructionStatus.Executing);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(),
-            InstructionStatus.Successful);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(),
-            InstructionStatus.Scheduled);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(), InstructionStatus.Executing);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(), InstructionStatus.Successful);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(), InstructionStatus.Scheduled);
 
         i = future2.get();
         i.checkedExecutionStart();
         i.executionCompleted(InstructionStatus.Successful, getDetails());
 
         this.mockedNotificationServiceWrapper.assertNotificationsCount(6);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(4, mockedSubmit2.getId(),
-            InstructionStatus.Executing);
-        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(5, mockedSubmit2.getId(),
-            InstructionStatus.Successful);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(4, mockedSubmit2.getId(), InstructionStatus.Executing);
+        this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(5, mockedSubmit2.getId(), InstructionStatus.Successful);
     }
 
     private Details getDetails() {
@@ -333,8 +323,7 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
         return getMockedSubmitInstructionInput(id, Optional.empty(), dependencyIds);
     }
 
-    private SubmitInstructionInput getMockedSubmitInstructionInput(final String id, final Optional<Nanotime> deadline,
-        final String... dependencyIds) {
+    private SubmitInstructionInput getMockedSubmitInstructionInput(final String id, final Optional<Nanotime> deadline, final String... dependencyIds) {
         final SubmitInstructionInput mockedSubmitInstruction = mock(SubmitInstructionInput.class);
 
         doReturn(PcepUpdateTunnelInput.class).when(mockedSubmitInstruction).getImplementedInterface();
@@ -345,8 +334,7 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
 
         doReturn(dependencies).when(mockedSubmitInstruction).getPreconditions();
         doReturn(getInstructionId(id)).when(mockedSubmitInstruction).getId();
-        doReturn(deadline.isPresent() ? deadline.get() : new Nanotime(BigInteger.valueOf(Long.MAX_VALUE)))
-            .when(mockedSubmitInstruction).getDeadline();
+        doReturn(deadline.isPresent() ? deadline.get() : new Nanotime(BigInteger.valueOf(Long.MAX_VALUE))).when(mockedSubmitInstruction).getDeadline();
         return mockedSubmitInstruction;
     }
 
@@ -360,10 +348,12 @@ public class ProgrammingServiceImplTest extends AbstractDataBrokerTest {
         return new InstructionId(id);
     }
 
-    private KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.
-        rev150720.instruction.queue.Instruction, InstructionKey> buildInstructionIID(final InstructionId id) {
-        return InstanceIdentifier.builder(InstructionsQueue.class, new InstructionsQueueKey(INSTRUCTIONS_QUEUE_KEY))
-            .build().child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720
-                .instruction.queue.Instruction.class, new InstructionKey(id));
+    private boolean assertInstructionExists(final InstructionId id) {
+        try {
+            return getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(InstructionsQueue.class, INSTRUCTIONS_QUEUE_KEY).build().child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.queue.Instruction.class,
+                    new InstructionKey(id))).get().isPresent();
+        } catch (InterruptedException | ExecutionException e) {
+            return false;
+        }
     }
 }
diff --git a/programming/impl/src/test/java/org/opendaylight/controller/config/yang/programming/impl/AbstractInstructionSchedulerTest.java b/programming/impl/src/test/java/org/opendaylight/controller/config/yang/programming/impl/AbstractInstructionSchedulerTest.java
deleted file mode 100644 (file)
index 5183b3a..0000000
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.programming.impl;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.contains;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Lists;
-import com.google.common.io.ByteSource;
-import com.google.common.io.Resources;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.util.Timer;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Set;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.mockito.Matchers;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.BindingAsyncDataBrokerImplModuleFactory;
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.BindingAsyncDataBrokerImplModuleMXBean;
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.BindingBrokerImplModuleFactory;
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.BindingBrokerImplModuleMXBean;
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.ForwardedCompatibleDataBrokerImplModuleFactory;
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.ForwardedCompatibleDataBrokerImplModuleMXBean;
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.NotificationBrokerImplModuleFactory;
-import org.opendaylight.controller.config.yang.md.sal.binding.impl.RuntimeMappingModuleFactory;
-import org.opendaylight.controller.config.yang.md.sal.dom.impl.DomBrokerImplModuleFactory;
-import org.opendaylight.controller.config.yang.md.sal.dom.impl.DomBrokerImplModuleMXBean;
-import org.opendaylight.controller.config.yang.md.sal.dom.impl.DomInmemoryDataBrokerModuleFactory;
-import org.opendaylight.controller.config.yang.md.sal.dom.impl.DomInmemoryDataBrokerModuleMXBean;
-import org.opendaylight.controller.config.yang.md.sal.dom.impl.SchemaServiceImplSingletonModuleFactory;
-import org.opendaylight.controller.config.yang.netty.timer.HashedWheelTimerModuleFactory;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodecFactory;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.core.api.model.YangTextSourceProvider;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
-import org.opendaylight.yangtools.yang.parser.repo.YangTextSchemaContextResolver;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-
-public abstract class AbstractInstructionSchedulerTest extends AbstractConfigTest {
-
-    private static final String FACTORY_NAME = InstructionSchedulerImplModuleFactory.NAME;
-    private static final String INSTANCE_NAME = "instruction-scheduler-impl";
-
-    private static final String BINDING_BROKER_INSTANCE_NAME = "binding-broker-impl";
-    private static final String NOTIFICATION_BROKER_INSTANCE_NAME = "notification-broker-impl";
-    private static final String COMPATIBLE_DATA_BROKER_INSTANCE_NAME = "binding-data-compatible-broker-instance";
-    private static final String DOM_BROKER_INSTANCE_NAME = "dom-broker-impl";
-    private static final String TIMER_INSTANCE_NAME = "timer-impl";
-    private static final String BINDING_ASYNC_BROKER_INSTANCE_NAME = "binding-async-broker-instance";
-    private static final String DOM_ASYNC_DATA_BROKER_INSTANCE = "dom-inmemory-data-broker";
-
-    @Mock
-    private RpcResult<TransactionStatus> mockedResult;
-
-    @SuppressWarnings("unchecked")
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
-        final List<ModuleFactory> moduleFactories = getModuleFactories();
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, moduleFactories.toArray(new ModuleFactory[moduleFactories.size()])));
-
-        doAnswer(new Answer<Filter>() {
-            @Override
-            public Filter answer(final InvocationOnMock invocation) {
-                final String str = invocation.getArgumentAt(0, String.class);
-                final Filter mockFilter = mock(Filter.class);
-                doReturn(str).when(mockFilter).toString();
-                return mockFilter;
-            }
-        }).when(mockedContext).createFilter(anyString());
-
-        Mockito.doReturn(new ServiceReference[] {}).when(mockedContext).getServiceReferences(Matchers.anyString(), Matchers.anyString());
-
-        final ServiceReference<?> classLoadingStrategySR = mock(ServiceReference.class, "ClassLoadingStrategy");
-        final ServiceReference<?> emptyServiceReference = mock(ServiceReference.class, "Empty");
-
-        Mockito.doNothing().when(mockedContext).addServiceListener(any(ServiceListener.class), Mockito.anyString());
-        Mockito.doNothing().when(mockedContext).removeServiceListener(any(ServiceListener.class));
-
-        Mockito.doNothing().when(mockedContext).addBundleListener(any(BundleListener.class));
-        Mockito.doNothing().when(mockedContext).removeBundleListener(any(BundleListener.class));
-
-        Mockito.doReturn(new Bundle[] {}).when(mockedContext).getBundles();
-
-        Mockito.doReturn(new ServiceReference[] {}).when(mockedContext).getServiceReferences(Matchers.anyString(), Matchers.anyString());
-
-        Mockito.doReturn("Class loading stategy reference").when(classLoadingStrategySR).toString();
-        Mockito.doReturn("Empty reference").when(emptyServiceReference).toString();
-
-        Mockito.doReturn(emptyServiceReference).when(mockedContext).getServiceReference(any(Class.class));
-        Mockito.doReturn(classLoadingStrategySR).when(mockedContext).getServiceReference(GeneratedClassLoadingStrategy.class);
-        Mockito.doReturn(classLoadingStrategySR).when(this.mockedContext).getServiceReference(ClassLoadingStrategy.class);
-
-        Mockito.doReturn(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy()).when(mockedContext).getService(classLoadingStrategySR);
-        Mockito.doReturn(null).when(mockedContext).getService(emptyServiceReference);
-
-        final SchemaContext context = parseYangStreams(getFilesAsByteSources(getYangModelsPaths()));
-        final SchemaService mockedSchemaService = mock(SchemaService.class);
-        doReturn(context).when(mockedSchemaService).getGlobalContext();
-        doAnswer(new Answer<ListenerRegistration<SchemaContextListener>>() {
-            @Override
-            public ListenerRegistration<SchemaContextListener> answer(InvocationOnMock invocation) {
-                invocation.getArgumentAt(0, SchemaContextListener.class).onGlobalContextUpdated(context);
-                ListenerRegistration<SchemaContextListener> reg = mock(ListenerRegistration.class);
-                doNothing().when(reg).close();
-                return reg;
-            }
-        }).when(mockedSchemaService).registerSchemaContextListener(any(SchemaContextListener.class));
-
-        setupMockService(SchemaService.class, mockedSchemaService);
-        setupMockService(YangTextSourceProvider.class, mock(YangTextSourceProvider.class));
-
-        BindingToNormalizedNodeCodec bindingCodec = BindingToNormalizedNodeCodecFactory.newInstance(
-                GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
-        BindingToNormalizedNodeCodecFactory.registerInstance(bindingCodec, mockedSchemaService);
-        setupMockService(BindingToNormalizedNodeCodec.class, bindingCodec);
-
-        setupMockService(Timer.class, mock(Timer.class));
-        setupMockService(EventLoopGroup.class, new NioEventLoopGroup());
-        setupMockService(DOMNotificationService.class, mock(DOMNotificationService.class));
-        setupMockService(DOMNotificationPublishService.class, mock(DOMNotificationPublishService.class));
-        setupMockService(DOMRpcService.class, mock(DOMRpcService.class));
-        setupMockService(DOMMountPointService.class, mock(DOMMountPointService.class));
-
-        final DOMRpcProviderService mockRpcProvider = mock(DOMRpcProviderService.class);
-        doReturn(mock(DOMRpcImplementationRegistration.class)).when(mockRpcProvider).registerRpcImplementation(
-                any(DOMRpcImplementation.class), any(Set.class));
-        setupMockService(DOMRpcProviderService.class, mockRpcProvider);
-    }
-
-    protected void setupMockService(final Class<?> serviceInterface, final Object instance) throws Exception {
-        final ServiceReference<?> mockServiceRef = mock(ServiceReference.class);
-        doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
-                getServiceReferences(anyString(), contains(serviceInterface.getName()));
-        doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
-                getServiceReferences(serviceInterface.getName(), null);
-        doReturn(instance).when(mockedContext).getService(mockServiceRef);
-    }
-
-    @After
-    public void tearDownGlobalBundleScanningSchemaServiceImpl() throws Exception{
-    }
-
-    public ObjectName createInstructionSchedulerModuleInstance(final ConfigTransactionJMXClient transaction, final ObjectName dataBrokerON,
-            final ObjectName rpcRegistyON, final ObjectName notificationBrokerON) throws Exception {
-        final ObjectName objectName = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
-        final InstructionSchedulerImplModuleMXBean mxBean = transaction.newMXBeanProxy(objectName,
-                InstructionSchedulerImplModuleMXBean.class);
-        mxBean.setDataProvider(dataBrokerON);
-        mxBean.setRpcRegistry(rpcRegistyON);
-        mxBean.setNotificationService(notificationBrokerON);
-        mxBean.setTimer(createTimerInstance(transaction));
-        return objectName;
-    }
-
-    private ObjectName createTimerInstance(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
-        final ObjectName nameCreated = transaction.createModule(HashedWheelTimerModuleFactory.NAME, TIMER_INSTANCE_NAME);
-        return nameCreated;
-
-    }
-
-    public ObjectName createBindingBrokerImpl(final ConfigTransactionJMXClient transaction, final ObjectName dataBrokerON,
-            final ObjectName notificationBrokerON) throws Exception {
-        final ObjectName objectName = transaction.createModule(BindingBrokerImplModuleFactory.NAME, BINDING_BROKER_INSTANCE_NAME);
-        final BindingBrokerImplModuleMXBean mxBean = transaction.newMXBeanProxy(objectName, BindingBrokerImplModuleMXBean.class);
-        mxBean.setDataBroker(dataBrokerON);
-        mxBean.setNotificationService(notificationBrokerON);
-        mxBean.setBindingMappingService(lookupMappingServiceInstance(transaction));
-        mxBean.setDomAsyncBroker(lookupDomBrokerInstance(transaction));
-        return objectName;
-    }
-
-    public ObjectName createNotificationBrokerInstance(final ConfigTransactionJMXClient transaction) throws Exception {
-        final ObjectName objectName = transaction.createModule(NotificationBrokerImplModuleFactory.NAME, NOTIFICATION_BROKER_INSTANCE_NAME);
-        return objectName;
-    }
-
-    public ObjectName createCompatibleDataBrokerInstance(final ConfigTransactionJMXClient transaction)
-            throws InstanceAlreadyExistsException, InstanceNotFoundException {
-        final ObjectName nameCreated = transaction.createModule(ForwardedCompatibleDataBrokerImplModuleFactory.NAME, COMPATIBLE_DATA_BROKER_INSTANCE_NAME);
-        final ForwardedCompatibleDataBrokerImplModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, ForwardedCompatibleDataBrokerImplModuleMXBean.class);
-        mxBean.setDataBroker(lookupDataBrokerInstance(transaction));
-        return nameCreated;
-    }
-
-    private static ObjectName lookupDataBrokerInstance(final ConfigTransactionJMXClient transaction) {
-        try {
-            return transaction.lookupConfigBean(BindingAsyncDataBrokerImplModuleFactory.NAME, BINDING_ASYNC_BROKER_INSTANCE_NAME);
-        } catch (final InstanceNotFoundException e) {
-            try {
-                return transaction.createModule(RuntimeMappingModuleFactory.NAME, RuntimeMappingModuleFactory.SINGLETON_NAME);
-            } catch (final InstanceAlreadyExistsException e1) {
-                throw new IllegalStateException(e1);
-            }
-        }
-    }
-
-    public ObjectName createAsyncDataBrokerInstance(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException, InstanceNotFoundException {
-        final ObjectName nameCreated = transaction.createModule(BindingAsyncDataBrokerImplModuleFactory.NAME, BINDING_ASYNC_BROKER_INSTANCE_NAME);
-        final BindingAsyncDataBrokerImplModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, BindingAsyncDataBrokerImplModuleMXBean.class);
-        mxBean.setBindingMappingService(lookupMappingServiceInstance(transaction));
-        mxBean.setDomAsyncBroker(lookupDomAsyncDataBroker(transaction));
-        mxBean.setSchemaService(lookupSchemaServiceInstance(transaction));
-        return nameCreated;
-    }
-
-    private static ObjectName lookupMappingServiceInstance(final ConfigTransactionJMXClient transaction) {
-        try {
-            return transaction.lookupConfigBean(RuntimeMappingModuleFactory.NAME, RuntimeMappingModuleFactory.SINGLETON_NAME);
-        } catch (final InstanceNotFoundException e) {
-            try {
-                return transaction.createModule(RuntimeMappingModuleFactory.NAME, RuntimeMappingModuleFactory.SINGLETON_NAME);
-            } catch (final InstanceAlreadyExistsException e1) {
-                throw new IllegalStateException(e1);
-            }
-        }
-    }
-
-    private static ObjectName lookupSchemaServiceInstance(final ConfigTransactionJMXClient transaction) {
-        try {
-            return transaction.lookupConfigBean(SchemaServiceImplSingletonModuleFactory.NAME, SchemaServiceImplSingletonModuleFactory.SINGLETON_NAME);
-        } catch (final InstanceNotFoundException e) {
-            try {
-                return transaction.createModule(SchemaServiceImplSingletonModuleFactory.NAME, SchemaServiceImplSingletonModuleFactory.SINGLETON_NAME);
-            } catch (final InstanceAlreadyExistsException e1) {
-                throw new IllegalStateException(e1);
-            }
-        }
-    }
-
-    public static ObjectName lookupDomBrokerInstance(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
-        try {
-            return transaction.lookupConfigBean(DomBrokerImplModuleFactory.NAME, DOM_BROKER_INSTANCE_NAME);
-        } catch (final InstanceNotFoundException e) {
-            try {
-                final ObjectName nameCreated = transaction.createModule(DomBrokerImplModuleFactory.NAME, DOM_BROKER_INSTANCE_NAME);
-                final DomBrokerImplModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, DomBrokerImplModuleMXBean.class);
-                mxBean.setAsyncDataBroker(lookupDomAsyncDataBroker(transaction));
-                return nameCreated;
-            } catch (final InstanceAlreadyExistsException e1) {
-                throw new IllegalStateException(e1);
-            }
-        }
-    }
-
-    private static ObjectName lookupDomAsyncDataBroker(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
-        try {
-            return transaction.lookupConfigBean(DomInmemoryDataBrokerModuleFactory.NAME, DOM_ASYNC_DATA_BROKER_INSTANCE);
-        } catch (final InstanceNotFoundException e) {
-            try {
-                final ObjectName nameCreated = transaction.createModule(DomInmemoryDataBrokerModuleFactory.NAME, DOM_ASYNC_DATA_BROKER_INSTANCE);
-                final DomInmemoryDataBrokerModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, DomInmemoryDataBrokerModuleMXBean.class);
-                mxBean.setSchemaService(lookupSchemaServiceInstance(transaction));
-                return nameCreated;
-            } catch (final InstanceAlreadyExistsException e1) {
-                throw new IllegalStateException(e1);
-            }
-        }
-    }
-
-    @Override
-    protected BundleContextServiceRegistrationHandler getBundleContextServiceRegistrationHandler(final Class<?> serviceType) {
-        if (serviceType.equals(SchemaContextListener.class)) {
-            return new BundleContextServiceRegistrationHandler() {
-                @Override
-                public void handleServiceRegistration(final Class<?> clazz, final Object serviceInstance, final Dictionary<String, ?> props) {
-                    final SchemaContextListener listener = (SchemaContextListener) serviceInstance;
-                    final SchemaContext context = parseYangStreams(getFilesAsByteSources(getYangModelsPaths()));
-                    listener.onGlobalContextUpdated(context);
-                    listener.onGlobalContextUpdated(context);
-                }
-            };
-        }
-        return super.getBundleContextServiceRegistrationHandler(serviceType);
-    }
-
-    public List<String> getYangModelsPaths() {
-        final List<String> paths = Lists.newArrayList("/META-INF/yang/ietf-inet-types@2013-07-15.yang", "/META-INF/yang/programming.yang");
-        return paths;
-    }
-
-    public List<ModuleFactory> getModuleFactories() {
-        return Lists.newArrayList(new InstructionSchedulerImplModuleFactory(), new HashedWheelTimerModuleFactory(),
-                new NotificationBrokerImplModuleFactory(), new DomBrokerImplModuleFactory(),
-                new RuntimeMappingModuleFactory(), new BindingBrokerImplModuleFactory(), new BindingAsyncDataBrokerImplModuleFactory(),
-                new DomInmemoryDataBrokerModuleFactory(), new SchemaServiceImplSingletonModuleFactory(),
-                new ForwardedCompatibleDataBrokerImplModuleFactory());
-    }
-
-    // TODO move back to AbstractConfigTest
-    private static Collection<ByteSource> getFilesAsByteSources(final List<String> paths) {
-        final Collection<ByteSource> resources = new ArrayList<>();
-        final List<String> failedToFind = new ArrayList<>();
-        for (final String path : paths) {
-            final URL url = AbstractInstructionSchedulerTest.class.getResource(path);
-            if (url == null) {
-                failedToFind.add(path);
-            } else {
-                resources.add(Resources.asByteSource(url));
-            }
-        }
-        Assert.assertEquals("Some files were not found", Collections.<String> emptyList(), failedToFind);
-
-        return resources;
-    }
-
-    private static YangTextSchemaContextResolver newSchemaContextResolver(final List<String> paths) {
-        final YangTextSchemaContextResolver resolver = YangTextSchemaContextResolver.create("test");
-        final List<String> failedToFind = new ArrayList<>();
-        for (final String path : paths) {
-            final URL url = AbstractInstructionSchedulerTest.class.getResource(path);
-            if (url == null) {
-                failedToFind.add(path);
-            } else {
-                try {
-                    resolver.registerSource(url);
-                } catch(SchemaSourceException | IOException | YangSyntaxErrorException e) {
-                    Throwables.propagate(e);
-                }
-            }
-        }
-        Assert.assertEquals("Some files were not found", Collections.<String> emptyList(), failedToFind);
-        return resolver;
-    }
-
-    private static SchemaContext parseYangStreams(final Collection<ByteSource> streams) {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
-        try {
-            return reactor.buildEffective(streams);
-        } catch (final ReactorException | IOException e) {
-            throw new RuntimeException("Unable to build schema context from " + streams, e);
-        }
-    }
-
-}
diff --git a/programming/impl/src/test/java/org/opendaylight/controller/config/yang/programming/impl/InstructionSchedulerImplModuleTest.java b/programming/impl/src/test/java/org/opendaylight/controller/config/yang/programming/impl/InstructionSchedulerImplModuleTest.java
deleted file mode 100644 (file)
index cd410c0..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.programming.impl;
-
-import javax.management.ObjectName;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-
-public class InstructionSchedulerImplModuleTest extends AbstractInstructionSchedulerTest {
-    private static final String FACTORY_NAME = InstructionSchedulerImplModuleFactory.NAME;
-
-    @Test
-    public void testCreateBean() throws Exception {
-        final CommitStatus status = createInstance();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 10, 0, 0);
-    }
-
-    @Test
-    public void testReusingOldInstance() throws Exception {
-        createInstance();
-        final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        assertBeanCount(1, FACTORY_NAME);
-        final CommitStatus status = transaction.commit();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 0, 10);
-    }
-
-    private CommitStatus createInstance() throws Exception {
-        final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        final ObjectName asyncDataBroker = createAsyncDataBrokerInstance(transaction);
-        final ObjectName dataBrokerON = createCompatibleDataBrokerInstance(transaction);
-        final ObjectName notificationBrokerON = createNotificationBrokerInstance(transaction);
-        createInstructionSchedulerModuleInstance(transaction, asyncDataBroker , createBindingBrokerImpl(transaction,
-                dataBrokerON, notificationBrokerON), notificationBrokerON);
-        return transaction.commit();
-    }
-}
\ No newline at end of file