Search in sources :

Example 1 with DOMClusterSingletonServiceProviderImpl

use of org.opendaylight.mdsal.singleton.dom.impl.DOMClusterSingletonServiceProviderImpl in project netconf by opendaylight.

the class MountPointEndToEndTest method setupMaster.

private void setupMaster() throws Exception {
    AbstractConcurrentDataBrokerTest dataBrokerTest = newDataBrokerTest();
    masterDataBroker = dataBrokerTest.getDataBroker();
    deviceDOMDataBroker = dataBrokerTest.getDomBroker();
    bindingToNormalized = dataBrokerTest.getDataBrokerTestCustomizer().getAdapterContext().currentSerializer();
    masterSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, ConfigFactory.load().getConfig("Master"));
    masterClusterSingletonServiceProvider = new DOMClusterSingletonServiceProviderImpl();
    masterClusterSingletonServiceProvider.initializeProvider();
    doReturn(masterSystem).when(mockMasterActorSystemProvider).getActorSystem();
    doReturn(MoreExecutors.newDirectExecutorService()).when(mockThreadPool).getExecutor();
    final SchemaResourcesDTO resources = resourceManager.getSchemaResources(new NetconfNodeBuilder().setSchemaCacheDirectory(TEST_DEFAULT_SUBDIR).build(), "test");
    resources.getSchemaRegistry().registerSchemaSource(id -> Futures.immediateFuture(YangTextSchemaSource.delegateForByteSource(id, topModuleInfo.getYangTextByteSource())), PotentialSchemaSource.create(RevisionSourceIdentifier.create(TOP_MODULE_NAME, topModuleInfo.getName().getRevision()), YangTextSchemaSource.class, 1));
    masterNetconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, masterDataBroker, mockRpcProviderRegistry, mockActionProviderRegistry, masterClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool, mockMasterActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config, masterMountPointService, mockEncryptionService, mockRpcProviderService, deviceActionFactory, resourceManager) {

        @Override
        protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup, final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime, final DeviceActionFactory deviceActionFact) {
            NetconfTopologyContext context = super.newNetconfTopologyContext(setup, serviceGroupIdent, actorResponseWaitTime, deviceActionFact);
            NetconfTopologyContext spiedContext = spy(context);
            doAnswer(invocation -> {
                final MasterSalFacade spiedFacade = (MasterSalFacade) spy(invocation.callRealMethod());
                doReturn(deviceDOMDataBroker).when(spiedFacade).newDeviceDataBroker();
                masterSalFacadeFuture.set(spiedFacade);
                return spiedFacade;
            }).when(spiedContext).newMasterSalFacade();
            return spiedContext;
        }
    };
    masterNetconfTopologyManager.init();
    verifyTopologyNodesCreated(masterDataBroker);
}
Also used : DeviceActionFactory(org.opendaylight.netconf.sal.connect.api.DeviceActionFactory) SchemaResourceManager(org.opendaylight.netconf.sal.connect.api.SchemaResourceManager) ThreadPool(org.opendaylight.controller.config.threadpool.ThreadPool) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) ConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder) GetTopOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.GetTopOutputBuilder) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) DOMActionProviderService(org.opendaylight.mdsal.dom.api.DOMActionProviderService) PutTopInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.PutTopInputBuilder) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Mockito.doReturn(org.mockito.Mockito.doReturn) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) DOMActionService(org.opendaylight.mdsal.dom.api.DOMActionService) DOMDataTreeReadOperations(org.opendaylight.mdsal.dom.api.DOMDataTreeReadOperations) Awaitility.await(org.awaitility.Awaitility.await) Module(org.opendaylight.yangtools.yang.model.api.Module) ActorSystemProvider(org.opendaylight.controller.cluster.ActorSystemProvider) Set(java.util.Set) ErrorType(org.opendaylight.yangtools.yang.common.RpcError.ErrorType) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) FluentFutures(org.opendaylight.yangtools.util.concurrent.FluentFutures) NetconfNodeConnectionStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top) Assert.assertFalse(org.junit.Assert.assertFalse) PotentialSchemaSource(org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource) NetconfSessionPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.mock(org.mockito.Mockito.mock) EventExecutor(io.netty.util.concurrent.EventExecutor) YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) Mock(org.mockito.Mock) TransactionChainListener(org.opendaylight.mdsal.binding.api.TransactionChainListener) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) RunWith(org.junit.runner.RunWith) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) Mockito.spy(org.mockito.Mockito.spy) Timeout(akka.util.Timeout) ArrayList(java.util.ArrayList) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) Mockito.timeout(org.mockito.Mockito.timeout) Lists(com.google.common.collect.Lists) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) Host(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) GetTopInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.GetTopInput) Before(org.junit.Before) ReconnectFuture(org.opendaylight.netconf.nettyutil.ReconnectFuture) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Keystore(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.Keystore) Assert.assertTrue(org.junit.Assert.assertTrue) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey) DOMRpcRouter(org.opendaylight.mdsal.dom.broker.DOMRpcRouter) NetconfMessageTransformUtil(org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil) File(java.io.File) QName(org.opendaylight.yangtools.yang.common.QName) ExecutionException(java.util.concurrent.ExecutionException) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) Mockito.never(org.mockito.Mockito.never) Futures(com.google.common.util.concurrent.Futures) NetconfTopologyUtils(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils) Assert.assertNull(org.junit.Assert.assertNull) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RpcProviderService(org.opendaylight.mdsal.binding.api.RpcProviderService) RevisionSourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) DOMRpcProviderService(org.opendaylight.mdsal.dom.api.DOMRpcProviderService) Assert.assertEquals(org.junit.Assert.assertEquals) RpcError(org.opendaylight.yangtools.yang.common.RpcError) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) DefaultSchemaResourceManager(org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) ClusteringRpcException(org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringRpcException) TopologyNetconf(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf) Config(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config) BindingReflections(org.opendaylight.mdsal.binding.spec.reflect.BindingReflections) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) SettableFuture(com.google.common.util.concurrent.SettableFuture) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) GlobalEventExecutor(io.netty.util.concurrent.GlobalEventExecutor) NetconfNode(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) After(org.junit.After) Assert.fail(org.junit.Assert.fail) BindingNormalizedNodeSerializer(org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer) LoginPasswordUnencryptedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.login.pw.unencrypted.LoginPasswordUnencryptedBuilder) DOMDataTreeReadWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) LoginPwUnencryptedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPwUnencryptedBuilder) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Uint16(org.opendaylight.yangtools.yang.common.Uint16) NetconfClientDispatcher(org.opendaylight.netconf.client.NetconfClientDispatcher) TransactionChain(org.opendaylight.mdsal.binding.api.TransactionChain) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) ImmutableNodes(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes) ActorSystem(akka.actor.ActorSystem) Entry(java.util.Map.Entry) Optional(java.util.Optional) TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder) DOMService(org.opendaylight.mdsal.dom.api.DOMService) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DataTreeIdentifier(org.opendaylight.mdsal.binding.api.DataTreeIdentifier) DOMRpcImplementation(org.opendaylight.mdsal.dom.api.DOMRpcImplementation) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ImmutableList(com.google.common.collect.ImmutableList) ScheduledThreadPool(org.opendaylight.controller.config.threadpool.ScheduledThreadPool) DOMMountPointListener(org.opendaylight.mdsal.dom.api.DOMMountPointListener) ConfigFactory(com.typesafe.config.ConfigFactory) DataTreeModification(org.opendaylight.mdsal.binding.api.DataTreeModification) SimpleEntry(java.util.AbstractMap.SimpleEntry) DataObjectModification(org.opendaylight.mdsal.binding.api.DataObjectModification) Builders(org.opendaylight.yangtools.yang.data.impl.schema.Builders) DOMClusterSingletonServiceProviderImpl(org.opendaylight.mdsal.singleton.dom.impl.DOMClusterSingletonServiceProviderImpl) BindingRuntimeHelpers(org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers) ClusterSingletonServiceProvider(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Assert.assertNotNull(org.junit.Assert.assertNotNull) DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) TestKit(akka.testkit.javadsl.TestKit) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Transaction(org.opendaylight.mdsal.binding.api.Transaction) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) AAAEncryptionService(org.opendaylight.aaa.encrypt.AAAEncryptionService) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) SchemaResourcesDTO(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO) DOMMountPointServiceImpl(org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) FluentFuture(com.google.common.util.concurrent.FluentFuture) YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) Timeout(akka.util.Timeout) DeviceActionFactory(org.opendaylight.netconf.sal.connect.api.DeviceActionFactory) SchemaResourcesDTO(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) DOMClusterSingletonServiceProviderImpl(org.opendaylight.mdsal.singleton.dom.impl.DOMClusterSingletonServiceProviderImpl) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest)

Aggregations

ActorSystem (akka.actor.ActorSystem)1 TestKit (akka.testkit.javadsl.TestKit)1 Timeout (akka.util.Timeout)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 FluentFuture (com.google.common.util.concurrent.FluentFuture)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 SettableFuture (com.google.common.util.concurrent.SettableFuture)1 ConfigFactory (com.typesafe.config.ConfigFactory)1 EventExecutor (io.netty.util.concurrent.EventExecutor)1 GlobalEventExecutor (io.netty.util.concurrent.GlobalEventExecutor)1 File (java.io.File)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1