From: Jan Hajnar Date: Mon, 16 Mar 2015 11:00:21 +0000 (+0100) Subject: BUG 2412 - Remove CompositeNode from sal-dom-* X-Git-Tag: release/lithium~375 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=refs%2Fchanges%2F30%2F16630%2F12 BUG 2412 - Remove CompositeNode from sal-dom-* * removed CompositeNodes from sal-dom-broker * removed deprecated services from sal-dom-broker * removed deprecated services from sal-dom-api * removed deprecated api calls from sal-binding-broker tests and sal-dom-spi Change-Id: Iae44e5c0acd0ad602bf98b9961fcd808657ac07b Signed-off-by: Jan Hajnar --- diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AbstractDataServiceTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AbstractDataServiceTest.java index 059c6449df..6de2666de1 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AbstractDataServiceTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AbstractDataServiceTest.java @@ -17,7 +17,6 @@ import org.opendaylight.controller.sal.binding.test.util.BindingTestContext; @SuppressWarnings("deprecation") public abstract class AbstractDataServiceTest { - protected org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService; protected DataProviderService baDataService; protected BindingTestContext testContext; @@ -32,7 +31,6 @@ public abstract class AbstractDataServiceTest { testContext.start(); baDataService = testContext.getBindingDataBroker(); - biDataService = testContext.getDomDataBroker(); } protected boolean getStartWithSchema() { diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/compat/MultipleAugmentationPutsTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/compat/MultipleAugmentationPutsTest.java deleted file mode 100644 index ba58a6f213..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/compat/MultipleAugmentationPutsTest.java +++ /dev/null @@ -1,200 +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.sal.binding.test.compat; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; -import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; -import org.opendaylight.controller.sal.binding.test.AugmentationVerifier; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyAugmentBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUses; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; - -@Deprecated -public class MultipleAugmentationPutsTest extends AbstractDataServiceTest implements DataChangeListener { - - private static final QName NODE_ID_QNAME = QName.create(TopLevelList.QNAME, "name"); - private static final String NODE_ID = "openflow:1"; - - private static final TopLevelListKey NODE_KEY = new TopLevelListKey(NODE_ID); - - private static final Map NODE_KEY_BI = Collections. singletonMap(NODE_ID_QNAME, - NODE_ID); - - private static final InstanceIdentifier NODES_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) // - .toInstance(); - - private static final InstanceIdentifier NODE_INSTANCE_ID_BA = - NODES_INSTANCE_ID_BA.child(TopLevelList.class, NODE_KEY); - - private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier NODE_INSTANCE_ID_BI = // - org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder() // - .node(Top.QNAME) // - .nodeWithKey(TopLevelList.QNAME, NODE_KEY_BI) // - .toInstance(); - private DataChangeEvent, DataObject> receivedChangeEvent; - - /** - * Test for Bug 148 - * - * @throws Exception - */ - @Test() - public void testAugmentSerialization() throws Exception { - - baDataService.registerDataChangeListener(NODES_INSTANCE_ID_BA, this); - - TopLevelList flowCapableNode = createTestNode(TreeLeafOnlyAugment.class, createTreeLeafOnlyAugmentation()); - commitNodeAndVerifyTransaction(flowCapableNode); - - assertNotNull(receivedChangeEvent); - verifyNode((Top) receivedChangeEvent.getUpdatedOperationalSubtree(), flowCapableNode); - - Top nodes = checkForNodes(); - verifyNode(nodes, flowCapableNode).assertHasAugmentation(TreeLeafOnlyAugment.class); - assertBindingIndependentVersion(NODE_INSTANCE_ID_BI); - TopLevelList meterStatsNode = createTestNode(TreeComplexUsesAugment.class, createTreeComplexUsesAugment()); - commitNodeAndVerifyTransaction(meterStatsNode); - - assertNotNull(receivedChangeEvent); - verifyNode((Top) receivedChangeEvent.getUpdatedOperationalSubtree(), meterStatsNode); - - assertBindingIndependentVersion(NODE_INSTANCE_ID_BI); - - TopLevelList mergedNode = (TopLevelList) baDataService.readOperationalData(NODE_INSTANCE_ID_BA); - - AugmentationVerifier.from(mergedNode) // - .assertHasAugmentation(TreeLeafOnlyAugment.class) // - .assertHasAugmentation(TreeComplexUsesAugment.class); - - assertBindingIndependentVersion(NODE_INSTANCE_ID_BI); - - TopLevelList meterStatsNodeWithDuration = createTestNode(TreeComplexUsesAugment.class, createTreeComplexUsesAugment(5)); - commitNodeAndVerifyTransaction(meterStatsNodeWithDuration); - - - TopLevelList nodeWithUpdatedList = (TopLevelList) baDataService.readOperationalData(NODE_INSTANCE_ID_BA); - AugmentationVerifier.from(nodeWithUpdatedList) // - .assertHasAugmentation(TreeLeafOnlyAugment.class) // - .assertHasAugmentation(TreeComplexUsesAugment.class); - - List meterStats = nodeWithUpdatedList.getAugmentation(TreeComplexUsesAugment.class).getListViaUses(); - assertNotNull(meterStats); - Assert.assertFalse(meterStats.isEmpty()); - assertBindingIndependentVersion(NODE_INSTANCE_ID_BI); - testNodeRemove(); - } - - private static > TopLevelList createTestNode(final Class augmentationClass, final T augmentation) { - TopLevelListBuilder nodeBuilder = new TopLevelListBuilder(); - nodeBuilder.setKey(NODE_KEY); - nodeBuilder.setName(NODE_KEY.getName()); - nodeBuilder.addAugmentation(augmentationClass, augmentation); - return nodeBuilder.build(); - } - - private DataModificationTransaction commitNodeAndVerifyTransaction(final TopLevelList original) throws Exception { - DataModificationTransaction transaction = baDataService.beginTransaction(); - transaction.putOperationalData(NODE_INSTANCE_ID_BA, original); - RpcResult result = transaction.commit().get(); - assertEquals(TransactionStatus.COMMITED, result.getResult()); - return transaction; - } - - private void testNodeRemove() throws Exception { - DataModificationTransaction transaction = baDataService.beginTransaction(); - transaction.removeOperationalData(NODE_INSTANCE_ID_BA); - RpcResult result = transaction.commit().get(); - assertEquals(TransactionStatus.COMMITED, result.getResult()); - - TopLevelList node = (TopLevelList) baDataService.readOperationalData(NODE_INSTANCE_ID_BA); - assertNull(node); - } - - private static AugmentationVerifier verifyNode(final Top nodes, final TopLevelList original) { - assertNotNull(nodes); - assertNotNull(nodes.getTopLevelList()); - assertEquals(1, nodes.getTopLevelList().size()); - TopLevelList readedNode = nodes.getTopLevelList().get(0); - assertEquals(original.getName(), readedNode.getName()); - assertEquals(original.getKey(), readedNode.getKey()); - return new AugmentationVerifier<>(readedNode); - } - - private void assertBindingIndependentVersion(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier nodeId) { - CompositeNode node = biDataService.readOperationalData(nodeId); - assertNotNull(node); - } - - private Top checkForNodes() { - return (Top) baDataService.readOperationalData(NODES_INSTANCE_ID_BA); - } - - private static TreeComplexUsesAugment createTreeComplexUsesAugment() { - return createTreeComplexUsesAugment(10); - } - - private static TreeComplexUsesAugment createTreeComplexUsesAugment(final int count) { - TreeComplexUsesAugmentBuilder tcuaBld = new TreeComplexUsesAugmentBuilder(); - ContainerWithUsesBuilder cwuBld = new ContainerWithUsesBuilder(); - cwuBld.setLeafFromGrouping("lfg1"); - - List lvuBag = new ArrayList<>(count); - for (int i = 0; i <= count; i++) { - ListViaUsesBuilder statistic = new ListViaUsesBuilder(); - String name = String.valueOf(i); - statistic.setKey(new ListViaUsesKey(name)); - statistic.setName(name); - lvuBag.add(statistic.build()); - } - tcuaBld.setContainerWithUses(cwuBld.build()); - tcuaBld.setListViaUses(lvuBag); - return tcuaBld.build(); - } - - private static TreeLeafOnlyAugment createTreeLeafOnlyAugmentation() { - TreeLeafOnlyAugmentBuilder fnub = new TreeLeafOnlyAugmentBuilder(); - fnub.setSimpleValue("meVerySimpleIs"); - TreeLeafOnlyAugment fnu = fnub.build(); - return fnu; - } - - @Override - public void onDataChanged(final DataChangeEvent, DataObject> change) { - receivedChangeEvent = change; - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/compat/package-info.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/compat/package-info.java deleted file mode 100644 index ec74c3e19b..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/compat/package-info.java +++ /dev/null @@ -1,13 +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 - */ -/** - * - * Test suite targeting legacy Data APIs - * - */ -package org.opendaylight.controller.sal.binding.test.compat; \ No newline at end of file diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java index 5de4313239..a439e9ea26 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java @@ -17,8 +17,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.MutableClassToInstanceMap; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; -import java.util.Set; -import java.util.concurrent.Future; import javassist.ClassPool; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.MountPointService; @@ -37,7 +35,6 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter; import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker; -import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker; import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; @@ -47,27 +44,17 @@ import org.opendaylight.controller.sal.binding.api.mount.MountProviderService; import org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl; import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker; import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; import org.opendaylight.controller.sal.core.spi.data.DOMStore; import org.opendaylight.controller.sal.dom.broker.BrokerImpl; -import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker; import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator; import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator; import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy; import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.opendaylight.yangtools.yang.binding.util.BindingReflections; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @Beta @@ -81,8 +68,6 @@ public class BindingTestContext implements AutoCloseable { private NotificationBrokerImpl baNotifyImpl; - @Deprecated - private org.opendaylight.controller.sal.core.api.data.DataProviderService biDataLegacyBroker; private BrokerImpl biBrokerImpl; private final ListeningExecutorService executor; @@ -94,9 +79,6 @@ public class BindingTestContext implements AutoCloseable { private ImmutableMap newDatastores; - @Deprecated - private BackwardsCompatibleDataBroker biCompatibleBroker; - @Deprecated private DataProviderService baData; @@ -147,11 +129,8 @@ public class BindingTestContext implements AutoCloseable { newDOMDataBroker = new SerializedDOMDataBroker(newDatastores, executor); - biCompatibleBroker = new BackwardsCompatibleDataBroker(newDOMDataBroker,mockSchemaService); - mockSchemaService.registerSchemaContextListener(configStore); mockSchemaService.registerSchemaContextListener(operStore); - biDataLegacyBroker = biCompatibleBroker; } public void startBindingDataBroker() { @@ -171,7 +150,7 @@ public class BindingTestContext implements AutoCloseable { final MountPointService mountService = new BindingDOMMountPointServiceAdapter(biMountImpl, codec); baBrokerImpl.setMountService(mountService); baBrokerImpl.setLegacyMountManager(new HydrogenMountProvisionServiceAdapter(mountService)); - baBrokerImpl.setRpcBroker(new HeliumRpcProviderRegistry(baConsumerRpc,baProviderRpc)); + baBrokerImpl.setRpcBroker(new HeliumRpcProviderRegistry(baConsumerRpc, baProviderRpc)); baBrokerImpl.setLegacyDataBroker(baData); baBrokerImpl.setNotificationBroker(baNotifyImpl); baBrokerImpl.start(); @@ -187,18 +166,12 @@ public class BindingTestContext implements AutoCloseable { final ClassToInstanceMap domBrokerServices = ImmutableClassToInstanceMap . builder() // - .put(org.opendaylight.controller.sal.core.api.data.DataProviderService.class, biDataLegacyBroker) // - .put(RpcProvisionRegistry.class, biBrokerImpl.getRouter()) // + .put(DOMRpcRouter.class, biBrokerImpl.getRouter()) // .put(DOMMountPointService.class, biMountImpl) .build(); return new ProviderSession() { - @Override - public Future> rpc(final QName rpc, final CompositeNode input) { - throw new UnsupportedOperationException(); - } - @Override public T getService(final Class service) { return domBrokerServices.getInstance(service); @@ -209,36 +182,9 @@ public class BindingTestContext implements AutoCloseable { return false; } - @Override - public Set getSupportedRpcs() { - return null; - } - @Override public void close() { } - - @Override - public ListenerRegistration addRpcRegistrationListener( - final RpcRegistrationListener listener) { - return null; - } - - @Override - public RpcRegistration addRpcImplementation(final QName rpcType, final RpcImplementation implementation) - throws IllegalArgumentException { - return null; - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(final QName rpcType, final RpcImplementation implementation) { - return null; - } - - @Override - public RoutedRpcRegistration addMountedRpcImplementation(final QName rpcType, final RpcImplementation implementation) { - return null; - } }; } @@ -291,15 +237,13 @@ public class BindingTestContext implements AutoCloseable { private void startDomBroker() { checkState(executor != null); - final SchemaAwareRpcBroker router = new SchemaAwareRpcBroker("/", mockSchemaService); - domRouter = new DOMRpcRouter(); mockSchemaService.registerSchemaContextListener(domRouter); final ClassToInstanceMap services = MutableClassToInstanceMap.create(); services.put(DOMRpcService.class, domRouter); - biBrokerImpl = new BrokerImpl(router,services); + biBrokerImpl = new BrokerImpl(domRouter,services); } @@ -319,11 +263,6 @@ public class BindingTestContext implements AutoCloseable { return baData; } - @Deprecated - public org.opendaylight.controller.sal.core.api.data.DataProviderService getDomDataBroker() { - return biDataLegacyBroker; - } - public RpcProviderRegistry getBindingRpcRegistry() { return baBrokerImpl.getRoot(); } diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug02Test.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug02Test.java deleted file mode 100644 index d5ddc9fc63..0000000000 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug02Test.java +++ /dev/null @@ -1,92 +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.sal.binding.test.bugfix; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import java.util.Collections; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; -import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; - -@SuppressWarnings("deprecation") -public class DOMCodecBug02Test extends AbstractDataServiceTest { - - private static final InstanceIdentifier TOP_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) // - .toInstance(); - - /** - * This test is ignored, till found out better way to test generation of - * classes without leaking of instances from previous run - * - * @throws Exception - */ - - @Override - public void setUp() { - ListeningExecutorService executor = MoreExecutors.sameThreadExecutor(); - BindingBrokerTestFactory factory = new BindingBrokerTestFactory(); - factory.setExecutor(executor); - factory.setStartWithParsedSchema(getStartWithSchema()); - testContext = factory.getTestContext(); - testContext.start(); - - baDataService = testContext.getBindingDataBroker(); - biDataService = testContext.getDomDataBroker(); - }; - - @Test - public void testSchemaContextNotAvailable() throws Exception { - - ExecutorService testExecutor = Executors.newFixedThreadPool(1); - testContext.loadYangSchemaFromClasspath(); - Future>> future = testExecutor - .submit(new Callable>>() { - @Override - public Future> call() throws Exception { - TopBuilder topBuilder = new TopBuilder(); - topBuilder.setTopLevelList(Collections. emptyList()); - DataModificationTransaction transaction = baDataService.beginTransaction(); - transaction.putOperationalData(TOP_INSTANCE_ID_BA, topBuilder.build()); - return transaction.commit(); - } - }); - - RpcResult result = future.get().get(); - assertEquals(TransactionStatus.COMMITED, result.getResult()); - - Top top = checkForTop(); - assertNotNull(top); - - } - - private Top checkForTop() { - return (Top) baDataService.readOperationalData(TOP_INSTANCE_ID_BA); - - } - - @Override - protected boolean getStartWithSchema() { - return false; - } - -} diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java index 7c5c2ba0e0..6e9d9fd82b 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java @@ -7,9 +7,10 @@ */ package org.opendaylight.controller.md.sal.common.impl.util.compat; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - +import com.google.common.base.Optional; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -17,26 +18,17 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; - -import javax.xml.transform.dom.DOMSource; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; -import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder; import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; @@ -51,15 +43,6 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import com.google.common.base.Optional; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * @deprecated This class provides compatibility between {@link CompositeNode} and {@link NormalizedNode}. - * Users of this class should use {@link NormalizedNode}s directly. - */ @Deprecated public abstract class DataNormalizationOperation implements Identifiable { @@ -98,7 +81,6 @@ public abstract class DataNormalizationOperation impleme public abstract DataNormalizationOperation getChild(QName child) throws DataNormalizationException; - public abstract NormalizedNode normalize(Node legacyData); public abstract boolean isLeaf(); @@ -113,15 +95,6 @@ public abstract class DataNormalizationOperation impleme super(identifier,potential); } - @Override - public NormalizedNode normalize(final Node legacyData) { - checkArgument(legacyData != null); - checkArgument(legacyData instanceof SimpleNode); - return normalizeImpl((SimpleNode) legacyData); - } - - protected abstract NormalizedNode normalizeImpl(SimpleNode node); - @Override public DataNormalizationOperation getChild(final PathArgument child) { return null; @@ -150,11 +123,6 @@ public abstract class DataNormalizationOperation impleme super(new NodeIdentifier(potential.getQName()),potential); } - @Override - protected NormalizedNode normalizeImpl(final SimpleNode node) { - return ImmutableNodes.leafNode(node.getNodeType(), node.getValue()); - } - } private static final class LeafListEntryNormalization extends SimpleTypeNormalization { @@ -163,13 +131,6 @@ public abstract class DataNormalizationOperation impleme super(new NodeWithValue(potential.getQName(), null),potential); } - @Override - protected NormalizedNode normalizeImpl(final SimpleNode node) { - NodeWithValue nodeId = new NodeWithValue(node.getNodeType(), node.getValue()); - return Builders.leafSetEntryBuilder().withNodeIdentifier(nodeId).withValue(node.getValue()).build(); - } - - @Override public boolean isKeyedEntry() { return true; @@ -183,58 +144,11 @@ public abstract class DataNormalizationOperation impleme super(identifier,schema); } - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public final NormalizedNode normalize(final Node legacyData) { - checkArgument(legacyData != null); - if (!isMixin() && getIdentifier().getNodeType() != null) { - checkArgument(getIdentifier().getNodeType().equals(legacyData.getNodeType()), - "Node QName must be %s was %s", getIdentifier().getNodeType(), legacyData.getNodeType()); - } - checkArgument(legacyData instanceof CompositeNode, "Node %s should be composite", legacyData); - CompositeNode compositeNode = (CompositeNode) legacyData; - NormalizedNodeContainerBuilder builder = createBuilder(compositeNode); - - Set> usedMixins = new HashSet<>(); - for (Node childLegacy : compositeNode.getValue()) { - final DataNormalizationOperation childOp; - - try { - childOp = getChild(childLegacy.getNodeType()); - } catch (DataNormalizationException e) { - throw new IllegalArgumentException(String.format("Failed to normalize data %s", compositeNode.getValue()), e); - } - - // We skip unknown nodes if this node is mixin since - // it's nodes and parent nodes are interleaved - if (childOp == null && isMixin()) { - continue; - } - - checkArgument(childOp != null, "Node %s is not allowed inside %s", childLegacy.getNodeType(), - getIdentifier()); - if (childOp.isMixin()) { - if (usedMixins.contains(childOp)) { - // We already run / processed that mixin, so to avoid - // duplicity we are skipping next nodes. - continue; - } - builder.addChild(childOp.normalize(compositeNode)); - usedMixins.add(childOp); - } else { - builder.addChild(childOp.normalize(childLegacy)); - } - } - return builder.build(); - } - @Override public boolean isLeaf() { return false; } - @SuppressWarnings("rawtypes") - protected abstract NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode); } @@ -306,20 +220,6 @@ public abstract class DataNormalizationOperation impleme keyDefinition = schema.getKeyDefinition(); } - @Override - protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) { - ImmutableMap.Builder keys = ImmutableMap.builder(); - for (QName key : keyDefinition) { - - SimpleNode valueNode = checkNotNull(compositeNode.getFirstSimpleByName(key), - "List node %s MUST contain leaf %s with value.", getIdentifier().getNodeType(), key); - keys.put(key, valueNode.getValue()); - } - - return Builders.mapEntryBuilder().withNodeIdentifier( - new NodeIdentifierWithPredicates(getIdentifier().getNodeType(), keys.build())); - } - @Override public NormalizedNode createDefault(final PathArgument currentArg) { DataContainerNodeAttrBuilder builder = Builders @@ -346,11 +246,6 @@ public abstract class DataNormalizationOperation impleme super(new NodeIdentifier(schema.getQName()), schema,schema); } - @Override - protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) { - return Builders.unkeyedListEntryBuilder().withNodeIdentifier(getIdentifier()); - } - @Override public NormalizedNode createDefault(final PathArgument currentArg) { return Builders.unkeyedListEntryBuilder().withNodeIdentifier((NodeIdentifier) currentArg).build(); @@ -364,11 +259,6 @@ public abstract class DataNormalizationOperation impleme super(new NodeIdentifier(schema.getQName()),schema, schema); } - @Override - protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) { - return Builders.containerBuilder().withNodeIdentifier(getIdentifier()); - } - @Override public NormalizedNode createDefault(final PathArgument currentArg) { return Builders.containerBuilder().withNodeIdentifier((NodeIdentifier) currentArg).build(); @@ -398,11 +288,6 @@ public abstract class DataNormalizationOperation impleme super(potential); } - @Override - protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) { - return Builders.orderedLeafSetBuilder().withNodeIdentifier(getIdentifier()); - } - @Override public NormalizedNode createDefault(final PathArgument currentArg) { return Builders.orderedLeafSetBuilder().withNodeIdentifier(getIdentifier()).build(); @@ -417,12 +302,6 @@ public abstract class DataNormalizationOperation impleme super(new NodeIdentifier(potential.getQName()),potential); innerOp = new LeafListEntryNormalization(potential); } - - @Override - protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) { - return Builders.leafSetBuilder().withNodeIdentifier(getIdentifier()); - } - @Override public NormalizedNode createDefault(final PathArgument currentArg) { return Builders.leafSetBuilder().withNodeIdentifier(getIdentifier()).build(); @@ -480,12 +359,6 @@ public abstract class DataNormalizationOperation impleme return getIdentifier().getPossibleChildNames(); } - @SuppressWarnings("rawtypes") - @Override - protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) { - return Builders.augmentationBuilder().withNodeIdentifier(getIdentifier()); - } - @Override public NormalizedNode createDefault(final PathArgument currentArg) { return Builders.augmentationBuilder().withNodeIdentifier(getIdentifier()).build(); @@ -503,12 +376,6 @@ public abstract class DataNormalizationOperation impleme Collections. emptyMap()), list); } - @SuppressWarnings("rawtypes") - @Override - protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) { - return Builders.mapBuilder().withNodeIdentifier(getIdentifier()); - } - @Override public NormalizedNode createDefault(final PathArgument currentArg) { return Builders.mapBuilder().withNodeIdentifier(getIdentifier()).build(); @@ -542,12 +409,6 @@ public abstract class DataNormalizationOperation impleme this.innerNode = new UnkeyedListItemNormalization(list); } - @SuppressWarnings("rawtypes") - @Override - protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) { - return Builders.unkeyedListBuilder().withNodeIdentifier(getIdentifier()); - } - @Override public NormalizedNode createDefault(final PathArgument currentArg) { return Builders.unkeyedListBuilder().withNodeIdentifier(getIdentifier()).build(); @@ -577,12 +438,6 @@ public abstract class DataNormalizationOperation impleme super(list); } - @SuppressWarnings("rawtypes") - @Override - protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) { - return Builders.orderedMapBuilder().withNodeIdentifier(getIdentifier()); - } - @Override public NormalizedNode createDefault(final PathArgument currentArg) { return Builders.orderedMapBuilder().withNodeIdentifier(getIdentifier()).build(); @@ -623,11 +478,6 @@ public abstract class DataNormalizationOperation impleme return byQName.get(child); } - @Override - protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) { - return Builders.choiceBuilder().withNodeIdentifier(getIdentifier()); - } - @Override public NormalizedNode createDefault(final PathArgument currentArg) { return Builders.choiceBuilder().withNodeIdentifier(getIdentifier()).build(); @@ -650,16 +500,6 @@ public abstract class DataNormalizationOperation impleme return null; } - @Override - public NormalizedNode normalize( final Node legacyData ) { - NormalizedNodeAttrBuilder builder = - Builders.anyXmlBuilder().withNodeIdentifier( - new NodeIdentifier( legacyData.getNodeType() ) ); - // Will be removed -// builder.withValue(legacyData); - return builder.build(); - } - @Override public boolean isLeaf() { return false; diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java index 65f0945ce3..9876a57d1a 100644 --- a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizer.java @@ -9,37 +9,15 @@ package org.opendaylight.controller.md.sal.common.impl.util.compat; import static com.google.common.base.Preconditions.checkArgument; -import java.util.AbstractMap; -import java.util.ArrayList; +import com.google.common.collect.ImmutableList; import java.util.Iterator; -import java.util.Map; - -import javax.xml.transform.dom.DOMSource; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; -import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.MixinNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; -import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; -import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl; -import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import com.google.common.base.Preconditions; -import com.google.common.base.Predicates; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - /** - * @deprecated This class provides compatibility between {@link CompositeNode} and {@link NormalizedNode}. - * Users of this class should use {@link NormalizedNode}s directly. + * @deprecated This class provides compatibility between XML semantics + * and {@link org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree} */ @Deprecated public class DataNormalizer { @@ -86,31 +64,6 @@ public class DataNormalizer { return currentOp; } - public Map.Entry> toNormalized( - final Map.Entry legacy) { - return toNormalized(legacy.getKey(), legacy.getValue()); - } - - public Map.Entry> toNormalized(final YangInstanceIdentifier legacyPath, - final CompositeNode legacyData) { - - YangInstanceIdentifier normalizedPath = toNormalized(legacyPath); - - DataNormalizationOperation currentOp = operation; - for (PathArgument arg : normalizedPath.getPathArguments()) { - try { - currentOp = currentOp.getChild(arg); - } catch (DataNormalizationException e) { - throw new IllegalArgumentException(String.format("Failed to validate normalized path %s", - normalizedPath), e); - } - } - Preconditions.checkArgument(currentOp != null, - "Instance Identifier %s does not reference correct schema Node.", normalizedPath); - return new AbstractMap.SimpleEntry>(normalizedPath, - currentOp.normalize(legacyData)); - } - public YangInstanceIdentifier toLegacy(final YangInstanceIdentifier normalized) throws DataNormalizationException { ImmutableList.Builder legacyArgs = ImmutableList.builder(); DataNormalizationOperation currentOp = operation; @@ -123,85 +76,6 @@ public class DataNormalizer { return YangInstanceIdentifier.create(legacyArgs.build()); } - public CompositeNode toLegacy(final YangInstanceIdentifier normalizedPath, final NormalizedNode normalizedData) { - // Preconditions.checkArgument(normalizedData instanceof - // DataContainerNode,"Node object %s, %s should be of type DataContainerNode",normalizedPath,normalizedData); - if (normalizedData instanceof DataContainerNode) { - return toLegacyFromDataContainer((DataContainerNode) normalizedData); - } else if (normalizedData instanceof AnyXmlNode) { - DOMSource value = ((AnyXmlNode) normalizedData).getValue(); - return value instanceof CompositeNode ? (CompositeNode) value : null; - } - return null; - } - - public static Node toLegacy(final NormalizedNode node) { - if (node instanceof MixinNode) { - /** - * Direct reading of MixinNodes is not supported, since it is not - * possible in legacy APIs create pointer to Mixin Nodes. - * - */ - return null; - } - - if (node instanceof DataContainerNode) { - return toLegacyFromDataContainer((DataContainerNode) node); - } else if (node instanceof AnyXmlNode) { - return null; - } - return toLegacySimple(node); - - } - - private static SimpleNode toLegacySimple(final NormalizedNode node) { - return new SimpleNodeTOImpl(node.getNodeType(), null, node.getValue()); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private static CompositeNode toLegacyFromDataContainer(final DataContainerNode node) { - CompositeNodeBuilder builder = ImmutableCompositeNode.builder(); - builder.setQName(node.getNodeType()); - for (NormalizedNode child : node.getValue()) { - if (child instanceof MixinNode && child instanceof NormalizedNodeContainer) { - builder.addAll(toLegacyNodesFromMixin((NormalizedNodeContainer) child)); - } else if (child instanceof UnkeyedListNode) { - builder.addAll(toLegacyNodesFromUnkeyedList((UnkeyedListNode) child)); - } else { - addToBuilder(builder, toLegacy(child)); - } - } - return builder.toInstance(); - } - - private static Iterable> toLegacyNodesFromUnkeyedList(final UnkeyedListNode mixin) { - ArrayList> ret = new ArrayList<>(); - for (NormalizedNode child : mixin.getValue()) { - ret.add(toLegacy(child)); - } - return FluentIterable.from(ret).filter(Predicates.notNull()); - } - - private static void addToBuilder(final CompositeNodeBuilder builder, final Node legacy) { - if (legacy != null) { - builder.add(legacy); - } - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private static Iterable> toLegacyNodesFromMixin( - final NormalizedNodeContainer> mixin) { - ArrayList> ret = new ArrayList<>(); - for (NormalizedNode child : mixin.getValue()) { - if (child instanceof MixinNode && child instanceof NormalizedNodeContainer) { - Iterables.addAll(ret, toLegacyNodesFromMixin((NormalizedNodeContainer) child)); - } else { - ret.add(toLegacy(child)); - } - } - return FluentIterable.from(ret).filter(Predicates.notNull()); - } - public DataNormalizationOperation getRootOperation() { return operation; } diff --git a/opendaylight/md-sal/sal-common-impl/src/test/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizerTest.java b/opendaylight/md-sal/sal-common-impl/src/test/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizerTest.java deleted file mode 100644 index 88a2839e5c..0000000000 --- a/opendaylight/md-sal/sal-common-impl/src/test/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizerTest.java +++ /dev/null @@ -1,832 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications 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.md.sal.common.impl.util.compat; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; -import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; -import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; -import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; -import org.opendaylight.yangtools.yang.data.impl.NodeFactory; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; - -@Deprecated -public class DataNormalizerTest { - - static class NormalizedNodeData { - PathArgument nodeID; - Class nodeClass; - Object nodeData; // List for a container, value Object for a leaf - - NormalizedNodeData(final PathArgument nodeID, final Class nodeClass, final Object nodeData) { - this.nodeID = nodeID; - this.nodeClass = nodeClass; - this.nodeData = nodeData; - } - } - - static class LegacyNodeData { - QName nodeKey; - Object nodeData; // List for a CompositeNode, value Object for a - // SimpeNode - - LegacyNodeData(final QName nodeKey, final Object nodeData) { - this.nodeKey = nodeKey; - this.nodeData = nodeData; - } - - @Override - public String toString() { - return nodeKey.toString(); - } - } - - static final QName TEST_QNAME = QName.create( - "urn:opendaylight:params:xml:ns:yang:controller:md:sal:normalization:test", "2014-03-13", "test"); - static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list"); - static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list"); - static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice"); - static final QName ID_QNAME = QName.create(TEST_QNAME, "id"); - static final QName NAME_QNAME = QName.create(TEST_QNAME, "name"); - static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); - - static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME); - static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME) - .build(); - static final QName ONE_QNAME = QName.create(TEST_QNAME, "one"); - static final QName TWO_QNAME = QName.create(TEST_QNAME, "two"); - static final QName THREE_QNAME = QName.create(TEST_QNAME, "three"); - - static final QName ANY_XML_DATA_QNAME = QName.create(TEST_QNAME, "any-xml-data"); - static final QName OUTER_CONTAINER_QNAME = QName.create(TEST_QNAME, "outer-container"); - static final QName AUGMENTED_LEAF_QNAME = QName.create(TEST_QNAME, "augmented-leaf"); - static final QName UNKEYED_LIST_QNAME = QName.create(TEST_QNAME, "unkeyed-list"); - static final QName UNORDERED_LEAF_LIST_QNAME = QName.create(TEST_QNAME, "unordered-leaf-list"); - static final QName ORDERED_LEAF_LIST_QNAME = QName.create(TEST_QNAME, "ordered-leaf-list"); - - static final Short OUTER_LIST_ID = (short) 10; - - static final YangInstanceIdentifier OUTER_LIST_PATH_LEGACY = YangInstanceIdentifier.builder(TEST_PATH) - .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, OUTER_LIST_ID).build(); - - static final YangInstanceIdentifier LEAF_TWO_PATH_LEGACY = YangInstanceIdentifier.builder(OUTER_LIST_PATH_LEGACY) - .node(TWO_QNAME).build(); - - static final QName ANY_XML_LEAF_QNAME = QName.create(TEST_QNAME, "leaf");; - static final QName ANY_XML_INNER_QNAME = QName.create(TEST_QNAME, "inner"); - static final QName ANY_XML_INNER_LEAF_QNAME = QName.create(TEST_QNAME, "inner-leaf"); - - SchemaContext createTestContext() { - YangParserImpl parser = new YangParserImpl(); - Set modules = parser.parseYangModelsFromStreams(Collections.singletonList(DataNormalizerTest.class - .getResourceAsStream("/normalization-test.yang"))); - return parser.resolveSchemaContext(modules); - } - - @Test - public void testToNormalizedInstanceIdentifier() { - SchemaContext testCtx = createTestContext(); - DataNormalizer normalizer = new DataNormalizer(testCtx); - - YangInstanceIdentifier normalizedPath = normalizer.toNormalized(LEAF_TWO_PATH_LEGACY); - - verifyNormalizedInstanceIdentifier(normalizedPath, TEST_QNAME, OUTER_LIST_QNAME, new Object[] { - OUTER_LIST_QNAME, ID_QNAME, OUTER_LIST_ID }, OUTER_CHOICE_QNAME, TWO_QNAME); - } - - private void verifyNormalizedInstanceIdentifier(final YangInstanceIdentifier actual, final Object... expPath) { - - assertNotNull("Actual InstanceIdentifier is null", actual); - assertEquals("InstanceIdentifier path length", expPath.length, Iterables.size(actual.getPathArguments())); - - for (int i = 0; i < expPath.length; i++) { - PathArgument actualArg = Iterables.get(actual.getPathArguments(), i); - if (expPath[i] instanceof Object[]) { // NodeIdentifierWithPredicates - Object[] exp = (Object[]) expPath[i]; - assertEquals("Actual path arg " + (i + 1) + " class", NodeIdentifierWithPredicates.class, - actualArg.getClass()); - NodeIdentifierWithPredicates actualNode = (NodeIdentifierWithPredicates) actualArg; - assertEquals("Actual path arg " + (i + 1) + " node type", exp[0], actualNode.getNodeType()); - assertEquals("Actual path arg " + (i + 1) + " key values map size", 1, actualNode.getKeyValues().size()); - Entry keyValuesEntry = actualNode.getKeyValues().entrySet().iterator().next(); - assertEquals("Actual path arg " + (i + 1) + " key values map key", exp[1], keyValuesEntry.getKey()); - assertEquals("Actual path arg " + (i + 1) + " key values map value", exp[2], keyValuesEntry.getValue()); - } else if (expPath[i] instanceof Set) { // AugmentationIdentifier - assertEquals("Actual path arg " + (i + 1) + " class", AugmentationIdentifier.class, - actualArg.getClass()); - AugmentationIdentifier actualNode = (AugmentationIdentifier) actualArg; - assertEquals("Actual path arg " + (i + 1) + " PossibleChildNames", expPath[i], - actualNode.getPossibleChildNames()); - } else { - assertEquals("Actual path arg " + (i + 1) + " node type", expPath[i], actualArg.getNodeType()); - } - } - } - - @Test - public void testToLegacyInstanceIdentifier() throws DataNormalizationException { - - DataNormalizer normalizer = new DataNormalizer(createTestContext()); - - YangInstanceIdentifier normalized = YangInstanceIdentifier.builder().node(TEST_QNAME).node(OUTER_LIST_QNAME) - .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, OUTER_LIST_ID).node(OUTER_CHOICE_QNAME).node(TWO_QNAME) - .build(); - - YangInstanceIdentifier legacy = normalizer.toLegacy(normalized); - - assertEquals("Legacy InstanceIdentifier", LEAF_TWO_PATH_LEGACY, legacy); - } - - @Test - public void testToLegacyNormalizedNode() { - - ChoiceNode choiceNode1 = Builders.choiceBuilder().withNodeIdentifier(new NodeIdentifier(OUTER_CHOICE_QNAME)) - .withChild(ImmutableNodes.leafNode(TWO_QNAME, "two")) - .withChild(ImmutableNodes.leafNode(THREE_QNAME, "three")).build(); - - MapEntryNode innerListEntryNode1 = Builders.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(INNER_LIST_QNAME, NAME_QNAME, "inner-name1")) - .withChild(ImmutableNodes.leafNode(NAME_QNAME, "inner-name1")) - .withChild(ImmutableNodes.leafNode(VALUE_QNAME, "inner-value1")).build(); - - MapEntryNode innerListEntryNode2 = Builders.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(INNER_LIST_QNAME, NAME_QNAME, "inner-name2")) - .withChild(ImmutableNodes.leafNode(NAME_QNAME, "inner-name2")) - .withChild(ImmutableNodes.leafNode(VALUE_QNAME, "inner-value2")).build(); - - OrderedMapNode innerListNode = Builders.orderedMapBuilder() - .withNodeIdentifier(new NodeIdentifier(INNER_LIST_QNAME)).withChild(innerListEntryNode1) - .withChild(innerListEntryNode2).build(); - - Short outerListID1 = Short.valueOf((short) 10); - MapEntryNode outerListEntryNode1 = Builders.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(OUTER_LIST_QNAME, ID_QNAME, outerListID1)) - .withChild(ImmutableNodes.leafNode(ID_QNAME, outerListID1)).withChild(choiceNode1) - .withChild(innerListNode).build(); - - ChoiceNode choiceNode2 = Builders.choiceBuilder().withNodeIdentifier(new NodeIdentifier(OUTER_CHOICE_QNAME)) - .withChild(ImmutableNodes.leafNode(ONE_QNAME, "one")).build(); - - Short outerListID2 = Short.valueOf((short) 20); - MapEntryNode outerListEntryNode2 = Builders.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(OUTER_LIST_QNAME, ID_QNAME, outerListID2)) - .withChild(ImmutableNodes.leafNode(ID_QNAME, outerListID2)).withChild(choiceNode2).build(); - - MapNode outerListNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(OUTER_LIST_QNAME)) - .withChild(outerListEntryNode1).withChild(outerListEntryNode2).build(); - - UnkeyedListEntryNode unkeyedListEntryNode1 = Builders.unkeyedListEntryBuilder() - .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)) - .withChild(ImmutableNodes.leafNode(NAME_QNAME, "unkeyed1")).build(); - - UnkeyedListEntryNode unkeyedListEntryNode2 = Builders.unkeyedListEntryBuilder() - .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)) - .withChild(ImmutableNodes.leafNode(NAME_QNAME, "unkeyed2")).build(); - - UnkeyedListNode unkeyedListNode = Builders.unkeyedListBuilder() - .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)).withChild(unkeyedListEntryNode1) - .withChild(unkeyedListEntryNode2).build(); - - ContainerNode testContainerNode = Builders.containerBuilder() - .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)).withChild(outerListNode).withChild(unkeyedListNode) - .build(); - - Node legacyNode = DataNormalizer.toLegacy(testContainerNode); - - verifyLegacyNode( - legacyNode, - expectCompositeNode( - TEST_QNAME, - expectCompositeNode( - OUTER_LIST_QNAME, - expectSimpleNode(ID_QNAME, outerListID1), - expectSimpleNode(TWO_QNAME, "two"), - expectSimpleNode(THREE_QNAME, "three"), - - expectCompositeNode(INNER_LIST_QNAME, expectSimpleNode(NAME_QNAME, "inner-name1"), - expectSimpleNode(VALUE_QNAME, "inner-value1")), - - expectCompositeNode(INNER_LIST_QNAME, expectSimpleNode(NAME_QNAME, "inner-name2"), - expectSimpleNode(VALUE_QNAME, "inner-value2"))), - expectCompositeNode(OUTER_LIST_QNAME, expectSimpleNode(ID_QNAME, outerListID2), - expectSimpleNode(ONE_QNAME, "one")), - expectCompositeNode(UNKEYED_LIST_QNAME, expectSimpleNode(NAME_QNAME, "unkeyed1")), - expectCompositeNode(UNKEYED_LIST_QNAME, expectSimpleNode(NAME_QNAME, "unkeyed2")))); - - // Conversion of Mixin type nodes is not supported. - - assertNull("Expected null returned for Mixin type node", DataNormalizer.toLegacy(outerListNode)); - } - - /** - * Following data are constructed: - * inner-leaf-value - * leaf-value - */ - @Ignore - @Test - public void testToLegacyNormalizedNodeWithAnyXml() { - - Node innerLeafChild = NodeFactory.createImmutableSimpleNode(ANY_XML_INNER_LEAF_QNAME, null, - "inner-leaf-value"); - CompositeNode innerContainer = NodeFactory.createImmutableCompositeNode(ANY_XML_INNER_QNAME, null, - Collections.> singletonList(innerLeafChild)); - - Node leafChild = NodeFactory.createImmutableSimpleNode(ANY_XML_LEAF_QNAME, null, "leaf-value"); - CompositeNode anyXmlNodeValue = NodeFactory.createImmutableCompositeNode(ANY_XML_DATA_QNAME, null, - Arrays.asList(leafChild, innerContainer)); - - AnyXmlNode testAnyXmlNode = Builders.anyXmlBuilder().withNodeIdentifier(new NodeIdentifier(TEST_QNAME)).build(); - - ContainerNode testContainerNode = Builders.containerBuilder() - .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)).withChild(testAnyXmlNode).build(); - - DataNormalizer normalizer = new DataNormalizer(createTestContext()); - Node legacyNode = normalizer.toLegacy(YangInstanceIdentifier.builder().node(TEST_QNAME).build(), testContainerNode); - - verifyLegacyNode( - legacyNode, - expectCompositeNode( - TEST_QNAME, - expectCompositeNode( - ANY_XML_DATA_QNAME, - expectSimpleNode(ANY_XML_LEAF_QNAME, "leaf-value"), - expectCompositeNode(ANY_XML_INNER_QNAME, - expectSimpleNode(ANY_XML_INNER_LEAF_QNAME, "inner-leaf-value"))))); - } - - @Test - public void testToLegacyNormalizedNodeWithLeafLists() { - - CompositeNodeBuilder testBuilder = ImmutableCompositeNode.builder(); - testBuilder.setQName(TEST_QNAME); - - ListNodeBuilder> leafSetBuilder = Builders.leafSetBuilder() - .withNodeIdentifier(new NodeIdentifier(UNORDERED_LEAF_LIST_QNAME)); - for (int i = 1; i <= 3; i++) { - leafSetBuilder.withChildValue("unordered-value" + i); - } - - ListNodeBuilder> orderedLeafSetBuilder = Builders.orderedLeafSetBuilder() - .withNodeIdentifier(new NodeIdentifier(ORDERED_LEAF_LIST_QNAME)); - for (int i = 3; i > 0; i--) { - orderedLeafSetBuilder.withChildValue("ordered-value" + i); - } - - ContainerNode testContainerNode = Builders.containerBuilder() - .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)).withChild(leafSetBuilder.build()) - .withChild(orderedLeafSetBuilder.build()).build(); - - DataNormalizer normalizer = new DataNormalizer(createTestContext()); - - Node legacyNode = normalizer.toLegacy(YangInstanceIdentifier.builder().node(TEST_QNAME).build(), testContainerNode); - - verifyLegacyNode( - legacyNode, - expectCompositeNode(TEST_QNAME, expectSimpleNode(UNORDERED_LEAF_LIST_QNAME, "unordered-value1"), - expectSimpleNode(UNORDERED_LEAF_LIST_QNAME, "unordered-value2"), - expectSimpleNode(UNORDERED_LEAF_LIST_QNAME, "unordered-value3"), - expectSimpleNode(ORDERED_LEAF_LIST_QNAME, "ordered-value3"), - expectSimpleNode(ORDERED_LEAF_LIST_QNAME, "ordered-value2"), - expectSimpleNode(ORDERED_LEAF_LIST_QNAME, "ordered-value1"))); - } - - @Test - public void testToLegacyNormalizedNodeWithAugmentation() { - - AugmentationNode augmentationNode = Builders.augmentationBuilder() - .withNodeIdentifier(new AugmentationIdentifier(Sets.newHashSet(AUGMENTED_LEAF_QNAME))) - .withChild(ImmutableNodes.leafNode(AUGMENTED_LEAF_QNAME, "augmented-value")).build(); - - ContainerNode outerContainerNode = Builders.containerBuilder() - .withNodeIdentifier(new NodeIdentifier(OUTER_CONTAINER_QNAME)).withChild(augmentationNode).build(); - - ContainerNode testContainerNode = Builders.containerBuilder() - .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)).withChild(outerContainerNode).build(); - - DataNormalizer normalizer = new DataNormalizer(createTestContext()); - - Node legacyNode = normalizer.toLegacy(YangInstanceIdentifier.builder().node(TEST_QNAME).build(), testContainerNode); - - verifyLegacyNode( - legacyNode, - expectCompositeNode( - TEST_QNAME, - expectCompositeNode(OUTER_CONTAINER_QNAME, - expectSimpleNode(AUGMENTED_LEAF_QNAME, "augmented-value")))); - } - - private boolean isOrdered(final QName nodeName) { - return ORDERED_LEAF_LIST_QNAME.equals(nodeName) || INNER_LIST_QNAME.equals(nodeName); - } - - @SuppressWarnings("unchecked") - private void verifyLegacyNode(final Node actual, final LegacyNodeData expNodeData) { - - assertNotNull("Actual Node is null", actual); - assertTrue("Expected CompositeNode instance", actual instanceof CompositeNode); - CompositeNode actualCN = (CompositeNode) actual; - assertEquals("Node key", expNodeData.nodeKey, actualCN.getKey()); - - List expChildData = Lists.newArrayList(); - List unorderdChildData = Lists.newArrayList(); - for (LegacyNodeData data : (List) expNodeData.nodeData) { - if (isOrdered(data.nodeKey)) { - expChildData.add(data); - } else { - unorderdChildData.add(data); - } - } - - Collections.sort(unorderdChildData, new Comparator() { - @Override - public int compare(final LegacyNodeData arg1, final LegacyNodeData arg2) { - if (!(arg1.nodeData instanceof List) && !(arg2.nodeData instanceof List)) { - // if neither is a list, just compare them - String str1 = arg1.nodeKey.getLocalName() + arg1.nodeData; - String str2 = arg2.nodeKey.getLocalName() + arg2.nodeData; - return str1.compareTo(str2); - } else if (arg1.nodeData instanceof List && arg2.nodeData instanceof List) { - // if both are lists, first check their local name - String str1 = arg1.nodeKey.getLocalName(); - String str2 = arg2.nodeKey.getLocalName(); - if (!str1.equals(str2)) { - return str1.compareTo(str2); - } else { - // if local names are the same, then look at the list contents - List l1 = (List) arg1.nodeData; - List l2 = (List) arg2.nodeData; - - if (l1.size() != l2.size()) { - // if the sizes are different, use that - return l2.size() - l1.size(); - } else { - // lastly sort and recursively check the list contents - Collections.sort(l1, this); - Collections.sort(l2, this); - - for (int i = 0 ; i < l1.size() ; i++) { - int diff = this.compare(l1.get(i), l2.get(i)); - if (diff != 0) { - return diff; - } - } - return 0; - } - } - } else if( arg1.nodeData instanceof List ) { - return -1; - } else{ - return 1; - } - } - }); - - expChildData.addAll(unorderdChildData); - - List> actualChildNodes = Lists.newArrayList(); - List> unorderedChildNodes = Lists.newArrayList(); - for (Node node : actualCN.getValue()) { - if (isOrdered(node.getKey())) { - actualChildNodes.add(node); - } else { - unorderedChildNodes.add(node); - } - } - - Collections.sort(unorderedChildNodes, new Comparator>() { - @Override - public int compare(final Node n1, final Node n2) { - if (n1 instanceof SimpleNode && n2 instanceof SimpleNode) { - // if they're SimpleNodes just compare their strings - String str1 = n1.getKey().getLocalName() + ((SimpleNode)n1).getValue(); - String str2 = n2.getKey().getLocalName() + ((SimpleNode)n2).getValue(); - return str1.compareTo(str2); - } else if (n1 instanceof CompositeNode && n2 instanceof CompositeNode) { - // if they're CompositeNodes, things are more interesting - String str1 = n1.getKey().getLocalName(); - String str2 = n2.getKey().getLocalName(); - if (!str1.equals(str2)) { - // if their local names differ, return that difference - return str1.compareTo(str2); - } else { - // otherwise, we need to look at their contents - ArrayList> l1 = new ArrayList>( ((CompositeNode)n1).getValue() ); - ArrayList> l2 = new ArrayList>( ((CompositeNode)n2).getValue() ); - - if (l1.size() != l2.size()) { - // if they have different numbers of things in them return that - return l2.size() - l1.size(); - } else { - // otherwise, compare the individual elements, first sort them - Collections.sort(l1, this); - Collections.sort(l2, this); - - // then compare them individually - for(int i = 0 ; i < l2.size() ; i++) { - int diff = this.compare(l1.get(i), l2.get(i)); - if(diff != 0){ - return diff; - } - } - return 0; - } - } - } else if (n1 instanceof CompositeNode && n2 instanceof SimpleNode) { - return -1; - } else if (n2 instanceof CompositeNode && n1 instanceof SimpleNode) { - return 1; - } else { - assertTrue("Expected either SimpleNodes CompositeNodes", false); - return 0; - } - } - }); - - actualChildNodes.addAll(unorderedChildNodes); - - for (Node actualChild : actualChildNodes) { - LegacyNodeData expData = expChildData.isEmpty() ? null : expChildData.remove(0); - assertNotNull("Unexpected child node with key " + actualChild.getKey(), expData); - assertEquals("Child node QName", expData.nodeKey, actualChild.getKey()); - - if (expData.nodeData instanceof List) { // List represents a - // composite node - verifyLegacyNode(actualChild, expData); - } else { // else a simple node - assertTrue("Expected SimpleNode instance", actualChild instanceof SimpleNode); - assertEquals("Child node value with key " + actualChild.getKey(), expData.nodeData, - ((SimpleNode) actualChild).getValue()); - } - } - - if (!expChildData.isEmpty()) { - fail("Missing child nodes: " + expChildData); - } - } - - private LegacyNodeData expectCompositeNode(final QName key, final LegacyNodeData... childData) { - return new LegacyNodeData(key, Lists.newArrayList(childData)); - } - - private LegacyNodeData expectSimpleNode(final QName key, final Object value) { - return new LegacyNodeData(key, value); - } - - @Test - public void testToNormalizedCompositeNode() { - SchemaContext testCtx = createTestContext(); - DataNormalizer normalizer = new DataNormalizer(testCtx); - - CompositeNodeBuilder testBuilder = ImmutableCompositeNode.builder(); - testBuilder.setQName(TEST_QNAME); - - CompositeNodeBuilder outerListBuilder = ImmutableCompositeNode.builder(); - outerListBuilder.setQName(OUTER_LIST_QNAME); - outerListBuilder.addLeaf(ID_QNAME, 10); - outerListBuilder.addLeaf(ONE_QNAME, "one"); - - for (int i = 3; i > 0; i--) { - CompositeNodeBuilder innerListBuilder = ImmutableCompositeNode.builder(); - innerListBuilder.setQName(INNER_LIST_QNAME); - innerListBuilder.addLeaf(NAME_QNAME, "inner-name" + i); - innerListBuilder.addLeaf(VALUE_QNAME, "inner-value" + i); - outerListBuilder.add(innerListBuilder.toInstance()); - } - - testBuilder.add(outerListBuilder.toInstance()); - - outerListBuilder = ImmutableCompositeNode.builder(); - outerListBuilder.setQName(OUTER_LIST_QNAME); - outerListBuilder.addLeaf(ID_QNAME, 20); - outerListBuilder.addLeaf(TWO_QNAME, "two"); - outerListBuilder.addLeaf(THREE_QNAME, "three"); - testBuilder.add(outerListBuilder.toInstance()); - - for (int i = 1; i <= 2; i++) { - CompositeNodeBuilder unkeyedListBuilder = ImmutableCompositeNode.builder(); - unkeyedListBuilder.setQName(UNKEYED_LIST_QNAME); - unkeyedListBuilder.addLeaf(NAME_QNAME, "unkeyed-name" + i); - testBuilder.add(unkeyedListBuilder.toInstance()); - } - - Entry> normalizedNodeEntry = normalizer - .toNormalized(new AbstractMap.SimpleEntry(YangInstanceIdentifier.create( - ImmutableList. of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance())); - - verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME); - - verifyNormalizedNode( - normalizedNodeEntry.getValue(), - expectContainerNode( - TEST_QNAME, - expectMapNode( - OUTER_LIST_QNAME, - expectMapEntryNode( - OUTER_LIST_QNAME, - ID_QNAME, - 10, - expectLeafNode(ID_QNAME, 10), - expectChoiceNode(OUTER_CHOICE_QNAME, expectLeafNode(ONE_QNAME, "one")), - expectOrderedMapNode( - INNER_LIST_QNAME, - expectMapEntryNode(INNER_LIST_QNAME, NAME_QNAME, "inner-name3", - expectLeafNode(NAME_QNAME, "inner-name3"), - expectLeafNode(VALUE_QNAME, "inner-value3")), - expectMapEntryNode(INNER_LIST_QNAME, NAME_QNAME, "inner-name2", - expectLeafNode(NAME_QNAME, "inner-name2"), - expectLeafNode(VALUE_QNAME, "inner-value2")), - expectMapEntryNode(INNER_LIST_QNAME, NAME_QNAME, "inner-name1", - expectLeafNode(NAME_QNAME, "inner-name1"), - expectLeafNode(VALUE_QNAME, "inner-value1")))), - expectMapEntryNode( - OUTER_LIST_QNAME, - ID_QNAME, - 20, - expectLeafNode(ID_QNAME, 20), - expectChoiceNode(OUTER_CHOICE_QNAME, expectLeafNode(TWO_QNAME, "two"), - expectLeafNode(THREE_QNAME, "three")))), - expectUnkeyedListNode( - UNKEYED_LIST_QNAME, - expectUnkeyedListEntryNode(UNKEYED_LIST_QNAME, - expectLeafNode(NAME_QNAME, "unkeyed-name1")), - expectUnkeyedListEntryNode(UNKEYED_LIST_QNAME, - expectLeafNode(NAME_QNAME, "unkeyed-name2"))))); - } - - @Ignore - @Test - public void testToNormalizedCompositeNodeWithAnyXml() { - SchemaContext testCtx = createTestContext(); - DataNormalizer normalizer = new DataNormalizer(testCtx); - - CompositeNodeBuilder testBuilder = ImmutableCompositeNode.builder(); - testBuilder.setQName(TEST_QNAME); - - CompositeNodeBuilder anyXmlBuilder = ImmutableCompositeNode.builder(); - anyXmlBuilder.setQName(ANY_XML_DATA_QNAME); - anyXmlBuilder.addLeaf(ANY_XML_LEAF_QNAME, "leaf-value"); - - CompositeNodeBuilder innerBuilder = ImmutableCompositeNode.builder(); - innerBuilder.setQName(ANY_XML_INNER_QNAME); - innerBuilder.addLeaf(ANY_XML_INNER_LEAF_QNAME, "inner-leaf-value"); - - anyXmlBuilder.add(innerBuilder.toInstance()); - CompositeNode anyXmlLegacy = anyXmlBuilder.toInstance(); - testBuilder.add(anyXmlLegacy); - - Entry> normalizedNodeEntry = normalizer - .toNormalized(new AbstractMap.SimpleEntry(YangInstanceIdentifier.create( - ImmutableList. of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance())); - - verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME); - - verifyNormalizedNode(normalizedNodeEntry.getValue(), - expectContainerNode(TEST_QNAME, expectAnyXmlNode(ANY_XML_DATA_QNAME, anyXmlLegacy))); - } - - @Test - public void testToNormalizedCompositeNodeWithAugmentation() { - SchemaContext testCtx = createTestContext(); - DataNormalizer normalizer = new DataNormalizer(testCtx); - - CompositeNodeBuilder testBuilder = ImmutableCompositeNode.builder(); - testBuilder.setQName(TEST_QNAME); - - CompositeNodeBuilder outerContBuilder = ImmutableCompositeNode.builder(); - outerContBuilder.setQName(OUTER_CONTAINER_QNAME); - outerContBuilder.addLeaf(AUGMENTED_LEAF_QNAME, "augmented-value"); - - testBuilder.add(outerContBuilder.toInstance()); - - Entry> normalizedNodeEntry = normalizer - .toNormalized(new AbstractMap.SimpleEntry(YangInstanceIdentifier.create( - ImmutableList. of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance())); - - verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME); - - NormalizedNodeData expAugmentation = expectAugmentation(AUGMENTED_LEAF_QNAME, - expectLeafNode(AUGMENTED_LEAF_QNAME, "augmented-value")); - - verifyNormalizedNode(normalizedNodeEntry.getValue(), - expectContainerNode(TEST_QNAME, expectContainerNode(OUTER_CONTAINER_QNAME, expAugmentation))); - - normalizedNodeEntry = normalizer.toNormalized(new AbstractMap.SimpleEntry( - YangInstanceIdentifier.create(Lists.newArrayList(new NodeIdentifier(TEST_QNAME), new NodeIdentifier( - OUTER_CONTAINER_QNAME))), outerContBuilder.toInstance())); - - } - - @Test - public void testToNormalizedCompositeNodeWithLeafLists() { - SchemaContext testCtx = createTestContext(); - DataNormalizer normalizer = new DataNormalizer(testCtx); - - CompositeNodeBuilder testBuilder = ImmutableCompositeNode.builder(); - testBuilder.setQName(TEST_QNAME); - - for (int i = 1; i <= 3; i++) { - testBuilder.addLeaf(UNORDERED_LEAF_LIST_QNAME, "unordered-value" + i); - } - - for (int i = 3; i > 0; i--) { - testBuilder.addLeaf(ORDERED_LEAF_LIST_QNAME, "ordered-value" + i); - } - - Entry> normalizedNodeEntry = normalizer - .toNormalized(new AbstractMap.SimpleEntry(YangInstanceIdentifier.create( - ImmutableList. of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance())); - - verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME); - - verifyNormalizedNode( - normalizedNodeEntry.getValue(), - expectContainerNode( - TEST_QNAME, - expectLeafSetNode(UNORDERED_LEAF_LIST_QNAME, - expectLeafSetEntryNode(UNORDERED_LEAF_LIST_QNAME, "unordered-value1"), - expectLeafSetEntryNode(UNORDERED_LEAF_LIST_QNAME, "unordered-value2"), - expectLeafSetEntryNode(UNORDERED_LEAF_LIST_QNAME, "unordered-value3")), - expectOrderedLeafSetNode(ORDERED_LEAF_LIST_QNAME, - expectLeafSetEntryNode(ORDERED_LEAF_LIST_QNAME, "ordered-value3"), - expectLeafSetEntryNode(ORDERED_LEAF_LIST_QNAME, "ordered-value2"), - expectLeafSetEntryNode(ORDERED_LEAF_LIST_QNAME, "ordered-value1")))); - } - - @SuppressWarnings("unchecked") - private void verifyNormalizedNode(final NormalizedNode actual, final NormalizedNodeData expNodeData) { - - Class expNodeClass = expNodeData.nodeClass; - PathArgument expNodeID = expNodeData.nodeID; - - assertNotNull("Actual NormalizedNode is null", actual); - assertTrue("NormalizedNode instance " + actual.getClass() + " is not derived from " + expNodeClass, - expNodeClass.isAssignableFrom(actual.getClass())); - assertEquals("NormalizedNode identifier", expNodeID, actual.getIdentifier()); - - if (expNodeData.nodeData instanceof List) { - Map orderingMap = null; - if (expNodeClass.equals(OrderedMapNode.class) || expNodeClass.equals(OrderedLeafSetNode.class)) { - orderingMap = Maps.newHashMap(); - } - - int i = 1; - Map expChildDataMap = Maps.newHashMap(); - List expChildDataList = (List) expNodeData.nodeData; - for (NormalizedNodeData data : expChildDataList) { - expChildDataMap.put(data.nodeID, data); - - if (orderingMap != null) { - orderingMap.put(data.nodeID, i++); - } - } - - assertNotNull("Actual value is null for node " + actual.getIdentifier(), actual.getValue()); - assertTrue("Expected value instance Iterable for node " + actual.getIdentifier(), - Iterable.class.isAssignableFrom(actual.getValue().getClass())); - - i = 1; - for (NormalizedNode actualChild : (Iterable>) actual.getValue()) { - NormalizedNodeData expChildData = expNodeClass.equals(UnkeyedListNode.class) ? expChildDataList - .remove(0) : expChildDataMap.remove(actualChild.getIdentifier()); - - assertNotNull( - "Unexpected child node " + actualChild.getClass() + " with identifier " - + actualChild.getIdentifier() + " for parent node " + actual.getClass() - + " with identifier " + actual.getIdentifier(), expChildData); - - if (orderingMap != null) { - assertEquals("Order index for child node " + actualChild.getIdentifier(), - orderingMap.get(actualChild.getIdentifier()), Integer.valueOf(i)); - } - - verifyNormalizedNode(actualChild, expChildData); - i++; - } - - if (expNodeClass.equals(UnkeyedListNode.class)) { - if (expChildDataList.size() > 0) { - fail("Missing " + expChildDataList.size() + " child nodes for parent " + actual.getIdentifier()); - } - } else { - if (!expChildDataMap.isEmpty()) { - fail("Missing child nodes for parent " + actual.getIdentifier() + ": " + expChildDataMap.keySet()); - } - } - } else { - assertEquals("Leaf value for node " + actual.getIdentifier(), expNodeData.nodeData, actual.getValue()); - } - } - - private NormalizedNodeData expectOrderedLeafSetNode(final QName nodeName, final NormalizedNodeData... childData) { - return new NormalizedNodeData(new NodeIdentifier(nodeName), OrderedLeafSetNode.class, - Lists.newArrayList(childData)); - } - - private NormalizedNodeData expectLeafSetNode(final QName nodeName, final NormalizedNodeData... childData) { - return new NormalizedNodeData(new NodeIdentifier(nodeName), LeafSetNode.class, Lists.newArrayList(childData)); - } - - private NormalizedNodeData expectLeafSetEntryNode(final QName nodeName, final Object value) { - return new NormalizedNodeData(new NodeWithValue(nodeName, value), LeafSetEntryNode.class, value); - } - - private NormalizedNodeData expectUnkeyedListNode(final QName nodeName, final NormalizedNodeData... childData) { - return new NormalizedNodeData(new NodeIdentifier(nodeName), UnkeyedListNode.class, - Lists.newArrayList(childData)); - } - - private NormalizedNodeData expectUnkeyedListEntryNode(final QName nodeName, final NormalizedNodeData... childData) { - return new NormalizedNodeData(new NodeIdentifier(nodeName), UnkeyedListEntryNode.class, - Lists.newArrayList(childData)); - } - - private NormalizedNodeData expectAugmentation(final QName augmentedNodeName, final NormalizedNodeData... childData) { - return new NormalizedNodeData(new AugmentationIdentifier(Sets.newHashSet(augmentedNodeName)), - AugmentationNode.class, Lists.newArrayList(childData)); - } - - private NormalizedNodeData expectAnyXmlNode(final QName nodeName, final Object value) { - return new NormalizedNodeData(new NodeIdentifier(nodeName), AnyXmlNode.class, value); - } - - private NormalizedNodeData expectContainerNode(final QName nodeName, final NormalizedNodeData... childData) { - return new NormalizedNodeData(new NodeIdentifier(nodeName), ContainerNode.class, Lists.newArrayList(childData)); - } - - private NormalizedNodeData expectChoiceNode(final QName nodeName, final NormalizedNodeData... childData) { - return new NormalizedNodeData(new NodeIdentifier(nodeName), ChoiceNode.class, Lists.newArrayList(childData)); - } - - private NormalizedNodeData expectLeafNode(final QName nodeName, final Object value) { - return new NormalizedNodeData(new NodeIdentifier(nodeName), LeafNode.class, value); - - } - - private NormalizedNodeData expectMapEntryNode(final QName nodeName, final QName key, final Object value, - final NormalizedNodeData... childData) { - return new NormalizedNodeData(new NodeIdentifierWithPredicates(nodeName, key, value), MapEntryNode.class, - Lists.newArrayList(childData)); - } - - private NormalizedNodeData expectMapNode(final QName key, final NormalizedNodeData... childData) { - return new NormalizedNodeData(new NodeIdentifier(key), MapNode.class, Lists.newArrayList(childData)); - } - - private NormalizedNodeData expectOrderedMapNode(final QName key, final NormalizedNodeData... childData) { - return new NormalizedNodeData(new NodeIdentifier(key), OrderedMapNode.class, Lists.newArrayList(childData)); - } -} diff --git a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java b/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java deleted file mode 100644 index 67fb6622d1..0000000000 --- a/opendaylight/md-sal/sal-connector-api/src/main/java/org/opendaylight/controller/sal/connector/api/Connector.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.connector.api; - -import java.util.Set; - -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -public interface Connector extends RpcImplementation, NotificationListener { - - - - Set getConfigurationPrefixes(); - Set getRuntimePrefixes(); - - void registerListener(ConnectorListener listener); - void unregisterListener(ConnectorListener listener); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java index 203bd40329..500dce3cfa 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java @@ -7,16 +7,6 @@ */ package org.opendaylight.controller.sal.core.api; -import java.util.Set; -import java.util.concurrent.Future; - -import org.opendaylight.controller.md.sal.common.api.routing.RoutedRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.osgi.framework.BundleContext; /** @@ -29,19 +19,6 @@ import org.osgi.framework.BundleContext; * removes direct dependencies between providers and consumers. * * - *

Infrastructure services

Some examples of infrastructure services: - * - *
    - *
  • RPC Invocation - see {@link ConsumerSession#rpc(QName, CompositeNode)}, - * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} and - * {@link RpcImplementation} - *
  • Notification Service - see {@link org.opendaylight.controller.sal.core.api.notify.NotificationService} and - * {@link org.opendaylight.controller.sal.core.api.notify.NotificationPublishService} - *
  • Functionality and Data model - *
  • Data Store access and modification - see {@link org.opendaylight.controller.sal.core.api.data.DataBrokerService} and - * {@link org.opendaylight.controller.sal.core.api.data.DataProviderService} - *
- * * The services are exposed via session. * *

Session-based access

@@ -100,12 +77,6 @@ public interface Broker { * from consumer, using the {@link Provider#getProviderFunctionality()}, and * register that functionality into system and concrete infrastructure * services. - * - *

- * Note that consumer could register additional functionality at later point - * by using service and functionality specific APIs (e.g. - * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} - * *

* The consumer is required to use returned session for all * communication with broker or one of the broker services. The session is @@ -147,18 +118,6 @@ public interface Broker { */ public interface ConsumerSession { - /** - * Sends an RPC to other components registered to the broker. - * - * @see RpcImplementation - * @param rpc - * Name of RPC - * @param input - * Input data to the RPC - * @return Result of the RPC call - */ - Future> rpc(QName rpc, CompositeNode input); - boolean isClosed(); /** @@ -198,33 +157,6 @@ public interface Broker { * */ public interface ProviderSession extends ConsumerSession { - /** - * Registers an implementation of the rpc. - * - *

- * The registered rpc functionality will be available to all other - * consumers and providers registered to the broker, which are aware of - * the {@link QName} assigned to the rpc. - * - *

- * There is no assumption that rpc type is in the set returned by - * invoking {@link RpcImplementation#getSupportedRpcs()}. This allows - * for dynamic rpc implementations. - * - * @param rpcType - * Name of Rpc - * @param implementation - * Provider's Implementation of the RPC functionality - * @throws IllegalArgumentException - * If the name of RPC is invalid - */ - RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation) - throws IllegalArgumentException; - - RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation); - - RoutedRpcRegistration addMountedRpcImplementation(QName rpcType, RpcImplementation implementation); - /** * Closes a session between provider and SAL. * @@ -237,19 +169,5 @@ public interface Broker { @Override boolean isClosed(); - - Set getSupportedRpcs(); - - ListenerRegistration addRpcRegistrationListener(RpcRegistrationListener listener); - } - - public interface RpcRegistration extends ObjectRegistration { - QName getType(); - - @Override - void close(); - } - - public interface RoutedRpcRegistration extends RpcRegistration, RoutedRegistration { } } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RoutedRpcDefaultImplementation.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RoutedRpcDefaultImplementation.java deleted file mode 100644 index 7a7b144fed..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RoutedRpcDefaultImplementation.java +++ /dev/null @@ -1,21 +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.sal.core.api; - -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -import com.google.common.util.concurrent.ListenableFuture; - -public interface RoutedRpcDefaultImplementation { - - ListenableFuture> invokeRpc(QName rpc, YangInstanceIdentifier identifier, CompositeNode input); - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcConsumptionRegistry.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcConsumptionRegistry.java deleted file mode 100644 index 5d086e59a7..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcConsumptionRegistry.java +++ /dev/null @@ -1,32 +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.sal.core.api; - -import java.util.concurrent.Future; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; - -/** - * @deprecated Use {@link org.opendaylight.controller.md.sal.dom.api.DOMRpcService} instead. - */ -@Deprecated -public interface RpcConsumptionRegistry { - /** - * Sends an RPC to other components registered to the broker. - * - * @see RpcImplementation - * @param rpc - * Name of RPC - * @param input - * Input data to the RPC - * @return Result of the RPC call - */ - Future> rpc(QName rpc, CompositeNode input); - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcImplementation.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcImplementation.java deleted file mode 100644 index 5055ad1430..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcImplementation.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api; - -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Set; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; - -/** - * {@link Provider}'s implementation of an RPC. - * - * In order to expose an RPC to other components, the provider MUST register - * a concrete implementation of this interface. - * - * The registration could be done by : - *

    - *
  • returning an instance of implementation in the return value of - * {@link Provider#getProviderFunctionality()} - *
  • passing an instance of implementation and {@link QName} of rpc as - * arguments to the - * {@link org.opendaylight.controller.sal.core.api.Broker.ProviderSession#addRpcImplementation(QName, RpcImplementation)} - *
- * - * The simplified process of the invocation of rpc is following: - * - *
    - *
  1. {@link Consumer} invokes - * {@link org.opendaylight.controller.sal.core.api.Broker.ConsumerSession#rpc(QName, CompositeNode)} - *
  2. {@link Broker} finds registered {@link RpcImplementation}s - *
  3. {@link Broker} invokes - * {@link RpcImplementation#invokeRpc(QName, CompositeNode)} - *
  4. {@link RpcImplementation} processes the data and returns a - * {@link RpcResult} - *
  5. {@link Broker} returns the {@link RpcResult} to {@link Consumer} - *
- * - * @deprecated Use {@link org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation} instead. - */ -@Deprecated -public interface RpcImplementation extends Provider.ProviderFunctionality { - - /** - * A set of rpc types supported by implementation. - * - * The set of rpc {@link QName}s which are supported by this implementation. - * This set is used, when {@link Provider} is registered to the SAL, to - * register and expose the implementation of the returned rpcs. - * - * @return Set of QNames identifying supported RPCs - */ - Set getSupportedRpcs(); - - /** - * Invokes a implementation of specified RPC asynchronously. - * - * @param rpc - * RPC to be invoked - * @param input - * Input data for the RPC. - * - * @throws IllegalArgumentException - *
    - *
  • If rpc is null. - *
  • If input is not null and - * false == rpc.equals(input.getNodeType) - *
- * @return Future promising an RpcResult containing the output of - * the RPC if was executed successfully, the list of errors - * otherwise. - */ - ListenableFuture> invokeRpc(QName rpc, CompositeNode input); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java deleted file mode 100644 index 1caed09437..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcProvisionRegistry.java +++ /dev/null @@ -1,59 +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.sal.core.api; - -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * @deprecated Use {@link org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService} and {@link org.opendaylight.controller.md.sal.dom.api.DOMRpcService} instead. - */ -@Deprecated -public interface RpcProvisionRegistry extends RpcImplementation, BrokerService, RouteChangePublisher, DOMService { - - /** - * Registers an implementation of the rpc. - * - *

- * The registered rpc functionality will be available to all other - * consumers and providers registered to the broker, which are aware of - * the {@link QName} assigned to the rpc. - * - *

- * There is no assumption that rpc type is in the set returned by - * invoking {@link RpcImplementation#getSupportedRpcs()}. This allows - * for dynamic rpc implementations. - * - * @param rpcType - * Name of Rpc - * @param implementation - * Provider's Implementation of the RPC functionality - * @throws IllegalArgumentException - * If the name of RPC is invalid - */ - RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation) - throws IllegalArgumentException; - - ListenerRegistration addRpcRegistrationListener(RpcRegistrationListener listener); - - RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation); - - /** - * Sets this RoutedRpc Implementation as a delegate rpc provider and will be asked to invoke rpc if the - * current provider can't service the rpc request - * - * @param defaultImplementation - * Provider's implementation of RPC functionality - */ - public void setRoutedRpcDefaultDelegate(RoutedRpcDefaultImplementation defaultImplementation); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRegistrationListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRegistrationListener.java deleted file mode 100644 index df20650ac4..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/RpcRegistrationListener.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api; - -import java.util.EventListener; -import org.opendaylight.yangtools.yang.common.QName; - -/** - * @deprecated Use {@link org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener} instead. - */ -@Deprecated -public interface RpcRegistrationListener extends EventListener { - - public void onRpcImplementationAdded(QName name); - - public void onRpcImplementationRemoved(QName name); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java deleted file mode 100644 index 88289b3106..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.data; - -import org.opendaylight.controller.md.sal.common.api.data.DataChangePublisher; -import org.opendaylight.controller.md.sal.common.api.data.DataModificationTransactionFactory; -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - - -/** - * DataBrokerService provides unified access to the data stores available in the - * system. - * - * - * @see DataProviderService - * @deprecated Replaced by {@link org.opendaylight.controller.md.sal.dom.api.DOMDataBroker} - * - */ -@Deprecated -public interface DataBrokerService extends - BrokerService, // - DataReader, // - DataModificationTransactionFactory, // - DataChangePublisher { - - - @Override - public CompositeNode readConfigurationData(YangInstanceIdentifier path); - - @Override - public CompositeNode readOperationalData(YangInstanceIdentifier path); - - @Override - DataModificationTransaction beginTransaction(); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataChangeListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataChangeListener.java deleted file mode 100644 index 47ac2d78af..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataChangeListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.data; - -import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * - * @deprecated Replaced by {@link org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener} - */ -@Deprecated -public interface DataChangeListener - extends - org.opendaylight.controller.md.sal.common.api.data.DataChangeListener { - - @Override - public void onDataChanged(DataChangeEvent change); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataModificationTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataModificationTransaction.java deleted file mode 100644 index dd5755e33c..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataModificationTransaction.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.data; - -import java.util.EventListener; -import java.util.concurrent.Future; - -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.md.sal.common.api.data.DataModification; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * - * @deprecated Replaced by more specific - * {@link org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction} - * , - * {@link org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction} - * or {@link org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction} - * - */ -@Deprecated -public interface DataModificationTransaction extends DataModification { - - /** - * Returns transaction identifier - * - * @return Transaction identifier - */ - @Override - Object getIdentifier(); - - @Override - TransactionStatus getStatus(); - - /** - * Commits transaction to be stored in global data repository. - * - * - * @return Future object which returns RpcResult with TransactionStatus when - * transaction is processed by store. - */ - @Override - Future> commit(); - - ListenerRegistration registerListener(DataTransactionListener listener); - - public interface DataTransactionListener extends EventListener { - void onStatusUpdated(DataModificationTransaction transaction, TransactionStatus status); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java deleted file mode 100644 index 194da91695..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.data; - -import org.opendaylight.controller.md.sal.common.api.data.DataProvisionService; -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.controller.sal.common.DataStoreIdentifier; -import org.opendaylight.controller.sal.core.api.Provider; -import org.opendaylight.yangtools.concepts.Registration; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * - * @deprecated Replaced by {@link org.opendaylight.controller.md.sal.dom.api.DOMDataBroker} - * - */ -@Deprecated -public interface DataProviderService extends - DataBrokerService, // - DataProvisionService - { - - /** - * Adds {@link DataValidator} for specified Data Store - * - * @param store - * Data Store - * @param validator - * Validator - */ - public void addValidator(DataStoreIdentifier store, DataValidator validator); - - /** - * Removes {@link DataValidator} from specified Data Store - * - * @param store - * @param validator - * Validator - */ - public void removeValidator(DataStoreIdentifier store, - DataValidator validator); - - /** - * Adds {@link DataRefresher} for specified data store - * - * @param store - * @param refresher - */ - void addRefresher(DataStoreIdentifier store, DataRefresher refresher); - - /** - * Removes {@link DataRefresher} from specified data store - * - * @param store - * @param refresher - */ - void removeRefresher(DataStoreIdentifier store, DataRefresher refresher); - - - Registration registerConfigurationReader(YangInstanceIdentifier path, DataReader reader); - - Registration registerOperationalReader(YangInstanceIdentifier path, DataReader reader); - - public interface DataRefresher extends Provider.ProviderFunctionality { - - /** - * Fired when some component explicitly requested the data refresh. - * - * The provider which exposed the {@link DataRefresher} should republish - * its provided data by editing the data in all affected data stores. - */ - void refreshData(); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java deleted file mode 100644 index d66d04816b..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java +++ /dev/null @@ -1,32 +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.sal.core.api.data; - -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * - * @deprecated Replaced by org.opendaylight.controller.sal.core.spi.data.DOMStore. - * - */ -@Deprecated -public interface DataStore extends // - DataReader, - DataCommitHandler { - - - Iterable getStoredConfigurationPaths(); - Iterable getStoredOperationalPaths(); - - boolean containsConfigurationPath(YangInstanceIdentifier path); - boolean containsOperationalPath(YangInstanceIdentifier path); - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataValidator.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataValidator.java deleted file mode 100644 index e4e6e2f26d..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataValidator.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.data; - -import java.util.Set; - -import org.opendaylight.controller.sal.common.DataStoreIdentifier; -import org.opendaylight.controller.sal.core.api.Provider; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; - - -/** - * {@link Provider}-supplied Validator of the data. - * - *

- * The registration could be done by : - *

    - *
  • returning an instance of implementation in the return value of - * {@link Provider#getProviderFunctionality()} - *
  • passing an instance of implementation and {@link DataStoreIdentifier} rpc - * as arguments to the - * {@link DataProviderService#addValidator(DataStoreIdentifier, DataValidator)} - *
- * - * @deprecated Replaced by {@link org.opendaylight.controller.md.sal.common.api.data.AsyncConfigurationCommitHandler} - * - **/ -@Deprecated -public interface DataValidator extends Provider.ProviderFunctionality { - - /** - * A set of Data Stores supported by implementation. - * - * The set of {@link DataStoreIdentifier}s which identifies target data - * stores which are supported by this implementation. This set is used, when - * {@link Provider} is registered to the SAL, to register and expose the - * validation functionality to affected data stores. - * - * @return Set of Data Store identifiers - */ - Set getSupportedDataStores(); - - /** - * Performs validation on supplied data. - * - * @param toValidate - * Data to validate - * @return Validation result. The - * {@link RpcResult#isSuccessful()} == true if the data - * passed validation, otherwise contains list of errors. - */ - RpcResult validate(CompositeNode toValidate); - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/package-info.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/package-info.java deleted file mode 100644 index 17911962ff..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.data; \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountInstance.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountInstance.java deleted file mode 100644 index a4343ba5cf..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountInstance.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.mount; - -import org.opendaylight.controller.sal.core.api.data.DataBrokerService; -import org.opendaylight.controller.sal.core.api.notify.NotificationService; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Interface representing a single mount instance and represents a way for - * clients to access underlying data, RPCs and notifications. - */ -@Deprecated -public interface MountInstance extends // - NotificationService, // - DataBrokerService { - - /** - * Invoke an RPC on the system underlying the mount instance. - * - * @param type RPC type - * @param input RPC input arguments - * @return Future representing execution of the RPC. - */ - ListenableFuture> rpc(QName type, CompositeNode input); - - /** - * Get {@link SchemaContext} of the system underlying the mount instance. - * - * @return A schema context. - */ - SchemaContext getSchemaContext(); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionInstance.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionInstance.java deleted file mode 100644 index a5c3b5d0f6..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionInstance.java +++ /dev/null @@ -1,24 +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.sal.core.api.mount; - -import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.opendaylight.controller.sal.core.api.data.DataProviderService; -import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -@Deprecated -public interface MountProvisionInstance extends // - MountInstance,// - NotificationPublishService, // - RpcProvisionRegistry,// - DataProviderService { - - void setSchemaContext(SchemaContext optional); - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionService.java deleted file mode 100644 index 37c30b6784..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountProvisionService.java +++ /dev/null @@ -1,28 +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.sal.core.api.mount; - -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * @deprecated Use org.opendaylight.controller.md.sal.dom.api.DOMMountPointService instead - */ -@Deprecated -public interface MountProvisionService extends MountService { - - @Override - public MountProvisionInstance getMountPoint(YangInstanceIdentifier path); - - MountProvisionInstance createMountPoint(YangInstanceIdentifier path); - - MountProvisionInstance createOrGetMountPoint(YangInstanceIdentifier path); - - ListenerRegistration registerProvisionListener(MountProvisionListener listener); - -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountService.java deleted file mode 100644 index 55b74c63d3..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.mount; - -import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -/** - * Client-level interface for interacting with mount points. It provides access - * to {@link MountInstance} instances based on their path. - * - * @deprecated Use org.opendaylight.controller.md.sal.dom.api.DOMMountPointService instead - */ -@Deprecated -public interface MountService extends BrokerService { - /** - * Obtain access to a mount instance registered at the specified path. - * - * @param path Path at which the instance is registered - * @return Reference to the instance, or null if no such instance exists. - */ - MountInstance getMountPoint(YangInstanceIdentifier path); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java deleted file mode 100644 index 7dc8cb36c5..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.notify; - -import java.util.EventListener; -import java.util.Set; - -import org.opendaylight.controller.sal.core.api.Consumer; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; - - -/** - * Notification listener for SAL notifications. - */ -public interface NotificationListener extends Consumer.ConsumerFunctionality, EventListener { - /** - * A set of notification types supported by listeners. - * - * The set of notification {@link QName}s which are supported by this - * listener. This set is used, when {@link Consumer} is registered to the - * SAL, to automatically register the listener. - * - * @return Set of QNames identifying supported notifications. - */ - Set getSupportedNotifications(); - - /** - * Fired when the notification occurs. - * - * The type of the notification could be learned by - * QName type = notification.getNodeType(); - * - * @param notification - * Notification content - */ - void onNotification(CompositeNode notification); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationPublishService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationPublishService.java deleted file mode 100644 index 4f5c7abf5f..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationPublishService.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.notify; - -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; - -/** - * Notification Publishing Service - * - * The simplified process of the notification publishing is following: - * - *
    - *
  1. {@link org.opendaylight.controller.sal.core.api.Provider} invokes {@link #sendNotification(CompositeNode)} - *
  2. {@link org.opendaylight.controller.sal.core.api.Broker} finds {@link NotificationListener}s which subscribed for - * the notification type. - * - *
  3. For each subscriber {@link org.opendaylight.controller.sal.core.api.Broker} invokes - * {@link NotificationListener#onNotification(CompositeNode)} - *
- */ -public interface NotificationPublishService extends NotificationService, DOMService { - /** - * Publishes a notification. - * - * Notification type is determined by the - * {@link CompositeNode#getNodeType()} of the - * notification parameter. - * - * @param notification - * Notification to publish - */ - void publish(CompositeNode notification); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java deleted file mode 100644 index 9c0db42d6c..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.core.api.notify; - -import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; - - -/** - * NotificationService provides access to the notification functionality of the - * SAL. - * - * NotificationService allows for consumption of notifications by registering - * implementations of NotificationListener. - * - * The registration of notification listeners could be done by: - *
    - *
  • returning an instance of implementation in the return value of - * {@link org.opendaylight.controller.sal.core.api.Provider#getProviderFunctionality()} - *
  • passing an instance of implementation and {@link QName} of an RPC as an - * argument to - * {@link org.opendaylight.controller.sal.core.api.Broker.ProviderSession#addRpcImplementation(QName, org.opendaylight.controller.sal.core.api.RpcImplementation)} - *
- * - * - */ -public interface NotificationService extends BrokerService { - - /** - * Registers a notification listener for supplied notification type. - * - * @param notification - * @param listener - */ - ListenerRegistration addNotificationListener(QName notification, - NotificationListener listener); -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/package-info.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/package-info.java deleted file mode 100644 index 61426a3fd8..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2013 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 - */ -/** - * SAL Notification functionality - */ -package org.opendaylight.controller.sal.core.api.notify; \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-common.yang b/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-common.yang index d963da1fc7..b7a0bc0b99 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-common.yang +++ b/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-common.yang @@ -37,7 +37,7 @@ module opendaylight-md-sal-common { } } } - + grouping rpc-state { list rpc-router { uses rpc-router; diff --git a/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-dom.yang b/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-dom.yang index 8194dee0f3..a926cc684d 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-dom.yang +++ b/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-dom.yang @@ -18,21 +18,11 @@ module opendaylight-md-sal-dom { config:java-class "org.opendaylight.controller.sal.core.api.Broker"; } - identity dom-data-broker { - base "config:service-type"; - config:java-class "org.opendaylight.controller.sal.core.api.data.DataProviderService"; - } - identity dom-async-data-broker { base "config:service-type"; config:java-class "org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"; } - identity dom-data-store { - base "config:service-type"; - config:java-class "org.opendaylight.controller.sal.core.api.data.DataStore"; - } - identity schema-service { base "config:service-type"; config:java-class "org.opendaylight.controller.sal.core.api.model.SchemaService"; diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java index 6e86795ea0..35c22a1bee 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java @@ -17,20 +17,11 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter; import org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter; -import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker; import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl; import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.opendaylight.controller.sal.core.api.data.DataBrokerService; -import org.opendaylight.controller.sal.core.api.data.DataProviderService; import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; -import org.opendaylight.controller.sal.core.api.mount.MountService; -import org.opendaylight.controller.sal.dom.broker.BackwardsCompatibleMountPointManager; import org.opendaylight.controller.sal.dom.broker.BrokerImpl; import org.opendaylight.controller.sal.dom.broker.GlobalBundleScanningSchemaServiceImpl; -import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker; -import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProviders; /** * @@ -66,14 +57,8 @@ public final class DomBrokerImplModule extends org.opendaylight.controller.confi final SchemaService schemaService = getSchemaServiceImpl(); services.putInstance(SchemaService.class, schemaService); - final SchemaAwareRpcBroker router = new SchemaAwareRpcBroker("/", SchemaContextProviders - .fromSchemaService(schemaService)); - services.putInstance(RpcProvisionRegistry.class, router); services.putInstance(DOMDataBroker.class, asyncBroker); - final DataProviderService legacyData = new BackwardsCompatibleDataBroker(asyncBroker,schemaService); - services.putInstance(DataProviderService.class,legacyData); - services.putInstance(DataBrokerService.class, legacyData); final DOMRpcRouter rpcRouter = new DOMRpcRouter(); schemaService.registerSchemaContextListener(rpcRouter); @@ -83,12 +68,7 @@ public final class DomBrokerImplModule extends org.opendaylight.controller.confi final DOMMountPointService mountService = new DOMMountPointServiceImpl(); services.putInstance(DOMMountPointService.class, mountService); - // TODO remove backwards service, use only new DOMMountPointService - final MountProvisionService backwardsMountService = new BackwardsCompatibleMountPointManager(mountService); - services.putInstance(MountService.class, backwardsMountService); - services.putInstance(MountProvisionService.class, backwardsMountService); - - return new BrokerImpl(router, services); + return new BrokerImpl(rpcRouter, services); } private SchemaService getSchemaServiceImpl() { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/statistics/DomBrokerRuntimeMXBeanImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/statistics/DomBrokerRuntimeMXBeanImpl.java deleted file mode 100644 index 666378ddb3..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/statistics/DomBrokerRuntimeMXBeanImpl.java +++ /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.md.sal.dom.statistics; - -import org.opendaylight.controller.config.yang.md.sal.dom.impl.Data; -import org.opendaylight.controller.config.yang.md.sal.dom.impl.DomBrokerImplRuntimeMXBean; -import org.opendaylight.controller.config.yang.md.sal.dom.impl.Transactions; -import org.opendaylight.controller.sal.dom.broker.DataBrokerImpl; - -@Deprecated -public class DomBrokerRuntimeMXBeanImpl implements - DomBrokerImplRuntimeMXBean { - - private final DataBrokerImpl dataService; - private final Transactions transactions = new Transactions(); - private final Data data = new Data(); - - public DomBrokerRuntimeMXBeanImpl(DataBrokerImpl dataService) { - this.dataService = dataService; - } - - public Transactions getTransactions() { - transactions.setCreated(dataService.getCreatedTransactionsCount().get()); - transactions.setSubmitted(dataService.getSubmittedTransactionsCount().get()); - transactions.setSuccessful(dataService.getFinishedTransactionsCount().get()); - transactions.setFailed(dataService.getFailedTransactionsCount().get()); - return transactions; - } - - @Override - public Data getData() { - transactions.setCreated(dataService.getCreatedTransactionsCount().get()); - transactions.setSubmitted(dataService.getSubmittedTransactionsCount().get()); - transactions.setSuccessful(dataService.getFinishedTransactionsCount().get()); - transactions.setFailed(dataService.getFailedTransactionsCount().get()); - data.setTransactions(transactions); - return data; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerImpl.java deleted file mode 100644 index fb5e438571..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataBrokerImpl.java +++ /dev/null @@ -1,23 +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.md.sal.dom.broker.impl; - -import com.google.common.util.concurrent.ListeningExecutorService; -import java.util.Map; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.core.spi.data.DOMStore; - -/** - * @deprecated Compatibility wrapper around {@link SerializedDOMDataBroker}. - */ -@Deprecated -public final class DOMDataBrokerImpl extends SerializedDOMDataBroker { - public DOMDataBrokerImpl(final Map datastores, final ListeningExecutorService executor) { - super(datastores, executor); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleDataBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleDataBroker.java deleted file mode 100644 index 2d715e3485..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleDataBroker.java +++ /dev/null @@ -1,168 +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.md.sal.dom.broker.impl.compat; - -import javax.annotation.concurrent.ThreadSafe; -import org.opendaylight.controller.md.sal.common.api.RegistrationListener; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration; -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.sal.common.DataStoreIdentifier; -import org.opendaylight.controller.sal.core.api.data.DataChangeListener; -import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.core.api.data.DataProviderService; -import org.opendaylight.controller.sal.core.api.data.DataValidator; -import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.Registration; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; - -@Deprecated -@ThreadSafe -public class BackwardsCompatibleDataBroker implements DataProviderService { - - private final DOMDataBroker backingBroker; - private volatile DataNormalizer normalizer; - private final ListenerRegistration schemaReg; - - public BackwardsCompatibleDataBroker(final DOMDataBroker newBiDataImpl, final SchemaService schemaService) { - backingBroker = newBiDataImpl; - schemaReg = schemaService.registerSchemaContextListener(new SchemaListener()); - } - - @Override - public CompositeNode readConfigurationData(final YangInstanceIdentifier legacyPath) { - final BackwardsCompatibleTransaction tx = BackwardsCompatibleTransaction.readOnlyTransaction(backingBroker.newReadOnlyTransaction(),normalizer); - try { - return tx.readConfigurationData(legacyPath); - } finally { - tx.commit(); - } - } - - @Override - public CompositeNode readOperationalData(final YangInstanceIdentifier legacyPath) { - final BackwardsCompatibleTransaction tx = BackwardsCompatibleTransaction.readOnlyTransaction(backingBroker.newReadOnlyTransaction(),normalizer); - try { - return tx.readOperationalData(legacyPath); - } finally { - tx.commit(); - } - } - - @Override - public DataModificationTransaction beginTransaction() { - return BackwardsCompatibleTransaction.readWriteTransaction(backingBroker.newReadWriteTransaction(), normalizer); - } - - @Override - public ListenerRegistration registerDataChangeListener(final YangInstanceIdentifier legacyPath, - final DataChangeListener listener) { - final YangInstanceIdentifier normalizedPath = normalizer.toNormalized(legacyPath); - - final TranslatingListenerInvoker translatingCfgListener = - TranslatingListenerInvoker.createConfig(listener, normalizer); - translatingCfgListener.register(backingBroker, normalizedPath); - - final TranslatingListenerInvoker translatingOpListener = - TranslatingListenerInvoker.createOperational(listener, normalizer); - translatingOpListener.register(backingBroker, normalizedPath); - - return new DelegateListenerRegistration(translatingCfgListener, translatingOpListener, listener); - } - - @Override - public Registration registerCommitHandler( - final YangInstanceIdentifier path, final DataCommitHandler commitHandler) { - // FIXME Do real forwarding - return new AbstractObjectRegistration>(commitHandler) { - @Override - protected void removeRegistration() { - // NOOP - } - }; - } - - @Override - public ListenerRegistration>> registerCommitHandlerListener( - final RegistrationListener> commitHandlerListener) { - return null; - } - - // Obsolete functionality - - @Override - public void addValidator(final DataStoreIdentifier store, final DataValidator validator) { - throw new UnsupportedOperationException(); - } - - @Override - public void removeValidator(final DataStoreIdentifier store, final DataValidator validator) { - throw new UnsupportedOperationException(); - } - - @Override - public void addRefresher(final DataStoreIdentifier store, final DataRefresher refresher) { - throw new UnsupportedOperationException(); - } - - @Override - public void removeRefresher(final DataStoreIdentifier store, final DataRefresher refresher) { - throw new UnsupportedOperationException(); - } - - @Override - public Registration registerConfigurationReader( - final YangInstanceIdentifier path, final DataReader reader) { - throw new UnsupportedOperationException("Data Reader contract is not supported."); - } - - @Override - public Registration registerOperationalReader( - final YangInstanceIdentifier path, final DataReader reader) { - throw new UnsupportedOperationException("Data Reader contract is not supported."); - } - - private static class DelegateListenerRegistration implements ListenerRegistration { - private final TranslatingListenerInvoker translatingCfgListener; - private final TranslatingListenerInvoker translatingOpListener; - private final DataChangeListener listener; - - public DelegateListenerRegistration(final TranslatingListenerInvoker translatingCfgListener, final TranslatingListenerInvoker translatingOpListener, final DataChangeListener listener) { - this.translatingCfgListener = translatingCfgListener; - this.translatingOpListener = translatingOpListener; - this.listener = listener; - } - - @Override - public void close() { - translatingCfgListener.close(); - translatingOpListener.close(); - } - - @Override - public DataChangeListener getInstance() { - return listener; - } - } - - private class SchemaListener implements SchemaContextListener { - - @Override - public void onGlobalContextUpdated(final SchemaContext ctx) { - normalizer = new DataNormalizer(ctx); - } - - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java deleted file mode 100644 index c35fe82750..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java +++ /dev/null @@ -1,265 +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.md.sal.dom.broker.impl.compat; - -import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; -import org.opendaylight.yangtools.concepts.Delegator; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public abstract class BackwardsCompatibleTransaction implements DataModificationTransaction, Delegator { - - private static final Logger LOG = LoggerFactory.getLogger(BackwardsCompatibleTransaction.class); - - private final T asyncTx; - private final DataNormalizer normalizer; - - protected BackwardsCompatibleTransaction(final T asyncTx, final DataNormalizer normalizer) { - super(); - this.asyncTx = asyncTx; - this.normalizer = normalizer; - } - - public static BackwardsCompatibleTransaction readOnlyTransaction(final DOMDataReadOnlyTransaction readTx, - final DataNormalizer normalizer) { - - return new BackwardsCompatibleTransaction(readTx, normalizer) { - - @Override - public TransactionStatus getStatus() { - return TransactionStatus.NEW; - } - - @Override - public Future> commit() { - getDelegate().close(); - return null; - } - }; - } - - public static BackwardsCompatibleTransaction readWriteTransaction(final DOMDataReadWriteTransaction rwTx, - final DataNormalizer normalizer) { - return new ReadWriteTransaction(rwTx, normalizer); - } - - protected DataNormalizer getNormalizer() { - return normalizer; - } - - @Override - public T getDelegate() { - return asyncTx; - }; - - @Override - public CompositeNode readConfigurationData(final YangInstanceIdentifier legacyPath) { - - YangInstanceIdentifier normalizedPath = normalizer.toNormalized(legacyPath); - - ListenableFuture>> normalizedData = asyncTx.read( - LogicalDatastoreType.CONFIGURATION, normalizedPath); - - try { - return normalizer.toLegacy(normalizedPath, normalizedData.get().orNull()); - } catch (InterruptedException | ExecutionException e) { - return null; - } - } - - @Override - public CompositeNode readOperationalData(final YangInstanceIdentifier legacyPath) { - YangInstanceIdentifier normalizedPath = normalizer.toNormalized(legacyPath); - - ListenableFuture>> normalizedData = asyncTx.read( - LogicalDatastoreType.OPERATIONAL, normalizedPath); - - try { - return normalizer.toLegacy(normalizedPath, normalizedData.get().orNull()); - } catch (InterruptedException | ExecutionException e) { - return null; - } - } - - @Override - public ListenerRegistration registerListener(final DataTransactionListener listener) { - throw new UnsupportedOperationException(); - } - - @Override - public Map getCreatedConfigurationData() { - return Collections.emptyMap(); - } - - @Override - public Map getCreatedOperationalData() { - return Collections.emptyMap(); - } - - @Override - public Map getOriginalConfigurationData() { - return Collections.emptyMap(); - } - - @Override - public Map getOriginalOperationalData() { - return Collections.emptyMap(); - } - - @Override - public Set getRemovedConfigurationData() { - return Collections.emptySet(); - } - - @Override - public Set getRemovedOperationalData() { - return Collections.emptySet(); - } - - @Override - public Map getUpdatedConfigurationData() { - return Collections.emptyMap(); - } - - @Override - public Map getUpdatedOperationalData() { - return Collections.emptyMap(); - } - - @Override - public void putConfigurationData(final YangInstanceIdentifier path, final CompositeNode data) { - throw new UnsupportedOperationException(); - } - - @Override - public void putOperationalData(final YangInstanceIdentifier path, final CompositeNode data) { - throw new UnsupportedOperationException(); - } - - @Override - public void removeConfigurationData(final YangInstanceIdentifier path) { - throw new UnsupportedOperationException(); - } - - @Override - public void removeOperationalData(final YangInstanceIdentifier path) { - throw new UnsupportedOperationException(); - } - - @Override - public Object getIdentifier() { - return asyncTx.getIdentifier(); - } - - private static final class ReadWriteTransaction extends BackwardsCompatibleTransaction { - - private TransactionStatus status = TransactionStatus.NEW; - - protected ReadWriteTransaction(final DOMDataReadWriteTransaction asyncTx, final DataNormalizer normalizer) { - super(asyncTx, normalizer); - } - - @Override - public TransactionStatus getStatus() { - return status; - } - - @Override - public Future> commit() { - Preconditions.checkState(status == TransactionStatus.NEW); - status = TransactionStatus.SUBMITED; - return AbstractDataTransaction.convertToLegacyCommitFuture(getDelegate().submit()); - } - - @Override - public void putConfigurationData(final YangInstanceIdentifier legacyPath, final CompositeNode legacyData) { - checkNotNull(legacyPath, "Path MUST NOT be null."); - checkNotNull(legacyData, "Data for path %s MUST NOT be null",legacyData); - Entry> normalizedData = getNormalizer().toNormalized(legacyPath, legacyData); - putWithEnsuredParents(LogicalDatastoreType.CONFIGURATION, normalizedData.getKey(), normalizedData.getValue()); - } - - @Override - public void putOperationalData(final YangInstanceIdentifier legacyPath, final CompositeNode legacyData) { - checkNotNull(legacyPath, "Path MUST NOT be null."); - checkNotNull(legacyData, "Data for path %s MUST NOT be null",legacyData); - Entry> normalizedData = getNormalizer().toNormalized(legacyPath, legacyData); - putWithEnsuredParents(LogicalDatastoreType.OPERATIONAL, normalizedData.getKey(), normalizedData.getValue()); - } - - private void putWithEnsuredParents(final LogicalDatastoreType store, final YangInstanceIdentifier normalizedPath, - final NormalizedNode normalizedData) { - - LOG.trace("write {}:{} ",store,normalizedPath); - try { - List currentArguments = new ArrayList<>(); - DataNormalizationOperation currentOp = getNormalizer().getRootOperation(); - Iterator iterator = normalizedPath.getPathArguments().iterator(); - while(iterator.hasNext()) { - PathArgument currentArg = iterator.next(); - try { - currentOp = currentOp.getChild(currentArg); - } catch (DataNormalizationException e) { - throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", normalizedPath), e); - } - currentArguments.add(currentArg); - YangInstanceIdentifier currentPath = YangInstanceIdentifier.create(currentArguments); - boolean isPresent = getDelegate().read(store, currentPath).get().isPresent(); - if(isPresent == false && iterator.hasNext()) { - getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg)); - } - } - } catch (InterruptedException | ExecutionException e) { - LOG.error("Exception durring read.",e); - } - - getDelegate().put(store, normalizedPath, normalizedData); - } - - @Override - public void removeConfigurationData(final YangInstanceIdentifier legacyPath) { - checkNotNull(legacyPath, "Path MUST NOT be null."); - getDelegate().delete(LogicalDatastoreType.CONFIGURATION, getNormalizer().toNormalized(legacyPath)); - } - - @Override - public void removeOperationalData(final YangInstanceIdentifier legacyPath) { - checkNotNull(legacyPath, "Path MUST NOT be null."); - getDelegate().delete(LogicalDatastoreType.OPERATIONAL, getNormalizer().toNormalized(legacyPath)); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingDataChangeEvent.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingDataChangeEvent.java deleted file mode 100644 index 309748526d..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingDataChangeEvent.java +++ /dev/null @@ -1,230 +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.md.sal.dom.broker.impl.compat; - -import com.google.common.collect.Maps; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated -public abstract class TranslatingDataChangeEvent implements DataChangeEvent { - - private TranslatingDataChangeEvent() { - } - - public static DataChangeEvent createOperational( - final AsyncDataChangeEvent> change, final DataNormalizer normalizer) { - return new OperationalChangeEvent(change, normalizer); - } - - public static DataChangeEvent createConfiguration( - final AsyncDataChangeEvent> change, final DataNormalizer normalizer) { - return new ConfigurationChangeEvent(change, normalizer); - } - - @Override - public Map getCreatedOperationalData() { - return Collections.emptyMap(); - } - - @Override - public Map getCreatedConfigurationData() { - return Collections.emptyMap(); - } - - @Override - public Map getUpdatedOperationalData() { - return Collections.emptyMap(); - } - - @Override - public Map getUpdatedConfigurationData() { - return Collections.emptyMap(); - } - - @Override - public Set getRemovedConfigurationData() { - return Collections.emptySet(); - } - - @Override - public Set getRemovedOperationalData() { - return Collections.emptySet(); - } - - @Override - public Map getOriginalConfigurationData() { - return Collections.emptyMap(); - } - - @Override - public Map getOriginalOperationalData() { - return Collections.emptyMap(); - } - - @Override - public CompositeNode getOriginalConfigurationSubtree() { - return null; - } - - @Override - public CompositeNode getOriginalOperationalSubtree() { - return null; - } - - @Override - public CompositeNode getUpdatedConfigurationSubtree() { - return null; - } - - @Override - public CompositeNode getUpdatedOperationalSubtree() { - return null; - } - - private final static class OperationalChangeEvent extends TranslatingDataChangeEvent { - - private final AsyncDataChangeEvent> delegate; - private final DataNormalizer normalizer; - private Map updatedCache; - - public OperationalChangeEvent(final AsyncDataChangeEvent> change, - final DataNormalizer normalizer) { - this.delegate = change; - this.normalizer = normalizer; - } - - @Override - public Map getCreatedOperationalData() { - return transformToLegacy(normalizer, delegate.getCreatedData()); - } - - - @Override - public Set getRemovedOperationalData() { - return delegate.getRemovedPaths(); - } - - @Override - public CompositeNode getOriginalOperationalSubtree() { - // first argument is unused - return normalizer.toLegacy(null, delegate.getOriginalSubtree()); - } - - @Override - public CompositeNode getUpdatedOperationalSubtree() { - // first argument is unused - return normalizer.toLegacy(null, delegate.getUpdatedSubtree()); - } - - @Override - public Map getOriginalOperationalData() { - return transformToLegacy(normalizer, delegate.getOriginalData()); - } - - @Override - public Map getUpdatedOperationalData() { - if(updatedCache == null) { - final Map updated = transformToLegacy(normalizer, delegate.getUpdatedData()); - final Map created = getCreatedConfigurationData(); - final HashMap updatedComposite = new HashMap<>(created.size() + updated.size()); - updatedComposite.putAll(created); - updatedComposite.putAll(updated); - updatedCache = Collections.unmodifiableMap(updatedComposite); - } - return updatedCache; - } - - @Override - public String toString() { - return "OperationalChangeEvent [delegate=" + delegate + "]"; - } - - } - - private static Map transformToLegacy(final DataNormalizer normalizer, final Map> nodes) { - final Map legacy = Maps.newHashMap(); - - for (final Map.Entry> entry : nodes.entrySet()) { - try { - legacy.put(normalizer.toLegacy(entry.getKey()), normalizer.toLegacy(entry.getKey(), entry.getValue())); - } catch (final DataNormalizationException e) { - throw new IllegalStateException("Unable to transform data change event to legacy format", e); - } - } - return legacy; - } - - private final static class ConfigurationChangeEvent extends TranslatingDataChangeEvent { - - private final AsyncDataChangeEvent> delegate; - private final DataNormalizer normalizer; - private Map updatedCache; - - public ConfigurationChangeEvent(final AsyncDataChangeEvent> change, - final DataNormalizer normalizer) { - this.delegate = change; - this.normalizer = normalizer; - } - - @Override - public Map getCreatedConfigurationData() { - return transformToLegacy(normalizer, delegate.getCreatedData()); - } - - - @Override - public Set getRemovedConfigurationData() { - return delegate.getRemovedPaths(); - } - - @Override - public CompositeNode getOriginalConfigurationSubtree() { - // first argument is unused - return normalizer.toLegacy(null, delegate.getOriginalSubtree()); - } - - @Override - public CompositeNode getUpdatedConfigurationSubtree() { - // first argument is unused - return normalizer.toLegacy(null, delegate.getUpdatedSubtree()); - } - - @Override - public Map getOriginalConfigurationData() { - return transformToLegacy(normalizer, delegate.getOriginalData()); - } - - @Override - public Map getUpdatedConfigurationData() { - if(updatedCache == null) { - final Map updated = transformToLegacy(normalizer, delegate.getUpdatedData()); - final Map created = getCreatedConfigurationData(); - final HashMap updatedComposite = new HashMap<>(created.size() + updated.size()); - updatedComposite.putAll(created); - updatedComposite.putAll(updated); - updatedCache = Collections.unmodifiableMap(updatedComposite); - } - return updatedCache; - } - - @Override - public String toString() { - return "ConfigurationChangeEvent [delegate=" + delegate + "]"; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingListenerInvoker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingListenerInvoker.java deleted file mode 100644 index 7bcd02ed68..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/TranslatingListenerInvoker.java +++ /dev/null @@ -1,107 +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.md.sal.dom.broker.impl.compat; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; -import org.opendaylight.controller.sal.core.api.data.DataChangeListener; -import org.opendaylight.yangtools.concepts.Delegator; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -@Deprecated -abstract class TranslatingListenerInvoker implements AutoCloseable, DOMDataChangeListener, Delegator { - - private final DataChangeListener delegate; - private final DataNormalizer normalizer; - protected ListenerRegistration reg; - - protected TranslatingListenerInvoker(final DataChangeListener listener, final DataNormalizer normalizer) { - this.delegate = listener; - this.normalizer = normalizer; - } - - static TranslatingListenerInvoker createConfig(final DataChangeListener listener, final DataNormalizer normalizer) { - return new TranslatingConfigListenerInvoker(listener, normalizer); - } - - static TranslatingListenerInvoker createOperational(final DataChangeListener listener, final DataNormalizer normalizer) { - return new TranslatingOperationalListenerInvoker(listener, normalizer); - } - - @Override - public void onDataChanged(final AsyncDataChangeEvent> normalizedChange) { - delegate.onDataChanged(getLegacyEvent(normalizer, normalizedChange)); - } - - abstract DataChangeEvent getLegacyEvent(final DataNormalizer normalizer, - final AsyncDataChangeEvent> normalizedChange); - - @Override - public DataChangeListener getDelegate() { - return delegate; - } - - abstract void register(final DOMDataBroker backingBroker, final YangInstanceIdentifier normalizedPath); - - @Override - public void close() { - if (reg != null) { - reg.close(); - } - } - - @Override - public String toString() { - return getDelegate().getClass().getName(); - } - - static final class TranslatingConfigListenerInvoker extends TranslatingListenerInvoker { - - public TranslatingConfigListenerInvoker(final DataChangeListener listener, final DataNormalizer normalizer) { - super(listener, normalizer); - } - - @Override - DataChangeEvent getLegacyEvent(final DataNormalizer normalizer, final AsyncDataChangeEvent> normalizedChange) { - return TranslatingDataChangeEvent.createConfiguration(normalizedChange, normalizer); - } - - @Override - void register(final DOMDataBroker backingBroker, final YangInstanceIdentifier normalizedPath) { - reg = backingBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, normalizedPath, this, - AsyncDataBroker.DataChangeScope.SUBTREE); - } - } - - static final class TranslatingOperationalListenerInvoker extends TranslatingListenerInvoker { - - public TranslatingOperationalListenerInvoker(final DataChangeListener listener, final DataNormalizer normalizer) { - super(listener, normalizer); - } - - @Override - DataChangeEvent getLegacyEvent(final DataNormalizer normalizer, final AsyncDataChangeEvent> normalizedChange) { - return TranslatingDataChangeEvent.createOperational(normalizedChange, normalizer); - } - - @Override - void register(final DOMDataBroker backingBroker, final YangInstanceIdentifier normalizedPath) { - reg = backingBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, normalizedPath, this, - AsyncDataBroker.DataChangeScope.SUBTREE); - } - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPoint.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPoint.java deleted file mode 100644 index 9e1134ece2..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPoint.java +++ /dev/null @@ -1,590 +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.sal.dom.broker; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.Iterables; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.JdkFutureAdapters; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import javax.annotation.Nullable; -import org.opendaylight.controller.md.sal.common.api.RegistrationListener; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration; -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.md.sal.common.impl.ListenerRegistry; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; -import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker; -import org.opendaylight.controller.sal.common.DataStoreIdentifier; -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; -import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; -import org.opendaylight.controller.sal.core.api.RpcRoutingContext; -import org.opendaylight.controller.sal.core.api.data.DataChangeListener; -import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.core.api.data.DataProviderService; -import org.opendaylight.controller.sal.core.api.data.DataValidator; -import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; -import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; -import org.opendaylight.controller.sal.dom.broker.impl.NotificationRouterImpl; -import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker; -import org.opendaylight.controller.sal.dom.broker.spi.NotificationRouter; -import org.opendaylight.controller.sal.dom.broker.util.ProxySchemaContext; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.Registration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; -import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; - -@Deprecated -public class BackwardsCompatibleMountPoint implements MountProvisionInstance, SchemaContextProvider, SchemaService { - - private final DataProviderService dataReader; - private final DataReader readWrapper; - - private final YangInstanceIdentifier mountPath; - private final NotificationPublishService notificationPublishService; - private final RpcProvisionRegistry rpcs; - - private final ListenerRegistry schemaListenerRegistry = new ListenerRegistry<>(); - - private SchemaContext schemaContext; - - public BackwardsCompatibleMountPoint(final YangInstanceIdentifier path, final DOMMountPointService.DOMMountPointBuilder mountPointBuilder) { - this.mountPath = Preconditions.checkNotNull(path); - Preconditions.checkNotNull(mountPointBuilder); - - dataReader = new DataBrokerImpl(); - readWrapper = new ReadWrapper(); - notificationPublishService = new DelgatingNotificationPublishService(); - rpcs = new SchemaAwareRpcBroker(path.toString(), this); - - mountPointBuilder.addService(DOMDataBroker.class, new BackwardsCompatibleDomStore(dataReader, this)); - mountPointBuilder.addService(NotificationPublishService.class, notificationPublishService); - mountPointBuilder.addService(RpcProvisionRegistry.class, rpcs); - - mountPointBuilder.addInitialSchemaContext(new ProxySchemaContext(this)); - - mountPointBuilder.register(); - } - - public BackwardsCompatibleMountPoint(final YangInstanceIdentifier path, final DOMMountPoint mount) { - this.mountPath = Preconditions.checkNotNull(path); - Preconditions.checkNotNull(mount); - - final DOMDataBroker domBroker = getServiceWithCheck(mount, DOMDataBroker.class); - - this.schemaContext = mount.getSchemaContext(); - - dataReader = new BackwardsCompatibleDataBroker(domBroker, this); - - // Set schema context to provide it for BackwardsCompatibleDataBroker - if(schemaContext != null) { - setSchemaContext(schemaContext); - } - - readWrapper = new ReadWrapper(); - - notificationPublishService = getServiceWithCheck(mount, NotificationPublishService.class); - rpcs = getServiceWithCheck(mount, RpcProvisionRegistry.class); - } - - private T getServiceWithCheck(final DOMMountPoint mount, final Class type) { - final Optional serviceOptional = mount.getService(type); - Preconditions.checkArgument(serviceOptional.isPresent(), "Service {} has to be set in {}. " + - "Cannot construct backwards compatible mount wrapper without it", type, mount); - return serviceOptional.get(); - } - - @Override - public void addModule(final Module module) { - throw new UnsupportedOperationException(); - } - - @Override - public void removeModule(final Module module) { - throw new UnsupportedOperationException(); - } - - @Override - public SchemaContext getSessionContext() { - return getSchemaContext(); - } - - @Override - public SchemaContext getGlobalContext() { - return getSchemaContext(); - } - - @Override - public ListenerRegistration registerSchemaContextListener(final SchemaContextListener listener) { - return schemaListenerRegistry.register(listener); - } - - @Override - public void publish(final CompositeNode notification) { - notificationPublishService.publish(notification); - } - - @Override - public ListenerRegistration addNotificationListener(final QName notification, final NotificationListener listener) { - return notificationPublishService.addNotificationListener(notification, listener); - } - - // TODO Read wrapper is never used ... same in org.opendaylight.controller.sal.dom.broker.MountPointImpl - public DataReader getReadWrapper() { - return readWrapper; - } - - @Override - public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { - return dataReader.readConfigurationData(path); - } - - @Override - public CompositeNode readOperationalData(final YangInstanceIdentifier path) { - return dataReader.readOperationalData(path); - } - - @Override - public Registration registerOperationalReader( - final YangInstanceIdentifier path, final DataReader reader) { - return dataReader.registerOperationalReader(path, reader); - } - - @Override - public Registration registerConfigurationReader( - final YangInstanceIdentifier path, final DataReader reader) { - return dataReader.registerConfigurationReader(path, reader); - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(final QName rpcType, final RpcImplementation implementation) { - return rpcs.addRoutedRpcImplementation(rpcType, implementation); - } - - @Override - public void setRoutedRpcDefaultDelegate(final RoutedRpcDefaultImplementation defaultImplementation) { - rpcs.setRoutedRpcDefaultDelegate(defaultImplementation); - } - - @Override - public RpcRegistration addRpcImplementation(final QName rpcType, final RpcImplementation implementation) - throws IllegalArgumentException { - return rpcs.addRpcImplementation(rpcType, implementation); - } - - @Override - public Set getSupportedRpcs() { - return rpcs.getSupportedRpcs(); - } - - @Override - public ListenableFuture> invokeRpc(final QName rpc, final CompositeNode input) { - return rpcs.invokeRpc(rpc, input); - } - - @Override - public ListenerRegistration addRpcRegistrationListener(final RpcRegistrationListener listener) { - return rpcs.addRpcRegistrationListener(listener); - } - - @Override - public ListenableFuture> rpc(final QName type, final CompositeNode input) { - return rpcs.invokeRpc(type, input); - } - - @Override - public DataModificationTransaction beginTransaction() { - return dataReader.beginTransaction(); - } - - @Override - public ListenerRegistration registerDataChangeListener(final YangInstanceIdentifier path, - final DataChangeListener listener) { - return dataReader.registerDataChangeListener(path, listener); - } - - @Override - public Registration registerCommitHandler( - final YangInstanceIdentifier path, final DataCommitHandler commitHandler) { - return dataReader.registerCommitHandler(path, commitHandler); - } - - @Override - public void removeRefresher(final DataStoreIdentifier store, final DataRefresher refresher) { - // NOOP - } - - @Override - public void addRefresher(final DataStoreIdentifier store, final DataRefresher refresher) { - // NOOP - } - - @Override - public void addValidator(final DataStoreIdentifier store, final DataValidator validator) { - // NOOP - } - @Override - public void removeValidator(final DataStoreIdentifier store, final DataValidator validator) { - // NOOP - } - - @Override - public SchemaContext getSchemaContext() { - return schemaContext; - } - - @Override - public void setSchemaContext(final SchemaContext schemaContext) { - this.schemaContext = schemaContext; - for (ListenerRegistration schemaServiceListenerListenerRegistration : schemaListenerRegistry.getListeners()) { - schemaServiceListenerListenerRegistration.getInstance().onGlobalContextUpdated(schemaContext); - } - } - - class ReadWrapper implements DataReader { - private YangInstanceIdentifier shortenPath(final YangInstanceIdentifier path) { - if (!mountPath.contains(path)) { - return null; - } - return YangInstanceIdentifier.create(Iterables.skip(path.getPathArguments(), Iterables.size(mountPath.getPathArguments()))); - } - - @Override - public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { - final YangInstanceIdentifier newPath = shortenPath(path); - if(newPath == null) { - return null; - } - return BackwardsCompatibleMountPoint.this.readConfigurationData(newPath); - } - - @Override - public CompositeNode readOperationalData(final YangInstanceIdentifier path) { - final YangInstanceIdentifier newPath = shortenPath(path); - if(newPath == null) { - return null; - } - return BackwardsCompatibleMountPoint.this.readOperationalData(newPath); - } - } - - @Override - public ListenerRegistration>> registerCommitHandlerListener( - final RegistrationListener> commitHandlerListener) { - return dataReader.registerCommitHandlerListener(commitHandlerListener); - } - - @Override - public > ListenerRegistration registerRouteChangeListener( - final L listener) { - return rpcs.registerRouteChangeListener(listener); - } - - @VisibleForTesting - static final class BackwardsCompatibleDomStore implements DOMDataBroker { - private final DataProviderService dataReader; - private final SchemaContextProvider schemaContextProvider; - - public BackwardsCompatibleDomStore(final DataProviderService dataReader, final SchemaContextProvider schemaContextProvider) { - this.dataReader = dataReader; - this.schemaContextProvider = schemaContextProvider; - } - - @Override - public DOMDataReadOnlyTransaction newReadOnlyTransaction() { - final DataNormalizer dataNormalizer = new DataNormalizer(schemaContextProvider.getSchemaContext()); - return new BackwardsCompatibleReadTransaction(dataReader, dataNormalizer); - } - - @Override - public DOMDataWriteTransaction newWriteOnlyTransaction() { - final DataNormalizer dataNormalizer = new DataNormalizer(schemaContextProvider.getSchemaContext()); - return new BackwardsCompatibleWriteTransaction(dataReader, dataNormalizer); - } - - @Override - public ListenerRegistration registerDataChangeListener(final LogicalDatastoreType store, final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) { - throw new UnsupportedOperationException("Register data listener not supported for mount point"); - } - - @Override - public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) { - throw new UnsupportedOperationException("Transaction chain not supported for mount point"); - } - - @Override - public DOMDataReadWriteTransaction newReadWriteTransaction() { - final DataNormalizer dataNormalizer = new DataNormalizer(schemaContextProvider.getSchemaContext()); - return new BackwardsCompatibleReadWriteTransaction(dataReader, dataNormalizer); - } - - @VisibleForTesting - static final class BackwardsCompatibleReadTransaction implements DOMDataReadOnlyTransaction { - private final DataProviderService dataReader; - private final DataNormalizer normalizer; - - public BackwardsCompatibleReadTransaction(final DataProviderService dataReader, final DataNormalizer normalizer) { - this.dataReader = dataReader; - this.normalizer = normalizer; - } - - @Override - public Object getIdentifier() { - return this; - } - - @Override - public void close() { - // NOOP - } - - @Override - public CheckedFuture>, ReadFailedException> read( - final LogicalDatastoreType store, final YangInstanceIdentifier path) { - - CompositeNode rawData = null; - - switch (store) { - case CONFIGURATION: { - rawData = dataReader.readConfigurationData(path); - break; - } - case OPERATIONAL: { - rawData = dataReader.readOperationalData(path); - break; - } - } - Preconditions.checkNotNull(rawData, "Unable to read %s data on path %s", store, path); - - final Map.Entry> normalized = normalizer.toNormalized(path, rawData); - final Optional> normalizedNodeOptional = Optional.>fromNullable(normalized.getValue()); - return Futures.immediateCheckedFuture(normalizedNodeOptional); - } - - @Override public CheckedFuture exists(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - - try { - return Futures.immediateCheckedFuture(read(store, path).get().isPresent()); - } catch (InterruptedException | ExecutionException e) { - return Futures.immediateFailedCheckedFuture(new ReadFailedException("Exists failed",e)); - } - } - } - - @VisibleForTesting - static final class BackwardsCompatibleWriteTransaction implements DOMDataWriteTransaction { - private DataModificationTransaction oldTx; - private final DataNormalizer dataNormalizer; - - public BackwardsCompatibleWriteTransaction(final DataProviderService dataReader, final DataNormalizer dataNormalizer) { - this.oldTx = dataReader.beginTransaction(); - this.dataNormalizer = dataNormalizer; - } - - @Override - public Object getIdentifier() { - return this; - } - - @Override - public boolean cancel() { - oldTx = null; - return true; - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { - final CompositeNode legacyData = dataNormalizer.toLegacy(path, data); - try { - final YangInstanceIdentifier legacyPath = dataNormalizer.toLegacy(path); - - switch (store) { - case CONFIGURATION: { - oldTx.putConfigurationData(legacyPath, legacyData); - return; - } - } - - throw new IllegalArgumentException("Cannot put data " + path + " to datastore " + store); - } catch (final DataNormalizationException e) { - throw new IllegalArgumentException(String.format("Cannot transform path %s to legacy format", path), e); - } - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { - // TODO not supported - throw new UnsupportedOperationException("Merge not supported for mount point"); - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - try { - final YangInstanceIdentifier legacyPath = dataNormalizer.toLegacy(path); - - switch (store) { - case CONFIGURATION: { - oldTx.removeConfigurationData(legacyPath); - return; - } - } - throw new IllegalArgumentException("Cannot delete data " + path + " from datastore " + store); - } catch (final DataNormalizationException e) { - throw new IllegalArgumentException(String.format("Cannot transform path %s to legacy format", path), e); - } - } - - @Override - public CheckedFuture submit() { - final ListenableFuture commitAsVoid = Futures.transform(commit(), new Function, Void>() { - @Override - public Void apply(@Nullable final RpcResult input) { - return null; - } - }); - - return Futures.makeChecked(commitAsVoid, new Function() { - @Override - public TransactionCommitFailedException apply(@Nullable final Exception input) { - return new TransactionCommitFailedException("Commit failed", input); - } - }); - } - - @Override - public ListenableFuture> commit() { - return JdkFutureAdapters.listenInPoolThread(oldTx.commit()); - } - } - - - @VisibleForTesting - static class BackwardsCompatibleReadWriteTransaction implements DOMDataReadWriteTransaction { - - private final DataProviderService dataReader; - private final DataNormalizer dataNormalizer; - private final BackwardsCompatibleWriteTransaction delegateWriteTx; - - public BackwardsCompatibleReadWriteTransaction(final DataProviderService dataReader, final DataNormalizer dataNormalizer) { - this.dataReader = dataReader; - this.dataNormalizer = dataNormalizer; - this.delegateWriteTx = new BackwardsCompatibleWriteTransaction(dataReader, dataNormalizer); - } - - @Override - public Object getIdentifier() { - return this; - } - - @Override - public CheckedFuture>, ReadFailedException> read( - final LogicalDatastoreType store, final YangInstanceIdentifier path) { - return new BackwardsCompatibleReadTransaction(dataReader, dataNormalizer).read(store, path); - } - - @Override public CheckedFuture exists(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { - - try { - return Futures.immediateCheckedFuture(read(store, path).get().isPresent()); - } catch (InterruptedException | ExecutionException e) { - return Futures.immediateFailedCheckedFuture(new ReadFailedException("Exists failed",e)); - } - } - - @Override - public boolean cancel() { - return delegateWriteTx.cancel(); - } - - @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { - delegateWriteTx.put(store, path, data); - } - - @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { - delegateWriteTx.merge(store, path, data); - } - - @Override - public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) { - delegateWriteTx.delete(store, path); - } - - @Override - public CheckedFuture submit() { - return delegateWriteTx.submit(); - } - - @Override - public ListenableFuture> commit() { - return delegateWriteTx.commit(); - } - } - } - - private class DelgatingNotificationPublishService implements NotificationPublishService { - private final NotificationRouter notificationRouter; - - public DelgatingNotificationPublishService(final NotificationRouter notificationRouter) { - this.notificationRouter = notificationRouter; - } - - private DelgatingNotificationPublishService() { - this(new NotificationRouterImpl()); - } - - @Override - public void publish(final CompositeNode notification) { - notificationRouter.publish(notification); - } - - @Override - public ListenerRegistration addNotificationListener(final QName notification, final NotificationListener listener) { - return notificationRouter.addNotificationListener(notification, listener); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManager.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManager.java deleted file mode 100644 index 389e62e11c..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManager.java +++ /dev/null @@ -1,98 +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.sal.dom.broker; - -import static com.google.common.base.Preconditions.checkState; - -import com.google.common.base.Optional; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.ListenerRegistry; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -@Deprecated -public class BackwardsCompatibleMountPointManager implements MountProvisionService, MountProvisionListener { - - private final ListenerRegistry listeners = ListenerRegistry.create(); - private final ConcurrentMap mounts = new ConcurrentHashMap<>(); - - private final DOMMountPointService domMountPointService; - - public BackwardsCompatibleMountPointManager(final DOMMountPointService domMountPointService) { - this.domMountPointService = domMountPointService; - } - - @Override - public MountProvisionInstance createMountPoint(final YangInstanceIdentifier path) { - checkState(!mounts.containsKey(path), "Mount already created"); - // Create mount point instance, wrap instance of new API with BackwardsCompatibleMountPoint to preserve backwards comatibility - final BackwardsCompatibleMountPoint mount = new BackwardsCompatibleMountPoint(path, domMountPointService.createMountPoint(path)); - mounts.put(path, mount); - return mount; - } - - public void notifyMountCreated(final YangInstanceIdentifier identifier) { - for (final ListenerRegistration listener : listeners.getListeners()) { - listener.getInstance().onMountPointCreated(identifier); - } - } - - public void notifyMountRemoved(final YangInstanceIdentifier identifier) { - for (final ListenerRegistration listener : listeners.getListeners()) { - listener.getInstance().onMountPointRemoved(identifier); - } - } - - @Override - public MountProvisionInstance createOrGetMountPoint( - final YangInstanceIdentifier path) { - final MountProvisionInstance mount = getMountPoint(path); - if (mount == null) { - return createMountPoint(path); - } - return mount; - } - - @Override - public MountProvisionInstance getMountPoint(final YangInstanceIdentifier path) { - // If the mount point was created here, return directly - if(mounts.containsKey(path)) { - return mounts.get(path); - } - - // If mount was created in underlying DOMMountService, wrap as MountProvisionInstance - final Optional mount = domMountPointService.getMountPoint(path); - if(mount.isPresent()) { - return new BackwardsCompatibleMountPoint(path, mount.get()); - } else { - return null; - } - } - - @Override - public ListenerRegistration registerProvisionListener( - final MountProvisionListener listener) { - return domMountPointService.registerProvisionListener(listener); - } - - @Override - public void onMountPointCreated(final YangInstanceIdentifier path) { - notifyMountCreated(path); - } - - @Override - public void onMountPointRemoved(final YangInstanceIdentifier path) { - notifyMountRemoved(path); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java index a200793fea..17d8229675 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java @@ -7,38 +7,38 @@ */ package org.opendaylight.controller.sal.dom.broker; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.Future; - -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.collect.ClassToInstanceMap; +import com.google.common.collect.ImmutableClassToInstanceMap; +import com.google.common.util.concurrent.CheckedFuture; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; +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.DOMRpcResult; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; +import org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.controller.sal.core.api.BrokerService; import org.opendaylight.controller.sal.core.api.Consumer; import org.opendaylight.controller.sal.core.api.Provider; -import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; -import org.opendaylight.controller.sal.core.api.RpcRoutingContext; -import org.opendaylight.controller.sal.dom.broker.spi.RpcRouter; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableClassToInstanceMap; -import com.google.common.util.concurrent.ListenableFuture; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; -public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable { +public class BrokerImpl implements Broker, DOMRpcProviderService, DOMRpcService, AutoCloseable { private final static Logger log = LoggerFactory.getLogger(BrokerImpl.class); // Broker Generic Context @@ -49,11 +49,11 @@ public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable { private AutoCloseable deactivator = null; - private RpcRouter router = null; + private DOMRpcRouter router = null; private final ClassToInstanceMap services; - public BrokerImpl(final RpcRouter router,final ClassToInstanceMap services) { + public BrokerImpl(final DOMRpcRouter router,final ClassToInstanceMap services) { this.router = Preconditions.checkNotNull(router, "RPC Router must not be null"); this.services = ImmutableClassToInstanceMap.copyOf(services); } @@ -71,11 +71,6 @@ public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable { return registerProvider(provider); } - protected Future> invokeRpcAsync(final QName rpc, - final CompositeNode input) { - return router.invokeRpc(rpc, input); - } - // Validation private void checkPredicates(final Provider prov) { Preconditions.checkNotNull(prov, "Provider should not be null."); @@ -121,48 +116,6 @@ public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable { } } - @Override - public RpcRegistration addRpcImplementation(final QName rpcType, - final RpcImplementation implementation) - throws IllegalArgumentException { - return router.addRpcImplementation(rpcType, implementation); - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation( - final QName rpcType, final RpcImplementation implementation) { - return router.addRoutedRpcImplementation(rpcType, implementation); - } - - @Override - public void setRoutedRpcDefaultDelegate( - final RoutedRpcDefaultImplementation defaultImplementation) { - router.setRoutedRpcDefaultDelegate(defaultImplementation); - } - - @Override - public ListenerRegistration addRpcRegistrationListener( - final RpcRegistrationListener listener) { - return router.addRpcRegistrationListener(listener); - } - - @Override - public > ListenerRegistration registerRouteChangeListener( - final L listener) { - return router.registerRouteChangeListener(listener); - } - - @Override - public Set getSupportedRpcs() { - return router.getSupportedRpcs(); - } - - @Override - public ListenableFuture> invokeRpc( - final QName rpc, final CompositeNode input) { - return router.invokeRpc(rpc, input); - } - /** * @return the deactivator */ @@ -181,7 +134,7 @@ public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable { /** * @return the router */ - public RpcRouter getRouter() { + public DOMRpcRouter getRouter() { return router; } @@ -189,7 +142,7 @@ public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable { * @param router * the router to set */ - public void setRouter(final RpcRouter router) { + public void setRouter(final DOMRpcRouter router) { this.router = router; } @@ -218,4 +171,28 @@ public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable { return session; } + + @Nonnull + @Override + public DOMRpcImplementationRegistration registerRpcImplementation(@Nonnull final T implementation, @Nonnull final DOMRpcIdentifier... rpcs) { + return router.registerRpcImplementation(implementation, rpcs); + } + + @Nonnull + @Override + public DOMRpcImplementationRegistration registerRpcImplementation(@Nonnull final T implementation, @Nonnull final Set rpcs) { + return router.registerRpcImplementation(implementation, rpcs); + } + + @Nonnull + @Override + public CheckedFuture invokeRpc(@Nonnull final SchemaPath type, @Nullable final NormalizedNode input) { + return router.invokeRpc(type, input); + } + + @Nonnull + @Override + public ListenerRegistration registerRpcListener(@Nonnull final T listener) { + return router.registerRpcListener(listener); + } } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java index e96b242720..721b1e5f09 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java @@ -7,24 +7,18 @@ */ package org.opendaylight.controller.sal.dom.broker; -import java.util.Collection; -import java.util.concurrent.Future; - -import javax.annotation.concurrent.GuardedBy; - +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.collect.ClassToInstanceMap; +import com.google.common.collect.MutableClassToInstanceMap; import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; import org.opendaylight.controller.sal.core.api.BrokerService; import org.opendaylight.controller.sal.core.api.Consumer; import org.opendaylight.controller.sal.dom.broker.osgi.AbstractBrokerServiceProxy; import org.opendaylight.controller.sal.dom.broker.osgi.ProxyFactory; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.MutableClassToInstanceMap; +import javax.annotation.concurrent.GuardedBy; +import java.util.Collection; class ConsumerContextImpl implements ConsumerSession { @@ -41,13 +35,6 @@ class ConsumerContextImpl implements ConsumerSession { consumer = provider; } - @Override - public Future> rpc(final QName rpc, - final CompositeNode input) { - checkNotClosed(); - return broker.invokeRpcAsync(rpc, input); - } - @Override public T getService(final Class service) { checkNotClosed(); @@ -84,6 +71,7 @@ class ConsumerContextImpl implements ConsumerSession { broker = null; } + @Override public synchronized boolean isClosed() { return closed; diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java deleted file mode 100644 index c06aefba15..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java +++ /dev/null @@ -1,90 +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.sal.dom.broker; - -import java.util.concurrent.atomic.AtomicLong; - -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker; -import org.opendaylight.controller.sal.common.DataStoreIdentifier; -import org.opendaylight.controller.sal.core.api.data.DataChangeListener; -import org.opendaylight.controller.sal.core.api.data.DataProviderService; -import org.opendaylight.controller.sal.core.api.data.DataValidator; -import org.opendaylight.controller.sal.dom.broker.impl.DataReaderRouter; -import org.opendaylight.yangtools.concepts.Registration; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -import com.google.common.util.concurrent.MoreExecutors; - -@Deprecated -public class DataBrokerImpl extends AbstractDataBroker implements - DataProviderService, AutoCloseable { - - private AtomicLong nextTransaction = new AtomicLong(); - private final AtomicLong createdTransactionsCount = new AtomicLong(); - - public DataBrokerImpl() { - setDataReadRouter(new DataReaderRouter()); - setExecutor(MoreExecutors.sameThreadExecutor()); - } - - public AtomicLong getCreatedTransactionsCount() { - return createdTransactionsCount; - } - - @Override - public DataTransactionImpl beginTransaction() { - String transactionId = "DOM-" + nextTransaction.getAndIncrement(); - createdTransactionsCount.getAndIncrement(); - return new DataTransactionImpl(transactionId,this); - } - - @Override - public Registration registerConfigurationReader( - YangInstanceIdentifier path, DataReader reader) { - return getDataReadRouter().registerConfigurationReader(path, reader); - } - - @Override - public Registration registerOperationalReader( - YangInstanceIdentifier path, DataReader reader) { - return getDataReadRouter().registerOperationalReader(path, reader); - } - - @Deprecated - @Override - public void addValidator(DataStoreIdentifier store, DataValidator validator) { - throw new UnsupportedOperationException("Deprecated"); - - } - - @Deprecated - @Override - public void removeValidator(DataStoreIdentifier store, DataValidator validator) { - throw new UnsupportedOperationException("Deprecated"); - } - - @Deprecated - @Override - public void addRefresher(DataStoreIdentifier store, DataRefresher refresher) { - throw new UnsupportedOperationException("Deprecated"); - } - - @Deprecated - @Override - public void removeRefresher(DataStoreIdentifier store, DataRefresher refresher) { - throw new UnsupportedOperationException("Deprecated"); - } - - @Override - public void close() throws Exception { - - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataTransactionImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataTransactionImpl.java deleted file mode 100644 index c229e94661..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataTransactionImpl.java +++ /dev/null @@ -1,39 +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.sal.dom.broker; - -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction; -import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.ListenerRegistry; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -@Deprecated -public class DataTransactionImpl extends AbstractDataTransaction - implements DataModificationTransaction { - private final ListenerRegistry listeners = new ListenerRegistry(); - - - - public DataTransactionImpl(Object identifier,DataBrokerImpl dataBroker) { - super(identifier,dataBroker); - } - - @Override - public ListenerRegistration registerListener(DataTransactionListener listener) { - return listeners.register(listener); - } - - protected void onStatusChange(TransactionStatus status) { - for (ListenerRegistration listenerRegistration : listeners) { - listenerRegistration.getInstance().onStatusUpdated(this, status); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java deleted file mode 100644 index 385d4009e0..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.dom.broker; - -import com.google.common.collect.Iterables; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Set; -import org.opendaylight.controller.md.sal.common.api.RegistrationListener; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration; -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.sal.common.DataStoreIdentifier; -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; -import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; -import org.opendaylight.controller.sal.core.api.RpcRoutingContext; -import org.opendaylight.controller.sal.core.api.data.DataChangeListener; -import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.core.api.data.DataValidator; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; -import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.controller.sal.dom.broker.impl.NotificationRouterImpl; -import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker; -import org.opendaylight.controller.sal.dom.broker.spi.NotificationRouter; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.Registration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; - -@Deprecated -public class MountPointImpl implements MountProvisionInstance, SchemaContextProvider { - - private final SchemaAwareRpcBroker rpcs; - private final DataBrokerImpl dataReader; - private final NotificationRouter notificationRouter; - private final DataReader readWrapper; - - - private final YangInstanceIdentifier mountPath; - - private SchemaContext schemaContext; - - public MountPointImpl(final YangInstanceIdentifier path) { - this.mountPath = path; - rpcs = new SchemaAwareRpcBroker(path.toString(),this); - dataReader = new DataBrokerImpl(); - notificationRouter = new NotificationRouterImpl(); - readWrapper = new ReadWrapper(); - } - - public YangInstanceIdentifier getMountPath() { - return mountPath; - } - - public DataReader getReadWrapper() { - return readWrapper; - } - - @Override - public void publish(final CompositeNode notification) { - notificationRouter.publish(notification); - } - - @Override - public ListenerRegistration addNotificationListener(final QName notification, final NotificationListener listener) { - return notificationRouter.addNotificationListener(notification, listener); - } - - @Override - public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { - return dataReader.readConfigurationData(path); - } - - @Override - public CompositeNode readOperationalData(final YangInstanceIdentifier path) { - return dataReader.readOperationalData(path); - } - - @Override - public Registration registerOperationalReader( - final YangInstanceIdentifier path, final DataReader reader) { - return dataReader.registerOperationalReader(path, reader); - } - - @Override - public Registration registerConfigurationReader( - final YangInstanceIdentifier path, final DataReader reader) { - return dataReader.registerConfigurationReader(path, reader); - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(final QName rpcType, final RpcImplementation implementation) { - return rpcs.addRoutedRpcImplementation(rpcType, implementation); - } - - @Override - public void setRoutedRpcDefaultDelegate(final RoutedRpcDefaultImplementation defaultImplementation) { - rpcs.setRoutedRpcDefaultDelegate(defaultImplementation); - } - - @Override - public RpcRegistration addRpcImplementation(final QName rpcType, final RpcImplementation implementation) - throws IllegalArgumentException { - return rpcs.addRpcImplementation(rpcType, implementation); - } - - @Override - public Set getSupportedRpcs() { - return rpcs.getSupportedRpcs(); - } - - @Override - public ListenableFuture> invokeRpc(final QName rpc, final CompositeNode input) { - return rpcs.invokeRpc(rpc, input); - } - - @Override - public ListenerRegistration addRpcRegistrationListener(final RpcRegistrationListener listener) { - return rpcs.addRpcRegistrationListener(listener); - } - - @Override - public ListenableFuture> rpc(final QName type, final CompositeNode input) { - return rpcs.invokeRpc( type, input ); - } - - @Override - public DataModificationTransaction beginTransaction() { - return dataReader.beginTransaction(); - } - - @Override - public ListenerRegistration registerDataChangeListener(final YangInstanceIdentifier path, - final DataChangeListener listener) { - return dataReader.registerDataChangeListener(path, listener); - } - - @Override - public Registration registerCommitHandler( - final YangInstanceIdentifier path, final DataCommitHandler commitHandler) { - return dataReader.registerCommitHandler(path, commitHandler); - } - - @Override - public void removeRefresher(final DataStoreIdentifier store, final DataRefresher refresher) { - // NOOP - } - - @Override - public void addRefresher(final DataStoreIdentifier store, final DataRefresher refresher) { - // NOOP - } - - @Override - public void addValidator(final DataStoreIdentifier store, final DataValidator validator) { - // NOOP - } - @Override - public void removeValidator(final DataStoreIdentifier store, final DataValidator validator) { - // NOOP - } - - @Override - public SchemaContext getSchemaContext() { - return schemaContext; - } - - @Override - public void setSchemaContext(final SchemaContext schemaContext) { - this.schemaContext = schemaContext; - } - - class ReadWrapper implements DataReader { - private YangInstanceIdentifier shortenPath(final YangInstanceIdentifier path) { - if (!mountPath.contains(path)) { - return null; - } - - return YangInstanceIdentifier.create(Iterables.skip(path.getPathArguments(), Iterables.size(mountPath.getPathArguments()))); - } - - @Override - public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { - YangInstanceIdentifier newPath = shortenPath(path); - if(newPath == null) { - return null; - } - return MountPointImpl.this.readConfigurationData(newPath); - } - - @Override - public CompositeNode readOperationalData(final YangInstanceIdentifier path) { - YangInstanceIdentifier newPath = shortenPath(path); - if(newPath == null) { - return null; - } - return MountPointImpl.this.readOperationalData(newPath); - } - } - - @Override - public ListenerRegistration>> registerCommitHandlerListener( - final RegistrationListener> commitHandlerListener) { - return dataReader.registerCommitHandlerListener(commitHandlerListener); - } - - @Override - public > ListenerRegistration registerRouteChangeListener( - final L listener) { - return rpcs.registerRouteChangeListener(listener); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.java deleted file mode 100644 index 434cf85bec..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.java +++ /dev/null @@ -1,91 +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.sal.dom.broker; - -import static com.google.common.base.Preconditions.checkState; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.opendaylight.controller.sal.core.api.data.DataProviderService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.ListenerRegistry; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -@Deprecated -public class MountPointManagerImpl implements MountProvisionService { - - private final ListenerRegistry listeners = - ListenerRegistry.create(); - private final ConcurrentMap mounts = - new ConcurrentHashMap<>(); - private DataProviderService dataBroker = null; - - @Override - public MountProvisionInstance createMountPoint(final YangInstanceIdentifier path) { - checkState(!mounts.containsKey(path), "Mount already created"); - final MountPointImpl mount = new MountPointImpl(path); - registerMountPoint(mount); - mounts.put(path, mount); - notifyMountCreated(path); - return mount; - } - - public void notifyMountCreated(final YangInstanceIdentifier identifier) { - for (final ListenerRegistration listener : listeners - .getListeners()) { - listener.getInstance().onMountPointCreated(identifier); - } - } - - public Object registerMountPoint(final MountPointImpl impl) { - // FIXME: Why is thie commented out? Either we need it or we don't - // dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper); - // dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper); - return null; - } - - @Override - public MountProvisionInstance createOrGetMountPoint( - final YangInstanceIdentifier path) { - final MountPointImpl mount = mounts.get(path); - if (mount == null) { - return createMountPoint(path); - } - return mount; - } - - @Override - public MountProvisionInstance getMountPoint(final YangInstanceIdentifier path) { - return mounts.get(path); - } - - /** - * @return the dataBroker - */ - public DataProviderService getDataBroker() { - return dataBroker; - } - - /** - * @param dataBroker - * the dataBroker to set - */ - public void setDataBroker(final DataProviderService dataBroker) { - this.dataBroker = dataBroker; - } - - @Override - public ListenerRegistration registerProvisionListener( - final MountProvisionListener listener) { - return listeners.register(listener); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java index b8bb279297..0c46c67948 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java @@ -7,20 +7,10 @@ */ package org.opendaylight.controller.sal.dom.broker; -import java.util.HashSet; -import java.util.Set; - import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; import org.opendaylight.controller.sal.core.api.Provider; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; class ProviderContextImpl extends ConsumerContextImpl implements ProviderSession { - private final Set registrations = new HashSet<>(); private final Provider provider; public ProviderContextImpl(final Provider provider, final BrokerImpl broker) { @@ -28,51 +18,8 @@ class ProviderContextImpl extends ConsumerContextImpl implements ProviderSession this.provider = provider; } - @Override - public RpcRegistrationWrapper addRpcImplementation(final QName rpcType, - final RpcImplementation implementation) throws IllegalArgumentException { - final RpcRegistration origReg = getBrokerChecked().getRouter() - .addRpcImplementation(rpcType, implementation); - final RpcRegistrationWrapper newReg = new RpcRegistrationWrapper( - origReg); - registrations.add(newReg); - return newReg; - } - - protected boolean removeRpcImplementation(final RpcRegistrationWrapper implToRemove) { - return registrations.remove(implToRemove); - } - @Override public void close() { - for (final RpcRegistrationWrapper reg : registrations) { - reg.close(); - } - } - - @Override - public RoutedRpcRegistration addMountedRpcImplementation( - final QName rpcType, final RpcImplementation implementation) { - throw new UnsupportedOperationException( - "TODO: auto-generated method stub"); - - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation( - final QName rpcType, final RpcImplementation implementation) { - return getBrokerChecked().getRouter().addRoutedRpcImplementation(rpcType, implementation); - } - - @Override - public Set getSupportedRpcs() { - return getBrokerChecked().getRouter().getSupportedRpcs(); - } - - @Override - public ListenerRegistration addRpcRegistrationListener( - final RpcRegistrationListener listener) { - return getBrokerChecked().getRouter().addRpcRegistrationListener(listener); } /** diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/RpcRegistrationWrapper.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/RpcRegistrationWrapper.java deleted file mode 100644 index db6c72e2ff..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/RpcRegistrationWrapper.java +++ /dev/null @@ -1,45 +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.sal.dom.broker; - -import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.yangtools.yang.common.QName; - -import com.google.common.base.Preconditions; - -public class RpcRegistrationWrapper implements RpcRegistration { - - private final RpcRegistration delegate; - - public RpcRegistrationWrapper(final RpcRegistration delegate) { - this.delegate = Preconditions.checkNotNull(delegate); - } - - @Override - public RpcImplementation getInstance() { - return delegate.getInstance(); - } - - @Override - public void close() { - delegate.close(); - } - - @Override - public QName getType() { - return delegate.getType(); - } - - /** - * @return the delegate - */ - public RpcRegistration getDelegate() { - return delegate; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.java deleted file mode 100644 index c03ae73177..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.java +++ /dev/null @@ -1,149 +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.sal.dom.broker.impl; - -import static com.google.common.base.Preconditions.checkState; - -import com.google.common.collect.Iterables; - -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; -import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class DataReaderRouter extends AbstractDataReadRouter { - private final static Logger LOG = LoggerFactory - .getLogger(DataReaderRouter.class); - private final static URI NETCONF_NAMESPACE = URI - .create("urn:ietf:params:xml:ns:netconf:base:1.0"); - private final static QName NETCONF_DATA = new QName(NETCONF_NAMESPACE, - "data"); - - @Override - protected CompositeNodeTOImpl merge(final YangInstanceIdentifier path, - final Iterable data) { - PathArgument pathArgument = Iterables.getLast(path.getPathArguments(), null); - boolean empty = true; - QName name = (pathArgument == null ? null : pathArgument.getNodeType()); - final ArrayList> nodes = new ArrayList>(); - final HashMap> keyNodes = new HashMap>(); - for (final CompositeNode dataBit : data) { - try { - if (pathArgument != null && dataBit != null) { - empty = false; - final Map> keyNodesLocal = getKeyNodes( - pathArgument, dataBit); - nodes.addAll(this.childrenWithout(dataBit, - keyNodesLocal.entrySet())); - } else if (dataBit != null) { - empty = false; - nodes.addAll(dataBit.getValue()); - } - } catch (IllegalStateException e) { - LOG.error("BUG: Readed data for path {} was invalid", path, e); - } - } - if (empty) { - return null; - } - /** - * Reading from Root - * - */ - if (pathArgument == null) { - return new CompositeNodeTOImpl(NETCONF_DATA, null, nodes); - } - final ArrayList> finalNodes = new ArrayList>( - nodes.size() + keyNodes.size()); - finalNodes.addAll(keyNodes.values()); - finalNodes.addAll(nodes); - return new CompositeNodeTOImpl(name, null, finalNodes); - } - - protected Map> _getKeyNodes( - final PathArgument argument, final CompositeNode node) { - return Collections.emptyMap(); - } - - protected Map> _getKeyNodes( - final NodeIdentifierWithPredicates argument, - final CompositeNode node) { - final HashMap> ret = new HashMap>(); - for (final Entry keyValue : argument.getKeyValues() - .entrySet()) { - final List> simpleNode = node - .getSimpleNodesByName(keyValue.getKey()); - if (simpleNode != null && !simpleNode.isEmpty()) { - checkState( - simpleNode.size() <= 1, - "Only one simple node for key $s is allowed in node $s", - keyValue.getKey(), node); - checkState( - simpleNode.get(0).getValue().equals(keyValue.getValue()), - "Key node must equal to instance identifier value in node $s", - node); - ret.put(keyValue.getKey(), simpleNode.get(0)); - } - final List compositeNode = node - .getCompositesByName(keyValue.getKey()); - checkState(compositeNode == null || compositeNode.isEmpty(), - "Key node must be Simple Node, not composite node."); - } - return ret; - } - - public Map> getKeyNodes( - final YangInstanceIdentifier.PathArgument argument, - final CompositeNode node) { - if (argument instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) { - return _getKeyNodes( - (YangInstanceIdentifier.NodeIdentifierWithPredicates) argument, - node); - } else if (argument != null) { - return _getKeyNodes(argument, node); - } else { - throw new IllegalArgumentException("Unhandled parameter types: " - + Arrays. asList(argument, node).toString()); - } - } - - private Collection> childrenWithout( - final CompositeNode node, - final Set>> entries) { - if (entries.isEmpty()) { - return node.getValue(); - } - final List> filteredNodes = new ArrayList>(); - for (final Node scannedNode : node.getValue()) { - if (!entries.contains(scannedNode.getNodeType())) { - filteredNodes.add(scannedNode); - } - } - return filteredNodes; - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/GlobalRpcRegistration.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/GlobalRpcRegistration.java deleted file mode 100644 index f63e5ea768..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/GlobalRpcRegistration.java +++ /dev/null @@ -1,38 +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.sal.dom.broker.impl; - -import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; -import org.opendaylight.yangtools.yang.common.QName; - -class GlobalRpcRegistration extends AbstractObjectRegistration implements - RpcRegistration { - private final QName type; - private SchemaAwareRpcBroker router; - - public GlobalRpcRegistration(final QName type, final RpcImplementation instance, final SchemaAwareRpcBroker router) { - super(instance); - this.type = type; - this.router = router; - } - - @Override - public QName getType() { - return type; - } - - @Override - protected void removeRegistration() { - if (router != null) { - router.remove(this); - router = null; - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/NotificationRouterImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/NotificationRouterImpl.java deleted file mode 100644 index 1e93202007..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/NotificationRouterImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.dom.broker.impl; - -import java.util.Collection; - -import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.controller.sal.dom.broker.spi.NotificationRouter; -import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; - -public class NotificationRouterImpl implements NotificationRouter { - private static Logger log = LoggerFactory.getLogger(NotificationRouterImpl.class); - - private final Multimap listeners = Multimaps.synchronizedSetMultimap(HashMultimap.create()); -// private Registration defaultListener; - - private void sendNotification(CompositeNode notification) { - final QName type = notification.getNodeType(); - final Collection toNotify = listeners.get(type); - log.trace("Publishing notification " + type); - - if ((toNotify == null) || toNotify.isEmpty()) { - log.debug("No listener registered for handling of notification {}", type); - return; - } - - for (MyListenerRegistration listener : toNotify) { - try { - // FIXME: ensure that notification is immutable - listener.getInstance().onNotification(notification); - } catch (Exception e) { - log.error("Uncaught exception in NotificationListener", e); - } - } - } - - @Override - public void publish(CompositeNode notification) { - sendNotification(notification); - } - - @Override - public ListenerRegistration addNotificationListener(QName notification, NotificationListener listener) { - MyListenerRegistration ret = new MyListenerRegistration(notification, listener); - listeners.put(notification, ret); - return ret; - } - - private class MyListenerRegistration extends AbstractListenerRegistration { - - final QName type; - - public MyListenerRegistration(QName type, NotificationListener instance) { - super(instance); - this.type = type; - } - - @Override - protected void removeRegistration() { - listeners.remove(type, this); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcRegImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcRegImpl.java deleted file mode 100644 index c2fa82b588..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcRegImpl.java +++ /dev/null @@ -1,48 +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.sal.dom.broker.impl; - -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -class RoutedRpcRegImpl extends AbstractObjectRegistration implements - RoutedRpcRegistration { - - private final QName type; - private final RoutedRpcSelector router; - - public RoutedRpcRegImpl(final QName rpcType, final RpcImplementation implementation, final RoutedRpcSelector routedRpcSelector) { - super(implementation); - this.type = rpcType; - router = routedRpcSelector; - } - - @Override - public void registerPath(final QName context, final YangInstanceIdentifier path) { - router.addPath(context, path, this); - } - - @Override - public void unregisterPath(final QName context, final YangInstanceIdentifier path) { - router.removePath(context, path, this); - } - - @Override - protected void removeRegistration() { - - } - - @Override - public QName getType() { - return type; - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcSelector.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcSelector.java deleted file mode 100644 index c8e3c0b6e0..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/RoutedRpcSelector.java +++ /dev/null @@ -1,103 +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.sal.dom.broker.impl; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.ListenableFuture; - -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy; -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.RpcRoutingContext; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -class RoutedRpcSelector implements RpcImplementation, AutoCloseable, Identifiable { - - private final RpcRoutingStrategy strategy; - private final Set supportedRpcs; - private final RpcRoutingContext identifier; - final ConcurrentMap implementations = new ConcurrentHashMap<>(); - private final SchemaAwareRpcBroker router; - - public RoutedRpcSelector(final RpcRoutingStrategy strategy, final SchemaAwareRpcBroker router) { - super(); - this.strategy = strategy; - supportedRpcs = ImmutableSet.of(strategy.getIdentifier()); - identifier = RpcRoutingContext.create(strategy.getContext(), strategy.getIdentifier()); - this.router = router; - } - - @Override - public RpcRoutingContext getIdentifier() { - return identifier; - } - - @Override - public void close() throws Exception { - - } - - @Override - public Set getSupportedRpcs() { - return supportedRpcs; - } - - public RoutedRpcRegistration addRoutedRpcImplementation(final QName rpcType, final RpcImplementation implementation) { - return new RoutedRpcRegImpl(rpcType, implementation, this); - } - - @Override - public ListenableFuture> invokeRpc(final QName rpc, final CompositeNode input) { - CompositeNode inputContainer = input.getFirstCompositeByName(QName.create(rpc,"input")); - checkArgument(inputContainer != null, "Rpc payload must contain input element"); - SimpleNode routeContainer = inputContainer.getFirstSimpleByName(strategy.getLeaf()); - checkArgument(routeContainer != null, "Leaf %s must be set with value", strategy.getLeaf()); - Object route = routeContainer.getValue(); - checkArgument(route instanceof YangInstanceIdentifier, - "The routed node %s is not an instance identifier", route); - RpcImplementation potential = null; - if (route != null) { - RoutedRpcRegImpl potentialReg = implementations.get(route); - if (potentialReg != null) { - potential = potentialReg.getInstance(); - } - } - if (potential == null) { - return router.invokeRpc(rpc, (YangInstanceIdentifier) route, input); - } else { - return potential.invokeRpc(rpc, input); - } - } - - public void addPath(final QName context, final YangInstanceIdentifier path, final RoutedRpcRegImpl routedRpcRegImpl) { - //checkArgument(strategy.getContext().equals(context),"Supplied context is not supported."); - RoutedRpcRegImpl previous = implementations.put(path, routedRpcRegImpl); - if (previous == null) { - router.notifyPathAnnouncement(context,strategy.getIdentifier(), path); - } - - } - - public void removePath(final QName context, final YangInstanceIdentifier path, final RoutedRpcRegImpl routedRpcRegImpl) { - boolean removed = implementations.remove(path, routedRpcRegImpl); - if (removed) { - router.notifyPathWithdrawal(context, strategy.getIdentifier(), path); - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java deleted file mode 100644 index 9a3cee7085..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java +++ /dev/null @@ -1,286 +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.sal.dom.broker.impl; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkState; -import com.google.common.base.Preconditions; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChange; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.md.sal.common.impl.routing.RoutingUtils; -import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy; -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; -import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.RpcImplementationUnavailableException; -import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; -import org.opendaylight.controller.sal.core.api.RpcRoutingContext; -import org.opendaylight.controller.sal.dom.broker.spi.RpcRouter; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.util.ListenerRegistry; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * RPC broker responsible for routing requests to remote systems. - */ -public class SchemaAwareRpcBroker implements RpcRouter, Identifiable, RoutedRpcDefaultImplementation { - - private static final Logger LOG = LoggerFactory.getLogger(SchemaAwareRpcBroker.class); - - - private final ListenerRegistry rpcRegistrationListeners = new ListenerRegistry<>(); - private final ListenerRegistry> routeChangeListeners = new ListenerRegistry<>(); - - - private final String identifier; - private final ConcurrentMap implementations = new ConcurrentHashMap<>(); - private RpcImplementation defaultImplementation; - private SchemaContextProvider schemaProvider; - private RoutedRpcDefaultImplementation defaultDelegate; - - public SchemaAwareRpcBroker(final String identifier, final SchemaContextProvider schemaProvider) { - super(); - this.identifier = identifier; - this.schemaProvider = schemaProvider; - } - - public RpcImplementation getDefaultImplementation() { - return defaultImplementation; - } - - public void setDefaultImplementation(final RpcImplementation defaultImplementation) { - this.defaultImplementation = defaultImplementation; - } - - public SchemaContextProvider getSchemaProvider() { - return schemaProvider; - } - - public void setSchemaProvider(final SchemaContextProvider schemaProvider) { - this.schemaProvider = schemaProvider; - } - - public RoutedRpcDefaultImplementation getRoutedRpcDefaultDelegate() { - return defaultDelegate; - } - - @Override - public void setRoutedRpcDefaultDelegate(final RoutedRpcDefaultImplementation defaultDelegate) { - this.defaultDelegate = defaultDelegate; - } - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(final QName rpcType, final RpcImplementation implementation) { - checkArgument(rpcType != null, "RPC Type should not be null"); - checkArgument(implementation != null, "RPC Implementatoin should not be null"); - return getOrCreateRoutedRpcRouter(rpcType).addRoutedRpcImplementation(rpcType, implementation); - } - - private RoutedRpcSelector getOrCreateRoutedRpcRouter(final QName rpcType) { - RoutedRpcSelector potential = getRoutedRpcRouter(rpcType); - if (potential != null) { - return potential; - } - synchronized (implementations) { - potential = getRoutedRpcRouter(rpcType); - if (potential != null) { - return potential; - } - RpcDefinition definition = findRpcDefinition(rpcType); - RpcRoutingStrategy strategy = RpcRoutingStrategy.from(definition); - checkState(strategy.isContextBasedRouted(), "Rpc %s is not routed.", rpcType); - potential = new RoutedRpcSelector( strategy, this); - implementations.put(rpcType, potential); - return potential; - } - } - - private RoutedRpcSelector getRoutedRpcRouter(final QName rpcType) { - RpcImplementation potential = implementations.get(rpcType); - if (potential != null) { - checkState(potential instanceof RoutedRpcSelector, "Rpc %s is not routed.", rpcType); - return (RoutedRpcSelector) potential; - } - return null; - - } - - @Override - public RpcRegistration addRpcImplementation(final QName rpcType, final RpcImplementation implementation) - throws IllegalArgumentException { - checkArgument(rpcType != null, "RPC Type should not be null"); - checkArgument(implementation != null, "RPC Implementatoin should not be null"); - checkState(!hasRpcImplementation(rpcType), "Implementation already registered"); - RpcDefinition definition = findRpcDefinition(rpcType); - checkArgument(!RpcRoutingStrategy.from(definition).isContextBasedRouted(), "RPC Type must not be content routed."); - GlobalRpcRegistration reg = new GlobalRpcRegistration(rpcType, implementation, this); - final RpcImplementation previous = implementations.putIfAbsent(rpcType, implementation); - Preconditions.checkState(previous == null, "Rpc %s is already registered.",rpcType); - notifyRpcAdded(rpcType); - return reg; - } - - private void notifyRpcAdded(final QName rpcType) { - for (ListenerRegistration listener : rpcRegistrationListeners) { - try { - listener.getInstance().onRpcImplementationAdded(rpcType); - } catch (Exception ex) { - LOG.error("Unhandled exception during invoking listener {}", listener.getInstance(), ex); - } - - } - } - - @Override - public ListenerRegistration addRpcRegistrationListener(final RpcRegistrationListener listener) { - ListenerRegistration reg = rpcRegistrationListeners.register(listener); - for (QName impl : implementations.keySet()) { - listener.onRpcImplementationAdded(impl); - } - return reg; - } - - @Override - public String getIdentifier() { - return identifier; - } - - @Override - public Set getSupportedRpcs() { - return ImmutableSet.copyOf(implementations.keySet()); - } - - @Override - public ListenableFuture> invokeRpc(final QName rpc, final CompositeNode input) { - return findRpcImplemention(rpc).invokeRpc(rpc, input); - } - - private RpcImplementation findRpcImplemention(final QName rpc) { - checkArgument(rpc != null, "Rpc name should not be null"); - RpcImplementation potentialImpl = implementations.get(rpc); - if (potentialImpl != null) { - return potentialImpl; - } - - potentialImpl = defaultImplementation; - if( potentialImpl == null ) { - throw new UnsupportedOperationException( "No implementation for this operation is available." ); - } - - return potentialImpl; - } - - private boolean hasRpcImplementation(final QName rpc) { - return implementations.containsKey(rpc); - } - - private RpcDefinition findRpcDefinition(final QName rpcType) { - checkArgument(rpcType != null, "Rpc name must be supplied."); - checkState(schemaProvider != null, "Schema Provider is not available."); - SchemaContext ctx = schemaProvider.getSchemaContext(); - checkState(ctx != null, "YANG Schema Context is not available."); - Module module = ctx.findModuleByNamespaceAndRevision(rpcType.getNamespace(), rpcType.getRevision()); - checkState(module != null, "YANG Module is not available."); - return findRpcDefinition(rpcType, module.getRpcs()); - } - - static private RpcDefinition findRpcDefinition(final QName rpcType, final Set rpcs) { - checkState(rpcs != null, "Rpc schema is not available."); - for (RpcDefinition rpc : rpcs) { - if (rpcType.equals(rpc.getQName())) { - return rpc; - } - } - throw new IllegalArgumentException("Supplied Rpc Type is not defined."); - } - - @Override - public ListenableFuture> invokeRpc(final QName rpc, final YangInstanceIdentifier route, final CompositeNode input) { - if (defaultDelegate == null) { - return Futures.immediateFailedCheckedFuture(new RpcImplementationUnavailableException("No RPC implementation found")); - } - - LOG.debug("Forwarding RPC {} path {} to delegate {}", rpc, route); - return defaultDelegate.invokeRpc(rpc, route, input); - } - - void remove(final GlobalRpcRegistration registration) { - implementations.remove(registration.getType(), registration); - } - - void notifyPathAnnouncement(final QName context, final QName identifier, final YangInstanceIdentifier path) { - RpcRoutingContext contextWrapped = RpcRoutingContext.create(context, identifier); - RouteChange change = RoutingUtils.announcementChange(contextWrapped , path); - for(ListenerRegistration> routeListener : routeChangeListeners) { - try { - routeListener.getInstance().onRouteChange(change); - } catch (Exception e) { - LOG.error("Unhandled exception during invoking onRouteChange for {}",routeListener.getInstance(),e); - } - } - - } - - void notifyPathWithdrawal(final QName context,final QName identifier, final YangInstanceIdentifier path) { - RpcRoutingContext contextWrapped = RpcRoutingContext.create(context, identifier); - RouteChange change = RoutingUtils.removalChange(contextWrapped , path); - for(ListenerRegistration> routeListener : routeChangeListeners) { - try { - routeListener.getInstance().onRouteChange(change); - } catch (Exception e) { - LOG.error("Unhandled exception during invoking onRouteChange for {}",routeListener.getInstance(),e); - } - } - } - - @Override - public > ListenerRegistration registerRouteChangeListener( - final L listener) { - ListenerRegistration reg = routeChangeListeners.registerWithType(listener); - RouteChange initial = createInitialRouteChange(); - try { - listener.onRouteChange(initial); - } catch (Exception e) { - LOG.error("Unhandled exception during sending initial route change event {} to {}",initial,listener, e); - } - return reg; - } - - private RouteChange createInitialRouteChange() { - FluentIterable rpcSelectors = FluentIterable.from(implementations.values()).filter(RoutedRpcSelector.class); - - - ImmutableMap.Builder> announcements = ImmutableMap.builder(); - ImmutableMap.Builder> removals = ImmutableMap.builder(); - for (RoutedRpcSelector routedRpcSelector : rpcSelectors) { - final RpcRoutingContext context = routedRpcSelector.getIdentifier(); - final Set paths = ImmutableSet.copyOf(routedRpcSelector.implementations.keySet()); - announcements.put(context, paths); - } - return RoutingUtils.change(announcements.build(), removals.build()); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java deleted file mode 100644 index 35b94be686..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataBrokerServiceProxy.java +++ /dev/null @@ -1,41 +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.sal.dom.broker.osgi; - -import org.opendaylight.controller.sal.core.api.data.DataBrokerService; -import org.opendaylight.controller.sal.core.api.data.DataChangeListener; -import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.osgi.framework.ServiceReference; - -@Deprecated -public class DataBrokerServiceProxy extends AbstractBrokerServiceProxy implements DataBrokerService { - - public DataBrokerServiceProxy(ServiceReference ref, DataBrokerService delegate) { - super(ref, delegate); - } - - public ListenerRegistration registerDataChangeListener(YangInstanceIdentifier path, - DataChangeListener listener) { - return addRegistration(getDelegate().registerDataChangeListener(path, listener)); - } - - public CompositeNode readConfigurationData(YangInstanceIdentifier path) { - return getDelegate().readConfigurationData(path); - } - - public CompositeNode readOperationalData(YangInstanceIdentifier path) { - return getDelegate().readOperationalData(path); - } - - public DataModificationTransaction beginTransaction() { - return getDelegate().beginTransaction(); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataProviderServiceProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataProviderServiceProxy.java deleted file mode 100644 index 21d7f44e5b..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataProviderServiceProxy.java +++ /dev/null @@ -1,96 +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.sal.dom.broker.osgi; - -import org.opendaylight.controller.md.sal.common.api.RegistrationListener; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration; -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.controller.sal.common.DataStoreIdentifier; -import org.opendaylight.controller.sal.core.api.data.DataChangeListener; -import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.core.api.data.DataProviderService; -import org.opendaylight.controller.sal.core.api.data.DataValidator; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.Registration; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.osgi.framework.ServiceReference; - -@Deprecated -public class DataProviderServiceProxy extends AbstractBrokerServiceProxy implements DataProviderService { - - public DataProviderServiceProxy(final ServiceReference ref, final DataProviderService delegate) { - super(ref, delegate); - } - - @Override - public ListenerRegistration registerDataChangeListener(final YangInstanceIdentifier path, - final DataChangeListener listener) { - return addRegistration(getDelegate().registerDataChangeListener(path, listener)); - } - - @Override - public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { - return getDelegate().readConfigurationData(path); - } - - @Override - public CompositeNode readOperationalData(final YangInstanceIdentifier path) { - return getDelegate().readOperationalData(path); - } - - @Override - public DataModificationTransaction beginTransaction() { - return getDelegate().beginTransaction(); - } - - @Override - public void addRefresher(final DataStoreIdentifier store, final DataRefresher refresher) { - getDelegate().addRefresher(store, refresher); - } - - @Override - public void addValidator(final DataStoreIdentifier store, final DataValidator validator) { - getDelegate().addValidator(store, validator); - } - - @Override - public Registration registerCommitHandler( - final YangInstanceIdentifier path, final DataCommitHandler commitHandler) { - return addRegistration(getDelegate().registerCommitHandler(path, commitHandler)); - } - - @Override - public Registration registerConfigurationReader( - final YangInstanceIdentifier path, final DataReader reader) { - return addRegistration(getDelegate().registerConfigurationReader(path, reader)); - } - - @Override - public Registration registerOperationalReader( - final YangInstanceIdentifier path, final DataReader reader) { - return addRegistration(getDelegate().registerOperationalReader(path, reader)); - } - - @Override - public void removeRefresher(final DataStoreIdentifier store, final DataRefresher refresher) { - getDelegate().removeRefresher(store, refresher); - } - - @Override - public void removeValidator(final DataStoreIdentifier store, final DataValidator validator) { - getDelegate().removeValidator(store, validator); - } - - @Override - public ListenerRegistration>> registerCommitHandlerListener( - final RegistrationListener> commitHandlerListener) { - return addRegistration(getDelegate().registerCommitHandlerListener(commitHandlerListener)); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/MountProviderServiceProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/MountProviderServiceProxy.java deleted file mode 100644 index 89f9836ecf..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/MountProviderServiceProxy.java +++ /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.sal.dom.broker.osgi; - -import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.osgi.framework.ServiceReference; - -@Deprecated -public class MountProviderServiceProxy extends AbstractBrokerServiceProxy implements MountProvisionService{ - - - public MountProviderServiceProxy(ServiceReference ref, MountProvisionService delegate) { - super(ref, delegate); - } - - @Override - public MountProvisionInstance getMountPoint(YangInstanceIdentifier path) { - return getDelegate().getMountPoint(path); - } - - @Override - public MountProvisionInstance createMountPoint(YangInstanceIdentifier path) { - return getDelegate().createMountPoint(path); - } - - @Override - public MountProvisionInstance createOrGetMountPoint(YangInstanceIdentifier path) { - return getDelegate().createOrGetMountPoint(path); - } - - @Override - public ListenerRegistration registerProvisionListener(MountProvisionListener listener) { - return getDelegate().registerProvisionListener(listener); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/NotificationPublishServiceProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/NotificationPublishServiceProxy.java deleted file mode 100644 index 72cd41b933..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/NotificationPublishServiceProxy.java +++ /dev/null @@ -1,34 +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.sal.dom.broker.osgi; - -import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.osgi.framework.ServiceReference; - -public class NotificationPublishServiceProxy extends AbstractBrokerServiceProxy implements NotificationPublishService { - - public NotificationPublishServiceProxy(ServiceReference ref, - NotificationPublishService delegate) { - super(ref, delegate); - } - - @Override - public ListenerRegistration addNotificationListener(QName notification, NotificationListener listener) { - return addRegistration(getDelegate().addNotificationListener(notification, listener)); - - } - - @Override - public void publish(CompositeNode notification) { - getDelegate().publish(notification); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/NotificationServiceProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/NotificationServiceProxy.java deleted file mode 100644 index 4da7f025b3..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/NotificationServiceProxy.java +++ /dev/null @@ -1,27 +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.sal.dom.broker.osgi; - -import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.controller.sal.core.api.notify.NotificationService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.osgi.framework.ServiceReference; - -public class NotificationServiceProxy extends AbstractBrokerServiceProxy implements - NotificationService { - - public NotificationServiceProxy(ServiceReference ref, NotificationService delegate) { - super(ref, delegate); - } - - @Override - public ListenerRegistration addNotificationListener(QName notification, NotificationListener listener) { - return addRegistration(getDelegate().addNotificationListener(notification, listener)); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java index c0eb5d55da..fdacd8b3d6 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java @@ -7,19 +7,14 @@ */ package org.opendaylight.controller.sal.dom.broker.osgi; -import java.util.Arrays; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.opendaylight.controller.sal.core.api.data.DataBrokerService; -import org.opendaylight.controller.sal.core.api.data.DataProviderService; import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; -import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; -import org.opendaylight.controller.sal.core.api.notify.NotificationService; import org.osgi.framework.ServiceReference; +import java.util.Arrays; + @SuppressWarnings("unchecked") public class ProxyFactory { @@ -31,44 +26,6 @@ public class ProxyFactory { return ((T) _createProxyImpl); } - @Deprecated - private static Object _createProxyImpl(final ServiceReference ref, - final DataBrokerService service) { - - return new DataBrokerServiceProxy( - ((ServiceReference) ref), service); - } - - @Deprecated - private static Object _createProxyImpl(final ServiceReference ref, - final DataProviderService service) { - - return new DataProviderServiceProxy( - ((ServiceReference) ref), service); - } - - private static Object _createProxyImpl(final ServiceReference ref, - final NotificationPublishService service) { - - return new NotificationPublishServiceProxy( - ((ServiceReference) ref), service); - } - - private static Object _createProxyImpl(final ServiceReference ref, - final NotificationService service) { - - return new NotificationServiceProxy( - ((ServiceReference) ref), service); - } - - @Deprecated - private static Object _createProxyImpl(final ServiceReference ref, - final MountProvisionService service) { - - return new MountProviderServiceProxy( - ((ServiceReference) ref), service); - } - private static Object _createProxyImpl(final ServiceReference ref, final DOMMountPointService service) { @@ -83,13 +40,6 @@ public class ProxyFactory { service); } - private static Object _createProxyImpl(final ServiceReference ref, - final RpcProvisionRegistry service) { - - return new RpcProvisionRegistryProxy( - ((ServiceReference) ref), service); - } - private static DOMDataBrokerProxy _createProxyImpl( final ServiceReference ref, final DOMDataBroker service) { @@ -108,20 +58,8 @@ public class ProxyFactory { if (service instanceof DOMDataBroker) { return _createProxyImpl(ref, (DOMDataBroker) service); - } else if (service instanceof RpcProvisionRegistry) { - return _createProxyImpl(ref, (RpcProvisionRegistry) service); - } else if (service instanceof DataProviderService) { - return _createProxyImpl(ref, (DataProviderService) service); - } else if (service instanceof MountProvisionService) { - return _createProxyImpl(ref, (MountProvisionService) service); - } else if (service instanceof NotificationPublishService) { - return _createProxyImpl(ref, (NotificationPublishService) service); - } else if (service instanceof DataBrokerService) { - return _createProxyImpl(ref, (DataBrokerService) service); } else if (service instanceof SchemaService) { return _createProxyImpl(ref, (SchemaService) service); - } else if (service instanceof NotificationService) { - return _createProxyImpl(ref, (NotificationService) service); } else if (service instanceof DOMMountPointService) { return _createProxyImpl(ref, (DOMMountPointService) service); } else if (service != null) { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/RpcProvisionRegistryProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/RpcProvisionRegistryProxy.java deleted file mode 100644 index 3c1901a530..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/RpcProvisionRegistryProxy.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2013 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.sal.dom.broker.osgi; - -import java.util.Set; - -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.sal.core.api.Broker; -import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; -import org.opendaylight.controller.sal.core.api.RpcRoutingContext; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.osgi.framework.ServiceReference; - -import com.google.common.util.concurrent.ListenableFuture; - -public class RpcProvisionRegistryProxy extends AbstractBrokerServiceProxy implements RpcProvisionRegistry { - - public RpcProvisionRegistryProxy(final ServiceReference ref, final RpcProvisionRegistry delegate) { - super(ref, delegate); - } - - @Override - public Broker.RpcRegistration addRpcImplementation(final QName rpcType, final RpcImplementation implementation) throws IllegalArgumentException { - return getDelegate().addRpcImplementation(rpcType, implementation); - } - - @Override - public ListenerRegistration addRpcRegistrationListener(final RpcRegistrationListener listener) { - return getDelegate().addRpcRegistrationListener(listener); - } - - @Override - public Broker.RoutedRpcRegistration addRoutedRpcImplementation(final QName rpcType, final RpcImplementation implementation) { - return getDelegate().addRoutedRpcImplementation(rpcType, implementation); - } - - @Override - public void setRoutedRpcDefaultDelegate(final RoutedRpcDefaultImplementation defaultImplementation) { - getDelegate().setRoutedRpcDefaultDelegate(defaultImplementation); - } - - @Override - public > ListenerRegistration registerRouteChangeListener(final L listener) { - return getDelegate().registerRouteChangeListener(listener); - } - - @Override - public Set getSupportedRpcs() { - return getDelegate().getSupportedRpcs(); - } - - @Override - public ListenableFuture> invokeRpc(final QName rpc, final CompositeNode input) { - return getDelegate().invokeRpc(rpc, input); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/NotificationRouter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/NotificationRouter.java deleted file mode 100644 index 2d8bd186c5..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/NotificationRouter.java +++ /dev/null @@ -1,28 +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.sal.dom.broker.spi; - -import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; - -public interface NotificationRouter { - - void publish(CompositeNode notification); - - /** - * Registers a notification listener for supplied notification type. - * - * @param notification - * @param listener - */ - ListenerRegistration addNotificationListener(QName notification, - NotificationListener listener); - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RoutedRpcProcessor.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RoutedRpcProcessor.java deleted file mode 100644 index f5e7dc99bd..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RoutedRpcProcessor.java +++ /dev/null @@ -1,27 +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.sal.dom.broker.spi; - -import java.util.Map; - -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -public interface RoutedRpcProcessor extends RpcImplementation { - - RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation); - - QName getRpcType(); - - Map getRoutes(); - - RpcImplementation getDefaultRoute(); - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RpcRouter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RpcRouter.java deleted file mode 100644 index b19dac5535..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/spi/RpcRouter.java +++ /dev/null @@ -1,29 +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.sal.dom.broker.spi; - -import java.util.Set; - -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.opendaylight.yangtools.yang.common.QName; - -public interface RpcRouter extends RpcProvisionRegistry, RpcImplementation { - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation); - - @Override - public RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation) - throws IllegalArgumentException; - - @Override - public Set getSupportedRpcs(); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang b/opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang index 989b5b5649..f06ff62722 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang +++ b/opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang @@ -43,14 +43,6 @@ module opendaylight-sal-dom-broker-impl { augment "/config:modules/config:module/config:configuration" { case dom-broker-impl { when "/config:modules/config:module/config:type = 'dom-broker-impl'"; - container data-store { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity sal:dom-data-store; - } - } - } container async-data-broker { uses config:service-ref { diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java deleted file mode 100644 index 9a45c26964..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointManagerTest.java +++ /dev/null @@ -1,137 +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.sal.dom.broker; - -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import com.google.common.base.Optional; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; -import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; -import org.opendaylight.controller.md.sal.dom.api.DOMService; -import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class BackwardsCompatibleMountPointManagerTest { - private static final Logger log = LoggerFactory.getLogger(BackwardsCompatibleMountPointManagerTest.class); - - @Mock - private DOMMountPointServiceImpl domMountPointService; - @Mock - private DOMMountPointService.DOMMountPointBuilder mountBuilder; - - private BackwardsCompatibleMountPointManager compatibleMountPointManager; - static final QName qName = QName.create("namespace", "12-12-1212", "mount"); - static final YangInstanceIdentifier id = YangInstanceIdentifier.of(qName); - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - stubMountService(); - compatibleMountPointManager = new BackwardsCompatibleMountPointManager(domMountPointService); - } - - @Test - public void testCreateMountpointAlreadyCreated() throws Exception { - compatibleMountPointManager.createMountPoint(id); - verify(domMountPointService).createMountPoint(id); - verify(mountBuilder, times(3)).addService(any(Class.class), any(DOMService.class)); - verify(mountBuilder).addInitialSchemaContext(any(SchemaContext.class)); - - try { - compatibleMountPointManager.createMountPoint(id); - } catch (final IllegalStateException e) { - log.debug("", e); - return; - } - fail("Should fail to create duplicate mount"); - } - - @Test - public void testCreateMountpointGetOrCreate() throws Exception { - compatibleMountPointManager = new BackwardsCompatibleMountPointManager(new DOMMountPointServiceImpl()); - - final MountProvisionListener listener = new MountProvisionListener() { - public int createdMounts = 0; - - @Override - public void onMountPointCreated(final YangInstanceIdentifier path) { - if(createdMounts++ > 1 ) { - fail("Only one mount point should have been created"); - } - } - - @Override - public void onMountPointRemoved(final YangInstanceIdentifier path) {} - }; - - compatibleMountPointManager.registerProvisionListener(listener); - - final MountProvisionInstance m1 = compatibleMountPointManager.createOrGetMountPoint(id); - m1.setSchemaContext(mockSchemaContext()); - compatibleMountPointManager.createOrGetMountPoint(id); - compatibleMountPointManager.createOrGetMountPoint(id); - } - - private void stubMountService() { - doReturn(mockMountPointBuilder()).when(domMountPointService).createMountPoint(any(YangInstanceIdentifier.class)); - doReturn(Optional.of(mockMountPoint())).when(domMountPointService).getMountPoint(any(YangInstanceIdentifier.class)); - } - - private DOMMountPoint mockMountPoint() { - final DOMMountPoint mock = mock(DOMMountPoint.class); - doAnswer(new Answer() { - @Override - public Object answer(final InvocationOnMock invocation) throws Throwable { - return Optional.of(mock(((Class) invocation.getArguments()[0]))); - } - }).when(mock).getService(any(Class.class)); - doReturn(mockSchemaContext()).when(mock).getSchemaContext(); - return mock; - } - - static SchemaContext mockSchemaContext() { - final SchemaContext mock = mock(SchemaContext.class); - doReturn(qName).when(mock).getQName(); - doReturn("schema").when(mock).toString(); - doReturn(mock(DataSchemaNode.class)).when(mock).getDataChildByName(any(QName.class)); - return mock; - } - - private DOMMountPointService.DOMMountPointBuilder mockMountPointBuilder() { - doReturn(mountBuilder).when(mountBuilder).addService(any(Class.class), any(DOMService.class)); - doReturn(mockObjectRegistration()).when(mountBuilder).register(); - doReturn(mountBuilder).when(mountBuilder).addInitialSchemaContext(any(SchemaContext.class)); - return mountBuilder; - } - - private ObjectRegistration mockObjectRegistration() { - return mock(ObjectRegistration.class); - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java deleted file mode 100644 index fac1c2414f..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/sal/dom/broker/BackwardsCompatibleMountPointTest.java +++ /dev/null @@ -1,154 +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.sal.dom.broker; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.AbstractMap; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; -import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; -import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; -import org.opendaylight.controller.sal.core.api.data.DataProviderService; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class BackwardsCompatibleMountPointTest { - private static final Logger log = LoggerFactory.getLogger(BackwardsCompatibleMountPointManagerTest.class); - - private static final YangInstanceIdentifier id = BackwardsCompatibleMountPointManagerTest.id; - private final NormalizedNode normalizedNode = mockNormalizedNode(); - private final CompositeNode compositeNode = mockCompositeNode(); - - @Mock - private DataProviderService oldBroker; - @Mock - private SchemaContextProvider schemaContextProvider; - @Mock - private DataModificationTransaction mockTx; - - private BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore backwardsCompatibleDomStore; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - stubSchemaProvider(); - stubOldBroker(); - backwardsCompatibleDomStore = new BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore(oldBroker, schemaContextProvider); - } - - private void stubOldBroker() { - doReturn(compositeNode).when(oldBroker).readConfigurationData(id); - doReturn(compositeNode).when(oldBroker).readOperationalData(id); - doReturn(mockTx).when(oldBroker).beginTransaction(); - doNothing().when(mockTx).putConfigurationData(id, compositeNode); - doNothing().when(mockTx).putOperationalData(id, compositeNode); - doReturn(com.google.common.util.concurrent.Futures.immediateFuture(RpcResultBuilder.success(TransactionStatus.COMMITED))).when(mockTx).commit(); - } - - private CompositeNode mockCompositeNode() { - final CompositeNode mock = mock(CompositeNode.class); - doReturn("node").when(mock).toString(); - return mock; - } - - private void stubSchemaProvider() { - doReturn(BackwardsCompatibleMountPointManagerTest.mockSchemaContext()).when(schemaContextProvider).getSchemaContext(); - } - - @Test - public void testBackwardsCompatibleBroker() throws Exception { - backwardsCompatibleDomStore.newReadOnlyTransaction(); - backwardsCompatibleDomStore.newWriteOnlyTransaction(); - backwardsCompatibleDomStore.newReadWriteTransaction(); - } - - @Test - public void testReadTransaction() throws Exception { - final BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleReadTransaction tx = - new BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleReadTransaction(oldBroker, mockNormalizer()); - - ListenableFuture>> read = tx.read(LogicalDatastoreType.CONFIGURATION, id); - assertEquals(normalizedNode, read.get().get()); - verify(oldBroker).readConfigurationData(id); - - read = tx.read(LogicalDatastoreType.OPERATIONAL, id); - assertEquals(normalizedNode, read.get().get()); - - verify(oldBroker).readOperationalData(id); - } - - @Test - public void testReadWriteTransactionOperational() throws Exception { - final BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleWriteTransaction tx = - new BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleWriteTransaction(oldBroker, mockNormalizer()); - - verify(oldBroker).beginTransaction(); - - tx.put(LogicalDatastoreType.CONFIGURATION, id, normalizedNode); - verify(mockTx).putConfigurationData(id, compositeNode); - - tx.put(LogicalDatastoreType.CONFIGURATION, id, normalizedNode); - verify(mockTx, times(2)).putConfigurationData(id, compositeNode); - - tx.commit(); - verify(mockTx).commit(); - } - - - @Test - public void testCannotPutOperational() throws Exception { - final BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleWriteTransaction tx = - new BackwardsCompatibleMountPoint.BackwardsCompatibleDomStore.BackwardsCompatibleWriteTransaction(oldBroker, mockNormalizer()); - - try { - tx.put(LogicalDatastoreType.OPERATIONAL, id, normalizedNode); - } catch (IllegalArgumentException e) { - // Cannot put operational data - log.debug("", e); - return; - } - - fail("Should fail when putting operational data"); - } - - private DataNormalizer mockNormalizer() throws DataNormalizationException { - final DataNormalizer mock = mock(DataNormalizer.class); - doReturn(new AbstractMap.SimpleEntry>(id, normalizedNode)) - .when(mock).toNormalized(any(YangInstanceIdentifier.class), any(CompositeNode.class)); - doReturn(compositeNode).when(mock).toLegacy(any(YangInstanceIdentifier.class), any(NormalizedNode.class)); - doReturn(id).when(mock).toLegacy(any(YangInstanceIdentifier.class)); - return mock; - } - - private NormalizedNode mockNormalizedNode() { - final NormalizedNode mock = mock(NormalizedNode.class); - doReturn("mockNormalizedNode").when(mock).toString(); - return mock; - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingConsumerSession.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingConsumerSession.java index ba14b0f15c..a8c2d3e5f1 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingConsumerSession.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingConsumerSession.java @@ -7,12 +7,8 @@ */ package org.opendaylight.controller.sal.core.spi; -import java.util.concurrent.Future; import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; public abstract class ForwardingConsumerSession implements ConsumerSession { @@ -33,11 +29,4 @@ public abstract class ForwardingConsumerSession implements ConsumerSession { return delegate().isClosed(); } - @Override - @Deprecated - public Future> rpc(QName arg0, CompositeNode arg1) { - return delegate().rpc(arg0, arg1); - } - - } diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingProviderSession.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingProviderSession.java index d32999791a..87cce9775c 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingProviderSession.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingProviderSession.java @@ -8,50 +8,13 @@ package org.opendaylight.controller.sal.core.spi; -import java.util.Set; -import java.util.concurrent.Future; import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; -import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; public abstract class ForwardingProviderSession implements ProviderSession { - protected abstract ProviderSession delegate(); - @Override - @Deprecated - public RoutedRpcRegistration addMountedRpcImplementation(QName arg0, RpcImplementation arg1) { - return delegate().addMountedRpcImplementation(arg0, arg1); - } - - @Override - @Deprecated - public RoutedRpcRegistration addRoutedRpcImplementation(QName arg0, RpcImplementation arg1) { - return delegate().addRoutedRpcImplementation(arg0, arg1); - } - - @Override - @Deprecated - public RpcRegistration addRpcImplementation(QName arg0, RpcImplementation arg1) - throws IllegalArgumentException { - return delegate().addRpcImplementation(arg0, arg1); - } - - @Deprecated - @Override - public ListenerRegistration addRpcRegistrationListener( - RpcRegistrationListener arg0) { - return delegate().addRpcRegistrationListener(arg0); - } - @Override public void close() { delegate().close(); @@ -62,19 +25,9 @@ public abstract class ForwardingProviderSession implements ProviderSession { return delegate().getService(arg0); } - @Override - public Set getSupportedRpcs() { - return delegate().getSupportedRpcs(); - } - @Override public boolean isClosed() { return delegate().isClosed(); } - @Override - public Future> rpc(QName arg0, CompositeNode arg1) { - return delegate().rpc(arg0, arg1); - } - } diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/api/SchemaSourceProviderFactory.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/api/SchemaSourceProviderFactory.java deleted file mode 100644 index 04c5c54184..0000000000 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/api/SchemaSourceProviderFactory.java +++ /dev/null @@ -1,16 +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.sal.connect.api; - -import org.opendaylight.controller.sal.core.api.RpcImplementation; -import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider; - -public interface SchemaSourceProviderFactory { - - SchemaSourceProvider createSourceProvider(final RpcImplementation deviceRpc); -} diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java index c7f1c6ad70..0f643789ec 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java @@ -9,7 +9,6 @@ package org.opendaylight.controller.sal.connect.netconf; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyCollectionOf; -import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -42,13 +41,11 @@ import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.opendaylight.controller.sal.connect.api.MessageTransformer; import org.opendaylight.controller.sal.connect.api.RemoteDeviceHandler; -import org.opendaylight.controller.sal.connect.api.SchemaSourceProviderFactory; import org.opendaylight.controller.sal.connect.netconf.listener.NetconfDeviceCommunicator; import org.opendaylight.controller.sal.connect.netconf.listener.NetconfSessionPreferences; import org.opendaylight.controller.sal.connect.netconf.sal.NetconfDeviceRpc; import org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil; import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; -import org.opendaylight.controller.sal.core.api.RpcImplementation; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.Module; @@ -62,7 +59,6 @@ import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource; import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration; import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry; -import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider; import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; public class NetconfDeviceTest { @@ -253,16 +249,6 @@ public class NetconfDeviceTest { return mock; } - public SchemaSourceProviderFactory getSourceProviderFactory() { - final SchemaSourceProviderFactory mock = mockClass(SchemaSourceProviderFactory.class); - - final SchemaSourceProvider schemaSourceProvider = mockClass(SchemaSourceProvider.class); - doReturn(Optional.absent()).when(schemaSourceProvider).getSchemaSource(anyString(), any(Optional.class)); - - doReturn(schemaSourceProvider).when(mock).createSourceProvider(any(RpcImplementation.class)); - return mock; - } - private static T mockClass(final Class remoteDeviceHandlerClass) { final T mock = mock(remoteDeviceHandlerClass); Mockito.doReturn(remoteDeviceHandlerClass.getSimpleName()).when(mock).toString(); diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/DocProvider.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/DocProvider.java index c07e9c78be..ca11b9ddd4 100644 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/DocProvider.java +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/DocProvider.java @@ -11,11 +11,10 @@ import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; - +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.controller.sal.core.api.Provider; import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; import org.opendaylight.controller.sal.rest.doc.impl.ApiDocGenerator; import org.opendaylight.controller.sal.rest.doc.mountpoints.MountPointSwagger; @@ -49,8 +48,8 @@ public class DocProvider implements BundleActivator, ServiceTrackerCustomizer
registration = mountService .registerProvisionListener(MountPointSwagger.getInstance()); MountPointSwagger.getInstance().setGlobalSchema(schemaService); diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java index 7e8707110f..5ed227fd91 100644 --- a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/mountpoints/MountPointSwagger.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.sal.rest.doc.mountpoints; +import com.google.common.base.Optional; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -18,9 +19,9 @@ import java.util.TreeMap; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import javax.ws.rs.core.UriInfo; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; import org.opendaylight.controller.sal.rest.doc.impl.BaseYangSwaggerGenerator; import org.opendaylight.controller.sal.rest.doc.swagger.Api; @@ -40,7 +41,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount private static final String DATASTORES_REVISION = "-"; private static final String DATASTORES_LABEL = "Datastores"; - private MountProvisionService mountService; + private DOMMountPointService mountService; private final Map instanceIdToLongId = new TreeMap<>( new Comparator() { @Override @@ -150,12 +151,12 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount return null; } - MountProvisionInstance mountPoint = mountService.getMountPoint(id); - if (mountPoint == null) { + Optional mountPoint = mountService.getMountPoint(id); + if (!mountPoint.isPresent()) { return null; } - SchemaContext context = mountPoint.getSchemaContext(); + SchemaContext context = mountPoint.get().getSchemaContext(); if (context == null) { return null; } @@ -204,7 +205,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount return api; } - public void setMountService(final MountProvisionService mountService) { + public void setMountService(final DOMMountPointService mountService) { this.mountService = mountService; } diff --git a/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java b/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java index 940b99fd99..f21766d9b0 100644 --- a/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java +++ b/opendaylight/md-sal/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java @@ -12,6 +12,7 @@ import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import com.google.common.base.Optional; import java.net.URISyntaxException; import java.util.Arrays; import java.util.HashSet; @@ -21,9 +22,9 @@ import java.util.TreeSet; import javax.ws.rs.core.UriInfo; import org.junit.Before; import org.junit.Test; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; import org.opendaylight.controller.sal.rest.doc.mountpoints.MountPointSwagger; import org.opendaylight.controller.sal.rest.doc.swagger.Api; import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration; @@ -130,11 +131,11 @@ public class MountPointSwaggerTest { SchemaContext context = helper.createMockSchemaContext(); SchemaService schemaService = helper.createMockSchemaService(context); - MountProvisionInstance mountPoint = mock(MountProvisionInstance.class); + DOMMountPoint mountPoint = mock(DOMMountPoint.class); when(mountPoint.getSchemaContext()).thenReturn(context); - MountProvisionService service = mock(MountProvisionService.class); - when(service.getMountPoint(instanceId)).thenReturn(mountPoint); + DOMMountPointService service = mock(DOMMountPointService.class); + when(service.getMountPoint(instanceId)).thenReturn(Optional.of(mountPoint)); swagger.setMountService(service); swagger.setGlobalSchema(schemaService);